/* STP Flow — shared theme for all employee-facing pages.
   Light body + dark navy sidebar (Stripe / Linear / Vercel style). */

:root {
    /* Surfaces */
    --bg:           #f6f8fb;
    --surface:      #ffffff;
    --surface-2:    #f1f5f9;
    --surface-3:    #e2e8f0;

    /* Borders */
    --border:        #e2e8f0;
    --border-strong: #cbd5e1;

    /* Text */
    --text:   #0f172a;
    --text-2: #475569;
    --text-3: #94a3b8;
    --text-4: #cbd5e1;

    /* Brand — Speech Therapy Plus LLC
       Derived from the company logo: warm orange + soft teal. */
    --primary:        #E58C2A;        /* warm orange (logo outline) */
    --primary-hover:  #C8741D;        /* deeper orange for hover/active */
    --primary-soft:   #FEF1E1;        /* very light orange tint background */
    --primary-text:   #ffffff;
    --primary-strong: #95632B;        /* tagline rust — useful for emphasis */

    /* Accent — soft teal (logo blue hand) */
    --accent:         #5BAFC9;
    --accent-soft:    #E0F2F7;
    --accent-strong:  #2E839B;

    /* Status */
    --success:        #10b981;
    --success-soft:   #ecfdf5;
    --success-strong: #047857;
    --warning:        #f59e0b;
    --warning-soft:   #fffbeb;
    --warning-strong: #b45309;
    --danger:         #ef4444;
    --danger-soft:    #fef2f2;
    --danger-strong:  #b91c1c;
    --info:           #0ea5e9;
    --info-soft:      #f0f9ff;
    --info-strong:    #0369a1;

    /* Sidebar (light teal-tinted slate — pulls subtly toward brand accent) */
    --sb-bg:          #EAF1F5;        /* soft teal-tinted slate */
    --sb-surface:     #DDE8EE;        /* hover bg, slightly darker */
    --sb-surface-2:   #C8D6DE;        /* badges, dividers */
    --sb-border:      #CFDBE2;
    --sb-text:        #475569;
    --sb-text-strong: #0f172a;
    --sb-text-dim:    #708092;
    --sb-active:      #E58C2A;        /* brand orange */
    --sb-active-bg:   rgba(229, 140, 42, 0.12);

    /* Layout */
    --sb-w:        240px;
    --radius:      8px;
    --radius-sm:   6px;
    --radius-pill: 999px;
    --shadow-sm:   0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow:      0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-md:   0 4px 6px -1px rgba(15, 23, 42, 0.07), 0 2px 4px -2px rgba(15, 23, 42, 0.05);

    --font-sans: "Inter", "InterVariable", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
                 "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@import url("https://rsms.me/inter/inter.css");

* { box-sizing: border-box; }
html, body {
    margin: 0; padding: 0;
    background: var(--bg); color: var(--text);
    font-family: var(--font-sans);
    font-size: 13.5px; line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: "cv02", "cv03", "cv04", "cv11";
    letter-spacing: -0.005em;
}
@supports (font-variation-settings: normal) {
    html, body { font-family: "InterVariable", var(--font-sans); }
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ==================  Layout  ================== */
.app {
    display: grid;
    grid-template-columns: var(--sb-w) 1fr;
    min-height: 100vh;
}

/* ==================  Sidebar  ================== */
.sidebar {
    background: var(--sb-bg);
    color: var(--sb-text);
    padding: 18px 0 0 0;
    display: flex; flex-direction: column;
    position: sticky; top: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    isolation: isolate;
    border-right: 1px solid var(--sb-border);
}

/* Floating accent dots — particles drifting up against the plain dark navy.
   Pure CSS, no JS. */
.sidebar .aurora-dots {
    position: absolute; inset: 0;
    pointer-events: none;
    z-index: -1;
    overflow: hidden;
}
.sidebar .aurora-dots span {
    position: absolute;
    width: 5px; height: 5px;
    border-radius: 50%;
    background: rgba(229, 140, 42, 0.55);
    box-shadow: 0 0 10px rgba(229, 140, 42, 0.45);
    animation: dot-float linear infinite;
    opacity: 0;
}
.sidebar .aurora-dots span.teal {
    background: rgba(91, 175, 201, 0.55);
    box-shadow: 0 0 10px rgba(91, 175, 201, 0.45);
}
@keyframes dot-float {
    0%   { transform: translateY(110vh) translateX(0); opacity: 0; }
    10%  { opacity: 1; }
    90%  { opacity: 1; }
    100% { transform: translateY(-10vh) translateX(20px); opacity: 0; }
}

/* Slight tint behind nav-section labels so they sit clearly above the aurora */
.sidebar nav { position: relative; z-index: 1; }
.sidebar .who-block { position: relative; z-index: 1; }

/* Reduced motion: kill animations for accessibility */
@media (prefers-reduced-motion: reduce) {
    .sidebar::before, .sidebar .aurora-dots span { animation: none; }
}
.sidebar .brand {
    padding: 16px 14px 14px;
    border-bottom: 1px solid var(--sb-border);
}
.sidebar .brand a.brand-link {
    display: flex; align-items: center; gap: 9px;
    text-decoration: none;
    color: var(--sb-text-strong);
}
.sidebar .brand a.brand-link:hover { text-decoration: none; }
.sidebar .brand .logo-mark {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px;
    background: linear-gradient(135deg, #F4A85A, #E58C2A);
    border-radius: 8px;
    color: white; font-size: 15px; font-weight: 800;
    letter-spacing: -0.04em;
    box-shadow: 0 2px 8px rgba(229,140,42,0.4);
    flex-shrink: 0;
}
.sidebar .brand .wordmark {
    display: flex; flex-direction: column; line-height: 1.15;
    min-width: 0;
}
.sidebar .brand .wordmark .name {
    color: var(--sb-text-strong);
    font-size: 14px; font-weight: 700;
    letter-spacing: -0.01em;
}
.sidebar .brand .wordmark .tag {
    color: var(--sb-text-dim);
    font-size: 10px;
    text-transform: uppercase; letter-spacing: 0.07em;
    font-weight: 600;
    margin-top: 1px;
}

.sidebar nav { flex: 1; padding: 10px 12px 10px 12px; }

.sidebar .nav-section {
    color: var(--sb-text-dim);
    font-size: 10px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.06em;
    padding: 12px 10px 6px;
}
.sidebar .nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px;
    color: var(--sb-text);
    border-radius: var(--radius-sm);
    text-decoration: none;
    margin-bottom: 1px;
    font-size: 13px; font-weight: 500;
    transition: background 100ms, color 100ms;
}
.sidebar .nav-item:hover {
    background: var(--sb-surface);
    color: var(--sb-text-strong);
    text-decoration: none;
}
.sidebar .nav-item.active {
    background: var(--sb-active-bg);
    color: var(--sb-text-strong);
    font-weight: 600;
}
.sidebar .nav-item.active::before {
    content: ""; position: absolute; left: 0;
    width: 3px; height: 18px;
    background: var(--sb-active); border-radius: 0 3px 3px 0;
}
.sidebar .nav-item { position: relative; }
.sidebar .nav-item .ico {
    width: 18px; height: 18px;
    flex-shrink: 0;
    opacity: 0.85;
    display: inline-flex; align-items: center; justify-content: center;
}
.sidebar .nav-item .ico svg {
    width: 16px; height: 16px;
    stroke: currentColor; stroke-width: 1.75;
    fill: none; stroke-linecap: round; stroke-linejoin: round;
}
/* Generic icon class — Lucide-style stroke icons */
.icon { display: inline-block; vertical-align: -2px; }
.icon svg {
    width: 14px; height: 14px;
    stroke: currentColor; stroke-width: 1.75;
    fill: none; stroke-linecap: round; stroke-linejoin: round;
}
.icon.lg svg { width: 18px; height: 18px; }
.icon.xl svg { width: 22px; height: 22px; }
.sidebar .nav-item.active .ico { opacity: 1; }
.sidebar .nav-item .nav-badge {
    margin-left: auto;
    padding: 1px 8px; border-radius: var(--radius-pill);
    background: var(--sb-surface-2);
    font-size: 10px; font-weight: 600;
    color: var(--sb-text-strong);
    min-width: 22px; text-align: center;
}
.sidebar .nav-item.active .nav-badge { background: var(--sb-active); }

.sidebar .who-block {
    padding: 14px 16px;
    border-top: 1px solid var(--sb-border);
    margin-top: auto;
    background: var(--sb-surface);
}
.sidebar .who-block label {
    display: block;
    font-size: 10px;
    color: var(--sb-text-dim);
    text-transform: uppercase; letter-spacing: 0.05em;
    font-weight: 600;
    margin-bottom: 6px;
}
.sidebar .who-block input {
    width: 100%;
    background: var(--sb-surface);
    border: 1px solid var(--sb-surface-2);
    color: var(--sb-text-strong);
    padding: 6px 10px; border-radius: var(--radius-sm);
    font-size: 13px; font-family: inherit;
}
.sidebar .who-block input::placeholder { color: var(--sb-text-dim); }
.sidebar .who-block input:focus {
    outline: none; border-color: var(--sb-active);
}
.sidebar .who-block .hint {
    font-size: 10px; color: var(--sb-text-dim);
    margin-top: 4px;
}

/* ==================  Main  ================== */
.main {
    padding: 28px 36px;
    max-width: 1500px;
    width: 100%;
    /* Dan 2026-05-22: include padding in width math; otherwise width:100% + 72px
       horizontal padding pushes .main 72px past the available column width and
       creates a horizontal scrollbar at narrower viewports. */
    box-sizing: border-box;
    min-width: 0;
}
.page-head {
    margin-bottom: 22px;
    display: flex; justify-content: space-between; align-items: flex-end;
    gap: 16px; flex-wrap: wrap;
}
.page-head h1 {
    margin: 0;
    font-size: 22px; font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text);
}
.page-head .sub {
    margin-top: 4px;
    color: var(--text-2);
    font-size: 13px;
}
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ==================  Panels  ================== */
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
}
.panel.flat { box-shadow: none; }
.panel-head {
    display: flex; justify-content: space-between; align-items: baseline;
    gap: 12px; flex-wrap: wrap;
    margin-bottom: 14px;
}
.panel-head h2 {
    margin: 0;
    font-size: 14px; font-weight: 600;
    color: var(--text);
    letter-spacing: -0.005em;
}
.panel-head .sub {
    color: var(--text-2);
    font-size: 12px;
}

