/* ==========================================================================
   DEX HEALTH — SHARED COMPONENT LIBRARY (Clinical Instrument)
   Every architecture page composes ONLY from these primitives.
   Requires tokens.css loaded first.
   ========================================================================== */

/* ==========================================================================
   1. APP SHELL — sidebar + topbar + scrollable content
   ========================================================================== */
.shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--rule);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-5) var(--sp-5);
    border-bottom: 1px solid var(--rule);
}

.brand-mark {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 15px;
    box-shadow: 0 6px 14px -6px var(--accent-glow);
}

.brand-name {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 0.95rem;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.brand-sub {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--ink-muted);
}

.nav {
    padding: var(--sp-4) var(--sp-3);
    flex-grow: 1;
    overflow-y: auto;
}

.nav-group-label {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--ink-faint);
    padding: var(--sp-4) var(--sp-3) var(--sp-2);
}

.nav a {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: 9px var(--sp-3);
    border-radius: var(--radius-sm);
    color: var(--ink-secondary);
    font-size: var(--text-sm);
    font-weight: 500;
    text-decoration: none;
    border-left: 2px solid transparent;
    transition: background var(--t-fast), color var(--t-fast);
}

.nav a i { width: 18px; text-align: center; font-size: 13px; color: var(--ink-faint); transition: color var(--t-fast); }

.nav a:hover { background: var(--surface-sunken); color: var(--ink); text-decoration: none; }
.nav a:hover i { color: var(--accent); }

.nav a.active {
    background: var(--accent-tint);
    color: var(--accent-strong);
    font-weight: 600;
    border-left-color: var(--accent);
}
.nav a.active i { color: var(--accent); }

.sidebar-foot {
    border-top: 1px solid var(--rule);
    padding: var(--sp-4) var(--sp-5);
    display: flex;
    align-items: center;
    gap: var(--sp-3);
}

.avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--rule-strong);
    flex-shrink: 0;
}

.avatar-fallback {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: var(--accent-tint);
    color: var(--accent-strong);
    display: grid; place-items: center;
    font-family: var(--font-mono);
    font-size: 0.7rem; font-weight: 700;
    flex-shrink: 0;
}

.foot-name { font-size: var(--text-sm); font-weight: 600; line-height: 1.2; }
.foot-role { font-family: var(--font-mono); font-size: 0.62rem; color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.08em; }

.main {
    flex-grow: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.content {
    width: 100%;
    max-width: var(--content-max);
    margin: 0 auto;
    padding: var(--sp-8);
    flex-grow: 1;
}

/* ==========================================================================
   2. PAGE HEADER — title + live status + the ECG hairline signature
   ========================================================================== */
.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--sp-4);
    flex-wrap: wrap;
    margin-bottom: var(--sp-3);
}

.page-title { font-size: var(--text-xl); font-weight: 800; }

.page-kicker {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--accent-strong);
    margin-bottom: var(--sp-1);
    display: block;
}

.page-sub { color: var(--ink-muted); font-size: var(--text-sm); margin-top: var(--sp-1); }

/* ECG divider: the signature motif under every page title */
.ecg-rule {
    height: 22px;
    margin: var(--sp-2) 0 var(--sp-6);
    color: var(--rule-strong);
    overflow: hidden;
}
.ecg-rule svg { width: 100%; height: 100%; display: block; }
.ecg-rule .beat { color: var(--accent); }

/* Live indicator */
.live-dot {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--stable-ink);
    background: var(--stable-tint);
    border: 1px solid rgba(23, 110, 69, 0.25);
    padding: 5px 12px;
    border-radius: 999px;
}
.live-dot::before {
    content: '';
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--stable);
    animation: live-pulse 1.8s ease-in-out infinite;
}
@keyframes live-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(23, 110, 69, 0.4); }
    50%      { box-shadow: 0 0 0 5px rgba(23, 110, 69, 0); }
}

/* ==========================================================================
   3. CARDS & STAT TILES
   ========================================================================== */
.card {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-soft);
    padding: var(--sp-6);
}

.card + .card { margin-top: var(--sp-6); }

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-4);
    margin-bottom: var(--sp-5);
}

.card-title {
    font-family: var(--font-display);
    font-size: var(--text-md);
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}
.card-title i { color: var(--accent); font-size: 0.9em; }

.card-sub { font-size: var(--text-xs); color: var(--ink-muted); margin-top: 2px; }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--sp-4);
    margin-bottom: var(--sp-6);
}

