/* ================================================================
   Design System - Consultorio Odontologico 2.0
   ================================================================ */

/* --- Design Tokens --- */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --success: #059669;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --info: #7c3aed;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --sidebar-bg: #0f172a;
  --sidebar-hover: #1e293b;
  --radius: 8px;
  --radius-sm: 4px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);
  --transition: 150ms ease;
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--gray-800); background: var(--gray-50); line-height: 1.5; overflow: hidden; height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Animations --- */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideInRight { from { opacity: 0; transform: translateX(100px); } to { opacity: 1; transform: translateX(0); } }
@keyframes slideOutRight { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(100px); } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ================================================================
   Layout
   ================================================================ */
.app-layout { display: flex; height: 100vh; overflow: hidden; }

/* --- Sidebar --- */
.sidebar {
  width: 240px; min-width: 240px; height: 100vh; background: var(--sidebar-bg);
  display: flex; flex-direction: column; color: var(--gray-400);
  transition: width var(--transition), min-width var(--transition); z-index: 100;
}
.sidebar-header {
  padding: 20px 16px; border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
.sidebar-header .logo-icon {
  width: 32px; height: 32px; border-radius: var(--radius); background: var(--primary);
  display: flex; align-items: center; justify-content: center; color: #fff;
  font-size: 18px; font-weight: 700; flex-shrink: 0;
}
.sidebar-header .logo-text { font-size: 15px; font-weight: 700; color: #fff; white-space: nowrap; overflow: hidden; }
.sidebar-header .logo-sub { font-size: 11px; color: var(--gray-500); white-space: nowrap; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 0; list-style: none; }
.nav-section {
  padding: 16px 16px 6px 16px; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px; color: var(--gray-500); white-space: nowrap;
}
.nav-item {
  padding: 12px 16px; color: var(--gray-400); cursor: pointer; transition: all var(--transition);
  display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 500;
  border-left: 3px solid transparent; white-space: nowrap; text-decoration: none;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.nav-item.active { background: var(--sidebar-hover); color: #fff; border-left-color: var(--primary); font-weight: 600; }
.nav-item .nav-icon { width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.nav-item .nav-icon svg { width: 18px; height: 18px; }
.nav-item .nav-label { overflow: hidden; text-overflow: ellipsis; }
.sidebar-footer {
  padding: 12px 16px; border-top: 1px solid rgba(255,255,255,0.08);
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
.sidebar-footer .user-avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--gray-600);
  display: flex; align-items: center; justify-content: center; color: #fff;
  font-size: 13px; font-weight: 600; flex-shrink: 0;
}
.sidebar-footer .user-info { flex: 1; overflow: hidden; }
.sidebar-footer .user-name { font-size: 13px; color: #fff; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-footer .user-role { font-size: 11px; color: var(--gray-500); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-footer .logout-btn {
  background: none; border: none; color: var(--gray-500); cursor: pointer; padding: 4px;
  border-radius: var(--radius-sm); transition: color var(--transition);
  display: flex; align-items: center; justify-content: center;
}
.sidebar-footer .logout-btn:hover { color: var(--danger); }

/* --- Topbar --- */
.topbar {
  background: #fff; height: 56px; min-height: 56px; border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; justify-content: space-between; padding: 0 24px; gap: 16px;
}
.topbar .topbar-title { font-size: 18px; font-weight: 700; color: var(--gray-800); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .topbar-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* --- Main Content --- */
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; background: var(--gray-50); }
.content-area { flex: 1; overflow: auto; padding: 24px; max-width: 1400px; }

/* ================================================================
   Login Page
   ================================================================ */
.login-container { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--gray-100); padding: 20px; }
.login-card { background: #fff; width: 100%; max-width: 400px; border-radius: 12px; box-shadow: var(--shadow-lg); overflow: hidden; animation: slideUp .3s ease; }
.login-header { padding: 32px 32px 20px; text-align: center; border-bottom: 1px solid var(--gray-100); }
.login-header h1 { font-size: 22px; font-weight: 700; color: var(--gray-800); margin-bottom: 4px; }
.login-header p { font-size: 13px; color: var(--gray-500); }
.login-form { padding: 32px; }
.login-form .form-group { margin-bottom: 20px; }
.login-footer { text-align: center; font-size: 12px; color: var(--gray-400); padding: 16px 32px 32px; }
.login-error { background: var(--danger-light); color: var(--danger); padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }

/* ================================================================
   Cards
   ================================================================ */
.card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--gray-100); display: flex; align-items: center; justify-content: space-between; background: var(--gray-50); min-height: 52px; }
.card-header .card-title { font-size: 15px; font-weight: 600; color: var(--gray-800); }
.card-header .card-actions { display: flex; align-items: center; gap: 8px; }
.card-body { padding: 20px; }
.card-body.no-padding { padding: 0; }

/* ================================================================
   Quick Stats
   ================================================================ */
.quick-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 24px; text-align: center; transition: box-shadow var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); }
.stat-card.clickable { cursor: pointer; }
.stat-card.clickable:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.stat-card .stat-value { font-size: 28px; font-weight: 700; color: var(--primary); }
.stat-card .stat-label { font-size: 12px; color: var(--gray-500); margin-top: 4px; }

