/* The run budget (frontend/DESIGN.md "Run budget", _budget_macros.html, agentbudget.py). Tokens only: both themes work.
   Spend by step is a quantity, not a state: neutral inks, each step its own fill pattern, and the legend carries the
   words and the dollars. Green only for reads covered by a sandbox-verified fix. */

/* Step fills. Never colour alone: solid, stripes, dots, cross-hatch, and a dashed box for what no step accounts for. */
.sg { display: inline-block; min-width: 0; }
.sg-1 { background: var(--ink-2); }
.sg-2 { background: var(--ink-3); background-image: repeating-linear-gradient(135deg, transparent 0 3px, var(--surface) 3px 4px); }
.sg-3 { background: var(--line-strong); }
.sg-4 { background: var(--ink-3); background-image: radial-gradient(var(--surface) 1px, transparent 1.2px); background-size: 4px 4px; }
.sg-5 { background: var(--ink-2); background-image: repeating-linear-gradient(90deg, transparent 0 3px, var(--surface) 3px 4px); }
.sg-6 { background: var(--line-strong); background-image: repeating-linear-gradient(45deg, var(--ink-3) 0 1px, transparent 1px 4px), repeating-linear-gradient(135deg, var(--ink-3) 0 1px, transparent 1px 4px); }
.sg-7 { background: var(--ink-3); }
.sg-8 { background: var(--ink-2); background-image: repeating-linear-gradient(0deg, transparent 0 3px, var(--surface) 3px 4px); }
.sg-0 { background: var(--surface); box-shadow: inset 0 0 0 1px var(--ink-3); }
.sg.is-left { background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--line); }

.bg-body { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: var(--sp-5) var(--sp-7); padding: var(--sp-5); }
@media (max-width: 1100px) { .bg-body { grid-template-columns: minmax(0, 1fr); } }
.bg-money { display: flex; flex-direction: column; gap: var(--sp-4); min-width: 0; }
.bg-fig { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--sp-2) var(--sp-4); min-width: 0; }
.bg-fig > b { font: 500 var(--fs-6)/1.1 var(--font-mono); color: var(--ink); }
.bg-noun { color: var(--ink-2); font-weight: 600; }
.bg-bar { display: flex; gap: 1px; height: 14px; min-width: 0; border-radius: 2px; background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; }
.bg-bar > .sg { height: 100%; min-width: 3px; flex: none; }
.bg-bar.is-nobudget { background: none; box-shadow: none; }
.bg-bar.is-over { box-shadow: inset 0 0 0 1px var(--warn); }
.bg-legend { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-6); margin: 0; padding: 0; list-style: none; font-size: var(--fs-2); color: var(--ink-2); min-width: 0; }
.bg-legend > li { display: inline-flex; align-items: center; gap: var(--sp-3); min-width: 0; white-space: nowrap; }
.bg-legend > li > i { width: 10px; height: 10px; border-radius: 2px; flex: none; }
.bg-legend b { color: var(--ink); font-weight: 600; }
.bg-line { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-6); font-size: var(--fs-2); color: var(--ink-2); min-width: 0; }
.bg-line b { color: var(--ink); font-weight: 600; }

/* What it bought: small tiles, one fact each. */
.bg-bought { display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); gap: var(--sp-4) var(--sp-5); margin: 0; align-content: start; min-width: 0; }
.bg-bought > div { display: flex; flex-direction: column; gap: var(--sp-1); min-width: 0; padding: var(--sp-3) var(--sp-4); border: 1px solid var(--line); border-radius: var(--r-2); background: var(--surface); }
.bg-bought dt { color: var(--ink-3); font-size: var(--fs-1); font-weight: 500; }
.bg-bought dd { margin: 0; min-width: 0; }
.bg-bought dd.mono { font: 500 var(--fs-5)/1.2 var(--font-mono); color: var(--ink); }
.bg-bought dd.is-win { color: var(--win); }
.bg-bought .bg-sub { color: var(--ink-3); font-size: var(--fs-1); line-height: 1.35; overflow-wrap: anywhere; }

/* Reads covered: verified fix solid green, not asked hatched in an outline, the rest the track. */
.bg-reads { grid-column: 1 / -1; display: flex; flex-direction: column; gap: var(--sp-3); min-width: 0; }
.bg-reads > .label { margin: 0; }
.bg-rbar { display: flex; height: 10px; min-width: 0; border-radius: 2px; background: var(--surface-3); overflow: hidden; }
.bg-rbar > span { height: 100%; flex: none; }
.rb-fix { background: var(--win); }
.rb-na { background: var(--surface); box-shadow: inset 0 0 0 1px var(--ink-3); background-image: repeating-linear-gradient(135deg, transparent 0 3px, color-mix(in srgb, var(--ink-3) 35%, transparent) 3px 4px); }
.rb-rest { background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--line); }
.bg-legend > li > i.rb-fix, .bg-legend > li > i.rb-na, .bg-legend > li > i.rb-rest { display: inline-block; }