.stat-tile {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-top: 3px solid var(--accent);
    border-radius: var(--radius-md);
    padding: var(--sp-4) var(--sp-5);
    box-shadow: var(--shadow-soft);
    transition: transform var(--t-normal), box-shadow var(--t-normal);
}
.stat-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }

.stat-tile.critical { border-top-color: var(--critical); }
.stat-tile.warning  { border-top-color: var(--warning); }
.stat-tile.stable   { border-top-color: var(--stable); }
.stat-tile.info     { border-top-color: var(--info); }

.stat-label {
    font-family: var(--font-mono);
    font-size: 0.64rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--ink-muted);
}

.stat-value {
    font-size: var(--text-2xl);
    font-weight: 600;
    line-height: 1.1;
    margin: var(--sp-1) 0;
}
.stat-value small { font-size: 0.45em; color: var(--ink-muted); font-weight: 500; }

.stat-meta { font-size: var(--text-xs); color: var(--ink-muted); }
.stat-meta.up   { color: var(--stable-ink); }
.stat-meta.down { color: var(--critical-ink); }

/* ==========================================================================
   4. STATUS LEDGER — badges, pills, severity dots
   ========================================================================== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-mono);
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 3px 10px;
    border-radius: 999px;
    border: 1px solid transparent;
    white-space: nowrap;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.badge.critical { background: var(--critical-tint); color: var(--critical-ink); border-color: rgba(179, 39, 30, 0.25); }
.badge.warning  { background: var(--warning-tint);  color: var(--warning-ink);  border-color: rgba(147, 101, 10, 0.3); }
.badge.stable   { background: var(--stable-tint);   color: var(--stable-ink);   border-color: rgba(23, 110, 69, 0.25); }
.badge.info     { background: var(--info-tint);     color: var(--info);         border-color: rgba(32, 91, 143, 0.25); }
.badge.neutral  { background: var(--surface-sunken); color: var(--ink-secondary); border-color: var(--rule-strong); }

/* Vital pill: mono value + unit, tinted by state */
.vital-pill {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    font-weight: 600;
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--rule);
    background: var(--surface);
}
.vital-pill .unit { font-size: 0.65rem; color: var(--ink-muted); font-weight: 500; }
.vital-pill.critical { background: var(--critical-tint); border-color: rgba(179,39,30,0.3); color: var(--critical-ink); }
.vital-pill.warning  { background: var(--warning-tint);  border-color: rgba(147,101,10,0.3); color: var(--warning-ink); }
.vital-pill.stable   { background: var(--stable-tint);   border-color: rgba(23,110,69,0.3);  color: var(--stable-ink); }

/* ==========================================================================
   5. BUTTONS
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    font-weight: 600;
    padding: 9px 18px;
    min-height: 38px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: background var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast), border-color var(--t-fast);
    text-decoration: none;
    white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
    background: var(--accent);
    color: #ffffff;
    box-shadow: 0 8px 18px -8px var(--accent-glow);
}
.btn-primary:hover { background: var(--accent-strong); }

.btn-secondary {
    background: var(--surface);
    color: var(--ink);
    border-color: var(--rule-strong);
}
.btn-secondary:hover { border-color: var(--ink-faint); background: var(--surface-sunken); }

.btn-danger {
    background: var(--critical);
    color: #fff;
}
.btn-danger:hover { background: var(--critical-ink); }

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

.btn-sm { padding: 6px 12px; min-height: 32px; font-size: var(--text-xs); }

.icon-btn {
    width: 34px; height: 34px;
    display: inline-grid; place-items: center;
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--radius-sm);
    color: var(--ink-secondary);
    cursor: pointer;
    transition: border-color var(--t-fast), color var(--t-fast), background var(--t-fast);
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent-strong); background: var(--accent-tint); }

/* ==========================================================================
   6. TABLES — hairline ledger style
   ========================================================================== */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
}

.table th {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--ink-muted);
    text-align: left;
    padding: var(--sp-2) var(--sp-4);
    border-bottom: 1px solid var(--rule-strong);
    white-space: nowrap;
}

.table td {
    padding: var(--sp-4);
    border-bottom: 1px solid var(--rule);
    vertical-align: middle;
}

.table tbody tr { transition: background var(--t-fast); }
.table tbody tr:hover { background: var(--accent-tint); }
.table tbody tr:last-child td { border-bottom: none; }

