/* ==========================================================================
   Celestra — clinical desk research
   One handwritten stylesheet. No framework, no CDN, no external assets.
   Every colour lives in the token block below; a theme swap is one block.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Design tokens
   -------------------------------------------------------------------------- */
:root {
  color-scheme: light;

  /* canvas + surfaces */
  --bg: #f6f7f9;
  --bg-alt: #eef1f5;
  --surface: #ffffff;
  --surface-2: #fbfcfd;
  --surface-3: #f4f6f8;
  --overlay: rgba(15, 23, 42, .44);

  /* hairlines */
  --border: #e6e8ec;
  --border-strong: #d6dae1;
  --border-input: #d8dde5;

  /* type */
  --text: #0f172a;
  --text-2: #4a5567;
  --text-3: #8a94a6;
  --text-inv: #ffffff;

  /* brand */
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-active: #1e40af;
  --primary-soft: #eff5ff;
  --primary-soft-2: #dbe8fe;
  --primary-border: #bfd6fd;
  --primary-text: #1d4ed8;

  /* pastel tint families: soft background / border / ink */
  --green-soft: #e7f7ee;   --green-border: #bfe8d1;  --green-ink: #157347;
  --blue-soft: #e6efff;    --blue-border: #c3d9fd;   --blue-ink: #1d4ed8;
  --purple-soft: #f0eaff;  --purple-border: #dbcdfb; --purple-ink: #6d28d9;
  --indigo-soft: #e8eaff;  --indigo-border: #cbd0fb; --indigo-ink: #4338ca;
  --teal-soft: #dff6f3;    --teal-border: #b3e6df;   --teal-ink: #0f766e;
  --amber-soft: #fdf3dc;   --amber-border: #f3ddab;  --amber-ink: #96620d;
  --rose-soft: #fee9ec;    --rose-border: #fac7ce;   --rose-ink: #be123c;
  --slate-soft: #eef0f4;   --slate-border: #dcdfe6;  --slate-ink: #5b6577;

  /* status semantics */
  --ok: #157347;
  --warn: #b45309;
  --danger: #be123c;
  --muted: #6b7482;

  /* shape + depth */
  --radius: 14px;
  --radius-md: 12px;
  --radius-sm: 9px;
  --radius-pill: 999px;
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-md: 0 4px 14px rgba(16, 24, 40, .07), 0 1px 3px rgba(16, 24, 40, .05);
  --shadow-lg: 0 18px 44px rgba(16, 24, 40, .16), 0 3px 10px rgba(16, 24, 40, .07);
  --focus-ring: 0 0 0 3px rgba(37, 99, 235, .35);

  /* metrics */
  --sidebar-w: 236px;
  --sidebar-w-collapsed: 68px;
  --shell-max: 1240px;

  /* type stacks — system only, nothing fetched */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
          Arial, "Noto Sans", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
               "Liberation Mono", monospace;
}

/* --------------------------------------------------------------------------
   2. Base
   -------------------------------------------------------------------------- */
* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5 { margin: 0; font-weight: 650; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 24px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
h4 { font-size: 14px; }
p { margin: 0 0 12px; }
p:last-child { margin-bottom: 0; }

a { color: var(--primary-text); text-decoration: none; }
a:hover { text-decoration: underline; }

ul, ol { margin: 0 0 12px; padding-left: 20px; }
li { margin: 0 0 6px; }
li:last-child { margin-bottom: 0; }

hr { border: 0; border-top: 1px solid var(--border); margin: 26px 0; }

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

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 200;
  background: var(--surface); color: var(--text);
  padding: 10px 14px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-md);
}
.skip-link:focus { top: 12px; }

/* --------------------------------------------------------------------------
   3. Shell + sidebar
   -------------------------------------------------------------------------- */
.app { min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px 16px;
  overflow-x: hidden;
  overflow-y: auto;
  z-index: 30;
}

.sidebar-head { display: flex; align-items: center; gap: 4px; margin-bottom: 18px; }

.brand {
  display: flex; align-items: center; gap: 10px;
  flex: 1 1 auto; min-width: 0; padding: 4px 8px;
  color: var(--text);
  font-weight: 700; letter-spacing: .14em; font-size: 12.5px;
  text-transform: uppercase;
}
.brand:hover { text-decoration: none; }
.brand-mark { flex: 0 0 auto; color: var(--primary); }
.brand-word { white-space: nowrap; }
.sidebar-toggle { flex: 0 0 auto; }
.sidebar-toggle .ic { transform: rotate(180deg); transition: transform .14s ease; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-group-label {
  padding: 14px 10px 6px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--text-3);
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 13.5px; font-weight: 500;
  transition: background .14s ease, color .14s ease;
}
.nav-item:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.nav-item .ic { flex: 0 0 auto; color: var(--text-3); }
.nav-item.is-active {
  background: var(--primary-soft);
  color: var(--primary-text);
  font-weight: 600;
}
.nav-item.is-active .ic { color: var(--primary); }
.nav-spacer { flex: 1 1 auto; }
.nav-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  padding: 28px 32px 64px;
}
.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); padding: 18px 10px 14px; align-items: center; }
.sidebar-collapsed .sidebar-head { width: 100%; flex-direction: column; justify-content: center; gap: 6px; margin-bottom: 12px; }
.sidebar-collapsed .sidebar .brand { flex: 0 0 auto; padding: 4px 0; justify-content: center; }
.sidebar-collapsed .sidebar .brand-word,
.sidebar-collapsed .sidebar .nav-label,
.sidebar-collapsed .sidebar .nav-group-label,
.sidebar-collapsed .sidebar .flow-text,
.sidebar-collapsed .sidebar .nav-project-meta { display: none; }
.sidebar-collapsed .sidebar-toggle .ic { transform: none; }
.sidebar-collapsed .nav { width: 100%; }
.sidebar-collapsed .nav-item { justify-content: center; padding: 10px 0; }
.sidebar-collapsed .flow-link { justify-content: center; padding-left: 0; padding-right: 0; }
.sidebar-collapsed .main { margin-left: var(--sidebar-w-collapsed); }
.shell { max-width: var(--shell-max); margin: 0 auto; }
.shell-narrow { max-width: 900px; margin: 0 auto; }

.page-head { margin-bottom: 20px; }
.page-head .eyebrow {
  font-size: 11px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--text-3); margin-bottom: 6px;
}
.page-head .sub { color: var(--text-2); margin-top: 6px; }
.page-head-row {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
}

/* --------------------------------------------------------------------------
   4. Banners + flashes
   -------------------------------------------------------------------------- */
/* The user-agent [hidden] rule is display:none at author-origin weight zero,
   so any of our own `display:` declarations silently defeats it. This keeps
   `el.hidden = true` working everywhere. */
[hidden] { display: none !important; }

.banner {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 14px;
  border: 1px solid var(--amber-border);
  background: var(--amber-soft);
  color: var(--amber-ink);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  font-size: 13px;
}
.banner .ic { flex: 0 0 auto; margin-top: 1px; }
.banner-body { flex: 1 1 auto; }
.banner strong { font-weight: 650; }
.banner-close {
  flex: 0 0 auto; border: 0; background: transparent; cursor: pointer;
  color: inherit; padding: 2px; border-radius: 6px; line-height: 0;
}
.banner-close:hover { background: rgba(0, 0, 0, .07); }
.banner.is-info { border-color: var(--blue-border); background: var(--blue-soft); color: var(--blue-ink); }
.banner.is-ok { border-color: var(--green-border); background: var(--green-soft); color: var(--green-ink); }
.banner.is-danger { border-color: var(--rose-border); background: var(--rose-soft); color: var(--rose-ink); }

.flash-area { margin-bottom: 16px; }

/* --------------------------------------------------------------------------
   5. Cards
   -------------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 20px 22px; }
.card + .card { margin-top: 16px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.card-head h2, .card-head h3 { margin: 0; }
.card-body { padding: 18px 20px; }
.card-foot {
  padding: 14px 20px; border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 var(--radius) var(--radius);
}
.card-hover { transition: box-shadow .16s ease, transform .16s ease, border-color .16s ease; }
.card-hover:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); }

.section { margin-bottom: 26px; }
.section-title {
  display: flex; align-items: center; gap: 8px;
  margin: 0 0 12px; font-size: 15px; font-weight: 650;
}
.section-title .count { color: var(--text-3); font-weight: 500; }

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* --------------------------------------------------------------------------
   6. Icon tiles
   -------------------------------------------------------------------------- */
