/* === self-hosted fonts: Inter (body) + Space Grotesk (display/instrument) === */
@font-face { font-family:"Inter"; font-weight:400; font-display:swap; src:url("/static/fonts/inter-400.woff2") format("woff2"); }
@font-face { font-family:"Inter"; font-weight:500; font-display:swap; src:url("/static/fonts/inter-500.woff2") format("woff2"); }
@font-face { font-family:"Inter"; font-weight:600; font-display:swap; src:url("/static/fonts/inter-600.woff2") format("woff2"); }
@font-face { font-family:"Inter"; font-weight:700; font-display:swap; src:url("/static/fonts/inter-700.woff2") format("woff2"); }
@font-face { font-family:"Space Grotesk"; font-weight:500; font-display:swap; src:url("/static/fonts/space-grotesk-500.woff2") format("woff2"); }
@font-face { font-family:"Space Grotesk"; font-weight:700; font-display:swap; src:url("/static/fonts/space-grotesk-700.woff2") format("woff2"); }

/* === reset & base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text: #0e1726;
  --text-muted: #5b6675;
  /* Instrument palette: radar-teal signal accent + amber 'attention'.
     primary is dark enough that white text on it clears WCAG AA (~4.8:1). */
  --primary: #0f766e;
  --primary-hover: #115e59;
  --on-primary: #ffffff;     /* text/icon color on a primary-filled surface */
  --primary-tint: rgba(15, 118, 110, 0.10);
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --amber: #c77d11;
  --success-tint: rgba(22, 163, 74, 0.13);
  --amber-tint: rgba(199, 125, 17, 0.13);
  --danger-tint: rgba(220, 38, 38, 0.11);
  --display: "Space Grotesk", "Inter", system-ui, sans-serif;
  --shadow-sm: 0 1px 2px rgba(16,24,40,0.06);
  --shadow-md: 0 4px 12px -2px rgba(16,24,40,0.10), 0 2px 6px -3px rgba(16,24,40,0.07);
  --shadow-lg: 0 18px 36px -10px rgba(16,24,40,0.20), 0 6px 14px -6px rgba(16,24,40,0.10);
  --radius: 12px;
  --radius-sm: 8px;
  --mono: ui-monospace, "SF Mono", Menlo, Monaco, Consolas, monospace;
  --fs-xs:.75rem; --fs-sm:.8125rem; --fs-base:.9375rem; --fs-md:1rem;
  --fs-lg:1.125rem; --fs-xl:1.25rem; --fs-2xl:1.5rem; --fs-3xl:1.875rem;
  --s-1:.25rem; --s-2:.5rem; --s-3:.75rem; --s-4:1rem; --s-5:1.5rem; --s-6:2rem; --s-8:3rem;
  --elev-1: var(--shadow-sm); --elev-2: var(--shadow-md); --elev-3: var(--shadow-lg);
  --sidebar-w: 252px;
  --sidebar-bg: #fbfcfe;
  --primary-strong: rgba(15, 118, 110, 0.18);
  --backdrop: rgba(0, 0, 0, 0.5);
}

:root[data-theme="dark"] {
  /* Cockpit-at-night: deep navy structure, brighter radar-teal signal. */
  --bg: #0b1220;
  --surface: #131d2e;
  --border: #273449;
  --border-strong: #3a4a63;
  --text: #eef2f7;
  --text-muted: #93a1b5;
  --primary: #2dd4bf;
  --primary-hover: #5eead4;
  --on-primary: #06302b;     /* dark ink: readable on the bright dark-mode teal */
  --primary-tint: rgba(45, 212, 191, 0.14);
  --success: #4ade80;
  --danger: #f87171;
  --warning: #f2b45a;
  --amber: #f2b45a;
  --success-tint: rgba(74, 222, 128, 0.15);
  --amber-tint: rgba(242, 180, 90, 0.15);
  --danger-tint: rgba(248, 113, 113, 0.13);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.35);
  --shadow-md: 0 6px 16px -4px rgba(0,0,0,0.5), 0 2px 6px -3px rgba(0,0,0,0.4);
  --shadow-lg: 0 20px 40px -12px rgba(0,0,0,0.6), 0 6px 14px -6px rgba(0,0,0,0.45);
  --sidebar-bg: #0a1019;
  --primary-strong: rgba(45, 212, 191, 0.28);
  --backdrop: rgba(0, 0, 0, 0.6);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1220;
    --surface: #131d2e;
    --border: #273449;
    --border-strong: #3a4a63;
    --text: #eef2f7;
    --text-muted: #93a1b5;
    --primary: #2dd4bf;
    --primary-hover: #5eead4;
    --on-primary: #06302b;
    --primary-tint: rgba(45, 212, 191, 0.14);
    --success: #4ade80;
    --danger: #f87171;
    --warning: #f2b45a;
    --amber: #f2b45a;
    --success-tint: rgba(74, 222, 128, 0.15);
    --amber-tint: rgba(242, 180, 90, 0.15);
    --danger-tint: rgba(248, 113, 113, 0.13);
    --primary-strong: rgba(45, 212, 191, 0.28);
    --backdrop: rgba(0, 0, 0, 0.6);
    --sidebar-bg: #0a1019;
    --shadow-sm: 0 1px 2px 0 rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px -2px rgba(0,0,0,0.4), 0 2px 4px -2px rgba(0,0,0,0.3);
  }
}

html { font-size: 15px; }
body {
  font-family:"Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

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

/* === nav ===
   The app uses the fixed left .sidebar + sticky .topbar (see the
   "sidebar / topbar / drawer" section). The legacy horizontal top-nav rules
   were removed — a bare `nav { display:flex; height:56px }` here forced the
   sidebar's three nav groups into one 56px row, overlapping them. The <nav>
   now flows as a normal block; link styling lives in `.sidebar nav a`. */

/* === layout === */
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

h1 {
  font-family: var(--display);
  font-size: 1.55rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 0.25rem;
  color: var(--text);
}
.page-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
  max-width: 70ch;
}
section ol, section ul { margin: 0.5rem 0 0.5rem 1.5rem; }
section li { margin-bottom: 0.4rem; line-height: 1.55; }
h2 {
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 1.75rem 0 0.75rem;
  color: var(--text);
}
p { margin-bottom: 0.75rem; }

/* === sections / cards === */
section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}
section h2:first-child { margin-top: 0; }

/* === dashboard stats === */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}
.stat .label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.stat .value {
  font-family: var(--display);
  font-size: 1.875rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-top: 0.4rem;
  font-variant-numeric: tabular-nums;
}
.stat.accent .value { color: var(--primary); }

/* === tables === */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  font-size: 0.875rem;
}
thead { background: var(--bg); }
th {
  text-align: left;
  font-weight: 600;
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.05s ease; }
tbody tr:hover { background: var(--primary-tint); }
td a {
  color: var(--primary);
  overflow-wrap: anywhere;  /* break only when needed — not mid-word like break-all */
}
/* line-clamp helpers for long free-text cells (program titles, snippets) so rows
   stay compact instead of ballooning to 10+ lines. */
