/* AMP board — Atoti design system tokens (antd compact algorithm). */
:root {
  --primary: #7391d9;
  --primary-tint: #eef2fa;
  --primary-hover: #8ea6df;
  --deep: #291a40;

  --gray-1: #272727;
  --gray-2: #414141;
  --gray-3: #5a5a5a;
  --gray-4: #747474;
  --gray-5: #a7a7a7;
  --gray-6: #dbdbdb;
  --gray-7: #f4f4f4;
  --gray-8: #fff;

  --ink: var(--gray-1);
  --muted: var(--gray-3);
  --faint: var(--gray-4);
  --border: #d9d9d9;
  --divider: var(--gray-7);
  --field: var(--gray-7);
  --surface: var(--gray-8);

  /* Small text on white never uses --primary (3.1:1). --link is 8.6:1. */
  --link: #1d4ed8;

  --ok-bg: #f6ffed; --ok-text: #237804; --ok-border: #b7eb8f;   /* 5.44:1 */
  --warn-bg: #fffbe6; --warn-text: #874d00; --warn-border: #ffe58f; /* 6.53:1 */
  --err-bg: #fff1f0; --err-text: #cf1322; --err-border: #ffa39e;   /* 5.07:1 */
  --neutral-bg: var(--gray-7); --neutral-text: var(--gray-3); --neutral-border: var(--gray-6);

  --radius: 2px;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "Roboto Mono", ui-monospace, Menlo, Consolas, monospace;

  --shell-pad: 12px;
}

* { box-sizing: border-box; }

/* `hidden` must win. Component rules set `display`, which otherwise beats the browser's
   [hidden] default — and the element that gets hidden here is the "Demo data" badge, so
   losing that fight puts a synthetic-data label on a live board. */
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  color: var(--ink);
  background: var(--field);
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: #1a45be; }  /* 7.96:1 — #8EA6DF would be 2.42:1 */

:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }

.mono { font-family: var(--mono); }

.skip-link {
  position: fixed; z-index: 20; left: 8px; top: -4rem;
  padding: 8px 12px; background: var(--deep); color: #fff;
  border-radius: var(--radius); text-decoration: none;
}
.skip-link:focus { top: 8px; }

.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); }

/* ------------------------------------------------------------------ shell */

/* body is the flex shell; #page-chrome must stretch to fill its remaining
   height and be a flex column itself so header/main/footer can lay out. */
#page-chrome {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
}

.app-header {
  flex: 0 0 auto;
  height: 40px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 var(--shell-pad);
  background: var(--gray-7);
  border-bottom: 1px solid var(--gray-6);
}
.app-brand { display: flex; align-items: center; flex: 0 0 auto; }
.app-brand img { height: 20px; width: auto; display: block; }

.section-menu { display: flex; align-items: center; gap: 4px; margin: 0; padding: 0; list-style: none; }
.section-menu a {
  display: block; padding: 3px 8px; border-radius: var(--radius);
  color: var(--gray-3); font-size: 12px; text-decoration: none;
}
.section-menu a[aria-current="page"] { background: var(--primary-tint); color: var(--primary); font-weight: 500; }
.section-menu a[aria-disabled="true"] { color: var(--faint); cursor: not-allowed; }
a.app-brand[aria-disabled="true"] { cursor: not-allowed; opacity: 0.4; }
/* One note for the whole header, not one per link — see `ensureReasonNote`. `--muted` not
   the link's inherited `--faint`: at this size #747474 on the #f4f4f4 header is 4.25:1,
   under AA for small text (Codex P2). */
.unavailable-note { font-size: 11px; margin-left: 8px; vertical-align: middle; color: var(--muted); flex: 0 1 auto; min-width: 0; }