.tile {
  flex: 0 0 auto;
  width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 11px;
  background: var(--slate-soft);
  border: 1px solid var(--slate-border);
  color: var(--slate-ink);
}
.tile svg { width: 19px; height: 19px; }
.tile-sm { width: 30px; height: 30px; border-radius: 9px; }
.tile-sm svg { width: 15px; height: 15px; }
.tile-lg { width: 44px; height: 44px; border-radius: 13px; }
.tile-lg svg { width: 22px; height: 22px; }

.tint-green  { background: var(--green-soft);  border-color: var(--green-border);  color: var(--green-ink); }
.tint-blue   { background: var(--blue-soft);   border-color: var(--blue-border);   color: var(--blue-ink); }
.tint-purple { background: var(--purple-soft); border-color: var(--purple-border); color: var(--purple-ink); }
.tint-indigo { background: var(--indigo-soft); border-color: var(--indigo-border); color: var(--indigo-ink); }
.tint-teal   { background: var(--teal-soft);   border-color: var(--teal-border);   color: var(--teal-ink); }
.tint-amber  { background: var(--amber-soft);  border-color: var(--amber-border);  color: var(--amber-ink); }
.tint-rose   { background: var(--rose-soft);   border-color: var(--rose-border);   color: var(--rose-ink); }
.tint-slate  { background: var(--slate-soft);  border-color: var(--slate-border);  color: var(--slate-ink); }

/* --------------------------------------------------------------------------
   7. Stat tiles
   -------------------------------------------------------------------------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stat {
  position: relative;
  padding: 16px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--slate-border);
  background: var(--slate-soft);
}
.stat-value {
  display: flex; align-items: center; gap: 8px;
  font-size: 30px; font-weight: 700; line-height: 1.1; letter-spacing: -.02em;
  color: var(--text);
}
.stat-label { margin-top: 6px; font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.stat-note { margin-top: 2px; font-size: 11.5px; color: var(--text-3); }
.stat.stat-green  { background: var(--green-soft);  border-color: var(--green-border); }
.stat.stat-green  .stat-value, .stat.stat-green .stat-label { color: var(--green-ink); }
.stat.stat-amber  { background: var(--amber-soft);  border-color: var(--amber-border); }
.stat.stat-amber  .stat-value, .stat.stat-amber .stat-label { color: var(--amber-ink); }
.stat.stat-rose   { background: var(--rose-soft);   border-color: var(--rose-border); }
.stat.stat-rose   .stat-value, .stat.stat-rose .stat-label { color: var(--rose-ink); }
.stat.stat-blue   { background: var(--blue-soft);   border-color: var(--blue-border); }
.stat.stat-blue   .stat-value, .stat.stat-blue .stat-label { color: var(--blue-ink); }
.stat.stat-slate  { background: var(--slate-soft);  border-color: var(--slate-border); }
.stat.stat-slate  .stat-value, .stat.stat-slate .stat-label { color: var(--slate-ink); }
.stat-check { color: var(--ok); display: inline-flex; }

/* --------------------------------------------------------------------------
   8. Chips + badges
   -------------------------------------------------------------------------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--slate-border);
  background: var(--slate-soft);
  color: var(--slate-ink);
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.chip-sm { padding: 2px 9px; font-size: 11px; font-weight: 550; }
.chip-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.chip-ready, .chip-high { background: var(--green-soft);  border-color: var(--green-border);  color: var(--green-ink); }
.chip-amber, .chip-medium { background: var(--amber-soft);  border-color: var(--amber-border);  color: var(--amber-ink); }
.chip-requires_input { background: var(--rose-soft); border-color: var(--rose-border);   color: var(--rose-ink); }
.chip-muted, .chip-rejected { background: var(--slate-soft);  border-color: var(--slate-border);  color: var(--slate-ink); }
.chip-blue         { background: var(--blue-soft);   border-color: var(--blue-border);   color: var(--blue-ink); }
.chip-purple       { background: var(--purple-soft); border-color: var(--purple-border); color: var(--purple-ink); }
.chip-teal         { background: var(--teal-soft);   border-color: var(--teal-border);   color: var(--teal-ink); }

/* source chips light up as they are actually used */
.chip-source {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-3);
  font-weight: 550;
  opacity: .72;
  transition: opacity .2s ease, color .2s ease, border-color .2s ease, background .2s ease;
}
.chip-source.is-used {
  opacity: 1;
  background: var(--primary-soft);
  border-color: var(--primary-border);
  color: var(--primary-text);
}
.chip-row { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }

/* reviewer file pills */
.chip-rose { background: var(--rose-soft); border-color: var(--rose-border); color: var(--rose-ink); }
.chip-file { max-width: 100%; gap: 5px; }
.chip-file-icon { display: inline-flex; flex: none; }
.chip-file-icon .spinner { width: 11px; height: 11px; }
.chip-file-name { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.chip-file-x {
  display: inline-flex; border: 0; background: none; padding: 0; margin-left: 2px;
  color: inherit; opacity: .65; cursor: pointer;
}
.chip-file-x:hover, .chip-file-x:focus-visible { opacity: 1; }
.chip-file.is-removing { opacity: .55; }
.chip-file.is-removing .chip-file-name { text-decoration: line-through; }
.chip-file.is-failed { border-color: var(--rose-ink); }
.review-files { margin-top: 6px; }
.review-files-label { font-size: 12px; font-weight: 600; }
.reviewer-files-hint { margin: 6px 0 0; font-size: 12px; color: var(--text-3); }
.file-errors { list-style: none; margin: 6px 0 0; padding: 0; font-size: 12px; color: var(--rose-ink); }
.file-errors:empty { display: none; }
.file-undo {
  border: 0; background: none; padding: 0; margin-left: 4px;
  font: inherit; color: inherit; text-decoration: underline; cursor: pointer;
}

.tier {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 6px;
  font-size: 11px; font-weight: 650; letter-spacing: .01em;
  border: 1px solid var(--slate-border); background: var(--slate-soft); color: var(--slate-ink);
  white-space: nowrap;
}
.tier-1 { background: var(--green-soft);  border-color: var(--green-border);  color: var(--green-ink); }
.tier-2 { background: var(--blue-soft);   border-color: var(--blue-border);   color: var(--blue-ink); }
.tier-3 { background: var(--purple-soft); border-color: var(--purple-border); color: var(--purple-ink); }
.tier-4 { background: var(--amber-soft);  border-color: var(--amber-border);  color: var(--amber-ink); }
.tier-5 { background: var(--rose-soft);   border-color: var(--rose-border);   color: var(--rose-ink); }

/* run + agent status chips */
.status { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; }
.status-queued, .status-pending { color: var(--text-3); }
.status-researching, .status-running, .status-synthesising { color: var(--primary-text); }
.status-complete, .status-completed { color: var(--ok); }
.status-failed { color: var(--danger); }
.status-blocked, .status-skipped, .status-cancelled { color: var(--muted); }

.meta { color: var(--text-3); font-size: 12.5px; }
.meta-row { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; }
.dot-sep { color: var(--border-strong); }

/* --------------------------------------------------------------------------
   9. Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background .14s ease, border-color .14s ease, color .14s ease, box-shadow .14s ease;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.btn[disabled], .btn.is-disabled { opacity: .55; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; }

.btn-primary {
  background: var(--primary); border-color: var(--primary); color: var(--text-inv);
  box-shadow: var(--shadow-xs);
}
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-primary:active { background: var(--primary-active); }

.btn-secondary { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-secondary:hover { background: var(--surface-3); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }

.btn-danger { background: var(--surface); border-color: var(--rose-border); color: var(--danger); }
.btn-danger:hover { background: var(--rose-soft); }

.btn-soft { background: var(--primary-soft); border-color: var(--primary-border); color: var(--primary-text); }
.btn-soft:hover { background: var(--primary-soft-2); }

.btn-lg { padding: 11px 20px; font-size: 14px; }
.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn-row-end { justify-content: flex-end; }

/* filter pills */
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 13px; border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font: inherit; font-size: 12.5px; font-weight: 600;
  cursor: pointer;
  transition: background .14s ease, color .14s ease, border-color .14s ease;
}
.pill:hover { background: var(--surface-3); color: var(--text); }
.pill:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.pill[aria-pressed="true"], .pill.is-active {
  background: var(--primary-soft); border-color: var(--primary-border); color: var(--primary-text);
}

