/* admin.css: the admin tools on the Deep Ink kit (Database, AI Logic, Drawing Board) and
   the askText prompt. Only admins see these screens, but they are built like the rest of
   the product: kit.css classes carry type, buttons, fields and menus; the svx-* classes
   here only place them. Each screen's position stays in styles.css and its layer
   (z-index) in the full-screen layer rule in dialogs.css. */

/* ---------- screen frame: top bar, rail, main ---------- */
#db-screen, #ailogic-screen, #board-screen, #costs-screen {
  color: var(--sv-text); font-family: var(--sv-font-body); -webkit-font-smoothing: antialiased;
  background: var(--sv-bg) radial-gradient(ellipse 90% 70% at 50% -10%, var(--sv-violet-ground), var(--sv-bg) 70%) no-repeat;
}
.svx-app { position: absolute; inset: 0; display: grid; grid-template-columns: 264px minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr); }
.svx-top { grid-column: 1 / -1; display: flex; align-items: center; gap: var(--sv-space-3); min-width: 0;
  min-height: calc(var(--sv-topbar-h) + env(safe-area-inset-top)); padding: env(safe-area-inset-top) var(--sv-space-5) 0;
  border-bottom: 1px solid var(--sv-line); background: rgba(var(--sv-ground-rgb), .55); }
.svx-title { margin-left: var(--sv-space-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.svx-badge { flex: none; }
.svx-act { flex: none; }

.svx-rail { display: flex; flex-direction: column; gap: var(--sv-space-1); min-height: 0; overflow-y: auto; scrollbar-width: none;
  padding: var(--sv-space-4) var(--sv-space-3); border-right: 1px solid var(--sv-line); background: rgba(var(--sv-ground-rgb), .35); }
.svx-rail::-webkit-scrollbar { display: none; }
.svx-rail__label { padding: var(--sv-space-1) var(--sv-space-3) var(--sv-space-2); }
.svx-rail__list { display: flex; flex-direction: column; gap: 2px; }
.svx-rail__new { margin-bottom: var(--sv-space-3); flex: none; }
.svx-rail__note { margin: auto 0 0; padding: var(--sv-space-3) var(--sv-space-3) 0; border-top: 1px solid var(--sv-line); line-height: 1.45; }
/* rail rows: the kit menu row; the open one carries a 2 px rule on its left edge */
.svx-rail .sv-menu__item, #dbs-tables .dbs-tbl { position: relative; flex: none; }
.svx-rail .sv-menu__item.act, .svx-rail .sv-menu__item.on, #dbs-tables .dbs-tbl.act { color: var(--sv-violet-bright); background: rgba(var(--sv-glow-rgb), .06); }
.svx-rail .sv-menu__item.act::before, .svx-rail .sv-menu__item.on::before, #dbs-tables .dbs-tbl.act::before {
  content: ""; position: absolute; left: 0; top: var(--sv-space-2); bottom: var(--sv-space-2); width: 2px; background: var(--sv-violet); }
.svx-rail .sv-menu__item .sv-icon { color: var(--sv-text-dim); transition: color var(--sv-t1) var(--sv-ease); }
.svx-rail .sv-menu__item:hover .sv-icon, .svx-rail .sv-menu__item.act .sv-icon { color: var(--sv-violet-bright); }
.svx-count { margin-left: auto; color: var(--sv-text-dim); }

.svx-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; }
.svx-head { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sv-space-2) var(--sv-space-3); padding: var(--sv-space-5) var(--sv-space-5) var(--sv-space-4); }
.svx-head--stack { flex-direction: column; align-items: flex-start; gap: var(--sv-space-1); }
.svx-head .sv-title-3 { overflow-wrap: anywhere; }
.svx-meta { display: inline; color: var(--sv-text-muted); }
.svx-meta .sv-data { color: var(--sv-text-soft); }
.svx-desc { margin: 0; max-width: 72ch; }