.app-title {
  flex: 1 1 auto; min-width: 0; margin: 0;
  color: var(--gray-3); font-size: 12px; font-weight: 400; text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.app-header-end { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 600;
}

.control-strip {
  flex: 0 0 auto;
  min-height: 44px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 8px var(--shell-pad);
  background: var(--surface);
  border-bottom: 1px solid var(--gray-6);
}
.control-strip label { display: flex; align-items: center; gap: 8px; color: var(--gray-3); font-size: 12px; }
.control-strip select {
  height: 28px; padding: 4px 11px;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  font: inherit; font-size: 13px;
}
.control-strip select:hover:enabled { border-color: var(--primary-hover); }
.control-strip select:disabled { color: var(--faint); background: var(--field); }
#selection-status { margin: 0 0 0 auto; color: var(--gray-4); font: 11px/1.4 var(--mono); }

main { flex: 1 1 auto; width: 100%; padding: 16px var(--shell-pad) 24px; }

.brand-signature {
  flex: 0 0 auto;
  height: 28px;
  display: flex; align-items: center; gap: 8px;
  padding: 0 var(--shell-pad);
  background: var(--gray-7);
  border-top: 1px solid var(--gray-6);
  color: var(--gray-3); font-size: 11px;
}
.brand-signature img { height: 14px; width: auto; display: block; opacity: .8; }

/* ------------------------------------------------------------------- tags */

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 0 7px; height: 20px;
  border: 1px solid var(--neutral-border); border-radius: var(--radius);
  background: var(--neutral-bg); color: var(--neutral-text);
  font-size: 12px; line-height: 18px; white-space: nowrap;
}
.tag--ok { background: var(--ok-bg); color: var(--ok-text); border-color: var(--ok-border); }
.tag--warn { background: var(--warn-bg); color: var(--warn-text); border-color: var(--warn-border); }
.tag--err { background: var(--err-bg); color: var(--err-text); border-color: var(--err-border); }
/* Design-system pair, kept as specified: #7391D9 on #EEF2FA measures 2.76:1.
   It is never the only carrier of meaning — the tag always states its word. */
.tag--primary { background: var(--primary-tint); color: var(--primary); border-color: var(--primary); }

.tag .icon { width: 12px; height: 12px; }

.notice-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.notice { max-width: 100%; white-space: normal; height: auto; padding: 2px 7px; }

.icon { width: 16px; height: 16px; vertical-align: -.2em; }
.icon-external { width: 12px; height: 12px; margin-left: 4px; }

/* ------------------------------------------------------------------ board */

.board-view { display: flex; flex-direction: column; gap: 12px; }
.board-title { margin: 0; font-size: 16px; font-weight: 500; line-height: 1.4; color: var(--ink); }

.panel {
  min-width: 0;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.panel-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 12px; padding-bottom: 8px;
  border-bottom: 1px solid var(--divider);
}
.panel-head h2 { margin: 0; font-size: 14px; font-weight: 600; color: var(--ink); }
.panel-head > p { margin: 0 0 0 auto; color: var(--gray-4); font-size: 12px; }
.panel-status { margin: 0 0 12px; color: var(--muted); font-size: 12px; }
.panel-status strong { color: var(--ink); }

.focus-target:focus { outline: 2px solid var(--primary); outline-offset: -2px; }