.table .cell-main { font-weight: 600; color: var(--ink); }
.table .cell-sub  { font-family: var(--font-mono); font-size: 0.68rem; color: var(--ink-muted); margin-top: 1px; }
.table td.num { text-align: right; }

/* Person cell: avatar + name + id */
.person { display: flex; align-items: center; gap: var(--sp-3); min-width: 180px; }

/* ==========================================================================
   7. FORMS
   ========================================================================== */
.form-group { margin-bottom: var(--sp-4); }

.form-label {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.64rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--ink-secondary);
    margin-bottom: var(--sp-2);
}

.form-control, .form-select {
    width: 100%;
    padding: 10px 14px;
    min-height: 40px;
    font-family: var(--font-body);
    font-size: var(--text-sm);
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius-sm);
    transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.form-control::placeholder { color: var(--ink-faint); }
.form-control:focus, .form-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }

.search-field { position: relative; }
.search-field i {
    position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
    color: var(--ink-faint); font-size: 12px;
}
.search-field .form-control { padding-left: 36px; }

/* Toggle switch */
.switch {
    width: 42px; height: 24px;
    border-radius: 999px;
    background: var(--rule-strong);
    border: none;
    position: relative;
    cursor: pointer;
    transition: background var(--t-normal);
    flex-shrink: 0;
}
.switch::after {
    content: '';
    position: absolute;
    top: 3px; left: 3px;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: var(--surface);
    box-shadow: 0 1px 3px rgba(0,0,0,0.25);
    transition: transform var(--t-normal);
}
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(18px); }

/* ==========================================================================
   8. MODALS — one pattern, everywhere
   ========================================================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(27, 36, 32, 0.45);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--sp-6);
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--t-normal);
}
.modal-overlay.active { opacity: 1; pointer-events: auto; }

.modal {
    width: 100%;
    max-width: 520px;
    max-height: 88vh;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lift);
    transform: translateY(14px) scale(0.985);
    transition: transform var(--t-normal);
}
.modal-overlay.active .modal { transform: none; }

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-5) var(--sp-6);
    border-bottom: 1px solid var(--rule);
}
.modal-title { font-family: var(--font-display); font-size: var(--text-md); font-weight: 700; }
.modal-body { padding: var(--sp-6); }
.modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: var(--sp-3);
    padding: var(--sp-4) var(--sp-6);
    border-top: 1px solid var(--rule);
    background: var(--surface-sunken);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ==========================================================================
   9. TOASTS
   ========================================================================== */
#toast-region {
    position: fixed;
    bottom: var(--sp-6);
    right: var(--sp-6);
    z-index: 1200;
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    min-width: 280px;
    max-width: 360px;
    background: var(--ink);
    color: var(--ink-on-dark);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius-sm);
    padding: var(--sp-3) var(--sp-4);
    box-shadow: var(--shadow-lift);
    pointer-events: auto;
    animation: toast-in var(--t-normal) both;
}
.toast.critical { border-left-color: var(--critical); }
.toast.warning  { border-left-color: #d9a03f; }
.toast.stable   { border-left-color: #3fd996; }
.toast-title { font-size: var(--text-sm); font-weight: 700; }
.toast-msg { font-size: var(--text-xs); opacity: 0.8; margin-top: 1px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ==========================================================================
   10. TABS
   ========================================================================== */
.tabs {
    display: flex;
    gap: var(--sp-1);
    border-bottom: 1px solid var(--rule);
    margin-bottom: var(--sp-6);
    overflow-x: auto;
}

.tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 10px var(--sp-4);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--ink-muted);
    cursor: pointer;
    white-space: nowrap;
    transition: color var(--t-fast), border-color var(--t-fast);
    margin-bottom: -1px;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--accent-strong); border-bottom-color: var(--accent); }

.tab-panel { display: none; }
.tab-panel.active { display: block; animation: panel-in var(--t-normal) both; }
@keyframes panel-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ==========================================================================
   11. SPARKLINES & CHART WELLS
   ========================================================================== */