/* --------------------------------------------------------------------------
   10. Tables — hairline, no zebra, sticky header, horizontal scroll wrapper
   -------------------------------------------------------------------------- */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  max-height: 620px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
table.data {
  width: 100%;
  min-width: 560px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
table.data th, table.data td {
  padding: 10px 14px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}
table.data thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 11.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  white-space: nowrap;
  border-bottom: 1px solid var(--border-strong);
}
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: var(--surface-2); }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.nowrap, table.data th.nowrap { white-space: nowrap; }
table.data.table-compact th, table.data.table-compact td { padding: 7px 12px; }

.table-title {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  margin: 0 0 8px;
}
.table-footnote {
  margin: 8px 2px 0;
  font-size: 12px; font-style: italic; color: var(--text-3);
}
.kv { width: 100%; border-collapse: collapse; font-size: 13px; }
.kv th, .kv td { padding: 9px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.kv th { width: 34%; color: var(--text-2); font-weight: 600; background: var(--surface-2); }
.kv tr:last-child th, .kv tr:last-child td { border-bottom: 0; }

/* --------------------------------------------------------------------------
   11. Forms
   -------------------------------------------------------------------------- */
.field { margin-bottom: 16px; }
.field label, .label {
  display: block; margin-bottom: 6px;
  font-size: 13px; font-weight: 600; color: var(--text);
}
.label .optional { color: var(--text-3); font-weight: 500; }
.req { color: var(--danger); }
.hint { margin-top: 5px; font-size: 12px; color: var(--text-3); }

input[type="text"], input[type="search"], input[type="email"], input[type="url"],
select, textarea {
  width: 100%;
  padding: 9px 12px;
  font: inherit; font-size: 13.5px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-sm);
  transition: border-color .14s ease, box-shadow .14s ease;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: var(--text-3); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
}
select {
  appearance: none;
  padding-right: 34px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%),
                    linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }

.search-wrap { position: relative; flex: 1 1 260px; min-width: 200px; }
.search-wrap .ic {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  color: var(--text-3); pointer-events: none;
}
.search-wrap input { padding-left: 34px; }

.toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin-bottom: 16px;
}
.toolbar .spacer { flex: 1 1 auto; }
.sort-wrap { display: flex; align-items: center; gap: 8px; }
.sort-wrap label { margin: 0; white-space: nowrap; font-weight: 500; color: var(--text-2); }
.sort-wrap select { width: auto; min-width: 150px; }

/* radio cards — mode selector */
.radio-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.radio-card {
  position: relative;
  display: flex; gap: 11px; align-items: flex-start;
  padding: 14px 16px;
  border: 1px solid var(--border-input);
  border-radius: var(--radius-md);
  background: var(--surface);
  cursor: pointer;
  transition: border-color .14s ease, background .14s ease, box-shadow .14s ease;
}
.radio-card:hover { border-color: var(--border-strong); background: var(--surface-2); }
.radio-card input[type="radio"] { margin: 3px 0 0; accent-color: var(--primary); flex: 0 0 auto; }
.radio-card:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 1px var(--primary) inset;
}
.radio-card:has(input:focus-visible) { box-shadow: var(--focus-ring); }
.radio-card .rc-title { font-weight: 650; font-size: 13.5px; }
.radio-card .rc-desc { margin-top: 3px; font-size: 12.5px; color: var(--text-2); }

.reveal { margin-top: 12px; }
.reveal[hidden] { display: none !important; }

/* --------------------------------------------------------------------------
   12. Progress bar + spinner
   -------------------------------------------------------------------------- */
.progress {
  position: relative;
  height: 5px;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0;
  border-radius: var(--radius-pill);
  background: var(--primary);
  transition: width .45s ease;
}
.progress.is-complete .progress-bar { background: var(--ok); }
.progress.is-failed .progress-bar { background: var(--danger); }

.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--primary-soft-2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  flex: 0 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.pulse-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--primary);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* --------------------------------------------------------------------------
   13. Verification tag pills
   -------------------------------------------------------------------------- */
.vtag {
  display: inline-block;
  padding: 1px 6px;
  margin: 0 2px 0 0;
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 10.5px; font-weight: 600; letter-spacing: .01em;
  line-height: 1.5;
  white-space: nowrap;
  border: 1px solid var(--slate-border);
  background: var(--slate-soft);
  color: var(--slate-ink);
  vertical-align: baseline;
}
.vtag-verified   { background: var(--green-soft);  border-color: var(--green-border);  color: var(--green-ink); }
.vtag-original   { background: var(--blue-soft);   border-color: var(--blue-border);   color: var(--blue-ink); }
.vtag-inference  { background: var(--amber-soft);  border-color: var(--amber-border);  color: var(--amber-ink); }
.vtag-update     { background: var(--purple-soft); border-color: var(--purple-border); color: var(--purple-ink); }
.vtag-not-verified { background: var(--rose-soft); border-color: var(--rose-border);   color: var(--rose-ink); }
.vtag-general-knowledge { background: var(--slate-soft); border-color: var(--slate-border); color: var(--slate-ink); }

.src-ref {
  font-size: 11.5px; color: var(--text-3);
  font-family: var(--font-mono);
}

/* --------------------------------------------------------------------------
   14. Agent cards (discovery) + insight cards
   -------------------------------------------------------------------------- */
.agent-card {
  display: block;
  padding: 15px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}
.agent-card + .agent-card { margin-top: 10px; }
.agent-card-top { display: flex; align-items: center; gap: 12px; }
.agent-id { flex: 1 1 auto; min-width: 0; }
.agent-name { font-size: 14px; font-weight: 650; }
.agent-tagline { font-size: 12.5px; color: var(--text-2); margin-top: 2px; }
.agent-status { flex: 0 0 auto; display: flex; align-items: center; gap: 7px; }
.agent-progress { margin-top: 12px; }
.agent-message {
  margin-top: 7px;
  font-size: 12px; color: var(--text-3);
  min-height: 18px;
  overflow-wrap: anywhere;
}
.agent-card.is-complete { border-color: var(--green-border); }
.agent-card.is-failed { border-color: var(--rose-border); }
.agent-card.is-blocked { opacity: .78; }

.source-strip {
  margin-top: 16px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
}
.source-strip h3 { font-size: 13px; font-weight: 650; margin-bottom: 10px; color: var(--text-2); }

.insight-card { padding: 16px 18px; }
.insight-card-top { display: flex; gap: 12px; align-items: flex-start; }
.insight-main { flex: 1 1 auto; min-width: 0; }
.insight-title { font-size: 14.5px; font-weight: 650; }
.insight-summary { margin-top: 4px; color: var(--text-2); font-size: 13px; }
.insight-detail { margin-top: 8px; font-size: 13px; color: var(--text-2); }
.insight-aside { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.insight-sources { margin-top: 11px; }
.insight-sources .lead { font-size: 12px; color: var(--text-3); margin-bottom: 6px; }
.insight-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-top: 13px;
  padding-top: 12px; border-top: 1px solid var(--border);
}
.insight-card[data-hidden="1"] { display: none; }
.insight-card.is-reviewed { border-color: var(--green-border); }
.review-note {
  margin-top: 10px; padding: 10px 12px;
  border-left: 3px solid var(--primary-border);
  background: var(--primary-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 12.5px; color: var(--text-2);
}

.empty {
  padding: 34px 20px; text-align: center;
  color: var(--text-3);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface-2);
}
.empty h3 { color: var(--text-2); margin-bottom: 6px; }

/* takeaway highlight cards */
.takeaway { padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; height: 100%; }
.takeaway .tk-title { font-size: 13.5px; font-weight: 650; }
.takeaway .tk-body { font-size: 12.5px; color: var(--text-2); flex: 1 1 auto; }

/* --------------------------------------------------------------------------
   15. Modal + slide-over
   -------------------------------------------------------------------------- */
