/* reMyCrypto admin panel — "Instrument, color is data". Consumes semantic/component tokens only
   (web/css/tokens.css, generated from docs/design/TOKENS.json). */
*, *::before, *::after { box-sizing: border-box; }
html { color-scheme: dark; background: var(--color-bg-page); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; background: var(--color-bg-page); color: var(--color-text-primary);
  font-family: var(--font-ui); font-size: var(--text-body); line-height: 1.4;
  -webkit-font-smoothing: antialiased; font-synthesis-weight: none;
}
a { color: inherit; text-decoration-color: var(--color-border-control); text-underline-offset: 2px; }
a:hover { text-decoration-color: var(--color-text-primary); }
:focus-visible { outline: 2px solid var(--color-border-focus); outline-offset: 2px; border-radius: var(--radius-control); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
code, .mono, pre { font-family: var(--font-data); }
.num { font-family: var(--font-data); font-variant-numeric: tabular-nums; }
.muted { color: var(--color-text-muted); }
.sec { color: var(--color-text-secondary); }
.up { color: var(--color-text-pnl-up); }
.down { color: var(--color-text-pnl-down); }
.danger-text { color: var(--color-text-danger); }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: var(--space-sm); top: -4rem; z-index: 100; background: var(--color-action-primary); color: var(--color-text-inverse); padding: var(--space-sm) var(--space-md); }
.skip:focus { top: var(--space-sm); }
.nowrap { white-space: nowrap; }
.micro { font-size: var(--text-micro); letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-text-muted); font-weight: 500; }

/* ---------- shell ---------- */
.runbar {
  position: sticky; top: 0; z-index: 30; background: var(--color-bg-strip);
  border-bottom: 1px solid var(--color-border-hairline); min-height: var(--c-runbar-height);
  display: flex; align-items: center; gap: var(--space-md); padding: var(--space-xs) var(--space-md);
  flex-wrap: wrap;
}
.rb-brand { font-family: var(--font-data); font-size: var(--text-micro); letter-spacing: 0.12em; color: var(--color-text-secondary); text-transform: uppercase; white-space: nowrap; }
.rb-state { display: inline-flex; align-items: center; gap: var(--space-xs); font-family: var(--font-data); font-size: var(--text-data); font-weight: 600; white-space: nowrap; }
.rb-gen { font-family: var(--font-data); font-size: var(--text-data); white-space: nowrap; }
.rb-gen a { text-decoration: none; }
.rb-gen b { font-weight: 600; font-size: 1rem; }
.rb-phase { flex: 1 1 16rem; min-width: 12rem; display: grid; gap: 2px; }
.steps { display: flex; gap: 2px; height: 6px; }
.step { flex: 1; background: transparent; border: 1px solid var(--c-runbar-phase-todo); position: relative; overflow: hidden; border-radius: 1px; }
.step.done { background: var(--c-runbar-phase-done); border-color: var(--c-runbar-phase-done); }
.step.active { border-color: var(--c-runbar-phase-active); }
.step.active > i { position: absolute; inset: 0; background: var(--c-runbar-phase-active); transform-origin: left; transform: scaleX(var(--p, 0)); }
.step.active.tick > i { animation: sweep var(--motion-sweep) var(--motion-ease) both; }
@keyframes sweep { from { transform: scaleX(0); } to { transform: scaleX(var(--p, 0)); } }
.rb-phase-label { display: flex; justify-content: space-between; gap: var(--space-sm); font-family: var(--font-data); font-size: var(--text-micro); color: var(--color-text-secondary); white-space: nowrap; }
.rb-phase-label b { color: var(--color-text-primary); font-weight: 600; }
.rb-meta { display: flex; align-items: center; gap: var(--space-md); font-family: var(--font-data); font-size: var(--text-micro); color: var(--color-text-secondary); flex-wrap: wrap; }
.rb-meta > span { white-space: nowrap; display: inline-flex; align-items: center; gap: var(--space-xs); }
.rb-meta a { text-decoration: none; }
.rb-meta a:hover { text-decoration: underline; }
.rb-meta .k { color: var(--color-text-muted); }
.rb-actions { display: flex; align-items: center; gap: var(--space-sm); margin-left: auto; }
.runbar .rb-menu { display: none; }
.runbar .rb-more { display: none; }

.banners:empty { display: none; }
.banner { display: flex; gap: var(--space-md); align-items: center; flex-wrap: wrap; padding: var(--space-sm) var(--space-md); background: var(--color-bg-surface); border-bottom: 1px solid var(--color-border-hairline); border-left: 3px solid var(--color-status-warning); }
.banner.critical { border-left-color: var(--color-status-critical); }
.banner.serious { border-left-color: var(--color-status-serious); }
.banner p { flex: 1 1 20rem; }