/* ---------- Database ---------- */
.svx-search { position: relative; flex: 0 1 300px; min-width: 200px; }
.svx-search .sv-input { padding-right: 36px; }
.svx-search .sv-icon { position: absolute; right: var(--sv-space-3); top: 50%; transform: translateY(-50%); color: var(--sv-text-dim); pointer-events: none; }
/* table rows are kit menu buttons built in openDatabase(); its loading and empty notes are plain rows */
#dbs-tables .dbs-tbl { display: flex; align-items: center; gap: var(--sv-space-3); min-height: var(--sv-h-md); padding: 0 var(--sv-space-3); cursor: pointer; border-radius: var(--sv-r);
  font-family: var(--sv-font-body); font-size: var(--sv-fs-17); color: var(--sv-text-soft); transition: background-color var(--sv-t1) var(--sv-ease), color var(--sv-t1) var(--sv-ease); }
#dbs-tables .dbs-tbl:hover { background: rgba(var(--sv-glow-rgb), .06); color: var(--sv-text); }
#dbs-tables .dbs-tbl > span:first-of-type { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#dbs-tables .dbs-tbl .n { margin-left: auto; font-family: var(--sv-font-mono); font-size: var(--sv-fs-12); font-variant-numeric: tabular-nums; color: var(--sv-text-dim); }
#dbs-tables div.dbs-tbl:only-child:not([data-t]) { cursor: default; font-style: italic; color: var(--sv-text-dim); background: none; }

.svx-grid { position: relative; flex: 1; min-height: 0; margin: 0 var(--sv-space-5); overflow: auto; scrollbar-width: none;
  border: 1px solid var(--sv-line); border-radius: var(--sv-r); background: rgba(var(--sv-ground-rgb), .45); }
.svx-grid::-webkit-scrollbar { display: none; }
.svx-table { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; }
.svx-table th { display: table-cell; position: sticky; top: 0; z-index: 1; padding: var(--sv-space-3) var(--sv-space-4); text-align: left; white-space: nowrap;
  background: var(--sv-bg); border-bottom: 1px solid var(--sv-line-strong); }
.svx-table td { max-width: 340px; padding: var(--sv-space-2) var(--sv-space-4); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: baseline;
  border-bottom: 1px solid var(--sv-line-soft); font-size: var(--sv-fs-17); color: var(--sv-text-soft); }
.svx-table td.sv-data { font-size: var(--sv-fs-12); color: var(--sv-text-muted); }
.svx-table td.key { color: var(--sv-text); }
.svx-table td.null { font-style: italic; color: var(--sv-text-dim); }
.svx-table td.mask { color: var(--sv-text-dim); letter-spacing: var(--sv-ls-label); }
.svx-table tbody tr:hover td { background: rgba(var(--sv-glow-rgb), .04); color: var(--sv-text); }
.svx-table tbody tr:last-child td { border-bottom: 0; }
.svx-empty { position: absolute; inset: 0; display: grid; place-content: center; gap: var(--sv-space-1); padding: var(--sv-space-5); text-align: center; }
.svx-empty[hidden], .svx-table[hidden] { display: none; }
.svx-empty p { margin: 0; }

/* horizontal pan for wide tables (the grid's own scrollbar is hidden) */
.svx-slider { display: flex; align-items: center; gap: var(--sv-space-3); margin: var(--sv-space-3) var(--sv-space-5) 0; }
.svx-slider[hidden] { display: none; }
.svx-slider .sv-label { flex: none; white-space: nowrap; }
.svx-slider input[type=range] { -webkit-appearance: none; appearance: none; flex: 1; min-width: 0; height: 12px; margin: 0; background: none; cursor: pointer; }
.svx-slider input[type=range]::-webkit-slider-runnable-track { height: 2px; background: var(--sv-line-2); }
.svx-slider input[type=range]::-moz-range-track { height: 2px; background: var(--sv-line-2); }
.svx-slider input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 40px; height: 12px; margin-top: -5px; border: 1px solid var(--sv-rim); border-radius: var(--sv-r); background: var(--sv-surface-primary); }
.svx-slider input[type=range]::-moz-range-thumb { width: 40px; height: 12px; border: 1px solid var(--sv-rim); border-radius: var(--sv-r); background: var(--sv-surface-primary); }
.svx-slider input[type=range]:focus-visible { outline: var(--sv-focus); outline-offset: 2px; }

.svx-foot { display: flex; align-items: center; gap: var(--sv-space-3); min-width: 0; padding: var(--sv-space-3) var(--sv-space-5) calc(var(--sv-space-4) + env(safe-area-inset-bottom)); }
.svx-pageinfo { color: var(--sv-text-muted); white-space: nowrap; }
.svx-foot__note { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-left: var(--sv-space-3); border-left: 2px solid var(--sv-violet-deep); }