/* ================================================================
   Forms
   ================================================================ */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--gray-700); margin-bottom: 4px; }
.form-group label .required { color: var(--danger); margin-left: 2px; }
.form-group .form-hint { font-size: 11px; color: var(--gray-500); margin-top: 4px; }
.form-group .form-error { font-size: 12px; color: var(--danger); margin-top: 4px; }
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%; padding: 8px 12px; border: 1px solid var(--gray-300); border-radius: var(--radius-sm);
  font-size: 14px; color: var(--gray-800); background: #fff; font-family: inherit; line-height: 1.5;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-group input:hover,
.form-group select:hover,
.form-group textarea:hover { border-color: var(--gray-400); }
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.15); }
.form-group input:disabled,
.form-group select:disabled,
.form-group textarea:disabled { background: var(--gray-100); color: var(--gray-500); cursor: not-allowed; }
.form-group input.input-error,
.form-group select.input-error,
.form-group textarea.input-error { border-color: var(--danger); }
.form-group input.input-error:focus,
.form-group select.input-error:focus,
.form-group textarea.input-error:focus { box-shadow: 0 0 0 3px rgba(220,38,38,0.15); }
.form-group textarea { min-height: 80px; resize: vertical; }
.form-group select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
  padding-right: 32px; cursor: pointer;
}
.form-row { display: flex; gap: 12px; }
.form-row > * { flex: 1; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }

/* ================================================================
   Buttons
   ================================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; font-size: 14px; font-weight: 500; border-radius: 6px;
  cursor: pointer; transition: all var(--transition); border: none;
  font-family: inherit; line-height: 1.5; white-space: nowrap; text-decoration: none; user-select: none;
}
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:active { background: #1e40af; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #047857; }
.btn-success:active { background: #046c4e; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-danger:active { background: #991b1b; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #b45309; }
.btn-info { background: var(--info); color: #fff; }
.btn-info:hover { background: #6d28d9; }
.btn-outline { background: #fff; border: 1px solid var(--gray-300); color: var(--gray-700); }
.btn-outline:hover { background: var(--gray-50); border-color: var(--gray-400); }
.btn-outline:active { background: var(--gray-100); }
.btn-ghost { background: transparent; color: var(--gray-600); }
.btn-ghost:hover { background: var(--gray-100); }
.btn-link { background: none; color: var(--primary); padding: 4px 8px; }
.btn-link:hover { text-decoration: underline; background: var(--primary-light); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 16px; }
.btn-block { width: 100%; display: flex; }
.btn-icon { padding: 6px; min-width: 32px; width: 32px; height: 32px; }
.btn-icon.btn-sm { padding: 4px; min-width: 24px; width: 24px; height: 24px; }
.btn-icon.btn-lg { padding: 8px; min-width: 40px; width: 40px; height: 40px; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; }
.btn-group .btn:first-child { border-radius: 6px 0 0 6px; }
.btn-group .btn:last-child { border-radius: 0 6px 6px 0; }
.btn-group .btn + .btn { border-left: 1px solid rgba(255,255,255,0.2); }
.btn-group .btn-outline + .btn-outline { border-left: 1px solid var(--gray-300); }

/* ================================================================
   Badges
   ================================================================ */
