/* Aloka Ayurveda — clinic management system styles.
   Warm, editorial, minimalist chrome matched to the clinic's brand mockups:
   olive green as the primary action color, a muted terracotta/rust as a
   secondary accent (eyebrows, links, numerals), pastel sage/rose/sand tiles
   for iconography, and a warm cream page surface. Chart data marks use the
   validated categorical/status palette from the design system (see
   --series-* and --status-* below) — that palette is intentionally separate
   from brand chrome, so restyles never touch chart-color accessibility
   guarantees. All hex values below were sampled from the client's own
   reference mockups for fidelity, then contrast-checked against WCAG AA.
*/

:root {
  color-scheme: light;
  /* Brand chrome */
  --brand-logo: #5c8607;       /* the logo artwork's exact green (image asset only) */
  --brand-primary: #5c7726;    /* AA-safe step of the mockup's olive, ~5:1 on white */
  --brand-primary-dark: #46591d;
  --brand-primary-light: #e6ebd4; /* pale sage — active nav, confirmed pills, sage tiles */
  --brand-accent: #67852b;
  --brand-primary-ink: var(--brand-primary); /* link/icon text use — same as brand-primary in light, brighter in dark */

  --rust: #8a6a45;             /* muted brown — eyebrows, secondary links */
  --rust-strong: #935d35;      /* bold numerals, stronger rust accents */
  --tile-rose-bg: #f1dfd1;
  --tile-sand-bg: #f1e7c4;
  --avatar-rust: #a16d53;      /* solid terracotta for the current-user avatar */

  --bg-page: #faf9f4;
  --bg-surface: #fdfcf8;
  --bg-surface-2: #f2f0e6;
  --surface-white: #ffffff;    /* inputs, modal, raised white surfaces (distinct from --bg-surface) */

  /* Chart / status chrome (validated palette) */
  --chart-surface: #fcfcfb;
  --text-primary: #201d15;
  --text-secondary: #5c584c;
  --text-muted: #93897b;
  --gridline: #e8e4d8;
  --axis: #cac4b3;
  --border: rgba(32,29,21,0.09);

  --series-1: #2a78d6; /* blue */
  --series-2: #eb6834; /* orange */
  --series-3: #1baf7a; /* aqua */
  --series-4: #eda100; /* yellow */
  --series-5: #e87ba4; /* magenta */
  --series-6: #008300; /* green */
  --series-7: #4a3aa7; /* violet */
  --series-8: #e34948; /* red */

  --status-good: #0ca30c;
  --status-warning: #fab219;
  --status-serious: #ec835a;
  --status-critical: #d03b3b;

  /* Semantic text/bg pairs that were one-off hex values — tokenised so dark
     mode can override them without touching the validated chart palette above. */
  --text-stat-warning: #a06f00;
  --text-stat-good: #0a6b0a;
  --text-trend-up: #2f7d2f;
  --text-badge-good: #2f6b1f;
  --text-badge-warning: #8a5a00;
  --bg-badge-serious: color-mix(in srgb, var(--status-serious) 20%, white);
  --text-badge-serious: #a03f1c;
  --bg-badge-critical: color-mix(in srgb, var(--status-critical) 16%, white);
  --text-badge-critical: #8f1f1f;
  --bg-login-error: color-mix(in srgb, var(--status-critical) 12%, white);
  --text-login-error: #8f1f1f;
  --text-offline-banner: #6b5300;
  --border-offline-banner: rgba(107,83,0,0.15);
  --progress-amber: #d3a521;
  --text-icon-sand: #8a5a00;
  --modal-backdrop: rgba(32,29,21,0.35);
  --modal-shadow: 0 12px 40px rgba(32,29,21,0.16);

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(32,29,21,0.04), 0 10px 28px rgba(32,29,21,0.05);
  --font-serif: Georgia, "Iowan Old Style", "Palatino Linotype", "Times New Roman", serif;
}