.bg-na { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3) var(--sp-5); padding: var(--sp-4) var(--sp-5); border: 1px dashed var(--ink-3); border-radius: var(--r-2); min-width: 0; }
.bg-na > .label { margin: 0; color: var(--ink); font-size: var(--fs-3); font-weight: 600; }
.bg-na > .cli { flex: 0 1 18rem; min-width: 0; }

/* A list cell: spent of budget and a short meter. */
.bgc { display: inline-flex; align-items: center; gap: var(--sp-3); min-width: 0; white-space: nowrap; }
.bgc-meter { display: inline-block; width: 3rem; height: 5px; flex: none; border-radius: 2px; background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; }
.bgc-meter > i { display: block; height: 100%; min-width: 2px; background: var(--ink-2); }
.bgc-meter.is-stopped { box-shadow: inset 0 0 0 1px var(--warn); }
.bgc-meter.is-stopped > i { background: var(--warn); }
.is-warn-text { color: var(--warn); font-weight: 600; }
.tbl.is-list td.is-num .bgc { justify-content: flex-end; width: 100%; }

/* "Not asked yet": per kind, a bar of the estimate's high end, the count and the range; then the one command. */
.na-body { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: var(--sp-5) var(--sp-7); padding: var(--sp-5); align-items: start; }
@media (max-width: 1100px) { .na-body { grid-template-columns: minmax(0, 1fr); } }
.na-kinds { display: grid; grid-template-columns: max-content minmax(4rem, 1fr) max-content max-content max-content; gap: var(--sp-3) var(--sp-5); align-items: center; min-width: 0; font-size: var(--fs-2); }
.na-kinds > .na-name { color: var(--ink); white-space: nowrap; }
.na-kinds > .bar > span { background: var(--ink-3); }
.na-kinds > .na-n, .na-kinds > .na-est, .na-kinds > .na-share { white-space: nowrap; text-align: right; }
.na-run { display: flex; flex-direction: column; gap: var(--sp-3); min-width: 0; }
.na-items td .l1 > .mono { flex: none; }
@media (max-width: 720px) { .na-kinds { grid-template-columns: max-content minmax(3rem, 1fr) max-content; } .na-kinds > .na-est, .na-kinds > .na-share { display: none; } }

/* Settings › Agent budget: the policy table, and the qopt.toml lines to copy. */
.pol-tbl td .input { width: 7.5rem; }
.pol-tbl .pol-src { color: var(--ink-3); font-size: var(--fs-1); }
.pol-tbl .l2 { display: flex; align-items: baseline; gap: var(--sp-3); min-width: 0; }
.pol-tbl .l2 > .clip { min-width: 0; }
.pol-toml { margin: 0; padding: var(--sp-4) var(--sp-5); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-2); font: 500 var(--fs-2)/1.5 var(--font-mono); white-space: pre; overflow-x: auto; max-width: 100%; }
.pol-note { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3) var(--sp-5); min-width: 0; }

/* Runs › Agent spend: one row per project, a month per cell as a stacked bar by step, the trend of cost per fix. */
.sp-tbl td.sp-cell { padding-top: var(--sp-3); padding-bottom: var(--sp-3); vertical-align: bottom; }
.sp-col { display: flex; flex-direction: column; justify-content: flex-end; gap: var(--sp-1); height: 3.25rem; min-width: 0; }
.sp-stack { display: flex; flex-direction: column-reverse; width: 100%; max-width: 2.25rem; margin: 0 auto; border-radius: 2px; overflow: hidden; }
.sp-stack > span { display: block; width: 100%; min-height: 1px; }
.sg.sp-before { background: var(--surface); box-shadow: inset 0 0 0 1px var(--ink-3); background-image: repeating-linear-gradient(135deg, transparent 0 3px, color-mix(in srgb, var(--ink-3) 35%, transparent) 3px 4px); }
.sp-num { font: 400 var(--fs-1)/1.2 var(--font-mono); color: var(--ink-2); text-align: center; white-space: nowrap; }
.sp-none { display: block; text-align: center; color: var(--ink-3); font-size: var(--fs-1); }
.sp-trend { width: 100%; height: 28px; display: block; }
.sp-trend polyline { fill: none; stroke: var(--ink-2); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.sp-trend circle { fill: var(--ink); }
.sp-mbar { display: flex; height: 8px; margin-left: auto; }
.sp-legend { padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--line); }