/* ==================  Tables  ================== */
table.tbl {
    width: 100%; border-collapse: collapse;
    font-size: 13px;
}
table.tbl th, table.tbl td {
    padding: 10px 14px;
    text-align: left;
    vertical-align: middle;
    border-bottom: 1px solid var(--border);
}
table.tbl thead th {
    background: var(--surface-2);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-2);
    font-weight: 600;
    position: sticky; top: 0; z-index: 1;
}
table.tbl tbody tr { transition: background 100ms; }
table.tbl tbody tr:hover { background: var(--surface-2); }
table.tbl tbody tr.selected {
    background: var(--primary-soft);
}
table.tbl td .secondary {
    display: block;
    font-size: 11px; color: var(--text-2);
    margin-top: 2px;
}
table.tbl .num { font-variant-numeric: tabular-nums; text-align: right; }
.scroll {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: auto;
    max-height: 70vh;
}

/* ==================  Buttons  ================== */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    font-size: 13px; font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 100ms;
    line-height: 1.4;
    white-space: nowrap;
}
.btn:hover {
    background: var(--surface-2);
    border-color: var(--text-3);
    text-decoration: none;
    color: var(--text);
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--primary-text); }

.btn.success { background: var(--success); border-color: var(--success); color: white; }
.btn.success:hover { background: var(--success-strong); border-color: var(--success-strong); color: white; }

