/* Shared theme control: SVG icons inherit the current text color. */
.theme-switch { display: inline-flex; gap: 2px; padding: 2px; border: 1px solid #cbd5e1; border-radius: 8px; background: #e2eaf4; }
.session-bar .theme-switch button { display: grid; place-items: center; width: 28px; height: 28px; padding: 5px; border: 0; border-radius: 6px; background: transparent; color: #64748b; }
.session-bar .theme-switch button[aria-pressed="true"] { background: #fff; color: #245ac2; box-shadow: 0 1px 3px #0f172a24; }
.theme-switch svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.theme-switch button:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111827; --panel: #1d2939; --line: #3a4a5e; --line2: #303e50;
  --ink: #edf2f8; --muted: #adbacb; --brand: #6797f5; --brand-d: #a9c5ff;
  --ok: #71d99c; --okbg: #153c2c; --warn: #f3c969; --danger: #ff9696; --dangerbg: #482b32;
  --eu: #253d61; --sel: #254d76; --header: #26364a; --chip: #303e50;
}
:root[data-theme="dark"] body { background: var(--bg); color: var(--ink); }
:root[data-theme="dark"] :is(.session-bar, .pager, .detail .dhead, .kl) { background: #26364a; color: var(--ink); }
:root[data-theme="dark"] :is(.ixf, .tablescroll, .panel, .kt, .detail, .popover, .modal, .ctx, .grpbox, .multisel-pop, .summary, .card) { background: var(--panel); color: var(--ink); border-color: var(--line); }
:root[data-theme="dark"] :is(.btn, .btn.ibtn, .session-bar button, .chip, .pl, .search, .seg, .andor button, .combo button, .filterbar .add-filter, input, select) { background: #26364a; color: var(--ink); border-color: var(--line); }
:root[data-theme="dark"] :is(.btn:hover, .btn.ibtn:hover, .vitem:hover, .ms-row:hover, #statoChips .chip:hover, .pl .x0:hover) { background: #33475f; color: var(--ink); }
:root[data-theme="dark"] :is(.btn.pri, .chip.on, #statoChips .chip.on) { background: #315eaf; border-color: #6797f5; color: #fff; }
:root[data-theme="dark"] :is(.seg button, #statoChips .chip) { color: var(--muted); }
:root[data-theme="dark"] :is(.seg button.on, .btn.ibtn.on, .andor button.on) { background: #315286; color: #fff; border-color: #6797f5; }
:root[data-theme="dark"] :is(.session-bar .theme-switch button) { background: transparent; color: #aebdd0; }
:root[data-theme="dark"] .theme-switch { background: #172233; border-color: var(--line); }
:root[data-theme="dark"] .session-bar .theme-switch button[aria-pressed="true"] { background: #415b80; color: #fff; }
:root[data-theme="dark"] :is(.filterbar .fchip, .grpbox.depth1, .grpbox.depth2) { background: #293c56; color: var(--ink); border-color: var(--line); }
:root[data-theme="dark"] .filterbar .fchip .fk { color: var(--muted); }
:root[data-theme="dark"] :is(thead th, thead th.key) { background: var(--header); color: var(--ink); }
:root[data-theme="dark"] table.itab thead th { background: var(--panel); color: var(--muted); }
:root[data-theme="dark"] table.itab td { border-color: var(--line2); }
:root[data-theme="dark"] tr.grpA td { background: #202e40; }
:root[data-theme="dark"] tr.grpB td { background: #1a2635; }
:root[data-theme="dark"] tbody tr:hover td { background: #344a64 !important; }
:root[data-theme="dark"] tr.sel td, :root[data-theme="dark"] tr.sel:hover td { background: #28507a !important; }
:root[data-theme="dark"] tr.focus td, :root[data-theme="dark"] table.itab tr.cur td { background: #594a2e !important; }
:root[data-theme="dark"] table.itab tr.same td { background: #293f5c; }
:root[data-theme="dark"] :is(.b-stato, .b-it) { background: #35465a; border-color: #53647a; color: #e2e8f0; }
:root[data-theme="dark"] :is(.b-eu, .b-adv, .b-drop) { background: #303f64; border-color: #596b9c; color: #cbd8ff; }
:root[data-theme="dark"] :is(.b-ok, .b-done, .giac-badge) { border-color: #3b7659; }
:root[data-theme="dark"] :is(.b-none, .b-late, .b-multi) { background: #482b32; border-color: #96616a; color: #ffb7b7; }
:root[data-theme="dark"] :is(.ui-state[data-state="loading"], .ui-state[data-state="progress"]) { background: #203d59; color: #c7e2ff; }
:root[data-theme="dark"] :is(.ui-state[data-state="empty"], .ui-state[data-state="disabled"]) { background: #29394d; color: #d0dbe8; }
:root[data-theme="dark"] :is(.ui-state[data-state="error"], .ui-state[data-state="validation"], .ui-state[data-state="unauthorized"], .ui-state[data-state="forbidden"]) { background: #4a2b32; color: #ffd0d0; }
:root[data-theme="dark"] :is(.ui-state[data-state="warning"], .ui-state[data-state="partial"], .ui-state[data-state="conflict"], .ui-state[data-state="stale"], .ui-state[data-state="unsaved"]) { background: #4d4027; color: #ffe1a0; }
:root[data-theme="dark"] .ui-state[data-state="success"] { background: #1d4935; color: #b7f3cd; }
:root[data-theme="dark"] :is(.card p, .card .brand) { color: #bdcde1; }
:root[data-theme="dark"] .card button[type="submit"] { background: #315eaf; color: #fff; }
:root[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #60738b; border-color: var(--panel); }

:root[data-theme="dark"] .kt.rt2 { background:#573927; border-color:#a26136; }
:root[data-theme="dark"] .kt.rt2 :is(.l,.v) { color:#ffd1a8; }
:root[data-theme="dark"] .kt.rt3 { background:#5b2b32; border-color:#a34c59; }
:root[data-theme="dark"] .kt.rt3 :is(.l,.v) { color:#ffc3c7; }
:root[data-theme="dark"] .kt.rt4 { background:#46335f; border-color:#8666b4; }
:root[data-theme="dark"] .kt.rt4 :is(.l,.v) { color:#e0c8ff; }