/* ---------- Dark theme ----------
   Values follow the same categorical/status palette (series-N and status-N
   stay identical — they're validated per-mode already, not re-derived here)
   plus the design system's dark chart-chrome table for surfaces/ink/
   gridlines/border. Brand-specific tokens (olive, rust, tiles) are new
   dark derivations, each contrast-checked against the surfaces that use
   them (documented in build-notes.md). Declared under both the OS-preference
   media query and an explicit [data-theme] scope so a manual toggle always
   wins over the OS setting. */
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --brand-primary: #5c7726;
    --brand-primary-dark: #a9c97a;
    --brand-primary-light: #3d5222;
    --brand-accent: #71a02a;
    --brand-primary-ink: #71a02a;

    --rust: #c99a6a;
    --rust-strong: #d9a876;
    --tile-rose-bg: #3a2a20;
    --tile-sand-bg: #3a3420;
    --avatar-rust: #a16d53;

    --bg-page: #0d0d0d;
    --bg-surface: #1a1a19;
    --bg-surface-2: #242422;
    --surface-white: #26261f;

    --chart-surface: #1a1a19;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --gridline: #2c2c2a;
    --axis: #383835;
    --border: rgba(255,255,255,0.10);

    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-7: #9085e9;
    --series-8: #e66767;

    --status-good: #0ca30c;
    --status-warning: #fab219;
    --status-serious: #ec835a;
    --status-critical: #d03b3b;

    --text-stat-warning: #e0ac2e;
    --text-stat-good: #4fbb4f;
    --text-trend-up: #4fbb4f;
    --text-badge-good: #8fd66a;
    --text-badge-warning: #e0ac2e;
    --bg-badge-serious: #3d2418;
    --text-badge-serious: #f2a685;
    --bg-badge-critical: #3a1616;
    --text-badge-critical: #f2908f;
    --bg-login-error: #3a1616;
    --text-login-error: #f2908f;
    --text-offline-banner: #e0ac2e;
    --border-offline-banner: rgba(224,172,46,0.25);
    --progress-amber: #e0ac2e;
    --text-icon-sand: #e0ac2e;
    --modal-backdrop: rgba(0,0,0,0.55);
    --modal-shadow: 0 12px 40px rgba(0,0,0,0.5);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --brand-primary: #5c7726;
  --brand-primary-dark: #a9c97a;
  --brand-primary-light: #3d5222;
  --brand-accent: #71a02a;
  --brand-primary-ink: #71a02a;

  --rust: #c99a6a;
  --rust-strong: #d9a876;
  --tile-rose-bg: #3a2a20;
  --tile-sand-bg: #3a3420;
  --avatar-rust: #a16d53;

  --bg-page: #0d0d0d;
  --bg-surface: #1a1a19;
  --bg-surface-2: #242422;
  --surface-white: #26261f;

  --chart-surface: #1a1a19;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --gridline: #2c2c2a;
  --axis: #383835;
  --border: rgba(255,255,255,0.10);

  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;

  --status-good: #0ca30c;
  --status-warning: #fab219;
  --status-serious: #ec835a;
  --status-critical: #d03b3b;

  --text-stat-warning: #e0ac2e;
  --text-stat-good: #4fbb4f;
  --text-trend-up: #4fbb4f;
  --text-badge-good: #8fd66a;
  --text-badge-warning: #e0ac2e;
  --bg-badge-serious: #3d2418;
  --text-badge-serious: #f2a685;
  --bg-badge-critical: #3a1616;
  --text-badge-critical: #f2908f;
  --bg-login-error: #3a1616;
  --text-login-error: #f2908f;
  --text-offline-banner: #e0ac2e;
  --border-offline-banner: rgba(224,172,46,0.25);
  --progress-amber: #e0ac2e;
  --text-icon-sand: #e0ac2e;
  --modal-backdrop: rgba(0,0,0,0.55);
  --modal-shadow: 0 12px 40px rgba(0,0,0,0.5);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg-page);
  color: var(--text-primary);
  font-variant-numeric: proportional-nums;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-primary-ink); }

/* ---------- Layout ---------- */
#app-root { display: flex; min-height: 100vh; }

