/* ============================================================
   Dental CRM — Design System
   ============================================================ */
:root {
  --teal-50: #ecfeff;
  --teal-100: #cffafe;
  --teal-200: #a5f3fc;
  --teal-300: #67e8f9;
  --teal-400: #22d3ee;
  --teal-500: #06b6d4;
  --teal-600: #0891b2;
  --teal-700: #0e7490;
  --teal-800: #155e75;

  --emerald-500: #10b981;
  --amber-500: #f59e0b;
  --rose-500: #f43f5e;
  --violet-500: #8b5cf6;
  --sky-500: #0ea5e9;
  --indigo-500: #6366f1;

  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;

  --primary: var(--teal-600);
  --primary-dark: var(--teal-700);
  --primary-light: var(--teal-50);
  --accent: var(--teal-500);

  --bg: #f1f5f9;
  --surface: #ffffff;
  --border: var(--slate-200);
  --text: var(--slate-800);
  --text-muted: var(--slate-500);
  --text-soft: var(--slate-400);

  --sidebar-bg: linear-gradient(180deg, #0b2330 0%, #0e3a46 60%, #11505a 100%);
  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .08);
  --shadow: 0 4px 16px rgba(15, 23, 42, .08);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, .18);
  --font: "Segoe UI", "Inter", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
a { color: var(--primary); text-decoration: none; }
h1,h2,h3,h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--slate-300); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--slate-400); background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ============ LOGIN ============ */
/* La tarjeta crece con el panel de cuentas de prueba: se permite desplazarla en pantallas bajas
   en lugar de recortarla. El fondo va fijo para que no se desplace con ella. */
.login-wrap { position: fixed; inset: 0; display: flex; justify-content: center; overflow: auto; padding: 28px 0; }
.login-bg {
  position: fixed; inset: 0;
  background:
    radial-gradient(1200px 700px at 15% -10%, rgba(34,211,238,.25), transparent 55%),
    radial-gradient(1000px 700px at 110% 110%, rgba(16,185,129,.22), transparent 55%),
    linear-gradient(135deg, #06222c 0%, #0b3a47 55%, #0e5a63 100%);
}
.login-bg::before {
  content: ""; position: absolute; inset: 0; opacity: .18;
  background-image: radial-gradient(rgba(255,255,255,.35) 1px, transparent 1px);
  background-size: 26px 26px;
}
.login-card {
  position: relative; z-index: 2; margin: auto;
  width: min(410px, 92vw);
  background: rgba(255,255,255,.98);
  border-radius: 22px;
  padding: 40px 38px 30px;
  box-shadow: var(--shadow-lg);
}
.login-brand { text-align: center; margin-bottom: 26px; }
.login-brand .logo-mark {
  width: 64px; height: 64px; margin: 0 auto 14px;
  font-size: 34px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--teal-500), var(--emerald-500));
  border-radius: 18px; box-shadow: 0 10px 24px rgba(6,182,212,.35);
}
.login-brand h1 { font-size: 22px; color: var(--slate-900); }
.login-brand p { margin: 4px 0 0; color: var(--text-muted); }
.login-hints { margin-top: 22px; padding-top: 16px; border-top: 1px dashed var(--border); display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.login-hints div { font-size: 12px; color: var(--text-muted); background: var(--slate-100); padding: 5px 10px; border-radius: 999px; }
.login-hints b { color: var(--slate-700); }
.login-error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; padding: 10px 12px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 14px; }

/* Ojo para ver la contraseña. Lo coloca ponerOjos() envolviendo cada campo. */
.pw-wrap { position: relative; display: block; width: 100%; }
.pw-wrap > input { width: 100%; padding-right: 42px; }
.pw-ojo {
  position: absolute; right: 5px; top: 50%; transform: translateY(-50%);
  border: 0; background: transparent; cursor: pointer;
  font-size: 15px; line-height: 1; padding: 5px 7px; border-radius: 7px;
  opacity: .55; transition: opacity .12s, background .12s;
}
.pw-ojo:hover { opacity: 1; background: var(--slate-100); }

