/* Prism UI tokens: monochrome core, semantic colour for status only. */
:root {
  --bg: #fafafa;
  --fg: #0a0a0a;
  --fg-muted: #737373;
  --fg-soft: #a3a3a3;
  --surface: #ffffff;
  --surface-soft: #f5f5f5;
  --border: #e5e5e5;
  --border-focus: #a3a3a3;
  --dot: #dedede;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.06);
  --shadow-lg: 0 2px 6px rgba(0,0,0,.05), 0 16px 48px rgba(0,0,0,.10);

  --red: #c63a31; --orange: #b4500b; --yellow: #e3b341; --green: #2a7d3f;
  --sky: #4ea3e0; --blue: #4d7ef0; --purple: #9b5cf0; --pink: #e05a9b;
  --red-soft: #fdecea; --orange-soft: #fdf0e6; --green-soft: #e9f7ec; --blue-soft: #eaf0fe;
  --accent: var(--fg);
  --accent-soft: var(--surface-soft);

  --font: "Geist", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --fs-xs: 11px; --fs-sm: 12px; --fs-base: 13px; --fs-md: 14px; --fs-lg: 16px; --fs-xl: 18px; --fs-2xl: 22px;

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-dropdown: cubic-bezier(0.22, 1, 0.36, 1);
  --dur-normal: 150ms;
  --dur-slow: 250ms;
  --header-h: 60px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0a0a; --fg: #fafafa; --fg-muted: #a3a3a3; --fg-soft: #737373;
    --surface: #111111; --surface-soft: #1a1a1a; --border: #262626; --border-focus: #525252; --dot: #222;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.4);
    --shadow-lg: 0 2px 6px rgba(0,0,0,.5), 0 16px 48px rgba(0,0,0,.6);
    --red-soft: #3a1d1b; --orange-soft: #3a2616; --green-soft: #15301c; --blue-soft: #18223d;
    --red: #f07167; --orange: #f0a35e; --green: #5cc27a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0a0a0a; --fg: #fafafa; --fg-muted: #a3a3a3; --fg-soft: #737373;
  --surface: #111111; --surface-soft: #1a1a1a; --border: #262626; --border-focus: #525252; --dot: #222;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.4);
  --shadow-lg: 0 2px 6px rgba(0,0,0,.5), 0 16px 48px rgba(0,0,0,.6);
  --red-soft: #3a1d1b; --orange-soft: #3a2616; --green-soft: #15301c; --blue-soft: #18223d;
    --red: #f07167; --orange: #f0a35e; --green: #5cc27a;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  font-size: var(--fs-base);
  letter-spacing: -0.005em;
  font-variant-numeric: tabular-nums;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
.mono { font-family: var(--mono); }
.muted { color: var(--fg-muted); }
.soft { color: var(--fg-muted); }
.upper { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--fg-muted); font-weight: 500; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
kbd {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 4px; margin: 0 1px;
  border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px;
  font-family: var(--mono); font-size: 10px; color: var(--fg-muted); background: var(--surface);
}

/* ── Shell: header + sidebar + main, fills the window ────── */
.shell {
  height: 100vh;
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  grid-template-rows: var(--header-h) minmax(0, 1fr);
  grid-template-areas: "header header" "sidebar main";
}
.header {
  grid-area: header; display: flex; align-items: center; gap: 12px;
  padding: 0 16px; border-bottom: 1px solid var(--border); background: var(--surface);
}
.brand-pill {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px;
  border: 1px solid var(--border); border-radius: 9999px; background: var(--surface);
  box-shadow: var(--shadow-sm); font-weight: 600; white-space: nowrap;
}
.brand-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.brand-pill .client { font-weight: 400; color: var(--fg-muted); }
/* Client logo: shown on its own white chip so it reads in both themes. */
.brand {
  display: inline-flex; align-items: center; gap: 10px; height: 40px; padding: 0 12px 0 4px;
  border: 1px solid var(--border); border-radius: 9999px; background: var(--surface); box-shadow: var(--shadow-sm);
  white-space: nowrap;
}
.brand-chip { display: inline-grid; place-items: center; height: 32px; padding: 0 10px; border-radius: 9999px; background: #fff; }
.brand-chip img { display: block; height: var(--logo-h, 22px); width: auto; }
.brand-sep { width: 1px; height: 18px; background: var(--border); }
.brand-tool { font-weight: 600; }
.header-title { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.header-title .desk { font-weight: 600; }
.header-title .muted { font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header .spacer { flex: 1; }
.tag {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: 9999px; background: var(--surface);
  font-size: var(--fs-xs); color: var(--fg-muted); white-space: nowrap;
}
.tag .live { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }

.icon-btn {
  width: 36px; height: 36px; flex: none; display: inline-grid; place-items: center;
  border: 1px solid var(--border); border-radius: 50%; background: var(--surface);
  transition: transform var(--dur-normal) var(--ease), background var(--dur-normal), color var(--dur-normal);
}
.icon-btn:hover { background: var(--surface-soft); }
.icon-btn:active { transform: scale(.94); }
.icon-btn[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.icon-btn svg { width: 16px; height: 16px; }

/* ── Pill button ─────────────────────────────────────────── */
.pill {
  position: relative; overflow: hidden; isolation: isolate;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 18px; border-radius: 9999px; border: 1px solid var(--fg);
  background: var(--pill-bg, var(--fg)); color: var(--pill-fg, var(--bg)); border-color: var(--pill-bg, var(--fg));
  font-weight: 500; white-space: nowrap;
  transition: transform var(--dur-normal) var(--ease), opacity var(--dur-normal);
}
.pill:hover { opacity: .88; }
.pill:active { transform: scale(.97); }
.pill:disabled { opacity: .35; cursor: not-allowed; transform: none; }
.pill.ghost { background: var(--surface); color: var(--fg); border-color: var(--border); }
.pill.ghost:hover { background: var(--surface-soft); opacity: 1; }
.pill.sm { height: 30px; padding: 0 14px; font-size: var(--fs-sm); }

/* Progress fill inverts the label as it sweeps (Prism export state). */
.pill .fill {
  position: absolute; inset: 0; transform-origin: left; transform: scaleX(var(--p, 0));
  background: var(--fill-bg, #fff); mix-blend-mode: var(--fill-blend, difference); pointer-events: none;
  transition: transform 120ms linear;
}
.pill.running { cursor: progress; }

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  grid-area: sidebar; min-height: 0; display: flex; flex-direction: column;
  border-right: 1px solid var(--border); background: var(--surface);
}
.sidebar-scroll { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding: 14px 12px; }
/* Run button and "How it works" stay fixed in the bottom-left corner. */
.sidebar-foot { flex: none; display: grid; gap: 10px; padding: 12px; border-top: 1px solid var(--border); }
.nav-label { padding: 0 10px 6px; }
.nav-item {
  width: 100%; display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 10px;
  border: 0; border-radius: 9px; background: transparent; text-align: left;
  color: var(--fg-muted); transition: background var(--dur-normal), color var(--dur-normal);
}
.nav-item:hover { background: var(--surface-soft); color: var(--fg); }
.nav-item[aria-current="true"] { background: var(--accent-soft); color: var(--fg); font-weight: 500; }
.nav-item .lane-dot { flex: none; }
.nav-item .count { margin-left: auto; font-family: var(--mono); font-size: var(--fs-xs); color: var(--fg-muted); }
.nav-item[aria-current="true"] .count { color: var(--fg); }
.nav-item svg { width: 14px; height: 14px; flex: none; }
.run-box { display: grid; gap: 8px; }
.run-box .pill { width: 100%; }
.run-icon { display: none; width: 14px; height: 14px; }
.run-status { padding: 0 4px; font-size: var(--fs-xs); color: var(--fg-muted); line-height: 1.4; }
.about {
  padding: 12px 14px; border-radius: 12px; background: var(--surface-soft);
  border: 1px solid var(--border); font-size: var(--fs-sm); color: var(--fg-muted); line-height: 1.5;
}
.about ol { margin: 6px 0 8px; padding-left: 18px; }
.about li + li { margin-top: 2px; }
.about li + li { margin-top: 4px; }
.about b { color: var(--fg); font-weight: 500; }
.kbd-hint { font-size: var(--fs-xs); }

/* ── Main: list + detail ─────────────────────────────────── */
.main {
  grid-area: main; min-height: 0; display: grid;
  grid-template-columns: minmax(340px, 400px) minmax(0, 1fr);
  background-image: radial-gradient(var(--dot) 1px, transparent 1px);
  background-size: 22px 22px;
}
.main.page-mode { grid-template-columns: minmax(0, 1fr); }
.main.page-mode .list-pane, .main.page-mode .detail-pane { display: none; }
.list-pane { min-height: 0; display: flex; flex-direction: column; border-right: 1px solid var(--border); background: var(--surface); }
.pane-head {
  flex: none; height: 52px; padding: 0 16px; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  border-bottom: 1px solid var(--border);
}
.pane-head h2 { margin: 0; font-size: var(--fs-md); font-weight: 600; }
.segmented { display: inline-flex; padding: 2px; border-radius: 9999px; background: var(--surface-soft); border: 1px solid var(--border); }
.segmented button {
  border: 0; background: transparent; padding: 3px 10px; border-radius: 9999px;
  font-size: var(--fs-xs); color: var(--fg-muted);
  transition: background var(--dur-normal), color var(--dur-normal);
}
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--fg); box-shadow: var(--shadow-sm); }
.list-body { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 8px 16px; }
.lane-title { display: flex; align-items: center; gap: 8px; padding: 14px 10px 6px; }
.lane-title .count { margin-left: auto; font-family: var(--mono); font-size: var(--fs-xs); color: var(--fg-muted); }
.lane-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.lane-empty { padding: 4px 10px 6px; color: var(--fg-soft); font-size: var(--fs-sm); }
.row {
  position: relative; width: 100%; display: grid; grid-template-columns: auto 1fr auto; gap: 3px 10px; align-items: center;
  text-align: left; border: 1px solid transparent; background: transparent; border-radius: 10px;
  padding: 9px 10px; transition: background var(--dur-normal);
}
.row:hover { background: var(--surface-soft); }
.row[aria-current="true"] { background: var(--accent-soft); border-color: transparent; }
.row[aria-current="true"]::before {
  content: ""; position: absolute; left: -8px; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent);
}
.row .subj { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .meta { grid-column: 2 / 4; color: var(--fg-muted); font-size: var(--fs-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .conf { font-family: var(--mono); font-size: var(--fs-xs); color: var(--fg-muted); }
.row.processing { opacity: .35; }
.row.done .subj { color: var(--fg-muted); }

.urg {
  display: inline-flex; align-items: center; justify-content: center; min-width: 26px; height: 20px; padding: 0 6px;
  border-radius: 9999px; font-family: var(--mono); font-size: var(--fs-xs); font-weight: 600;
  border: 1px solid var(--border); color: var(--fg-muted); background: var(--surface);
}
.urg.P1 { background: var(--red-soft); color: var(--red); border-color: transparent; }
.urg.P2 { background: var(--orange-soft); color: var(--orange); border-color: transparent; }

/* ── Detail pane ─────────────────────────────────────────── */
.detail-pane { min-height: 0; display: flex; flex-direction: column; }
.detail-scroll { flex: 1; min-height: 0; overflow-y: auto; }
.detail-pane { container-type: inline-size; }
.detail-inner { max-width: 880px; margin: 0 auto; padding: 24px 28px 32px; }
.detail-head { display: flex; gap: 12px; align-items: flex-start; }
.detail-head h1 { margin: 4px 0 0; font-size: var(--fs-2xl); font-weight: 600; letter-spacing: -0.02em; }
.detail-head .ids { display: flex; gap: 8px; align-items: center; color: var(--fg-muted); font-size: var(--fs-sm); }
.lane-badge {
  margin-left: auto; flex: none; display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 12px;
  border-radius: 9999px; font-size: var(--fs-sm); font-weight: 500; border: 1px solid var(--border); background: var(--surface);
}

/* Flow stepper: where this ticket is in the pipeline. */
.stepper {
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 0; margin: 20px 0 8px;
  padding: 12px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-sm);
}
.stepper button {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0;
  padding: 6px 10px; border: 0; background: transparent; border-radius: 8px; text-align: left;
  transition: background var(--dur-normal);
}
.stepper button:hover { background: var(--surface-soft); }
.stepper button + button { padding-left: 16px; }
.stepper button + button::before {
  content: ""; position: absolute; left: -6px; top: 50%; width: 8px; height: 8px; margin-top: -4px;
  border-top: 1.5px solid var(--border-focus); border-right: 1.5px solid var(--border-focus); transform: rotate(45deg);
}
.stepper .s-name { display: flex; align-items: center; gap: 6px; font-weight: 500; }
.stepper .s-val { font-size: var(--fs-xs); color: var(--fg-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.stepper .s-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--fg); flex: none; }
.stepper .s-dot.flag { background: var(--red); }
.stepper .s-dot.warn { background: var(--orange); }
.stepper .s-dot.wait { background: transparent; border: 1.5px solid var(--border-focus); }
.stepper .s-dot.ok { background: var(--accent); }

.steps { list-style: none; margin: 0; padding: 0; }
.step {
  margin-top: 14px; padding: 18px 20px; border: 1px solid var(--border); border-radius: 14px;
  background: var(--surface); box-shadow: var(--shadow-sm); scroll-margin-top: 16px;
}
.step.flagged { border-color: color-mix(in srgb, var(--red) 35%, var(--border)); }
.step-title { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.step-title h3 { margin: 0; font-size: var(--fs-md); font-weight: 600; }
.step-title .aside { margin-left: auto; font-size: var(--fs-sm); color: var(--fg-muted); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 9999px;
  background: var(--surface-soft); border: 1px solid var(--border); font-size: var(--fs-sm); color: var(--fg-muted); white-space: nowrap;
}
.chip b { color: var(--fg); font-weight: 500; }
.body-text {
  margin-top: 12px; padding: 14px 16px; border-radius: 12px; background: var(--surface-soft);
  line-height: 1.65; white-space: pre-wrap; font-size: var(--fs-md);
}
.pii-token {
  font-family: var(--mono); font-size: var(--fs-xs); padding: 1px 5px; border-radius: 5px;
  background: var(--fg); color: var(--bg); white-space: nowrap;
}
.pii-raw { background: var(--yellow); color: #0a0a0a; border-radius: 3px; padding: 0 2px; }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }

.kv { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.kv > div { padding: 12px 14px 12px 0; min-width: 0; }
.kv > div + div { padding-left: 14px; border-left: 1px solid var(--border); }
.kv .v { margin-top: 4px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.confbar { position: relative; height: 6px; margin-top: 8px; border-radius: 9999px; background: var(--surface-soft); }
.confbar .f { position: absolute; inset: 0; border-radius: 9999px; background: var(--fg); transform-origin: left; transform: scaleX(var(--v, 0)); transition: transform var(--dur-slow) var(--ease); }
.confbar .t { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--orange); border-radius: 2px; transition: left var(--dur-slow) var(--ease); }
.prose { margin: 12px 0 0; line-height: 1.6; }
.quote { color: var(--fg-muted); border-left: 1px solid var(--border-focus); padding-left: 12px; }
.compare { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border); font-size: var(--fs-sm); color: var(--fg-muted); }
.compare .diff { color: var(--orange); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--orange) 50%, transparent); }

.checks { display: grid; gap: 6px; }
.check {
  display: grid; grid-template-columns: 18px 1fr; gap: 10px; align-items: start;
  padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border);
}
.check.hit { border-color: transparent; background: var(--red-soft); }
.check.warn { border-color: transparent; background: var(--orange-soft); }
.check.pass { color: var(--fg-muted); border-color: transparent; padding-left: 0; padding-right: 0; }
.check .ic { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; margin-top: 1px; }
.check.hit .ic { background: var(--red); color: #fff; }
.check.warn .ic { background: var(--orange); color: #fff; }
.check.pass .ic { background: var(--surface-soft); border: 1px solid var(--border); }
.check .ic svg { width: 11px; height: 11px; }
.check .t { font-weight: 500; color: var(--fg); }
.check .g { margin-top: 2px; font-size: var(--fs-sm); color: var(--fg-muted); }
.outcome { margin-top: 12px; padding: 11px 14px; border-radius: 12px; background: var(--fg); color: var(--bg); font-weight: 500; }

textarea.reply {
  width: 100%; min-height: 150px; resize: vertical; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface); line-height: 1.6; font-size: var(--fs-md);
  transition: border-color var(--dur-normal);
}
textarea.reply:focus { outline: none; border-color: var(--border-focus); }
textarea.reply[readonly] { background: var(--surface-soft); color: var(--fg-muted); }

/* Sticky decision bar at the foot of the detail pane. */
.decide-bar {
  flex: none; border-top: 1px solid var(--border); background: color-mix(in srgb, var(--surface) 92%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.decide-inner { max-width: 880px; margin: 0 auto; padding: 12px 28px; display: flex; align-items: center; gap: 10px; }
.decide-inner .what { min-width: 0; font-size: var(--fs-sm); color: var(--fg-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.decide-inner .what b { color: var(--fg); font-weight: 500; }
.decide-inner .controls { margin-left: auto; display: flex; gap: 8px; align-items: center; flex: none; }
.select {
  appearance: none; height: 36px; padding: 0 32px 0 14px; border-radius: 9999px; border: 1px solid var(--border);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none' stroke='%23737373' stroke-width='1.5'%3E%3Cpath d='M1 1l4 4 4-4'/%3E%3C/svg%3E") no-repeat right 13px center;
}
.select:focus { outline: none; border-color: var(--border-focus); }
.done-note { display: inline-flex; align-items: center; gap: 8px; color: var(--green); font-weight: 500; }

/* ── Insights page ───────────────────────────────────────── */
.insights-page { min-height: 0; overflow-y: auto; }
.insights-inner { max-width: 1720px; margin: 0 auto; padding: 28px 36px 48px; }
.insights-inner h1 { margin: 0; font-size: var(--fs-2xl); font-weight: 600; letter-spacing: -0.02em; }
.panel { padding: 20px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-sm); }
.panel h2 { margin: 0 0 4px; font-size: var(--fs-md); font-weight: 600; }
.panel .sub { margin: 0; color: var(--fg-muted); font-size: var(--fs-sm); }
.ins-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px; margin-top: 16px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 20px; }
.summary { margin-top: 20px; padding: 20px 22px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-sm); }
.summary p { margin: 0; font-size: var(--fs-lg); line-height: 1.6; max-width: 70ch; }
.summary b { font-weight: 600; }
.stat { padding: 16px 18px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-sm); }
.stat .n { font-size: 28px; font-weight: 600; letter-spacing: -0.03em; margin-top: 6px; }
.stat .d { margin-top: 2px; font-size: var(--fs-sm); color: var(--fg-muted); }
.formula { margin-top: 12px; font-family: var(--mono); font-size: var(--fs-xs); color: var(--fg-muted); line-height: 1.7; }
table.evals { width: 100%; border-collapse: collapse; margin-top: 12px; }
table.evals th, table.evals td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: right; }
table.evals th:first-child, table.evals td:first-child { text-align: left; }
table.evals th { font-size: var(--fs-xs); color: var(--fg-muted); font-weight: 500; text-transform: uppercase; letter-spacing: .06em; }
table.evals td { font-family: var(--mono); }
table.evals td:first-child { font-family: var(--font); }
.meter { display: inline-block; width: 64px; height: 4px; margin-left: 8px; vertical-align: middle; border-radius: 4px; background: var(--surface-soft); position: relative; overflow: hidden; }
.meter i { position: absolute; inset: 0 auto 0 0; background: var(--fg-soft); }
.gate-bars { display: grid; gap: 8px; margin-top: 14px; }
.gate-bar { display: grid; grid-template-columns: 180px 1fr 28px; gap: 10px; align-items: center; font-size: var(--fs-sm); }
.gate-bar .track { height: 8px; border-radius: 8px; background: var(--surface-soft); overflow: hidden; }
.gate-bar .track i { display: block; height: 100%; border-radius: 8px; }
.gate-bar .v { font-family: var(--mono); text-align: right; color: var(--fg-muted); }
.log { list-style: none; margin: 12px 0 0; padding: 0; font-size: var(--fs-sm); }
.log li { display: grid; grid-template-columns: 70px 84px 1fr; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.log li span:not(:last-child) { font-family: var(--mono); font-size: var(--fs-xs); color: var(--fg-muted); padding-top: 1px; }

/* ── Dashboard: queue bar ────────────────────────────────── */
.flow { margin-top: 20px; padding: 18px 20px 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-sm); }
.flow-bar { display: flex; height: 12px; border-radius: 9999px; overflow: hidden; background: var(--surface-soft); gap: 2px; }
/* Width animates only during a run, on a 12px bar of five segments. */
.flow-bar .seg { height: 100%; min-width: 0; transition: width 420ms var(--ease); }
.flow-legend { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; margin-top: 14px; }
.flow-legend.has-new { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.lane-stat {
  display: grid; grid-template-columns: auto 1fr; gap: 0 8px; align-items: baseline; text-align: left;
  padding: 8px 10px; border: 0; border-radius: 10px; background: transparent; transition: background var(--dur-normal);
}
.lane-stat:hover { background: var(--surface-soft); }
.lane-stat .lane-dot { transform: translateY(-2px); }
.lane-stat .name { font-weight: 500; }
.lane-stat .count { grid-column: 2; font-size: var(--fs-xl); font-weight: 600; letter-spacing: -0.02em; }
.lane-stat .d { grid-column: 2; font-size: var(--fs-xs); color: var(--fg-muted); line-height: 1.35; }
.dash-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; margin-top: 16px; align-items: start; }
.todo { margin-top: 10px; }
.todo-row {
  width: 100%; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 2px 12px; align-items: center;
  padding: 11px 10px; border: 0; border-top: 1px solid var(--border); background: transparent; text-align: left;
  transition: background var(--dur-normal);
}
.todo-row:first-child { border-top: 0; }
.todo-row:hover { background: var(--surface-soft); border-radius: 10px; }
.todo-row .subj { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.todo-row .why { grid-column: 2; font-size: var(--fs-sm); color: var(--fg-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.todo-row .go { grid-row: 1 / 3; grid-column: 3; display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-sm); color: var(--fg-muted); }
.todo-row .go svg, .link-btn svg { width: 12px; height: 12px; }
.todo-row:hover .go { color: var(--fg); }
.todo-row .due { color: var(--orange); }
.glance { display: grid; gap: 0; margin-top: 8px; }
.glance div { display: flex; justify-content: space-between; align-items: baseline; padding: 11px 0; border-top: 1px solid var(--border); }
.glance div:first-child { border-top: 0; }
.glance b { font-size: var(--fs-lg); font-weight: 600; font-family: var(--mono); }
.link-btn { display: inline-flex; align-items: center; gap: 6px; margin-top: 12px; border: 0; background: none; padding: 0; color: var(--fg); font-weight: 500; }
.link-btn:hover { text-decoration: underline; }

/* ── Not triaged yet ──────────────────────────────────────── */
.hero-empty {
  margin-top: 20px; padding: 28px; border: 1px dashed var(--border-focus); border-radius: 16px; background: var(--surface);
  display: flex; align-items: center; gap: 24px;
}
.hero-empty h2 { margin: 0 0 4px; font-size: var(--fs-lg); }
.hero-empty p { margin: 0; color: var(--fg-muted); line-height: 1.5; }
.hero-empty .pill { margin-left: auto; flex: none; }
.inbox-preview { margin-top: 16px; }

/* ── Dashboard insights ──────────────────────────────────── */
.section-head { display: flex; align-items: baseline; gap: 12px; margin-top: 28px; }
.section-head h2 { margin: 0; font-size: var(--fs-lg); font-weight: 600; }
.section-head .muted { font-size: var(--fs-sm); }
.ins-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 12px; }
.ins-card {
  display: flex; flex-direction: column; gap: 8px; padding: 18px 20px; border: 1px solid var(--border); border-radius: 14px;
  background: var(--surface); box-shadow: var(--shadow-sm);
}
.ins-card.risk { --tone: var(--red); --tone-soft: var(--red-soft); }
.ins-card.watch { --tone: var(--orange); --tone-soft: var(--orange-soft); }
.ins-card.opportunity { --tone: var(--accent); --tone-soft: var(--accent-soft); }
.ins-card h3 { margin: 0; display: flex; align-items: baseline; gap: 8px; font-size: var(--fs-md); font-weight: 600; }
.ins-card h3::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--tone); transform: translateY(-1px); }
.ins-card p { margin: 0; line-height: 1.55; color: var(--fg-muted); max-width: 68ch; }
.ins-card.lead { grid-column: 1 / -1; padding: 22px 24px; }
.ins-card.lead h3 { font-size: var(--fs-lg); }
.ins-card.lead p { font-size: var(--fs-md); }
.ins-move { padding-top: 10px; border-top: 1px dashed var(--border); line-height: 1.55; }
.ins-move b { font-weight: 600; margin-right: 4px; }
.ins-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: auto; padding-top: 4px; }
.ins-foot .tone { font-size: var(--fs-xs); font-weight: 600; padding: 2px 8px; border-radius: 9999px; background: var(--tone-soft); color: var(--tone); }
.ins-foot .who { font-size: var(--fs-sm); color: var(--fg-muted); margin-right: 4px; }
.ref {
  height: 24px; padding: 0 9px; border-radius: 9999px; border: 1px solid var(--border); background: var(--surface);
  font-family: var(--mono); font-size: var(--fs-xs); color: var(--fg-muted); transition: border-color var(--dur-normal), color var(--dur-normal);
}
.ref:hover { border-color: var(--accent); color: var(--fg); }
.dash-grid { margin-top: 12px; }
.more-links { display: flex; gap: 20px; padding: 4px 10px 0; }

/* ── What's next ─────────────────────────────────────────── */
.plan { list-style: none; margin: 20px 0 0; padding: 0; display: grid; gap: 12px; }
.plan li { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 20px; padding: 18px 20px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-sm); }
.plan .when { font-size: var(--fs-sm); color: var(--accent); font-weight: 600; padding-top: 2px; }
.plan h3 { margin: 0; font-size: var(--fs-md); font-weight: 600; }
.plan ul { margin: 8px 0 0; padding-left: 18px; line-height: 1.6; }
.plan ul li { display: list-item; padding: 0; border: 0; box-shadow: none; background: none; grid-template-columns: none; }
.plan .role { margin-top: 10px; font-size: var(--fs-sm); color: var(--fg-muted); }
.plan .role b { color: var(--fg); font-weight: 500; }