.shell { display: grid; grid-template-columns: 12.5rem minmax(0, 1fr); min-height: calc(100dvh - var(--c-runbar-height)); }
.rail { border-right: 1px solid var(--color-border-hairline); background: var(--color-bg-page); padding: var(--space-md) 0; position: sticky; top: var(--c-runbar-height); align-self: start; height: calc(100dvh - var(--c-runbar-height)); overflow-y: auto; display: flex; flex-direction: column; }
.rail h2 { font-size: var(--text-micro); letter-spacing: 0.1em; text-transform: uppercase; color: var(--color-text-muted); font-weight: 500; padding: var(--space-lg) var(--space-lg) var(--space-xs); }
.rail ul { list-style: none; margin: 0; padding: 0; }
.rail a, .rail button.rail-btn { display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm); padding: 0.3125rem var(--space-lg); color: var(--color-text-secondary); text-decoration: none; border-left: 2px solid transparent; font-size: var(--text-body); width: 100%; background: none; border-top: 0; border-right: 0; border-bottom: 0; text-align: left; cursor: pointer; min-height: 2rem; }
.rail a:hover, .rail button.rail-btn:hover { color: var(--color-text-primary); background: var(--color-bg-surface); }
.rail a[aria-current="page"] { color: var(--color-text-primary); border-left-color: var(--color-text-primary); background: var(--color-bg-surface); font-weight: 600; }
.rail .badge { font-family: var(--font-data); font-size: var(--text-micro); background: var(--color-status-warning); color: var(--color-text-inverse); padding: 0 0.375rem; border-radius: var(--radius-control); font-weight: 600; }
.rail-foot { margin-top: auto; border-top: 1px solid var(--color-border-hairline); padding-top: var(--space-sm); }
.rail-foot kbd { font-family: var(--font-data); font-size: var(--text-micro); color: var(--color-text-muted); border: 1px solid var(--color-border-strong); padding: 0 0.25rem; border-radius: var(--radius-control); }
.rail-foot label { display: grid; gap: 2px; padding: var(--space-sm) var(--space-lg); font-size: var(--text-micro); color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.08em; }
.rail-foot select { font-size: var(--text-data); text-transform: none; letter-spacing: 0; }

main { padding: var(--space-lg) var(--space-lg) var(--space-xxl); min-width: 0; }
main:focus { outline: none; }

/* ---------- page header ---------- */
.crumbs { font-size: var(--text-data); color: var(--color-text-muted); margin-bottom: var(--space-xs); }
.crumbs a { color: var(--color-text-secondary); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-lg); flex-wrap: wrap; margin-bottom: var(--space-md); }
.page-head h1 { font-size: var(--text-h1); font-weight: 600; letter-spacing: -0.01em; line-height: 1.15; }
.page-head h1 .mono { font-weight: 500; }
.page-head .purpose { color: var(--color-text-secondary); margin-top: 2px; max-width: 70ch; }
.page-actions { display: flex; gap: var(--space-sm); flex-wrap: wrap; align-items: center; }

/* ---------- grid + panels ---------- */
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--c-panel-gap); }
.span-2 { grid-column: span 2; } .span-3 { grid-column: span 3; } .span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; }
.span-6 { grid-column: span 6; } .span-7 { grid-column: span 7; } .span-8 { grid-column: span 8; } .span-9 { grid-column: span 9; } .span-12 { grid-column: span 12; }
.panel { background: var(--color-bg-surface); border: 1px solid var(--color-border-hairline); border-radius: var(--radius-panel); min-width: 0; display: flex; flex-direction: column; }
.panel-strip { display: flex; align-items: center; justify-content: space-between; gap: var(--space-xs) var(--space-sm); flex-wrap: wrap; min-height: var(--c-panel-strip-height); padding: 3px var(--space-sm) 3px var(--space-md); background: var(--color-bg-strip); border-bottom: 1px solid var(--color-border-hairline); }
.panel-strip h2 { font-size: var(--text-micro); letter-spacing: 0.1em; text-transform: uppercase; font-weight: 600; color: var(--color-text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel-strip .q { font-size: var(--text-data); color: var(--color-text-muted); text-transform: none; letter-spacing: 0; font-weight: 400; margin-left: var(--space-sm); }
.panel-tools { display: flex; gap: var(--space-xs); align-items: center; flex-wrap: wrap; max-width: 100%; }
.panel-body { padding: var(--space-md); min-width: 0; flex: 1; }
.panel-body.flush { padding: 0; }
.panel-foot { padding: var(--space-xs) var(--space-md); border-top: 1px solid var(--color-border-hairline); font-size: var(--text-data); color: var(--color-text-muted); display: flex; justify-content: space-between; gap: var(--space-sm); flex-wrap: wrap; }
.stack { display: grid; gap: var(--space-md); }
.row { display: flex; gap: var(--space-md); flex-wrap: wrap; align-items: baseline; }
.cols-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(16rem, 100%), 1fr)); gap: var(--space-md); }
.cols-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(12rem, 100%), 1fr)); gap: var(--space-md); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 2px var(--space-md); font-size: var(--text-data); }
.kv dt { color: var(--color-text-muted); }
.kv dd { margin: 0; font-family: var(--font-data); font-variant-numeric: tabular-nums; min-width: 0; overflow-wrap: anywhere; }
.prose { max-width: 72ch; line-height: 1.5; }
.prose h2 { font-size: var(--text-h2); margin: var(--space-lg) 0 var(--space-xs); }
.prose h3 { font-size: 1rem; margin: var(--space-md) 0 var(--space-xs); color: var(--color-text-secondary); }
.prose ul { padding-left: 1.2em; margin: var(--space-xs) 0; }
.prose h3.micro, h3.micro { font-size: var(--text-micro); letter-spacing: 0.1em; text-transform: uppercase; color: var(--color-text-muted); margin: 0 0 var(--space-xs); }
.prose p { margin: var(--space-xs) 0; }

