/* ============================================================
   Seraya AI — Staff console (implemented from the design system)
   Recreates ui_kits/console faithfully in plain CSS, wired to the
   live DentalDesk backend.
   ============================================================ */

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font-text);
  color: var(--text-body);
  background: var(--surface-page);
}
button { font-family: inherit; }

/* ---- App grid: 248px navy sidebar + fluid workspace ---- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; height: 100vh; overflow: hidden; }

/* ---- Sidebar ---- */
.side { background: var(--navy-800); display: flex; flex-direction: column; border-right: 1px solid var(--navy-900); }
.side-brand { display: flex; align-items: center; height: 60px; padding: 0 18px; border-bottom: 1px solid rgba(255,255,255,.07); }
.side-scroll { flex: 1; overflow-y: auto; padding-bottom: 8px; }
.side-section { padding: 16px 12px 6px; font-family: var(--font-display); font-size: 10.5px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--navy-300); }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; margin: 1px 8px;
  border-radius: 8px; font-family: var(--font-text); font-size: 14px; color: var(--navy-100);
  cursor: pointer; transition: all .15s var(--ease-out); border: none; background: transparent;
  width: calc(100% - 16px); text-align: left;
}
.nav-item:hover { background: rgba(255,255,255,.06); }
.nav-item.active { background: var(--brand); color: #fff; box-shadow: 0 2px 8px rgba(14,124,123,.4); }
.nav-item .lucide { width: 18px; height: 18px; }
.nav-count { margin-left: auto; font-family: var(--font-mono); font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: rgba(255,255,255,.12); }
.nav-item.active .nav-count { background: rgba(255,255,255,.22); }
.side-foot { margin-top: auto; padding: 14px; border-top: 1px solid rgba(255,255,255,.07); display: flex; align-items: center; gap: 10px; }
.side-foot-name { font-family: var(--font-display); font-size: 13.5px; font-weight: 600; color: #fff; }
.side-foot-meta { font-family: var(--font-text); font-size: 12px; color: var(--navy-300); }

/* ---- Main column ---- */
.main { display: flex; flex-direction: column; overflow: hidden; }
.topbar { height: 60px; flex: none; background: var(--surface-card); border-bottom: 1px solid var(--border-subtle); display: flex; align-items: center; gap: 16px; padding: 0 24px; }
.top-title { font-family: var(--font-display); font-size: 18px; font-weight: 600; color: var(--text-strong); letter-spacing: -0.01em; }
.search { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px; background: var(--slate-50); border: 1px solid var(--border-subtle); border-radius: 8px; width: 300px; color: var(--text-faint); }
.search input { border: 0; background: transparent; outline: none; font-family: var(--font-text); font-size: 14px; color: var(--text-strong); width: 100%; }
.content { flex: 1; overflow-y: auto; padding: 28px; }

/* ---- Page header ---- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 22px; }
.page-title { font-family: var(--font-display); font-size: 26px; font-weight: 600; color: var(--text-strong); letter-spacing: -0.02em; margin: 0; }
.page-sub { font-family: var(--font-text); font-size: 14px; color: var(--text-muted); margin: 5px 0 0; }

/* ---- KPI tiles ---- */
.kpi-row { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; margin-bottom: 22px; }
.kpi { background: var(--surface-card); border: 1px solid var(--border-subtle); border-radius: 12px; padding: 18px; box-shadow: var(--shadow-xs); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; }
.kpi-icon { width: 34px; height: 34px; border-radius: 9px; display: flex; align-items: center; justify-content: center; }
.kpi-label { font-family: var(--font-text); font-size: 13px; color: var(--text-muted); margin: 14px 0 4px; }
.kpi-value { font-family: var(--font-display); font-size: 28px; font-weight: 600; color: var(--text-strong); letter-spacing: -0.02em; }
.kpi-delta { font-family: var(--font-mono); font-size: 12px; font-weight: 500; color: var(--status-ok-fg); }

/* ---- Two-column grid ---- */
.grid2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 16px; }

/* ---- Cards ---- */
.card { background: var(--surface-card); border: 1px solid var(--border-subtle); border-radius: 12px; box-shadow: var(--shadow-xs); }
.card-pad { padding: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border-subtle); }
.card-title { font-family: var(--font-display); font-size: 15px; font-weight: 600; color: var(--text-strong); }
.card-sub { font-family: var(--font-text); font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.kv { display: flex; justify-content: space-between; align-items: center; }
.kv-k { font-family: var(--font-text); font-size: 14px; color: var(--text-body); }
.kv-v { font-family: var(--font-mono); font-size: 15px; font-weight: 600; color: var(--text-strong); }
.card-dark { background: var(--navy-700); border: none; border-radius: 12px; padding: 18px; }

/* ---- Tables ---- */
.table-wrap { background: var(--surface-card); border: 1px solid var(--border-subtle); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow-xs); }
.table-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border-subtle); }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-family: var(--font-display); font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--text-faint); padding: 11px 18px; border-bottom: 1px solid var(--border-subtle); background: var(--slate-25); }
.tbl td { padding: 13px 18px; border-bottom: 1px solid var(--border-subtle); font-family: var(--font-text); font-size: 14px; color: var(--text-body); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.td-strong { font-family: var(--font-display); font-weight: 600; color: var(--text-strong); }
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; }
.mono { font-family: var(--font-mono); font-size: 13px; }
.row-name { display: flex; align-items: center; gap: 10px; }