.btn.danger { color: var(--danger-strong); border-color: var(--border-strong); background: var(--surface); }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger); color: var(--danger-strong); }

.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); border-color: transparent; }

.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn.lg { padding: 10px 18px; font-size: 14px; }
.btn.icon { padding: 7px; }

/* ==================  Forms  ================== */
input, select, textarea {
    background: var(--surface);
    border: 1px solid var(--border-strong);
    color: var(--text);
    padding: 7px 11px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    line-height: 1.4;
    transition: border-color 100ms, box-shadow 100ms;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}
textarea { resize: vertical; min-height: 60px; }
input::placeholder, textarea::placeholder { color: var(--text-3); }

label.field { display: block; margin-bottom: 14px; }
label.field > span {
    display: block;
    font-size: 11px;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 4px;
    font-weight: 600;
}
label.field input,
label.field select,
label.field textarea { width: 100%; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px 14px;
}

/* ==================  Pills  ================== */
.pill {
    display: inline-block;
    padding: 2px 9px;
    border-radius: var(--radius-pill);
    font-size: 11px; font-weight: 500;
    background: var(--surface-2); color: var(--text-2);
    border: 1px solid var(--border);
    line-height: 1.4;
}
.pill.primary { background: var(--primary-soft); color: var(--primary); border-color: var(--primary-soft); }
.pill.success { background: var(--success-soft); color: var(--success-strong); border-color: var(--success-soft); }
.pill.warning { background: var(--warning-soft); color: var(--warning-strong); border-color: var(--warning-soft); }
.pill.danger  { background: var(--danger-soft); color: var(--danger-strong); border-color: var(--danger-soft); }
.pill.info    { background: var(--info-soft); color: var(--info-strong); border-color: var(--info-soft); }
.pill.solid-primary { background: var(--primary); color: white; border-color: var(--primary); }
.pill.solid-success { background: var(--success); color: white; border-color: var(--success); }
.pill.solid-warning { background: var(--warning); color: white; border-color: var(--warning); }
.pill.solid-danger  { background: var(--danger); color: white; border-color: var(--danger); }
/* Semantic aliases used by templates: ok = good (paid/active),
   bad = bad (unpaid/inactive), warn = pending, muted = neutral.
   Rob 2026-05-20: Attendance fees needed green/red color coding;
   templates were referencing .ok/.bad but they weren't defined in flow.css. */