.clamp-1, .clamp-2, .clamp-3 { display:-webkit-box; -webkit-box-orient:vertical; overflow:hidden; }
.clamp-1 { -webkit-line-clamp:1; }
.clamp-2 { -webkit-line-clamp:2; }
.clamp-3 { -webkit-line-clamp:3; }
td .clamp-1, td .clamp-2, td .clamp-3 { max-width:42ch; }
.nowrap { white-space:nowrap; }

/* Secondary record-navigation links shown beneath a primary cell value. */
.row-links { display:flex; flex-wrap:wrap; gap:var(--s-2); margin-top:var(--s-1); font-size:0.8rem; }
.row-links a { display:inline-flex; align-items:center; gap:4px; }
.row-links .icon { width:14px; height:14px; }

/* Bundled recruitments shown in one draft row. */
.bundle-list { margin:var(--s-1) 0 0; padding-left:var(--s-3); font-size:0.85rem; }
.bundle-list li { margin-bottom:2px; }

/* CoVe per-claim verification list on a draft row. */
.draft-verify { margin-top:var(--s-1); font-size:0.8rem; }
.verify-list { margin:var(--s-1) 0 0; padding-left:var(--s-3); list-style:none; }
.verify-list li.ok { color: var(--text-muted); }
.verify-list li.bad { color: var(--warn, #b45309); }

/* Pin the Actions column to the right edge so its buttons stay in view without
   scrolling the table sideways. Body cells are tagged .draft-actions /
   [data-col=actions]; header cells carry .col-actions (or [data-col=actions]). */
.table-scroll th.col-actions,
.table-scroll td.col-actions,
.table-scroll td.draft-actions,
.table-scroll th[data-col="actions"],
.table-scroll td[data-col="actions"] {
  position: sticky;
  right: 0;
  border-left: 1px solid var(--border);
}
.table-scroll thead th.col-actions,
.table-scroll thead th[data-col="actions"] { background: var(--bg); z-index: 6; }
.table-scroll tbody td.col-actions,
.table-scroll tbody td.draft-actions,
.table-scroll tbody td[data-col="actions"] { background: var(--surface); z-index: 2; }

/* === form controls (one cohesive rule for every text-like control) === */
input[type="text"], input[type="password"], input[type="search"], input[type="email"],
input[type="url"], input[type="number"], input[type="tel"], input[type="date"],
input[type="file"], input:not([type]), textarea, select {
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  font-family: inherit;
  line-height: 1.5;
  background: var(--surface);
  color: var(--text);
  width: 100%;
  min-height: 2.25rem;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-tint);
}
input::placeholder, textarea::placeholder { color: var(--text-muted); opacity: 1; }
textarea {
  resize: vertical;          /* no sideways drag; grow downward only */
  min-height: 6rem;
  display: block;
}
select { cursor: pointer; }
label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text);
  margin-bottom: var(--s-3);
}
form.add {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
form.add input, form.add select { width: auto; flex: 1; min-width: 160px; }

/* === buttons === */
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  padding: 0.5rem 1rem;
  min-height: 2.25rem;          /* same height as form controls */
  font-size: var(--fs-sm);
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
  background: var(--primary);
  color: white;
  transition: background 0.12s ease, transform 0.05s ease, box-shadow 0.12s ease;
  white-space: nowrap;
}
button:hover { background: var(--primary-hover); }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
input:disabled, textarea:disabled, select:disabled {
  opacity: 0.6; cursor: not-allowed; background: var(--bg);
}

/* Legacy fallback for bare (unclassed) table buttons only — buttons that carry
   an explicit .btn/.btn-ghost/.btn-danger class must obey that class, not this. */
td form button:not([class]) {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 0.3rem 0.7rem;
  min-height: 0;               /* compact in tables */
  font-size: 0.8rem;
}
td form button:not([class]):hover { background: var(--bg); border-color: var(--text-muted); }
td form[action*="approve"] button:not([class]) { color: var(--success); border-color: rgba(22, 163, 74, 0.3); }
td form[action*="approve"] button:not([class]):hover { background: rgba(22, 163, 74, 0.08); }
td form[action*="reject"] button:not([class]) { color: var(--danger); border-color: rgba(220, 38, 38, 0.3); }
td form[action*="reject"] button:not([class]):hover { background: rgba(220, 38, 38, 0.08); }

form.run-now { margin-bottom: 1.5rem; }

/* === error / messages === */
.error {
  color: var(--danger);
  background: rgba(220, 38, 38, 0.08);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  margin-top: 1rem;
  border: 1px solid rgba(220, 38, 38, 0.2);
}

/* === login === */
.login-container {
  max-width: 380px;
  margin: 5rem auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 2rem 2.25rem;
  box-shadow: var(--shadow-md);
}
.login-container h1 {
  font-size: 1.25rem;
  margin-bottom: 0.25rem;
}
.login-container .subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}
.login-container button { width: 100%; padding: 0.6rem 1rem; }

/* === empty state === */
.empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}

/* === code / cron === */
code {
  font-family: var(--mono);
  background: var(--bg);
  color: var(--text);
  padding: 0.125rem 0.4rem;
  border-radius: 4px;
  font-size: 0.85em;
  border: 1px solid var(--border);
}
pre {
  font-family: var(--mono);
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.75rem;
  overflow-x: auto;
  font-size: 0.85rem;
  white-space: pre-wrap;
}
.draft-view summary { cursor: pointer; }
.draft-body { white-space: pre-wrap; max-width: 48rem; margin-top: 0.4rem; }
pre code {
  background: transparent;
  border: 0;
  padding: 0;
  font-size: inherit;
}

/* === notification row states === */
tr.unread { background: var(--primary-tint); }
tr.unread:hover { background: rgba(37, 99, 235, 0.12); }
tr.read { opacity: 0.65; }

/* === status badges === */
.badge-success { background: rgba(22,163,74,0.15); color: var(--success); border-radius: 999px; padding: 0.15rem 0.6rem; font-size: 0.72rem; font-weight: 600; }
.badge-info { background: rgba(37,99,235,0.15); color: var(--primary); border-radius: 999px; padding: 0.15rem 0.6rem; font-size: 0.72rem; font-weight: 600; }
.badge-warn { background: rgba(217,119,6,0.15); color: var(--warning); border-radius: 999px; padding: 0.15rem 0.6rem; font-size: 0.72rem; font-weight: 600; }
.badge-muted { background: var(--bg); color: var(--text-muted); border-radius: 999px; padding: 0.15rem 0.6rem; font-size: 0.72rem; font-weight: 600; }
td.flags { color: var(--warning); font-size: 0.8rem; font-style: italic; }

/* === typed recruitment periods (structured date_range) === */
.period-list { display: flex; flex-direction: column; gap: var(--s-1); }
.period-row { display: flex; align-items: center; gap: var(--s-2); font-size: var(--fs-sm); }
.period-label { color: var(--text-muted); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.02em; }