.chart-well {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--radius-md);
    padding: var(--sp-4);
}
.chart-well svg { width: 100%; display: block; }
.gridline { stroke: var(--rule); stroke-width: 1; }
.spark-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.spark-line.critical { stroke: var(--critical); }
.spark-line.warning  { stroke: #b07c14; }
.spark-fill { fill: var(--accent-glow); stroke: none; opacity: 0.6; }

.ecg-well {
    background: var(--surface-ink);
    border-radius: var(--radius-md);
    padding: var(--sp-4);
    position: relative;
    overflow: hidden;
}
.ecg-well svg { width: 100%; display: block; stroke: #3fd996; fill: none; stroke-width: 1.8; stroke-linecap: round; }
.ecg-well .ecg-grid { stroke: rgba(63, 217, 150, 0.08); stroke-width: 0.75; }
.ecg-sweep {
    position: absolute; top: 0; bottom: 0; width: 3px;
    background: rgba(63, 217, 150, 0.5);
    box-shadow: 0 0 12px #3fd996;
    animation: ecg-sweep 3s linear infinite;
}
@keyframes ecg-sweep { 0% { left: 0; } 100% { left: calc(100% - 3px); } }

/* ==========================================================================
   12. PAGE-LOAD STAGGER — one orchestrated reveal per page
   ========================================================================== */
.reveal { opacity: 0; animation: reveal-up 0.55s var(--ease-out) forwards; }
.reveal:nth-child(1) { animation-delay: 0.02s; }
.reveal:nth-child(2) { animation-delay: 0.08s; }
.reveal:nth-child(3) { animation-delay: 0.14s; }
.reveal:nth-child(4) { animation-delay: 0.20s; }
.reveal:nth-child(5) { animation-delay: 0.26s; }
.reveal:nth-child(6) { animation-delay: 0.32s; }
@keyframes reveal-up { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ==========================================================================
   13. PHONE FRAME (patient surface)
   ========================================================================== */
.phone-stage {
    height: 100vh;
    overflow: hidden;              /* the scaled frame always fits — never scroll the stage */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--sp-5);
    background:
        radial-gradient(ellipse 60% 45% at 50% 0%, rgba(47, 189, 139, 0.09), transparent),
        var(--surface-ink);
}

.phone {
    width: 378px;
    height: 818px;                 /* true device geometry — NEVER squashed */
    flex-shrink: 0;
    background: #05080a;
    border-radius: 48px;
    border: 3px solid #2c3a36;
    box-shadow:
        inset 0 0 0 8px #05080a,
        inset 0 0 2px 10px rgba(255,255,255,0.06),
        0 40px 90px -30px rgba(0, 0, 0, 0.85);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform-origin: center center;
}

/* Short viewports: scale the WHOLE frame uniformly (text, spacing, layout stay
   proportional — the in-app experience is identical, just smaller). Steps are
   sized so the frame + breathing room always fits the band's minimum height. */
@media (max-width: 430px)  { .phone { transform: scale(0.85); } }
@media (max-height: 858px) { .phone { transform: scale(0.92); } }
@media (max-height: 800px) { .phone { transform: scale(0.85); } }
@media (max-height: 744px) { .phone { transform: scale(0.79); } }
@media (max-height: 688px) { .phone { transform: scale(0.72); } }
@media (max-height: 632px) { .phone { transform: scale(0.65); } }
@media (max-height: 576px) { .phone { transform: scale(0.58); } }
@media (max-height: 520px) { .phone { transform: scale(0.52); } }

.phone-screen {
    position: absolute;
    inset: 8px;
    border-radius: 40px;
    background: #0b100e;
    color: var(--ink-on-dark);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.phone-island {
    position: absolute;
    top: 14px; left: 50%; transform: translateX(-50%);
    width: 96px; height: 26px;
    background: #05080a;
    border-radius: 14px;
    z-index: 60;
}

.phone-statusbar {
    height: 48px;
    flex-shrink: 0;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    padding: 0 26px 4px;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 600;
    z-index: 50;
}

.phone-body { flex-grow: 1; overflow-y: auto; padding: var(--sp-4) var(--sp-4) 96px; }
.phone-body::-webkit-scrollbar { display: none; }

.phone-nav {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 78px;
    padding-bottom: 16px;
    background: rgba(5, 8, 10, 0.92);
    backdrop-filter: blur(16px);
    border-top: 1px solid rgba(255,255,255,0.07);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    z-index: 55;
}

.phone-nav button {
    background: none; border: none;
    color: #5d6a64;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 4px; cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.6rem; font-weight: 600;
    transition: color var(--t-fast);
}
.phone-nav button i { font-size: 17px; }
.phone-nav button:hover { color: #9aa8a1; }
.phone-nav button.active { color: var(--accent); }

.phone-home-bar {
    position: absolute; bottom: 6px; left: 50%; transform: translateX(-50%);
    width: 120px; height: 5px; border-radius: 3px;
    background: rgba(255,255,255,0.3);
    z-index: 60;
}

/* Dark-glass card for phone screens */
.glass-card {
    background: rgba(255, 255, 255, 0.045);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-lg);
    padding: var(--sp-4);
    margin-bottom: var(--sp-3);
}

/* ==========================================================================
   14. EMPTY STATES & UTILITIES
   ========================================================================== */
.empty-state {
    text-align: center;
    padding: var(--sp-14) var(--sp-6);
    color: var(--ink-muted);
}
.empty-state i { font-size: 30px; color: var(--ink-faint); margin-bottom: var(--sp-3); display: block; }

.flex { display: flex; align-items: center; }
.gap-2 { gap: var(--sp-2); } .gap-3 { gap: var(--sp-3); } .gap-4 { gap: var(--sp-4); }
.between { justify-content: space-between; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-6); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-6); }
.mt-2 { margin-top: var(--sp-2); } .mt-4 { margin-top: var(--sp-4); } .mt-6 { margin-top: var(--sp-6); }
.mb-4 { margin-bottom: var(--sp-4); } .mb-6 { margin-bottom: var(--sp-6); }
.muted { color: var(--ink-muted); }
.text-sm { font-size: var(--text-sm); } .text-xs { font-size: var(--text-xs); }

/* ==========================================================================
   15. RESPONSIVE — portals collapse gracefully
   ========================================================================== */
@media (max-width: 1080px) {
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .content { padding: var(--sp-5); }
}

@media (max-width: 860px) {
    .shell { flex-direction: column; }
    .sidebar {
        width: 100%;
        height: auto;
        position: static;
        flex-direction: row;
        align-items: center;
        overflow-x: auto;
        border-right: none;
        border-bottom: 1px solid var(--rule);
    }
    .brand { border-bottom: none; flex-shrink: 0; }
    .nav { display: flex; padding: var(--sp-2); flex-grow: 1; }
    .nav-group-label { display: none; }
    .nav a { white-space: nowrap; border-left: none; border-bottom: 2px solid transparent; border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
    .nav a.active { border-bottom-color: var(--accent); }
    .sidebar-foot { display: none; }
    .form-row-2 { grid-template-columns: 1fr; }
    .page-title { font-size: var(--text-lg); }
}

/* ==========================================================================
   16. AI TRANSPARENCY FLAG — EU AI Act labelling primitive.
   Attach to any AI-generated output. Violet = machine inference, never status.
   ========================================================================== */
.ai-flag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-family: var(--font-mono);
    font-size: 0.58rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: #5d43a8;
    background: rgba(122, 92, 201, 0.1);
    border: 1px solid rgba(122, 92, 201, 0.3);
    padding: 2px 8px;
    border-radius: 999px;
    white-space: nowrap;
}
.ai-flag::before {
    content: '';
    width: 5px; height: 5px;
    border-radius: 50%;
    background: #7a5cc9;
}

/* ==========================================================================
   17. COLORWAY PICKER — white-label theme selection (admin theme, clinic theme)
   ========================================================================== */
.color-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--sp-3);
    margin-top: var(--sp-3);
}
.color-option-card {
    border: 2px solid var(--rule);
    border-radius: var(--radius-md);
    padding: var(--sp-3);
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    cursor: pointer;
    background: var(--surface);
    transition: border-color var(--t-fast), transform var(--t-fast);
    font-family: var(--font-body);
}
.color-option-card:hover { border-color: var(--rule-strong); transform: translateY(-1px); }
.color-option-card.active { border-color: var(--accent); background: var(--accent-tint); }
.color-swatch {
    width: 30px; height: 30px;
    border-radius: 8px;
    flex-shrink: 0;
    border: 1px solid rgba(27, 36, 32, 0.1);
}
.color-option-name { font-size: var(--text-sm); font-weight: 600; color: var(--ink); }

/* ==========================================================================
   18. TABLE PAGINATION — growing datasets page, they do not scroll forever
   ========================================================================== */
.table-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-4);
    padding-top: var(--sp-4);
    margin-top: var(--sp-2);
    border-top: 1px solid var(--rule);
}
.pager-info {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--ink-muted);
}
.pager-controls { display: flex; gap: var(--sp-2); }
.pager-controls .icon-btn:disabled {
    opacity: 0.4;
    cursor: default;
    pointer-events: none;
}
