/* 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: repeat(4, minmax(0, 1fr));
  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; }

/* 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}

/* Responsive clinic workspace and permission-filtered module drawer. */
#app-root-inner{min-height:100dvh;max-width:100%;align-items:stretch}
.main,.view,.grid>*,.settings-content,.field{min-width:0}
.sidebar{position:sticky;top:0;height:100dvh;overflow-y:auto;overscroll-behavior:contain}
.mobile-header,.menu-close,.menu-backdrop{display:none}
.toolbar{flex-wrap:wrap;gap:12px}
.toolbar>*{max-width:100%;min-width:0}
.table-wrap{width:100%;max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch}
.card{min-width:0;max-width:100%}
img,canvas{max-width:100%}
input,select,textarea{max-width:100%;box-sizing:border-box}
.page-header>*,.dash-header>*{min-width:0;max-width:100%}
@media(max-width:1024px){
 #app-root,#app-root-inner{flex-direction:column}
 .mobile-header{display:flex;align-items:center;justify-content:space-between;gap:16px;position:sticky;top:0;z-index:30;background:var(--bg-surface);border-bottom:1px solid var(--border);padding:10px 16px;padding-top:max(10px,env(safe-area-inset-top))}
 .mobile-header img{width:138px;max-height:48px;object-fit:contain;display:block}
 .menu-toggle,.menu-close{border:1px solid var(--border);background:var(--bg-surface);color:var(--text-primary);border-radius:10px;min-height:44px;min-width:44px;cursor:pointer}
 .menu-toggle{display:flex;align-items:center;gap:9px;padding:8px 12px;font:inherit}
 .menu-close{display:block;align-self:flex-end;font-size:28px;line-height:1}
 .sidebar{position:fixed;inset:0 auto 0 0;width:min(320px,88vw);height:100dvh;z-index:60;transform:translateX(-105%);visibility:hidden;transition:transform .2s ease,visibility .2s;padding:16px;padding-top:max(16px,env(safe-area-inset-top));padding-bottom:max(16px,env(safe-area-inset-bottom));box-shadow:8px 0 30px #0003}
 .menu-open .sidebar{transform:translateX(0);visibility:visible}
 .menu-backdrop{position:fixed;inset:0;z-index:50;border:0;background:#0007;width:100%;height:100dvh}
 .menu-open .menu-backdrop{display:block}
 body.module-menu-open{overflow:hidden}
 .sidebar .nav-link{min-height:44px;display:flex;align-items:center}
 .view{padding:22px 20px 48px}
 .settings-layout{grid-template-columns:1fr}
 .sync-strip{flex-wrap:wrap;gap:8px;padding:10px 20px}
 .grid-3,.grid-4{grid-template-columns:repeat(2,minmax(0,1fr))}
}
@media(max-width:600px){
 .view{padding:18px 12px calc(32px + env(safe-area-inset-bottom))}
 .grid-2,.grid-3,.grid-4,.form-row{grid-template-columns:minmax(0,1fr)}
 .page-title,.dash-greeting{font-size:26px;overflow-wrap:anywhere}
 .card{padding:16px 12px}
 .page-header,.dash-header{align-items:stretch;gap:12px}
 .page-header>.btn,.dash-header>.btn{width:100%;justify-content:center}
 .toolbar>input,.toolbar>select{width:100%}
 input,select,textarea{font-size:16px}
 .btn{min-height:44px;white-space:normal}
 .sync-strip{padding:10px 12px;font-size:12px}
 .sync-sub{display:none}
 .sync-time{font-size:11px}
 .modal-backdrop{padding:10px}
 .modal{padding:18px 14px;max-height:calc(100dvh - 20px);overflow-y:auto}
 .rx-row{grid-template-columns:minmax(0,1fr)}
 .rx-row .icon-btn{grid-column:auto}
 .body-map-panel{padding:10px;box-sizing:border-box}
 .bm-figures{gap:8px}
 .bm-svg{max-width:37vw}
 .patient-header .ph-grid{grid-template-columns:minmax(0,1fr)}
 th,td{padding:10px 8px}
}
@media(prefers-reduced-motion:reduce){.sidebar{transition:none}}

/* Consistent prescription controls across screen sizes. */
.rx-row .field { min-width: 0; max-width: none; }
.rx-row .field input, .rx-row .field select { width: 100%; min-width: 0; height: 44px; box-sizing: border-box; }
.rx-row .field label { display: block; min-height: 20px; }

/* Patient directory and treatment-day workspace. */
.patient-filters { align-items:end; gap:16px; }
.patient-filters .field:first-child { flex:1; min-width:200px; }
.patient-filters .field { margin:0; }
.patient-detail-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:12px; margin:16px 0; }
.patient-detail-grid > div { min-width:0; padding:14px; border:1px solid var(--gridline); border-radius:10px; background:var(--bg-surface-2); }
.patient-detail-grid dt { font-size:12px; color:var(--text-secondary); margin-bottom:6px; }
.patient-detail-grid dd { margin:0; font-size:14px; overflow-wrap:anywhere; white-space:pre-wrap; }
.patient-name-link { padding:0; border:0; background:none; font:inherit; font-weight:700; text-align:left; color:var(--text-primary); cursor:pointer; overflow-wrap:anywhere; }
.patient-name-link span { font-weight:400; }
.patient-name-link:hover { text-decoration:underline; }
.today-therapy { margin:8px 0; padding:10px; border-radius:8px; background:var(--bg-surface-2); line-height:1.6; }
.treatment-summary-content { width:min(1120px,96vw); max-width:1120px; max-height:92dvh; overflow:auto; }
.summary-reports { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; margin:16px 0; }
.summary-reports details { padding:14px; border:1px solid var(--gridline); border-radius:10px; }
.summary-reports summary { cursor:pointer; font-weight:600; }
.therapy-notes { background:var(--bg-surface-2); padding:12px; border-radius:8px; margin:12px 0; white-space:pre-wrap; }
.therapy-session-table td { vertical-align:top; white-space:pre-wrap; min-width:80px; }
.therapy-editor, .course-editor-root .modal-backdrop, .assessment-report-root .modal-backdrop { z-index:1200; }
.session-date { padding:12px; border-radius:8px; background:var(--bg-surface-2); }
@media(max-width:800px){.patient-detail-grid {grid-template-columns:repeat(2,minmax(0,1fr));}.summary-reports {grid-template-columns:1fr;}}
@media(max-width:480px){.patient-detail-grid {grid-template-columns:1fr;}.patient-filters {align-items:stretch;}.patient-filters .field {width:100%;}.treatment-summary-content {padding:16px;}.tc-meta-grid{grid-template-columns:1fr;}}
@media(max-width:700px){
 .therapy-table-wrap{overflow:visible;}
 .therapy-session-table, .therapy-session-table tbody{display:block;width:100%;min-width:0;}
 .therapy-session-table thead{display:none;}
 .therapy-session-table tr{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;padding:12px;margin:12px 0;border:1px solid var(--gridline);border-radius:10px;}
 .therapy-session-table td{display:block;min-width:0;padding:0;border:0;overflow-wrap:anywhere;}
 .therapy-session-table td::before{content:attr(data-label);display:block;font-size:11px;color:var(--text-secondary);margin-bottom:3px;}
}

@media(max-width:480px){.patient-detail-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;}.patient-detail-grid>div{padding:10px;}.patient-detail-grid .patient-address{grid-column:1/-1;}}
@media(max-width:700px){.therapy-session-table td{background:transparent!important;}}
.treatment-card { display:flex; flex-direction:column; }
.treatment-card .today-treatment-block { margin:4px 0 16px; }
.treatment-card .course-progress { margin-top:auto; padding-top:18px; }