/* ---------- AI Logic ---------- */
.svx-live { font-family: var(--sv-font-display); font-weight: 600; font-size: var(--sv-fs-12); letter-spacing: var(--sv-ls-label); color: var(--sv-text-dim); text-align: right; max-width: 340px; }
.svx-live b { font-weight: 600; color: var(--sv-violet-bright); }
.svx-canvas { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: none; padding: var(--sv-space-4) var(--sv-space-6) var(--sv-space-7); }
.svx-canvas::-webkit-scrollbar { display: none; }
.svx-canvas:has(.svx-bp) { overflow: auto; }

/* flow maps: numbered stage cards joined by a hairline */
.svx-pipe { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; }
.svx-node__head { display: flex; align-items: center; gap: var(--sv-space-3); margin-bottom: var(--sv-space-2); }
.svx-node__num { flex: none; width: 24px; height: 24px; display: grid; place-items: center; color: var(--sv-violet-bright); border: 1px solid var(--sv-line-strong); border-radius: var(--sv-r); }
.svx-node__title { font-family: var(--sv-font-display); font-weight: 600; font-size: var(--sv-fs-17); letter-spacing: var(--sv-ls-title); color: var(--sv-text); }
.svx-node .sv-text { margin: 0; }
.svx-node__tags { margin-top: var(--sv-space-3); }
.svx-node--loop { border-style: dashed; border-color: var(--sv-line-strong); background: none; }
.svx-arrow { position: relative; align-self: center; width: 1px; height: var(--sv-space-5); background: var(--sv-line-strong); }
.svx-arrow::after { content: ""; position: absolute; left: -3px; bottom: 1px; width: 5px; height: 5px; border-right: 1px solid var(--sv-line-strong); border-bottom: 1px solid var(--sv-line-strong); transform: rotate(45deg); }
.svx-arrow--back { background: var(--sv-line); }

/* blueprint maps: absolutely placed nodes, wires on an SVG layer behind them */
.svx-bp { position: relative; margin: 0 auto; width: var(--svx-bw); height: var(--svx-bh); }
.svx-bp .aim-wires { position: absolute; inset: 0; z-index: 1; pointer-events: none; overflow: visible; }
.svx-bp .wire { fill: none; stroke: rgba(var(--sv-glow-rgb), .45); stroke-width: 1.25; }
.svx-bp .wire.dash { stroke-dasharray: 4 5; stroke: rgba(var(--sv-glow-rgb), .3); }
.svx-bp .wah { fill: rgba(var(--sv-glow-rgb), .55); }
.svx-bp .wlbl { fill: var(--sv-text-dim); font-family: var(--sv-font-display); font-weight: 600; font-size: var(--sv-fs-11); letter-spacing: var(--sv-ls-label);
  text-anchor: middle; paint-order: stroke; stroke: var(--sv-bg); stroke-width: 3px; }
.svx-bpn { position: absolute; z-index: 2; left: var(--svx-x); top: var(--svx-y); width: var(--svx-w); box-sizing: border-box; padding: var(--sv-space-3);
  background: var(--sv-surface-card); border: 1px solid var(--sv-line-2); border-radius: var(--sv-r); box-shadow: var(--sv-e-raised); }
/* ports: small square studs on the left and right edges */
.svx-bpn::before, .svx-bpn::after { content: ""; position: absolute; top: 50%; width: 7px; height: 7px; margin-top: -4px; box-sizing: border-box; background: var(--sv-bg); border: 1px solid var(--sv-line-strong); }
.svx-bpn::before { left: -4px; }
.svx-bpn::after { right: -4px; }
.svx-bpn__title { font-family: var(--sv-font-display); font-weight: 600; font-size: var(--sv-fs-17); letter-spacing: var(--sv-ls-title); line-height: 1.2; color: var(--sv-text); }
.svx-bpn__sub { margin-top: var(--sv-space-1); font-size: var(--sv-fs-17); line-height: 1.3; color: var(--sv-text-muted); }
.svx-bpn .sv-badge { margin-top: var(--sv-space-2); }
.svx-bpn.good { border-color: color-mix(in srgb, var(--sv-success) 55%, transparent); }
.svx-bpn.good::before, .svx-bpn.good::after { border-color: var(--sv-success); }
.svx-bpn.good .sv-badge { color: var(--sv-success); border-color: color-mix(in srgb, var(--sv-success) 45%, transparent); }
.svx-bpn.warn { border-color: color-mix(in srgb, var(--sv-warning) 55%, transparent); }
.svx-bpn.warn::before, .svx-bpn.warn::after { border-color: var(--sv-warning); }
.svx-bpn.warn .sv-badge { color: var(--sv-warning); border-color: color-mix(in srgb, var(--sv-warning) 45%, transparent); }