/* "Why" column: one chip per matching rule (pass/fail/unknown), note in tooltip. */
.reason-chips { display:flex; flex-wrap:wrap; gap:4px; max-width:22rem; }
.reason-chip {
  display:inline-flex; align-items:center; gap:4px;
  padding:.1rem .5rem .1rem .35rem; border-radius:999px;
  font-size:.72rem; font-weight:600; white-space:nowrap;
  border:1px solid transparent; cursor:default;
}
.reason-chip .reason-mark {
  display:inline-flex; align-items:center; justify-content:center;
  width:.95rem; height:.95rem; border-radius:50%; font-size:.66rem; line-height:1;
}
.reason-pass    { background:rgba(22,163,74,.12);  color:var(--success); border-color:rgba(22,163,74,.30); }
.reason-pass .reason-mark    { background:var(--success); color:#fff; }
.reason-fail    { background:rgba(220,38,38,.12);  color:var(--danger);  border-color:rgba(220,38,38,.30); }
.reason-fail .reason-mark    { background:var(--danger); color:#fff; }
.reason-unknown { background:rgba(217,119,6,.12);  color:var(--warning); border-color:rgba(217,119,6,.30); }
.reason-unknown .reason-mark { background:var(--warning); color:#fff; }

/* Source tags: removable chips + inline add input. */
.tag-cell { min-width:11rem; }
.tag-cell .inline-form { display:inline-flex; margin:0; }
.tag-chip {
  display:inline-flex; align-items:center; gap:2px; margin:0 4px 4px 0;
  padding:.1rem .2rem .1rem .5rem; border-radius:999px;
  font-size:.74rem; font-weight:600; white-space:nowrap;
  background:var(--primary-tint); color:var(--primary); border:1px solid var(--primary-strong);
}
.tag-chip .tag-x {
  all:unset; cursor:pointer; line-height:1; font-size:.95rem; padding:0 .25rem;
  color:var(--primary); opacity:.7; border-radius:50%;
}
.tag-chip .tag-x:hover { opacity:1; background:var(--danger); color:#fff; }
.tag-add input {
  width:5.5rem; padding:.15rem .45rem; font-size:.74rem; min-height:0;
  border:1px dashed var(--border-strong); border-radius:999px; background:transparent;
}
.tag-add input:focus { width:9rem; border-style:solid; }
.manage-tags summary { cursor:pointer; font-weight:600; }
.manage-tags .stack { gap:var(--s-2); margin-top:var(--s-2); }
.manage-tags .row.tight { align-items:center; gap:var(--s-2); }
.manage-tags input { min-height:0; padding:.2rem .5rem; }
.pager { display: flex; align-items: center; gap: 0.6rem; margin: 1rem 0; flex-wrap: wrap; }
.pager-info { color: var(--text-muted); font-size: 0.82rem; }
.pager-page { font-size: 0.82rem; font-weight: 600; }
.pager .disabled { opacity: 0.4; pointer-events: none; }
.triage-prompt-editor { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 0.75rem 1rem; margin: 0.5rem 0 1rem; }
.triage-prompt-editor summary { cursor: pointer; font-weight: 600; }
.triage-result { margin-top: 0.35rem; font-size: 0.82rem; line-height: 1.35; max-width: 38rem; }
.triage-result:empty { display: none; }
.rule-chip { display: inline-block; font-size: 0.72rem; border-radius: 999px; padding: 0.1rem 0.5rem; margin: 0.1rem; }
.rule-pass { background: rgba(22,163,74,0.15); color: var(--success); }
.rule-fail { background: rgba(220,38,38,0.15); color: var(--danger, #dc2626); }
.rule-unknown { background: var(--bg); color: var(--text-muted); }

/* Relevance ranking tags (FR-22) — presentation only, never an eligibility signal. */
.relevance-tag { border-radius: 999px; padding: 0.1rem 0.5rem; font-size: 0.7rem; font-weight: 600; white-space: nowrap; }
.relevance-high { background: rgba(22,163,74,0.15); color: var(--success); }
.relevance-medium { background: rgba(37,99,235,0.15); color: var(--primary); }
.relevance-low { background: var(--bg); color: var(--text-muted); }
.relevance-none { background: var(--bg); color: var(--text-muted); }
.relevance-help, .relevance-context { color: var(--text-muted); font-size: 0.75rem; font-weight: 400; }

/* === table scroll wrapper === */
/* Data tables scroll within a capped viewport so the column headers can stick
   to the top while you scroll the rows. The wrapper owns the frame + the scroll
   context; the inner table's own overflow/border are neutralised so the sticky
   headers attach to THIS element (an inner overflow:hidden would trap them). */
.table-scroll {
  overflow: auto;
  max-height: calc(100vh - 10rem);
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.table-scroll > table { overflow: visible; border: none; border-radius: 0; box-shadow: none; }
.table-scroll thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--bg);
  /* border-collapse drops a sticky cell's own border; repaint it as an inset. */
  box-shadow: inset 0 -1px 0 var(--border);
}
.col-nowrap { white-space: nowrap; }
.col-amount { text-align: right; }
.col-num { font-variant-numeric: tabular-nums; }
.proj-link { font-size: 0.8rem; white-space: nowrap; }

/* === theme toggle === */
.theme-toggle {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  border-radius: 999px;
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.theme-toggle:hover { background: var(--bg); color: var(--text); }
.theme-toggle .theme-icon-light { display: inline; }
.theme-toggle .theme-icon-dark { display: none; }
:root[data-theme="dark"] .theme-toggle .theme-icon-light { display: none; }
:root[data-theme="dark"] .theme-toggle .theme-icon-dark { display: inline; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .theme-icon-light { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .theme-icon-dark { display: inline; }
}

/* === utility === */
.muted { color: var(--text-muted); }

/* === scan progress === */
.table tr.row-running, table tr.row-running { background: rgba(37, 99, 235, 0.04); }
:root[data-theme="dark"] .table tr.row-running,
:root[data-theme="dark"] table tr.row-running { background: rgba(96, 165, 250, 0.06); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .table tr.row-running,
  :root:not([data-theme="light"]) table tr.row-running { background: rgba(96, 165, 250, 0.06); }
}
.spinner {
  display: inline-block;
  font-weight: 600;
  color: var(--primary);
  animation: dotPulse 1s ease-in-out infinite;
}
@keyframes dotPulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

/* === background-job panel (scrapers) === */
.job-panel { margin: 1rem 0; padding: 0.75rem 1rem; border: 1px solid var(--border); border-radius: var(--radius, 8px); background: var(--primary-tint); }
.job-panel-title { margin: 0 0 0.5rem; font-size: 0.95rem; display: flex; align-items: center; gap: 0.4rem; }
.job-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.job-item { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.job-label { font-weight: 600; }
.job-chip { display: inline-flex; align-items: center; gap: 0.4rem; border-radius: 999px; padding: 0.15rem 0.7rem; font-size: 0.74rem; font-weight: 600; }
.job-chip-running { background: rgba(37,99,235,0.15); color: var(--primary); }
.job-chip-done { background: rgba(22,163,74,0.15); color: var(--success); text-decoration: none; }
.job-chip-failed { background: rgba(217,119,6,0.15); color: var(--warning); }
.job-chip-running .spinner { width: 0.8rem; height: 0.8rem; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: jobSpin 0.7s linear infinite; }
@keyframes jobSpin { to { transform: rotate(360deg); } }
.task-progress { display: inline-flex; align-items: center; gap: 0.5rem; font-size: 0.78rem; color: var(--text-muted); }
.task-progress progress { width: 160px; height: 0.7rem; }
.info-tip { cursor: help; color: var(--text-muted); font-size: 0.85em; margin-left: 0.25rem; }
.info-tip:hover, .info-tip:focus { color: var(--primary); }

/* === dashboard workflow diagram === */
.workflow { display: flex; flex-direction: column; gap: 0.4rem; margin-top: 1rem; }
.wf-lane { display: flex; align-items: stretch; gap: 0.4rem; flex-wrap: wrap; }
.wf-lane-center { justify-content: center; }
.wf-lane-label { width: 100%; font-size: 0.74rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; margin-top: 0.5rem; }
.wf-block { display: flex; flex-direction: column; align-items: center; gap: 0.3rem; min-width: 132px; padding: 0.7rem 0.8rem; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); color: var(--text); text-align: center; }
.wf-head { display: flex; flex-direction: column; align-items: center; gap: 0.25rem; text-decoration: none; color: var(--text); }
.wf-ico { color: var(--primary); }
.wf-title { font-weight: 600; font-size: 0.9rem; }
.wf-count { font-size: 1.5rem; font-weight: 700; line-height: 1; color: var(--text); }
.wf-run { font-size: 0.72rem; margin-top: 0.2rem; }
.wf-arrow { align-self: center; color: var(--primary); font-size: 1.4rem; font-weight: 700; }
/* Convergence: both lanes drop into matching. */
.wf-converge { text-align: center; color: var(--text-muted); font-size: 0.85rem; font-weight: 600; padding: 0.2rem 0; }
.wf-converge::before { content: "↓"; display: block; color: var(--primary); font-size: 1.4rem; }
@media (max-width: 760px) { .wf-arrow { transform: rotate(90deg); align-self: flex-start; margin-left: 1rem; } .wf-lane { flex-direction: column; align-items: stretch; } }

/* === recruitments table === */
.table-recruitments { min-width: 1800px; }
.table-recruitments th, .table-recruitments td { white-space: nowrap; }

/* 1 Title */
.table-recruitments td:nth-child(1) { min-width: 320px; max-width: 360px; white-space: normal; font-weight: 500; }
/* 2 Operator */
.table-recruitments td:nth-child(2) { min-width: 200px; max-width: 240px; white-space: normal; color: var(--text-muted); }
/* 3 Region */
.table-recruitments td:nth-child(3) { min-width: 120px; }
/* 4 Date range */
.table-recruitments td:nth-child(4) { min-width: 160px; color: var(--text-muted); font-size: 0.82rem; }
/* 5 Max amount */
.table-recruitments td:nth-child(5) { text-align: right; font-variant-numeric: tabular-nums; min-width: 100px; }
/* 6 Purpose, 7 Target group, 13 Status notes */
.table-recruitments td:nth-child(6),
.table-recruitments td:nth-child(7),
.table-recruitments td:nth-child(13) {
  min-width: 220px;
  max-width: 320px;
  color: var(--text-muted);
  font-size: 0.82rem;
  vertical-align: top;
}
.table-recruitments td:nth-child(6) .cell-clamp,
.table-recruitments td:nth-child(7) .cell-clamp,
.table-recruitments td:nth-child(13) .cell-clamp {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  line-height: 1.4;
  word-break: break-word;
}
/* 8 Project link */
.table-recruitments td:nth-child(8) { min-width: 80px; font-size: 0.8rem; }
/* 9 State */
.table-recruitments td:nth-child(9) { min-width: 100px; }
/* 10 Next open, 11 Next close, 14 Last checked, 15 Last changed */
.table-recruitments td:nth-child(10),
.table-recruitments td:nth-child(11),
.table-recruitments td:nth-child(14),
.table-recruitments td:nth-child(15) {
  min-width: 130px; color: var(--text-muted); font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}
/* 12 Flags */
.table-recruitments td:nth-child(12) { min-width: 140px; font-size: 0.8rem; color: var(--warning); font-style: italic; }
/* 16 Archived */
.table-recruitments td:nth-child(16) { min-width: 90px; text-align: center; }

/* === enrichment workflow === */
.enrich-bar {
  background: var(--primary-tint);
  border: 1px solid var(--border);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.9rem;
  flex-wrap: wrap;
}

.enriched-marker {
  color: var(--primary);
  margin-left: 0.25rem;
  font-size: 0.85em;
  cursor: help;
  opacity: 0.75;
}

.prompt-modal {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 1.5rem;
  background: var(--surface);
  color: var(--text);
  max-width: 700px;
  width: 90vw;
}
.prompt-modal h2 { margin: 0 0 0.75rem; font-size: 1rem; }
.prompt-modal pre {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 0.85rem;
  white-space: pre-wrap;
  max-height: 400px;
  overflow-y: auto;
  margin: 1rem 0;
}
.prompt-modal::backdrop { background: rgba(0, 0, 0, 0.45); }
.preview-modal {
  width: min(820px, 92vw);
  max-width: 92vw;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0;
  background: var(--bg);
  color: var(--text);
}
.preview-modal::backdrop { background: rgba(0, 0, 0, 0.5); }
/* === shared centered modal component ===
   margin:auto re-enables the UA's fixed centering (reset by star-rule margin:0). */
@keyframes modal-in {
  from { opacity: 0; transform: scale(0.97) translateY(-6px); }
  to   { opacity: 1; transform: none; }
}
dialog.modal {
  margin: auto;
  width: min(var(--modal-w, 640px), 92vw);
  max-height: 82vh;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 0;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--elev-2);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: modal-in 0.18s ease;
}
dialog.modal:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
dialog.modal::backdrop { background: var(--backdrop); }
.modal-sm { --modal-w: 420px; }
.modal-md { --modal-w: 640px; }
.modal-lg { --modal-w: 820px; }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface);
}
.modal-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 1rem;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.modal-body {
  padding: 0.5rem 1.25rem 1.25rem;
  overflow-y: auto;
  flex: 1;
}
@media (prefers-reduced-motion: reduce) {
  dialog.modal { animation: none; }
}
/* CoVe verification chip + dialog log */
.cove-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  border: 0;
  cursor: default;
  line-height: 1.5;
  font-family: var(--display);
  letter-spacing: 0.01em;
}
button.cove-chip {
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.12s;
}
button.cove-chip:hover { opacity: 0.8; }
.cove-chip-verified { background: var(--success-tint); color: var(--success); }
.cove-chip-revised { background: var(--amber-tint); color: var(--amber); }
.cove-chip-error { background: var(--danger-tint); color: var(--danger); }
.cove-chip-none {
  background: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.cove-log-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
}
.cove-log-count { font-size: 0.82rem; }
.cove-log {
  list-style: none;
  margin: 0;
  padding: 0;
}
.cove-log-row {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
  line-height: 1.55;
  flex-wrap: wrap;
}
.cove-log-row:last-child { border-bottom: 0; }
.cove-log-label { flex: 1; min-width: 0; }
.cove-log-note { font-size: 0.8rem; white-space: nowrap; }
.verdict-supported {
  display: inline-block;
  min-width: 1.3rem;
  text-align: center;
  font-weight: 700;
  color: var(--success);
}
.verdict-unsupported {
  display: inline-block;
  min-width: 1.3rem;
  text-align: center;
  font-weight: 700;
  color: var(--danger);
}
.verdict-unknown {
  display: inline-block;
  min-width: 1.3rem;
  text-align: center;
  font-weight: 700;
  color: var(--text-muted);
}
.release-entry { padding-block: 0.75rem; border-bottom: 1px solid var(--border); }
.release-entry:last-child { border-bottom: 0; }
.release-entry h3.release-ver { margin: 0.25rem 0 0.5rem; font-size: 1.05rem; color: var(--accent, var(--text)); }
.release-entry h4 { margin: 0.9rem 0 0.35rem; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted, var(--text)); }
.release-entry ul { margin: 0.25rem 0 0.5rem; padding-left: 1.1rem; }
.release-entry li { margin: 0.2rem 0; }
.release-entry p { margin: 0.4rem 0; }
.preview-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--border);
}
.preview-modal iframe {
  display: block;
  width: 100%;
  height: min(70vh, 640px);
  border: 0;
  background: #fff;
}
.lang-toggle { margin: 0; margin-left: auto; }
.lang-toggle button {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  border-radius: 999px;
  width: 38px;
  height: 32px;
  padding: 0;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
}
.lang-toggle button:hover {
  background: var(--bg);
  color: var(--text);
}