.sidebar {
  width: 246px;
  flex-shrink: 0;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  padding: 22px 14px;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 10px;
  padding: 0 6px 20px;
  margin-bottom: 18px;
}
.sidebar .brand .leaf {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar .brand .leaf img { width: 34px; height: 34px; object-fit: contain; display: block; }
.sidebar .brand-name { font-weight: 700; font-size: 16px; line-height: 1.2; color: var(--brand-primary); letter-spacing: 0.04em; }
.sidebar .brand-sub { font-size: 10px; color: var(--text-muted); margin-top: 1px; letter-spacing: 0.12em; }

.nav-sep {
  height: 1px;
  background: var(--border);
  margin: 10px 12px;
  opacity: 0.7;
}

.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: 999px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 2px;
  cursor: pointer;
  position: relative;
}
.nav-link:hover { background: var(--bg-surface-2); color: var(--text-primary); }
.nav-link.active { background: var(--brand-primary); color: #fff; font-weight: 600; }
.nav-icon { width: 18px; text-align: center; opacity: 0.9; flex-shrink: 0; }
.nav-badge {
  margin-left: auto; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px; background: var(--tile-sand-bg); color: var(--rust-strong);
  font-size: 10.5px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center;
}
.nav-link.active .nav-badge { background: rgba(255,255,255,0.25); color: #fff; }

.sidebar-footer { margin-top: auto; font-size: 12px; }

.tip-card {
  background: var(--tile-sand-bg); border-radius: var(--radius-sm);
  padding: 12px 14px; margin-bottom: 14px; font-size: 12px;
}
.tip-card .tip-title { font-weight: 700; color: var(--rust-strong); margin-bottom: 3px; display: flex; align-items: center; gap: 5px; }
.tip-card .tip-body { color: var(--text-secondary); line-height: 1.5; }

.consultant-credit { font-size: 11px; color: var(--text-muted); padding: 0 6px 12px; line-height: 1.5; border-top: 1px solid var(--border); padding-top: 12px; }
.consultant-credit strong { color: var(--text-secondary); font-weight: 600; }

.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 8px; border-top: 1px solid var(--border); margin-top: 4px;
}
.sidebar-user .avatar { flex-shrink: 0; }
.sidebar-user .who { min-width: 0; flex: 1; }
.sidebar-user .who .name { font-size: 13px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .who .role { font-size: 11px; color: var(--text-muted); text-transform: capitalize; }
.sidebar-user .logout-icon-btn {
  background: none; border: none; cursor: pointer; color: var(--text-muted);
  font-size: 16px; padding: 6px; border-radius: 8px; flex-shrink: 0;
}
.sidebar-user .logout-icon-btn:hover { background: var(--bg-surface-2); color: var(--text-primary); }

.avatar {
  width: 34px; height: 34px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.avatar-sm { width: 28px; height: 28px; font-size: 11px; }
.avatar-sage { background: var(--brand-primary-light); color: var(--brand-primary-dark); }
.avatar-rose { background: var(--tile-rose-bg); color: var(--rust-strong); }
.avatar-rust { background: var(--avatar-rust); color: #fff; }

/* Sync status strip (replaces the old plain topbar) */
.sync-strip {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.sync-strip-left { display: flex; align-items: center; gap: 10px; }
.sync-strip-icon {
  width: 26px; height: 26px; border-radius: 999px; background: var(--bg-surface-2);
  display: flex; align-items: center; justify-content: center; font-size: 13px; color: var(--brand-primary-ink);
}
.sync-strip .sync-title { font-weight: 700; color: var(--text-primary); }
.sync-strip .sync-sub { color: var(--text-muted); }
.sync-strip .sync-time { color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--status-good); flex-shrink: 0; }
.sync-dot.offline { background: var(--status-warning); }
.sync-dot.syncing { background: var(--series-1); animation: pulse 1s infinite; }
.sync-dot.error { background: var(--status-critical); }
@keyframes pulse { 50% { opacity: 0.3; } }

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.view { padding: 28px 32px 64px; flex: 1; }

/* Per-page header (eyebrow + title), used by every non-dashboard page */
.page-header { margin-bottom: 22px; display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-eyebrow { font-size: 11px; font-weight: 700; color: var(--rust); text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 4px; }
.page-title { font-family: var(--font-serif); font-size: 30px; font-weight: 700; margin: 0; letter-spacing: -0.01em; color: var(--text-primary); }
.page-subtitle { font-size: 14px; color: var(--text-secondary); margin-top: 4px; }

/* Dashboard-style greeting header */
.dash-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.dash-greeting { font-family: var(--font-serif); font-size: 34px; font-weight: 700; margin: 4px 0 4px; letter-spacing: -0.01em; }
.dash-subtitle { font-size: 14px; color: var(--text-secondary); }

/* Live clock above the greeting */
.dash-clock { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 2px; }
.dash-clock .dc-date { font-size: 15px; font-weight: 700; color: var(--rust); letter-spacing: 0.02em; }
.dash-clock .dc-time {
  font-family: var(--font-serif); font-size: 30px; font-weight: 700;
  color: var(--text-primary); font-variant-numeric: tabular-nums; letter-spacing: 0.01em;
}

/* Two-up dashboard rows: equal-height cards, tall lists scroll inside */
.dash-row { align-items: stretch; }
.dash-row > .card { display: flex; flex-direction: column; }
.dash-row > .card + .card { margin-top: 0; } /* grid gap handles spacing; margin would shrink the track */
.dash-scroll { max-height: 320px; overflow-y: auto; }

/* Report chart bodies: consistent height so paired cards line up */
.report-chart { min-height: 240px; overflow-x: auto; display: flex; flex-direction: column; justify-content: center; }
.report-chart .chart-empty { margin: auto; }
.reports-section { font-family: var(--font-serif); font-size: 22px; font-weight: 700; margin: 26px 0 14px; letter-spacing: -0.01em; }

/* ---------- Components ---------- */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }
.card h2 { margin: 0 0 4px; font-weight: 800; font-size: 20px; letter-spacing: -0.01em; }
.card h3 { margin: 0 0 14px; font-weight: 800; font-size: 19px; letter-spacing: -0.01em; color: var(--text-primary); }
.card h3:only-child, .toolbar h3 { margin-bottom: 0; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1000px) { .grid-3, .grid-4 { grid-template-columns: repeat(2,1fr); } }

.stat-tile {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.stat-value { font-size: 26px; font-weight: 700; margin-top: 6px; letter-spacing: -0.01em; }
.stat-sub { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.stat-warning .stat-value { color: var(--text-stat-warning); }
.stat-critical .stat-value { color: var(--status-critical); }
.stat-good .stat-value { color: var(--text-stat-good); }

/* Bento hero stat card (dashboard) — icon tile + trend + value + sub */
.hero-stat { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.hero-stat-top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 14px; }
.hero-stat-icon { width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 18px; }
.hero-stat-icon.sage { background: var(--brand-primary-light); }
.hero-stat-icon.rose { background: var(--tile-rose-bg); }
.hero-stat-icon.sand { background: var(--tile-sand-bg); }
.hero-stat-trend { font-size: 12px; font-weight: 700; color: var(--text-trend-up); }
.hero-stat-trend.down { color: var(--status-critical); }
.hero-stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.hero-stat-value { font-family: var(--font-serif); font-size: 30px; font-weight: 700; margin: 4px 0 4px; }
.hero-stat-sub { font-size: 12.5px; color: var(--text-secondary); }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .search { flex: 1; min-width: 200px; }

/* In-page tab strip (Accounts, Inventory) */
.subtabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 14px; border-bottom: 1px solid var(--border); }
.subtab {
  background: none; border: none; border-bottom: 2px solid transparent;
  padding: 9px 14px; font-size: 14px; font-weight: 600; color: var(--text-secondary);
  cursor: pointer; margin-bottom: -1px;
}
.subtab:hover { color: var(--text-primary); }
.subtab.active { color: var(--brand-primary); border-bottom-color: var(--brand-primary); }

input, select, textarea {
  font-family: inherit; font-size: 14px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-white);
  color: var(--text-primary);
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand-accent);
  box-shadow: 0 0 0 3px var(--brand-primary-light);
}
textarea { resize: vertical; min-height: 74px; line-height: 1.5; }
textarea.autogrow { overflow: hidden; }
label { font-size: 13.5px; color: var(--text-primary); display: block; margin-bottom: 6px; font-weight: 700; letter-spacing: -0.005em; }
.field { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr; } }
.icon-btn {
  align-self: end; flex-shrink: 0; width: 34px; height: 38px; margin-bottom: 14px;
  border: 1px solid var(--border); background: var(--bg-surface); color: var(--text-muted);
  border-radius: var(--radius-sm); font-size: 18px; line-height: 1; cursor: pointer;
}
.icon-btn:hover { background: var(--bg-badge-critical); color: var(--text-badge-critical); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px; border-radius: 999px; border: 1px solid transparent;
  background: var(--brand-primary); color: #fff; font-weight: 600; font-size: 14px;
  cursor: pointer;
}
.btn:hover { background: var(--brand-primary-dark); }
.btn.secondary { background: var(--bg-surface); color: var(--text-primary); border-color: var(--border); }
.btn.secondary:hover { background: var(--bg-surface-2); }
.btn.outline { background: transparent; color: var(--brand-primary); border-color: var(--border); font-weight: 700; }
.btn.outline:hover { background: var(--brand-primary-light); }
.btn.danger { background: var(--status-critical); }
.btn.small { padding: 6px 12px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--gridline); }
th { color: var(--text-muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .03em; }
tr:hover td { background: var(--bg-surface-2); }
.table-wrap { overflow-x: auto; }
.row-link { cursor: pointer; }

.badge {
  display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0;
  padding: 4px 11px; border-radius: 999px; font-size: 12px; font-weight: 600;
  white-space: nowrap;
}
.badge::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: 0.8; }
.badge-good { background: var(--brand-primary-light); color: var(--text-badge-good); }
.badge-warning { background: var(--tile-sand-bg); color: var(--text-badge-warning); }
.badge-serious { background: var(--bg-badge-serious); color: var(--text-badge-serious); }
.badge-critical { background: var(--bg-badge-critical); color: var(--text-badge-critical); }
.badge-neutral { background: var(--bg-surface-2); color: var(--text-secondary); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tab { padding: 9px 14px; font-size: 13px; font-weight: 600; color: var(--text-secondary); cursor: pointer; border-bottom: 2px solid transparent; }
.tab.active { color: var(--brand-primary-dark); border-color: var(--brand-primary); }

.modal-backdrop {
  position: fixed; inset: 0; background: var(--modal-backdrop);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow-y: auto; z-index: 50;
  backdrop-filter: blur(1px);
}
.modal { background: var(--surface-white); border-radius: var(--radius); padding: 22px 24px; width: 100%; max-width: 640px; box-shadow: var(--modal-shadow); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal { max-height: 92vh; overflow-y: auto; }
.modal-header h3 { font-weight: 800; font-size: 17px; letter-spacing: -0.01em; margin: 0; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted); }

.empty-state { text-align: center; color: var(--text-muted); padding: 40px 20px; font-size: 13px; }

.chart-svg { width: 100%; height: auto; display: block; }
.chart-gridline { stroke: var(--gridline); stroke-width: 1; }
.chart-axis { stroke: var(--axis); stroke-width: 1; }
.chart-axis-label { fill: var(--text-muted); font-size: 11px; }
.chart-value-label { fill: var(--text-secondary); font-size: 12px; }
.chart-empty { color: var(--text-muted); font-size: 13px; padding: 30px 0; text-align: center; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 10px; font-size: 12px; color: var(--text-secondary); }
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; }

.dosha-chip { display: inline-flex; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--brand-primary-light); color: var(--brand-primary-dark); }