/* ---------- stat tiles ---------- */
.stat { display: grid; gap: 2px; align-content: start; }
.stat .label { font-size: var(--text-data); color: var(--color-text-secondary); }
.stat .value { font-family: var(--font-data); font-variant-numeric: tabular-nums; font-size: var(--text-h2); font-weight: 500; line-height: 1.1; }
.stat .value.hero { font-size: var(--text-hero); font-weight: 500; letter-spacing: -0.02em; font-variant-numeric: proportional-nums; }
.stat .sub { font-size: var(--text-data); color: var(--color-text-muted); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(9rem, 100%), 1fr)); gap: var(--space-md) var(--space-lg); }

/* ---------- buttons, inputs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-xs); min-height: var(--c-button-height); padding: 0 var(--space-md); border: 1px solid var(--color-border-control); background: transparent; color: var(--color-text-primary); border-radius: var(--radius-control); cursor: pointer; font-weight: 500; white-space: nowrap; text-decoration: none; font-size: var(--text-body); }
.btn:hover { background: var(--color-bg-hover); }
.btn.primary { background: var(--c-button-primary-bg); color: var(--c-button-primary-text); border-color: var(--c-button-primary-bg); font-weight: 600; }
.btn.primary:hover { background: var(--color-action-primary-hover); }
.btn.danger { border-color: var(--c-button-danger-border); color: var(--c-button-danger-text); }
.btn.danger:hover { background: var(--color-bg-hover); }
.btn.ghost { border-color: transparent; color: var(--color-text-secondary); }
.btn.ghost:hover { color: var(--color-text-primary); }
.btn.sm { min-height: 1.5rem; padding: 0 var(--space-sm); font-size: var(--text-data); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
.btn .kbd { font-family: var(--font-data); font-size: var(--text-micro); opacity: 0.7; }
input[type="text"], input[type="password"], input[type="number"], input[type="search"], select, textarea {
  background: var(--color-bg-page); border: 1px solid var(--color-border-control); border-radius: var(--radius-control);
  min-height: var(--c-button-height); padding: 0 var(--space-sm); color: var(--color-text-primary); font-size: var(--text-input); max-width: 100%;
}
select { padding-right: var(--space-lg); }
textarea { padding: var(--space-sm); font-family: var(--font-data); font-size: var(--text-data); line-height: 1.5; width: 100%; resize: vertical; }
input[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--color-status-critical); }
.field { display: grid; gap: var(--space-xs); }
.field > label, .field > .label, legend { font-size: var(--text-data); color: var(--color-text-secondary); font-weight: 500; }
.field .hint { font-size: var(--text-data); color: var(--color-text-muted); }
.field .err { font-size: var(--text-data); color: var(--color-text-danger); }
.field .err:empty { display: none; }
fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: var(--space-xs); }
.check { display: flex; gap: var(--space-sm); align-items: flex-start; min-height: 1.5rem; cursor: pointer; }
.check input { width: 1.125rem; height: 1.125rem; margin-top: 1px; accent-color: var(--color-text-primary); flex: none; }
.segmented { display: inline-flex; flex-wrap: wrap; max-width: 100%; border: 1px solid var(--color-border-control); border-radius: var(--radius-control); overflow: hidden; }
.segmented button { border: 0; background: transparent; padding: 0 var(--space-md); min-height: 1.75rem; color: var(--color-text-secondary); cursor: pointer; font-size: var(--text-data); border-right: 1px solid var(--color-border-control); }
.segmented button:last-child { border-right: 0; }
.segmented button[aria-pressed="true"], .segmented button[aria-selected="true"] { background: var(--color-text-primary); color: var(--color-text-inverse); font-weight: 600; }
.segmented button[disabled] { opacity: 0.45; cursor: not-allowed; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--color-border-hairline); margin-bottom: var(--space-md); overflow-x: auto; scrollbar-width: none; }
.tabs [role="tab"] { background: none; border: 0; border-bottom: 2px solid transparent; padding: var(--space-sm) var(--space-md); color: var(--color-text-secondary); cursor: pointer; white-space: nowrap; font-size: var(--text-body); margin-bottom: -1px; min-height: 2.25rem; }
.tabs [role="tab"][aria-selected="true"] { color: var(--color-text-primary); border-bottom-color: var(--color-text-primary); font-weight: 600; }
.tabs [role="tab"]:hover { color: var(--color-text-primary); }
.tabs .count { font-family: var(--font-data); font-size: var(--text-micro); color: var(--color-text-muted); margin-left: 4px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; max-width: 100%; position: relative; }
.panel-body, .chart-table, .lineage { position: relative; }
table.data { border-collapse: collapse; width: 100%; font-size: var(--text-data); }
table.data th { position: sticky; top: 0; background: var(--color-bg-strip); text-align: left; font-weight: 500; color: var(--color-text-muted); font-size: var(--text-micro); letter-spacing: 0.06em; text-transform: uppercase; padding: 0 var(--space-sm); height: 1.75rem; border-bottom: 1px solid var(--color-border-hairline); white-space: nowrap; z-index: 1; }
table.data th button { all: unset; cursor: pointer; display: inline-flex; gap: 3px; align-items: center; }
table.data th button:focus-visible { outline: 2px solid var(--color-border-focus); outline-offset: 2px; }
table.data th[aria-sort] button::after { content: "↕"; opacity: 0.4; }
table.data th[aria-sort="ascending"] button::after { content: "↑"; opacity: 1; }
table.data th[aria-sort="descending"] button::after { content: "↓"; opacity: 1; }
table.data td { padding: 0 var(--space-sm); height: var(--c-table-row-height); border-bottom: 1px solid var(--color-border-hairline); white-space: nowrap; vertical-align: middle; }
table.data td.wrap { white-space: normal; min-width: 16rem; padding-top: 4px; padding-bottom: 4px; line-height: 1.35; }
table.data .r { text-align: right; }
table.data td.r, table.data td.num { font-family: var(--font-data); font-variant-numeric: tabular-nums; }
table.data tbody tr:hover { background: var(--color-bg-hover); }
table.data tbody tr.clickable { cursor: pointer; }
table.data tbody tr.is-muted td { color: var(--color-text-muted); }
table.data td a { text-decoration: none; }
table.data td a:hover { text-decoration: underline; }
table.data .sticky-col { position: sticky; left: 0; background: var(--color-bg-surface); z-index: 1; }
table.data tbody tr:hover .sticky-col { background: var(--color-bg-hover); }
table.data th.sticky-col { z-index: 2; background: var(--color-bg-strip); }
.id-link { font-family: var(--font-data); font-weight: 500; }

/* ---------- chips, glyphs, tags ---------- */
.chip { display: inline-flex; align-items: center; gap: 4px; font-family: var(--font-data); font-size: var(--text-micro); letter-spacing: 0.04em; padding: 1px 6px; border: 1px solid var(--color-border-strong); border-radius: var(--radius-control); color: var(--color-text-secondary); white-space: nowrap; line-height: 1.5; }
.chip.solid { background: var(--color-text-primary); border-color: var(--color-text-primary); color: var(--color-text-inverse); font-weight: 600; }
.glyph { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.glyph::before { content: ""; width: 8px; height: 8px; flex: none; }
.glyph.good::before { background: var(--color-status-good); border-radius: 50%; }
.glyph.warning::before { width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-bottom: 9px solid var(--color-status-warning); }
.glyph.serious::before { background: var(--color-status-serious); transform: rotate(45deg) scale(0.85); }
.glyph.critical::before { background: var(--color-status-critical); }
.glyph.info::before { border: 1.5px solid var(--color-text-secondary); border-radius: 50%; width: 7px; height: 7px; }
.glyph.neutral::before { background: var(--color-text-muted); border-radius: 50%; }
.glyph.off::before { border: 1.5px solid var(--color-text-muted); border-radius: 50%; width: 7px; height: 7px; }
.prov { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.prov::before { content: ""; width: 10px; height: 3px; background: var(--swatch, var(--color-series-nonai)); flex: none; }
.prov.claude { --swatch: var(--color-series-claude); } .prov.codex { --swatch: var(--color-series-codex); } .prov.grok { --swatch: var(--color-series-grok); }
.sw { display: inline-block; width: 10px; height: 10px; background: var(--swatch, var(--color-series-nonai)); flex: none; }
.sw.claude { --swatch: var(--color-series-claude); } .sw.codex { --swatch: var(--color-series-codex); } .sw.grok { --swatch: var(--color-series-grok); }
.legend { display: flex; gap: var(--space-md); flex-wrap: wrap; font-size: var(--text-data); color: var(--color-text-secondary); align-items: center; }
.legend span { display: inline-flex; gap: 5px; align-items: center; }

/* stage ladder */
.ladder { display: inline-flex; gap: 2px; align-items: center; vertical-align: middle; }
.ladder i { width: 10px; height: 6px; border: 1px solid var(--color-border-strong); }
.ladder i.on { background: var(--color-text-secondary); border-color: var(--color-text-secondary); }
.ladder i.cur { background: var(--color-text-primary); border-color: var(--color-text-primary); }
.ladder-lg { display: flex; gap: 2px; flex-wrap: wrap; }
.ladder-lg span { font-family: var(--font-data); font-size: var(--text-micro); padding: 2px 6px; border: 1px solid var(--color-border-strong); color: var(--color-text-muted); white-space: nowrap; }
.ladder-lg span.on { color: var(--color-text-secondary); border-color: var(--color-text-muted); }
.ladder-lg span.cur { background: var(--color-text-primary); color: var(--color-text-inverse); border-color: var(--color-text-primary); font-weight: 600; }

/* dimension strip */
.dims { display: inline-flex; align-items: center; gap: 6px; vertical-align: middle; }
.dims .n { font-family: var(--font-data); font-weight: 600; min-width: 1.75em; font-size: var(--text-data); }
.dims .cells { display: inline-flex; gap: 1px; align-items: center; }
.dims .cells i { width: 5px; height: 12px; border: 1px solid var(--c-dimstrip-cell-off); display: block; }
.dims .cells i.on { background: var(--c-dimstrip-cell-on); border-color: var(--c-dimstrip-cell-on); }
.dims .cells i.new { background: var(--c-dimstrip-cell-new); border-color: var(--c-dimstrip-cell-new); }
.dims .cells b { width: 4px; }
.dims.lg .cells i { width: 12px; height: 18px; }
.dims.lg .n { font-size: var(--text-h2); }
.dimgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: 2px; }
.dimgrid span { font-family: var(--font-data); font-size: var(--text-micro); padding: 3px 6px; border: 1px solid var(--color-border-hairline); color: var(--color-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dimgrid span.on { color: var(--color-text-inverse); background: var(--color-text-primary); border-color: var(--color-text-primary); font-weight: 600; }
.dimgrid span.new { color: var(--color-text-inverse); background: var(--color-seq-4); border-color: var(--color-seq-4); font-weight: 600; }
.dimgrid .mech { border-style: dashed; }

/* bar list */
.bars { display: grid; gap: 4px; }
.bar-row { display: grid; grid-template-columns: minmax(6rem, 11rem) 1fr minmax(3.5rem, auto); gap: var(--space-sm); align-items: center; font-size: var(--text-data); }
.bar-row .lbl { color: var(--color-text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; gap: 5px; align-items: center; }
.bar-row .track { height: 12px; position: relative; }
.bar-row .fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--bar, var(--color-text-secondary)); border-radius: 0 3px 3px 0; min-width: 1px; }
.bar-row .val { font-family: var(--font-data); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.bar-row.is-active .lbl { color: var(--color-text-primary); font-weight: 600; }
button.bar-row { all: unset; display: grid; grid-template-columns: minmax(6rem, 11rem) 1fr minmax(3.5rem, auto); gap: var(--space-sm); align-items: center; font-size: var(--text-data); cursor: pointer; padding: 2px 0; }
button.bar-row:hover { background: var(--color-bg-hover); }
button.bar-row:focus-visible { outline: 2px solid var(--color-border-focus); outline-offset: 2px; }

/* charts */
.chart-fig { margin: 0; display: grid; gap: var(--space-xs); min-width: 0; }
.chart { width: 100%; position: relative; }
.chart svg { display: block; overflow: visible; }
.chart text { font-family: var(--font-data); font-size: 10.5px; fill: var(--color-text-muted); }
.chart .grid-line { stroke: var(--color-border-hairline); stroke-width: 1; }
.chart .axis-line { stroke: var(--color-border-strong); stroke-width: 1; }
.chart .endlbl { fill: var(--color-text-secondary); font-size: 11px; }
.chart .xhair { stroke: var(--color-text-muted); stroke-width: 1; }
.chart-cap { display: flex; justify-content: space-between; gap: var(--space-sm); align-items: center; flex-wrap: wrap; }
.chart-table { max-height: 16rem; overflow: auto; }
.tooltip { position: fixed; z-index: 80; pointer-events: none; background: var(--color-bg-strip); border: 1px solid var(--color-border-strong); padding: var(--space-xs) var(--space-sm); font-family: var(--font-data); font-size: var(--text-data); color: var(--color-text-primary); max-width: 22rem; white-space: pre-line; line-height: 1.45; }
.spark { vertical-align: middle; }

/* heatmaps */
.hm { display: grid; gap: 1px; }
.hm.dense { column-gap: 0; row-gap: 3px; }
.hm .cell.ok { background: var(--color-border-strong); outline: 0; }
.hm .cell { min-height: 10px; background: var(--color-bg-page); outline: 1px solid var(--color-border-hairline); outline-offset: -1px; }
.hm .cell.s1 { background: var(--color-seq-1); outline: 0; } .hm .cell.s2 { background: var(--color-seq-2); outline: 0; } .hm .cell.s3 { background: var(--color-seq-3); outline: 0; } .hm .cell.s4 { background: var(--color-seq-4); outline: 0; } .hm .cell.s5 { background: var(--color-seq-5); outline: 0; }
.hm .cell.gap { background: repeating-linear-gradient(135deg, var(--color-status-critical) 0 2px, transparent 2px 5px); outline: 1px solid var(--color-status-critical); outline-offset: -1px; }
.hm .cell.tried { background: repeating-linear-gradient(135deg, var(--color-border-strong) 0 1px, transparent 1px 5px); }
.hm-row { display: contents; }
.hm-lbl { font-family: var(--font-data); font-size: var(--text-micro); color: var(--color-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; align-self: center; }
.scale { display: inline-flex; gap: 1px; align-items: center; font-size: var(--text-micro); color: var(--color-text-muted); font-family: var(--font-data); }
.scale i { width: 16px; height: 8px; display: block; }
.niche { display: grid; gap: 2px; }
.niche a, .niche span.cell { display: flex; align-items: center; justify-content: center; min-height: 2.25rem; font-family: var(--font-data); font-size: var(--text-micro); text-decoration: none; }
.niche a.s1, .niche a.s2 { color: var(--color-text-primary); } .niche a.s3, .niche a.s4, .niche a.s5 { color: var(--color-text-inverse); font-weight: 600; }
.niche .s1 { background: var(--color-seq-1); } .niche .s2 { background: var(--color-seq-2); } .niche .s3 { background: var(--color-seq-3); } .niche .s4 { background: var(--color-seq-4); } .niche .s5 { background: var(--color-seq-5); }
.niche span.cell { outline: 1px solid var(--color-border-hairline); outline-offset: -1px; color: var(--color-text-muted); }
.niche span.cell.tried { background: repeating-linear-gradient(135deg, var(--color-border-strong) 0 1px, transparent 1px 6px); }
.niche .ax { font-family: var(--font-data); font-size: var(--text-micro); color: var(--color-text-muted); display: flex; align-items: center; justify-content: center; }

/* lineage */
.lineage { position: relative; overflow-x: auto; }
.lineage-canvas { position: relative; }
.lineage svg { position: absolute; inset: 0; }
.lineage svg path { fill: none; stroke: var(--color-border-strong); stroke-width: 1.5; }
.lineage svg text { font-family: var(--font-data); font-size: 10px; fill: var(--color-text-muted); }
.lnode { position: absolute; width: 11rem; min-height: 3rem; padding: 4px 8px; background: var(--color-bg-strip); border: 1px solid var(--color-border-strong); text-decoration: none; display: grid; gap: 1px; font-size: var(--text-data); }
.lnode:hover { border-color: var(--color-text-secondary); }
.lnode.focus { border: 2px solid var(--color-text-primary); background: var(--color-bg-hover); }
.lnode .t { display: flex; justify-content: space-between; gap: 4px; font-family: var(--font-data); font-weight: 600; }
.lnode .s { color: var(--color-text-muted); font-family: var(--font-data); font-size: var(--text-micro); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lnode.failed .t { color: var(--color-text-secondary); text-decoration: line-through; text-decoration-color: var(--color-text-muted); }

/* gantt */
.gantt { display: grid; gap: 3px; }
.gantt-row { display: grid; grid-template-columns: 8rem 1fr 6rem; gap: var(--space-sm); align-items: center; font-size: var(--text-data); }
.gantt-row .track { position: relative; height: 12px; }
.gantt-row .seg { position: absolute; top: 0; bottom: 0; background: var(--color-text-secondary); border-radius: 0 2px 2px 0; }
.gantt-row .seg.running { background: var(--color-text-primary); }
.gantt-row .seg.failed { background: var(--color-status-critical); }

/* feed */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: grid; grid-template-columns: 4.25rem minmax(0, 1fr); gap: var(--space-sm); padding: 6px var(--space-md); border-bottom: 1px solid var(--color-border-hairline); font-size: var(--text-data); align-items: baseline; }
.feed li:last-child { border-bottom: 0; }
.feed .t { font-family: var(--font-data); color: var(--color-text-muted); white-space: nowrap; }
.feed .ttl { color: var(--color-text-primary); }
.feed .d { color: var(--color-text-secondary); display: block; margin-top: 1px; }
.feed .actor { font-family: var(--font-data); font-size: var(--text-micro); color: var(--color-text-muted); margin-left: 6px; text-transform: uppercase; letter-spacing: 0.05em; }
.feed a { text-decoration: none; }
.feed a:hover .ttl { text-decoration: underline; }

/* alerts */
.alerts { list-style: none; margin: 0; padding: 0; }
.alerts li { border-bottom: 1px solid var(--color-border-hairline); }
.alerts li:last-child { border-bottom: 0; }
.alerts a, .alerts .a { display: grid; grid-template-columns: 1rem minmax(0, 1fr) auto; gap: var(--space-sm); padding: 7px var(--space-md); text-decoration: none; align-items: start; }
.alerts a:hover { background: var(--color-bg-hover); }
.alerts .ttl { font-weight: 600; }
.alerts .d { color: var(--color-text-secondary); font-size: var(--text-data); display: block; margin-top: 1px; }
.alerts .age { font-family: var(--font-data); font-size: var(--text-micro); color: var(--color-text-muted); white-space: nowrap; padding-top: 2px; }
.alerts .glyph { padding-top: 4px; }

/* cards (approvals) */
.card { background: var(--color-bg-surface); border: 1px solid var(--color-border-hairline); }
.card-head { display: flex; justify-content: space-between; gap: var(--space-md); flex-wrap: wrap; align-items: center; padding: var(--space-md); border-bottom: 1px solid var(--color-border-hairline); background: var(--color-bg-strip); }
.card-head h2 { font-size: 1.125rem; font-weight: 600; }
.card-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(15rem, 100%), 1fr)); }
.card-cols > section { padding: var(--space-md); border-right: 1px solid var(--color-border-hairline); border-bottom: 1px solid var(--color-border-hairline); min-width: 0; }
.card-cols h3 { font-size: var(--text-micro); letter-spacing: 0.1em; text-transform: uppercase; color: var(--color-text-muted); font-weight: 600; margin-bottom: var(--space-sm); }
.card-foot { display: flex; justify-content: space-between; gap: var(--space-md); flex-wrap: wrap; align-items: center; padding: var(--space-md); }
.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; font-size: var(--text-data); }
.checklist li { display: grid; grid-template-columns: 1.1rem 1fr auto; gap: 4px; align-items: baseline; }
.checklist .ok { color: var(--color-status-good); font-weight: 700; }
.checklist .no { color: var(--color-text-danger); font-weight: 700; }
.checklist .na { color: var(--color-text-muted); }
.blockers { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.blockers li { font-size: var(--text-data); }

/* meters */
.meter { display: grid; gap: 3px; }
.meter .top { display: flex; justify-content: space-between; font-size: var(--text-data); gap: var(--space-sm); }
.meter .track { height: 6px; background: var(--color-border-hairline); position: relative; }
.meter .fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--color-text-secondary); }
.meter .fill.trip { background: var(--color-status-warning); }
.meter .mark { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--color-text-primary); }