/* HubSpot client-matching */
.sparkle {
  color: var(--warning, #c97a00);
  margin-right: 0.3rem;
}
tr.needs-review {
  background: rgba(201, 122, 0, 0.07);
}
.chip {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.85rem;
  text-decoration: none;
  color: var(--text);
}
.chip.active {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}
.kv {
  display: grid;
  grid-template-columns: max-content 1fr;
  column-gap: 1rem;
  row-gap: 0.3rem;
}
.kv dt { font-weight: 600; color: var(--text-muted); }
.matching-clients {
  margin-top: 0.5rem;
  padding-left: 0.6rem;
  border-left: 3px solid var(--warning, #c97a00);
}
.matching-clients ul {
  margin: 0.3rem 0 0 1rem;
}

/* === banner family === */
.banner { display:flex; gap:var(--s-2); align-items:flex-start; padding:var(--s-3) var(--s-4); border-radius:var(--radius-sm); border:1px solid var(--border); margin-bottom:var(--s-4); font-size:var(--fs-sm); }
.banner-success { background:rgba(22,163,74,.10); border-color:rgba(22,163,74,.30); color:var(--success); }
.banner-info    { background:var(--primary-tint); border-color:rgba(37,99,235,.30); color:var(--primary); }
.banner-warn    { background:rgba(217,119,6,.10);  border-color:rgba(217,119,6,.30);  color:var(--warning); }
.banner-error   { background:rgba(220,38,38,.10);  border-color:rgba(220,38,38,.25);  color:var(--danger); }

/* === btn family, skeleton, empty-icon, reduced-motion === */
/* One box-model for the whole family so an <a> and a <button> are the same size
   (anchors don't match the base `button` rule, which is why sizes drifted). */
.btn, .btn-ghost, .btn-danger {
  display:inline-flex; align-items:center; justify-content:center; gap:var(--s-2);
  min-height:2.25rem; padding:var(--s-2) var(--s-4); box-sizing:border-box;
  font-family:inherit; font-size:var(--fs-sm); font-weight:500; line-height:1.1;
  border-radius:var(--radius-sm); border:1px solid transparent; cursor:pointer;
  white-space:nowrap; text-decoration:none;
}
.btn { background:var(--primary); color:var(--on-primary); }
.btn-ghost { background:transparent; border-color:var(--border-strong); color:var(--text); }
.btn-ghost:hover { background:var(--bg); text-decoration:none; }
.btn-danger { background:var(--danger); color:#fff; }
/* ghost + danger = a SUBTLE row-level destructive action (outlined danger text),
   so a per-row "Delete" doesn't read as loud as a solid primary next to it. */
.btn-ghost.btn-danger { background:transparent; color:var(--danger); border-color:var(--border-strong); }
.btn-ghost.btn-danger:hover { background:rgba(220,38,38,.08); border-color:var(--danger); }
.card { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); padding:var(--s-4) var(--s-5); margin-bottom:var(--s-4); box-shadow:var(--elev-1); }
.card h2:first-child, .card h3:first-child { margin-top:0; }
.skeleton { background:linear-gradient(90deg,var(--border) 25%,var(--bg) 37%,var(--border) 63%); background-size:400% 100%; animation:shimmer 1.4s ease infinite; border-radius:var(--radius-sm); }
@keyframes shimmer { 0%{background-position:100% 0} 100%{background-position:-100% 0} }
.empty .empty-icon { width:2rem; height:2rem; opacity:.5; margin:0 auto var(--s-3); display:block; }
@media (prefers-reduced-motion: reduce){ .skeleton{ animation:none } * { transition:none !important } }

/* === focus-visible + skip-link === */
:focus-visible { outline:2px solid var(--primary); outline-offset:2px; border-radius:2px; }
.skip-link { position:absolute; left:-999px; }
.skip-link:focus { left:var(--s-3); top:var(--s-3); z-index:50; background:var(--surface); padding:var(--s-2) var(--s-3); border:1px solid var(--border); border-radius:var(--radius-sm); }

.icon{ width:18px;height:18px;vertical-align:-3px;flex:0 0 auto } svg.icon use{ pointer-events:none }

/* === sidebar / topbar / drawer === */
.sidebar { display:flex; flex-direction:column; position:fixed; top:0; left:0; width:var(--sidebar-w); height:100vh; overflow-y:auto; background:var(--sidebar-bg); border-right:1px solid var(--border); padding:var(--s-4) var(--s-3); z-index:20; }
.sidebar .brand { display:flex; gap:var(--s-2); align-items:center; font-family:var(--display); font-weight:700; font-size:1.05rem; letter-spacing:-.02em; padding:var(--s-2) var(--s-2); margin-bottom:var(--s-4); color:var(--text); }
.sidebar .brand svg { color:var(--primary); }
.sidebar nav { display:flex; flex-direction:column; }
.nav-group { margin-bottom:var(--s-5); }
.nav-group:last-child { margin-bottom:0; }
.nav-head { display:block; font-size:var(--fs-xs); font-weight:600; text-transform:uppercase; letter-spacing:.07em; color:var(--text-muted); padding:0 var(--s-3); margin-bottom:var(--s-2); }
.sidebar nav a { display:flex; gap:var(--s-3); align-items:center; padding:var(--s-2) var(--s-3); border-radius:var(--radius-sm); color:var(--text-muted); font-weight:500; font-size:var(--fs-sm); margin-top:2px; transition:background .12s ease, color .12s ease; }
.sidebar nav a:hover { background:var(--bg); color:var(--text); text-decoration:none; }
.sidebar nav a.active { background:var(--primary-tint); color:var(--primary); font-weight:600; box-shadow:inset 0 0 0 1px var(--primary-strong); }
.sidebar nav a .icon { opacity:.85; }
.sidebar nav a.active .icon { opacity:1; }
.sidebar .badge { margin-left:auto; background:var(--primary); color:var(--on-primary); border-radius:999px; padding:.05rem .42rem; font-size:.68rem; font-weight:600; min-width:1.2rem; text-align:center; line-height:1.35; }
.app-shell { margin-left:var(--sidebar-w); }
.topbar { position:sticky; top:0; height:56px; display:flex; align-items:center; gap:var(--s-2); padding:0 var(--s-5); background:var(--surface); border-bottom:1px solid var(--border); box-shadow:var(--shadow-sm); z-index:10; }
.topbar .spacer { flex:1; }
.drawer-toggle { display:none; }
@media (max-width:900px){
  .sidebar { transform:translateX(-100%); transition:transform .2s ease; }
  body.drawer-open .sidebar { transform:none; }
  .app-shell { margin-left:0; }
  .drawer-toggle { display:inline-flex; }
}
.island-toolbar { display:flex; gap:var(--s-2); align-items:center; margin-bottom:var(--s-3); flex-wrap:wrap; }
.island-toolbar input { width:auto; flex:1; min-width:200px; }
.agent-console textarea { width:100%; }
.agent-console .card { margin-bottom:var(--s-4); }
.col-menu { position:relative; }
.col-menu-panel { position:absolute; z-index:30; top:100%; right:0; background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-sm); box-shadow:var(--elev-2); padding:var(--s-2); max-height:300px; overflow:auto; }
.col-menu-panel label { display:flex; gap:var(--s-2); align-items:center; font-weight:400; white-space:nowrap; margin-bottom:var(--s-1); }

/* === recruitments sticky header & column === */
.table-recruitments thead th { position:sticky; top:56px; z-index:5; background:var(--bg); }
.table-recruitments td:first-child, .table-recruitments th:first-child {
  position:sticky; left:0; z-index:4; background:var(--surface);
}
.table-recruitments thead th:first-child { z-index:6; background:var(--bg); }

/* === page header === */
.page-head { display:flex; align-items:center; justify-content:space-between; gap:var(--s-3); margin-bottom:var(--s-5); flex-wrap:wrap; }
.page-head h1 { display:flex; align-items:center; gap:var(--s-2); margin-bottom:0; }

/* === button polish === */
.btn { display:inline-flex; align-items:center; gap:var(--s-2); text-decoration:none; box-shadow:var(--shadow-sm); transition:background .12s ease, box-shadow .12s ease, transform .04s ease; }
.btn:hover { background:var(--primary-hover); text-decoration:none; }
.btn:active { transform:translateY(1px); }
.btn-ghost { box-shadow:none; }
.btn-ghost:hover { background:var(--bg); }
.btn-danger:hover { background:#b91c1c; }

/* === filter / inline forms === */
.filter-bar form { display:flex; gap:var(--s-3); align-items:flex-end; flex-wrap:wrap; }
.filter-bar label, .inline-form label { margin-bottom:0; }
.filter-bar input, .filter-bar select, .inline-form select { width:auto; min-width:160px; }
.inline-form { display:flex; gap:var(--s-3); align-items:flex-end; flex-wrap:wrap; }

/* === stacked forms === */
.form-stack { display:flex; flex-direction:column; }
.form-actions { display:flex; gap:var(--s-2); align-items:center; margin-top:var(--s-2); }
.ref-fields { border:1px solid var(--border); border-radius:var(--radius-sm); padding:var(--s-3) var(--s-4); margin-bottom:var(--s-4); }
.ref-fields legend { font-size:var(--fs-xs); font-weight:600; text-transform:uppercase; letter-spacing:.06em; color:var(--text-muted); padding:0 var(--s-2); }

/* === ticket detail === */
.ticket-meta { display:flex; gap:var(--s-3); align-items:center; flex-wrap:wrap; margin-bottom:var(--s-3); }
.ticket-body { font-family:inherit; white-space:pre-wrap; word-break:break-word; background:var(--bg); border:1px solid var(--border); border-radius:var(--radius-sm); padding:var(--s-3) var(--s-4); margin:var(--s-2) 0; font-size:var(--fs-sm); line-height:1.6; }
.comment { border-top:1px solid var(--border); padding-top:var(--s-3); margin-top:var(--s-3); }
.comment:first-of-type { border-top:none; padding-top:0; margin-top:var(--s-2); }
details.card summary { cursor:pointer; font-weight:600; }

/* === island inline status select === */
.status-select { display:inline-flex; align-items:center; gap:var(--s-2); }
.status-select select { width:auto; min-width:140px; min-height:0; padding:.2rem var(--s-2); font-size:var(--fs-sm); }

/* === misc === */
.table-scroll { overflow-x:auto; }

/* === toasts === */
.toaster { position: fixed; bottom: var(--s-4); right: var(--s-4); z-index: 60; display: flex; flex-direction: column; gap: var(--s-2); max-width: min(92vw, 360px); }
.toast { display: flex; align-items: flex-start; gap: var(--s-2); padding: var(--s-3); background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--border-strong); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); font-size: var(--fs-sm); }
.toast--success { border-left-color: var(--success); }
.toast--error { border-left-color: var(--danger); }
.toast--info { border-left-color: var(--primary); }
.toast__msg { flex: 1; color: var(--text); line-height: 1.4; }
.toast__dismiss { background: transparent; border: none; color: var(--text-muted); font-size: 1.1rem; line-height: 1; padding: 0 var(--s-1); min-height: 0; cursor: pointer; }
.toast__dismiss:hover { color: var(--text); }
.is-busy { opacity: 0.6; cursor: progress; }
@media (prefers-reduced-motion: no-preference) {
  .toast { animation: toast-in 0.15s ease; }
  @keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
}