.helper-text { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ---------- OP Assessment (doctor single-scroll patient view) ---------- */
.section-divider-label {
  font-size: 15px; font-weight: 800; color: var(--text-primary);
  letter-spacing: -0.01em; margin: 24px 0 12px;
  padding-bottom: 7px; border-bottom: 2px solid var(--gridline);
}
.tick-group { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.tick-option {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12.5px; color: var(--text-secondary);
  background: var(--surface-white); border: 1px solid var(--border); border-radius: 999px;
  padding: 5px 11px; cursor: pointer; user-select: none;
}
.tick-option input { width: auto; margin: 0; }
.tick-option:has(input:checked) { background: var(--brand-primary-light); border-color: var(--brand-primary); color: var(--brand-primary-dark); font-weight: 600; }
.personal-history-row { display: grid; grid-template-columns: 150px 1fr; gap: 12px; align-items: start; padding: 10px 0; border-bottom: 1px solid var(--gridline); }
.personal-history-row:last-child { border-bottom: none; }
.ph-label { font-size: 13px; font-weight: 600; color: var(--text-primary); padding-top: 6px; }
.ph-note { margin-top: 2px; }
.vitals-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 800px) {
  .vitals-row { grid-template-columns: repeat(2, 1fr); }
  .personal-history-row { grid-template-columns: 1fr; }
}

/* ---------- Dashboard bento components ---------- */
.care-flow-row { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--gridline); }
.care-flow-row:last-of-type { border-bottom: none; }
.care-flow-time { width: 74px; flex-shrink: 0; }
.care-flow-time .t { font-weight: 700; font-size: 14px; }
.care-flow-time .type { font-size: 10.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.care-flow-who { flex: 1; min-width: 0; }
.care-flow-who .name { font-weight: 600; font-size: 14px; }
.care-flow-who .detail { font-size: 12.5px; color: var(--text-secondary); }
.care-flow-link { text-align: center; padding-top: 12px; }
.care-flow-link a { font-size: 13px; font-weight: 600; color: var(--rust); cursor: pointer; }

.card-link { font-size: 13px; font-weight: 600; color: var(--brand-primary-ink); cursor: pointer; display: inline-flex; align-items: center; gap: 3px; }

.donut-wrap { display: flex; align-items: center; gap: 20px; margin-bottom: 16px; }
.donut-center-value { font-family: var(--font-serif); font-size: 26px; font-weight: 700; }
.donut-center-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.donut-rows { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.donut-row-top { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.donut-row-top .frac { font-weight: 700; }
.progress-track { height: 6px; border-radius: 999px; background: var(--gridline); overflow: hidden; }
.progress-fill { height: 100%; border-radius: 999px; background: var(--brand-primary); }
.progress-fill.amber { background: var(--progress-amber); }

.nudge-banner { background: var(--tile-sand-bg); border-radius: var(--radius-sm); padding: 12px 14px; font-size: 13px; color: var(--text-primary); }
.nudge-banner strong { color: var(--rust-strong); }

.attention-row { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--gridline); cursor: pointer; }
.attention-row:last-child { border-bottom: none; }
.attention-row .num { font-family: var(--font-serif); font-size: 22px; font-weight: 700; color: var(--rust-strong); width: 28px; flex-shrink: 0; }
.attention-row .body { flex: 1; min-width: 0; }
.attention-row .body .title { font-weight: 600; font-size: 13.5px; }
.attention-row .body .sub { font-size: 12px; color: var(--text-muted); }
.attention-row .chev { color: var(--text-muted); flex-shrink: 0; }
.attention-row:hover .body .title { color: var(--brand-primary-dark); }

.patient-row-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px; }
@media (max-width: 700px) { .patient-row-grid { grid-template-columns: 1fr; } }
.patient-row { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.patient-row .name { font-weight: 600; font-size: 13.5px; }
.patient-row .sub { font-size: 12px; color: var(--text-muted); }
.patient-row:hover .name { color: var(--brand-primary-dark); }

.live-dot-wrap { position: absolute; top: 18px; right: 20px; font-size: 11px; font-weight: 700; color: var(--rust); display: flex; align-items: center; gap: 5px; }
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--status-good); }