.modal-backdrop, .slideover-backdrop {
  position: fixed; inset: 0;
  background: var(--overlay);
  z-index: 90;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  animation: fade .16s ease;
}
.slideover-backdrop { justify-content: flex-end; padding: 0; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: 100%; max-width: 620px;
  max-height: calc(100vh - 48px);
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: rise .18s ease;
}
@keyframes rise { from { transform: translateY(8px); opacity: .6; } to { transform: none; opacity: 1; } }

.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 20px; border-top: 1px solid var(--border);
  background: var(--surface-2);
}
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; padding: 0;
  border: 0; border-radius: 8px; background: transparent;
  color: var(--text-3); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.icon-btn-lg { width: 38px; height: 38px; }

.readonly-block {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 13px;
}
.counter { margin-top: 6px; text-align: right; font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.counter.is-over { color: var(--danger); font-weight: 650; }

.impact {
  margin-top: 16px; padding: 14px 16px;
  border: 1px solid var(--blue-border);
  background: var(--blue-soft);
  border-radius: var(--radius-md);
}
.impact h4 { display: flex; align-items: center; gap: 7px; color: var(--blue-ink); }
.impact .lead { font-size: 12.5px; color: var(--text-2); margin: 6px 0 10px; }
.impact-item { display: flex; gap: 10px; align-items: flex-start; padding: 7px 0; }
.impact-item + .impact-item { border-top: 1px solid var(--blue-border); }
.impact-name { font-size: 13px; font-weight: 620; }
.impact-desc { font-size: 12.5px; color: var(--text-2); }

.slideover {
  width: 100%; max-width: 520px; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  animation: slidein .2s ease;
}
@keyframes slidein { from { transform: translateX(24px); opacity: .5; } to { transform: none; opacity: 1; } }
.slideover-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.slideover-body { padding: 18px 20px; overflow-y: auto; flex: 1 1 auto; }

.evidence-item { padding: 14px 0; border-bottom: 1px solid var(--border); }
.evidence-item:last-child { border-bottom: 0; }
.evidence-item.is-supplementary {
  border-left: 3px solid var(--amber-border);
  background: var(--amber-soft);
  padding: 14px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
}
.evidence-quote {
  margin: 0 0 10px;
  padding: 10px 14px;
  border-left: 3px solid var(--primary-border);
  background: var(--surface-3);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 13px; color: var(--text);
}
.evidence-item.is-supplementary .evidence-quote { background: var(--surface); border-left-color: var(--amber-border); }
.evidence-meta { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; font-size: 12px; color: var(--text-3); }
.supp-flag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 6px;
  background: var(--amber-soft); border: 1px solid var(--amber-border); color: var(--amber-ink);
  font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  font-family: var(--font-mono);
}

/* --------------------------------------------------------------------------
   16. Report typography
   -------------------------------------------------------------------------- */
.report { }
.report .doc-title { font-size: 26px; margin-bottom: 6px; }
.report-section { margin-bottom: 28px; }
.report-section > h2 {
  font-size: 18px;
  padding-bottom: 8px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.report-section h3 { font-size: 15px; margin: 18px 0 8px; }
.report-section h4 { font-size: 13.5px; margin: 14px 0 6px; color: var(--text-2); }
.prose { font-size: 13.5px; line-height: 1.65; color: var(--text); max-width: 78ch; }
.prose p + p { margin-top: 10px; }

.stage {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 24px 26px;
  margin-bottom: 20px;
}
.stage-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 6px; }
.stage-head .stage-id {
  font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-3);
}
.stage-head h2 { font-size: 20px; margin-top: 3px; }
.core-question {
  margin: 12px 0 18px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  border: 1px solid var(--primary-border);
  color: var(--primary-text);
  font-size: 13.5px; font-weight: 550;
}
.core-question strong { font-weight: 700; }
.stage-meta { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }

.subblock { margin: 18px 0; }
.subblock > h3 {
  font-size: 12px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--text-3); margin-bottom: 9px;
}
.callout {
  padding: 13px 16px;
  border-left: 3px solid var(--primary);
  background: var(--primary-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 13px; color: var(--text-2);
}
.callout.is-amber { border-left-color: var(--warn); background: var(--amber-soft); color: var(--amber-ink); }
.callout.is-rose { border-left-color: var(--danger); background: var(--rose-soft); color: var(--rose-ink); }
.callout.is-slate { border-left-color: var(--border-strong); background: var(--surface-3); color: var(--text-2); }
.callout strong { color: inherit; }

ol.takeaways { padding-left: 22px; font-size: 13.5px; }
ol.takeaways li { margin-bottom: 8px; }
ul.checks { list-style: none; padding-left: 0; }
ul.checks li { display: flex; gap: 9px; align-items: flex-start; margin-bottom: 8px; font-size: 13.5px; }
ul.checks .ic { flex: 0 0 auto; margin-top: 2px; color: var(--ok); }

.stage-toc { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }

/* contradictions */
.contra { padding: 0; overflow: hidden; }
.contra-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.contra-sides { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.contra-side { padding: 16px 18px; }
.contra-side + .contra-side { border-left: 1px solid var(--border); }
.contra-side .side-label {
  font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-3); margin-bottom: 6px;
}
.contra-side .side-source { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.contra-side .side-name { font-size: 13.5px; font-weight: 650; }
.contra-claim { font-size: 13px; color: var(--text-2); }
.contra-reason { padding: 13px 18px; border-top: 1px solid var(--border); background: var(--surface-2); font-size: 12.5px; color: var(--text-2); }
.contra-actions { padding: 14px 18px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.no-autoresolve {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 14px; margin-bottom: 16px;
  border: 1px dashed var(--rose-border); background: var(--rose-soft); color: var(--rose-ink);
  border-radius: var(--radius-md); font-size: 13px; font-weight: 600;
}

/* --------------------------------------------------------------------------
   17. Misc layout helpers
   -------------------------------------------------------------------------- */
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; gap: 12px; align-items: center; }
.row-between { display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.text-sm { font-size: 12.5px; }
.text-muted { color: var(--text-2); }
.text-faint { color: var(--text-3); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mono { font-family: var(--font-mono); font-size: 12px; }
.break { overflow-wrap: anywhere; }

.list-plain { list-style: none; padding-left: 0; }
.list-plain li { display: flex; gap: 9px; align-items: flex-start; }

.included-item { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; }
.included-item + .included-item { border-top: 1px solid var(--border); }
.included-name { font-size: 13.5px; font-weight: 650; }
.included-desc { font-size: 12.5px; color: var(--text-2); margin-top: 2px; }

.run-row { display: flex; align-items: center; gap: 14px; padding: 14px 18px; }
.run-row + .run-row { border-top: 1px solid var(--border); }
.run-row .run-main { flex: 1 1 auto; min-width: 0; }
.run-row .run-title { font-size: 13.5px; font-weight: 650; }

/* --------------------------------------------------------------------------
   18. Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 1120px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .sidebar { width: var(--sidebar-w-collapsed); padding: 18px 10px 14px; align-items: center; }
  .sidebar-head { width: 100%; justify-content: center; margin-bottom: 18px; }
  .sidebar .brand { flex: 0 0 auto; padding: 4px 0; justify-content: center; }
  .sidebar-toggle { display: none; }
  .sidebar .brand-word, .sidebar .nav-label, .sidebar .nav-group-label { display: none; }
  .nav { width: 100%; }
  .nav-item { justify-content: center; padding: 10px 0; }
  .sidebar .flow-link { justify-content: center; padding-left: 0; padding-right: 0; }
  .main { margin-left: var(--sidebar-w-collapsed); padding: 20px 18px 56px; }
  .grid-3, .grid-2, .field-row, .radio-cards, .contra-sides { grid-template-columns: minmax(0, 1fr); }
  .contra-side + .contra-side { border-left: 0; border-top: 1px solid var(--border); }
  .slideover { max-width: 100%; }
  .stage { padding: 18px 16px; }
}

@media (max-width: 620px) {
  .stats, .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal { max-width: 100%; max-height: 92vh; border-radius: var(--radius) var(--radius) 0 0; }
  .insight-card-top { flex-wrap: wrap; }
  .page-head-row { flex-direction: column; align-items: stretch; }
}

/* --------------------------------------------------------------------------
   19. Reduced motion
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  .spinner { border-top-color: var(--primary); }
}

/* --------------------------------------------------------------------------
   20. Dark theme — tokens only
   -------------------------------------------------------------------------- */
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;

    --bg: #0d1117;
    --bg-alt: #11161f;
    --surface: #151b24;
    --surface-2: #1a212b;
    --surface-3: #212a36;
    --overlay: rgba(2, 6, 14, .66);

    --border: #262f3c;
    --border-strong: #35404f;
    --border-input: #3a4553;

    --text: #e8edf5;
    --text-2: #a7b3c4;
    --text-3: #78859a;
    --text-inv: #0b1018;

    --primary: #3b82f6;
    --primary-hover: #60a5fa;
    --primary-active: #2563eb;
    --primary-soft: #16233a;
    --primary-soft-2: #1d3050;
    --primary-border: #2c4874;
    --primary-text: #93b8fb;

    --green-soft: #10241b;   --green-border: #1f4634;  --green-ink: #6ee7b7;
    --blue-soft: #12233c;    --blue-border: #24406b;   --blue-ink: #93b8fb;
    --purple-soft: #201a38;  --purple-border: #3a2f63; --purple-ink: #c4b5fd;
    --indigo-soft: #191d3d;  --indigo-border: #2e3568; --indigo-ink: #a5b4fc;
    --teal-soft: #0e2725;    --teal-border: #1d4844;   --teal-ink: #5eead4;
    --amber-soft: #2a2010;   --amber-border: #55411b;  --amber-ink: #fcd34d;
    --rose-soft: #2c1219;    --rose-border: #5c2231;   --rose-ink: #fda4af;
    --slate-soft: #1c242f;   --slate-border: #2f3a48;  --slate-ink: #a7b3c4;

    --ok: #34d399;
    --warn: #fbbf24;
    --danger: #fb7185;
    --muted: #8a97a8;

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, .45), 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-md: 0 4px 14px rgba(0, 0, 0, .5), 0 1px 3px rgba(0, 0, 0, .35);
    --shadow-lg: 0 18px 44px rgba(0, 0, 0, .62), 0 3px 10px rgba(0, 0, 0, .4);
    --focus-ring: 0 0 0 3px rgba(59, 130, 246, .45);
  }
}

/* --------------------------------------------------------------------------
   21. Print
   -------------------------------------------------------------------------- */
/* Printing keeps the colours: dots, chips, tag pills and timeline bars carry
   meaning, and browsers drop backgrounds unless the page opts in. */
html, body, * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

@media print {
  html, body, * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  .sidebar, .toolbar, .btn, .pills, .no-print { display: none !important; }
  .main { margin-left: 0; padding: 0; }
  .card, .stage { box-shadow: none; break-inside: avoid; }
  .table-wrap { max-height: none; overflow: visible; }
}

/* Wide dialog for table snapshots: report tables need the room. */
.modal.modal-wide { width: min(1100px, 96vw); max-width: none; }

/* Agent roster on the review gate page. */
.agent-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.agent-list li { display: flex; align-items: flex-start; gap: 12px; }
.agent-list li .sub { margin: 2px 0 0; }

/* Question-and-answer record in a stage report. */
.qa-item { padding: 12px 0; border-top: 1px solid var(--hairline); }
.qa-item:first-of-type { border-top: 0; }
.qa-question { font-weight: 650; margin: 0 0 4px; }
.qa-answer { margin: 0 0 6px; }
.qa-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
           margin: 0; font-size: 12px; }