/* LLM provider switcher (Settings). Compact table; the inline edit/add forms
   live inside <details> so the panel stays tidy until expanded. */
.provider-table { width: 100%; }
.provider-table td, .provider-table th { vertical-align: middle; }
.provider-table summary { display: inline-flex; cursor: pointer; list-style: none; }
.provider-table summary::-webkit-details-marker { display: none; }

/* Agent chat */
.chat-head { display:flex; align-items:center; justify-content:space-between; gap:var(--s-4); margin-bottom:var(--s-4); }
.chat-head h1 { margin:0; }

.chat-panel {
  display:flex; flex-direction:column;
  background:var(--surface); border:1px solid var(--border);
  border-radius:var(--radius); box-shadow:var(--elev-1); overflow:hidden;
  height:min(72vh, 780px);
}
.chat-transcript {
  flex:1; overflow-y:auto; padding:var(--s-5);
  display:flex; flex-direction:column; gap:var(--s-3); scroll-behavior:smooth;
}
.chat-empty { margin:auto; color:var(--text-muted); font-size:var(--fs-sm); text-align:center; }

.chat-row { display:flex; gap:var(--s-2); align-items:flex-end; max-width:82%; }
.chat-row.user { align-self:flex-end; }
.chat-row.assistant { align-self:flex-start; }
.chat-avatar {
  flex:0 0 auto; width:28px; height:28px; border-radius:50%;
  display:grid; place-items:center; background:var(--primary-tint); color:var(--primary);
}
.chat-avatar svg { width:16px; height:16px; }
.chat-bubble {
  padding:var(--s-2) var(--s-3); border-radius:6px;
  min-width:0; max-width:100%; box-sizing:border-box;
  white-space:pre-wrap; overflow-wrap:anywhere; word-break:break-word;
  line-height:1.5; font-size:var(--fs-base);
}
.chat-row.user .chat-bubble { background:var(--primary); color:var(--on-primary); border-bottom-right-radius:2px; }
.chat-row.assistant .chat-bubble { background:var(--bg); border:1px solid var(--border); border-bottom-left-radius:2px; }