/* empty / error / skeleton */
.empty { padding: var(--space-xl) var(--space-lg); display: grid; gap: var(--space-sm); justify-items: start; max-width: 60ch; }
.empty h3 { font-size: 1rem; font-weight: 600; }
.empty p { color: var(--color-text-secondary); }
.err-box { padding: var(--space-md); border-left: 3px solid var(--color-status-critical); display: grid; gap: var(--space-sm); justify-items: start; }
.sk { display: block; height: 10px; background: var(--color-bg-hover); margin: 9px 0; }
.sk.w40 { width: 40%; } .sk.w60 { width: 60%; } .sk.w80 { width: 80%; }
.is-stale .num, .is-stale .value { color: var(--color-text-muted); }
.flash { text-decoration: underline; text-decoration-color: var(--color-text-primary); text-decoration-thickness: 2px; animation: flash var(--motion-flash) ease-out; }
@keyframes flash { from { text-decoration-color: var(--color-text-primary); } to { text-decoration-color: transparent; } }

/* filter bar */
.filters { display: flex; gap: var(--space-sm); flex-wrap: wrap; align-items: end; padding: var(--space-sm) var(--space-md); border-bottom: 1px solid var(--color-border-hairline); }
.filters .field { gap: 2px; }
.filters .field > label { font-size: var(--text-micro); text-transform: uppercase; letter-spacing: 0.06em; color: var(--color-text-muted); }
.filters input, .filters select { min-height: 1.875rem; font-size: var(--text-data); }
.filters input[type="search"] { min-width: 12rem; }
.filters input[type="number"] { width: 5rem; }
.pager { display: flex; gap: var(--space-sm); align-items: center; }