/* Cuentas de prueba bajo el acceso. Solo se pintan mientras queden contraseñas de fábrica. */
.demo-accounts { margin-top: 22px; padding-top: 16px; border-top: 1px dashed var(--border); }
.demo-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; font-size: 12px; font-weight: 700; color: var(--slate-700); margin-bottom: 9px; }
.demo-head span { font-weight: 400; font-size: 11px; color: var(--text-muted); }
.demo-list { max-height: 46vh; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
.demo-group + .demo-group { margin-top: 12px; }
.demo-group h4 {
  margin: 0 0 6px; font-size: 11px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--text-muted);
}
.demo-row {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 7px 10px; margin-bottom: 5px;
  background: var(--slate-100); border: 1px solid transparent; border-radius: 10px;
  font: inherit; text-align: left; cursor: pointer; transition: background .15s, border-color .15s;
}
.demo-row:hover { background: var(--teal-50); border-color: var(--teal-400); }
.demo-who { display: flex; flex-direction: column; line-height: 1.35; min-width: 0; flex: 1; }
.demo-who b { font-size: 13px; color: var(--slate-900); }
.demo-who em { font-size: 11px; font-style: normal; color: var(--text-muted); }
.demo-row code {
  flex: 0 0 auto; font-size: 12px; color: var(--slate-700); background: var(--surface);
  padding: 3px 8px; border-radius: 6px; border: 1px solid var(--border); white-space: nowrap;
}
.demo-note { margin: 10px 2px 0; font-size: 11px; line-height: 1.55; color: var(--text-muted); }
.demo-note code { font-size: 11px; background: var(--slate-100); padding: 1px 4px; border-radius: 4px; }