/* ---------- Login screen ---------- */
.login-screen {
  width: 100%; min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--bg-page);
}
.login-card {
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow);
  padding: 38px 40px; width: 100%; max-width: 400px;
}
.login-brand { text-align: center; margin-bottom: 6px; }
.login-logo { width: 100%; max-width: 240px; height: auto; margin: 0 auto 20px; display: block; }
.login-brand h1 { font-family: var(--font-serif); font-size: 24px; margin: 0 0 10px; font-weight: 700; letter-spacing: -0.01em; }
.login-brand p { font-size: 14px; color: var(--text-secondary); margin: 0; line-height: 1.5; }
.login-brand .consultant-line { font-size: 12px; color: var(--text-muted); margin-top: 10px; }
.login-error { background: var(--bg-login-error); color: var(--text-login-error); padding: 8px 12px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 12px; }
.login-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 22px; }
.login-actions .btn { width: 100%; padding: 13px 16px; font-size: 15px; }
.login-back { text-align: left; font-size: 13px; color: var(--text-secondary); cursor: pointer; margin-bottom: 14px; display: inline-flex; align-items: center; gap: 4px; }
.login-toggle { text-align: center; font-size: 13px; margin-top: 14px; color: var(--text-secondary); }
.login-toggle a { cursor: pointer; }
.demo-hint { font-size: 11px; color: var(--text-muted); text-align: center; margin-top: 20px; line-height: 1.6; }