/* live activity: a button to the AI terminal and a read-only tail */
.svx-liveview { max-width: 820px; margin: 0 auto; }
.svx-tail { margin-top: var(--sv-space-5); max-height: 420px; overflow-y: auto; scrollbar-width: none; padding: var(--sv-space-4);
  white-space: pre-wrap; line-height: 1.7; color: var(--sv-text-muted); }
.svx-tail::-webkit-scrollbar { display: none; }
.svx-tail .empty { font-family: var(--sv-font-body); font-style: italic; font-size: var(--sv-fs-17); color: var(--sv-text-dim); }

/* ---------- Drawing Board ---------- */
.svx-presence { display: inline-flex; align-items: center; gap: var(--sv-space-2); flex-wrap: wrap; justify-content: flex-end; min-width: 0; }
.svx-who { display: inline-flex; align-items: center; gap: var(--sv-space-2); height: var(--sv-h-sm); padding: 0 var(--sv-space-3) 0 var(--sv-space-1);
  border: 1px solid var(--sv-line-2); border-radius: var(--sv-r); }
.svx-who__av { width: 24px; height: 24px; flex: none; display: grid; place-items: center; border-radius: var(--sv-r); background: var(--svx-who, var(--sv-violet)); color: var(--sv-bg);
  font-family: var(--sv-font-display); font-weight: 700; font-size: var(--sv-fs-12); }
.svx-who__name { font-size: var(--sv-fs-17); color: var(--sv-text-soft); white-space: nowrap; }

.svx-file { height: auto; min-height: var(--sv-h-lg); padding: var(--sv-space-2) var(--sv-space-3); flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px; }
.svx-file .brd-item-t { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.svx-file .brd-item-m { font-style: italic; font-size: var(--sv-fs-14); color: var(--sv-text-dim); }
.svx-file .brd-item-m:empty { display: none; }

#board-screen .svx-main { position: relative; }
.svx-board-empty { margin: auto; max-width: 420px; padding: var(--sv-space-5); text-align: center; }
.svx-doc { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.svx-dochead { display: flex; align-items: center; gap: var(--sv-space-2); min-width: 0; padding: var(--sv-space-4) var(--sv-space-5); border-bottom: 1px solid var(--sv-line); }
.svx-doc__title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.svx-doc__status { flex: none; }
.svx-doc__del:hover { color: var(--sv-danger); border-color: rgba(220,90,78,.45); }
.svx-writers { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sv-space-2); padding: var(--sv-space-2) var(--sv-space-5); border-bottom: 1px solid var(--sv-line-soft); }
.svx-plate { display: inline-flex; align-items: center; gap: var(--sv-space-2); height: 28px; padding: 0 var(--sv-space-3); border: 1px solid var(--sv-line); border-radius: var(--sv-r);
  font-size: var(--sv-fs-14); color: var(--sv-text-muted); }
.svx-plate b { font-weight: 600; color: var(--svx-who, var(--sv-text)); }
.svx-plate .brd-plate-x { font-style: italic; }
.svx-plate__dot { width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--svx-who, var(--sv-violet)); animation: svx-writing 1.4s ease-in-out infinite; }
@keyframes svx-writing { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .svx-plate__dot { animation: none; } }
html[data-reduce-motion="1"] .svx-plate__dot { animation: none; }
.svx-editor { flex: 1; min-height: 0; height: auto; margin: var(--sv-space-4) var(--sv-space-5) calc(var(--sv-space-5) + env(safe-area-inset-bottom)); width: auto; resize: none; padding: var(--sv-space-4) var(--sv-space-5); line-height: 1.6; scrollbar-width: thin; }
.svx-editor:disabled { opacity: .55; }