.summary-section { min-width: 0; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 8px; }
.card {
  display: flex; flex-direction: column; min-width: 0;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.card-label { font-size: 13px; font-weight: 600; line-height: 1.35; }
.card-source { margin-top: 2px; color: var(--gray-4); font-size: 11px; }
.card-source a { font-size: 11px; }
.card-value {
  display: block; margin: 8px 0 6px;
  font-family: var(--mono); font-size: 28px; font-weight: 500; line-height: 1.1;
  color: var(--ink); overflow-wrap: anywhere;
}
.card-value[data-figure="false"] { font-size: 18px; font-family: var(--sans); font-weight: 600; }
.card .tag { align-self: flex-start; }
.card-reason { margin: 8px 0 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
.card-detail { margin: 6px 0 0; color: var(--gray-4); font-size: 12px; line-height: 1.4; }
.card-supporting { margin: 8px 0 0; padding-top: 8px; border-top: 1px solid var(--divider); font-family: var(--mono); font-size: 11px; }
.card-supporting div { display: flex; justify-content: space-between; gap: 8px; margin: 4px 0; }
.card-supporting dt { color: var(--gray-4); }
.card-supporting dd { margin: 0; text-align: right; color: var(--ink); }
.card-supporting dd span { display: block; color: var(--gray-4); font-size: 10px; }
.evidence-action {
  align-self: flex-start; margin-top: auto; padding: 8px 4px 2px;
  color: var(--link); background: none; border: 0; cursor: pointer;
  font: inherit; font-size: 12px; font-weight: 600;
}
.evidence-action:hover { text-decoration: underline; }

/* ----------------------------------------------------------------- sankey */

/* Below ~1120px the labels stop being legible, so the diagram scrolls in its
   own container rather than shrinking the type or letting the page scroll. */
.sankey-scroll { overflow-x: auto; overflow-y: hidden; }
.sankey-scroll:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.sankey { display: block; width: 100%; min-width: 1120px; height: auto; }
.sk-node { fill: var(--primary); }
.sk-node--drop { fill: var(--gray-5); }
.sk-flow { fill: rgba(115, 145, 217, .32); }
.sk-drop { fill: rgba(167, 167, 167, .42); }
.sk-stage { font: 500 12px var(--sans); fill: var(--gray-2); }
.sk-count { font: 400 16px var(--mono); fill: var(--ink); }
.sk-share { font: 400 12px var(--mono); fill: var(--link); }
.sk-share--state { font: 400 11px var(--sans); fill: var(--gray-4); }
.sk-drop-label { font: 500 12px var(--sans); fill: var(--gray-3); }
.sk-drop-count { font: 400 11px var(--mono); fill: var(--gray-4); }

.sk-legend {
  display: flex; flex-wrap: wrap; gap: 8px 20px;
  margin: 12px 0 0; padding: 0; list-style: none;
  color: var(--muted); font-size: 12px;
}
.sk-legend li { display: flex; align-items: center; gap: 8px; }
.sk-swatch { width: 14px; height: 10px; border-radius: var(--radius); }
.sk-swatch--flow { background: rgba(115, 145, 217, .32); border: 1px solid var(--primary); }
.sk-swatch--drop { background: rgba(167, 167, 167, .42); border: 1px solid var(--gray-5); }
.sk-note { margin: 8px 0 0; color: var(--gray-4); font-size: 12px; line-height: 1.45; }

.stage-list { margin: 0; padding: 0; list-style: none; }
.stage-row {
  display: grid; grid-template-columns: minmax(0, 1fr) 96px 120px auto;
  align-items: center; gap: 12px;
  padding: 8px 0; border-bottom: 1px solid var(--divider);
}
.stage-name { font-size: 13px; }
.stage-value { font-family: var(--mono); font-size: 16px; text-align: right; }
.stage-value[data-figure="false"] { font-family: var(--sans); font-size: 12px; color: var(--gray-4); }
.stage-no-ratio { color: var(--gray-4); font-size: 11px; }

.count-bar { display: block; height: 8px; background: var(--gray-7); border-radius: var(--radius); overflow: hidden; }
/* An unmeasured stage gets no bar at all, not an empty track that reads as zero. */
.stage-row .count-bar:empty { background: none; }
.count-bar-fill { display: block; height: 100%; background: var(--primary); }

/* ---------------------------------------------------------------- outcome */

.analysis-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: 12px; align-items: start; }

.outcome-list { border-top: 1px solid var(--divider); }
.outcome-row {
  display: grid; grid-template-columns: minmax(0, 1fr) 100px 40px 64px;
  align-items: center; gap: 12px;
  padding: 6px 0; border-bottom: 1px solid var(--divider);
}
.outcome-label { font-size: 13px; overflow-wrap: anywhere; }
.outcome-count { font-family: var(--mono); font-size: 13px; text-align: right; }
.outcome-share { font-family: var(--mono); font-size: 13px; text-align: right; }
.outcome-share[data-figure="false"] { font-family: var(--sans); font-size: 11px; color: var(--gray-4); line-height: 1.25; }
.outcome-row[data-zero="true"] { color: var(--gray-4); }
.outcome-row[data-zero="true"] .count-bar-fill { background: var(--gray-5); }

.absence-list { margin: 0; }
.absence-row { display: grid; grid-template-columns: 128px minmax(0, 1fr); gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--divider); }
.absence-row:last-child { border-bottom: 0; }
.absence-row dt { margin: 0; }
.absence-row dd { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.45; }

