/* Dashboard design system (2026-10-20 revamp, owner ask: "uniform on all pages ... modern, flat and boxy").
   One set of tokens, one page skeleton, one look for panels / tiles / buttons / inputs / tables / badges.
   Every page links this file first, then nav.css, then its own <style> for what is specific to that page.
   Rules: square corners everywhere except true markers (dots, spinners, gauge needles), no drop shadows,
   no gradients, 1px lines on flat surfaces, one accent per page set as --accent on :root. */

:root {
    --bg: #0b0b0c;
    --surface: #121214;
    --surface-2: #18181b;
    --surface-3: #1f1f23;
    --line: #26262b;
    --line-2: #34343b;
    --text: #d9d9de;
    --text-hi: #f4f4f5;
    --muted: #85858f;
    --faint: #55555e;
    --accent: #e4e4e7;
    --accent-dim: color-mix(in srgb, var(--accent) 14%, transparent);
    --accent-line: color-mix(in srgb, var(--accent) 45%, var(--line-2));
    --on-accent: #0b0b0c;
    --pos: #4ade80; --pos-dim: #0f2a1a;
    --neg: #f87171; --neg-dim: #2a1010;
    --warn: #f5c66a; --warn-dim: #221b0c;
    --info: #93c5fd; --info-dim: #0e1a2a;
    --violet: #a78bfa; --violet-dim: #17132a;
    --r: 0px;
    --mono: ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Consolas, "Fira Code", "Liberation Mono", monospace;
    --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, Helvetica, Arial, sans-serif;
}

/* ---- base ---- */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { font-family: var(--sans); background: var(--bg); color: var(--text); line-height: 1.4; }
a { color: var(--accent); }
::selection { background: var(--accent); color: var(--on-accent); }
.mono { font-family: var(--mono); }
.spacer { flex: 1; }
.up, .pos { color: var(--pos) !important; }
.down, .neg { color: var(--neg) !important; }
.flat { color: var(--muted) !important; }

/* ---- page skeleton ---- */
.page-wrap { max-width: 1240px; margin: 0 auto; padding: 1.6rem 2rem 4rem; }
.head { display: flex; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.4rem; }
.head .spacer { flex: 1; }
h1 { font-size: 1.35rem; font-weight: 700; letter-spacing: -0.01em; color: var(--text-hi); margin-bottom: 0.3rem; }
.lead { color: var(--muted); font-size: 0.84rem; line-height: 1.5; max-width: 820px; }
.lead b { color: var(--text); font-weight: 600; }
.page-header { margin-bottom: 1.4rem; }
.page-header h1 { margin-bottom: 0.2rem; }
.page-header .subtitle, .page-header .lede { color: var(--muted); font-size: 0.84rem; }
.foot { color: var(--faint); font-size: 0.7rem; margin-top: 2rem; line-height: 1.5; }
.empty { color: var(--faint); font-size: 0.85rem; padding: 0.6rem 0; }
.note { color: var(--muted); font-size: 0.74rem; line-height: 1.5; }
.note b { color: var(--text); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
@media (max-width: 900px) { .two { grid-template-columns: 1fr; } }

/* ---- kicker: the small uppercase label used on panel titles, tiles and table heads ---- */
.kicker, .card h2, .tile .k, th, .calc-field label, .fg-kicker {
    font-size: 0.64rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted);
}

/* ---- panels ---- */
.card, .panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 1.1rem 1.25rem; margin-bottom: 1.2rem; min-width: 0; }
.card h2 { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 0.9rem; color: var(--text-hi); }
.card h2 .dot { width: 8px; height: 8px; background: var(--accent); display: inline-block; flex: none; }
.card h2 .sub { color: var(--muted); font-weight: 500; letter-spacing: 0; text-transform: none; font-size: 0.74rem; }
.card h2 .right { margin-left: auto; display: flex; gap: 0.4rem; align-items: center; font-weight: 500; letter-spacing: 0; text-transform: none; font-size: 0.74rem; color: var(--muted); }

/* ---- stat tiles ---- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.6rem; margin-bottom: 1.2rem; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 0.75rem 0.95rem; min-width: 0; }
.tile .k { margin-bottom: 0.35rem; }
.tile .v { font-size: 1.3rem; font-weight: 700; color: var(--text-hi); font-family: var(--mono); font-variant-numeric: tabular-nums; line-height: 1.1; }
.tile .s { font-size: 0.68rem; color: var(--muted); margin-top: 0.3rem; line-height: 1.4; }

/* ---- buttons ---- */
.btn, button.primary, button.ghost, button.danger, .fg-btn, .export-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
    background: var(--surface-2); border: 1px solid var(--line-2); color: var(--text); border-radius: var(--r);
    padding: 0.45rem 0.85rem; font: 600 0.78rem var(--sans); line-height: 1.2; cursor: pointer; white-space: nowrap; text-decoration: none;
    transition: border-color 0.12s, background 0.12s, color 0.12s;
}
.btn:hover, button.ghost:hover, .fg-btn:hover, .export-btn:hover { border-color: var(--accent); color: var(--text-hi); }
.btn:disabled, button:disabled { opacity: 0.5; cursor: default; }
.btn.primary, button.primary, .fg-btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover:not(:disabled), button.primary:hover:not(:disabled), .fg-btn.primary:hover { filter: brightness(1.1); }
.btn.ghost, button.ghost { background: transparent; }
.btn.danger, button.danger { background: transparent; color: var(--neg); border-color: color-mix(in srgb, var(--neg) 40%, var(--line-2)); }
.btn.danger:hover, button.danger:hover { background: var(--neg-dim); border-color: var(--neg); color: var(--neg); }
.btn.small, .btn.sm { padding: 0.28rem 0.55rem; font-size: 0.7rem; }
.btn.link { background: none; border: none; color: var(--accent); padding: 0; font-weight: 500; }
.btn.link:hover { text-decoration: underline; }
.spin { display: inline-block; width: 10px; height: 10px; border: 2px solid color-mix(in srgb, var(--accent) 35%, transparent); border-top-color: var(--accent); border-radius: 50%; animation: sp 0.8s linear infinite; vertical-align: -1px; }
@keyframes sp { to { transform: rotate(360deg); } }

/* ---- segmented controls and sub-tabs ---- */
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--r); overflow: hidden; background: var(--surface-2); }
.seg button { background: none; border: none; color: var(--muted); padding: 0.42rem 0.7rem; font: 600 0.74rem var(--sans); cursor: pointer; }
.seg button + button, .seg .lbl + button { border-left: 1px solid var(--line-2); }
.seg button:hover { color: var(--text-hi); }
.seg button.on, .seg button[aria-pressed="true"] { color: var(--accent); background: var(--accent-dim); }
.seg .lbl { color: var(--faint); padding: 0.42rem 0.55rem 0.42rem 0.7rem; font-size: 0.62rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; align-self: center; }
.subtabs, .ptabs { display: flex; gap: 0; border-bottom: 1px solid var(--line); margin-bottom: 1.2rem; flex-wrap: wrap; align-items: center; }
.subtab, .ptab { background: none; border: none; color: var(--muted); padding: 0.6rem 0.95rem; font: 600 0.82rem var(--sans); cursor: pointer; text-decoration: none; position: relative; margin-bottom: -1px; border-bottom: 2px solid transparent; }
.subtab:hover, .ptab:hover { color: var(--text-hi); background: var(--surface); }
.subtab.active, .ptab.active { color: var(--text-hi); border-bottom-color: var(--accent); }
.subtab .cnt, .ptab .cnt { color: var(--faint); font-weight: 500; font-size: 0.7rem; margin-left: 0.3rem; font-family: var(--mono); }
.pane { display: none; } .pane.active { display: block; }
.subnav { display: flex; gap: 0; margin-bottom: 1.4rem; flex-wrap: wrap; border: 1px solid var(--line-2); width: max-content; max-width: 100%; }
.subnav a { padding: 0.42rem 1rem; color: var(--muted); text-decoration: none; font: 600 0.78rem var(--sans); border-left: 1px solid var(--line-2); }
.subnav a:first-child { border-left: 0; }
.subnav a:hover { color: var(--text-hi); background: var(--surface-2); }
.subnav a.active { color: var(--accent); background: var(--accent-dim); }

/* ---- forms ---- */
.controls { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; font-size: 0.78rem; color: var(--muted); }
.controls label { display: inline-flex; align-items: center; gap: 0.35rem; }
select, input[type=text], input[type=number], input[type=url], input[type=search], input[type=date], textarea {
    background: var(--bg); border: 1px solid var(--line-2); color: var(--text-hi); border-radius: var(--r);
    padding: 0.42rem 0.6rem; font: 400 0.82rem var(--sans); outline: none;
}
select:focus, input:focus, textarea:focus { border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--faint); }
.chk { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.78rem; color: var(--muted); cursor: pointer; user-select: none; }
.chk input, .toggle input { accent-color: var(--accent); }
.toggle { display: inline-flex; align-items: center; gap: 0.5rem; font: 600 0.76rem var(--sans); color: var(--muted); cursor: pointer; user-select: none; border: 1px solid var(--line-2); background: var(--surface-2); padding: 0.4rem 0.8rem; }
.toggle:hover { border-color: var(--accent); color: var(--text-hi); }