.src-chip { display: inline-block; padding: 1px 8px; border-radius: 999px;
            border: 1px solid var(--blue-border); background: var(--blue-soft);
            color: var(--blue-ink); font-size: 11px; }

/* Open-web pages consulted, listed under an insight's evidence. */
.site-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 12px; }
.site-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.site-list a { word-break: break-word; }


/* --------------------------------------------------------------------------
   20. The flow: stepper, phase groups, gate panel, decision states
   -------------------------------------------------------------------------- */
.flow { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.flow-step { position: relative; }
.flow-link {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); font-size: 13px; font-weight: 500;
}
.flow-link:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.flow-link.is-disabled { color: var(--text-3); cursor: default; }
.flow-link.is-disabled:hover { background: transparent; }
.flow-num {
  flex: 0 0 auto; width: 20px; height: 20px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  border: 1.5px solid var(--border-strong); color: var(--text-3); background: var(--surface);
}
.flow-text { display: flex; flex-direction: column; min-width: 0; }
.flow-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.flow-desc { font-size: 11.5px; color: var(--text-3); font-weight: 400; margin-top: 1px; }
.flow-step.is-done .flow-num { background: var(--green-soft); border-color: var(--green-border); color: var(--green-ink); }
.flow-step.is-current .flow-link { background: var(--primary-soft); color: var(--primary-text); font-weight: 600; }
.flow-step.is-current .flow-num { background: var(--primary); border-color: var(--primary); color: #fff; }
.flow-step.is-failed .flow-num { background: var(--rose-soft); border-color: var(--rose-border); color: var(--rose-ink); }
.flow-step.is-upcoming .flow-link { opacity: .7; }
.flow.is-compact .flow-link { padding: 6px 8px; }
.sidebar .flow-desc { display: none; }

.phase-group { margin-top: 18px; }
.phase-group + .phase-group { margin-top: 26px; }
.phase-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px; margin-bottom: 10px;
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--surface-2);
}
.phase-head .phase-num {
  width: 26px; height: 26px; border-radius: 50%; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  background: var(--surface); border: 1.5px solid var(--border-strong); color: var(--text-2);
}
.phase-head h2 { font-size: 15px; margin: 0; }
.phase-head .sub { margin: 0; font-size: 12.5px; }
.phase-head .phase-state { margin-left: auto; display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; }
.phase-group.is-complete .phase-head { border-color: var(--green-border); background: var(--green-soft); }
.phase-group.is-complete .phase-num { background: var(--green-ink); border-color: var(--green-ink); color: #fff; }
.phase-group.is-complete .phase-state { color: var(--green-ink); }
.phase-group.is-running .phase-head { border-color: var(--primary-border); background: var(--primary-soft); }
.phase-group.is-running .phase-num { background: var(--primary); border-color: var(--primary); color: #fff; }
.phase-group.is-running .phase-state { color: var(--primary-text); }
.phase-group.is-failed .phase-head { border-color: var(--rose-border); background: var(--rose-soft); }
.phase-group.is-failed .phase-state { color: var(--rose-ink); }
.phase-group.is-gated .phase-head, .phase-group.is-queued .phase-head { border-style: dashed; }
.phase-group.is-gated .phase-state, .phase-group.is-queued .phase-state { color: var(--text-3); }
.phase-gate {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin: 16px 0 0; padding: 12px 16px;
  border: 1px dashed var(--amber-border); border-radius: var(--radius-md);
  background: var(--amber-soft); color: var(--amber-ink); font-size: 13px;
}
.phase-gate.is-passed { border-color: var(--green-border); background: var(--green-soft); color: var(--green-ink); }
.phase-gate .ic { flex: 0 0 auto; }

.gate-panel { border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); box-shadow: var(--shadow-xs); }
.gate-panel.is-blocked { border-color: var(--rose-border); }
.gate-panel.is-ready { border-color: var(--green-border); }
.gate-panel.is-done { border-color: var(--green-border); background: var(--green-soft); }
.gate-body { padding: 16px 18px; display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.gate-main { flex: 1 1 320px; min-width: 0; }
.gate-title { font-size: 15px; font-weight: 650; display: flex; align-items: center; gap: 8px; }
.gate-sub { color: var(--text-2); font-size: 13px; margin-top: 4px; }
.gate-actions { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.gate-actions .hint { font-size: 12px; color: var(--text-3); max-width: 280px; text-align: right; }
@media (max-width: 620px) {
  .gate-actions { flex: 1 1 100%; min-width: 0; align-items: stretch; }
  .gate-actions form { width: 100%; min-width: 0; }
  .gate-actions .btn { max-width: 100%; white-space: normal; }
  .gate-actions .hint { max-width: 100%; text-align: left; }
}
.gate-blockers { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.gate-blockers li {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 8px 10px; border-radius: var(--radius-sm);
  background: var(--rose-soft); color: var(--rose-ink); font-size: 12.5px;
}
.gate-blockers li .ic { flex: 0 0 auto; margin-top: 1px; }
.gate-blockers a { color: inherit; font-weight: 600; }
.gate-counts { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

.insight-card.is-requires-input { border-color: var(--rose-border); }
.insight-card.is-requires-input.is-reviewed { border-color: var(--green-border); }
.input-reason {
  margin-top: 10px; padding: 10px 12px;
  border-left: 3px solid var(--danger);
  background: var(--rose-soft); color: var(--rose-ink);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 12.5px;
}
.input-reason strong { color: inherit; }
.input-reason.is-resolved { border-left-color: var(--green-border); background: var(--green-soft); color: var(--green-ink); }
.review-note.is-input { border-left-color: var(--amber-border); background: var(--amber-soft); color: var(--amber-ink); }
.review-note.is-revision { border-left-color: var(--blue-border); background: var(--blue-soft); color: var(--blue-ink); }
.review-note strong { color: inherit; }
.decision-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.decision-row .lead { font-size: 12px; color: var(--text-3); }
.insight-card.is-locked .btn { display: none; }
.insight-card.is-locked .btn.btn-ghost, .insight-card.is-locked .btn[data-modal-url$="/table"] { display: inline-flex; }

.modal-explain {
  padding: 12px 14px; margin-bottom: 14px;
  border-radius: var(--radius-sm); font-size: 13px; line-height: 1.5;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2);
}
.modal-explain.is-modify { border-color: var(--blue-border); background: var(--blue-soft); color: var(--blue-ink); }
.modal-explain.is-input { border-color: var(--amber-border); background: var(--amber-soft); color: var(--amber-ink); }
.modal-explain strong { color: inherit; }
.modal-explain ul { margin: 6px 0 0 18px; padding: 0; }

.doc-state {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px; margin-bottom: 18px;
  border-radius: var(--radius-md); font-size: 13.5px;
}
.doc-state.is-draft { border: 1px dashed var(--amber-border); background: var(--amber-soft); color: var(--amber-ink); }
.doc-state.is-approved { border: 1px solid var(--green-border); background: var(--green-soft); color: var(--green-ink); }
.doc-state strong { color: inherit; }
.doc-state .spacer { flex: 1 1 auto; }

.nav-project-meta { padding: 2px 10px 8px; }
.nav-project-name { font-size: 13px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-project-meta .meta { margin-top: 4px; }
@media (max-width: 900px) { .sidebar .flow-text, .sidebar .nav-project-meta { display: none; } }

.insight-card.is-flash, .contra.is-flash { animation: card-flash 1.6s ease-out; }
@keyframes card-flash { 0% { box-shadow: 0 0 0 3px var(--green-border); } 100% { box-shadow: var(--shadow-xs); } }
textarea.is-invalid { border-color: var(--danger); }

.callout.is-green { border-left-color: var(--green-border); background: var(--green-soft); color: var(--green-ink); }

.phase-toggle {
  width: 100%; text-align: left; cursor: pointer; font: inherit; color: inherit;
  margin-bottom: 0; border-radius: var(--radius-md) var(--radius-md) 0 0;
}
.phase-toggle:hover { filter: brightness(.98); }
.phase-toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.phase-id { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }
.phase-title { font-size: 15px; font-weight: 650; }
.phase-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; margin-left: auto; }
.phase-head .phase-state { margin-left: 0; }
.phase-chevron { display: inline-flex; color: var(--text-3); transition: transform .16s ease; margin-left: 6px; }
.phase-group.is-open .phase-chevron { transform: rotate(90deg); }
.phase-progress { margin: 0; border-radius: 0; height: 8px; }
.phase-progress .progress-bar { border-radius: 0; }
.phase-hint { padding: 6px 16px 0; font-size: 12px; }
.phase-body { margin-top: 12px; }
.phase-body .agent-card + .agent-card { margin-top: 10px; }

/* --------------------------------------------------------------------------
   21. Insight cards (five-part review cards) and the card grid
   -------------------------------------------------------------------------- */
.insight-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
@media (max-width: 900px) { .insight-grid { grid-template-columns: minmax(0, 1fr); } }
.insight-grid > [data-hidden="1"] { display: none; }

.icard {
  display: flex; flex-direction: column; gap: 10px;
  padding: 16px 18px;
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--surface); box-shadow: var(--shadow-xs);
  border-top: 3px solid var(--border-strong);
}
.icard.is-reviewed { border-top-color: var(--green-border); }
.icard.needs-review { border-top-color: var(--amber-border); }
.icard.not-covered { background: var(--surface-2); }
.icard.is-flash { animation: card-flash 1.6s ease-out; }

.icard-head { display: flex; align-items: center; gap: 10px; }
.icard-num {
  flex: 0 0 auto; padding: 2px 8px; border-radius: var(--radius-sm);
  background: var(--primary-soft); color: var(--primary-text);
  font-weight: 700; font-size: 12.5px; font-family: var(--font-mono);
}
.icard-title { flex: 1 1 auto; min-width: 0; font-size: 15px; font-weight: 700; margin: 0; }
.icard-agent {
  flex: 0 0 auto; font-size: 11px; color: var(--text-3);
  padding: 2px 8px; border: 1px solid var(--border); border-radius: var(--radius-pill);
  white-space: nowrap;
}
.icard-finding { margin: 0; font-size: 13.5px; color: var(--text); line-height: 1.5; }

.icard-status { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-2); font-weight: 600; }
@media (max-width: 620px) { .icard-status { flex-wrap: wrap; } }
@media (max-width: 620px) { .chip-source { max-width: 100%; min-width: 0; white-space: normal; overflow-wrap: anywhere; } }
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: 0 0 auto; }
.status-dot.is-ready { background: var(--ok); }
.status-dot.is-review { background: var(--warn); }
.status-sep { color: var(--border-strong); font-weight: 400; }
.status-text { font-weight: 600; }
.icard-why { margin: -4px 0 0; font-size: 12px; color: var(--text-3); line-height: 1.45; }
.icard-why.is-resolved { color: var(--text-3); }

.icard-evidence { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; background: var(--surface-2); }
.icard-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.icard-metric { padding: 8px 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.icard-metric-value { font-size: 17px; font-weight: 700; color: var(--text); line-height: 1.2; overflow-wrap: anywhere; }
.icard-metric-label { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.icard-table td, .icard-table th { font-size: 12px; }
.icard-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; counter-reset: step; }
.icard-steps li {
  counter-increment: step; display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px 5px 8px; font-size: 12px; font-weight: 600;
  background: var(--primary-soft); color: var(--primary-text);
  border-radius: var(--radius-sm);
}
.icard-steps li::before {
  content: counter(step); width: 16px; height: 16px; border-radius: 50%;
  background: var(--primary); color: #fff; font-size: 10px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.icard-points { margin: 0; padding-left: 20px; font-size: 12.5px; color: var(--text-2); display: flex; flex-direction: column; gap: 4px; }
.icard-points li::marker { color: var(--primary); font-weight: 700; }

.icard-section { display: flex; flex-direction: column; gap: 4px; }
.icard-label { font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); }
.icard-text { margin: 0; font-size: 12.5px; color: var(--text-2); line-height: 1.5; }
.icard-note { margin: 0; font-size: 12px; color: var(--text-3); display: flex; align-items: center; gap: 6px; }

.icard-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding-top: 10px; border-top: 1px solid var(--border); margin-top: 2px; }
.icard-links { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.icard-link { font-size: 12.5px; font-weight: 600; color: var(--primary-text); display: inline-flex; align-items: center; gap: 4px; }
.icard-link.as-button { background: none; border: 0; padding: 0; cursor: pointer; font: inherit; font-size: 12.5px; font-weight: 600; color: var(--primary-text); }
.icard-link:hover, .icard-link.as-button:hover { text-decoration: underline; }
.icard-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.icard-menu { position: relative; margin-left: auto; }
.icard-menu > summary {
  list-style: none; border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text-2);
}
.icard-menu > summary::-webkit-details-marker { display: none; }
.icard-menu[open] > summary { background: var(--surface-3); color: var(--text); }
.icard-menu-popover {
  position: absolute; right: 0; bottom: calc(100% + 8px); z-index: 25;
  min-width: 184px; padding: 6px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); box-shadow: var(--shadow-md);
}
.icard-menu-item {
  width: 100%; display: flex; align-items: center; gap: 8px;
  padding: 8px 9px; border: 0; border-radius: 7px;
  background: transparent; color: var(--text-2);
  font: inherit; font-size: 12.5px; font-weight: 550; text-align: left;
  cursor: pointer; text-decoration: none;
}
.icard-menu-item:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.icard-menu-item .ic { flex: 0 0 auto; color: var(--text-3); }
.phase-cards { margin-bottom: 28px; }
.phase-cards-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.phase-cards-head h3 { margin: 0; font-size: 15px; }
.phase-cards-head .count { color: var(--text-3); font-weight: 500; }
.phase-cards.is-new .phase-cards-head h3 { color: var(--primary-text); }