/* ── Wide screens: use the width instead of scrolling ───── */
.dash-cols { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-items: start; }
.dash-main { min-width: 0; container-type: inline-size; }
.dash-rail { display: grid; gap: 16px; margin-top: 20px; }
.dash-rail .panel { margin: 0; }
@media (min-width: 1280px) {
  .dash-cols { grid-template-columns: minmax(0, 1fr) 380px; }
  .dash-rail { position: sticky; top: 16px; max-height: calc(100vh - var(--header-h) - 32px); overflow-y: auto; }
}
@container (min-width: 1100px) {
  .ins-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.steps-grid { display: grid; grid-template-columns: minmax(0, 1fr); }
@container (min-width: 1040px) {
  .detail-inner, .decide-inner { max-width: 1440px; }
  .steps-grid { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 14px; align-items: start; }
}
.plan { grid-template-columns: repeat(auto-fill, minmax(min(100%, 620px), 1fr)); }
.inbox-preview .todo { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); column-gap: 24px; }
.inbox-preview .todo-row:nth-child(2) { border-top: 0; }

/* ── Empty state ─────────────────────────────────────────── */
.empty { height: 100%; display: grid; place-items: center; text-align: center; color: var(--fg-muted); padding: 32px; }
.empty h2 { margin: 0 0 6px; color: var(--fg); font-size: var(--fs-lg); }