.pill.ok    { background: var(--success-soft); color: var(--success-strong); border-color: var(--success-soft); }
.pill.bad   { background: var(--danger-soft);  color: var(--danger-strong);  border-color: var(--danger-soft); }
.pill.warn  { background: var(--warning-soft); color: var(--warning-strong); border-color: var(--warning-soft); }

/* ==================  Side-drawer pattern (overlay)  ==================
   Rob 2026-05-21: reverted from full-screen — staff wants a SIDE drawer
   that OVERLAPS the page content (table stays visible behind), not a
   modal that covers everything. Same shared classes so Waitlist,
   Cancellations, Call Queue, Lead Tracker all stay consistent.

   Usage:
     - Parent toggles `.open` to show the drawer + scrim
     - Drawer element: .fs-drawer  (slides in from the right)
     - Scrim element:  .fs-drawer-scrim  (click-outside-to-close)
     - Sticky header:  .fs-drawer-head with .fs-drawer-close button   */
.fs-drawer {
    position: fixed;
    top: 14px;
    right: 14px;
    bottom: 14px;
    width: min(440px, calc(100vw - 28px));
    z-index: 50;
    transform: translateX(calc(100% + 30px));
    transition: transform 220ms cubic-bezier(.2,.85,.3,1.05);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    /* Rob 2026-05-21: stop scroll-chaining so the wheel never bleeds
       into the page behind the drawer when you hit the drawer's edge. */
    overscroll-behavior: contain;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 18px
             max(14px, env(safe-area-inset-bottom, 0px))
             18px;
    box-shadow: -18px 0 40px -8px rgba(15,23,42,0.22),
                 -2px 0 0 rgba(15,23,42,0.05);
}
/* While ANY drawer is open, freeze background page scroll so the wheel
   only ever scrolls the drawer. Uses :has() — well-supported in modern
   browsers. Covers all parent toggle classes the templates use. */