/* ---- Appointment / call list rows ---- */
.appt-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border-subtle); }
.appt-row:last-child { border-bottom: none; }
.appt-time { font-family: var(--font-mono); font-size: 13px; font-weight: 500; color: var(--text-strong); width: 76px; flex: none; }
.appt-name { font-family: var(--font-display); font-size: 14px; font-weight: 600; color: var(--text-strong); }
.appt-type { font-family: var(--font-text); font-size: 12.5px; color: var(--text-muted); }

/* ---- Avatar (initials + hashed tint) ---- */
.avatar { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 999px; flex: none; font-family: var(--font-display); font-weight: 600; font-size: 12px; color: #fff; user-select: none; }

/* ---- Badge (status tones) ---- */
.badge { display: inline-flex; align-items: center; gap: 5px; font-family: var(--font-display); font-weight: 600; font-size: var(--text-xs); line-height: 1; letter-spacing: .005em; padding: 4px 9px; border-radius: var(--radius-pill); border: 1px solid transparent; white-space: nowrap; }
.badge .dot { width: 6px; height: 6px; border-radius: 999px; background: currentColor; }
.badge.neutral { background: var(--slate-100); color: var(--slate-600); }
.badge.ok { background: var(--status-ok-bg); color: var(--status-ok-fg); }
.badge.warn { background: var(--status-warn-bg); color: var(--status-warn-fg); }
.badge.err { background: var(--status-err-bg); color: var(--status-err-fg); }
.badge.info { background: var(--status-info-bg); color: var(--status-info-fg); }
.badge.ai { background: var(--status-ai-bg); color: var(--status-ai-fg); }
.badge.brand { background: var(--brand-subtle); color: var(--brand-hover); }

/* ---- Buttons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; font-size: var(--text-base); font-family: var(--font-display); font-weight: 600; letter-spacing: -0.005em; line-height: 1; border-radius: var(--radius-md); border: 1px solid transparent; cursor: pointer; white-space: nowrap; transition: var(--transition-base); }
.btn:focus-visible { outline: none; box-shadow: var(--shadow-ring); }
.btn .lucide { width: 16px; height: 16px; }
.btn-sm { height: 32px; padding: 0 12px; font-size: var(--text-sm); border-radius: var(--radius-sm); }
.btn-primary { background: var(--brand); color: var(--text-on-brand); box-shadow: var(--shadow-xs); }
.btn-primary:hover { background: var(--brand-hover); }
.btn-primary:active { background: var(--brand-active); transform: translateY(0.5px); }
.btn-secondary { background: var(--surface-card); color: var(--text-strong); border-color: var(--border-default); box-shadow: var(--shadow-xs); }
.btn-secondary:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.btn-ghost { background: transparent; color: var(--text-body); }
.btn-ghost:hover { background: var(--surface-sunken); color: var(--text-strong); }
.btn-ondark { background: rgba(255,255,255,.08); color: #fff; border-color: rgba(255,255,255,.16); }
.btn-ondark:hover { background: rgba(255,255,255,.14); }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 8px; border: none; background: transparent; cursor: pointer; color: var(--text-body); transition: var(--transition-base); }
.icon-btn:hover { background: var(--surface-sunken); }

/* ---- Tabs (line variant) ---- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border-subtle); margin-bottom: 16px; }
.tab { display: inline-flex; align-items: center; gap: 7px; padding: 10px 12px; font-family: var(--font-display); font-weight: 600; font-size: 14px; color: var(--text-muted); background: none; border: none; border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; transition: var(--transition-base); }
.tab:hover { color: var(--text-strong); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.tab .cnt { font-family: var(--font-mono); font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 999px; background: var(--surface-sunken); color: var(--text-muted); }
.tab.active .cnt { background: var(--brand-subtle); color: var(--brand-hover); }

/* ---- Form fields ---- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-family: var(--font-display); font-size: 12.5px; font-weight: 600; color: var(--text-strong); }
.field input { height: 40px; padding: 0 12px; border: 1px solid var(--border-default); border-radius: var(--radius-md); background: var(--surface-card); font-family: var(--font-text); font-size: 14px; color: var(--text-strong); box-shadow: var(--shadow-inset); transition: var(--transition-base); }
.field input:focus { outline: none; border-color: var(--border-brand); box-shadow: var(--shadow-ring); }
.field input::placeholder { color: var(--text-faint); }

/* ---- Modal ---- */
.modal-scrim { position: fixed; inset: 0; background: rgba(10,37,64,.42); backdrop-filter: blur(4px); display: none; align-items: center; justify-content: center; z-index: 50; }
.modal-scrim.open { display: flex; }
.modal { width: 520px; max-width: calc(100vw - 32px); background: var(--surface-card); border-radius: var(--radius-lg); box-shadow: var(--shadow-xl); overflow: hidden; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border-subtle); }
.modal-title { font-family: var(--font-display); font-size: 17px; font-weight: 600; color: var(--text-strong); }
.modal-body { padding: 20px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.modal-foot { padding: 16px 20px; border-top: 1px solid var(--border-subtle); display: flex; justify-content: flex-end; gap: 10px; }
.col-span { grid-column: 1 / -1; }

/* ---- Misc ---- */
.empty { padding: 40px; text-align: center; color: var(--text-muted); font-size: 14px; }
.spin { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 999px; animation: sa-spin .6s linear infinite; display: inline-block; }
@keyframes sa-spin { to { transform: rotate(360deg); } }
.link { color: var(--text-link); text-decoration: none; font-weight: 600; font-size: 13px; }
.link:hover { text-decoration: underline; }
.result-line { font-size: 13px; color: var(--text-muted); }
.link-name { color: var(--text-strong); }
.row-name:hover .link-name { color: var(--text-link); }
.payer-select, .conn-input { height: 40px; padding: 0 12px; border: 1px solid var(--border-default); border-radius: var(--radius-md); background: var(--surface-card); font-family: var(--font-text); font-size: 14px; color: var(--text-strong); box-shadow: var(--shadow-inset); }
.payer-select:focus, .conn-input:focus { outline: none; border-color: var(--border-brand); box-shadow: var(--shadow-ring); }
.conn-input::placeholder { color: var(--text-faint); }

/* ---- Calendar (week grid) ---- */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: var(--border-subtle); border: 1px solid var(--border-subtle); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow-xs); }
.cal-day { background: var(--surface-card); min-height: 220px; display: flex; flex-direction: column; }
.cal-today { background: var(--brand-subtle); }
.cal-head { display: flex; align-items: baseline; justify-content: space-between; padding: 10px 12px 6px; border-bottom: 1px solid var(--border-subtle); }
.cal-dow { font-family: var(--font-display); font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--text-faint); }
.cal-num { font-family: var(--font-display); font-size: 16px; font-weight: 600; color: var(--text-strong); }
.cal-today .cal-num { color: var(--brand); }
.cal-body { padding: 8px; display: flex; flex-direction: column; gap: 6px; overflow-y: auto; }
.cal-appt { display: flex; flex-direction: column; gap: 1px; padding: 6px 8px; border-radius: 8px; cursor: pointer; border-left: 3px solid; transition: var(--transition-base); }
.cal-appt:hover { box-shadow: var(--shadow-sm); }
.cal-appt.info { background: var(--status-info-bg); border-color: var(--blue-500); }
.cal-appt.ok { background: var(--status-ok-bg); border-color: var(--green-500); }
.cal-appt.err { background: var(--status-err-bg); border-color: var(--red-500); }
.cal-cancel .cal-name { text-decoration: line-through; opacity: .7; }
.cal-time { font-family: var(--font-mono); font-size: 11px; font-weight: 600; color: var(--text-strong); }
.cal-name { font-family: var(--font-display); font-size: 12.5px; font-weight: 600; color: var(--text-strong); }
.cal-type { font-family: var(--font-text); font-size: 11px; color: var(--text-muted); }
.cal-empty { color: var(--text-faint); font-size: 12px; text-align: center; padding: 8px 0; }

/* ---- Auth / onboarding gates ---- */
.gate { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, #0E3050, #0A2540 55%, #061521); }
.gate-card { width: 420px; max-width: 100%; background: var(--surface-card); border-radius: var(--radius-xl); padding: 32px; box-shadow: var(--shadow-xl); }
.gate-wide { width: 720px; }
.gate-title { font-family: var(--font-display); font-size: 24px; font-weight: 600; color: var(--text-strong); letter-spacing: -0.02em; margin: 14px 0 4px; }
.gate-sub { font-family: var(--font-text); font-size: 14px; color: var(--text-muted); margin: 0 0 20px; }
.gate-form { display: flex; flex-direction: column; gap: 14px; }
.gate-hint { font-size: 12px; color: var(--text-faint); margin-top: 14px; text-align: center; }
.onb-steps { display: flex; flex-direction: column; gap: 18px; margin-bottom: 18px; }
.onb-block { border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); padding: 16px; }
.onb-h { font-family: var(--font-display); font-size: 13px; font-weight: 600; color: var(--brand); margin-bottom: 12px; letter-spacing: .02em; }
.onb-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
