/* ════════ Platform dark mode ════════
   Active when <html data-theme="dark"> (set in index.html before the first paint, from the person's
   choice: Auto follows the system, or Light / Dark). Loaded last, after brand.css. Palette: deep navy
   surfaces (never pure black), the same brand blue lifted for contrast, every text AA on its surface. */
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1220; --surface: #121a2b; --surface-2: #172238; --border: #26324a; --border-strong: #3a4866;
  --text: #e8edf6; --text-2: #b4bfd3; --text-3: #94a0b8;
  --ink: #e8edf6; --ink-2: #b4bfd3; --ink-3: #94a0b8; --ink-brand: #7db6f2; --ink-ok: #4cc38a;
  --primary: #4d9be6; --primary-2: #7db6f2; --primary-soft: rgba(77,155,230,.14);
  --brand: #4d9be6; --brand-navy: #c9d8f2;
  --ok: #4cc38a; --ok-soft: rgba(76,195,138,.12); --warn: #f0a24a; --warn-soft: rgba(240,162,74,.12);
  --bad: #f07a6d; --bad-soft: rgba(240,122,109,.12); --info: #4d9be6; --info-soft: rgba(77,155,230,.12);
  --p-card: rgba(18,26,43,.88);
  --p-shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  --p-shadow-hi: 0 1px 2px rgba(0,0,0,.4), 0 16px 40px rgba(0,0,0,.45);
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3);
  --s4: 0 0 2px rgba(0,0,0,.5), 0 2px 4px rgba(0,0,0,.4); --s8: 0 0 2px rgba(0,0,0,.5), 0 4px 8px rgba(0,0,0,.4);
  --s16: 0 0 2px rgba(0,0,0,.5), 0 8px 16px rgba(0,0,0,.45); --s64: 0 0 8px rgba(0,0,0,.5), 0 32px 64px rgba(0,0,0,.55);
}
html[data-theme="dark"] body { background: var(--bg) !important; color: var(--text); }
html[data-theme="dark"] .lek, html[data-theme="dark"] .bg-waves { opacity: .12 !important; filter: invert(1) hue-rotate(180deg); }

/* surfaces */
html[data-theme="dark"] :is(.card, .gridbox, .kpi, .modal, .modal .mb, .modal .mh, .modal .mf, .signin-card, .push-card, .qs, .toast,
  .item-card, .tbl-wrap, .mbx-list, .read, .mbx-read, .tabs, .chat-panel, .dd-menu, .menu, .popover, .wz-card, .box, .panel, .sb-points li) {
  background: var(--surface) !important; color: var(--text); border-color: var(--border) !important; box-shadow: var(--p-shadow) !important;
}
html[data-theme="dark"] :is(.top, header.top) { background: rgba(11,18,32,.82) !important; border-color: var(--border) !important;
  -webkit-backdrop-filter: saturate(160%) blur(18px); backdrop-filter: saturate(160%) blur(18px); }
