/* PatriotsConnect Control. Colours are tokens; dark mode swaps the tokens, never the components. */
:root {
  color-scheme: light;
  --page: #f6f6f8;
  --surface: #ffffff;
  --surface-2: #f4f4f7;
  --surface-3: #ececf1;
  --hairline: rgba(15, 17, 26, 0.09);
  --hairline-strong: rgba(15, 17, 26, 0.16);
  --text: #12131a;
  --text-2: #565a68;
  --text-3: #6f7382;
  --accent: #5457e0;
  --accent-hover: #4346c9;
  --accent-soft: rgba(84, 87, 224, 0.1);
  --on-accent: #ffffff;
  --series-1: #5457e0;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --grid: #ecebf1;
  --axis: #c9c9d4;
  --good: #0a7f0a;
  --good-soft: rgba(12, 163, 12, 0.11);
  --warning: #9a6a00;
  --warning-soft: rgba(250, 178, 25, 0.18);
  --serious: #b9501f;
  --serious-soft: rgba(236, 131, 90, 0.16);
  --critical: #c22f2f;
  --critical-soft: rgba(208, 59, 59, 0.1);
  --seq-1: #e6e6fb; --seq-2: #c5c6f6; --seq-3: #9c9eef; --seq-4: #6468e2; --seq-5: #4b4ed6; --seq-6: #3a3cb0;
  --seq-ink-1: #12131a; --seq-ink-2: #12131a; --seq-ink-3: #12131a; --seq-ink-4: #ffffff; --seq-ink-5: #ffffff; --seq-ink-6: #ffffff;
  --shadow-sm: 0 1px 2px rgba(15, 17, 26, 0.05);
  --shadow-lg: 0 18px 50px rgba(15, 17, 26, 0.18);
  --overlay: rgba(15, 17, 26, 0.38);
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0c0d11; --surface: #15161b; --surface-2: #1c1d24; --surface-3: #25262f;
    --hairline: rgba(255, 255, 255, 0.08); --hairline-strong: rgba(255, 255, 255, 0.16);
    --text: #f1f1f4; --text-2: #b6b8c4; --text-3: #8d90a0;
    --accent: #7d80ee; --accent-hover: #9396f3; --accent-soft: rgba(125, 128, 238, 0.16); --on-accent: #0c0d11;
    --series-1: #7d80ee; --series-2: #d95926; --series-3: #199e70;
    --grid: #24252d; --axis: #3a3b46;
    --good: #35c235; --good-soft: rgba(12, 163, 12, 0.18);
    --warning: #fab219; --warning-soft: rgba(250, 178, 25, 0.15);
    --serious: #ec835a; --serious-soft: rgba(236, 131, 90, 0.16);
    --critical: #ef6a6a; --critical-soft: rgba(208, 59, 59, 0.2);
    --seq-1: #24254a; --seq-2: #2f3166; --seq-3: #3f4189; --seq-4: #5457c0; --seq-5: #7d80ee; --seq-6: #a9abf5;
    --seq-ink-1: #f1f1f4; --seq-ink-2: #f1f1f4; --seq-ink-3: #f1f1f4; --seq-ink-4: #ffffff; --seq-ink-5: #0c0d11; --seq-ink-6: #0c0d11;
    --shadow-sm: none; --shadow-lg: 0 18px 50px rgba(0, 0, 0, 0.6); --overlay: rgba(0, 0, 0, 0.6);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0c0d11; --surface: #15161b; --surface-2: #1c1d24; --surface-3: #25262f;
  --hairline: rgba(255, 255, 255, 0.08); --hairline-strong: rgba(255, 255, 255, 0.16);
  --text: #f1f1f4; --text-2: #b6b8c4; --text-3: #8d90a0;
  --accent: #7d80ee; --accent-hover: #9396f3; --accent-soft: rgba(125, 128, 238, 0.16); --on-accent: #0c0d11;
  --series-1: #7d80ee; --series-2: #d95926; --series-3: #199e70;
  --grid: #24252d; --axis: #3a3b46;
  --good: #35c235; --good-soft: rgba(12, 163, 12, 0.18);
  --warning: #fab219; --warning-soft: rgba(250, 178, 25, 0.15);
  --serious: #ec835a; --serious-soft: rgba(236, 131, 90, 0.16);
  --critical: #ef6a6a; --critical-soft: rgba(208, 59, 59, 0.2);
  --seq-1: #24254a; --seq-2: #2f3166; --seq-3: #3f4189; --seq-4: #5457c0; --seq-5: #7d80ee; --seq-6: #a9abf5;
    --seq-ink-1: #f1f1f4; --seq-ink-2: #f1f1f4; --seq-ink-3: #f1f1f4; --seq-ink-4: #ffffff; --seq-ink-5: #0c0d11; --seq-ink-6: #0c0d11;
  --shadow-sm: none; --shadow-lg: 0 18px 50px rgba(0, 0, 0, 0.6); --overlay: rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }
html, body, #root { height: 100%; }
body {
  margin: 0; background: var(--page); color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
svg.icon { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--text-3); }
.secondary { color: var(--text-2); }
.nums { font-variant-numeric: tabular-nums; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.row { display: flex; align-items: center; gap: 8px; }
.spacer { flex: 1; }

/* Shown only until the app starts; the hint appears if it never does */
.boot { min-height: 100%; display: grid; place-content: center; gap: 8px; padding: 16px; text-align: center; color: var(--text-2); }
.boot-hint { opacity: 0; max-width: 460px; font-size: 13px; animation: boot-hint 0s 4s forwards; }
.boot-hint p { margin-bottom: 6px; }
.boot a { color: var(--accent); text-decoration: underline; font-weight: 600; }
.boot code { background: var(--surface-3); padding: 1px 5px; border-radius: 4px; }
@keyframes boot-hint { to { opacity: 1; } }

/* Sign-in */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--hairline); border-radius: 16px; padding: 32px 28px; box-shadow: var(--shadow-sm); }
.login-card img { width: 44px; height: 44px; border-radius: 11px; display: block; margin-bottom: 18px; }
.login-card h1 { font-size: 20px; font-weight: 650; letter-spacing: -0.2px; }
.login-card p { color: var(--text-2); margin: 4px 0 22px; }
.login-note { margin-top: 18px; font-size: 12.5px; color: var(--text-3); display: flex; gap: 6px; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12.5px; font-weight: 550; color: var(--text-2); margin-bottom: 5px; }
.field small { display: block; margin-top: 4px; color: var(--text-3); font-size: 12px; }
.input, .select, .textarea {
  width: 100%; background: var(--surface); border: 1px solid var(--hairline-strong); border-radius: 8px; padding: 8px 11px; min-height: 36px;
}
.textarea { resize: vertical; min-height: 84px; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.form-error { background: var(--critical-soft); color: var(--critical); border-radius: 8px; padding: 8px 11px; font-size: 13px; margin-bottom: 14px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 34px; padding: 6px 12px; border-radius: 8px; font-weight: 550; font-size: 13px;
  background: var(--surface); border: 1px solid var(--hairline-strong); cursor: pointer; white-space: nowrap; transition: background .12s;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { background: var(--critical); border-color: transparent; color: #fff; }
.btn.danger:hover { filter: brightness(.93); }
.btn.danger-ghost { color: var(--critical); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { min-height: 28px; padding: 3px 9px; font-size: 12.5px; }
.btn.icon-only { padding: 0; width: 34px; }
.btn.full { width: 100%; }

/* Shell */
.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100%; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; border-right: 1px solid var(--hairline); background: var(--surface); padding: 14px 10px; overflow-y: auto; z-index: 30; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; }
.brand img { width: 28px; height: 28px; border-radius: 7px; }
.brand b { font-weight: 650; font-size: 14px; letter-spacing: -0.1px; display: block; line-height: 1.2; }
.brand small { color: var(--text-3); font-size: 11.5px; display: block; }
.nav-group { margin-bottom: 14px; }
.nav-label { font-size: 11.5px; font-weight: 550; color: var(--text-3); padding: 0 8px 4px; }
.nav-item { display: flex; align-items: center; gap: 9px; padding: 7px 8px; border-radius: 7px; color: var(--text-2); font-weight: 500; font-size: 13.5px; cursor: pointer; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-count { margin-left: auto; min-width: 20px; padding: 0 6px; height: 19px; border-radius: 10px; background: var(--critical); color: #fff; font-size: 11.5px; font-weight: 650; display: grid; place-items: center; }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--hairline); padding-top: 10px; }
.me { display: flex; align-items: center; gap: 9px; padding: 4px 6px; }
.me b { display: block; font-size: 13px; font-weight: 600; }
.me small { display: block; color: var(--text-3); font-size: 11.5px; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; height: 56px; padding: 0 24px; background: var(--page); border-bottom: 1px solid var(--hairline); }
.topbar .menu-btn { display: none; }
.search { position: relative; flex: 1; max-width: 460px; }
.search svg { position: absolute; left: 10px; top: 10px; color: var(--text-3); }
.search input { width: 100%; height: 36px; border-radius: 8px; border: 1px solid var(--hairline); background: var(--surface); padding: 0 12px 0 32px; }
.search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-pop { position: absolute; top: 42px; left: 0; right: 0; background: var(--surface); border: 1px solid var(--hairline-strong); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 6px; max-height: 420px; overflow-y: auto; }
.search-head { font-size: 11.5px; color: var(--text-3); font-weight: 550; padding: 6px 8px 3px; }
.search-item { display: flex; align-items: center; gap: 9px; padding: 7px 8px; border-radius: 7px; cursor: pointer; width: 100%; text-align: left; background: none; border: 0; }
.search-item:hover { background: var(--surface-2); }
.updated { color: var(--text-3); font-size: 12.5px; white-space: nowrap; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); display: inline-block; margin-right: 6px; }
.page { padding: 22px 24px 48px; max-width: 1400px; width: 100%; transition: opacity .15s; }
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 21px; font-weight: 650; letter-spacing: -0.3px; }
.page-head p { color: var(--text-2); margin-top: 2px; max-width: 70ch; }
.page-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.refetching { opacity: .55; }

/* Cards & grids */
.card { background: var(--surface); border: 1px solid var(--hairline); border-radius: 12px; box-shadow: var(--shadow-sm); min-width: 0; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px 0; }
.card-head h2 { font-size: 14px; font-weight: 600; }
.card-head p { color: var(--text-3); font-size: 12.5px; }
.card-body { padding: 12px 16px 16px; }
.card-body.flush { padding: 8px 0 0; }
.grid { display: grid; gap: 14px; margin-bottom: 14px; }
.grid.k4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.k3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.k2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.wide-left { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }

/* Stat tiles */
.tile { padding: 14px 16px; }
.tile-label { color: var(--text-2); font-size: 12.5px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.tile-value { font-size: 26px; font-weight: 640; letter-spacing: -0.5px; margin-top: 4px; line-height: 1.2; }
.tile-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 6px; min-height: 26px; }
.delta { font-size: 12.5px; font-weight: 550; color: var(--text-3); }
.delta.up { color: var(--good); }
.delta.down { color: var(--critical); }

/* Attention strip */
.attention { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.attn { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 9px; background: var(--surface); border: 1px solid var(--hairline); font-weight: 550; font-size: 13px; cursor: pointer; }
.attn:hover { background: var(--surface-2); }
.attn b { font-weight: 700; }
.attn.critical { background: var(--critical-soft); border-color: transparent; color: var(--critical); }
.attn.warning { background: var(--warning-soft); border-color: transparent; color: var(--warning); }
.attn.clear { cursor: default; background: var(--good-soft); border-color: transparent; color: var(--good); }

/* Pills */
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 20px; font-size: 12px; font-weight: 600; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.pill svg.icon { width: 12px; height: 12px; }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.warning { background: var(--warning-soft); color: var(--warning); }
.pill.serious { background: var(--serious-soft); color: var(--serious); }
.pill.critical { background: var(--critical-soft); color: var(--critical); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }

/* Tabs & filters */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--hairline); margin-bottom: 14px; overflow-x: auto; }
.tab { padding: 8px 12px; border: 0; background: none; color: var(--text-2); font-weight: 550; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 14px; }
.chip { padding: 5px 11px; border-radius: 20px; border: 1px solid var(--hairline-strong); background: var(--surface); font-size: 12.5px; font-weight: 550; color: var(--text-2); cursor: pointer; }
.chip:hover { background: var(--surface-2); }
.chip.active { background: var(--accent); border-color: transparent; color: var(--on-accent); }
.segmented { display: inline-flex; padding: 2px; background: var(--surface-3); border-radius: 8px; }
.segmented button { border: 0; background: none; padding: 4px 10px; border-radius: 6px; font-size: 12.5px; font-weight: 550; color: var(--text-2); cursor: pointer; }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.filter-input { width: 290px; max-width: 100%; }
.select.compact { width: auto; min-height: 34px; padding: 5px 9px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th { text-align: left; font-size: 12px; font-weight: 550; color: var(--text-3); padding: 8px 12px; border-bottom: 1px solid var(--hairline); white-space: nowrap; background: var(--surface); }
table.data td { padding: 9px 12px; border-bottom: 1px solid var(--hairline); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr.clickable { cursor: pointer; }
table.data tr.clickable:hover td { background: var(--surface-2); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
.cell-user { display: flex; align-items: center; gap: 9px; min-width: 0; }
.cell-user b { font-weight: 600; display: block; }
.cell-user small { color: var(--text-3); font-size: 12px; display: block; }
.avatar { border-radius: 50%; object-fit: cover; background: var(--surface-3); flex: none; display: inline-grid; place-items: center; color: var(--text-2); font-weight: 650; overflow: hidden; }
.thumb { width: 42px; height: 42px; border-radius: 7px; object-fit: cover; background: var(--surface-3); flex: none; display: inline-grid; place-items: center; color: var(--text-3); }
.pager { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--hairline); color: var(--text-2); font-size: 13px; }
.empty { padding: 40px 16px; text-align: center; color: var(--text-3); }
.empty svg.icon { width: 26px; height: 26px; margin-bottom: 8px; }
.empty b { display: block; color: var(--text); font-weight: 600; margin-bottom: 2px; }
.loading { padding: 40px; text-align: center; color: var(--text-3); }
.error-box { padding: 16px; border-radius: 10px; background: var(--critical-soft); color: var(--critical); margin-bottom: 14px; }

/* Lists */
.list-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--hairline); }
.list-row:last-child { border-bottom: 0; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13.5px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

/* Case cards */
.case { padding: 14px 16px; border-bottom: 1px solid var(--hairline); }
.case:last-child { border-bottom: 0; }
.case-top { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-bottom: 8px; }
.case-body { display: flex; gap: 12px; align-items: flex-start; }
.case-preview { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.case-quote { background: var(--surface-2); border-radius: 8px; padding: 8px 11px; margin-top: 6px; color: var(--text); white-space: pre-wrap; max-height: 130px; overflow: hidden; }
.case-media { width: 76px; height: 76px; border-radius: 8px; object-fit: cover; flex: none; cursor: zoom-in; background: var(--surface-3); border: 0; padding: 0; }
.case-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.doc-images { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.doc-images button { border: 0; padding: 0; background: none; cursor: zoom-in; border-radius: 8px; overflow: hidden; }
.doc-images img { width: 120px; height: 84px; object-fit: cover; display: block; background: var(--surface-3); }

/* Media tiles and viewer */
.media-tile { position: relative; flex: none; padding: 0; border: 0; border-radius: 7px; overflow: hidden; background: var(--surface-3); color: var(--text-3); cursor: pointer; display: inline-grid; place-items: center; }
.media-tile img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.media-tile:hover img { filter: brightness(.85); }
.media-play { position: relative; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: rgba(0, 0, 0, .62); color: #fff; }
.media-play svg.icon { fill: #fff; margin-left: 1px; }
.media-more { position: absolute; right: 3px; bottom: 3px; min-width: 16px; padding: 0 4px; border-radius: 8px; background: rgba(0, 0, 0, .68); color: #fff; font-size: 10.5px; font-weight: 700; line-height: 16px; text-align: center; }
.viewer { position: fixed; inset: 0; z-index: 70; display: flex; flex-direction: column; background: rgba(8, 9, 12, .97); color: #fff; }
.viewer-top { display: flex; align-items: center; gap: 10px; padding: 12px 16px; min-height: 56px; }
.viewer-count { font-size: 13px; color: #c9cad3; }
.viewer-close, .viewer-nav { display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .12); color: #fff; cursor: pointer; flex: none; }
.viewer-close:hover, .viewer-nav:hover:not(:disabled) { background: rgba(255, 255, 255, .22); }
.viewer-nav:disabled { opacity: .3; cursor: default; }
.viewer-body { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; gap: 14px; padding: 0 16px; }
.viewer-stage { flex: 1; min-width: 0; height: 100%; display: flex; align-items: center; justify-content: center; }
.viewer-media { max-width: 100%; max-height: 100%; border-radius: 8px; background: #000; display: block; }
.viewer-error { text-align: center; color: #d6d7de; display: grid; justify-items: center; gap: 6px; padding: 24px; }
.viewer-error b { color: #fff; font-weight: 600; }
.viewer .btn { color: #12131a; background: #fff; border-color: transparent; margin-top: 6px; }
.viewer .btn:hover { background: #e6e6ec; }
.viewer-caption { padding: 12px 20px 16px; max-height: 22vh; overflow-y: auto; font-size: 13.5px; color: #d6d7de; text-align: center; overflow-wrap: anywhere; }
.viewer-caption b { color: #fff; font-weight: 600; display: block; margin-bottom: 2px; }

/* Charts */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart text { font: 11.5px system-ui, -apple-system, "Segoe UI", sans-serif; fill: var(--text-3); font-variant-numeric: tabular-nums; }
.chart-tip { position: absolute; z-index: 5; pointer-events: none; background: var(--surface); border: 1px solid var(--hairline-strong); border-radius: 8px; box-shadow: var(--shadow-lg); padding: 7px 10px; font-size: 12.5px; min-width: 110px; white-space: nowrap; }
.chart-tip .tip-title { color: var(--text-3); font-size: 11.5px; margin-bottom: 3px; }
.chart-tip .tip-row { display: flex; align-items: center; gap: 7px; }
.chart-tip .tip-key { width: 12px; height: 2px; border-radius: 1px; flex: none; }
.chart-tip b { font-weight: 650; font-variant-numeric: tabular-nums; }
.chart-tip span.tip-name { color: var(--text-2); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12.5px; color: var(--text-2); margin-bottom: 8px; }
.legend i { display: inline-block; width: 12px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.link-btn { background: none; border: 0; padding: 0; color: var(--text-3); font-size: 12.5px; cursor: pointer; }
.link-btn:hover { color: var(--text); text-decoration: underline; }
.bar-list { display: grid; gap: 9px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; font-size: 13px; }
.bar-row .bar-track { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.bar-row .bar-fill { height: 100%; border-radius: 3px; background: var(--series-1); }
.seg-bar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; gap: 2px; }
.seg-bar i { display: block; height: 100%; }
.seg-legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12.5px; color: var(--text-2); margin-top: 8px; }
.seg-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; }
.meter { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--series-1); border-radius: 4px; }
table.cohort { width: 100%; border-collapse: separate; border-spacing: 2px; font-size: 12.5px; }
table.cohort th { font-weight: 550; color: var(--text-3); text-align: left; padding: 4px 6px; white-space: nowrap; }
table.cohort td { padding: 7px 8px; border-radius: 5px; text-align: center; font-variant-numeric: tabular-nums; }
table.cohort td.label { text-align: left; white-space: nowrap; color: var(--text-2); }

/* Overlays */
.overlay { position: fixed; inset: 0; background: var(--overlay); z-index: 50; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 560px; max-width: 100%; background: var(--page); z-index: 51; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: slide .18s ease-out; }
@keyframes slide { from { transform: translateX(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; background: var(--surface); border-bottom: 1px solid var(--hairline); }
.drawer-body { flex: 1; overflow-y: auto; padding: 14px 18px 40px; }
.drawer-body .card { margin-bottom: 12px; }
.dialog-wrap { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; overflow-y: auto; }
.dialog { width: 100%; max-width: 460px; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 20px; position: relative; z-index: 61; }
.dialog.wide { max-width: 620px; }
.dialog h2 { font-size: 16px; font-weight: 650; margin-bottom: 4px; }
.dialog > p { color: var(--text-2); margin-bottom: 14px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.lightbox { position: relative; z-index: 61; max-width: 92vw; max-height: 92vh; border-radius: 10px; }
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 80; display: grid; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast { display: flex; gap: 8px; padding: 10px 13px; border-radius: 10px; background: var(--text); color: var(--page); box-shadow: var(--shadow-lg); font-size: 13.5px; font-weight: 500; animation: rise .16s ease-out; }
.toast.error { background: var(--critical); color: #fff; }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.health { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--hairline); }
.health:last-child { border-bottom: 0; }
.switch { position: relative; width: 38px; height: 22px; border-radius: 11px; background: var(--surface-3); border: 1px solid var(--hairline-strong); cursor: pointer; padding: 0; flex: none; }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: left .12s; }
.switch.on { background: var(--critical); border-color: transparent; }
.switch.on::after { left: 18px; }

@media (max-width: 1100px) {
  .grid.k4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.wide-left, .grid.k3 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 600px) {
  .viewer-body { gap: 0; padding: 0; position: relative; }
  .viewer-nav { position: absolute; z-index: 2; top: 50%; margin-top: -20px; }
  .viewer-nav.prev { left: 8px; }
  .viewer-nav.next { right: 8px; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 248px; transform: translateX(-100%); transition: transform .18s; z-index: 45; }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .topbar { padding: 0 16px; }
  .topbar .menu-btn { display: inline-flex; }
  .updated { display: none; }
  .page { padding: 16px 16px 40px; }
  .grid.k2 { grid-template-columns: minmax(0, 1fr); }
  .page-actions { margin-left: 0; }
}
@media (max-width: 480px) {
  .grid.k4 { grid-template-columns: minmax(0, 1fr); }
  .tile-value { font-size: 23px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@media (forced-colors: active) { .bar-fill, .meter i, .seg-bar i { forced-color-adjust: none; } }