/* --------------------------------------------------------------- adoption */

.adoption-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 8px; }
.adoption-figure { padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); }
.adoption-label { display: block; color: var(--gray-4); font-size: 12px; }
.adoption-value { display: block; margin: 6px 0; font: 500 28px/1.1 var(--mono); overflow-wrap: anywhere; }
.adoption-value[data-figure="false"] { font-family: var(--sans); font-size: 18px; font-weight: 600; }
.repo-list { margin: 12px 0 0; }
.repo-list-label { display: block; color: var(--gray-4); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.repo-list .mono { font-size: 12px; overflow-wrap: anywhere; }

.limitation {
  margin: 12px 0 0; padding: 8px 12px;
  color: var(--muted); background: var(--gray-7);
  border-left: 2px solid var(--gray-5);
  font-size: 12px; line-height: 1.45;
}

/* -------------------------------------------------------------- evidence */

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  padding: 6px 12px;
  color: var(--gray-3); background: var(--gray-7);
  border-bottom: 1px solid var(--border);
  text-align: left; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em;
}
td { padding: 6px 12px; border-bottom: 1px solid var(--divider); font-size: 13px; vertical-align: top; }
th.num, td.num { text-align: right; font-family: var(--mono); }
.subvalue, .demo-evidence {
  display: block; margin-top: 2px;
  color: var(--gray-4); font-family: var(--sans); font-size: 11px; line-height: 1.35;
  font-weight: 400; text-align: left;
}
td.num .subvalue { text-align: right; }
.demo-evidence { color: var(--link); }
.no-run-record { color: var(--gray-4); }
.empty-inline { display: grid; gap: 4px; padding: 24px; color: var(--muted); background: var(--gray-7); text-align: center; }
.empty-inline strong { color: var(--ink); }

/* ------------------------------------------------------------ provenance */