.badge {
  display: inline-flex; align-items: center; padding: 2px 8px; font-size: 11px;
  font-weight: 600; border-radius: 9999px; text-transform: uppercase;
  letter-spacing: 0.5px; white-space: nowrap; line-height: 1.6;
}
.badge .badge-dot { width: 6px; height: 6px; border-radius: 50%; margin-right: 6px; background: currentColor; }
.badge-success { background: #d1fae5; color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-info { background: var(--primary-light); color: var(--primary); }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }
.badge-purple { background: #ede9fe; color: var(--info); }

/* ================================================================
   Tables
   ================================================================ */
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table thead { position: sticky; top: 0; z-index: 10; }
.data-table th {
  padding: 10px 16px; text-align: left; font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px; color: var(--gray-500);
  background: var(--gray-50); border-bottom: 2px solid var(--gray-200); white-space: nowrap;
}
.data-table th.sortable { cursor: pointer; user-select: none; }
.data-table th.sortable:hover { color: var(--gray-700); background: var(--gray-100); }
.data-table th.sorted { color: var(--primary); }
.data-table td { padding: 10px 16px; font-size: 14px; border-bottom: 1px solid var(--gray-100); color: var(--gray-700); vertical-align: middle; }
.data-table tr:hover td { background: var(--primary-light); }
.data-table tr.clickable { cursor: pointer; }
.data-table tr.selected td { background: var(--primary-light); }
.data-table td.actions { white-space: nowrap; }
.data-table .empty-row td { text-align: center; color: var(--gray-400); padding: 32px 16px; font-size: 13px; }
.table-responsive { overflow-x: auto; }

/* ================================================================
   Modals
   ================================================================ */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 1000; animation: fadeIn .2s ease; padding: 20px; }
.modal-card { background: #fff; border-radius: 12px; box-shadow: var(--shadow-lg); min-width: 400px; max-width: 640px; max-height: 80vh; display: flex; flex-direction: column; animation: slideUp .25s ease; }
.modal-card.modal-lg { max-width: 800px; }
.modal-card.modal-sm { min-width: 300px; max-width: 400px; }
.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--gray-200); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.modal-header .modal-title { font-size: 16px; font-weight: 600; color: var(--gray-800); }
.modal-header .modal-close {
  background: none; border: none; color: var(--gray-400); cursor: pointer; padding: 4px;
  border-radius: var(--radius-sm); font-size: 20px; line-height: 1; transition: color var(--transition), background var(--transition);
  display: flex; align-items: center; justify-content: center; width: 28px; height: 28px;
}
.modal-header .modal-close:hover { color: var(--gray-700); background: var(--gray-100); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 12px 20px; border-top: 1px solid var(--gray-200); display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-shrink: 0; }

/* ================================================================
   Toasts
   ================================================================ */
.toast-container { position: fixed; top: 16px; right: 16px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast-container .toast { pointer-events: auto; }
.toast { padding: 12px 16px; border-radius: 8px; box-shadow: var(--shadow-md); display: flex; align-items: center; gap: 8px; min-width: 300px; max-width: 420px; animation: slideInRight .3s ease; font-size: 14px; }
.toast.removing { animation: slideOutRight .3s ease forwards; }
.toast .toast-icon { flex-shrink: 0; }
.toast .toast-message { flex: 1; }
.toast .toast-close { flex-shrink: 0; background: none; border: none; color: inherit; opacity: 0.5; cursor: pointer; padding: 0; font-size: 16px; line-height: 1; }
.toast .toast-close:hover { opacity: 1; }
.toast-success { background: #d1fae5; border-left: 4px solid var(--success); color: var(--success); }
.toast-error { background: var(--danger-light); border-left: 4px solid var(--danger); color: var(--danger); }
.toast-warning { background: var(--warning-light); border-left: 4px solid var(--warning); color: var(--warning); }
.toast-info { background: var(--primary-light); border-left: 4px solid var(--primary); color: var(--primary); }

/* ================================================================
   Search Bar
   ================================================================ */
.search-bar { position: relative; }
.search-bar input { width: 100%; padding: 8px 12px 8px 36px; border: 1px solid var(--gray-300); border-radius: var(--radius-sm); font-size: 14px; color: var(--gray-800); background: #fff; font-family: inherit; transition: border-color var(--transition), box-shadow var(--transition); }
.search-bar input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.15); }
.search-bar .search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--gray-400); width: 16px; height: 16px; pointer-events: none; }
.search-bar .search-clear { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); background: none; border: none; color: var(--gray-400); cursor: pointer; padding: 4px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 14px; }
.search-bar .search-clear:hover { color: var(--gray-600); background: var(--gray-100); }