html:has(.open > .fs-drawer),
html:has(.open .fs-drawer),
body:has(.open > .fs-drawer),
body:has(.open .fs-drawer) {
    overflow: hidden;
}
.fs-drawer-host.open .fs-drawer,
.open > .fs-drawer,
.open .fs-drawer {
    transform: translateX(0);
}
@media (max-width: 600px) {
    /* Phones: drawer takes full width with small inset */
    .fs-drawer {
        top: 8px; right: 8px; bottom: 8px;
        width: calc(100vw - 16px);
    }
}
.fs-drawer-scrim {
    display: none;
    position: fixed; inset: 0;
    background: rgba(15,23,42,0.22);
    z-index: 49;
    animation: fs-scrim-in 180ms ease-out;
}
.fs-drawer-host.open .fs-drawer-scrim,
.open > .fs-drawer-scrim,
.open .fs-drawer-scrim { display: block; }
@keyframes fs-scrim-in { from { opacity: 0; } to { opacity: 1; } }
.fs-drawer-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 8px; padding-bottom: 10px; border-bottom: 1px solid var(--border);
    margin-bottom: 14px;
    position: sticky; top: 0; background: var(--surface); z-index: 2;
}
.fs-drawer-head .title {
    font-size: 12px; font-weight: 700; color: var(--text-2);
    text-transform: uppercase; letter-spacing: .05em;
}
.fs-drawer-close {
    background: transparent; border: 1px solid transparent;
    cursor: pointer; color: var(--text-3);
    padding: 4px 8px;
    font-size: 14px; font-weight: 600; line-height: 1;
    border-radius: var(--radius-sm);
    display: inline-flex; align-items: center; gap: 6px;
}
.fs-drawer-close:hover { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.fs-drawer-close::before { content: "✕"; font-size: 13px; }
.fs-drawer-close::after { content: "Close"; font-size: 11px; opacity: 0.75; }

/* ==================  Stats  ================== */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}
.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    box-shadow: var(--shadow-sm);
}
.stat .label {
    font-size: 11px;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}
.stat .value {
    font-size: 24px;
    font-weight: 600;
    color: var(--text);
    margin-top: 4px;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}
.stat .hint {
    font-size: 11px; color: var(--text-2);
    margin-top: 4px;
}
.stat.tone-primary .value { color: var(--primary); }
.stat.tone-success .value { color: var(--success-strong); }
.stat.tone-warning .value { color: var(--warning-strong); }
.stat.tone-danger  .value { color: var(--danger-strong); }

/* ==================  Misc  ================== */
.muted { color: var(--text-2); }
.dim { color: var(--text-3); }
.empty {
    text-align: center;
    padding: 36px 16px;
    color: var(--text-3);
    font-size: 13px; font-style: italic;
}
.kv {
    display: grid;
    grid-template-columns: 130px 1fr;
    gap: 6px 14px;
    font-size: 13px;
}
.kv .k { color: var(--text-2); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; padding-top: 2px; }
.kv .v { color: var(--text); }

.tabs { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--border); }
.tabs button {
    background: transparent; border: 0;
    color: var(--text-2);
    padding: 9px 14px;
    border-radius: 0;
    cursor: pointer;
    font-size: 13px; font-weight: 500;
    font-family: inherit;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color 100ms, border-color 100ms;
}
.tabs button:hover { color: var(--text); }
.tabs button.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.toast {
    position: fixed; bottom: 24px; right: 24px;
    background: var(--text); color: white;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 500;
    box-shadow: var(--shadow-md);
    z-index: 9999;
}

.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, 0.5);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
}
.modal {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 22px;
    max-width: 460px; width: 92%;
    box-shadow: var(--shadow-md);
}
.modal h3 { margin: 0 0 14px; font-size: 16px; font-weight: 600; }
.modal .row {
    display: flex; gap: 8px; justify-content: flex-end;
    margin-top: 16px;
}

/* Inline link/button hybrid */
.lnk {
    color: var(--primary);
    background: transparent;
    border: 0; padding: 0;
    cursor: pointer; font-size: inherit;
    font-family: inherit;
    text-decoration: none;
}
.lnk:hover { text-decoration: underline; }

/* Code-style monospace */
.mono { font-family: var(--font-mono); font-size: 12px; }

/* ============================================================
   Mobile / iPhone — hamburger drawer + safe-area + reflows
   ============================================================ */

/* Hamburger toggle button — hidden on desktop */
#mobile-nav-toggle {
    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + 12px);
    left: calc(env(safe-area-inset-left, 0px) + 12px);
    z-index: 95;
    width: 42px; height: 42px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    display: none;
    align-items: center; justify-content: center;
    box-shadow: var(--shadow);
}
#mobile-nav-toggle:active { transform: scale(0.95); }
#mobile-nav-toggle .icon svg { width: 20px; height: 20px; stroke-width: 2; }