/* ── Settings popover ────────────────────────────────────── */
.settings {
  position: fixed; top: calc(var(--header-h) + 8px); right: 16px; z-index: 30; width: 300px; padding: 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg);
  transform-origin: top right; transform: scale(.97); opacity: 0; pointer-events: none;
  transition: transform var(--dur-normal) var(--ease-dropdown), opacity var(--dur-normal);
}
.settings.open { transform: scale(1); opacity: 1; pointer-events: auto; transition-duration: var(--dur-slow); }
.settings .group + .group { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.setting { display: grid; gap: 6px; margin-top: 12px; }
.setting .lbl { display: flex; justify-content: space-between; font-size: var(--fs-sm); }
.setting .lbl span + span { font-family: var(--mono); color: var(--fg-muted); }
.row-setting { grid-template-columns: 1fr auto; align-items: center; font-size: var(--fs-sm); }
.setting .hint, .hint { font-size: var(--fs-xs); color: var(--fg-soft); line-height: 1.45; }
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 14px; background: transparent; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 3px; border-radius: 3px; background: var(--border); }
input[type="range"]::-moz-range-track { height: 3px; border-radius: 3px; background: var(--border); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; margin-top: -5.5px; border-radius: 50%; background: var(--fg); border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--fg); }
input[type="range"]::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--fg); border: 2px solid var(--surface); }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: var(--fs-sm); cursor: pointer; }
.switch input { appearance: none; width: 30px; height: 18px; border-radius: 9999px; background: var(--border); position: relative; cursor: pointer; transition: background var(--dur-normal); flex: none; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); box-shadow: var(--shadow-sm); transition: transform var(--dur-slow) var(--ease); }
.switch input:checked { background: var(--fg); }
.switch input:checked::after { transform: translateX(12px); }
.num { width: 72px; height: 28px; padding: 0 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); font-family: var(--mono); font-size: var(--fs-sm); text-align: right; }
.num:focus { outline: none; border-color: var(--border-focus); }