/* code */
pre.code { margin: 0; padding: var(--space-md); background: var(--color-bg-page); border: 1px solid var(--color-border-hairline); font-size: var(--text-data); line-height: 1.55; overflow: auto; max-height: 36rem; color: var(--color-text-secondary); white-space: pre; }
pre.rules { white-space: pre; color: var(--color-text-primary); }

/* dialogs */
dialog { background: var(--color-bg-surface); color: var(--color-text-primary); border: 1px solid var(--color-border-strong); padding: 0; width: min(34rem, calc(100vw - 2rem)); max-height: calc(100dvh - 2rem); }
dialog.wide { width: min(46rem, calc(100vw - 2rem)); }
dialog::backdrop { background: var(--color-bg-scrim); }
.dlg-head { padding: var(--space-md) var(--space-lg); border-bottom: 1px solid var(--color-border-hairline); background: var(--color-bg-strip); display: flex; justify-content: space-between; align-items: center; gap: var(--space-md); }
.dlg-head h2 { font-size: 1.125rem; font-weight: 600; }
.dlg-body { padding: var(--space-lg); display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-md); }
.dlg-body .field { min-width: 0; grid-template-columns: minmax(0, 1fr); }
.dlg-body select { width: 100%; min-width: 0; }
.dlg-foot { padding: var(--space-md) var(--space-lg); border-top: 1px solid var(--color-border-hairline); display: flex; justify-content: flex-end; gap: var(--space-sm); flex-wrap: wrap; }
.consequence { border-left: 3px solid var(--color-status-warning); padding: var(--space-sm) var(--space-md); background: var(--color-bg-page); }
.consequence.danger { border-left-color: var(--color-status-critical); }
.jump-results { list-style: none; margin: 0; padding: 0; max-height: 50dvh; overflow: auto; }
.jump-results li { display: flex; justify-content: space-between; gap: var(--space-md); padding: 6px var(--space-lg); cursor: pointer; min-height: 2rem; align-items: center; }
.jump-results li[aria-selected="true"], .jump-results li:hover { background: var(--color-bg-hover); }
.jump-results li[aria-selected="true"] { box-shadow: inset 2px 0 0 var(--color-text-primary); }
.jump-results .k { font-family: var(--font-data); font-size: var(--text-micro); color: var(--color-text-muted); text-transform: uppercase; }