.chat-tool-chip {
  align-self:flex-start; display:inline-flex; align-items:center; gap:var(--s-1);
  font-size:var(--fs-xs); color:var(--text-muted); background:var(--bg);
  border:1px solid var(--border); border-radius:999px; padding:2px var(--s-2);
  font-family:var(--mono); max-width:82%; word-break:break-word;
}
.chat-tool-chip svg { width:13px; height:13px; opacity:.7; flex:0 0 auto; }
/* Tool steps (run_code etc.) collapse by default — only the tool name shows;
   the raw output is behind a disclosure so it never floods the transcript. */
.chat-tool { align-self:flex-start; max-width:82%; min-width:0; }
.chat-tool > summary { cursor:pointer; list-style:none; }
.chat-tool > summary::-webkit-details-marker { display:none; }
/* Collapsed step is strictly ONE line: icon + tool name + short human summary +
   chevron. nowrap + ellipsis on the summary keeps it from spilling to line two. */
.chat-tool > summary.chat-tool-chip { white-space:nowrap; max-width:100%; overflow:hidden; }
.chat-tool-name { font-weight:600; flex:0 0 auto; }
.chat-tool-sum { min-width:0; overflow:hidden; text-overflow:ellipsis; opacity:.85; }
.chat-tool-sum:empty { display:none; }
.chat-tool > summary::after { content:"▸"; margin-left:8px; font-size:10px; opacity:.5; flex:0 0 auto; }
.chat-tool[open] > summary::after { content:"▾"; }
/* Expanded readout — human-readable, not raw JSON. */
.chat-tool-body { margin:6px 0 0; display:flex; flex-direction:column; gap:6px; }
.chat-tool-body:empty { display:none; }
.chat-tool-pre {
  margin:0; padding:var(--s-2) var(--s-3);
  background:var(--bg); border:1px solid var(--border); border-radius:6px;
  font-family:var(--mono); font-size:var(--fs-xs); color:var(--text);
  white-space:pre-wrap; overflow-wrap:anywhere; max-height:260px; overflow:auto;
}
.chat-tool-files { display:flex; flex-wrap:wrap; gap:4px; }
.chat-file-chip {
  font-family:var(--mono); font-size:var(--fs-xs); color:var(--primary);
  background:var(--primary-tint); border-radius:4px; padding:1px 6px;
}
.chat-tool-counts { font-size:var(--fs-sm); font-weight:600; color:var(--text); }
.chat-tool-sample { margin:0; padding-left:16px; display:flex; flex-direction:column; gap:2px;
  font-size:var(--fs-xs); color:var(--text-muted); }