.offline-banner {
  background: var(--tile-sand-bg); color: var(--text-offline-banner); font-size: 13px;
  padding: 8px 20px; text-align: center; font-weight: 600;
  border-bottom: 1px solid var(--border-offline-banner);
}

/* ---------- Icons ---------- */
.icon { display: block; flex-shrink: 0; }
.hero-stat-icon.sage { color: var(--brand-primary-dark); }
.hero-stat-icon.rose { color: var(--rust-strong); }
.hero-stat-icon.sand { color: var(--text-icon-sand); }

/* ---------- Filter pills ---------- */
.pill-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  border: 1px solid var(--border); background: var(--bg-surface); color: var(--text-secondary);
  font-size: 13px; font-weight: 600; padding: 7px 16px; border-radius: 999px; cursor: pointer;
}
.pill.active { background: var(--brand-primary); color: #fff; border-color: var(--brand-primary); }
.pill:hover:not(.active) { background: var(--bg-surface-2); }

/* ---------- Treatment cards ---------- */
.treatment-card {
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow);
}
.treatment-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.treatment-icon {
  width: 36px; height: 36px; border-radius: 10px; background: var(--tile-rose-bg); color: var(--rust-strong);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.tc-title { font-weight: 700; font-size: 15px; }
.tc-sub { font-size: 12.5px; color: var(--text-secondary); margin-top: 2px; }
.phase-row { margin-bottom: 14px; }
.tc-meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; padding-top: 10px; border-top: 1px solid var(--gridline); margin-bottom: 10px; }
.tc-meta-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 2px; }
.tc-meta-value { font-size: 13px; font-weight: 600; }
.tc-quote { background: var(--bg-surface-2); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 13px; font-style: italic; color: var(--text-secondary); }

/* ---------- Settings ---------- */
.settings-layout { display: grid; grid-template-columns: 260px 1fr; gap: 20px; align-items: start; }
@media (max-width: 800px) { .settings-layout { grid-template-columns: 1fr; } }
.settings-nav { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; box-shadow: var(--shadow); }
.settings-nav-item {
  display: flex; align-items: center; justify-content: space-between; padding: 11px 14px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; color: var(--text-secondary); cursor: pointer;
}
.settings-nav-item span { color: var(--text-muted); }
.settings-nav-item:hover { background: var(--bg-surface-2); }
.settings-nav-item.active { background: var(--brand-primary-light); color: var(--brand-primary-dark); }
.settings-card-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
.settings-card-icon {
  width: 38px; height: 38px; border-radius: 10px; background: var(--brand-primary-light); color: var(--brand-primary-dark);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.pref-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0;
  border-bottom: 1px solid var(--gridline);
}
.pref-row:last-of-type { border-bottom: none; }
.toggle-switch { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-switch span {
  position: absolute; inset: 0; background: var(--gridline); border-radius: 999px; cursor: pointer; transition: background .15s;
}
.toggle-switch span::before {
  content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .15s;
}
.toggle-switch input:checked + span { background: var(--brand-primary); }
.toggle-switch input:checked + span::before { transform: translateX(18px); }
.toggle-switch input:disabled + span { opacity: 0.5; cursor: not-allowed; }

.role-select { width: auto; min-width: 130px; }

.theme-option-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 640px) { .theme-option-grid { grid-template-columns: 1fr; } }
.theme-option {
  position: relative;
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  text-align: left; font-family: inherit;
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 14px 16px; cursor: pointer;
}
.theme-option:hover { background: var(--bg-surface-2); }
.theme-option.active { border-color: var(--brand-primary); background: var(--brand-primary-light); }
.theme-option-icon { color: var(--brand-primary-dark); }
.theme-option-label { font-weight: 700; font-size: 14px; color: var(--text-primary); }
.theme-option-hint { font-size: 12px; color: var(--text-secondary); }
.theme-option-check {
  position: absolute; top: 12px; right: 12px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--brand-primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
}