/* Booking and visit forms */
.form-row>.field{min-width:0;flex:1}.field input:not([type=checkbox]):not([type=radio]),.field select,.field-value{box-sizing:border-box;min-height:46px;width:100%;min-width:0}.field select{color:var(--text-primary);background-color:var(--bg-surface);padding-right:32px}.field select option{background:var(--bg-surface);color:var(--text-primary)}.field-value{display:flex;align-items:center;padding:10px 12px;border:1px solid var(--border);border-radius:8px}.field input[type=date],.field input[type=time]{max-width:100%}.form-row{align-items:start}.patient-name-link{background:none;border:0;color:var(--brand-primary-ink);font:inherit;cursor:pointer;padding:0;text-align:left}.availability-grid{display:grid;grid-template-columns:repeat(7,minmax(0,1fr));gap:8px;margin:16px 0}.availability-day{min-width:0;padding:12px 4px;border:1px solid var(--border);border-radius:8px;background:var(--bg-surface);color:var(--text-primary);cursor:pointer;display:flex;flex-direction:column;gap:5px;align-items:center}.availability-day.blocked{background:#f8e5e0;border-color:#c46250;color:#8f3022}.availability-day:disabled{opacity:.5;cursor:not-allowed}.availability-day small{font-size:10px}.availability-legend{display:flex;gap:16px;align-items:center}.row-actions input,.row-actions select{width:auto;max-width:100%}.modal .form-row{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px}.modal input[readonly]{background:var(--bg-surface-2)}
@media(max-width:600px){.availability-grid{grid-template-columns:repeat(3,minmax(0,1fr))}.modal .form-row{grid-template-columns:minmax(0,1fr);gap:0}.toolbar>.row-actions{width:100%;flex-wrap:wrap}.row-actions input,.row-actions select{flex:1;min-width:120px}.modal{padding:20px;max-width:calc(100vw - 24px)}.field{min-width:0}}

.modal .dob-age-row{grid-template-columns:minmax(0,1.4fr) minmax(0,1fr)}
/* Uniform form controls across registration, appointments and finance. */
.form-row{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px;align-items:start}
.form-row>.field{min-width:0;max-width:none!important}
.field input:not([type=checkbox]):not([type=radio]),.field select,.field-value{width:100%;box-sizing:border-box;min-height:46px;height:46px;line-height:normal}
.field-value{display:flex;align-items:center;padding:10px 12px;border:1px solid var(--border);border-radius:8px}
.form-row .field label{display:block;min-height:20px;margin-bottom:6px}
.invoice-item-row{grid-template-columns:2fr 1fr 1fr}
.report-filters{display:grid;grid-template-columns:2fr 1fr 1fr auto;align-items:end;gap:16px}
.report-filters .field{margin:0;min-width:0}.report-filters .btn{min-height:46px}
.report-preview{overflow:auto;max-height:60vh;margin-bottom:16px}.report-preview th{text-align:left}.report-preview td{white-space:pre-wrap;overflow-wrap:anywhere}
.subtabs{display:flex;flex-wrap:wrap;gap:8px}.row-actions{flex-wrap:wrap}.btn{min-height:40px}
[hidden]{display:none!important}
@media(max-width:640px){.form-row,.invoice-item-row,.report-filters{grid-template-columns:1fr}.dob-age-row{grid-template-columns:1fr 1fr}.toolbar .row-actions{width:100%}.toolbar .row-actions>.btn{flex:1;white-space:normal}.modal{width:calc(100vw - 24px);box-sizing:border-box}.field select{max-width:100%}}
.dob-age-row{display:grid!important;grid-template-columns:minmax(0,1fr) minmax(0,1fr)!important;gap:16px!important}.dob-age-row>.field{width:auto!important;flex:none!important}.dob-age-row input{min-width:0!important}
.modal .dob-age-row{grid-template-columns:repeat(2,minmax(0,1fr))!important}.modal .invoice-item-row{grid-template-columns:repeat(3,minmax(0,1fr))}
@media(max-width:640px){.modal .invoice-item-row{grid-template-columns:1fr}}

/* Local AI uses the same responsive form and draft-review patterns. */
.ai-modal{max-width:900px;width:calc(100vw - 32px)}.ai-draft textarea{width:100%;resize:vertical;min-height:220px;line-height:1.65;white-space:pre-wrap}.ai-submit{display:flex;align-self:end}.ai-submit .btn{width:100%;min-height:46px}.ai-draft details{margin:14px 0}.ai-patient-host .page-title{font-size:24px}.ai-patient-host .page-header{gap:12px}.ai-draft .tick-option{margin:14px 0}.ai-patient-host .page-header,.ph-top{flex-wrap:wrap}
@media(max-width:640px){.ai-modal{width:calc(100vw - 16px);padding:16px}.ai-draft .row-actions>.btn{flex:1}.ai-draft textarea{font-size:16px}}

/* Readable local drafts and balanced room scheduling. */
.ai-readable{font-size:16px;line-height:1.85;max-width:78ch;margin:20px auto;overflow-wrap:anywhere;white-space:pre-wrap}
.ai-readable p{margin:0 0 14px}.ai-readable h3{font-size:17px;line-height:1.5;margin:24px 0 12px;color:var(--text-primary)}
.ai-readable .ai-bullet{padding-left:18px;position:relative}.ai-readable .ai-bullet:before{content:'\2022';position:absolute;left:0}
.ai-readable hr{border:0;border-top:1px solid var(--border);margin:24px 0}.ai-readable[lang=ml]{line-height:2;font-size:17px}
.ai-clinical-notice{padding:14px 16px;background:var(--bg-surface-2);border-left:4px solid #ab843b;border-radius:8px;line-height:1.6}
.ai-critical{background:#fff1ef;color:#9c251b;border-color:#b42318;font-weight:600}
.therapy-room-grid{display:grid;grid-template-columns:minmax(0,1fr);gap:20px}.therapy-room-grid>.card{min-width:0}
.therapy-room-grid .toolbar{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}
.therapy-room-grid select{min-width:130px;min-height:46px;max-width:100%;box-sizing:border-box}
.room-booking-form .field{min-width:0;width:100%;margin-bottom:16px}.room-booking-form input,.room-booking-form select{width:100%;min-width:0;max-width:100%;height:46px;box-sizing:border-box}
.room-booking-form label{display:block;margin-bottom:6px;min-height:20px}
/* Rooms and session bookings remain full-width, stacked at every breakpoint. */
@media(max-width:640px){.ai-readable{font-size:16px;margin:16px 0}.ai-draft{padding:16px}.therapy-room-grid .toolbar .btn{width:100%}.room-booking-form .form-row{grid-template-columns:minmax(0,1fr)}}

@media(max-width:640px){
.room-bookings-table,.room-bookings-table tbody{display:block;width:100%;min-width:0}
.room-bookings-table thead{display:none}.room-bookings-table tr{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px;padding:16px 0;border-bottom:1px solid var(--border)}
.room-bookings-table td{display:block;white-space:normal!important;min-width:0;padding:0;border:0;overflow-wrap:anywhere}
.room-bookings-table td:before{content:attr(data-label);display:block;font-size:11px;line-height:1.4;margin-bottom:6px;color:var(--text-secondary)}
.room-bookings-table td:first-child,.room-bookings-table td:last-child{grid-column:1/-1}.room-bookings-table select{width:100%!important}
}

/* Shared form geometry: keep native controls accessible without flattening text areas. */
:root { --control-height:46px; --form-gap:16px; }
.field { min-width:0; }
.form-row { gap:var(--form-gap); }
.field label { line-height:1.45; overflow-wrap:anywhere; }
input:not([type=checkbox]):not([type=radio]):not([type=hidden]):not([type=range]):not([type=color]), select {
 box-sizing:border-box; min-width:0; max-width:100%; min-height:var(--control-height);
 padding:10px 12px; border-radius:8px; font:inherit; font-size:14px;
}
.field select { padding-right:32px; }
.field textarea { box-sizing:border-box; width:100%; min-height:104px; padding:12px; line-height:1.6; }
input[type=checkbox],input[type=radio] { width:18px; height:18px; min-height:18px; flex:0 0 18px; accent-color:var(--brand-primary); }
.field input[type=file] { height:auto; min-height:46px; padding:8px; }
input[type=file]::file-selector-button { padding:6px 10px; margin-right:10px; border:1px solid var(--border); border-radius:6px; background:var(--bg-surface-2); color:var(--text-primary); }
input:disabled,select:disabled,textarea:disabled { cursor:not-allowed; opacity:.7; }
input[readonly],textarea[readonly] { background:var(--bg-surface-2); }
.btn:focus-visible,.icon-btn:focus-visible { outline:3px solid var(--brand-accent); outline-offset:3px; }
.form-row>.field { margin-bottom:0; }
.form-row>.field:only-child { grid-column:1/-1; }
.form-row { margin-bottom:16px; }
.modal .invoice-item-row,.invoice-item-row { grid-template-columns:minmax(0,2fr) repeat(2,minmax(0,1fr)); align-items:end; }
.modal .purchase-item-row,.purchase-item-row { grid-template-columns:repeat(2,minmax(0,1fr)); align-items:end; padding:16px; border:1px solid var(--border); border-radius:10px; }
.modal .mu-row,.mu-row { grid-template-columns:minmax(0,2fr) minmax(0,1fr) 46px; align-items:end; }
.mu-row .icon-btn,.rx-row .icon-btn { height:46px; width:46px; margin-bottom:0; align-self:end; }
.rx-row { align-items:end; }
.rx-row .field input,.rx-row .field select { height:46px; }
.toolbar { gap:12px; flex-wrap:wrap; }
.toolbar input,.toolbar select,.toolbar .btn,.report-filters .btn { min-height:46px; }
.modal-backdrop { box-sizing:border-box; padding:16px; }
.modal { box-sizing:border-box; max-height:calc(100dvh - 32px); overflow-y:auto; overscroll-behavior:contain; }
.modal form { min-width:0; }
@media(max-width:900px){ .report-filters { grid-template-columns:repeat(2,minmax(0,1fr)); } }
@media(max-width:640px){
 .form-row,.modal .form-row,.modal .invoice-item-row,.invoice-item-row,.report-filters { grid-template-columns:minmax(0,1fr); gap:14px; }
 .modal .purchase-item-row,.purchase-item-row { grid-template-columns:repeat(2,minmax(0,1fr)); }
 .purchase-item-row>.field:nth-child(-n+2) { grid-column:1/-1; }
 .modal .mu-row,.mu-row { grid-template-columns:minmax(0,1fr) 46px; }
 .mu-row>.field:first-child { grid-column:1/-1; }
 .modal .dob-age-row,.dob-age-row { grid-template-columns:minmax(0,1fr)!important; }
 input:not([type=checkbox]):not([type=radio]):not([type=hidden]),select,textarea { font-size:16px!important; }
 .toolbar input,.toolbar select { width:100%!important; }
 .modal-backdrop { padding:8px; }
 .modal { max-height:calc(100dvh - 16px); padding:20px 16px; }
}

/* Module-level rhythm and full-size filters (desktop, tablet and phone). */
.pill-tabs { gap:10px; margin-block:24px; align-items:center; }
.pill-tabs .pill { min-height:44px; display:inline-flex; align-items:center; justify-content:center; line-height:1.4; white-space:normal; text-align:center; }
#appointment-stats { margin-bottom:24px; }
.therapy-room-grid { align-items:start; gap:24px; }
.therapy-room-grid > .card + .card { margin-top:0; }
.patient-registration-actions .toolbar { margin:0; }
.patient-registration-actions .row-actions { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; width:min(100%,520px); align-items:stretch; }
.patient-registration-actions .btn { min-height:46px; margin:0; justify-content:center; line-height:1.4; white-space:normal; }
#registration-status:empty { display:none; }
#registration-status:not(:empty) { margin:16px 0 0; }
.toolbar.equal-filter-row { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); align-items:center; gap:16px; }
.toolbar.equal-filter-row > input,.toolbar.equal-filter-row > select { width:100%; min-width:0; height:46px; margin:0; }
select { height:46px; min-height:46px; padding:10px 36px 10px 12px; line-height:normal; border-radius:8px; }
select[multiple],select[size]:not([size="1"]) { height:auto; min-height:120px; }
#request-status { flex:1 1 280px; width:100%; max-width:520px; }
.therapy-room-grid select { min-width:170px; }
@media(max-width:640px){
 .pill-tabs { margin-block:20px; gap:10px; }
 .pill-tabs .pill { flex:1 1 160px; }
 .toolbar.equal-filter-row { grid-template-columns:minmax(0,1fr); gap:12px; }
 #request-status { flex-basis:100%; max-width:none; }
 .patient-registration-actions .row-actions { width:100%; }
}
@media(max-width:380px){ .patient-registration-actions .row-actions { grid-template-columns:1fr; } }

/* Compact room registry; retain accessible control heights. */
.rooms-summary-card { padding:16px 20px; }
.rooms-summary-card .toolbar { margin-bottom:8px; }
.rooms-summary-card th { padding-top:8px; padding-bottom:8px; }
.rooms-summary-card td { padding-top:6px; padding-bottom:6px; }
@media(max-width:640px){ .rooms-summary-card { padding:14px; } }