.chat-tool-sample li { overflow-wrap:anywhere; }
.chat-tool--err > summary.chat-tool-chip { color:var(--danger); border-color:var(--danger); }

.chat-pending-card {
  align-self:stretch; border:1px solid var(--border); border-left:3px solid var(--primary);
  border-radius:var(--radius-sm); padding:var(--s-3); background:var(--surface); box-shadow:var(--elev-1);
}
.chat-pending-card.high-risk { border-color:var(--danger); border-left-color:var(--danger); background:rgba(220,38,38,.05); }
.chat-pending-args {
  font-family:var(--mono); font-size:var(--fs-xs); background:var(--bg);
  border:1px solid var(--border); border-radius:var(--radius-sm);
  padding:var(--s-2); margin:var(--s-2) 0 0; overflow-x:auto; white-space:pre-wrap; word-break:break-word;
}
.chat-risk-warn { color:var(--danger); font-size:var(--fs-sm); margin:var(--s-2) 0 0; }
.chat-approve { display:flex; gap:var(--s-2); align-items:center; flex-wrap:wrap; margin-top:var(--s-3); }
.chat-approve input[type=text] { flex:1; min-width:160px; }

.chat-composer {
  display:flex; align-items:flex-end; gap:var(--s-2);
  border-top:1px solid var(--border); padding:var(--s-3); background:var(--surface);
}
.chat-inputwrap {
  position:relative; flex:1; display:flex; align-items:flex-end; gap:var(--s-1);
  border:1px solid var(--border-strong); border-radius:var(--radius);
  padding:var(--s-1) var(--s-2); background:var(--bg);
}
.chat-inputwrap:focus-within { border-color:var(--primary); box-shadow:0 0 0 3px var(--primary-tint); }
.chat-inputwrap textarea {
  flex:1; border:0; background:transparent; resize:none; padding:var(--s-2) 0;
  font:inherit; color:var(--text); min-height:auto; max-height:160px; line-height:1.5;
  outline:none; box-shadow:none; width:auto;
}
.chat-inputwrap textarea:focus { box-shadow:none; }
.chat-attach {
  flex:0 0 auto; display:grid; place-items:center; width:34px; height:34px; margin:0;
  border-radius:var(--radius-sm); cursor:pointer; color:var(--text-muted);
}
.chat-attach:hover { background:var(--primary-tint); color:var(--primary); }
.chat-attach svg { width:18px; height:18px; }
.chat-attach input[type=file] { position:absolute; width:1px; height:1px; opacity:0; overflow:hidden; }
.chat-attach-name {
  align-self:center; font-size:var(--fs-xs); color:var(--text-muted);
  max-width:150px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}