.provenance {
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.provenance dl { display: flex; flex-wrap: wrap; gap: 8px 32px; margin: 0; }
.provenance dt { color: var(--gray-4); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.provenance dd { margin: 2px 0 0; color: var(--ink); font-family: var(--mono); font-size: 12px; overflow-wrap: anywhere; }

/* ------------------------------------------------------------ page state */

.page-state {
  min-height: 260px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 32px; text-align: center;
}
.page-state > strong { margin-top: 8px; font-size: 16px; font-weight: 600; color: var(--ink); }
.page-state > span:not(.tag) { color: var(--muted); font-size: 13px; }
.button {
  height: 28px; padding: 0 15px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
  font: inherit; font-size: 13px; cursor: pointer;
}
/* #4F6FBF keeps the primary hue and carries white text at 4.82:1. */
.button--primary { background: #4f6fbf; border-color: #4f6fbf; color: #fff; }
.button--primary:hover { background: #415da6; border-color: #415da6; }
.page-state .button { margin-top: 8px; }

/* ------------------------------------------------------------------ queue */

.queue-view { display: flex; flex-direction: column; gap: 12px; }
.queue-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  margin: 0; color: var(--gray-4); font: 11px/1.4 var(--mono);
}
.queue-meta-sep { color: var(--faint); }
.store-label { color: var(--gray-4); font-size: 11px; font-style: italic; }

.flow-recordless-note { margin: 4px 0 0; color: var(--muted); font-size: 11px; line-height: 1.4; }
.flow-fields { display: flex; flex-direction: column; gap: 4px; margin: 6px 0 0; }
.flow-field { display: flex; flex-direction: column; gap: 1px; }
.flow-field-label { color: var(--gray-4); font-size: 10px; line-height: 1.3; }
.flow-field-value { font-family: var(--mono); font-size: 12px; color: var(--ink); }
.flow-field-value--absent { color: var(--gray-4); font-style: italic; }
/* A caveat is not provenance. `.store-label` is the quietest text on the page by design, which
   is the wrong register for a sentence the operator has to read to interpret the value above it. */
.flow-field-note { display: block; margin-top: 2px; color: var(--ink); font-size: 11px; line-height: 1.4; }

/* .tag-gap: dashed-border pill for an absence or an ambiguity the records cannot settle — the
   rounds-absence chips and every flag. Since AMP-227 deleted the legend, and AMP-231 deleted
   the three-region/tcard board this used to sit inside, it is the page's only remaining visual
   claim vocabulary, and it is deliberately the weakest one. */
.tag-gap { border-style: dashed !important; }

/* --------------------------------------------------------- queue chrome */

/* AMP-227 deleted the summary strip, legend, explainer, callouts, register and stores table —
   1,323 words of chrome above the cards. AMP-231 then replaced the three-region/tcard board
   those rules served with the five-lane board below (`.queue-lanes`, `.lane-head`, the `.flow-
   card`/`.card-*` rules) — so their own rules are gone with them too. `.tag-gap` stays: the
   dashed pill is still the only visual vocabulary for "the records cannot settle this". */

/* ----------------------------------------------------------- responsive */

@media (max-width: 960px) {
  .analysis-grid { grid-template-columns: 1fr; }
  .app-title { display: none; }
}

@media (max-width: 720px) {
  .app-header { gap: 8px; }
  .control-strip { align-items: stretch; }
  .control-strip label { flex: 1 1 200px; }
  .control-strip select { width: 100%; }
  #selection-status { margin: 0; width: 100%; }
  .stage-row { grid-template-columns: minmax(0, 1fr) 96px; grid-template-areas: "name value" "bar bar" "ratio ratio"; gap: 6px 12px; }
  .stage-name { grid-area: name; }
  .stage-value { grid-area: value; }
  .stage-row .count-bar { grid-area: bar; }
  .stage-row .tag, .stage-no-ratio { grid-area: ratio; justify-self: start; }
}

@media (max-width: 480px) {
  :root { --shell-pad: 8px; }
  .section-menu { gap: 2px; flex-wrap: wrap; }
  .outcome-row { grid-template-columns: minmax(0, 1fr) 40px 64px; }
  .outcome-row .count-bar { display: none; }
  .absence-row { grid-template-columns: 1fr; gap: 4px; }
  .table-scroll { overflow: visible; }
  table, thead, tbody, tr, th, td { display: block; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
  tr { padding: 8px 0; border-bottom: 1px solid var(--border); }
  td, td.num {
    display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 8px;
    padding: 4px 0; border: 0; text-align: left; overflow-wrap: anywhere;
  }
  td.num .subvalue { text-align: left; }
  /* The label is grid child 1; everything after it belongs in the value column. */
  td > .subvalue, td > .demo-evidence, td > .tag { grid-column: 2; justify-self: start; }
  td::before {
    content: attr(data-label);
    color: var(--gray-4); font: 600 10px/1.4 var(--sans);
    text-transform: uppercase; letter-spacing: .04em;
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

@media print {
  /* On paper there is nothing to scroll, so the width floor would simply clip the last lanes.
     Same override the Sankey carries for the same reason (`.queue-lanes` has its own copy of
     this rule further down, beside the rest of the AMP-231 board CSS). */
  body { background: #fff; }
  .control-strip, .evidence-action, .skip-link, .brand-signature { display: none !important; }
  main { padding: 12px 0; }
  .card, .panel { break-inside: avoid; }
  .tag { border: 1px solid #555 !important; color: #111 !important; background: #fff !important; }
  a { color: #111; text-decoration: underline; }
  .sk-share, .demo-evidence { fill: #111; color: #111; }
  /* The 1120px legibility floor exceeds an A4/Letter portrait printable width,
     and a scroll container clips rather than scrolls on paper — the later stages
     would simply be missing from the report. Fit the whole diagram to the page. */
  .sankey-scroll { overflow: visible; }
  .sankey { min-width: 0; }
}

/* ---- Detail drawer ---- */
.drawer-host {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
  /* backdrop click does not close the drawer — use Escape or the close button */
}

.drawer-host::before {
  content: '';
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .35);
}

.drawer-inner {
  position: relative;
  z-index: 1;
  background: var(--surface, #fff);
  width: min(480px, 100vw);
  height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 24px rgba(0,0,0,.15);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface, #fff);
  z-index: 1;
}

.drawer-subject {
  font-weight: 600;
  font-size: .95rem;
  white-space: nowrap;
}

.drawer-close {
  flex-shrink: 0;
  font-size: 1.25rem;
  line-height: 1;
  padding: 2px 8px;
}

.drawer-body {
  flex: 1;
  padding: 16px 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.drawer-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.drawer-section-title {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  margin: 0;
}

.drawer-footer {
  padding-top: 8px;
}

.drawer-flow-link {
  width: 100%;
}

/* Pips for rounds counter */
.drawer-rounds-pips {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.drawer-pip {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1.5px solid var(--gray-5);
  background: transparent;
}

.drawer-pip--filled {
  background: var(--primary, #4f46e5);
  border-color: var(--primary, #4f46e5);
}

.drawer-rounds-count {
  font-variant-numeric: tabular-nums;
  font-size: .85rem;
}

/* Dashed slot — absent data */
.drawer-dashed-slot {
  border: 1.5px dashed var(--gray-6);
  border-radius: 6px;
  padding: 8px 10px;
  background: transparent;
}

.flow-field-value--absent {
  color: var(--muted);
  font-style: italic;
}

/* Flow card open state — ring highlight */
.flow-card--open {
  outline: 2px solid var(--primary, #4f46e5);
  outline-offset: 2px;
}

/* Sibling list */
.drawer-sibling-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.drawer-sibling {
  font-size: .85rem;
  color: var(--ink);
  padding: 4px 0;
  border-bottom: 1px solid var(--divider);
}

/* Header title + actions — Jira and pull request, first thing an operator reaches for */
.drawer-title {
  margin: 0;
  font-size: .85rem;
  color: var(--ink);
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: break-word;
}
.drawer-title--absent {
  color: var(--faint);
  font-style: italic;
}
.drawer-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 12px 20px;
}
.button--disabled {
  color: var(--faint);
  border-style: dashed;
  cursor: default;
}
.drawer-actions .button {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

/* "Where it stands" chips */
.drawer-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* Cost tiles */
.cost-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.cost-tile {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border: 1px solid var(--gray-6);
  border-radius: var(--radius);
}
.cost-l {
  font-size: .7rem;
  color: var(--muted);
}
.cost-v {
  font: 600 15px/1.2 var(--mono);
  color: var(--ink);
}
.cost-v[data-state="floor"] { color: var(--warn-text); }
.cost-n {
  font-size: .7rem;
  color: var(--faint);
}

/* This card's runs */
.runs {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--gray-6);
  border-radius: var(--radius);
}
.run {
  display: grid;
  grid-template-columns: 118px 1fr 70px 60px;
  gap: 8px;
  padding: 7px 10px;
  border-top: 1px solid var(--divider);
  font-size: 12px;
}
.run:first-child { border-top: 0; }
.run-cost {
  text-align: right;
  font-family: var(--mono);
}
.run-cost--absent {
  color: var(--faint);
  font-style: italic;
}

/* ---- Flow view ---- */
.flow-view {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px 20px 24px;
}

.flow-view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.flow-view-title {
  font-weight: 600;
  font-size: .95rem;
  word-break: break-all;
}

.flow-view-meta {
  font-size: .8rem;
  color: var(--muted);
  display: flex;
  gap: 8px;
  align-items: baseline;
  flex-wrap: wrap;
  margin: 0;
}

.flow-view-floor {
  display: flex;
  gap: 12px;
  align-items: baseline;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--field);
  border-radius: 6px;
  border: 1px solid var(--border);
}

.flow-view-floor-label {
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
}

.flow-view-floor-value {
  font-size: 1.05rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.flow-run-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.flow-run {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface, #fff);
}

.flow-run-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
}

.flow-run-id {
  font-size: .8rem;
  font-family: monospace;
  color: var(--muted);
  word-break: break-all;
}

.flow-run-cost {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.flow-view-empty {
  color: var(--muted);
  font-style: italic;
  font-size: .9rem;
}

.flow-view-loading {
  padding: 24px 20px;
  color: var(--muted);
  font-style: italic;
}

/* Management summary: scoped to this page; queue styles remain unchanged. */
.management-header { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 16px 32px; padding: 8px 0 16px; }
.management-header .board-title { font-size: 26px; font-weight: 600; }
.management-eyebrow { margin: 0 0 6px; font-size: 12px; color: var(--muted); }
.management-intro { margin: 8px 0 0; color: var(--muted); font-size: 14px; }
.management-scope { display: flex; flex-wrap: wrap; gap: 16px 28px; margin: 0; align-items: center; }
.management-scope dt { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.management-scope dd { margin: 0; font-size: 13px; overflow-wrap: anywhere; }
.management-scope-note { width: 100%; margin: 0; color: var(--muted); font-size: 12px; }
.review-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.review-measure { min-width: 0; }
.review-measure h3 { margin: 0; font-size: 13px; font-weight: 600; }
.review-measure p { font-size: 12px; color: var(--muted); line-height: 1.5; }
.measurement-guide > summary { cursor: pointer; font-size: 13px; font-weight: 600; }
.measurement-guide > section { margin-top: 16px; border: 0; padding: 0; }
@media (max-width: 680px) { .review-grid { grid-template-columns: 1fr; } .management-scope { gap: 16px; } }
.board-view .card-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 999px) { .board-view .card-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 680px) { .board-view .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 440px) { .board-view .card-grid { grid-template-columns: 1fr; } }
/* ---- lane cards (AMP-231) ---- */
.flow-card { display: flex; flex-direction: column; padding: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 8px; min-width: 0; }
.flow-card[data-lane="running"] { border-color: var(--primary); }
.flow-card--recordless { border: 1px dashed var(--gray-5); background: #fafafa; }
.card-hit { display: flex; flex-direction: column; gap: 5px; width: 100%; padding: 9px 10px 7px; margin: 0; border: 0; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; border-radius: var(--radius) var(--radius) 0 0; }
.card-hit:hover { background: #f7f9fd; }
.card-hit:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.card-top { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.card-key { font: 600 12px/1.3 var(--mono); color: var(--ink); }
.card-parent { color: var(--faint); font: 400 11px/1.3 var(--mono); }
.card-cost { margin-left: auto; font: 600 13px/1.2 var(--mono); color: var(--ink); white-space: nowrap; text-align: right; }
.card-cost small { display: block; font-weight: 400; font-size: 10px; color: var(--faint); }
.card-cost[data-state="floor"] { color: var(--warn-text); }
.card-cost[data-state="unknown"] { color: var(--faint); font-weight: 500; }
.card-title { font-size: 12.5px; line-height: 1.35; color: var(--ink); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-title--absent { color: var(--faint); font-style: italic; }
.card-chips { display: flex; flex-wrap: wrap; gap: 4px; }
/* `.tag` is `white-space: nowrap` with a fixed height — fine for a status word, not for a
   `cause` string, which can run well past the lane column with nothing to wrap it (controller
   finding 1, final review Important 8). Relaxed the same way `.notice` already is. */
.card-chips .tag { margin: 0; white-space: normal; height: auto; min-height: 20px; padding: 2px 7px; line-height: 16px; }
.tag--rounds { gap: 6px; }
.pips { display: inline-flex; gap: 2px; align-items: center; }
.pip { width: 6px; height: 6px; border-radius: 50%; border: 1px solid var(--faint); }
.pip--on { background: var(--muted); border-color: var(--muted); }
.card-foot { display: flex; align-items: center; gap: 6px; padding: 5px 10px 7px; border-top: 1px solid var(--divider); color: var(--muted); font: 11px/1.3 var(--mono); }
.card-agent { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-links { display: inline-flex; gap: 4px; flex: 0 0 auto; }
.card-age { flex: 0 0 auto; }
.lnk { display: inline-flex; align-items: center; gap: 3px; height: 22px; padding: 0 6px; border: 1px solid var(--gray-6); border-radius: var(--radius); background: var(--surface); color: var(--link); font: 500 11px/1 var(--mono); text-decoration: none; }
.lnk:hover { border-color: var(--primary); background: var(--primary-tint); text-decoration: none; }
.lnk .ext { width: 10px; height: 10px; }
.lnk--historical { border-style: dashed; }
.lnk--none { color: var(--faint); border-style: dashed; cursor: default; }

/* ---- lanes, band, strip (AMP-231) ---- */
.board-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
.sb { display: flex; align-items: baseline; gap: 10px; padding: 8px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); border-top: 2px solid var(--gray-6); }
.sb[data-tone="run"] { border-top-color: var(--primary); }
.sb[data-tone="wait"] { border-top-color: var(--warn-text); }
.sb[data-tone="done"] { border-top-color: var(--ok-text); }
.sb-label { font-size: 12px; color: var(--muted); }
.sb-value { font: 500 22px/1 var(--mono); color: var(--ink); }
.sb-note { margin-left: auto; color: var(--faint); font: 11px/1.3 var(--mono); text-align: right; }
.queue-lanes { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(660px, 3fr) minmax(220px, 1fr); gap: 12px; align-items: start; overflow-x: auto; }
.queue-lanes:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.lane { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.lane-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 6px 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); border-top: 3px solid var(--gray-6); }
.lane[data-tone="run"] > .lane-head { border-top-color: var(--primary); }
.lane[data-tone="wait"] > .lane-head { border-top-color: var(--warn-text); }
.lane[data-tone="done"] > .lane-head { border-top-color: var(--ok-text); }
.lane-head h2 { margin: 0; font-size: 13px; font-weight: 600; }
.lane-count { font: 500 14px/1 var(--mono); color: var(--ink); margin-left: 4px; }
.lane-asof { margin-left: auto; color: var(--muted); font: 11px/1.3 var(--mono); }
.lane-asof[data-stale="true"] { color: var(--warn-text); font-weight: 600; }
.lane-body { display: flex; flex-direction: column; min-width: 0; }
.lane-empty { margin: 0; padding: 14px 10px; color: var(--muted); font-size: 12px; text-align: center; background: var(--surface); border: 1px dashed var(--gray-6); border-radius: var(--radius); }
.lane-band { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.band-head { display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: var(--warn-bg); border: 1px solid var(--warn-border); border-radius: var(--radius); border-top: 3px solid var(--warn-text); }
.band-head h2 { margin: 0; font-size: 13px; font-weight: 600; }
.band-lanes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; align-items: start; }
.band-lanes .lane-head { border-top-width: 1px; border-top-color: var(--border); }
.lane-group { display: flex; flex-direction: column; min-width: 0; }
.group-head { display: flex; align-items: center; gap: 8px; margin: 4px 2px 6px; color: var(--muted); font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.group-head::after { content: ""; flex: 1 1 auto; height: 1px; background: var(--gray-6); }
.group-head b { font: 500 11px/1 var(--mono); color: var(--muted); }
@media (max-width: 1100px) { .queue-lanes { grid-template-columns: 1fr; } .band-lanes { grid-template-columns: 1fr; } .board-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media print { .queue-lanes { grid-template-columns: 1fr; overflow-x: visible; } }