.hidden { display: none !important; }

/* Toasts (SW update prompt, sync notices) */
#aloka-toast-host {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  z-index: 1000; display: flex; flex-direction: column; gap: 8px; align-items: center;
  width: min(520px, calc(100vw - 32px));
}
.aloka-toast {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: var(--text-primary); color: var(--surface-white);
  border-radius: var(--radius-sm); padding: 12px 14px;
  box-shadow: var(--shadow); font-size: 13px; line-height: 1.4;
}
.aloka-toast span { flex: 1; }
.aloka-toast-action {
  flex-shrink: 0; font-family: inherit; font-size: 13px; font-weight: 700;
  background: var(--brand-primary); color: #fff; border: none;
  border-radius: 8px; padding: 6px 12px; cursor: pointer;
}
.aloka-toast-close {
  flex-shrink: 0; background: none; border: none; color: inherit;
  font-size: 18px; line-height: 1; cursor: pointer; opacity: 0.7;
}
.aloka-toast-close:hover { opacity: 1; }

/* ---------- Patient workspace ---------- */
.back-link { font-size: 13px; font-weight: 600; color: var(--rust); display: inline-block; margin: 4px 0 10px; }
.patient-header .ph-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.patient-header h2 { font-family: var(--font-serif); font-size: 24px; font-weight: 700; margin: 0; }
.patient-header .ph-mrn { font-family: system-ui, sans-serif; font-weight: 500; font-size: 13px; color: var(--text-muted); }
.patient-header .ph-facts { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 6px; font-size: 13.5px; color: var(--text-secondary); }
.patient-header .ph-facts b { color: var(--text-primary); }
.patient-header .ph-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 20px;
  margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--gridline);
}
.patient-header .ph-grid > div { font-size: 13.5px; color: var(--text-primary); }
.patient-header .ph-label { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); font-weight: 700; margin-bottom: 2px; }
@media (max-width: 720px) { .patient-header .ph-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 440px) { .patient-header .ph-grid { grid-template-columns: 1fr; } }

.subcard { background: var(--bg-surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 16px; }
.mini-card { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; margin-bottom: 12px; background: var(--bg-surface); }
.mini-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.mini-card-top h3 { margin: 0; font-size: 15px; }
.rx-items { margin: 6px 0 8px; padding-left: 18px; font-size: 13px; color: var(--text-secondary); }
.rx-legend { font-size: 12.5px; color: var(--text-secondary); background: var(--bg-surface-2); border-radius: var(--radius-sm); padding: 8px 12px; margin-bottom: 10px; line-height: 1.6; }
.rx-legend b { color: var(--text-primary); }
.rx-row {
  grid-template-columns: 1.5fr 1fr 1.3fr 1.1fr 0.8fr 0.7fr 1.2fr auto;
  gap: 10px; align-items: end; padding: 10px 0; border-bottom: 1px dashed var(--gridline);
}
.rx-row:last-of-type { border-bottom: none; }
.rx-row .field { margin-bottom: 0; }
.rx-row .icon-btn { margin-bottom: 0; }
@media (max-width: 1024px) { .rx-row { grid-template-columns: 1fr 1fr 1fr; } .rx-row .icon-btn { grid-column: -2 / -1; justify-self: end; } }
@media (max-width: 560px) { .rx-row { grid-template-columns: 1fr 1fr; } }
.rx-table { font-size: 13px; }
.rx-table th, .rx-table td { padding: 8px 10px; }
.rx-table th:first-child, .rx-table td:first-child { width: 28px; color: var(--text-muted); }
.tc-line { margin-top: 6px; font-size: 13px; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

.history-list { display: flex; flex-direction: column; gap: 2px; max-height: 360px; overflow-y: auto; }
.history-item { padding: 10px 0; border-bottom: 1px solid var(--gridline); font-size: 14px; }
.history-item:last-child { border-bottom: none; }

/* ---------- Body map ---------- */
.body-map { position: relative; display: flex; flex-direction: column; gap: 16px; align-items: center; }
.bm-figures { display: flex; justify-content: center; gap: 28px; width: 100%; max-width: 620px; flex-wrap: wrap; }
.bm-figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.bm-figure figcaption { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-muted); }
.bm-svg { width: 190px; max-width: 42vw; height: auto; }

.body-part, .joint-node {
  fill: var(--gridline); stroke: var(--text-muted); stroke-width: 1;
  cursor: pointer; transition: fill .12s ease;
}
.joint-node { fill: var(--bg-surface); stroke: var(--brand-primary); stroke-width: 1.5; }
.body-map:not(.is-readonly) .body-part:hover,
.body-map:not(.is-readonly) .joint-node:hover { fill: var(--brand-primary); }
.body-part:focus-visible, .joint-node:focus-visible { outline: 2px solid var(--brand-primary); outline-offset: 1px; }
.body-part.selected, .joint-node.selected {
  fill: var(--status-critical); stroke: var(--status-critical);
}
.body-map.is-readonly .body-part, .body-map.is-readonly .joint-node { cursor: default; }

.bm-tooltip {
  position: absolute; z-index: 5; pointer-events: none;
  transform: translate(-50%, -140%);
  background: var(--text-primary); color: var(--bg-surface);
  padding: 4px 9px; border-radius: 6px; font-size: 12px; font-weight: 600; white-space: nowrap;
}

.body-map-panel { width: 100%; max-width: 520px; background: var(--bg-surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; }
.bmp-head { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--text-secondary); margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; }
.bmp-head button { background: none; border: none; color: var(--text-muted); font-size: 18px; line-height: 1; cursor: pointer; }
.body-map-chips { display: flex; flex-wrap: wrap; gap: 6px; min-height: 22px; }
.bm-chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--surface-white); border: 1px solid var(--border); color: var(--text-primary);
  border-radius: 8px; padding: 4px 10px; font-size: 12.5px; font-weight: 600;
}
.bm-chip button { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 15px; line-height: 1; padding: 0; }
.bm-chip button:hover { color: var(--text-badge-critical); }