/* Agent chat — typing indicator */
.chat-dots { display:inline-flex; gap:4px; align-items:center; padding:2px 0; }
.chat-dots i { width:6px; height:6px; border-radius:50%; background:var(--text-muted); opacity:.4; animation:chatdot 1.2s infinite ease-in-out; }
.chat-dots i:nth-child(2) { animation-delay:.2s; }
.chat-dots i:nth-child(3) { animation-delay:.4s; }
@keyframes chatdot { 0%,60%,100% { transform:translateY(0); opacity:.4; } 30% { transform:translateY(-3px); opacity:1; } }

/* === layout utilities (retire ad-hoc inline flex) === */
.toolbar { display:flex; gap:var(--s-2); align-items:center; flex-wrap:wrap; margin-bottom:var(--s-4); }
.toolbar .spacer, .row .spacer { margin-left:auto; }
.row { display:flex; gap:var(--s-2); align-items:center; flex-wrap:wrap; }
.row.tight { gap:var(--s-1); }
.inline-form { display:inline; }
.mono-input { font-family:var(--mono) !important; }

/* === pipeline nav = waypoint NODES connected by a flight-path rail ===
   Each pipeline icon becomes a circular node (the svg's own box, padded so the
   18px glyph sits inside a 26px circle). The rail runs behind, centered on the
   node column (padding-left ~11px + 13px node radius ≈ 24px), so the opaque
   nodes sit ON the line like waypoints. The node — not the row — shows active. */
.nav-group.pipeline { position:relative; }
.nav-group.pipeline > a { position:relative; z-index:1; }
.nav-group.pipeline > a > svg.icon {
  width:26px; height:26px; padding:4px; box-sizing:border-box; flex:0 0 auto; opacity:1;
  background:var(--surface); border:1px solid var(--border-strong); border-radius:50%;
  color:var(--text-muted); transition:background .12s ease, border-color .12s ease, color .12s ease;
}
.nav-group.pipeline > a:hover { background:transparent; color:var(--text); }
.nav-group.pipeline > a:hover > svg.icon { border-color:var(--primary); color:var(--primary); }
.nav-group.pipeline > a.active { background:transparent; box-shadow:none; color:var(--primary); }
.nav-group.pipeline > a.active > svg.icon { background:var(--primary); border-color:var(--primary); color:var(--on-primary); }
.nav-group.pipeline::before {
  content:""; position:absolute; left:23px; top:40px; bottom:24px; width:2px; z-index:0;
  background:var(--border-strong); border-radius:2px;
}

/* === dashboard mission panel (live pipeline status — the signature) === */
.mission {
  background:var(--surface); border:1px solid var(--border); border-radius:var(--radius);
  box-shadow:var(--shadow-sm); padding:var(--s-5); margin-bottom:var(--s-5);
}
.mission-head { display:flex; align-items:center; justify-content:space-between; gap:var(--s-3); margin-bottom:var(--s-4); flex-wrap:wrap; }
.mission-title { font-family:var(--display); font-weight:600; letter-spacing:-.01em; font-size:var(--fs-lg); display:flex; align-items:center; gap:var(--s-2); margin:0; }
.mission-title .dot { width:9px; height:9px; border-radius:50%; background:var(--primary); }
@media (prefers-reduced-motion: no-preference) { .mission-title .dot { animation:radar 2.6s infinite; } }
@keyframes radar { 0%{ box-shadow:0 0 0 0 var(--primary-strong);} 70%{ box-shadow:0 0 0 9px transparent;} 100%{ box-shadow:0 0 0 0 transparent;} }
.mission-sub { color:var(--text-muted); font-size:var(--fs-sm); }
.mission-flow { display:flex; align-items:stretch; flex-wrap:wrap; }
.stage { flex:1 1 0; min-width:104px; display:flex; flex-direction:column; gap:3px; padding:var(--s-3); border-radius:var(--radius-sm); transition:background .12s ease; }
a.stage:hover { background:var(--bg); text-decoration:none; }
.stage-label { font-size:var(--fs-xs); text-transform:uppercase; letter-spacing:.06em; color:var(--text-muted); font-weight:600; }
.stage-count { font-family:var(--display); font-size:1.7rem; font-weight:600; color:var(--text); font-variant-numeric:tabular-nums; letter-spacing:-.02em; line-height:1.1; }
.stage-note { font-size:var(--fs-xs); color:var(--text-muted); }
.stage-note.attn { color:var(--amber); font-weight:600; }
.mission-arrow { align-self:center; color:var(--border-strong); flex:0 0 auto; font-size:1.1rem; }
.mission-split { align-self:center; color:var(--text-muted); font-size:var(--fs-xs); flex:0 0 auto; padding:0 var(--s-1); }
@media (max-width:820px){ .mission-arrow{ display:none; } .stage{ flex-basis:30%; } }
.mission-actions { margin-top:var(--s-4); margin-bottom:0; }
label.row { margin-bottom:0; font-weight:500; }
label.row input[type=checkbox] { width:auto; min-height:0; }
.row select, .row input:not([type=checkbox]) { width:auto; flex:0 1 auto; min-width:180px; }

/* === more layout utilities (page-by-page de-inlining) === */
.stack { display:flex; flex-direction:column; gap:var(--s-3); }
.stack.gap-2 { gap:var(--s-2); }
.mt-2 { margin-top:var(--s-2); } .mt-3 { margin-top:var(--s-3); }
.mt-4 { margin-top:var(--s-4); } .mt-5 { margin-top:var(--s-5); }
.mb-0 { margin-bottom:0; } .mb-3 { margin-bottom:var(--s-3); } .mb-4 { margin-bottom:var(--s-4); }
.w-auto { width:auto; }
.btn-sm { font-size:var(--fs-sm); padding:var(--s-1) var(--s-3); min-height:auto; }
.field-label { display:block; font-size:var(--fs-sm); font-weight:500; color:var(--text); margin-bottom:var(--s-2); }
/* aligned label/control grid for settings-style forms */
.form-grid { display:grid; grid-template-columns:minmax(140px,max-content) 1fr; gap:var(--s-3) var(--s-4); align-items:center; }
.form-grid > label { margin:0; }
@media (max-width:640px){ .form-grid { grid-template-columns:1fr; gap:var(--s-2); } }

/* doc-page sub-headings + small text (help / mcp-setup) */
.subhead { font-family:var(--display); font-weight:600; font-size:var(--fs-base); letter-spacing:-.01em; margin:var(--s-4) 0 var(--s-2); color:var(--text); }
.text-sm { font-size:var(--fs-sm); }

/* action cells: a clean wrapping row of equal-height buttons (was unstyled) */
.draft-actions { display:flex; flex-wrap:wrap; gap:var(--s-2); align-items:center; }
.draft-actions form { margin:0; }
.draft-actions .btn, .draft-actions button { white-space:nowrap; }