/* Evidence marks: a dot per tag, a quiet chip per source, one legend per page */
.vdot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin: 0 5px 1px 0; vertical-align: middle; border: 1px solid transparent;
  background: var(--slate-border);
}
.vdot.vtag-verified { background: var(--ok); border-color: var(--green-border); }
.vdot.vtag-inference { background: var(--warn); border-color: var(--amber-border); }
.vdot.vtag-original { background: var(--primary); border-color: var(--blue-border); }
.vdot.vtag-update { background: var(--purple-ink); border-color: var(--purple-border); }
.vdot.vtag-not-verified { background: var(--danger); border-color: var(--rose-border); }
.vdot.vtag-general-knowledge { background: var(--slate-ink); border-color: var(--slate-border); opacity: .55; }
.vdot-label { display: inline-flex; align-items: center; gap: 2px; font-size: 12px; color: var(--text-2); }
.vsrc {
  display: inline-block; margin-left: 4px; padding: 0 6px;
  font-size: 11px; color: var(--text-3); background: var(--surface-3);
  border-radius: var(--radius-pill); white-space: nowrap; vertical-align: middle;
}
.vlegend {
  display: flex; flex-wrap: wrap; gap: 6px 16px;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); font-size: 12px; color: var(--text-2);
}
.vlegend.is-compact { padding: 6px 10px; font-size: 11.5px; }
.icon-btn-sm { width: 22px; height: 22px; padding: 0; }
.import-box summary::-webkit-details-marker { display: none; }