.toast {
  position: fixed; left: 50%; bottom: 84px; z-index: 40; transform: translate(-50%, 8px);
  padding: 8px 14px; border-radius: 9999px; background: var(--fg); color: var(--bg); font-size: var(--fs-sm);
  opacity: 0; pointer-events: none; transition: opacity var(--dur-slow), transform var(--dur-slow) var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ── Smaller desktop windows ─────────────────────────────── */
@media (max-width: 1280px) {
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 1100px) {
  .shell { grid-template-columns: 64px minmax(0, 1fr); }
  .sidebar-scroll, .sidebar-foot { padding: 12px 8px; }
  .nav-label, .about, .nav-item .label, .nav-item .count, .brand-sep, .brand-tool, .run-status { display: none; }
  #btn-run { padding: 0; }
  #btn-run #run-label { display: none; }
  #btn-run .run-icon { display: block; }
  .nav-item { justify-content: center; padding: 0; }
  .main { grid-template-columns: 320px minmax(0, 1fr); }
  .stepper .s-val { display: none; }
  .kv { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kv > div:nth-child(3) { padding-left: 0; border-left: 0; }
  .kv > div:nth-child(n+3) { border-top: 1px solid var(--border); }
  .ins-grid, .stats, .flow-legend, .flow-legend.has-new { grid-template-columns: 1fr 1fr; }
  .dash-grid, .ins-cards { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  body { overflow: auto; }
  .shell { height: auto; min-height: 100vh; grid-template-columns: 1fr; grid-template-areas: "header" "main"; grid-template-rows: auto auto; }
  .sidebar, .header-title, #source-tag { display: none; }
  .header { padding: 10px 12px; flex-wrap: wrap; }
  .main { grid-template-columns: 1fr; }
  .list-pane { max-height: 380px; border-right: 0; border-bottom: 1px solid var(--border); }
  .detail-pane { min-height: 70vh; }
  .kv, .stats, .ins-grid, .stepper, .flow-legend { grid-template-columns: 1fr 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0ms !important; animation-duration: 0ms !important; }
}