/* ---------- Attachments ---------- */
.attach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.attach-item { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px; text-align: center; background: var(--bg-surface); }
.attach-thumb { width: 100%; height: 90px; object-fit: cover; border-radius: 6px; background: var(--bg-surface-2); cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--text-muted); }
.attach-name { font-size: 12px; font-weight: 600; margin-top: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-meta { font-size: 11px; color: var(--text-muted); }
.attach-actions { display: flex; gap: 4px; justify-content: center; margin-top: 8px; }

/* ---------- Permissions matrix ---------- */
.perm-matrix th, .perm-matrix td { text-align: center; }
.perm-matrix th:first-child, .perm-matrix td:first-child { text-align: left; }
.perm-matrix input { width: auto; }

/* ---------- Responsive shell (sidebar -> top strip under 880px) ---------- */
@media (max-width: 880px) {
  #app-root, #app-root-inner { flex-direction: column; }
  .sidebar {
    width: 100%; flex-direction: row; align-items: center; gap: 8px;
    padding: 10px 12px; border-right: none; border-bottom: 1px solid var(--border);
    overflow-x: auto; position: sticky; top: 0; z-index: 20;
  }
  .sidebar .brand { padding: 0; margin: 0 6px 0 0; flex-shrink: 0; }
  .sidebar .brand > div { display: none; }
  #nav-links { display: flex; gap: 4px; flex: 1; }
  .nav-sep { display: none; }
  .nav-link { padding: 8px 12px; white-space: nowrap; margin: 0; }
  .sidebar-footer { display: flex; align-items: center; gap: 8px; margin: 0; }
  .sidebar-footer .tip-card, .sidebar-footer .consultant-credit { display: none; }
  .sidebar-user { border: none; padding: 4px; margin: 0; }
  .sidebar-user .who { display: none; }
  .view { padding: 18px 16px 48px; }
  .grid-2 { grid-template-columns: 1fr; }
  .page-title { font-size: 25px; }
  .dash-greeting { font-size: 27px; }
}
/* Official alokaayurveda.com branding; existing dark-theme/status tokens retained. */
@font-face{font-family:Inter;src:url('/fonts/inter.ttf') format('truetype');font-display:swap}@font-face{font-family:Marcellus;src:url('/fonts/marcellus.ttf') format('truetype');font-display:swap}
:root:not([data-theme=dark]){--brand-primary:#5c8607;--brand-primary-dark:#4b6f05;--brand-primary-light:#e3e9d8;--bg-page:#fdfaf1;--font-serif:Marcellus,Georgia,serif}
body{font-family:Inter,Arial,sans-serif}.official-brand{display:block;text-decoration:none;padding:24px 20px}.official-brand img{width:190px;max-width:100%;height:auto}.tip-body a{color:var(--brand-primary-ink)}.sidebar .nav-link{font-size:14px}.helper-text{line-height:1.7}