/* Persistent insight research workspace */
.insight-workspace {
  width: min(840px, calc(100vw - 48px));
  max-width: none;
  height: min(80vh, 760px);
  position: relative;
  overflow: hidden;
}
.insight-workspace-grid {
  display: grid;
  grid-template-columns: 1fr 2fr;
  flex: 1 1 auto;
  min-height: 0;
}
.insight-workspace-context {
  overflow: auto;
  padding: 16px;
  border-right: 1px solid var(--border);
  background: var(--surface-2);
}
.insight-workspace-context .icard-label { margin: 0 0 6px; }
.insight-workspace-context .icard-label:not(:first-child) { margin-top: 16px; }
.insight-workspace-chat {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
}
.insight-workspace-messages { flex: 1 1 auto; overflow: auto; padding: 16px; }
.insight-workspace-composer { padding: 12px 16px; border-top: 1px solid var(--border); }
.insight-workspace-composer textarea { width: 100%; min-height: 66px; resize: vertical; }
.insight-workspace-actions { display: flex; align-items: center; gap: 8px; justify-content: flex-end; margin-top: 8px; }
.insight-workspace-actions .meta { margin-right: auto; }
.insight-workspace-preview { position: absolute; inset: 62px 0 0; background: var(--surface); z-index: 2; }
.insight-workspace-preview[hidden] { display: none; }
.insight-workspace-preview .insight-workspace-proposal { height: 100%; margin: 0; overflow: auto; padding: 20px; }
.workspace-card-preview { width: 100%; margin: 0; }
.workspace-card-preview .table-wrap { max-width: 100%; overflow-x: auto; }
.workspace-change-group { margin: 18px 0; }
.workspace-change-group h3 { margin: 0 0 8px; font-size: 14px; }
.workspace-change { padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.workspace-change + .workspace-change { margin-top: 8px; }
.workspace-change p { margin: 5px 0 0; }
.workspace-item-changes { margin: 8px 0 0; padding-left: 18px; }
.workspace-item-changes .is-added { color: var(--green-ink); }
.workspace-item-changes .is-removed { color: var(--danger); }
.workspace-change-sources { margin-top: 8px; }
.workspace-removal-warning { margin: 14px 0; padding: 10px 12px; border-left: 3px solid var(--amber-border); background: var(--amber-soft); color: var(--amber-ink); }
.workspace-unchanged { margin: 16px 0; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.workspace-unchanged summary { cursor: pointer; font-weight: 600; }
.workspace-unchanged ul { margin: 8px 0 0; padding-left: 18px; }
.insight-workspace-message { max-width: 88%; margin: 0 0 12px; padding: 11px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.insight-workspace-message.is-user { margin-left: auto; background: var(--primary-soft); border-color: var(--primary-border); }
.insight-workspace-message.is-failed { border-color: var(--danger); }
.insight-workspace-message-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; font-size: 12px; }
.insight-workspace-message-content p { margin: 0; }
.insight-workspace-message-content p + p, .insight-workspace-message-content ul { margin: 8px 0 0; }
.insight-workspace-message-content ul { padding-left: 18px; }
.insight-workspace-message-content code { padding: 1px 4px; border-radius: 4px; background: var(--surface-3); }
.source-chip-toggle { cursor: pointer; font: inherit; }
.insight-workspace-error { margin: 8px 0 0; color: var(--danger); }
.source-chip { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 8px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text-2); font-size: 11.5px; text-decoration: none; }
.source-chip:hover { border-color: var(--primary-border); color: var(--text); }
.insight-workspace-summary-marker { margin: 12px 0; padding: 7px 10px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); color: var(--text-3); font-size: 11.5px; text-align: center; }
.insight-workspace-lock { margin: 14px 0 0; }

@media (max-width: 900px) {
  .insight-workspace-grid { grid-template-columns: 1fr; grid-template-rows: 132px minmax(0, 1fr); }
  .insight-workspace-context { border-right: 0; border-bottom: 1px solid var(--border); }
}

@media (max-width: 620px) {
  .insight-workspace { width: 100%; height: 92vh; }
  .insight-workspace-actions { align-items: stretch; flex-wrap: wrap; }
  .insight-workspace-actions .meta { flex-basis: 100%; }
}

/* --------------------------------------------------------------------------
   22. LOT rules workspace: sections, rule cards, visuals
   -------------------------------------------------------------------------- */
