
/* The operations UI (docs/Operations UI Plan.md). Layout: a top bar, a filter row scoping everything below it, then one
   chart-led view at a time; the subaccount view adds a side pane for the selected day. */
:root {
  --bg: #f4f6f6; --surface: #ffffff; --surface-2: #eef2f2; --ink: #0f1d27; --text: #1d2a32; --muted: #56656d;
  --faint: #86939a; --line: #dbe2e4; --grid: #e8eded; --accent: #1b5d87; --accent-soft: #e2edf4; --on-accent: #ffffff;
  --good: #1d7a3a; --warn: #a96400; --bad: #c03636; --bench: #66737b; --sel: #1b5d87; --res: #9aa5ab;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
  --shadow: 0 6px 24px rgba(15, 29, 39, .10);
  --sans: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, sans-serif; --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #0d1317; --surface: #141c21; --surface-2: #1b252b; --ink: #eaf1f4; --text: #d3dde1; --muted: #98a6ad;
  --faint: #6b7a81; --line: #27333a; --grid: #1e292f; --accent: #6eb0dc; --accent-soft: #19303f; --on-accent: #0d1317;
  --good: #4cbf6e; --warn: #e2a23c; --bad: #ef6b6b; --bench: #9ba8af; --sel: #6eb0dc; --res: #74838a;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --shadow: 0 6px 24px rgba(0, 0, 0, .45); color-scheme: dark; } }
:root[data-theme="dark"] {
  --bg: #0d1317; --surface: #141c21; --surface-2: #1b252b; --ink: #eaf1f4; --text: #d3dde1; --muted: #98a6ad;
  --faint: #6b7a81; --line: #27333a; --grid: #1e292f; --accent: #6eb0dc; --accent-soft: #19303f; --on-accent: #0d1317;
  --good: #4cbf6e; --warn: #e2a23c; --bad: #ef6b6b; --bench: #9ba8af; --sel: #6eb0dc; --res: #74838a;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --shadow: 0 6px 24px rgba(0, 0, 0, .45); color-scheme: dark; }

* { box-sizing: border-box; }
html, body { margin: 0; }
[hidden] { display: none !important; }
body { background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 14px; line-height: 1.45; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.pos { color: var(--good); } .neg { color: var(--bad); }

.wrap { max-width: 1240px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }

/* top bar */
.top { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top .wrap { display: flex; align-items: center; gap: 10px 20px; flex-wrap: wrap; padding-block: 10px; }
.brand { font-weight: 600; color: var(--ink); letter-spacing: .01em; display: flex; align-items: center; gap: 8px; }
.brand svg { flex: none; }
.acct { display: flex; align-items: center; gap: 8px; }
.acct select { background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; }
.badge { font-size: 11px; font-weight: 600; letter-spacing: .08em; padding: 2px 7px; border-radius: 4px; border: 1px solid var(--accent); color: var(--accent); }
nav.tabs { display: flex; gap: 2px; flex-wrap: wrap; }
nav.tabs a { padding: 6px 10px; border-radius: 6px; color: var(--muted); font-weight: 500; display: flex; align-items: center; gap: 6px; }
nav.tabs a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
nav.tabs a[aria-current="page"] { color: var(--ink); background: var(--accent-soft); }
nav.tabs a.disabled { color: var(--faint); pointer-events: none; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.dot.ok { background: var(--good); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); } .dot.off { background: var(--faint); }
.asof { margin-left: auto; color: var(--muted); font-size: 12.5px; display: flex; gap: 14px; align-items: center; }
.asof button { background: none; border: none; color: var(--muted); cursor: pointer; padding: 0; }

/* segmented control */
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 7px; padding: 2px; gap: 2px; }
.seg button { border: none; background: none; padding: 4px 10px; border-radius: 5px; cursor: pointer; color: var(--muted); font-size: 13px; white-space: nowrap; }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.12); font-weight: 500; }

main { padding-block: 18px 48px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
main > *, .split > *, .grid2 > * { min-width: 0; }
h1 { font-size: 20px; font-weight: 600; color: var(--ink); margin: 0; text-wrap: balance; }
h2 { font-size: 15px; font-weight: 600; color: var(--ink); margin: 0; }
.crumbs { font-size: 13px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; }
.head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; }
.sub { color: var(--muted); font-size: 13px; }

/* filter row */
.filters { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; }
.custom { display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); }
.custom input { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; }
.toggles { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 3px 10px 3px 8px; font-size: 12.5px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.chip[aria-pressed="true"] { color: var(--text); border-color: var(--faint); }
.chip .key { width: 14px; height: 0; border-top: 2px solid currentColor; }
.chip[aria-pressed="false"] .key { opacity: .35; }

/* stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.stat { background: var(--surface); padding: 12px 14px; display: grid; gap: 2px; }
.stat .l { font-size: 11.5px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.stat .v { font-size: 19px; font-weight: 500; color: var(--ink); font-variant-numeric: tabular-nums; }
.stat .n { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* chart card */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.card-h { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 12px; align-items: center; padding: 12px 14px 0; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.lk { width: 16px; height: 0; border-top: 2px solid; display: inline-block; }
.lk.dash { border-top-style: dashed; } .lk.dot2 { border-top-style: dotted; }
.chartwrap { position: relative; height: 340px; margin: 6px 4px 8px; touch-action: pan-y; user-select: none; }
.chartwrap.tall { height: 380px; }
.chart { position: absolute; inset: 0; }
.selline { position: absolute; top: 6px; bottom: 26px; width: 0; border-left: 1.5px solid var(--sel); pointer-events: none; z-index: 3; }
.selline::before { content: ""; position: absolute; top: -4px; left: -5px; width: 8px; height: 8px; border-radius: 50%; background: var(--sel); }
.brush { position: absolute; top: 6px; bottom: 26px; background: var(--accent); opacity: .12; pointer-events: none; z-index: 3; }
.hint { font-size: 12px; color: var(--faint); padding: 0 14px 10px; }
.tip { position: absolute; z-index: 4; pointer-events: none; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); padding: 8px 10px; font-size: 12.5px; min-width: 190px; }
.tip-d { color: var(--muted); font-size: 11.5px; margin-bottom: 4px; }
.tip-r { display: grid; grid-template-columns: 14px auto 1fr; gap: 0 8px; align-items: center; }
.tip-r b { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; text-align: right; }
.tip-r span:last-child { color: var(--muted); }
.tip-ev { margin-top: 5px; padding-top: 5px; border-top: 1px solid var(--line); color: var(--text); display: grid; gap: 2px; }
.tip-ev div { display: flex; gap: 6px; align-items: center; }

/* allocation */
.alloc { display: flex; height: 10px; gap: 2px; margin: 0 14px 14px; border-radius: 3px; overflow: hidden; }
.alloc div { min-width: 2px; }

/* tables */
.tbl-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th { text-align: left; font-weight: 500; font-size: 11.5px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 8px 12px; border-bottom: 1px solid var(--grid); white-space: nowrap; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: none; }
td.r, th.r { text-align: right; }
tr.closed td { color: var(--faint); }
tr.closed a { color: var(--faint); }
tbody tr:hover td { background: var(--surface-2); }
.pill { font-size: 11px; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); margin-left: 6px; }
.pill.warn { border-color: var(--warn); color: var(--warn); }
.pill.bad { border-color: var(--bad); color: var(--bad); }
.pill.good { border-color: var(--good); color: var(--good); }
.sw { width: 10px; height: 10px; border-radius: 2px; display: inline-block; margin-right: 8px; vertical-align: -1px; }
.linkbtn { background: none; border: none; padding: 0; color: var(--accent); cursor: pointer; }
.linkbtn:hover { text-decoration: underline; }
.cell-ck { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.cell-ck input { accent-color: var(--accent); margin: 0; }
.grouprow td { background: var(--surface-2); font-size: 11.5px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); padding: 5px 12px; }

/* detail layout */
.split { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; align-items: start; }
.split.has-pane { grid-template-columns: minmax(0, 1fr) 340px; }
.pane { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; position: sticky; top: 72px; max-height: calc(100vh - 90px); overflow: auto; }
.pane-h { display: flex; justify-content: space-between; align-items: start; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.pane-h .x { background: none; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; padding: 2px 8px; color: var(--muted); }
.pane-sec { padding: 10px 14px; border-bottom: 1px solid var(--line); }
.pane-sec:last-child { border-bottom: none; }
.pane-sec h3 { font-size: 11.5px; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0 0 6px; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; font-variant-numeric: tabular-nums; }
.kv span:nth-child(odd) { color: var(--muted); }
.pane table td, .pane table th { padding: 5px 6px; }
.pane-nav { display: flex; gap: 6px; }
.pane-nav button { background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px; cursor: pointer; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }

/* status */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.scard { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: grid; gap: 8px; }
.scard.warn { border-left: 3px solid var(--warn); } .scard.bad { border-left: 3px solid var(--bad); }
.scard-h { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--ink); min-width: 0; }
.scard-h span.nm { min-width: 0; }
td.nm { white-space: normal; min-width: 140px; }
td.det { white-space: normal; min-width: 240px; overflow-wrap: anywhere; color: var(--muted); }
span.tr { display: block; font-family: var(--sans); font-size: 11.5px; color: var(--muted); }

.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 10px 14px; font-size: 13px; color: var(--muted); }
.pager button, .btn { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; cursor: pointer; }
.pager button:disabled { opacity: .4; cursor: default; }
.empty { padding: 40px 14px; text-align: center; color: var(--muted); }

@media (max-width: 900px) {
  .split.has-pane { grid-template-columns: minmax(0, 1fr); }
  .pane { position: fixed; left: 0; right: 0; bottom: 0; top: auto; max-height: 62vh; border-radius: 14px 14px 0 0; z-index: 20; box-shadow: var(--shadow);
    padding-bottom: env(safe-area-inset-bottom, 0px); padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px); }
  .grid2 { grid-template-columns: minmax(0, 1fr); }
  .asof { margin-left: 0; width: 100%; }
}
@media (max-width: 560px) {
  .chartwrap, .chartwrap.tall { height: 280px; }
  .stat .v { font-size: 17px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding-inline: 16px; }
.login form { width: min(360px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 24px; display: grid; gap: 14px; box-shadow: var(--shadow); }
.login label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.login input { background: var(--bg); border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px; font-size: 15px; color: var(--text); }
.login button { background: var(--accent); color: var(--on-accent); border: none; border-radius: 7px; padding: 9px; font-weight: 600; cursor: pointer; }
.login .err { color: var(--bad); font-size: 13px; }
.loading { padding: 60px 0; text-align: center; color: var(--muted); }
.asof form { display: inline; }