html[data-theme="dark"] :is(.tree, aside.tree) { background: #0e1626 !important; border-color: var(--border) !important; }
html[data-theme="dark"] .tabbar { background: rgba(11,18,32,.9) !important; border-color: var(--border) !important; }
html[data-theme="dark"] .main, html[data-theme="dark"] .shell { background: transparent !important; }
html[data-theme="dark"] .signin { background: var(--bg) !important; }

/* text */
html[data-theme="dark"] :is(h1, h2, h3, h4, b, strong, th, .page-head h1, .lbl .tx, .kpi b, .qs-list li b, .empty b) { color: var(--text); }
html[data-theme="dark"] :is(.sub, .small, small, .faint, .kpi span, .page-head .sub, .signin-sub, .qs-list li small, .empty, .muted, .left) { color: var(--text-2) !important; }
html[data-theme="dark"] a { color: #7db6f2; }
html[data-theme="dark"] .app-foot, html[data-theme="dark"] .app-foot a, html[data-theme="dark"] .app-foot .lnk { color: var(--text-3) !important; }

/* tables */
html[data-theme="dark"] .tbl th { background: var(--surface-2) !important; color: var(--text-2) !important; border-color: var(--border) !important; }
html[data-theme="dark"] .tbl td { border-color: var(--border) !important; color: var(--text); }
html[data-theme="dark"] .tbl tr.clickable:hover td, html[data-theme="dark"] .tbl tbody tr:hover td { background: rgba(77,155,230,.07) !important; }
html[data-theme="dark"] table.tbl.slim tr { border-color: var(--border) !important; }

/* forms */
html[data-theme="dark"] :is(input, select, textarea) { background: #0e1626 !important; color: var(--text) !important; border-color: var(--border-strong) !important; }
html[data-theme="dark"] :is(input, textarea)::placeholder { color: #7f8aa3 !important; }
html[data-theme="dark"] .btn:not(.primary):not(.danger) { background: var(--surface-2) !important; color: var(--text) !important; border-color: var(--border-strong) !important; }
html[data-theme="dark"] .btn.primary { color: #fff !important; }
html[data-theme="dark"] .seg { background: #0e1626 !important; } html[data-theme="dark"] .seg .on { background: var(--surface-2) !important; color: #7db6f2 !important; }

/* menu */
html[data-theme="dark"] .tree .lbl { color: var(--text-2) !important; }
html[data-theme="dark"] .tree .lbl.active, html[data-theme="dark"] .tree .lbl:hover { background: rgba(77,155,230,.12) !important; color: var(--text) !important; }
html[data-theme="dark"] .toptabs a { color: var(--text-2) !important; }
html[data-theme="dark"] .toptabs a.active, html[data-theme="dark"] .toptabs a:hover { background: rgba(255,255,255,.06) !important; color: var(--text) !important; }
html[data-theme="dark"] :is(.qs-open, .sec-chip, .tf-logout, .theme-btn) { background: rgba(255,255,255,.04) !important; color: var(--text-2) !important; border-color: var(--border-strong) !important; }
html[data-theme="dark"] .tabbar .tb { color: #94a0b8; } html[data-theme="dark"] .tabbar .tb.on { color: #7db6f2; }

/* status pills and badges keep their meaning, toned for the dark */
html[data-theme="dark"] :is(.ph-open, .ok) { color: var(--ok) !important; }
html[data-theme="dark"] :is(.badge, .chip, .pill) { background: rgba(255,255,255,.06) !important; color: var(--text-2) !important; border-color: var(--border) !important; }
html[data-theme="dark"] .gridbox-title { border-color: var(--border) !important; color: var(--text); }
html[data-theme="dark"] .alert { background: var(--surface-2) !important; color: var(--text) !important; border-color: var(--border) !important; }
html[data-theme="dark"] .empty .e { background: radial-gradient(circle at 30% 30%, #1d2a44, #121a2b); box-shadow: inset 0 0 0 1px var(--border); }
html[data-theme="dark"] .skel i { background: linear-gradient(90deg, #172238, #1d2a44, #172238) !important; background-size: 200% 100% !important; }
html[data-theme="dark"] .qs-bg { background: rgba(0,0,0,.5); }
html[data-theme="dark"] .wz-steps i { background: #1d2a44; color: var(--text-2); }
html[data-theme="dark"] .wz-steps li.on span { color: var(--text); }
html[data-theme="dark"] img.signin-logo, html[data-theme="dark"] .brand img { filter: brightness(1.15); }

/* the remaining light pieces found by an automatic scan */
html[data-theme="dark"] :is(.gridbox-title, .gridbox-foot, .wz-nav) { background: var(--surface-2) !important; border-color: var(--border) !important; color: var(--text) !important; }
html[data-theme="dark"] .gridbox-title b { color: var(--text) !important; }
html[data-theme="dark"] .tbl tbody tr:nth-child(n) td { background: transparent !important; }
html[data-theme="dark"] .tbl tbody tr:nth-child(even) td { background: rgba(255,255,255,.02) !important; }
html[data-theme="dark"] .corr-btn { background: rgba(77,155,230,.10) !important; color: #7db6f2 !important; border-color: rgba(77,155,230,.35) !important; }
html[data-theme="dark"] .btn.danger { background: rgba(240,122,109,.12) !important; color: #f07a6d !important; border-color: rgba(240,122,109,.4) !important; }
html[data-theme="dark"] [data-s-group].drafts .gridbox-title, html[data-theme="dark"] .gridbox-title.warn { background: rgba(240,162,74,.08) !important; }
html[data-theme="dark"] details.nt-fold, html[data-theme="dark"] .nt-fold summary { background: var(--surface-2) !important; color: var(--text) !important; border-color: var(--border) !important; }
/* hard-coded greys and oranges that are too dark on navy */
html[data-theme="dark"] .sb-points span, html[data-theme="dark"] .wz-count, html[data-theme="dark"] .wz-steps button, html[data-theme="dark"] .wz-steps span { color: var(--text-2) !important; }
html[data-theme="dark"] :is(.qs-open kbd, .qs-in kbd) { background: rgba(255,255,255,.08); color: var(--text-2); }
html[data-theme="dark"] :is(.ph-wait, .ph-eval, .ph-closed, .warn, [class*="pret"]) { color: var(--warn) !important; }
html[data-theme="dark"] :is(.ph-evaluation, .badge.warn, .tile .tn b.crit) { color: #f0a24a !important; }
html[data-theme="dark"] .fund-secret { color: var(--text-2) !important; }
/* the light style's white glass rim reads as a hard outline on navy */
html[data-theme="dark"] { --p-rim: linear-gradient(150deg, rgba(255,255,255,.10), rgba(255,255,255,.03) 40%, rgba(255,255,255,.02)); }
html[data-theme="dark"] :is(.card, .gridbox, .kpi, .signin-card) { border: 1px solid rgba(255,255,255,.07) !important; }
@media (max-width: 640px) { html[data-theme="dark"] .tbl tbody tr:nth-child(even) td { background: transparent !important; } }