/* toasts */
.toasts { position: fixed; right: var(--space-lg); bottom: var(--space-lg); z-index: 90; display: grid; gap: var(--space-sm); width: min(26rem, calc(100vw - 2rem)); }
.toast { background: var(--color-bg-strip); border: 1px solid var(--color-border-strong); border-left: 3px solid var(--color-status-good); padding: var(--space-sm) var(--space-md); display: flex; gap: var(--space-md); justify-content: space-between; align-items: center; font-size: var(--text-body); }
.toast.error { border-left-color: var(--color-status-critical); }
.toast.warning { border-left-color: var(--color-status-warning); }

/* ---------- responsive ---------- */
@media (max-width: 80em) {
  .span-2 { grid-column: span 3; } .span-3 { grid-column: span 6; } .span-4 { grid-column: span 6; } .span-5 { grid-column: span 6; } .span-7 { grid-column: span 12; } .span-8 { grid-column: span 12; } .span-9 { grid-column: span 12; }
  .span-6.keep, .span-4.keep, .span-3.keep { grid-column: span 6; }
}
@media (max-width: 64em) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail { position: fixed; top: 0; left: 0; bottom: 0; z-index: 60; width: min(18rem, 85vw); height: 100dvh; transform: translateX(-102%); visibility: hidden; transition: transform var(--motion-fast) var(--motion-ease); border-right: 1px solid var(--color-border-strong); background: var(--color-bg-surface); padding-top: var(--space-lg); }
  .rail.open { transform: none; visibility: visible; }
  .rail-scrim { position: fixed; inset: 0; background: var(--color-bg-scrim); z-index: 55; }
  .runbar .rb-menu { display: inline-flex; }
  .rb-brand { display: none; }
  .rb-meta { display: none; width: 100%; order: 10; }
  .runbar.more .rb-meta { display: flex; }
  .runbar .rb-more { display: inline-flex; }
  .rb-phase { order: 9; flex-basis: 100%; }
  main { padding: var(--space-md) var(--space-md) var(--space-xxl); }
  .grid > * { grid-column: span 12 !important; }
  .grid > .half { grid-column: span 6 !important; }
}
@media (max-width: 40em) {
  .page-head h1 { font-size: var(--text-h2); }
  .bar-row, button.bar-row { grid-template-columns: minmax(5rem, 8rem) 1fr minmax(3rem, auto); }
  .toasts { left: var(--space-md); right: var(--space-md); bottom: calc(var(--space-md) + env(safe-area-inset-bottom)); width: auto; }
  .gantt-row { grid-template-columns: 6rem 1fr 4.5rem; }
  .filters input[type="search"] { min-width: 0; width: 100%; }
  .filters .field.grow { flex: 1 1 100%; }
  .card-foot .btn { flex: 1 1 auto; }
}
@media (pointer: coarse) {
  .btn { min-height: var(--c-button-height-touch); }
  table.data td { height: var(--c-table-row-height-touch); }
  .rail a, .rail button.rail-btn { min-height: 2.75rem; }
  .tabs [role="tab"] { min-height: 2.75rem; }
  .segmented button { min-height: 2.5rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
  .flash { text-decoration: none; }
}
@media (forced-colors: active) {
  .step.done, .step.active > i, .dims .cells i.on, .hm .cell[class*="s"] { forced-color-adjust: none; }
}