/* ================================================================
   SearchSelect (Typeahead)
   ================================================================ */
.search-select { position: relative; }
.search-select input { width: 100%; padding: 8px 12px; border: 1px solid var(--gray-300); border-radius: var(--radius-sm); font-size: 14px; color: var(--gray-800); background: #fff; font-family: inherit; transition: border-color var(--transition), box-shadow var(--transition); }
.search-select input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.15); }
.search-select-dropdown { position: absolute; top: 100%; left: 0; right: 0; background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); max-height: 240px; overflow-y: auto; z-index: 500; margin-top: 4px; }
.search-select-item { padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--gray-100); transition: background var(--transition); }
.search-select-item:last-child { border-bottom: none; }
.search-select-item:hover { background: var(--gray-50); }
.search-select-item.active { background: var(--primary-light); }
.search-select-item .code { font-size: 12px; color: var(--gray-500); font-family: "SF Mono", Consolas, monospace; }
.search-select-item .name { font-size: 14px; color: var(--gray-800); }
.search-select-item .sub { font-size: 12px; color: var(--gray-500); }
.search-select-empty { padding: 16px; text-align: center; color: var(--gray-400); font-size: 13px; }

/* ================================================================
   Odontogram
   ================================================================ */
.odontogram { max-width: 700px; margin: 0 auto; user-select: none; }
.odontogram .odontogram-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.odontogram .odontogram-title { font-size: 15px; font-weight: 600; color: var(--gray-700); }
.odontogram .odontogram-legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 11px; color: var(--gray-500); }
.odontogram .odontogram-legend span { display: flex; align-items: center; gap: 4px; }
.odontogram .odontogram-legend .legend-dot { width: 10px; height: 10px; border-radius: 2px; }
.quadrant { display: inline-grid; grid-template-columns: repeat(8, 1fr); gap: 3px; margin: 4px 0; }
.tooth {
  width: 100%; aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  border-radius: 4px; cursor: pointer; border: 2px solid var(--gray-200); font-size: 11px;
  font-weight: 600; transition: all var(--transition); position: relative; background: #fff; color: var(--gray-600);
}
.tooth:hover { border-color: var(--primary); transform: scale(1.1); z-index: 2; box-shadow: var(--shadow-md); }
.tooth:active { transform: scale(0.95); }
.tooth.selected { border-color: var(--primary-dark); border-width: 3px; box-shadow: 0 0 0 3px rgba(37,99,235,0.2); }
.tooth.sound { background: #fff; color: var(--gray-600); }
.tooth.carious { background: var(--danger-light); color: var(--danger); border-color: var(--danger); }
.tooth.restored { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }
.tooth.crowned { background: var(--warning-light); color: var(--warning); border-color: var(--warning); }
.tooth.extracted { background: var(--gray-100); color: var(--gray-400); text-decoration: line-through; border-style: dashed; border-color: var(--gray-300); }
.tooth.endodontic { background: #ede9fe; color: var(--info); border-color: var(--info); }
.tooth.implants { background: rgba(124,58,237,0.1); color: var(--info); border-color: var(--info); }
.tooth.sealed { background: #d1fae5; color: var(--success); border-color: var(--success); }
.tooth .surfaces { position: absolute; bottom: 1px; left: 1px; right: 1px; display: flex; gap: 1px; justify-content: center; }
.tooth .surface-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: 0.7; }

/* ================================================================
   Tabs
   ================================================================ */
.tabs-wrapper { }
.tabs-header { display: flex; border-bottom: 2px solid var(--gray-200); gap: 0; overflow-x: auto; }
.tabs-header::-webkit-scrollbar { display: none; }
.tab-btn {
  padding: 10px 16px; font-size: 14px; color: var(--gray-500); border: none;
  border-bottom: 2px solid transparent; margin-bottom: -2px; cursor: pointer;
  background: none; font-family: inherit; font-weight: 500; transition: all var(--transition);
  white-space: nowrap; display: inline-flex; align-items: center; gap: 6px;
}
.tab-btn:hover { color: var(--gray-700); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-btn .tab-count { font-size: 11px; background: var(--gray-200); color: var(--gray-600); padding: 1px 6px; border-radius: 9999px; font-weight: 600; }
.tab-btn.active .tab-count { background: var(--primary-light); color: var(--primary); }
.tab-content { overflow: auto; }

/* ================================================================
   Tooth Detail Panel
   ================================================================ */
.tooth-detail-panel { width: 320px; min-width: 320px; background: #fff; border-left: 1px solid var(--gray-200); display: flex; flex-direction: column; height: 100%; overflow: hidden; box-shadow: var(--shadow); }
.tooth-detail-panel .panel-header { padding: 16px; border-bottom: 1px solid var(--gray-200); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.tooth-detail-panel .panel-header .panel-title { font-size: 14px; font-weight: 600; color: var(--gray-700); }
.tooth-detail-panel .panel-body { flex: 1; overflow-y: auto; }
.tooth-info { text-align: center; padding: 12px; border-bottom: 1px solid var(--gray-100); }
.tooth-info .tooth-number { font-size: 32px; font-weight: 700; color: var(--primary); }
.tooth-info .tooth-name { font-size: 13px; color: var(--gray-500); margin-bottom: 8px; }
.tooth-info .tooth-state { margin-top: 4px; }
.tooth-events { list-style: none; padding: 8px 0; }
.tooth-events .section-title { padding: 8px 16px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--gray-500); }
.tooth-event { padding: 8px 16px; border-bottom: 1px solid var(--gray-100); font-size: 13px; display: flex; align-items: flex-start; gap: 8px; cursor: pointer; transition: background var(--transition); }
.tooth-event:hover { background: var(--gray-50); }
.tooth-event:last-child { border-bottom: none; }
.tooth-event .event-icon { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; flex-shrink: 0; }
.tooth-event .event-content { flex: 1; min-width: 0; }
.tooth-event .event-title { font-weight: 500; color: var(--gray-800); }
.tooth-event .event-description { font-size: 12px; color: var(--gray-500); margin-top: 2px; }
.tooth-event .tooth-event-date { font-size: 11px; color: var(--gray-400); }

/* ================================================================
   Status-Specific
   ================================================================ */
.status-SCHEDULED, .status-CONFIRMED { background: var(--primary-light); color: var(--primary); }
.status-IN_ROOM, .status-IN_PROGRESS { background: var(--warning-light); color: var(--warning); }
.status-COMPLETED, .status-SIGNED, .status-PAID { background: #d1fae5; color: var(--success); }
.status-CANCELLED, .status-DRAFT { background: var(--gray-100); color: var(--gray-600); }
.status-NO_SHOW, .status-OVERDUE { background: var(--danger-light); color: var(--danger); }
.status-ISSUED { background: var(--primary-light); color: var(--primary); }
.severity-CRITICAL { background: var(--danger-light); color: var(--danger); }
.severity-HIGH { background: var(--warning-light); color: var(--warning); }
.severity-MEDIUM { background: var(--primary-light); color: var(--primary); }
.severity-LOW { background: var(--gray-100); color: var(--gray-600); }

/* ================================================================
   Utilities
   ================================================================ */
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-col { display: flex; flex-direction: column; }
.inline-flex { display: inline-flex; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-end { justify-content: flex-end; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }

.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; } .gap-5 { gap: 20px; } .gap-6 { gap: 24px; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-5 { margin-top: 20px; } .mt-6 { margin-top: 24px; }
.mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; } .mb-5 { margin-bottom: 20px; } .mb-6 { margin-bottom: 24px; }
.ml-auto { margin-left: auto; } .mr-auto { margin-right: auto; } .mx-auto { margin-left: auto; margin-right: auto; }

.p-1 { padding: 4px; } .p-2 { padding: 8px; } .p-3 { padding: 12px; } .p-4 { padding: 16px; } .p-5 { padding: 20px; } .p-6 { padding: 24px; }
.px-3 { padding-left: 12px; padding-right: 12px; } .px-4 { padding-left: 16px; padding-right: 16px; }
.py-2 { padding-top: 8px; padding-bottom: 8px; } .py-3 { padding-top: 12px; padding-bottom: 12px; }

.text-sm { font-size: 12px; } .text-base { font-size: 14px; } .text-lg { font-size: 16px; } .text-xl { font-size: 18px; } .text-2xl { font-size: 24px; }
.text-gray { color: var(--gray-500); } .text-primary { color: var(--primary); } .text-success { color: var(--success); } .text-danger { color: var(--danger); } .text-warning { color: var(--warning); }
.text-center { text-align: center; } .text-right { text-align: right; } .text-left { text-align: left; }
.text-mono { font-family: "SF Mono", Consolas, monospace; }
.font-medium { font-weight: 500; } .font-semibold { font-weight: 600; } .font-bold { font-weight: 700; }
.w-full { width: 100%; } .h-full { height: 100%; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rounded { border-radius: var(--radius); } .rounded-sm { border-radius: var(--radius-sm); } .rounded-full { border-radius: 9999px; }
.overflow-hidden { overflow: hidden; } .overflow-auto { overflow: auto; }
.shrink-0 { flex-shrink: 0; } .flex-1 { flex: 1; }
.cursor-pointer { cursor: pointer; } .select-none { user-select: none; }

/* --- Loading --- */
.loading { display: inline-block; width: 20px; height: 20px; border: 2px solid var(--primary); border-top-color: transparent; border-radius: 50%; animation: spin .6s linear infinite; }
.loading-sm { width: 16px; height: 16px; border-width: 2px; }
.loading-lg { width: 32px; height: 32px; border-width: 3px; }
.loading-overlay { position: absolute; inset: 0; background: rgba(255,255,255,0.7); display: flex; align-items: center; justify-content: center; z-index: 10; border-radius: inherit; }

/* --- Empty State --- */
.empty-state { text-align: center; padding: 40px 20px; color: var(--gray-400); }
.empty-state .empty-state-icon { font-size: 48px; margin-bottom: 8px; opacity: 0.5; }
.empty-state .empty-state-text { font-size: 14px; }
.empty-state .empty-state-action { margin-top: 12px; }

/* --- Dividers & Page --- */
hr { border: none; border-top: 1px solid var(--gray-200); margin: 16px 0; }
.page-header { margin-bottom: 20px; }
.page-header h2 { font-size: 20px; font-weight: 700; color: var(--gray-800); margin-bottom: 4px; }
.page-header p { font-size: 13px; color: var(--gray-500); }
.section { margin-bottom: 24px; }
.section-title { font-size: 13px; font-weight: 600; color: var(--gray-700); margin-bottom: 12px; text-transform: uppercase; letter-spacing: .5px; }

/* --- Confirm Dialog --- */
.confirm-dialog .modal-body { text-align: center; padding: 32px 20px; }
.confirm-dialog .confirm-icon { width: 56px; height: 56px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 28px; margin-bottom: 16px; }
.confirm-dialog .confirm-icon.danger { background: var(--danger-light); color: var(--danger); }
.confirm-dialog .confirm-icon.warning { background: var(--warning-light); color: var(--warning); }
.confirm-dialog .confirm-message { font-size: 14px; color: var(--gray-700); line-height: 1.6; }

/* ================================================================
   Responsive
   ================================================================ */
@media (max-width: 768px) {
  .sidebar { width: 60px; min-width: 60px; }
  .sidebar-header { padding: 16px 12px; justify-content: center; }
  .sidebar-header .logo-text, .sidebar-header .logo-sub { display: none; }
  .nav-item { padding: 12px; justify-content: center; }
  .nav-item .nav-label { display: none; }
  .nav-section { display: none; }
  .sidebar-footer { padding: 8px 12px; justify-content: center; }
  .sidebar-footer .user-info { display: none; }
  .quick-stats { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-row { flex-direction: column; }
  .content-area { padding: 16px; }
  .topbar { padding: 0 16px; }
  .topbar .topbar-title { font-size: 16px; }
  .modal-card { min-width: auto; max-width: calc(100vw - 40px); max-height: 90vh; }
  .modal-card.modal-lg { max-width: calc(100vw - 40px); }
  .tooth-detail-panel { position: fixed; right: 0; top: 0; bottom: 0; z-index: 900; box-shadow: var(--shadow-lg); }
  .toast { min-width: auto; max-width: calc(100vw - 48px); }
}

@media (max-width: 480px) {
  .login-card { max-width: 100%; border-radius: 0; }
  .login-header { padding: 24px 20px 16px; }
  .login-form { padding: 20px; }
  .stat-card { padding: 16px; }
  .stat-card .stat-value { font-size: 24px; }
  .btn-lg { padding: 10px 20px; font-size: 14px; }
  .content-area { padding: 12px; }
}

/* ================================================================
   Print
   ================================================================ */
@media print {
  .sidebar, .topbar, .tooth-detail-panel, .toast-container, .modal-overlay { display: none !important; }
  .main-content { overflow: visible; }
  .content-area { overflow: visible; padding: 0; }
  .card { box-shadow: none; border: 1px solid var(--gray-200); break-inside: avoid; }
  body { background: #fff; color: #000; }
}

/* ================================================================
   Scrollbar
   ================================================================ */
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }
.modal-body::-webkit-scrollbar { width: 6px; }
.modal-body::-webkit-scrollbar-track { background: transparent; }
.modal-body::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }
.content-area::-webkit-scrollbar { width: 6px; }
.content-area::-webkit-scrollbar-track { background: transparent; }
.content-area::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }
.content-area::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }
.search-select-dropdown::-webkit-scrollbar { width: 6px; }
.search-select-dropdown::-webkit-scrollbar-track { background: transparent; }
.search-select-dropdown::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }
.tooth-detail-panel .panel-body::-webkit-scrollbar { width: 4px; }
.tooth-detail-panel .panel-body::-webkit-scrollbar-track { background: transparent; }
.tooth-detail-panel .panel-body::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 2px; }

/* ================================================================
   Focus Visible
   ================================================================ */
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }
