:root {
  color-scheme: dark;
  --bg: #0b0f15;
  --canvas: #0d1219;
  --panel: #131922;
  --panel-2: #19202b;
  --node: #161d28;
  --node-2: #1b2331;
  --border: #283142;
  --border-2: #344055;
  --text: #d6dde8;
  --muted: #8b95a7;
  --faint: #5c6678;
  --accent: #7aa2f7;
  --green: #3fb950;
  --yellow: #d29922;
  --orange: #f0883e;
  --red: #f85149;
  --purple: #bc8cff;
  --cyan: #39c5cf;
  --mono: ui-monospace, SFMono-Regular, "Cascadia Code", Menlo, Consolas, monospace;
  --side-w: 290px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
body { display: flex; flex-direction: column; overflow: hidden; }
button { font: inherit; color: inherit; }

/* Header */
.top {
  flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px;
  padding: 8px 16px; background: var(--panel); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; letter-spacing: 0.5px; color: var(--accent); }
.side-toggle {
  flex: none; margin-right: -10px; padding: 1px 8px; line-height: 1.4; background: transparent; color: var(--muted);
  border: 1px solid var(--border); border-radius: 6px; cursor: pointer;
}
.side-toggle:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }
.side-toggle:focus-visible { outline: 1px solid var(--accent); outline-offset: 1px; }
.side-toggle.on { color: var(--accent); border-color: rgba(122, 162, 247, 0.45); }
.summary { color: var(--muted); font-size: 13px; }
.controls { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 12.5px; }
.controls label { cursor: pointer; user-select: none; }
.controls input { accent-color: var(--accent); vertical-align: -2px; }
.conn { margin-left: auto; display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; }
.conn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.conn.ok .dot { background: var(--green); box-shadow: 0 0 6px rgba(63, 185, 80, 0.7); }
.conn.err .dot { background: var(--red); }

.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: var(--side-w) 1fr; }
body.side-hidden .layout { grid-template-columns: 1fr; }
body.side-hidden .side { display: none; }