/* ============ APP LAYOUT ============ */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 256px; flex: 0 0 256px;
  background: var(--sidebar-bg);
  color: #d7f4f7;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  z-index: 50;
}
.sidebar-brand { display: flex; gap: 12px; align-items: center; padding: 20px 20px 18px; }
.sidebar-brand .logo-mark {
  width: 42px; height: 42px; font-size: 22px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--teal-400), var(--emerald-500));
  border-radius: 12px; box-shadow: 0 6px 16px rgba(0,0,0,.3);
}
.sidebar-title { display: flex; flex-direction: column; line-height: 1.2; }
.sidebar-title strong { color: #fff; font-size: 15px; }
.sidebar-title span { font-size: 11px; color: #9fd6dd; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 6px 12px; }
.nav-section { font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; color: #6fa8b2; margin: 16px 12px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px; margin: 2px 0;
  color: #cde8ec; cursor: pointer; font-weight: 500; font-size: 13.5px;
  transition: background .15s, color .15s; position: relative;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: linear-gradient(90deg, rgba(34,211,238,.22), rgba(34,211,238,.06)); color: #fff; }
.nav-item.active::before { content: ""; position: absolute; left: -12px; top: 20%; bottom: 20%; width: 3px; border-radius: 3px; background: var(--teal-400); }
.nav-item .ico { width: 20px; text-align: center; font-size: 16px; flex: 0 0 20px; }
.nav-badge { margin-left: auto; background: var(--teal-500); color: #04343f; font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 999px; }

.sidebar-footer { padding: 12px 16px 16px; border-top: 1px solid rgba(255,255,255,.1); }
.sidebar-user { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.sidebar-user .avatar { flex: 0 0 auto; }
.sidebar-user-info { min-width: 0; line-height: 1.25; }
.sidebar-user-info strong { display: block; color: #fff; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-info span { font-size: 11px; color: #9fd6dd; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 64px; display: flex; align-items: center; gap: 16px;
  padding: 0 24px; background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 40;
}
.topbar-title { font-size: 18px; color: var(--slate-900); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.global-search { position: relative; }
.global-search .gs-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 14px; opacity: .6; }
.global-search input {
  width: 240px; padding: 9px 12px 9px 34px; border: 1px solid var(--border);
  border-radius: 999px; background: var(--slate-50); font-size: 13px; transition: all .15s;
}
.global-search input:focus { outline: none; border-color: var(--teal-400); background: #fff; box-shadow: 0 0 0 3px rgba(6,182,212,.12); }
.topbar-date { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.topbar-user { display: flex; align-items: center; gap: 8px; }

.content { padding: 24px; max-width: 1500px; width: 100%; margin: 0 auto; }

/* ============ AVATARS ============ */
.avatar {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 14px; flex: 0 0 auto;
}
.avatar.sm { width: 30px; height: 30px; font-size: 12px; }
.avatar.lg { width: 52px; height: 52px; font-size: 19px; }
.avatar.xl { width: 76px; height: 76px; font-size: 28px; border-radius: 20px; }

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: 10px; cursor: pointer;
  padding: 9px 16px; font-size: 13.5px; font-weight: 600; font-family: inherit;
  transition: all .15s; white-space: nowrap; background: #fff; color: var(--slate-700);
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--teal-500), var(--teal-600)); color: #fff; box-shadow: 0 4px 12px rgba(6,182,212,.28); }
.btn-primary:hover { background: linear-gradient(135deg, var(--teal-600), var(--teal-700)); }
.btn-secondary { background: var(--slate-100); color: var(--slate-700); }
.btn-secondary:hover { background: var(--slate-200); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--slate-100); }
.btn-ghost-dark { background: transparent; color: #d7f4f7; border-color: rgba(255,255,255,.18); }
.btn-ghost-dark:hover { background: rgba(255,255,255,.1); }
.btn-danger { background: var(--rose-500); color: #fff; }
.btn-danger:hover { background: #e11d48; }
.btn-outline { border-color: var(--slate-300); background: #fff; }
.btn-outline:hover { border-color: var(--teal-400); color: var(--teal-700); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
.btn-xs { padding: 3px 9px; font-size: 12px; border-radius: 7px; }
.icon-btn {
  width: 38px; height: 38px; border: 1px solid var(--border); background: #fff; border-radius: 10px;
  cursor: pointer; font-size: 16px; display: grid; place-items: center; transition: all .15s;
}
.icon-btn:hover { background: var(--slate-50); border-color: var(--slate-300); }

/* ============ CARDS ============ */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 20px; }
.card-header { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-header h3 { font-size: 15px; color: var(--slate-900); }
.card-header .spacer { margin-left: auto; }
.card-body { padding: 20px; }

/* Stat cards */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
  transition: transform .15s, box-shadow .15s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-card .stat-ico {
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
  font-size: 20px; margin-bottom: 12px;
}
.stat-card .stat-label { font-size: 12.5px; color: var(--text-muted); font-weight: 500; }
.stat-card .stat-value { font-size: 26px; font-weight: 700; color: var(--slate-900); margin-top: 2px; letter-spacing: -.02em; }
.stat-card .stat-sub { font-size: 12px; color: var(--text-soft); margin-top: 2px; }

/* ============ FORMS ============ */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--slate-600); }
.input, .select, .textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  font-size: 13.5px; font-family: inherit; background: #fff; color: var(--text); transition: all .15s;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--teal-400); box-shadow: 0 0 0 3px rgba(6,182,212,.12); }
.textarea { min-height: 80px; resize: vertical; }
.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 24 24' fill='none' stroke='%2364748b' stroke-width='3'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 16px; }
.form-grid .span-2 { grid-column: span 2; }

/* ============ TABLES ============ */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted); font-weight: 650; padding: 10px 16px; border-bottom: 1px solid var(--border);
  background: var(--slate-50); position: sticky; top: 0; white-space: nowrap;
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--slate-100); vertical-align: middle; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: var(--teal-50); }
.table tbody tr.clickable { cursor: pointer; }
.table .cell-main { font-weight: 600; color: var(--slate-900); }
.table .cell-sub { font-size: 12px; color: var(--text-muted); }

/* ============ BADGES ============ */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 650; white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-teal { background: #ccfbf1; color: #0f766e; }
.badge-emerald { background: #d1fae5; color: #047857; }
.badge-amber { background: #fef3c7; color: #b45309; }
.badge-rose { background: #ffe4e6; color: #be123c; }
.badge-slate { background: var(--slate-100); color: var(--slate-600); }
.badge-violet { background: #ede9fe; color: #6d28d9; }
.badge-sky { background: #e0f2fe; color: #0369a1; }
.badge-indigo { background: #e0e7ff; color: #4338ca; }

/* ============ TABS ============ */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); padding: 0 20px; overflow-x: auto; }
.tab {
  padding: 12px 16px; font-size: 13.5px; font-weight: 600; color: var(--text-muted); cursor: pointer;
  border-bottom: 2px solid transparent; white-space: nowrap; transition: color .15s;
}
.tab:hover { color: var(--slate-700); }
.tab.active { color: var(--teal-700); border-bottom-color: var(--teal-500); }

/* ============ MODAL ============ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.5); backdrop-filter: blur(3px);
  display: flex; align-items: flex-start; justify-content: center; z-index: 100;
  padding: 40px 20px; overflow-y: auto; animation: fadeIn .18s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: #fff; border-radius: 16px; width: min(640px, 96vw); max-height: 92vh;
  display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: slideUp .2s ease;
}
@keyframes slideUp { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal.modal-lg { width: min(880px, 96vw); }
.modal.modal-xl { width: min(1080px, 96vw); }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 16px; flex: 1; }
.modal-body { padding: 22px; overflow-y: auto; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* ============ TOASTS ============ */
.toast-root { position: fixed; bottom: 22px; right: 22px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  min-width: 260px; max-width: 380px; padding: 13px 16px; border-radius: 12px;
  background: var(--slate-900); color: #fff; box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 10px; animation: toastIn .25s ease; font-size: 13.5px;
}
.toast.success { background: linear-gradient(135deg, #059669, #047857); }
.toast.error { background: linear-gradient(135deg, #e11d48, #be123c); }
.toast.info { background: linear-gradient(135deg, #0891b2, #0e7490); }
@keyframes toastIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ============ MISC ============ */
.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h2 { font-size: 22px; color: var(--slate-900); }
.page-head .sub { color: var(--text-muted); font-size: 13.5px; }
.page-head .spacer { margin-left: auto; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.flex { display: flex; gap: 10px; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.muted { color: var(--text-muted); }
.small { font-size: 12px; }
.strong { font-weight: 650; }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-5 { margin-top: 20px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }
.w-100 { width: 100%; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mono { font-variant-numeric: tabular-nums; }
.empty { text-align: center; padding: 44px 20px; color: var(--text-muted); }
.empty .big { font-size: 40px; margin-bottom: 8px; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 8px 16px; }
.kv dt { color: var(--text-muted); font-size: 12.5px; font-weight: 600; }
.kv dd { margin: 0; font-size: 13.5px; }

/* Search/table toolbar */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .input, .toolbar .select { width: auto; }

/* Chart containers */
.chart { width: 100%; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-muted); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend .swatch { width: 10px; height: 10px; border-radius: 3px; }

/* ============ CALENDAR ============ */
.cal-head { display: flex; align-items: center; gap: 12px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow { text-align: center; font-size: 12px; font-weight: 650; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; padding: 8px 0; }
.cal-cell {
  min-height: 108px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 7px 8px; cursor: pointer; transition: all .12s; overflow: hidden; position: relative;
}
.cal-cell:hover { border-color: var(--teal-300); box-shadow: var(--shadow-sm); }
.cal-cell.out { background: var(--slate-50); opacity: .55; }
.cal-cell.today { border-color: var(--teal-500); box-shadow: 0 0 0 2px rgba(6,182,212,.18); }
.cal-cell .cal-num { font-size: 12px; font-weight: 650; color: var(--slate-600); }
.cal-cell.today .cal-num { background: var(--teal-500); color: #fff; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; }
.cal-events { margin-top: 6px; display: flex; flex-direction: column; gap: 3px; }
.cal-event {
  font-size: 11px; padding: 2px 6px; border-radius: 5px; color: #fff; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cal-more { font-size: 10.5px; color: var(--text-muted); padding-left: 6px; }

/* ============ ODONTOGRAM ============ */
.odonto-wrap { display: flex; gap: 24px; flex-wrap: wrap; align-items: flex-start; }
.odonto-chart { flex: 1 1 520px; min-width: 320px; }
.odonto-legend { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 16px; align-content: start; }

/* Arcadas dibujadas en SVG: los dientes van colocados sobre una elipse y girados hacia el centro,
   con la forma que les toca por su número (incisivo, canino, premolar o molar). */
.odonto-arch { display: block; width: 100%; height: auto; overflow: visible; }
.odonto-label { text-align: center; font-size: 12px; color: var(--text-muted); margin: 2px 0 4px; }
.odonto-side {
  display: flex; justify-content: space-between; font-size: 11px;
  color: var(--text-soft); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px;
}
.odonto-oclusion { height: 1px; background: var(--border); margin: 2px 8%; }

/* Cada estado define de qué color se pinta la corona. Las mismas clases visten las etiquetas de
   la leyenda, por eso conservan también background/border/color. */
.tooth-btn { cursor: pointer; --diente: #ffffff; --diente-borde: var(--slate-400); }
.tooth-btn .tooth-crown { fill: var(--diente); stroke: var(--diente-borde); stroke-width: 2.5; }
.tooth-btn .tooth-root { fill: #f8f4ec; stroke: var(--diente-borde); stroke-width: 2; opacity: .95; }
.tooth-btn .tooth-detail { fill: none; stroke: var(--diente-borde); stroke-width: 1.6; opacity: .5; stroke-linecap: round; }
.tooth-btn .tooth-hit { fill: transparent; }
.tooth-btn .tooth-num { font-size: 12px; font-weight: 600; fill: var(--text-soft); text-anchor: middle; }
.tooth-btn:hover .tooth-crown, .tooth-btn:hover .tooth-root { stroke: var(--teal-600); stroke-width: 3; }
.tooth-btn:hover .tooth-num { fill: var(--teal-700); }
.tooth-btn.solo-lectura { cursor: default; }
.tooth-btn.solo-lectura:hover .tooth-crown, .tooth-btn.solo-lectura:hover .tooth-root { stroke: var(--diente-borde); stroke-width: 2.5; }
/* Ausente: solo queda el hueco marcado. */
.tooth-btn.cond-missing .tooth-crown, .tooth-btn.cond-missing .tooth-root { fill: none; opacity: .35; stroke-dasharray: 5 4; }
.tooth-btn.cond-missing .tooth-detail { display: none; }
.cond-sound { --diente: #ffffff; --diente-borde: var(--slate-400); background: #fff; border-color: var(--slate-300); color: var(--slate-600); }
.cond-caries { --diente: #fde047; --diente-borde: #eab308; background: #fde047; border-color: #eab308; color: #713f12; }
.cond-filled { --diente: #bfdbfe; --diente-borde: #3b82f6; background: #bfdbfe; border-color: #3b82f6; color: #1e3a8a; }
.cond-missing { --diente: #e2e8f0; --diente-borde: #94a3b8; background: #e2e8f0; border-color: #94a3b8; color: #475569; }
.cond-crown { --diente: #fbcfe8; --diente-borde: #ec4899; background: #fbcfe8; border-color: #ec4899; color: #831843; }
.cond-root_canal { --diente: #fca5a5; --diente-borde: #ef4444; background: #fca5a5; border-color: #ef4444; color: #7f1d1d; }
.cond-implant { --diente: #c7d2fe; --diente-borde: #6366f1; background: #c7d2fe; border-color: #6366f1; color: #312e81; }
.cond-bridge { --diente: #ddd6fe; --diente-borde: #8b5cf6; background: #ddd6fe; border-color: #8b5cf6; color: #4c1d95; }
.cond-sealant { --diente: #a5f3fc; --diente-borde: #06b6d4; background: #a5f3fc; border-color: #06b6d4; color: #164e63; }
.cond-fractured { --diente: #fed7aa; --diente-borde: #f97316; background: #fed7aa; border-color: #f97316; color: #7c2d12; }
.cond-pulpitis { --diente: #fda4af; --diente-borde: #f43f5e; background: #fda4af; border-color: #f43f5e; color: #881337; }
.cond-to_extract { --diente: #fecaca; --diente-borde: #ef4444; background: #fecaca; border-color: #ef4444; color: #7f1d1d; }

/* ============ RESPONSIVE ============ */
@media (max-width: 1024px) {
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s; height: 100vh; }
  .sidebar.open { transform: none; }
  .global-search input { width: 150px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: span 1; }
  .topbar-date { display: none; }
}

/* ============ BRANDING ============ */
.brand-logo { display: inline-block; vertical-align: middle; max-height: 40px; max-width: 160px; object-fit: contain; }
.sidebar-brand .logo-mark { display: grid; }
.sidebar-brand .logo-mark img.brand-logo { max-height: 30px; max-width: 30px; }

/* ============ NOTIFICATIONS ============ */
.notif-wrap { position: relative; }
.notif-badge {
  position: absolute; top: -5px; right: -5px; background: var(--rose-500); color: #fff;
  font-size: 10px; font-weight: 700; min-width: 17px; height: 17px; border-radius: 999px;
  display: grid; place-items: center; padding: 0 4px; box-shadow: 0 2px 6px rgba(244,63,94,.4);
}
.notif-panel {
  position: absolute; right: 0; top: 46px; width: 340px; max-height: 440px; overflow-y: auto;
  background: #fff; border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg);
  z-index: 90; padding: 6px;
}
.notif-item { display: flex; gap: 10px; padding: 11px 12px; border-radius: 10px; cursor: pointer; transition: background .12s; }
.notif-item:hover { background: var(--slate-50); }
.notif-item.unread { background: var(--teal-50); }
.notif-item .n-ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-size: 16px; flex: 0 0 auto; background: var(--slate-100); }
.notif-item .n-body { min-width: 0; flex: 1; }
.notif-item .n-title { font-weight: 650; font-size: 13px; color: var(--slate-800); }
.notif-item .n-msg { font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; }
.notif-item .n-time { font-size: 10.5px; color: var(--text-soft); margin-top: 2px; }
.notif-panel .notif-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px 6px; }
.notif-panel .notif-head strong { font-size: 13px; }
.notif-panel .notif-empty { padding: 26px; text-align: center; color: var(--text-muted); font-size: 13px; }

/* ============ LOCATION SWITCHER ============ */
.loc-select { width: auto; min-width: 150px; padding-top: 8px; padding-bottom: 8px; font-weight: 600; border-color: var(--border); background-color: var(--slate-50); }

/* ============ ACTIVE CLINIC + CONNECTION INDICATORS ============ */
.active-clinic {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; font-weight: 700; white-space: nowrap;
  padding: 5px 11px; border-radius: 999px;
  color: var(--teal-700); background: var(--teal-50); border: 1px solid var(--teal-200);
}
.active-clinic.all { color: #b45309; background: #fef3c7; border-color: #fcd34d; }
.active-clinic .dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.conn-status { display: inline-flex; align-items: center; padding: 4px; }
.conn-status .dot { width: 9px; height: 9px; border-radius: 50%; background: #94a3b8; }
.conn-status.online .dot { background: #10b981; box-shadow: 0 0 0 3px rgba(16,185,129,.18); }
.conn-status.offline .dot { background: #f43f5e; box-shadow: 0 0 0 3px rgba(244,63,94,.18); }
[data-theme="dark"] .active-clinic { color: #67e8f9; background: var(--teal-50); }
[data-theme="dark"] .active-clinic.all { color: #fbbf24; background: rgba(245,158,11,.12); }

/* Aviso de factura anulada: se conserva el documento, pero se ve de un vistazo que no tiene efecto. */
.invoice-void { border-left: 4px solid #f43f5e; background: #fff1f2; }
[data-theme="dark"] .invoice-void { background: rgba(244,63,94,.12); }

/* ============ DOCUMENTS TAB ============ */
.doc-item { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-bottom: 1px solid var(--slate-100); }
.doc-item:last-child { border-bottom: none; }
.doc-ico { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 20px; flex: 0 0 auto; background: var(--slate-100); }
.dropzone {
  border: 2px dashed var(--slate-300); border-radius: 12px; padding: 22px; text-align: center;
  color: var(--text-muted); cursor: pointer; transition: all .15s; background: var(--slate-50);
}
.dropzone:hover, .dropzone.drag { border-color: var(--teal-400); background: var(--teal-50); color: var(--teal-700); }

/* ============ PERMISSIONS MATRIX ============ */
.perm-role-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.perm-group { margin-bottom: 18px; }
.perm-group h5 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin: 0 0 8px; }
.perm-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; }
.perm-row .switch { margin-left: auto; }
.switch { position: relative; width: 40px; height: 22px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; background: var(--slate-300); border-radius: 999px; cursor: pointer; transition: .2s;
}
.switch .slider::before { content: ""; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + .slider { background: var(--teal-500); }
.switch input:checked + .slider::before { transform: translateX(18px); }

/* ============ PRINT ============ */
@media print {
  .sidebar, .topbar, .toast-root, #modal-root, .page-head .btn, .no-print { display: none !important; }
  .main { margin: 0; }
  .content { padding: 0; }
  body { background: #fff; }
  .card { box-shadow: none; border-color: #ddd; }
}

/* ============ DARK MODE ============ */
[data-theme="dark"] {
  --bg: #0b1220;
  --surface: #141d30;
  --border: #263144;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-soft: #64748b;
  --primary-light: #0d2830;

  --slate-50: #0f172a;
  --slate-100: #1a2436;
  --slate-200: #263144;
  --slate-300: #33415a;
  --slate-400: #64748b;
  --slate-500: #94a3b8;
  --slate-600: #cbd5e1;
  --slate-700: #e2e8f0;
  --slate-800: #f1f5f9;
  --slate-900: #f8fafc;

  --teal-50: #0d2830;
  --teal-100: #123a44;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4), 0 1px 3px rgba(0,0,0,.5);
  --shadow: 0 6px 20px rgba(0,0,0,.45);
  --shadow-lg: 0 16px 48px rgba(0,0,0,.6);
}
[data-theme="dark"] body { background: var(--bg); color: var(--text); }
[data-theme="dark"] .login-card { background: rgba(19,28,48,.97); box-shadow: var(--shadow-lg); }
[data-theme="dark"] .login-brand h1 { color: #f8fafc; }
[data-theme="dark"] .login-hints div { background: var(--slate-100); }
[data-theme="dark"] .login-error { background: rgba(190,18,60,.15); color: #fda4af; border-color: rgba(244,63,94,.35); }
[data-theme="dark"] .modal { background: var(--surface); }
[data-theme="dark"] .input, [data-theme="dark"] .select, [data-theme="dark"] .textarea { background: #0d1526; color: var(--text); border-color: var(--border); }
[data-theme="dark"] .btn { background: var(--slate-100); color: var(--text); }
[data-theme="dark"] .btn-outline, [data-theme="dark"] .icon-btn { background: var(--surface); }
[data-theme="dark"] .btn-secondary { background: var(--slate-200); color: var(--text); }
[data-theme="dark"] .btn-ghost:hover { background: var(--slate-100); }
[data-theme="dark"] .notif-panel { background: var(--surface); }
[data-theme="dark"] .notif-item:hover { background: var(--slate-100); }
[data-theme="dark"] .notif-item.unread { background: var(--teal-50); }
[data-theme="dark"] .toast-root .toast { background: var(--slate-800); color: #0f172a; }
[data-theme="dark"] .toast.success { color: #fff; }
[data-theme="dark"] .toast.error { color: #fff; }
[data-theme="dark"] .toast.info { color: #fff; }
[data-theme="dark"] .cal-cell.out { background: #0d1526; }
/* En oscuro el diente sano se apaga un poco para no deslumbrar; los estados mantienen su color. */
[data-theme="dark"] .tooth-btn.cond-sound { --diente: #cbd5e1; --diente-borde: #64748b; }
[data-theme="dark"] .tooth-btn .tooth-root { fill: #94a3b8; }
[data-theme="dark"] .cond-sound { background: var(--slate-100); border-color: var(--slate-300); color: var(--text); }
[data-theme="dark"] .table tbody tr:hover { background: var(--teal-50); }
[data-theme="dark"] .dropzone { background: #0d1526; }
[data-theme="dark"] .doc-ico, [data-theme="dark"] .notif-item .n-ico { background: var(--slate-200); }
[data-theme="dark"] .stat-card .stat-value { color: #f8fafc; }
[data-theme="dark"] .topbar-title, [data-theme="dark"] .page-head h2 { color: #f8fafc; }

/* ============ MULTI-CLINIC OVERVIEW ============ */
.live-pill { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 700; color: var(--teal-700); background: var(--teal-50); padding: 5px 12px; border-radius: 999px; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #10b981; animation: pulse 1.6s infinite; flex: 0 0 auto; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(16,185,129,.5); } 50% { box-shadow: 0 0 0 6px rgba(16,185,129,0); } }
.branch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.branch-card { transition: transform .15s, box-shadow .15s; }
.branch-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.branch-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.branch-chip { display: flex; align-items: center; gap: 8px; background: var(--slate-50); border-radius: 10px; padding: 8px 10px; }
.branch-chip .bc-icon { font-size: 16px; }
.branch-chip .bc-value { font-weight: 700; font-size: 15px; color: var(--slate-900); line-height: 1.15; }
.branch-chip .bc-label { font-size: 10.5px; color: var(--text-muted); }
[data-theme="dark"] .live-pill { color: #67e8f9; }
[data-theme="dark"] .branch-chip .bc-value { color: #f8fafc; }



/* ---------- Consentimientos informados ---------- */
.consent-body {
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.65;
  max-height: 320px;
  overflow-y: auto;
  background: var(--slate-50, #f8fafc);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 10px;
  padding: 16px;
  margin: 0;
  color: var(--text, #0f172a);
}
.consent-sign { margin-top: 14px; text-align: center; }
.consent-signature {
  display: block;
  margin: 6px auto;
  max-height: 120px;
  border-bottom: 1px solid var(--border, #e2e8f0);
}
.sign-pad-wrap { position: relative; }
.sign-pad {
  width: 100%;
  height: 180px;
  border: 2px dashed var(--border, #cbd5e1);
  border-radius: 12px;
  background: #fff;
  cursor: crosshair;
  touch-action: none;          /* imprescindible: si no, firmar arrastra la página en tableta */
}
.sign-pad-hint {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  color: var(--text-muted, #94a3b8);
  font-size: 13px;
}

/* ---------- Impresión ---------- */
#print-root { display: none; }
@media print {
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block !important; padding: 24px; color: #000; }
  #print-root h1 { font-size: 18px; margin: 0 0 4px; }
  #print-root .meta { font-size: 12px; color: #444; margin: 0 0 16px; }
  #print-root pre { white-space: pre-wrap; font-family: Georgia, serif; font-size: 12px; line-height: 1.6; }
  #print-root .firma { margin-top: 32px; text-align: center; }
  #print-root .firma img { max-height: 110px; border-bottom: 1px solid #000; }
  #print-root .firma p { margin: 4px 0 0; font-size: 12px; }
}

/* ============ AVISOS ============ */
.alert { padding: 11px 13px; border-radius: var(--radius-sm); font-size: 13px; line-height: 1.5; border: 1px solid; }
.alert-warn { background: #fffbeb; border-color: #fcd34d; color: #92400e; }
[data-theme="dark"] .alert-warn { background: rgba(245,158,11,.12); border-color: rgba(245,158,11,.35); color: #fcd34d; }

/* Factura anulada: se conserva con su número, pero tiene que verse de un vistazo que ya no vale. */
.invoice-void { border-left: 4px solid var(--rose-500); background: #fff1f2; }
.invoice-void .strong { color: #9f1239; }
[data-theme="dark"] .invoice-void { background: rgba(244,63,94,.12); }
[data-theme="dark"] .invoice-void .strong { color: #fda4af; }