/* ---- tables ---- */
table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
th { text-align: left; padding: 0.35rem 0.5rem; border-bottom: 1px solid var(--line-2); white-space: nowrap; user-select: none; }
th.sortable { cursor: pointer; } th.sortable:hover { color: var(--text); }
th.sorted { color: var(--accent); }
td { padding: 0.42rem 0.5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
td.sym { font-weight: 700; color: var(--text-hi); white-space: nowrap; }
td.sym .name { display: block; font-weight: 400; color: var(--muted); font-size: 0.68rem; }

/* ---- badges and chips: flat, square, uppercase ---- */
.badge, .chip { display: inline-block; font-size: 0.6rem; font-weight: 700; padding: 0.12rem 0.4rem; border-radius: var(--r); text-transform: uppercase; letter-spacing: 0.06em; background: var(--surface-3); color: var(--muted); vertical-align: middle; white-space: nowrap; }
.badge.good, .chip.good, .badge.ok, .badge.armed, .badge.beats, .badge.rh, .badge.now, .chip.fit { color: var(--pos); background: var(--pos-dim); }
.badge.bad, .chip.bad, .badge.out, .badge.ir, .badge.susp, .badge.miss, .chip.reject { color: var(--neg); background: var(--neg-dim); }
.badge.warn, .chip.warn, .badge.seeding, .badge.dtd, .badge.stale, .badge.lev, .chip.unverified, .chip.error { color: var(--warn); background: var(--warn-dim); }
.badge.info, .badge.cash, .badge.sw, .badge.build, .chip.me, .chip.manual { color: var(--info); background: var(--info-dim); }
.badge.opt, .badge.wv, .chip.ai { color: var(--violet); background: var(--violet-dim); }

/* ---- messages: the shared look for block notices. Pages map their own class names (.warn, .err, .flag, .status)
   onto these two rules because the same names mean plain coloured text on some pages. ---- */
.msg-box { border-radius: var(--r); padding: 0.7rem 0.9rem; font-size: 0.8rem; line-height: 1.5; margin-bottom: 1.2rem; border: 1px solid var(--line-2); background: var(--surface); color: var(--text); }
.msg-box.is-warn { background: var(--warn-dim); border-color: color-mix(in srgb, var(--warn) 35%, transparent); color: var(--warn); }
.msg-box.is-err { background: var(--neg-dim); border-color: color-mix(in srgb, var(--neg) 35%, transparent); color: #fca5a5; }
.msg-box.is-ok { background: var(--pos-dim); border-color: color-mix(in srgb, var(--pos) 35%, transparent); color: #86efac; }
.msg-box.is-info { background: var(--info-dim); border-color: color-mix(in srgb, var(--info) 35%, transparent); color: var(--info); }
.note code { color: var(--warn); font-family: var(--mono); font-size: 0.74rem; }

/* ---- overlays: modal, toast, lightbox ---- */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,0.75); z-index: 200; display: none; align-items: flex-start; justify-content: center; overflow-y: auto; padding: 4vh 16px; }
.modal-bg.on, .modal-bg.open { display: flex; }
.modal { background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r); width: 100%; max-width: 980px; padding: 1.2rem 1.4rem 1.4rem; position: relative; }
.modal h3 { color: var(--text-hi); font-size: 1rem; margin: 0 2rem 0.8rem 0; }
.modal .close { position: absolute; top: 8px; right: 10px; background: none; border: none; color: var(--muted); font-size: 1.4rem; cursor: pointer; line-height: 1; }
.modal .close:hover { color: var(--text-hi); }
.toast { position: fixed; bottom: 1.2rem; right: 1.2rem; background: var(--surface-2); border: 1px solid var(--line-2); border-left: 3px solid var(--accent); color: var(--text); padding: 0.6rem 1rem; border-radius: var(--r); font-size: 0.8rem; opacity: 0; transition: opacity 0.2s; z-index: 300; pointer-events: none; }
.toast.show { opacity: 1; }
.toast.err { border-left-color: var(--neg); color: var(--neg); }
.lightbox, .zoom { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.9); z-index: 250; align-items: center; justify-content: center; cursor: zoom-out; }
.lightbox.open, .zoom.on { display: flex; }
.lightbox img, .zoom img { max-width: 94vw; max-height: 94vh; border: 1px solid var(--line-2); }

/* ---- misc shared ---- */
.tip { position: absolute; pointer-events: none; background: var(--surface-2); border: 1px solid var(--line-2); padding: 0.5rem 0.7rem; font-size: 0.78rem; color: var(--text); white-space: nowrap; display: none; z-index: 5; line-height: 1.5; }
.tip b { color: var(--text-hi); }

@media (max-width: 760px) {
    .page-wrap { padding: 1rem 1rem 3rem; }
    h1 { font-size: 1.15rem; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