/* Left panel: names only */
.side { min-height: 0; overflow: auto; scrollbar-width: thin; scrollbar-color: var(--border-2) transparent; background: var(--panel); border-right: 1px solid var(--border); padding: 6px 0 20px; }
.side-list { font-size: 13px; }
.row {
  display: flex; align-items: center; gap: 6px; height: 26px; padding-right: 10px; cursor: pointer;
  white-space: nowrap; border-left: 2px solid transparent; user-select: none;
}
.row:hover { background: rgba(255, 255, 255, 0.035); }
.row:focus-visible { outline: 1px solid var(--accent); outline-offset: -1px; }
.row.sel { background: rgba(122, 162, 247, 0.13); border-left-color: var(--accent); }
.row .caret { flex: none; width: 14px; text-align: center; color: var(--faint); font-size: 10px; }
.row .caret:hover { color: var(--text); }
.row .label { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.row.r-session { height: 30px; margin-top: 4px; }
.row.r-session .label { font-weight: 600; }
.row.r-proc .label { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.row.r-group .label, .row.r-more .label { color: var(--faint); font-size: 12px; }
.row.dim .label { color: var(--faint); }
.row.idle .label { color: var(--muted); }
.sd { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.sd.working { background: var(--green); box-shadow: 0 0 5px rgba(63, 185, 80, 0.65); }
.sd.tool { background: var(--accent); box-shadow: 0 0 5px rgba(122, 162, 247, 0.6); }
.sd.waiting { background: var(--purple); }
.sd.idle { background: #4b5465; }
.sd.finished { background: transparent; border: 1px solid var(--faint); }
.sd.unknown { background: transparent; border: 1px dashed var(--faint); }
.sd.proc { border-radius: 2px; width: 7px; height: 7px; background: var(--cyan); }
.sd.proc.hot { background: var(--orange); }
.sd.proc.loose { background: var(--yellow); }
.sd.proc.service { background: #4b5465; }
.sd.group { border-radius: 2px; background: transparent; border: 1px solid var(--faint); }
.side-empty { color: var(--faint); padding: 20px 16px; font-size: 13px; }

/* Right: graph view */
.detail { position: relative; min-width: 0; min-height: 0; background: var(--canvas); overflow: hidden; }
.canvas {
  position: absolute; inset: 0; overflow: hidden; cursor: grab; touch-action: none;
  background-image: radial-gradient(circle, rgba(139, 149, 167, 0.13) 1px, transparent 1.2px);
  background-size: 22px 22px;
}
.canvas.panning { cursor: grabbing; }
.world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.edges { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.nodes { position: absolute; left: 0; top: 0; }
.placeholder { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--faint); pointer-events: none; padding: 20px; text-align: center; }
.placeholder[hidden] { display: none; }

.edge { fill: none; stroke: var(--border-2); stroke-width: 1.6; }
.edge.working { stroke: rgba(63, 185, 80, 0.55); }
.edge.tool { stroke: rgba(122, 162, 247, 0.55); }
.edge.waiting { stroke: rgba(188, 140, 255, 0.5); }
.edge.finished { stroke: #2a3242; stroke-dasharray: 4 4; }
.edge.proc { stroke: rgba(57, 197, 207, 0.38); }
.edge.loose { stroke: rgba(210, 153, 34, 0.45); }
.edge.service { stroke: #2f3848; }
.edge.flow { stroke-dasharray: 6 6; animation: flow 1.1s linear infinite; }
.edge.on { stroke-width: 2.4; }
@keyframes flow { to { stroke-dashoffset: -12; } }
@media (prefers-reduced-motion: reduce) { .edge.flow { animation: none; } }

.node {
  position: absolute; left: 0; top: 0; overflow: hidden; cursor: pointer;
  background: var(--node); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35); padding: 8px 10px 8px 14px; font-size: 12.5px;
  transition: border-color 0.15s, box-shadow 0.15s, opacity 0.3s;
}
.node::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--faint); }
.node:hover { border-color: var(--border-2); }
.node.sel { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(122, 162, 247, 0.35), 0 4px 18px rgba(0, 0, 0, 0.5); }
.node.enter { opacity: 0; }
.node .l { display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; min-width: 0; }
.node .l + .l { margin-top: 3px; }
.node .t { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.node .name { font-weight: 650; font-size: 13.5px; }
.node .sub { color: var(--muted); }
.node .mono { font-family: var(--mono); font-size: 11.5px; }
.node .stats { color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.node .act { color: var(--muted); }
.node .act .tn { color: var(--accent); font-family: var(--mono); font-size: 11.5px; flex: none; }

.n-session { background: var(--node-2); border-color: var(--border-2); }
.n-session::before { background: var(--accent); }
.n-session.idle::before { background: #4b5465; }
.n-session .name { font-size: 14.5px; }
.n-agent.working::before { background: var(--green); }
.n-agent.tool::before { background: var(--accent); }
.n-agent.waiting::before { background: var(--purple); }
.n-agent.idle::before { background: #4b5465; }
.n-agent.finished { opacity: 0.62; }
.n-agent.finished::before { background: #2a3242; }
.n-agent.working { border-color: rgba(63, 185, 80, 0.35); }
.n-agent.tool { border-color: rgba(122, 162, 247, 0.35); }
.n-agent.waiting { border-color: rgba(188, 140, 255, 0.3); }
.n-proc { border-radius: 8px; padding-top: 6px; padding-bottom: 6px; }
.n-proc::before { background: var(--cyan); }
.n-proc.loose::before { background: var(--yellow); }
.n-proc.service::before { background: #4b5465; }
.n-proc.service .cmd { color: var(--muted); }
.n-proc .cmd { font-family: var(--mono); font-size: 11.5px; }
.n-proc .k { color: var(--faint); font-family: var(--mono); font-size: 11px; flex: none; }
.n-proc .cpubar { position: absolute; left: 4px; right: 0; bottom: 0; height: 2px; background: transparent; }
.n-proc .cpubar i { display: block; height: 100%; background: var(--cyan); opacity: 0.8; }
.n-proc .cpubar i.hot { background: var(--orange); }
.n-group, .n-more {
  display: flex; align-items: center; border-style: dashed; background: transparent; box-shadow: none;
  color: var(--muted); padding: 0 12px 0 14px; font-size: 12px;
}
.n-group::before, .n-more::before { background: transparent; }
.n-group .t, .n-more .t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.n-group.loose { border-color: rgba(210, 153, 34, 0.5); color: var(--yellow); }
.n-more:hover, .n-group:hover { color: var(--text); }

.badge { display: inline-block; padding: 0 7px; border-radius: 999px; font-size: 11px; font-weight: 600; border: 1px solid transparent; white-space: nowrap; flex: none; }
.b-busy, .b-working { background: rgba(63, 185, 80, 0.15); color: var(--green); border-color: rgba(63, 185, 80, 0.35); }
.b-tool { background: rgba(122, 162, 247, 0.15); color: var(--accent); border-color: rgba(122, 162, 247, 0.35); }
.b-waiting { background: rgba(188, 140, 255, 0.14); color: var(--purple); border-color: rgba(188, 140, 255, 0.35); }
.b-idle { background: rgba(139, 149, 167, 0.12); color: var(--muted); border-color: var(--border); }
.b-finished, .b-unknown { background: transparent; color: var(--faint); border-color: var(--border); }
.chip { display: inline-block; padding: 0 6px; border-radius: 4px; font-size: 11px; font-family: var(--mono); background: #232b3a; color: var(--text); white-space: nowrap; flex: none; }
.chip.model-opus { color: var(--orange); }
.chip.model-sonnet { color: var(--cyan); }
.chip.model-haiku { color: var(--green); }
.chip.model-fable { color: #9085e9; }
.chip.effort { color: var(--yellow); }
.chip.dim { color: var(--muted); }
.hot { color: var(--orange); }

/* Toolbar, info panel, legend (overlays on the canvas) */
.toolbar {
  position: absolute; left: 12px; right: 12px; top: 10px; display: flex; align-items: flex-start; gap: 10px;
  pointer-events: none;
}
.crumbs, .zoom { pointer-events: auto; background: rgba(19, 25, 34, 0.92); border: 1px solid var(--border); border-radius: 8px; }
.crumbs { padding: 4px 10px; font-size: 12.5px; color: var(--muted); max-width: calc(100% - 820px); min-width: 120px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumbs:empty { display: none; }
.crumbs b { color: var(--text); font-weight: 600; }
.crumbs a { color: var(--muted); cursor: pointer; text-decoration: none; }
.crumbs a:hover { color: var(--text); }
.zoom { display: flex; align-items: center; gap: 2px; padding: 2px; font-size: 12px; }
.zoom button { background: transparent; border: 0; border-radius: 6px; padding: 3px 9px; cursor: pointer; color: var(--muted); }
.zoom button:hover { background: rgba(255, 255, 255, 0.06); color: var(--text); }
.zoom span { color: var(--faint); min-width: 46px; text-align: center; font-variant-numeric: tabular-nums; }
.zoom label.auto {
  display: inline-flex; align-items: center; gap: 3px; margin: 0 4px 0 -4px; padding: 2px 6px 2px 3px; border-radius: 6px;
  color: var(--faint); cursor: pointer; user-select: none; font-size: 11.5px;
}
.zoom label.auto:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }
.zoom label.auto.on { color: var(--accent); }
.zoom label.auto input { margin: 0; accent-color: var(--accent); }
.zoom label.auto.flash { animation: auto-flash 1.5s ease-out; }
@keyframes auto-flash { 0%, 40% { background: rgba(210, 153, 34, 0.28); color: var(--yellow); } 100% { background: transparent; } }
@media (prefers-reduced-motion: reduce) { .zoom label.auto.flash { animation: none; outline: 1px solid var(--yellow); } }

.info {
  position: absolute; top: 10px; right: 12px; width: 340px; max-height: calc(100% - 60px); display: flex; flex-direction: column;
  background: rgba(19, 25, 34, 0.96); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
}
.info[hidden] { display: none; }
.info-head { display: flex; align-items: center; justify-content: space-between; padding: 7px 10px 7px 12px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 13px; }
.info-head span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.info-head button { background: transparent; border: 0; color: var(--muted); cursor: pointer; padding: 0 4px; }
.info.collapsed .info-body { display: none; }
.info.collapsed .info-head { border-bottom: 0; }
.info-body { overflow: auto; scrollbar-width: thin; scrollbar-color: var(--border-2) transparent; padding: 8px 12px 12px; font-size: 12.5px; }
.info dl { display: grid; grid-template-columns: max-content 1fr; gap: 3px 12px; margin: 0; }
.info dt { color: var(--faint); }
.info dd { margin: 0; min-width: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.info h4 { margin: 12px 0 5px; font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.info pre { margin: 0; padding: 6px 8px; background: #0e131b; border: 1px solid var(--border); border-radius: 6px; font-family: var(--mono); font-size: 11.5px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 180px; overflow: auto; }
.info .tl { margin: 0; padding: 0; list-style: none; }
.info .tl li { padding: 3px 0; border-top: 1px solid rgba(255, 255, 255, 0.04); }
.info .tl li:first-child { border-top: 0; }
.info .tn { color: var(--accent); font-family: var(--mono); font-size: 11.5px; }
.info .note { color: var(--yellow); font-size: 12px; margin-bottom: 8px; }
.info .muted { color: var(--faint); }

.legend {
  position: absolute; left: 12px; bottom: 10px; display: flex; flex-wrap: wrap; gap: 4px 12px; max-width: calc(100% - 24px);
  padding: 4px 10px; font-size: 11.5px; color: var(--muted); background: rgba(19, 25, 34, 0.85); border: 1px solid var(--border); border-radius: 8px;
  pointer-events: none;
}
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.lg { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--faint); }
.lg.working { background: var(--green); }
.lg.tool { background: var(--accent); }
.lg.waiting { background: var(--purple); }
.lg.idle { background: #4b5465; }
.lg.finished { background: transparent; border: 1px dashed var(--faint); }
.lg.proc { background: var(--cyan); }
.lg.loose { background: var(--yellow); }

.foot { flex: none; color: var(--faint); font-size: 11.5px; padding: 3px 16px; border-top: 1px solid var(--border); background: var(--panel); text-align: right; }

@media (max-width: 1100px) {
  .crumbs { max-width: calc(100% - 440px); }
  .info { top: 52px; width: 300px; }
}
@media (max-width: 760px) {
  body { overflow: auto; }
  .layout { grid-template-columns: 1fr; grid-template-rows: minmax(120px, 38vh) minmax(420px, 1fr); }
  body.side-hidden .layout { grid-template-rows: minmax(420px, 1fr); }
  .side { border-right: 0; border-bottom: 1px solid var(--border); }
  .info { left: 12px; right: 12px; width: auto; max-height: 45%; }
  .legend { display: none; }
  .controls { font-size: 12px; }
}

/* ---------- Usage (API-equivalent estimate) ---------- */
/* Model families: fixed categorical order, validated on the dark canvas (dataviz validator, all checks pass). */
:root {
  --fam-opus: #d95926;
  --fam-sonnet: #199e70;
  --fam-haiku: #c98500;
  --fam-fable: #9085e9;
  --fam-mythos: #d55181;
  --fam-other: #6b7385;
  --lv-good: #0ca30c;
  --lv-warning: #fab219;
  --lv-critical: #d03b3b;
}
.fam-opus { fill: var(--fam-opus); background: var(--fam-opus); }
.fam-sonnet { fill: var(--fam-sonnet); background: var(--fam-sonnet); }
.fam-haiku { fill: var(--fam-haiku); background: var(--fam-haiku); }
.fam-fable { fill: var(--fam-fable); background: var(--fam-fable); }
.fam-mythos { fill: var(--fam-mythos); background: var(--fam-mythos); }
.fam-other { fill: var(--fam-other); background: var(--fam-other); }

.usage-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--border); color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums;
}
.usage-pill:hover, .usage-pill.on { color: var(--text); border-color: var(--accent); }
.usage-pill[hidden] { display: none; }
.sd.lv-good { background: var(--lv-good); }
.sd.lv-warning { background: var(--lv-warning); }
.sd.lv-critical { background: var(--lv-critical); }

.node .usd { color: var(--text); }
.node .warn, .info .warn, .usage .warn { color: var(--yellow); }
.sharebar { position: absolute; left: 4px; right: 0; bottom: 0; height: 3px; background: rgba(255, 255, 255, 0.04); }
.sharebar i { display: block; height: 100%; background: var(--accent); opacity: 0.75; }
.sharebar.inline { position: relative; left: auto; display: inline-block; width: 70px; height: 5px; border-radius: 3px; overflow: hidden; vertical-align: 1px; margin-right: 6px; }
.info .tl .bar-row { display: flex; gap: 8px; justify-content: space-between; }
.info .tl .bar-row .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.info .tl .bar-row .v { flex: none; font-variant-numeric: tabular-nums; color: var(--muted); }
.info .tl .sharebar.inline { width: 100%; margin: 3px 0 0; display: block; }

.usage {
  position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; background: var(--canvas);
}
.usage[hidden] { display: none; }
.usage-head { display: flex; align-items: center; gap: 14px; padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--panel); }
.usage-head h2 { margin: 0; font-size: 15px; font-weight: 650; }
.usage-head .est { font-weight: 400; color: var(--yellow); font-size: 12px; margin-left: 6px; }
.usage-head .close { margin-left: auto; background: transparent; border: 0; color: var(--muted); cursor: pointer; font-size: 15px; }
.usage-head .close:hover { color: var(--text); }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 7px; overflow: hidden; }
.seg button { background: transparent; border: 0; padding: 3px 12px; cursor: pointer; color: var(--muted); font-size: 12.5px; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button.on { background: rgba(122, 162, 247, 0.18); color: var(--text); }
.usage-body { flex: 1; overflow: auto; padding: 14px 16px 24px; font-size: 13px; scrollbar-width: thin; scrollbar-color: var(--border-2) transparent; }
.usage .muted { color: var(--faint); }
.usage .mono { font-family: var(--mono); font-size: 12px; }
.u-plan { color: var(--muted); margin-bottom: 10px; display: grid; gap: 3px; }
.u-plan b, .u-total b { color: var(--text); }
.u-limits { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; margin-bottom: 16px; }
.u-card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.u-card-head { display: flex; justify-content: space-between; align-items: baseline; font-weight: 600; margin-bottom: 6px; }
.u-card-head .big { font-size: 18px; font-variant-numeric: tabular-nums; }
.lvt { font-size: 11.5px; font-weight: 600; margin-left: 6px; }
.lvt.warning { color: var(--lv-warning); }
.lvt.critical { color: #f07575; }
.gauge { position: relative; height: 8px; border-radius: 4px; background: #1f2735; margin: 4px 0 8px; }
.gauge i { display: block; height: 100%; border-radius: 4px; background: var(--lv-good); }
.gauge.lv-warning i { background: var(--lv-warning); }
.gauge.lv-critical i { background: var(--lv-critical); }
.gauge .tick { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: var(--text); border-radius: 1px; }
.u-lines { display: grid; gap: 2px; color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.u-lines b { color: var(--text); }
.calib { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; font-size: 12.5px; color: var(--muted); }
.calib input { width: 78px; background: #0e131b; border: 1px solid var(--border-2); border-radius: 5px; color: var(--text); padding: 2px 6px; font: inherit; }
.calib button { background: var(--panel-2); border: 1px solid var(--border-2); border-radius: 5px; color: var(--text); padding: 2px 9px; cursor: pointer; font-size: 12px; }
.calib button:hover { border-color: var(--accent); }
.calib button[data-clear] { color: var(--muted); }
.u-msg { margin-top: 6px; font-size: 12px; }
.u-msg.ok { color: var(--green); }
.u-msg.err { color: var(--yellow); }
.u-chart { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px 6px; margin-bottom: 16px; }
.u-chart-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 14px; color: var(--muted); font-size: 12.5px; margin-bottom: 4px; }
.u-legend { display: flex; gap: 12px; }
.u-legend span, .u-tip div { display: inline-flex; align-items: center; gap: 5px; }
.u-legend i, .u-tip i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.u-plot { position: relative; }
.u-plot svg { display: block; }
.u-plot .grid { stroke: #222a38; stroke-width: 1; }
.u-plot .base { stroke: var(--border-2); stroke-width: 1; }
.u-plot .xt { stroke: var(--border-2); }
.u-plot .ax { fill: var(--faint); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.u-plot .hit { fill: transparent; }
.u-plot .hit:hover { fill: rgba(255, 255, 255, 0.05); }
.u-tip {
  position: absolute; pointer-events: none; min-width: 150px; padding: 6px 9px; display: grid; gap: 2px;
  background: rgba(19, 25, 34, 0.97); border: 1px solid var(--border-2); border-radius: 7px; font-size: 12px; font-variant-numeric: tabular-nums;
}
.u-tip[hidden] { display: none; }
.u-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.u-tablewrap { overflow-x: auto; }
.u-chart { overflow: hidden; }
.u-table { width: 100%; border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.u-table th { text-align: left; color: var(--faint); font-weight: 600; font-size: 11.5px; padding: 4px 8px; border-bottom: 1px solid var(--border); }
.u-table td { padding: 5px 8px; border-bottom: 1px solid rgba(255, 255, 255, 0.04); vertical-align: middle; white-space: nowrap; }
.u-table .n { text-align: right; }
.u-table tr.u-s { cursor: pointer; }
.u-table tr.u-s:hover { background: rgba(255, 255, 255, 0.03); }
.u-table tr.u-s td:first-child { max-width: 420px; overflow: hidden; text-overflow: ellipsis; }
.u-table .caret { display: inline-block; width: 14px; color: var(--faint); font-size: 10px; }
.u-table .nm { font-weight: 600; }
.u-table .sub { color: var(--faint); margin-left: 8px; font-style: italic; }
.u-table tr.u-a td:first-child { padding-left: 30px; max-width: 420px; overflow: hidden; text-overflow: ellipsis; }
.u-table tr.u-a .nm { font-weight: 400; color: var(--muted); margin-right: 6px; }
.u-table tr.u-a td { color: var(--muted); }
.u-table a.live { color: var(--green); cursor: pointer; font-size: 11.5px; margin-left: 6px; }
.u-table a.live:hover { text-decoration: underline; }
.u-foot { margin-top: 14px; color: var(--faint); font-size: 11.5px; display: grid; gap: 3px; }
@media (max-width: 760px) {
  .u-limits { grid-template-columns: 1fr; }
  .u-table th:nth-child(5), .u-table td:nth-child(5), .u-table th:nth-child(6), .u-table td:nth-child(6) { display: none; }
}

/* "All" view: one framed block per session, stacked in the same canvas */
.row.r-all { height: 30px; margin: 2px 0 6px; border-bottom: 1px solid var(--border); }
.row.r-all .label { font-weight: 700; color: var(--accent); }
.row.r-all .cnt { margin-left: auto; color: var(--faint); font-size: 11.5px; }
.row.r-all.on:not(.sel) { border-left-color: rgba(122, 162, 247, 0.45); background: rgba(122, 162, 247, 0.05); }
.sd.all { border-radius: 2px; background: transparent; border: 1.5px solid var(--accent); box-shadow: 2px 2px 0 -0.5px rgba(122, 162, 247, 0.5); }
.frames { position: absolute; left: 0; top: 0; }
.frame {
  position: absolute; left: 0; top: 0; border: 1px solid var(--border); border-radius: 14px;
  background: rgba(19, 25, 34, 0.55); transition: border-color 0.15s, opacity 0.3s;
}
.frame.enter { opacity: 0; }
.frame.working { border-color: rgba(63, 185, 80, 0.28); }
.frame.sel { border-color: rgba(122, 162, 247, 0.55); }
.frame-head {
  height: 46px; padding: 6px 14px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.045); cursor: pointer;
  border-radius: 14px 14px 0 0; overflow: hidden;
}
.frame-head:hover { background: rgba(255, 255, 255, 0.025); }
.fh-l { display: flex; align-items: center; gap: 8px; white-space: nowrap; overflow: hidden; min-width: 0; font-size: 12.5px; }
.fh-name { font-weight: 700; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.fh-usage { margin-left: auto; flex: none; color: var(--text); font-variant-numeric: tabular-nums; }
.fh-sub { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.fh-sub .mono { font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.fh-sub > span:last-child { flex: none; }
.chip.shared { font-family: inherit; color: var(--yellow); background: rgba(210, 153, 34, 0.12); border: 1px solid rgba(210, 153, 34, 0.35); }
.n-session.shared { border-style: dashed; }
.info .all-list li { cursor: pointer; }
.info .all-list li:hover { background: rgba(255, 255, 255, 0.03); }
.info .all-list .sd { display: inline-block; margin-right: 6px; vertical-align: 0; }
.info a[data-goto] { color: var(--accent); cursor: pointer; }

/* ---------- Stats page: cost per session over a time range ---------- */
/* Agent groups: fixed categorical order main, general-purpose, workflow, fork, Explore, other types.
   Validated on the dark surface #131922 with the dataviz validator (adjacent CVD ΔE ≥ 8.4, all checks pass). */
:root {
  --grp-main: #3987e5;
  --grp-general-purpose: #d95926;
  --grp-workflow-subagent: #199e70;
  --grp-fork: #c98500;
  --grp-Explore: #d55181;
  --grp-other: #9085e9;
}
.grp-main { fill: var(--grp-main); background: var(--grp-main); }
.grp-general-purpose { fill: var(--grp-general-purpose); background: var(--grp-general-purpose); }
.grp-workflow-subagent { fill: var(--grp-workflow-subagent); background: var(--grp-workflow-subagent); }
.grp-fork { fill: var(--grp-fork); background: var(--grp-fork); }
.grp-Explore { fill: var(--grp-Explore); background: var(--grp-Explore); }
.grp-other { fill: var(--grp-other); background: var(--grp-other); }

.row.r-stats { height: 30px; margin: 0 0 6px; border-bottom: 1px solid var(--border); }
.row.r-stats .label { font-weight: 700; color: var(--accent); }
.row.r-stats .cnt { margin-left: auto; color: var(--faint); font-size: 11.5px; }
.sd.stats { border-radius: 1px; background: linear-gradient(to top, var(--accent) 0 45%, transparent 45% 60%, var(--accent) 60% 100%); width: 8px; }

.statspage { position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; background: var(--canvas); }
.statspage[hidden] { display: none; }
.st-filters {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; padding: 8px 16px;
  border-bottom: 1px solid var(--border); background: var(--panel); font-size: 12.5px; color: var(--muted);
}
.st-filters .seg button { white-space: nowrap; }
.st-sep { flex: 1; }
.st-lab { color: var(--faint); }
.st-custom { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.st-custom[hidden] { display: none; }
.st-custom input { background: #0e131b; border: 1px solid var(--border-2); border-radius: 5px; color: var(--text); padding: 1px 6px; font: inherit; color-scheme: dark; }
.st-custom button { background: var(--panel-2); border: 1px solid var(--border-2); border-radius: 5px; color: var(--text); padding: 2px 10px; cursor: pointer; }
.st-custom button:hover { border-color: var(--accent); }
.st-body { flex: 1; overflow: auto; padding: 12px 16px 24px; font-size: 13px; scrollbar-width: thin; scrollbar-color: var(--border-2) transparent; transition: opacity 0.15s; }
.st-body.loading { opacity: 0.55; }
.statspage .muted { color: var(--faint); }
.statspage .warn { color: var(--yellow); }
.statspage .mono { font-family: var(--mono); font-size: 12px; }
.st-range { color: var(--muted); margin-bottom: 10px; display: grid; gap: 2px; font-variant-numeric: tabular-nums; }
.st-range b { color: var(--text); }
.st-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 12px; }
.st-tile { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; min-width: 0; }
.st-tile.st-week { grid-column: span 2; }
.st-tl { color: var(--muted); font-size: 12px; }
.st-tv { font-size: 21px; font-weight: 600; color: var(--text); white-space: nowrap; }
.st-ts { color: var(--faint); font-size: 11.5px; overflow-wrap: anywhere; }
.st-tile .gauge { margin: 4px 0 4px; }
.st-main { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 390px; gap: 12px; align-items: start; }
.st-chart { margin-bottom: 0; min-width: 0; }
.st-empty { padding: 30px 0; text-align: center; }
.st-detail {
  position: sticky; top: 0; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
  font-size: 12.5px; max-height: calc(100vh - 140px); overflow: auto; overflow-x: hidden; scrollbar-width: thin; scrollbar-color: var(--border-2) transparent;
}
.st-detail dl { display: grid; grid-template-columns: max-content 1fr; gap: 3px 12px; margin: 8px 0 0; }
.st-detail dt { color: var(--faint); }
.st-detail dd { margin: 0; min-width: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.st-detail h4 { margin: 12px 0 6px; font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.st-detail a.live { color: var(--green); cursor: pointer; font-size: 12px; }
.st-detail a.live:hover { text-decoration: underline; }
.sdt-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sdt-name { font-weight: 700; font-size: 14.5px; overflow-wrap: anywhere; }
.sdt-sub { color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sdt-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.sdt-table td { padding: 3px 4px; border-top: 1px solid rgba(255, 255, 255, 0.04); white-space: nowrap; }
.sdt-table tr:first-child td { border-top: 0; }
.sdt-table .n { text-align: right; color: var(--muted); }
.sdt-table td.ag { max-width: 0; width: 100%; overflow: hidden; text-overflow: ellipsis; }
.sdt-table .sub { color: var(--faint); margin-left: 6px; font-size: 11.5px; }
.sdt-table .share .sharebar.inline { width: 40px; }
.sw { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.thin { display: flex; gap: 2px; height: 8px; border-radius: 4px; overflow: hidden; margin: 2px 0 6px; }
.thin i { display: block; min-width: 1px; height: 100%; flex-basis: 0; }

/* Horizontal stacked bars: label column (HTML, truncates) + one SVG per row; rows abut so gridlines read continuous. */
.hb { margin-top: 4px; }
.hb-axis, .hb-row { display: grid; align-items: center; }
.hb-axis svg { display: block; }
.hb-row { height: 30px; cursor: pointer; border-radius: 6px; }
.hb-row svg { display: block; overflow: visible; }
.hb-row:hover { background: rgba(255, 255, 255, 0.03); }
.hb-row.sel { background: rgba(122, 162, 247, 0.12); box-shadow: inset 2px 0 0 var(--accent); }
.hb-row:focus-visible { outline: 1px solid var(--accent); outline-offset: -1px; }
.hb-label { display: flex; align-items: baseline; gap: 6px; padding: 0 10px 0 6px; min-width: 0; white-space: nowrap; overflow: hidden; }
.hb-label .sd { align-self: center; }
.hb-label .nm { font-weight: 600; overflow: hidden; text-overflow: ellipsis; flex: 0 0 auto; max-width: 100%; }
.hb-label .sd + .nm { max-width: calc(100% - 14px); }
.hb-label .pj { color: var(--faint); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 0 1 auto; }
.hb .grid { stroke: #222a38; stroke-width: 1; }
.hb .ax { fill: var(--faint); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.hb .val { fill: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.hb-row.sel .val, .hb-row:hover .val { fill: var(--text); }
.hb .mk { transition: filter 0.1s; }
.hb .mk.on { filter: brightness(1.3); }
.st-more { margin-top: 8px; background: transparent; border: 1px dashed var(--border-2); border-radius: 6px; color: var(--muted); padding: 3px 12px; cursor: pointer; font-size: 12px; }
.st-more:hover { color: var(--text); border-color: var(--accent); }
.st-tip { z-index: 2; min-width: 190px; }
.st-tip .tr { display: flex; align-items: center; gap: 6px; }
.st-tip .tr.on { background: rgba(255, 255, 255, 0.06); border-radius: 4px; }
.st-tip .lk { display: inline-block; width: 12px; height: 2px; border-radius: 1px; }
.st-table tr.st-tr { cursor: pointer; }
.st-table tr.st-tr:hover { background: rgba(255, 255, 255, 0.03); }
.st-table tr.st-tr.sel { background: rgba(122, 162, 247, 0.12); }
.st-table .nm { font-weight: 600; }
.st-table th { white-space: nowrap; }
.st-table th, .st-table td { padding-left: 6px; padding-right: 6px; }
.st-table td:first-child { max-width: 300px; overflow: hidden; text-overflow: ellipsis; }
.st-table .sw { margin-right: 4px; }
.sd.inl { display: inline-block; vertical-align: 0; }
@media (max-width: 1100px) {
  .st-main { grid-template-columns: 1fr; }
  .st-detail { position: static; max-height: none; }
}
@media (max-width: 760px) {
  .st-tile.st-week { grid-column: auto; }
  .st-sep { display: none; }
  .st-table th:nth-child(n+4), .st-table td:nth-child(n+4) { display: none; }
}

/* Next API call (nc-): price with the cache state of this second, countdown, /clear hint. */
.nc-line .k { color: var(--faint); font-size: 11px; flex: none; }
.nc.warm, .cd.warm { color: #7ee29a; }
.nc.cold, .cd.cold { color: var(--orange); }
.chip.nc-clear { font-family: inherit; color: var(--yellow); background: rgba(210, 153, 34, 0.12); border: 1px solid rgba(210, 153, 34, 0.35); }
.chip.wf { color: var(--purple); }
.info .nc-cur { font-weight: 650; color: var(--text); }
.info .nc-clear-v { color: var(--yellow); font-weight: 650; }
.info .nc-note { font-size: 11.5px; margin-top: 4px; }

/* V2 hub: machines, account header, scope selectors, login and account pages */
.row.r-machine { height: 28px; margin-top: 4px; }
.row.r-machine .label { font-weight: 650; }
.row.r-machine .cnt { margin-left: auto; color: var(--faint); font-size: 11.5px; white-space: nowrap; padding-left: 6px; }
.row.r-machine.offline .label { color: var(--muted); }
.row.r-machine.on:not(.sel) { border-left-color: rgba(122, 162, 247, 0.45); background: rgba(122, 162, 247, 0.05); }
.sd.mach { border-radius: 2px; width: 9px; height: 7px; }
.sd.offline { background: transparent; border: 1px solid var(--red); }
.sd.mach.idle { background: #4b5465; }
.chip.mach { font-family: inherit; color: var(--cyan); background: rgba(57, 197, 207, 0.1); border: 1px solid rgba(57, 197, 207, 0.3); margin-right: 4px; }
.side-empty a { color: var(--accent); }
.side-empty code { font-family: var(--mono); font-size: 12px; }
.acct { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--muted); }
.acct[hidden] { display: none; }
.acct-name { color: var(--text); }
.acct a { color: var(--accent); text-decoration: none; }
.acct a:hover { text-decoration: underline; }
.acct button { background: transparent; border: 1px solid var(--border); border-radius: 6px; padding: 1px 8px; color: var(--muted); cursor: pointer; }
.acct button:hover { color: var(--text); border-color: var(--border-2); }
.mach-sel { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 7px; padding: 3px 8px; font: inherit; font-size: 12.5px; }
.mach-sel[hidden] { display: none; }

.ac-page { overflow: auto; }
.ac-wrap { max-width: 860px; margin: 0 auto; padding: 24px 16px 48px; }
.ac-card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 18px 20px; margin-bottom: 18px; }
.ac-card h2 { margin: 0 0 12px; font-size: 16px; }
.ac-card p { color: var(--muted); margin: 6px 0 12px; }
.ac-card code, .ac-key { font-family: var(--mono); font-size: 12.5px; }
.ac-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.ac-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); }
.ac-form input { background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 7px; padding: 6px 9px; font: inherit; min-width: 220px; }
.ac-form input:focus { outline: 2px solid rgba(122, 162, 247, 0.5); border-color: var(--accent); }
.ac-btn { background: rgba(122, 162, 247, 0.18); border: 1px solid var(--accent); color: var(--text); border-radius: 7px; padding: 6px 14px; cursor: pointer; }
.ac-btn:hover { background: rgba(122, 162, 247, 0.28); }
.ac-btn.danger { background: transparent; border-color: rgba(248, 81, 73, 0.6); color: #ffb3ad; padding: 2px 10px; }
.ac-btn.danger:hover { background: rgba(248, 81, 73, 0.12); }
.ac-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ac-table th, .ac-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.ac-table th { color: var(--muted); font-weight: 500; font-size: 12px; }
.ac-table td.r { text-align: right; }
.ac-msg { margin-top: 10px; font-size: 13px; min-height: 1em; }
.ac-msg.err { color: #ffb3ad; }
.ac-msg.ok { color: var(--green); }
.ac-new { margin-top: 12px; padding: 12px; border: 1px solid rgba(210, 153, 34, 0.5); background: rgba(210, 153, 34, 0.08); border-radius: 8px; }
.ac-new .ac-key { display: block; margin: 8px 0; padding: 8px; background: var(--bg); border-radius: 6px; word-break: break-all; user-select: all; }
.ac-top { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.ac-top a { color: var(--accent); text-decoration: none; }
.ac-login { max-width: 380px; margin: 10vh auto 0; }
.ac-login .ac-form { flex-direction: column; align-items: stretch; }
.ac-login .ac-form input { min-width: 0; }
@media (max-width: 600px) { .acct { width: 100%; justify-content: flex-end; } .ac-form input { min-width: 0; width: 100%; } .ac-form label { width: 100%; } }
.ac-page .muted { color: var(--faint); }
.ac-page .mono { font-family: var(--mono); font-size: 12px; }
.info code { font-family: var(--mono); font-size: 12px; }
.ac-page [hidden] { display: none !important; }