.rules-preview { display:grid; grid-template-columns:repeat(auto-fill,minmax(280px,1fr)); gap:10px; }
.rules-preview-sec { display:flex; gap:10px; align-items:flex-start; padding:12px 14px; border:1px solid var(--border); border-radius:var(--radius-md); background:var(--surface); }
.rules-tabs { display:flex; gap:6px; flex-wrap:wrap; margin:10px 0 16px; border-bottom:1px solid var(--border); padding-bottom:10px; }
.rules-tab { display:inline-flex; align-items:center; gap:7px; padding:7px 12px; border-radius:var(--radius-pill); border:1px solid var(--border); font-size:12.5px; font-weight:600; color:var(--text-2); background:var(--surface); }
.rules-tab:hover { text-decoration:none; background:var(--surface-3); }
.rules-tab.is-active { background:var(--primary-soft); color:var(--primary-text); border-color:var(--primary-border); }
.rules-tab-num { width:18px; height:18px; border-radius:50%; background:var(--surface-3); font-size:11px; display:inline-flex; align-items:center; justify-content:center; }
.rules-tab.is-active .rules-tab-num { background:var(--primary); color:#fff; }
.rules-tab-count { font-size:11px; color:var(--text-3); }
.rules-grid { display:grid; grid-template-columns:repeat(2, minmax(0,1fr)); gap:16px; align-items:start; }
@media (max-width: 1100px) { .rules-grid { grid-template-columns:1fr; } }
.rules-section .phase-cards-head { margin-bottom:6px; }

.rcard { display:flex; flex-direction:column; gap:10px; padding:16px 18px; border:1px solid var(--border); border-top:3px solid var(--border-strong); border-radius:var(--radius-md); background:var(--surface); box-shadow:var(--shadow-xs); }
.rcard.is-reviewed { border-top-color:var(--green-border); } .rcard.needs-review { border-top-color:var(--amber-border); }
.rcard.is-flash { animation: card-flash 1.6s ease-out; }
.rcard-head { display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.rcard-title { flex:1 1 auto; font-size:15px; font-weight:700; margin:0; min-width:0; }
.rcard-objective { margin:-4px 0 0; font-size:12.5px; color:var(--text-3); }
.rcard-rule { padding:10px 12px; border-left:3px solid var(--primary); background:var(--primary-soft); border-radius:0 var(--radius-sm) var(--radius-sm) 0; }
.rcard-statement { margin:2px 0 0; font-size:13.5px; font-weight:600; color:var(--text); }
.rcard-rationale { margin:6px 0 0; font-size:12.5px; color:var(--text-2); }
.conf-pill { font-size:11px; padding:2px 9px; border-radius:var(--radius-pill); border:1px solid var(--border); background:var(--surface-2); color:var(--text-2); white-space:nowrap; }
.conf-verified_indication, .conf-verified_class { background:var(--green-soft); border-color:var(--green-border); color:var(--green-ink); }
.conf-borrowed { background:var(--amber-soft); border-color:var(--amber-border); color:var(--amber-ink); }
.conf-original { background:var(--blue-soft); border-color:var(--blue-border); color:var(--blue-ink); }
.rcard-params { display:grid; grid-template-columns:repeat(auto-fit,minmax(150px,1fr)); gap:8px; }
.param { border:1px solid var(--border); border-radius:var(--radius-sm); padding:8px 10px; background:var(--surface-2); }
.param-value { font-size:18px; font-weight:700; line-height:1.2; overflow-wrap:anywhere; } .param-unit { font-size:12px; color:var(--text-3); font-weight:500; }
.param-label { font-size:11.5px; color:var(--text-2); margin-top:2px; }
.param-prov { font-size:10.5px; margin-top:4px; text-transform:uppercase; letter-spacing:.06em; color:var(--text-3); }
.prov-research { color:var(--green-ink); } .prov-client { color:var(--primary-text); }
.rcard-gaps { padding:8px 12px; border-left:3px solid var(--amber-border); background:var(--amber-soft); border-radius:0 var(--radius-sm) var(--radius-sm) 0; font-size:12.5px; }
.rcard-gaps ul { margin:4px 0 0 16px; padding:0; }
.rule-table td, .rule-table th { font-size:12px; }
.role-pill { font-size:11px; padding:1px 8px; border-radius:var(--radius-pill); background:var(--surface-3); color:var(--text-2); }
.role-branded { background:var(--primary-soft); color:var(--primary-text); } .role-supportive { background:var(--slate-soft); }
.code-chip { display:inline-block; font-family:var(--font-mono); font-size:11px; padding:1px 7px; border-radius:6px; background:var(--primary-soft); color:var(--primary-text); margin:1px 3px 1px 0; }
.code-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(200px,1fr)); gap:8px; }
.code-card { border:1px solid var(--border); border-radius:var(--radius-sm); padding:8px 10px; background:var(--surface-2); }
.code-card-code { font-family:var(--font-mono); font-weight:700; font-size:14px; color:var(--primary-text); }
.code-card-sys { font-size:11px; color:var(--text-3); text-transform:uppercase; letter-spacing:.05em; }
.code-card-desc { font-size:12px; color:var(--text-2); margin-top:3px; }

.funnel { list-style:none; padding:0; margin:6px 0 0; }
.funnel-step { width:var(--w, 100%); margin:0 auto 6px; }
.funnel-box { border:1px solid var(--primary-border); background:var(--primary-soft); border-radius:var(--radius-sm); padding:8px 12px; }
.funnel-title { font-weight:700; font-size:13px; display:flex; align-items:center; gap:6px; }
.funnel-num { width:18px; height:18px; border-radius:50%; background:var(--primary); color:#fff; font-size:11px; display:inline-flex; align-items:center; justify-content:center; }
.funnel-criteria { font-size:12.5px; margin-top:2px; } .funnel-why { font-size:11.5px; color:var(--text-3); margin-top:2px; }

.flow-ladder { list-style:none; padding:0; margin:6px 0 0; }
.ladder-step { border-left:3px solid var(--primary); padding:6px 12px 8px; margin-bottom:8px; background:var(--surface-2); border-radius:0 var(--radius-sm) var(--radius-sm) 0; }
.ladder-q { font-weight:600; font-size:13px; display:flex; gap:8px; align-items:center; }
.ladder-num { width:18px; height:18px; border-radius:50%; background:var(--primary); color:#fff; font-size:11px; display:inline-flex; align-items:center; justify-content:center; flex:0 0 auto; }
.ladder-branches { display:flex; gap:10px; flex-wrap:wrap; margin-top:5px; font-size:12.5px; }
.ladder-branch { padding:3px 9px; border-radius:var(--radius-sm); background:var(--surface); border:1px solid var(--border); }
.ladder-tag { font-weight:700; margin-right:6px; } .is-yes .ladder-tag { color:var(--ok); } .is-no .ladder-tag { color:var(--danger); }

.tl { border:1px solid var(--border); border-radius:var(--radius-sm); padding:10px 12px; background:var(--surface); }
.tl + .tl { margin-top:8px; }
.tl-head { display:flex; justify-content:space-between; gap:10px; flex-wrap:wrap; font-size:12.5px; margin-bottom:6px; }
.tl-title { font-weight:700; } .tl-expected { color:var(--green-ink); font-weight:600; display:inline-flex; align-items:center; gap:4px; }
.tl-lane { display:grid; grid-template-columns:120px 1fr; gap:8px; align-items:center; margin:3px 0; }
.tl-lane-label { font-size:12px; color:var(--text-2); text-align:right; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.tl-lane-label.is-line { font-weight:700; color:var(--text); }
.tl-track { position:relative; height:22px; background:var(--surface-3); border-radius:4px; overflow:hidden; }
.tl-bar { position:absolute; top:3px; height:16px; border-radius:4px; font-size:10.5px; line-height:16px; padding:0 6px; white-space:nowrap; overflow:hidden; color:#fff; background:var(--primary); }
.tl-bar.tl-regimen { background:var(--primary); } .tl-bar.tl-episode { background:#0ea5a4; } .tl-bar.tl-claim { background:#6d28d9; } .tl-bar.tl-dx { background:var(--danger); }
.tl-bar.tl-gap { background:var(--surface); color:var(--text-2); border:1px dashed var(--border-strong); } .tl-bar.tl-line { background:var(--ok); }
.tl-axis { position:relative; height:14px; margin-left:128px; font-size:10px; color:var(--text-3); }
.tl-axis span { position:absolute; transform:translateX(-50%); }
.tl-axis span:first-child { transform:none; }
.tl-tracks { display:flex; flex-direction:column; gap:3px; }
.tl-bar.label-out { overflow:visible; padding:0; }
.tl-bar.label-out span { position:absolute; left:100%; top:0; padding-left:6px; color:var(--text-2); font-weight:600; }
.tl-bar.label-tip span { display:none; }
.tl-key { display:flex; flex-wrap:wrap; gap:4px 12px; margin:6px 0 0 128px; font-size:10.5px; color:var(--text-3); }
.tl-key i { display:inline-block; width:8px; height:8px; border-radius:2px; margin-right:4px; vertical-align:middle; }
.tl-point { position:absolute; top:3px; background:none; height:16px; display:flex; align-items:center; gap:5px; font-size:10.5px; color:var(--text-2); font-weight:600; white-space:nowrap; transform:translateX(-6px); }
.tl-point i { display:block; width:12px; height:12px; border-radius:2px; transform:rotate(45deg); background:var(--danger); flex:0 0 auto; }
.tl-point.tl-claim i { background:#6d28d9; }
.param-value.is-text { font-size:13.5px; font-weight:600; }
.gate-fold { margin-top:10px; font-size:12.5px; } .gate-fold summary { cursor:pointer; color:var(--text-2); font-weight:600; }
.gate-quiet { list-style:none; margin:8px 0 0; padding:0; display:grid; grid-template-columns:repeat(auto-fill, minmax(260px, 1fr)); gap:4px 16px; }
.gate-quiet li { display:flex; justify-content:space-between; gap:8px; padding:3px 0; border-bottom:1px dashed var(--border); }
.gate-quiet a { color:inherit; font-weight:600; }
.rcard.is-wide { grid-column:1 / -1; }