/* ---------- Cost (costs.js) ---------- */
/* The period controls sit in the top bar; the body scrolls as one column of
   stat tiles, charts and tables, each table on the Database grid. The chart
   colors are the categorical palette validated for this dark surface
   (dataviz: lightness band, chroma floor, CVD and normal-vision separation,
   3:1 contrast), one slot per category in a fixed order. */
#costs-screen {
  --viz-1: #3987e5; --viz-2: #d95926; --viz-3: #199e70; --viz-4: #c98500;
  --viz-5: #d55181; --viz-6: #008300; --viz-7: #9085e9; --viz-8: #e66767;
  --viz-surface: var(--sv-bg); --viz-grid: rgba(255,255,255,.08); --viz-axis: rgba(255,255,255,.18);
}
.svx-costs__ranges { flex: none; gap: var(--sv-space-2); }
.svx-costs__ranges .sv-cluster { gap: var(--sv-space-1); }
.svx-costs__custom { display: inline-flex; align-items: center; gap: var(--sv-space-1); }
.svx-costs__date { width: 138px; height: var(--sv-h-sm); padding: 0 var(--sv-space-2); font-size: var(--sv-fs-14); color-scheme: dark; }
.svx-costs__select { width: auto; height: var(--sv-h-sm); padding: 0 32px 0 var(--sv-space-3); font-size: var(--sv-fs-14); }
.svx-costs__body { position: relative; flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: none; padding: 0 var(--sv-space-5) calc(var(--sv-space-6) + env(safe-area-inset-bottom)); transition: opacity var(--sv-t1) var(--sv-ease); }
.svx-costs__body::-webkit-scrollbar { display: none; }
.svx-costs__body.is-loading { opacity: .55; pointer-events: none; }   /* refetch keeps the frame */
#costs-screen .svx-main { position: relative; }
.svx-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: var(--sv-space-3); margin-bottom: var(--sv-space-4); }
.svx-stats--small { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.svx-stats--small .svx-stat__v { font-size: var(--sv-fs-17); }
.svx-stat { display: flex; flex-direction: column; gap: 2px; padding: var(--sv-space-3) var(--sv-space-4); min-width: 0; }
.svx-stat--hero { grid-column: span 2; }
.svx-stat--hero .svx-stat__v { font-size: 44px; }
.svx-stat__k { color: var(--sv-text-dim); }
.svx-stat__v { font-family: var(--sv-font-mono); font-size: var(--sv-fs-22, 22px); color: var(--sv-text); line-height: 1.2; overflow-wrap: anywhere; }
.svx-stat__v small { font-family: var(--sv-font-display); font-weight: 600; font-size: var(--sv-fs-12); letter-spacing: var(--sv-ls-label); color: var(--sv-text-dim); }
.svx-stat__d { font-size: var(--sv-fs-12); }
.svx-stat__s { line-height: 1.35; }
.svx-stat--good .svx-stat__v { color: var(--sv-success); }
.svx-stat--warn .svx-stat__v { color: var(--sv-warning); }
/* deltas against the previous period: direction by arrow and words, tone by whether up is good */
.svx-delta { display: inline-flex; align-items: center; gap: 2px; font-family: var(--sv-font-mono); font-size: var(--sv-fs-12); color: var(--sv-text-muted); white-space: nowrap; }
.svx-delta--good { color: var(--sv-success); }
.svx-delta--bad { color: var(--sv-danger); }
.svx-pos { color: var(--sv-success); }
.svx-neg { color: var(--sv-text-soft); }
.svx-key { display: inline-block; width: 10px; height: 10px; margin-right: 6px; vertical-align: -1px; background: var(--c); border-radius: 2px; }
.svx-costs__h { margin: var(--sv-space-5) 0 var(--sv-space-3); display: flex; align-items: baseline; gap: var(--sv-space-3); flex-wrap: wrap; }
.svx-costs__h > .sv-btn, .svx-costs__h .svx-costs__pager { margin-left: auto; }
.svx-costs__pager { display: inline-flex; align-items: center; gap: var(--sv-space-2); white-space: nowrap; }
.svx-two { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 0 var(--sv-space-5); align-items: start; }
.svx-costs__grid { position: static; flex: none; margin: 0; max-height: min(60vh, 640px); }
.svx-costs__grid--short { max-height: 320px; }
.svx-costs__grid .svx-table { width: 100%; }
.svx-costs__grid .svx-table td.svx-num, .svx-costs__grid .svx-table th.svx-num { text-align: right; font-variant-numeric: tabular-nums; }
.svx-costs__grid .svx-table td.sv-data { font-size: var(--sv-fs-14); color: var(--sv-text-soft); }
.svx-costs__grid .svx-table tfoot td { position: sticky; bottom: 0; background: var(--sv-bg); border-top: 1px solid var(--sv-line-strong); border-bottom: 0; color: var(--sv-text); font-weight: 600; }
.svx-costs__grid .svx-table th.svx-sort { cursor: pointer; user-select: none; }
.svx-costs__grid .svx-table th.svx-sort:hover, .svx-costs__grid .svx-table th.is-sorted { color: var(--sv-violet-bright); }
.svx-costs__note { margin: var(--sv-space-3) 0 0; line-height: 1.5; max-width: 80ch; }
.svx-costs__err { color: var(--sv-danger); }
.svx-costs__coverage { margin: var(--sv-space-3) 0 0; padding-left: 1.2em; line-height: 1.5; max-width: 80ch; }
.svx-costs__bar { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sv-space-2) var(--sv-space-3); margin-bottom: var(--sv-space-3); }
.svx-costs__toggle { gap: var(--sv-space-2); padding: 0; min-height: 0; border: 0; background: none; cursor: pointer; }
.costs-acct, .costs-adv { padding-left: 0; padding-right: 0; height: auto; min-height: 0; text-align: left; }
.svx-crumb { margin: var(--sv-space-2) 0 var(--sv-space-3); }
.svx-profile { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--sv-space-3) var(--sv-space-5); padding: var(--sv-space-3) var(--sv-space-4); margin-bottom: var(--sv-space-4); border: 1px solid var(--sv-line); border-radius: var(--sv-r); background: rgba(var(--sv-ground-rgb), .35); }
.svx-profile > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.svx-profile b { font-weight: 500; color: var(--sv-text); overflow-wrap: anywhere; }