#sidebar-scrim {
    display: none;
    position: fixed; inset: 0;
    background: rgba(15,23,42,0.45);
    z-index: 90;
    backdrop-filter: blur(2px);
}
body.nav-open #sidebar-scrim { display: block; animation: scrim-in 180ms ease-out; }
@keyframes scrim-in { from { opacity: 0; } to { opacity: 1; } }

/* Mid-range laptops (1024-1279px) — keep the desktop sidebar but tighten
   .main padding and let charts/tables breathe. The 28/36 padding eats
   ~64px of horizontal real estate which is a lot when content area is
   ~784-1024px after the 240px sidebar. */
@media (max-width: 1279px) and (min-width: 901px) {
    .main { padding: 22px 20px; }
    .panel { padding: 14px 16px; }
    .page-head h1 { font-size: 20px; }
    .page-head .sub { font-size: 12px; }
}

@media (max-width: 900px) {
    .app { grid-template-columns: 1fr; overflow-x: hidden; }
    .main { overflow-x: hidden !important; min-width: 0 !important; max-width: 100% !important; }

    /* Stop any inner element from forcing horizontal overflow on the page */
    .main *:not(.scroll):not(.scroll-body):not(table) {
        max-width: 100% !important;
        min-width: 0 !important;
    }

    /* Tables/grids that want to scroll do so inside their own container */
    .scroll, .scroll-body {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    table.tbl, table.lst { min-width: 100%; }

    /* Page heads must wrap on mobile, not splay */
    .page-head { white-space: normal; }
    .page-head .sub { white-space: normal; word-break: break-word; }
    .page-head .actions { flex-wrap: wrap; }

    /* Master schedule grid scrolls horizontally inside its panel */
    .grid-container, #grid-container > .panel { overflow-x: auto; -webkit-overflow-scrolling: touch; }

    /* Modal overlays: center is too tall — flow from top with vertical scroll */
    .modal-overlay, .wizard-overlay {
        align-items: flex-start !important;
        padding: max(env(safe-area-inset-top, 0px), 14px) 12px 14px !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    #mobile-nav-toggle { display: flex; }

    .sidebar {
        position: fixed; top: 0; left: 0;
        width: min(82vw, 300px);
        height: 100vh;
        z-index: 100;
        transform: translateX(-105%);
        transition: transform 220ms cubic-bezier(.2,.85,.3,1);
        box-shadow: 0 0 0 1px transparent;
        padding-top: max(env(safe-area-inset-top, 0px), 14px);
    }
    body.nav-open .sidebar {
        transform: translateX(0);
        box-shadow: 12px 0 32px rgba(15,23,42,0.18);
    }

    .main {
        padding: 70px 16px 24px !important;
        padding-left: max(16px, env(safe-area-inset-left, 0px)) !important;
        padding-right: max(16px, env(safe-area-inset-right, 0px)) !important;
        padding-bottom: max(24px, calc(24px + env(safe-area-inset-bottom, 0px))) !important;
    }

    /* Single-column grids on phone */
    .grid, .module-grid, .kpi-grid, .stat-grid,
    .form-grid, .archive-stats {
        grid-template-columns: 1fr !important;
    }
    .dash-layout { grid-template-columns: 1fr !important; }
    .activity { position: static !important; max-height: 360px !important; }

    /* Hero stacks vertically */
    .hero { flex-direction: column !important; align-items: flex-start !important; gap: 10px !important; padding: 14px !important; }
    .hero .attention-row { width: 100%; justify-content: flex-start !important; }

    /* Page heads tighter */
    .page-head { flex-direction: column; align-items: stretch; gap: 8px; }
    .page-head h1 { font-size: 18px; }

    /* Tables get horizontal scroll wrapping */
    .scroll, .scroll-body { -webkit-overflow-scrolling: touch; }
    table.tbl, table.lst { font-size: 12.5px; }
    table.tbl td, table.tbl th, table.lst td, table.lst th { padding: 6px 8px; }

    /* Modals full-width on small screens */
    .modal, .wizard, #cmdk {
        width: calc(100vw - 24px) !important;
        max-width: calc(100vw - 24px) !important;
        left: 12px !important;
        right: 12px !important;
        transform: none !important;
    }
    #cmdk {
        top: max(12px, env(safe-area-inset-top, 0px)) !important;
        bottom: auto !important;
    }

    /* AI FAB — slightly smaller, lifted above iOS home indicator */
    #ai-fab {
        right: max(12px, env(safe-area-inset-right, 0px)) !important;
        bottom: calc(max(12px, env(safe-area-inset-bottom, 0px)) + 4px) !important;
        width: 48px !important; height: 48px !important;
    }
    #ai-popup {
        right: 12px !important; left: 12px !important;
        bottom: 70px !important;
        width: auto !important;
        max-width: none !important;
        height: 70vh !important; max-height: none !important;
    }

    /* iOS zooms inputs <16px on focus — bump everywhere */
    input, select, textarea { font-size: 16px !important; }

    /* Tighter cards */
    .panel { padding: 14px 14px; }

    /* Sidebar scrim catches taps */
    #sidebar-scrim { z-index: 99; }
}