/* charts: thin marks, hairline grid, text in text tokens, marks in the series color */
.svx-chart { margin: 0 0 var(--sv-space-3); padding: var(--sv-space-3) var(--sv-space-3) var(--sv-space-2); border: 1px solid var(--sv-line); border-radius: var(--sv-r); background: rgba(var(--sv-ground-rgb), .35); }
.svx-chart__t { display: block; margin-bottom: var(--sv-space-2); color: var(--sv-text-dim); }
.svx-ch { display: block; width: 100%; height: auto; overflow: visible; font-family: var(--sv-font-mono); }
.svx-ch--bars { max-width: 100%; }
.svx-ch__grid { stroke: var(--viz-grid); stroke-width: 1; shape-rendering: crispEdges; }
.svx-ch__axis { stroke: var(--viz-axis); stroke-width: 1; shape-rendering: crispEdges; }
.svx-ch__tick, .svx-ch__lbl, .svx-ch__val, .svx-ch__end { fill: var(--sv-text-dim); font-size: 11px; }
.svx-ch__lbl { fill: var(--sv-text-soft); font-family: var(--sv-font-body); font-size: 13px; }
.svx-ch__val, .svx-ch__end { fill: var(--sv-text-soft); font-variant-numeric: tabular-nums; }
.svx-ch__seg, .svx-ch__bar { stroke: var(--viz-surface); stroke-width: 2; }   /* the 2px surface gap */
.svx-ch__bar { rx: 0; }
.svx-ch__line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.svx-ch__dot { stroke: var(--viz-surface); stroke-width: 2; }                   /* the 2px surface ring */
.svx-ch__wash { opacity: .1; }
.svx-ch__hit { fill: transparent; cursor: crosshair; outline: none; }
.svx-ch__hit.is-hot, .svx-ch__hit:focus-visible { fill: rgba(255,255,255,.04); }
.svx-ch__cross { stroke: var(--viz-axis); stroke-width: 1; shape-rendering: crispEdges; pointer-events: none; }
.svx-ch__cross[hidden] { display: none; }
.svx-legend { display: flex; flex-wrap: wrap; gap: var(--sv-space-1) var(--sv-space-4); margin-top: var(--sv-space-2); padding: 0 var(--sv-space-1); font-size: var(--sv-fs-12); color: var(--sv-text-muted); }
.svx-legend__it { display: inline-flex; align-items: center; gap: 6px; }
.svx-legend__swatch { width: 10px; height: 10px; border-radius: 2px; background: var(--c); }
.svx-legend__line { width: 14px; height: 2px; border-radius: 1px; background: var(--c); }
.svx-tip { position: absolute; z-index: 5; min-width: 160px; max-width: 280px; padding: var(--sv-space-2) var(--sv-space-3); pointer-events: none;
  background: var(--sv-bg); border: 1px solid var(--sv-line-strong); border-radius: var(--sv-r); box-shadow: var(--sv-e-raised); font-size: var(--sv-fs-12); color: var(--sv-text-muted); }
.svx-tip[hidden] { display: none; }
.svx-tip__h { margin-bottom: 4px; color: var(--sv-text); font-family: var(--sv-font-display); font-weight: 600; letter-spacing: var(--sv-ls-label); }
.svx-tip__r { display: grid; grid-template-columns: 14px auto 1fr; align-items: center; gap: 6px; padding: 1px 0; }
.svx-tip__r i { width: 12px; height: 2px; background: var(--c); border-radius: 1px; }
.svx-tip__r b { font-family: var(--sv-font-mono); font-weight: 600; color: var(--sv-text); font-variant-numeric: tabular-nums; }
.svx-tip__t { margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--sv-line); color: var(--sv-text-soft); }

@media (max-width: 1100px) {
  /* the bar wraps so the period controls take a row of their own under the title and actions */
  #costs-screen .svx-top { flex-wrap: wrap; row-gap: 0; padding-bottom: var(--sv-space-2); }
  .svx-costs__ranges { order: 9; flex-basis: 100%; flex-wrap: wrap; }
  .svx-stat--hero { grid-column: span 1; }
  .svx-stat--hero .svx-stat__v { font-size: 32px; }
}

/* ---------- askText prompt ---------- */
.svx-prompt { width: min(440px, 100%); }
.svx-prompt .sv-label { margin-bottom: 2px; }

/* ---------- narrow screens ---------- */
@media (max-width: 860px) {
  .svx-app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr); }
  .svx-rail { flex-direction: row; align-items: center; gap: var(--sv-space-2); overflow-x: auto; overflow-y: hidden; padding: var(--sv-space-2) var(--sv-space-4);
    border-right: 0; border-bottom: 1px solid var(--sv-line); }
  .svx-rail__label, .svx-rail__note { display: none; }
  .svx-rail__list { flex-direction: row; gap: var(--sv-space-1); }
  .svx-rail .sv-menu__item, #dbs-tables .dbs-tbl { width: auto; white-space: nowrap; }
  .svx-rail__new { width: auto; margin: 0; }
  .svx-file { min-height: var(--sv-h-md); }
  .svx-file .brd-item-m { display: none; }
  .svx-badge, .svx-live, .svx-foot__note { display: none; }
  .svx-who__name { display: none; }
  .svx-who { padding: 0 var(--sv-space-1); }
}
@media (max-width: 720px) {
  .svx-top { gap: var(--sv-space-2); padding-left: var(--sv-space-4); padding-right: var(--sv-space-4); }
  .svx-title { font-size: var(--sv-fs-19); }
  .svx-act { width: var(--sv-h-md); padding: 0; }
  .svx-act__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .svx-head { padding: var(--sv-space-4); }
  .svx-search { flex: 1 1 100%; min-width: 0; }
  .svx-grid { margin: 0 var(--sv-space-4); }
  .svx-slider { margin: var(--sv-space-3) var(--sv-space-4) 0; }
  .svx-foot { padding-left: var(--sv-space-4); padding-right: var(--sv-space-4); }
  .svx-canvas { padding: var(--sv-space-2) var(--sv-space-4) var(--sv-space-6); }
  .svx-dochead { padding: var(--sv-space-3) var(--sv-space-4); }
  .svx-writers { padding: var(--sv-space-2) var(--sv-space-4); }
  .svx-editor { margin: var(--sv-space-3) var(--sv-space-4) calc(var(--sv-space-4) + env(safe-area-inset-bottom)); padding: var(--sv-space-3); }
}