@media (max-width: 600px) {
    .main { padding: 64px 12px 20px !important; }
    .module-card, .kpi-card { padding: 12px 14px; }
    .panel-head h2 { font-size: 14px; }
    h1 { font-size: 17px !important; }

    /* Hide noisy desktop-only sections */
    .activity { display: none; }
}

/* PWA standalone mode — extra top padding so iOS status bar doesn't overlap */
@media (display-mode: standalone) {
    body { padding-top: env(safe-area-inset-top, 0px); }
    #mobile-nav-toggle { top: calc(env(safe-area-inset-top, 0px) + 8px); }
}

/* ==================  Custom scrollbars  ================== */

/* Page (Firefox) */
html { scrollbar-width: thin; scrollbar-color: #c5d2dc transparent; }

/* Page (WebKit/Blink) */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: #c5d2dc;
    border-radius: 99px;
    border: 2px solid var(--bg);
    transition: background 120ms;
}
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
::-webkit-scrollbar-corner { background: transparent; }

/* Sidebar — slimmer, on its tinted background */
.sidebar { scrollbar-width: thin; scrollbar-color: #b3c4cf transparent; }
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb {
    background: rgba(112, 128, 146, 0.35);
    border: 2px solid var(--sb-bg);
    border-radius: 99px;
}
.sidebar::-webkit-scrollbar-thumb:hover { background: rgba(112, 128, 146, 0.6); }

/* Inner scroll containers (modal lists, table scrolls, panels) */
.scroll, .scroll-body, .activity-list, .chat-msgs {
    scrollbar-width: thin;
    scrollbar-color: #c5d2dc transparent;
}
.scroll::-webkit-scrollbar,
.scroll-body::-webkit-scrollbar,
.activity-list::-webkit-scrollbar,
.chat-msgs::-webkit-scrollbar { width: 8px; height: 8px; }
.scroll::-webkit-scrollbar-thumb,
.scroll-body::-webkit-scrollbar-thumb,
.activity-list::-webkit-scrollbar-thumb,
.chat-msgs::-webkit-scrollbar-thumb {
    background: #d1dbe4;
    border-radius: 99px;
    border: 2px solid var(--surface);
}
.scroll::-webkit-scrollbar-thumb:hover,
.scroll-body::-webkit-scrollbar-thumb:hover,
.activity-list::-webkit-scrollbar-thumb:hover,
.chat-msgs::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* Cmdk results dropdown */
#cmdk-results { scrollbar-width: thin; scrollbar-color: #c5d2dc transparent; }
#cmdk-results::-webkit-scrollbar { width: 6px; }
#cmdk-results::-webkit-scrollbar-thumb {
    background: #c5d2dc; border-radius: 99px;
}

/* Rob 2026-05-29 (#364): shared loading bar — same animated stripe the
   Worklist uses, applied across Waitlist / Attendance / Lead Tracker. */
.flow-progress {
    position: relative; height: 3px; overflow: hidden;
    background: var(--surface-2, #f1f5f9); border-radius: 2px;
    margin-bottom: 6px;
}
.flow-progress::before {
    content: ''; position: absolute; left: -40%; top: 0; bottom: 0; width: 40%;
    background: linear-gradient(90deg, transparent, var(--primary, #2563eb), transparent);
    animation: flow-progress-bar 1.1s ease-in-out infinite;
}
@keyframes flow-progress-bar { from { left: -40%; } to { left: 100%; } }
