/* AI Product Intelligence Agent — design system
   Sourced from the Claude Design handoff (index.html). Keeps backwards-compat
   aliases at the bottom so existing Go templates render without rewrites.
*/

:root {
  /* Galara brand tokens (claude.ai/design — Galara Design System) */
  --navy: #001D3A;
  --white: #FFFFFF;
  --teal: #05D8DD;
  --light-green: #B0F8FF;
  --light-blue: #36BCFF;
  --mid-blue: #1D94FF;
  --blue: #2266FF;
  --navy-900: #001227;
  --navy-700: #0A2A4C;
  --navy-600: #17385E;
  --navy-500: #2C4B70;
  --navy-400: #4A6788;
  --grey-50: #F4F7FB;
  --grey-100: #E8EEF5;
  --grey-200: #D5E0EC;
  --grey-300: #B6C6D8;
  --grey-400: #8A9DB2;
  --grey-500: #5F7288;
  --grey-600: #435469;
  --grey-700: #2C3B4E;
  --success: #12B886;
  --warning: #FFB020;
  --danger: #F0384B;
  --info: #1D94FF;
  --accent: var(--blue);
  --accent-hover: #1A57E6;
  --accent-active: #1449C4;
  --focus-ring: var(--mid-blue);

  /* Legacy names, re-pointed to Galara values (templates use these inline) */
  --bg: var(--grey-50);
  --surface: #FFFFFF;
  --surface-2: #FAFBFD;
  --border: var(--grey-200);
  --border-soft: var(--grey-100);
  --text: var(--navy);
  --text-2: var(--navy-600);
  --text-3: var(--grey-500);
  --text-muted: var(--grey-400);

  --indigo: var(--blue);
  --indigo-50: #EBF1FF;
  --indigo-100: #D9E5FF;
  --indigo-600: #1A57E6;
  --indigo-700: #1449C4;

  --violet: #05B8BD;
  --violet-50: #E6FBFC;
  --violet-100: #CFF7F9;
  --violet-600: #049296;

  --emerald: #12B886;
  --emerald-50: #E7F8F2;
  --emerald-100: #D0F1E6;

  --amber: #B97908;
  --amber-50: #FFF7E8;
  --amber-100: #FEEBC8;

  --red: #F0384B;
  --red-50: #FEEBED;
  --red-100: #FDD8DC;

  --sky: #1D94FF;
  --sky-50: #EAF5FF;
  --sky-100: #D6EBFF;

  --slate-50: var(--grey-50);
  --slate-100: var(--grey-100);
  --slate-200: var(--grey-200);

  /* Radius / shadows (Galara: soft & rounded, pill signature, navy-tinted shadows) */
  --radius-sm: 8px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 16px;
  --radius-pill: 999px;

  --shadow-xs: 0 1px 2px rgba(0,29,58,0.06);
  --shadow-sm: 0 2px 6px rgba(0,29,58,0.08);
  --shadow-md: 0 8px 20px rgba(0,29,58,0.10);
  --shadow-lg: 0 16px 40px rgba(0,29,58,0.14);
  --shadow-focus: 0 0 0 3px rgba(29,148,255,0.18);
}

/* Reset */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Urbanist', -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01", "cv11";
}
.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--indigo); }

*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--grey-300); border-radius: 10px; border: 2px solid var(--bg); }
*::-webkit-scrollbar-thumb:hover { background: var(--grey-400); }

/* App shell (dark sidebar + topbar + content) */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}
.sidebar {
  background: var(--navy);
  color: rgba(255,255,255,0.66);
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 18px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  margin-bottom: 12px;
}
.brand-mark {
  width: 28px; height: 28px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--blue) 0%, var(--teal) 100%);
  display: grid; place-items: center;
  color: white;
  font-weight: 800;
  font-size: 13px;
  box-shadow: 0 2px 8px rgba(34, 102, 255, 0.4);
}
/* Product logo lockup — a spark mark plus a typographic wordmark. Set in
   Urbanist, which the page already loads, so there is no separate image asset
   to keep in sync and it stays crisp at any size. */
.logo-lockup { display: inline-flex; align-items: center; gap: 10px; }
.logo-lockup .logo-mark {
  flex: none;
  display: grid; place-items: center;
  width: 30px; height: 30px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--blue) 0%, var(--teal) 100%);
  box-shadow: 0 2px 8px rgba(34, 102, 255, 0.35);
}
.logo-lockup .logo-mark svg { width: 17px; height: 17px; display: block; fill: #fff; }
.logo-lockup .logo-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.logo-lockup .logo-word { font-weight: 800; letter-spacing: -0.02em; }
.logo-lockup .logo-tag { font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }

/* On the navy sidebar */
.logo-lockup.on-dark .logo-word { color: #fff; font-size: 15px; }
.logo-lockup.on-dark .logo-tag { color: rgba(255,255,255,0.45); font-size: 9.5px; margin-top: 3px; }

/* Larger, on the light login panel */
.logo-lockup.lg { margin-bottom: 32px; }
.logo-lockup.lg .logo-mark { width: 40px; height: 40px; border-radius: var(--radius); }
.logo-lockup.lg .logo-mark svg { width: 22px; height: 22px; }
.logo-lockup.lg .logo-word { color: var(--navy); font-size: 20px; }
.logo-lockup.lg .logo-tag { color: var(--text-3); font-size: 10.5px; margin-top: 4px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px;
  border: none; background: transparent;
  border-radius: var(--radius-pill);
  font-size: 15px;
  transition: background 120ms;
}
.icon-btn:hover { background: rgba(255,255,255,0.10); }
.page .icon-btn:hover, .card .icon-btn:hover { background: var(--grey-100); }
.brand-name { color: white; font-weight: 700; font-size: 13.5px; letter-spacing: -0.01em; }
.brand-sub { color: rgba(255,255,255,0.45); font-size: 11px; display: block; margin-top: 3px; letter-spacing: 0.04em; }

.nav-group-label {
  font-size: 10.5px;
  color: rgba(255,255,255,0.4);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 16px 8px 6px 8px;
  font-weight: 600;
}
.nav-item, aside.sidebar a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-pill);
  color: rgba(255,255,255,0.62);
  font-size: 13.5px;
  border: none;
  background: transparent;
  text-align: left;
  width: 100%;
  transition: background 120ms;
}
.nav-item:hover, aside.sidebar a:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.active, aside.sidebar a.active { background: var(--blue); color: #fff; font-weight: 700; }
.nav-count {
  margin-left: auto;
  font-size: 11px;
  background: rgba(255,255,255,0.08);
  color: #E2E8F0;
  padding: 1px 7px;
  border-radius: 99px;
  font-variant-numeric: tabular-nums;
}
.nav-count.violet { background: rgba(5, 216, 221, 0.18); color: var(--teal); }
.nav-count.amber  { background: rgba(255, 176, 32, 0.2); color: var(--warning); }

.content {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.crumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-3);
  font-size: 13px;
}
.crumbs .sep { color: var(--text-muted); }
.crumbs .here { color: var(--text); font-weight: 500; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 30px; height: 30px;
  border-radius: var(--radius-pill);
  background: var(--light-green);
  color: var(--navy);
  display: grid; place-items: center;
  font-size: 12px;
  font-weight: 800;
}

/* Page */
.page {
  padding: 24px 28px 64px 28px;
  max-width: 1440px;
  width: 100%;
}
.page-head, .page-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}
.page-title, .page-head h1, .page-header h1 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 0;
}
.page-sub, .page-subtitle { color: var(--text-3); font-size: 13.5px; margin-top: 4px; }
.page-actions, .header-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.header-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; color: var(--text-3); font-size: 13px; margin-top: 6px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 700;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  transition: all 120ms;
  white-space: nowrap;
  cursor: pointer;
}
.btn:hover { background: var(--slate-50); border-color: #D1D5DB; }
.btn:active { transform: scale(0.97); }
.btn:focus-visible { box-shadow: var(--shadow-focus); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary, .btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  box-shadow: 0 1px 2px rgba(34, 102, 255, 0.25);
}
.btn.primary:hover, .btn-primary:hover { background: var(--indigo-600); border-color: var(--indigo-600); }
.btn.ai { background: var(--navy); color: white; border-color: var(--navy); }
.btn.ai:hover { background: var(--navy-700); border-color: var(--navy-700); }
.btn.ghost, .btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover, .btn-ghost:hover { background: var(--slate-100); color: var(--text); }
.btn.danger { color: var(--red); border-color: var(--red-100); background: var(--red-50); }
.btn.danger:hover { background: var(--red-100); }
.btn.sm, .btn-sm { padding: 5px 12px; font-size: 12px; gap: 5px; }
.btn.lg, .btn-lg { padding: 12px 22px; font-size: 14px; }

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  padding: 18px;
  margin-bottom: 16px;
}
.card-head {
  margin: -18px -18px 14px -18px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-soft);
  display: flex; align-items: center; gap: 12px;
}
.card-title { font-size: 13.5px; font-weight: 600; color: var(--text); letter-spacing: -0.005em; margin: 0; }
.card h2 { font-size: 15px; font-weight: 600; margin: 0 0 12px 0; letter-spacing: -0.01em; }

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  line-height: 1.5;
  white-space: nowrap;
  border: 1px solid transparent;
  background: var(--slate-100);
  color: var(--text-2);
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.gray    { background: var(--slate-100); color: var(--text-2); }
.badge.indigo  { background: var(--indigo-50); color: var(--indigo-700); }
.badge.violet  { background: var(--violet-50); color: var(--violet-600); }
.badge.emerald { background: var(--emerald-50); color: var(--emerald); }
.badge.amber   { background: var(--amber-50); color: var(--amber); }
.badge.red     { background: var(--red-50); color: var(--red); }
.badge.sky     { background: var(--sky-50); color: var(--sky); }
.badge.outline { background: white; border-color: var(--border); color: var(--text-2); }

/* statusClass() emits badge-<slug>. Common values mapped here. */
.badge-draft, .badge-not-started, .badge-pending, .badge-pending-review,
.badge-admin, .badge-topic-owner, .badge-department-contributor, .badge-role { background: var(--slate-100); color: var(--text-2); }
.badge-knowledge-scan-completed, .badge-questions-generated, .badge-questions-approved,
.badge-ready-for-owner-review, .badge-in-progress, .badge-collecting-input,
.badge-spec-draft-generated { background: var(--indigo-50); color: var(--indigo-700); }
.badge-ai-updates-pending, .badge-ai-draft, .badge-ai-updates-pending-review, .badge-proposed { background: var(--violet-50); color: var(--violet-600); }
.badge-confirmed, .badge-completed, .badge-done, .badge-resolved,
.badge-applied, .badge-answered, .badge-low { background: var(--emerald-50); color: var(--emerald); }
.badge-medium, .badge-warning, .badge-questions-sent, .badge-changes-requested, .badge-needs-clarification { background: var(--amber-50); color: var(--amber); }
.badge-high, .badge-critical, .badge-blocked-by-conflict, .badge-open,
.badge-needs-decision, .badge-rejected, .badge-superseded { background: var(--red-50); color: var(--red); }
.badge-info, .badge-sent { background: var(--sky-50); color: var(--sky); }

/* Table */
.table { width: 100%; border-collapse: collapse; font-size: 13px; background: var(--surface); border-radius: var(--radius-lg); overflow: hidden; }
.table th {
  text-align: left;
  font-weight: 700;
  color: var(--text-3);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.table tr:hover td { background: var(--surface-2); }
.table tr:last-child td { border-bottom: none; }
.table a { color: var(--text); font-weight: 500; }
.table a:hover { color: var(--indigo); }

/* Readiness bar */
.ready-bar {
  height: 6px;
  background: var(--slate-100);
  border-radius: 99px;
  overflow: hidden;
  min-width: 80px;
}
.ready-bar > span { display: block; height: 100%; border-radius: 99px; background: var(--indigo); }
.ready-bar.success > span { background: var(--emerald); }
.ready-bar.warn > span { background: var(--amber); }

/* KPI */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.kpi-label { font-size: 11.5px; color: var(--text-3); font-weight: 500; text-transform: uppercase; letter-spacing: 0.08em; }
.kpi-value { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; margin-top: 4px; }
.kpi-delta { font-size: 11.5px; color: var(--text-3); font-family: 'JetBrains Mono', monospace; }
.kpi-delta.up   { color: var(--emerald); }
.kpi-delta.down { color: var(--red); }
.kpi.accent-violet { border-color: #CFF7F9; background: linear-gradient(180deg, #F0FCFD 0%, white 60%); }
.kpi.accent-amber  { border-color: #FEEBC8; background: linear-gradient(180deg, #FFF9F0 0%, white 60%); }

/* AI surfaces */
.ai-block {
  border-left: 3px solid var(--teal);
  background: linear-gradient(90deg, rgba(5, 216, 221, 0.06) 0%, rgba(5, 216, 221, 0) 60%);
  padding: 14px 16px;
  border-radius: var(--radius);
}
.ai-tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10.5px; font-weight: 600;
  color: var(--violet);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 6px;
  background: var(--violet-50);
  border-radius: 4px;
}

/* Stepper */
.stepper {
  display: flex; align-items: center; gap: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  margin-bottom: 16px;
}
.step {
  flex: 1; display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  border-right: 1px solid var(--border-soft);
  font-size: 12.5px;
  color: var(--text-3);
  min-width: 0;
}
.step:last-child { border-right: none; }
.step-num {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--slate-100);
  color: var(--text-3);
  display: grid; place-items: center;
  font-size: 11.5px;
  font-weight: 600;
  flex-shrink: 0;
}
.step.done { background: linear-gradient(180deg, #E7F8F2 0%, #ffffff 80%); color: var(--text); }
.step.done .step-num { background: var(--emerald); color: white; }
.step.active { background: linear-gradient(180deg, #EBF1FF 0%, #ffffff 80%); color: var(--text); }
.step.active .step-num { background: var(--indigo); color: white; box-shadow: 0 0 0 3px var(--indigo-50); }
.step-label { font-weight: 500; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step-sub { font-size: 11px; color: var(--text-muted); font-family: 'JetBrains Mono', monospace; }

/* Tabs */
.tabs { display: flex; gap: 6px; margin-bottom: 20px; overflow-x: auto; padding: 4px; background: var(--grey-100); border-radius: var(--radius-pill); width: fit-content; max-width: 100%; }
.tab, .topic-tab a {
  padding: 8px 15px;
  font-size: 13px;
  color: var(--grey-600);
  border: none;
  background: transparent;
  border-radius: var(--radius-pill);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  transition: background 120ms, color 120ms;
}
.tab:hover, .topic-tab a:hover { color: var(--navy); background: rgba(255,255,255,0.7); }
.tab.active, .topic-tab a.active { color: white; background: var(--navy); }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field-label, .form-row > label, .stacked-form label { font-size: 12.5px; font-weight: 600; color: var(--text); display: block; margin-bottom: 4px; }
.field-help, .helper-text, .form-help { font-size: 12px; color: var(--text-3); }
.input, .textarea, .select,
.stacked-form input[type="text"],
.stacked-form input[type="email"],
.stacked-form input[type="password"],
.stacked-form input[type="number"],
.stacked-form textarea,
.stacked-form select,
.form-row input[type="text"],
.form-row input[type="email"],
.form-row input[type="password"],
.form-row textarea,
.form-row select {
  border: 1px solid var(--grey-300);
  border-radius: 12px;
  padding: 9px 13px;
  font-size: 13.5px;
  background: white;
  width: 100%;
  transition: border 120ms, box-shadow 120ms;
}
.input:focus, .textarea:focus, .select:focus,
.stacked-form input:focus, .stacked-form textarea:focus, .stacked-form select:focus,
.form-row input:focus, .form-row textarea:focus, .form-row select:focus {
  outline: none;
  border-color: var(--focus-ring);
  box-shadow: var(--shadow-focus);
}
.textarea, .stacked-form textarea, .form-row textarea { resize: vertical; min-height: 120px; font-family: inherit; width: 100%; }
.input-sm { padding: 6px 10px; font-size: 12.5px; width: auto; }
select.input-sm { min-width: 190px; padding: 9px 12px; font-size: 13.5px; }
.stacked-form { display: flex; flex-direction: column; gap: 4px; }
.form-row { margin-bottom: 14px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
.filter-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin-bottom: 16px; }
.filter-form label { font-size: 12.5px; color: var(--text-2); display: flex; flex-direction: column; gap: 4px; }

.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; }
.checkbox {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: white;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-2);
}
.checkbox:hover { background: var(--slate-50); }
.checkbox input { accent-color: var(--indigo); }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  background: white;
  border-radius: 99px;
  font-size: 12.5px;
  color: var(--text-2);
  cursor: pointer;
}
.chip:hover { background: var(--slate-50); }
.chip.selected { background: var(--indigo-50); border-color: var(--indigo-100); color: var(--indigo-700); }

/* Flash / hint */
.flash {
  background: var(--indigo-50);
  border: 1px solid var(--indigo-100);
  color: var(--indigo-700);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 12.5px;
  margin-bottom: 14px;
  display: flex; gap: 10px; align-items: flex-start;
}
.flash-msg { background: var(--emerald-50); border-color: var(--emerald-100); color: #064E3B; }
.flash-err, .flash-error { background: var(--red-50); border-color: var(--red-100); color: #7F1D1D; }
.hint {
  background: var(--violet-50);
  border: 1px solid #E9D5FF;
  color: #4C1D95;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 12.5px;
  margin-bottom: 14px;
}

/* Timeline (audit) */
.timeline { position: relative; padding-left: 24px; }
.timeline::before {
  content: ""; position: absolute; left: 8px; top: 4px; bottom: 4px; width: 2px;
  background: var(--border);
}
.tl-item { position: relative; padding: 0 0 18px 0; }
.tl-dot {
  position: absolute; left: -23px; top: 4px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: white;
  border: 2px solid var(--slate-200);
}
.tl-dot.ai     { border-color: var(--violet); background: var(--violet-50); }
.tl-dot.human  { border-color: var(--indigo); background: var(--indigo-50); }
.tl-meta { display: flex; gap: 8px; align-items: center; color: var(--text-3); font-size: 12px; }
.tl-action { color: var(--text); font-size: 13.5px; font-weight: 500; }
.tl-desc { color: var(--text-3); font-size: 12.5px; margin-top: 2px; }

/* Spec doc */
.spec-doc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 44px;
  box-shadow: var(--shadow-xs);
}
.spec-doc h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; margin: 0 0 16px 0; }
.spec-doc h2 { font-size: 17px; font-weight: 600; letter-spacing: -0.015em; margin: 32px 0 10px 0; padding-bottom: 8px; border-bottom: 1px solid var(--border-soft); }
.spec-doc h3 { font-size: 14px; font-weight: 600; margin: 20px 0 8px 0; }
.spec-doc p  { color: var(--text-2); font-size: 13.5px; line-height: 1.65; margin: 8px 0; }
.spec-doc ul { padding-left: 22px; color: var(--text-2); font-size: 13.5px; line-height: 1.7; }
.spec-doc li { margin: 3px 0; }
.spec-doc table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 13px; }
.spec-doc th, .spec-doc td { border-bottom: 1px solid var(--border-soft); padding: 8px 10px; text-align: left; }

.review-questions { list-style: none; margin: 8px 0 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.review-questions li { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text-2); }

.spec { /* container the renderer wraps the spec HTML in */ }
.spec h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; margin: 0 0 16px 0; }
.spec h2 { font-size: 17px; font-weight: 600; letter-spacing: -0.015em; margin: 32px 0 10px 0; padding-bottom: 8px; border-bottom: 1px solid var(--border-soft); }
.spec h3 { font-size: 14px; font-weight: 600; margin: 20px 0 8px 0; }
.spec p  { color: var(--text-2); font-size: 13.5px; line-height: 1.65; margin: 8px 0; }
.spec ul { padding-left: 22px; color: var(--text-2); font-size: 13.5px; line-height: 1.7; }
.spec table, .md-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.spec th, .spec td, .md-table th, .md-table td {
  border-bottom: 1px solid var(--border-soft);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}
.spec th, .md-table th {
  background: var(--surface-2);
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-3);
}
.spec tr:last-child td, .md-table tr:last-child td { border-bottom: none; }

/* ===== Spec page 3-column layout ===== */
.spec-layout {
  display: grid;
  grid-template-columns: 220px 1fr 280px;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 16px;
}
@media (max-width: 1280px) { .spec-layout { grid-template-columns: 200px 1fr; } .spec-side { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; } }
@media (max-width: 900px)  { .spec-layout { grid-template-columns: 1fr; } }

.spec-toc {
  position: sticky;
  top: 76px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.toc-item {
  display: block;
  padding: 6px 10px;
  border-radius: 6px;
  color: var(--text-3);
  font-size: 12.5px;
  cursor: pointer;
  border-left: 2px solid transparent;
  margin: 1px 0;
  text-decoration: none;
  line-height: 1.4;
}
.toc-item:hover { background: var(--slate-50); color: var(--text); }
.toc-item.active {
  color: var(--indigo);
  background: var(--indigo-50);
  border-left-color: var(--indigo);
  font-weight: 500;
}
.spec-side {
  position: sticky;
  top: 76px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ===== Workspace header ===== */
.ws-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 22px;
  margin-bottom: 16px;
}

/* Diff (for AI proposal previews) */
.diff-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.diff-block { padding: 12px 14px; border-radius: var(--radius); font-size: 13px; line-height: 1.55; }
.diff-block.before { background: var(--red-50); border: 1px solid var(--red-100); color: #7F1D1D; }
.diff-block.after  { background: var(--emerald-50); border: 1px solid var(--emerald-100); color: #064E3B; }
.diff-label { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px; opacity: 0.7; }

/* Conflict / locked banners */
.conflict-card {
  border: 1px solid var(--red-100);
  border-left: 4px solid var(--red);
  background: linear-gradient(90deg, var(--red-50) 0%, white 30%);
  border-radius: var(--radius-lg);
  padding: 18px;
}
.locked-banner {
  background: linear-gradient(90deg, #ECFDF5 0%, #ffffff 100%);
  border: 1px solid var(--emerald-100);
  border-left: 4px solid var(--emerald);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 16px;
}

/* Utilities */
.row    { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.col    { display: flex; flex-direction: column; gap: 8px; }
.grow   { flex: 1; min-width: 0; }
.muted  { color: var(--text-3); font-size: 13px; }
.small  { font-size: 12px; }
.xs     { font-size: 11.5px; }
.nowrap { white-space: nowrap; }
.empty  { color: var(--text-3); padding: 24px 0; text-align: center; }
.inline { display: inline-block; margin-right: 6px; }

.mt-0{margin-top:0}.mt-1{margin-top:4px}.mt-2{margin-top:8px}.mt-3{margin-top:12px}.mt-4{margin-top:16px}.mt-5{margin-top:20px}.mt-6{margin-top:24px}
.mb-1{margin-bottom:4px}.mb-2{margin-bottom:8px}.mb-3{margin-bottom:12px}.mb-4{margin-bottom:16px}.mb-5{margin-bottom:20px}.mb-6{margin-bottom:24px}
.gap-1{gap:4px}.gap-2{gap:8px}.gap-3{gap:12px}.gap-4{gap:16px}

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }

/* Login shell */
.login-shell {
  min-height: 100vh;
  background: var(--white);
  display: grid;
  grid-template-columns: 1fr 1fr;
}
@media (max-width: 900px) { .login-shell { grid-template-columns: 1fr; } .login-brand { display: none; } }
.login-shell > .flash { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 50; box-shadow: var(--shadow-md); }
.login-form-panel {
  display: flex; align-items: center; justify-content: center;
  padding: 40px;
}
.login-form-inner { width: 100%; max-width: 360px; }
.login-form-inner h1 { font-size: 28px; font-weight: 800; letter-spacing: -0.01em; color: var(--navy); margin: 0 0 6px 0; }
.login-form-inner .subtitle { color: var(--text-3); font-size: 14.5px; margin-bottom: 28px; }
.login-brand {
  position: relative;
  background: var(--navy);
  color: white;
  padding: 56px;
  display: flex; flex-direction: column; justify-content: center;
  overflow: hidden;
}
.login-glow-teal {
  position: absolute; right: -80px; top: -80px;
  width: 320px; height: 320px; border-radius: 50%;
  background: radial-gradient(circle, rgba(5,216,221,0.35), transparent 70%);
}
.login-glow-blue {
  position: absolute; left: -60px; bottom: -60px;
  width: 260px; height: 260px; border-radius: 50%;
  background: radial-gradient(circle, rgba(34,102,255,0.4), transparent 70%);
}
.login-kicker {
  position: relative;
  font-size: 12.5px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--teal);
  margin: 0 0 18px 0;
}
.login-headline {
  position: relative;
  margin: 0; font-size: 38px; font-weight: 800;
  line-height: 1.1; letter-spacing: -0.02em; max-width: 420px;
}
.login-sub {
  position: relative;
  margin: 18px 0 0 0; font-size: 15.5px; line-height: 1.55;
  color: rgba(255,255,255,0.72); max-width: 420px;
}

/* Backward-compat aliases */
.layout { display: contents; }
.main   { padding: 0; min-width: 0; }
.nav    { display: none; }
.nav-brand, .nav-user, .nav-user-name, .nav-logout-form { }
.page-subtitle { color: var(--text-3); font-size: 13.5px; }

/* Live job banner + spinner. Reload the page when the polling JS detects
   the topic's latest job has transitioned out of RUNNING. */
.job-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  margin-bottom: 16px;
  border: 1px solid var(--indigo-100);
  border-left: 3px solid var(--indigo);
  background: linear-gradient(90deg, var(--indigo-50) 0%, white 60%);
  border-radius: var(--radius-lg);
  position: relative;
  overflow: hidden;
}
.job-banner::after {
  content: "";
  position: absolute;
  left: -30%;
  bottom: 0;
  width: 30%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--indigo), transparent);
  animation: aipa-progress 1.6s cubic-bezier(.4, 0, .2, 1) infinite;
}
@keyframes aipa-progress {
  0%   { left: -30%; }
  100% { left: 100%; }
}
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--indigo-100);
  border-top-color: var(--indigo);
  border-radius: 50%;
  animation: aipa-spin 0.85s linear infinite;
  flex-shrink: 0;
}
.spinner.violet { border-color: var(--violet-100); border-top-color: var(--violet); }
@keyframes aipa-spin { to { transform: rotate(360deg); } }
.job-banner .job-text { display: flex; flex-direction: column; gap: 2px; }
.job-banner .job-title { font-size: 13.5px; font-weight: 600; color: var(--text); }
.job-banner .job-sub   { font-size: 12px; color: var(--text-3); }

/* Pulse for inline activity */
@keyframes aipa-pulse { 0%, 100% { opacity: .6; } 50% { opacity: 1; } }
.pulsing { animation: aipa-pulse 1.4s ease-in-out infinite; }

/* Dashboard 2-up: main table + side panel. Stacks below 1024px. */
.dash-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
@media (max-width: 1024px) {
  .dash-grid { grid-template-columns: 1fr; }
}

/* Make AI-block clickable rows in the dashboard sidebar a hair more inviting. */
a.ai-block:hover { background: linear-gradient(90deg, rgba(124, 58, 237, 0.08) 0%, rgba(124, 58, 237, 0) 60%); }
a[href].row:hover { background: var(--slate-50); }

/* Code blocks (JSON dumps in AI proposal review) */
.code-block, pre.code-block {
  background: var(--slate-50);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-2);
  overflow-x: auto;
  white-space: pre-wrap;
}

/* Section heading inside cards */
.section-heading {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 20px 0 10px 0;
  padding-top: 12px;
  border-top: 1px solid var(--border-soft);
}
.section-heading:first-child { margin-top: 0; padding-top: 0; border-top: none; }

/* Code-graph / source-type icon badges */
.badge-clickup { background: var(--sky-50); color: var(--sky); }
.badge-jira       { background: var(--indigo-50); color: var(--indigo-700); }
.badge-code-graph { background: var(--slate-100); color: var(--text-2); }
.badge-regulation { background: var(--violet-50); color: var(--violet-600); }
.badge-ai-assumption { background: var(--violet-50); color: var(--violet-600); }
.badge-requirement { background: var(--indigo-50); color: var(--indigo-700); }
.badge-existing-capability { background: var(--emerald-50); color: var(--emerald); }
.badge-missing-capability  { background: var(--amber-50); color: var(--amber); }
.badge-dependency { background: var(--sky-50); color: var(--sky); }
.badge-technical-impact { background: var(--slate-100); color: var(--text-2); }


/* Speech-to-text mic toggle */
.btn.mic.recording {
  background: var(--red-50);
  color: var(--red);
  border-color: var(--red-100);
  animation: mic-pulse 1.2s ease-in-out infinite;
}
@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.35); }
  50%      { box-shadow: 0 0 0 4px rgba(239, 68, 68, 0); }
}

/* New-topic page: form + "Refine with AI" side by side */
.topic-new-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 16px;
  align-items: start;
}
.topic-new-layout > .card { margin-bottom: 0; }
.topic-new-layout #brief-refine { position: sticky; top: 16px; }
@media (max-width: 960px) {
  .topic-new-layout {
    grid-template-columns: 1fr;
  }
  .topic-new-layout #brief-refine { position: static; }
}

/* Document view: main content + sidebar (no TOC column) */
.doc-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 16px;
}
@media (max-width: 900px) { .doc-layout { grid-template-columns: 1fr; } }

/* Generate-document toolbar: aligned select + action button */
.gen-doc-bar { display: flex; flex-direction: column; gap: 7px; }
.gen-doc-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.field-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-2); }
.field-select {
  appearance: none; -webkit-appearance: none;
  box-sizing: border-box;
  flex: 0 0 340px; max-width: 100%;
  height: 42px; margin: 0;
  padding: 0 38px 0 12px;
  font-size: 13.5px; font-weight: 500; line-height: normal; color: var(--text);
  background-color: var(--surface);
  border: 1px solid var(--border); border-radius: 8px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 16px;
  transition: border-color 120ms, box-shadow 120ms;
  cursor: pointer;
}
.field-select:hover { border-color: #CBD0DA; }
.field-select:focus { outline: none; border-color: var(--violet); box-shadow: 0 0 0 3px var(--violet-50); }
.gen-doc-row .btn { box-sizing: border-box; height: 42px; padding-top: 0; padding-bottom: 0; padding-left: 18px; padding-right: 18px; }

/* Document-type hint list under the toolbar */
.doc-type-hints { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 8px; margin-top: 16px; }
.doc-type-hint { padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--border-soft); border-radius: 8px; font-size: 12.5px; color: var(--text-3); line-height: 1.45; }
.doc-type-hint strong { color: var(--text-2); font-weight: 600; }

/* ============================================================
   INTERFACE REDESIGN — "Make the agent's work legible"
   Product Intelligence Design Doc v1, July 2026.

   Four disclosures the product owed its users and never made:
   who owns the next move, who wrote this sentence, what the
   agent is doing right now, and why a gate is closed.
   ============================================================ */

:root {
  --prov-ai: var(--teal);             /* #05D8DD */
  --prov-human: var(--success);       /* #12B886 */
  --prov-assumption: var(--warning);  /* #FFB020 */

  --prov-ai-ink: #00767A;
  --prov-human-ink: #0C7A5B;
  --prov-assumption-ink: #8A5A00;
  --danger-ink: #C42232;

  --prov-ai-wash: #F7FEFE;
  --prov-assumption-wash: #FFFCF5;

  --mono: 'JetBrains Mono', ui-monospace, monospace;
}

/* ---------- Ownership dot ----------
   Three states, no icon font. Shape, fill and an adjacent label
   all carry the state, so it survives greyscale and a screen
   reader equally. */
.own { width: 11px; height: 11px; border-radius: var(--radius-pill); flex: none; display: inline-block; }
.own--you   { background: var(--blue); box-shadow: 0 0 0 4px rgba(34,102,255,.16); }
.own--them  { background: none; border: 2.5px solid var(--grey-600); }
.own--agent { background: var(--teal); animation: agentPulse 1.6s ease-in-out infinite; }
.own--done  { background: var(--success); }
.own--blocked { background: var(--danger); border-radius: 3px; }

@keyframes agentPulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: .45; transform: scale(.82); } }
@keyframes shimmer    { 0% { background-position: -420px 0; } 100% { background-position: 420px 0; } }
@keyframes caret      { 0%,49% { opacity: 1; } 50%,100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .own--agent, .agent-caret, .job-step__glyph--now { animation: none; }
}

/* The ownership line itself: one sentence naming who holds the ball. */
.ownership {
  display: flex; align-items: stretch; gap: 0;
  border: 1px solid var(--border); border-radius: 12px;
  overflow: hidden; background: #FBFCFE;
}
.ownership__main { flex: 1; padding: 14px 18px; display: flex; align-items: center; gap: 13px; min-width: 0; }
.ownership__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ownership__who { font-size: 15.5px; font-weight: 700; }
.ownership__why { font-size: 13px; color: var(--text-2); }
.ownership__act { margin-left: auto; flex: none; }
.ownership__aside {
  width: 250px; flex: none; padding: 14px 18px;
  display: flex; flex-direction: column; gap: 7px;
  border-left: 1px solid var(--border);
}
.ownership__aside-label { font: 500 9.5px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--text-3); }
.ownership__aside-item { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-2); }
.ownership__aside-item .own { width: 9px; height: 9px; }

/* ---------- Provenance ----------
   Every block of spec text is exactly one of three things and
   says which. The dashed border on assumptions is the one
   non-colour cue that reads from across a room. */
.prov { border-left: 3px solid var(--grey-300); padding-left: 18px; display: flex; flex-direction: column; gap: 8px; }
.prov--human  { border-color: var(--prov-human); }
.prov--ai {
  border-color: var(--prov-ai); background: var(--prov-ai-wash);
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0; padding: 16px 18px;
}
.prov--assume {
  border-left-style: dashed; border-color: var(--prov-assumption);
  background: var(--prov-assumption-wash);
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0; padding: 16px 18px;
}
.prov__head { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.prov__tag { font: 700 9.5px/1 var(--mono); letter-spacing: .11em; text-transform: uppercase; }
.prov--ai     .prov__tag { color: var(--prov-ai-ink); }
.prov--human  .prov__tag { color: var(--prov-human-ink); }
.prov--assume .prov__tag { color: var(--prov-assumption-ink); }
/* Glyph, not colour — the state survives a greyscale print. */
.prov--ai     .prov__tag::before { content: "\25C6\00a0"; }
.prov--human  .prov__tag::before { content: "\2713\00a0"; }
.prov--assume .prov__tag::before { content: "?\00a0"; }
.prov__meta { font: 400 10.5px/1.4 var(--mono); color: var(--text-3); }
.prov__body { margin: 0; font-size: 16.5px; line-height: 1.68; color: var(--text); max-width: 68ch; }
.prov__actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding-top: 3px; }
.prov__note { font: 400 10.5px/1.5 var(--mono); color: var(--text-3); }

/* Provenance legend in the reader's left rail. */
.prov-legend { display: flex; flex-direction: column; gap: 9px; }
.prov-legend__row { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-2); }
.prov-legend__rule { width: 3px; height: 14px; border-radius: 2px; flex: none; }

/* ---------- Status badges ----------
   Glyph + word + colour, always all three. Every new badge must
   stay legible with `filter: grayscale(1)` applied. */
.sbadge {
  display: inline-flex; align-items: center; gap: 6px;
  font: 700 10.5px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase;
  border-radius: var(--radius-pill); padding: 4px 10px; border: 1px solid transparent;
  white-space: nowrap;
}
.sbadge::before { font-weight: 700; }
.sbadge--approved { background: #EAF9F4; color: var(--prov-human-ink); border-color: #B9E9DA; }
.sbadge--approved::before { content: "\2713"; }
.sbadge--pending  { background: var(--grey-50); color: var(--text-2); border-color: var(--grey-200); }
.sbadge--pending::before { content: "\25F7"; }
.sbadge--paused   { background: #FFF3DE; color: var(--prov-assumption-ink); border-color: #F5D9A6; }
.sbadge--paused::before { content: "\2016"; }
.sbadge--stale    { background: #FFF3DE; color: var(--prov-assumption-ink); border-color: #F5D9A6; }
.sbadge--stale::before { content: "\21BA"; }
.sbadge--changes  { background: #FFE9EC; color: var(--danger-ink); border-color: #FADCE0; }
.sbadge--changes::before { content: "\21A9"; }
.sbadge--cancelled { background: var(--grey-50); color: var(--text-3); border-color: var(--border); }
.sbadge--cancelled::before { content: "\2715"; }
.sbadge--ai       { background: #F1FDFD; color: var(--prov-ai-ink); border-color: #B8F0F2; }
.sbadge--ai::before { content: "\25C6"; }
.sbadge--assume   { background: var(--prov-assumption-wash); color: var(--prov-assumption-ink); border-color: #F5D9A6; }
.sbadge--assume::before { content: "?"; }
.sbadge--you      { background: #EAF1FF; color: var(--indigo-600); border-color: #CBDDFF; }
.sbadge--you::before { content: "\25CF"; }
.sbadge--late     { background: #FFE9EC; color: var(--danger-ink); border-color: #FADCE0; }
.sbadge--late::before { content: "\25B2"; }

/* ---------- Approval gate ----------
   One segment per department, so "4 of 5" is countable and the
   odd one out is visible. Colour repeats the caption, never
   carries it alone. */
.gate { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl); overflow: hidden; }
.gate__head { padding: 17px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.gate__title { display: flex; align-items: center; gap: 9px; }
.gate__title h2 { margin: 0; font-size: 17px; font-weight: 800; }
.gate__lede { font-size: 13.5px; color: var(--text-2); }
.gate__meter { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.gate__segs { display: flex; gap: 4px; width: 180px; }
.gate__seg { flex: 1; height: 8px; border-radius: var(--radius-pill); background: var(--grey-200); }
.gate__seg--valid   { background: var(--success); }
.gate__seg--warn    { background: var(--warning); }
.gate__seg--blocked { background: var(--danger); }
.gate__caption { font: 400 10.5px/1 var(--mono); color: var(--text-3); }
.gate__rule { padding: 14px 20px; background: #F9FBFD; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 11px; flex-wrap: wrap; }
.gate__rule-label { font: 700 10px/1 var(--mono); letter-spacing: .13em; text-transform: uppercase; color: var(--text-3); }
.gate__rule-text { font-size: 13px; color: var(--text-2); }
.gate table { width: 100%; border-collapse: collapse; font-size: 14px; }
.gate th {
  text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); background: #F9FBFD;
  font: 700 10px/1 var(--mono); letter-spacing: .13em; text-transform: uppercase; color: var(--text-3);
}
.gate td { padding: 14px; border-bottom: 1px solid var(--grey-50); vertical-align: top; }
.gate th:first-child, .gate td:first-child { padding-left: 20px; }
.gate th:last-child,  .gate td:last-child  { padding-right: 20px; }
.gate tr.is-attention { background: var(--prov-assumption-wash); }
.gate__dept { display: flex; flex-direction: column; gap: 2px; }
.gate__dept strong { font-weight: 700; }
.gate__dept span { font-size: 12px; color: var(--text-3); }
.gate__against { font: 400 12.5px/1.4 var(--mono); color: var(--text-2); }
.gate__against--stale { color: var(--prov-assumption-ink); font-weight: 600; }
.gate__means { font-size: 13px; color: var(--text-2); line-height: 1.5; }
/* The arithmetic, shown rather than asserted: "11 Aug + 3d paused". */
.gate__deadline { display: flex; flex-direction: column; gap: 1px; font-size: 13px; }
.gate__deadline strong { font-weight: 600; }
.gate__deadline span { font: 400 11px/1.3 var(--mono); color: var(--prov-assumption-ink); }

/* ---------- Job states ----------
   Every state answers three questions: what is happening, how
   long it has taken, and whether you may leave. Elapsed time
   only — an LLM's finish time is unknowable, and a broken
   estimate is what makes software feel untrustworthy. */
.job { border-radius: var(--radius-xl); overflow: hidden; display: flex; flex-direction: column; border: 1px solid var(--border); background: var(--surface); }
.job__head { padding: 11px 16px; border-bottom: 1px solid var(--border); background: var(--grey-50); }
.job__state { font: 700 10px/1 var(--mono); letter-spacing: .13em; text-transform: uppercase; color: var(--text-3); }
.job__body { padding: 18px; display: flex; flex-direction: column; gap: 12px; flex: 1; }
.job__title { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 700; }
.job__elapsed { margin-left: auto; font: 400 11px/1 var(--mono); color: var(--text-3); }
.job__say { margin: 0; font-size: 13.5px; line-height: 1.6; color: var(--text-2); }
.job__bar { height: 6px; border-radius: var(--radius-pill); background: var(--grey-100); overflow: hidden; }
.job__bar > span { display: block; height: 100%; background: var(--teal); }
.job__foot { margin-top: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.job__poll { font: 400 10px/1.4 var(--mono); color: var(--text-3); }
.job__err { background: var(--grey-50); border-radius: 9px; padding: 10px 12px; font: 400 11px/1.6 var(--mono); color: var(--text-2); word-break: break-word; }

.job--running { background: var(--navy); border-color: var(--navy); }
.job--running .job__head { background: rgba(255,255,255,.06); border-bottom-color: rgba(255,255,255,.1); }
.job--running .job__state { color: var(--teal); }
.job--running .job__title { color: #fff; }
.job--running .job__say { color: #A9B7C8; }
.job--running .job__elapsed, .job--running .job__poll { color: #7FA0BF; }
.job--running .job__bar { background: rgba(255,255,255,.13); }
.job--done   { border-color: #B9E9DA; }
.job--done   .job__head { background: #EAF9F4; border-bottom-color: #B9E9DA; }
.job--done   .job__state { color: var(--prov-human-ink); }
.job--failed { border-color: #FADCE0; }
.job--failed .job__head { background: #FFF5F6; border-bottom-color: #FADCE0; }
.job--failed .job__state { color: var(--danger-ink); }

/* Append-only step log. Renders whatever stages the server knows;
   with none, the card is still correct — just shorter. */
.job-steps { display: flex; flex-direction: column; gap: 6px; font: 400 11.5px/1.5 var(--mono); }
.job-step { display: flex; gap: 9px; }
.job-step__at { color: #4A6784; flex: none; }
.job-step__glyph { flex: none; }
.job-step__glyph--done { color: var(--success); }
.job-step__glyph--now  { color: var(--teal); animation: agentPulse 1.4s ease-in-out infinite; }
.job-step__what { color: #A9B7C8; }
.job-step--now .job-step__what { color: #fff; }
.job-step--todo .job-step__at, .job-step--todo .job-step__glyph, .job-step--todo .job-step__what { color: #4A6784; }
.agent-caret { animation: caret 1s step-end infinite; color: var(--teal); }
.job-skeleton { display: block; height: 9px; border-radius: var(--radius-pill);
  background: linear-gradient(90deg,#EDF1F7 8%,#E1E8F2 18%,#EDF1F7 33%);
  background-size: 420px 100%; animation: shimmer 1.4s linear infinite; }

/* ---------- The one list row ----------
   Dot, title, mono meta line, right-hand action. One shape for
   findings, sources, risks, conflicts and decisions — per-topic
   and global lists differ only by whether the meta names the
   topic. This is what deletes eight bespoke tables. */
.lrow { display: flex; align-items: flex-start; gap: 12px; padding: 13px 15px; border-bottom: 1px solid var(--grey-50); }
.lrow:last-child { border-bottom: none; }
.lrow__dot { width: 9px; height: 9px; border-radius: var(--radius-pill); flex: none; margin-top: 5px; background: var(--grey-300); }
.lrow__dot--ai { background: var(--teal); }
.lrow__dot--risk { background: var(--warning); }
.lrow__dot--conflict { background: var(--danger); border-radius: 2px; }
.lrow__dot--done { background: var(--success); }
.lrow__main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.lrow__title { font-size: 14px; font-weight: 700; }
.lrow__meta { font: 400 11px/1.45 var(--mono); color: var(--text-3); }
.lrow__act { flex: none; align-self: center; }
.lrow-list { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--surface); }

/* Empty states say what the agent last did, not just "nothing here". */
.empty-state {
  border: 1px dashed var(--grey-300); border-radius: 12px; padding: 22px;
  display: flex; flex-direction: column; gap: 7px; align-items: flex-start; background: #FBFCFE;
}
.empty-state__label { font: 400 9.5px/1 var(--mono); letter-spacing: .13em; text-transform: uppercase; color: var(--text-3); }
.empty-state__title { font-size: 14.5px; font-weight: 700; }
.empty-state__say { font-size: 13px; color: var(--text-2); line-height: 1.55; max-width: 46ch; }

/* ---------- Focus and field errors ----------
   A two-tone ring (white halo, navy outline) so focus survives
   on white, navy and amber grounds alike. */
:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px #fff, 0 0 0 5.5px var(--navy);
  border-radius: var(--radius-sm);
}
.sidebar :focus-visible, .job--running :focus-visible {
  box-shadow: 0 0 0 3px var(--navy), 0 0 0 5.5px var(--teal);
}
/* Errors are a border AND a glyph AND a sentence, adjacent to the
   field rather than banner-ed at the top of the page. */
.field-error input, .field-error textarea, .field-error select { border: 1.5px solid var(--danger); background: #FFF9FA; }
.field-error > label { color: var(--danger-ink); }
.field-msg { font-size: 11.5px; font-weight: 600; color: var(--danger-ink); display: flex; align-items: center; gap: 5px; }
.field-msg::before { content: "\25B2"; }

/* ---------- Rooms ----------
   Thirteen siblings become four rooms with sub-tabs. Two levels
   beat thirteen. Each room carries a count and a one-line
   description, so a new PM never has to guess where Findings
   lives. A room with nothing in it stays visible — absence is
   information too. */
.rooms { border-top: 1px solid var(--border); background: #F9FBFD; padding: 14px 22px 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.room {
  text-decoration: none; background: var(--surface);
  border: 1px solid var(--border); border-bottom: none;
  border-radius: 12px 12px 0 0; padding: 13px 15px 15px;
  display: flex; flex-direction: column; gap: 4px;
}
.room__top { display: flex; align-items: center; gap: 8px; }
.room__name { font-size: 14.5px; font-weight: 700; color: var(--text-2); }
.room__count { margin-left: auto; font: 400 10.5px/1 var(--mono); color: var(--text-3); }
.room__desc { font-size: 12px; color: var(--text-3); }
.room.is-active { background: var(--navy); border-color: var(--navy); }
.room.is-active .room__name { color: #fff; font-weight: 800; }
.room.is-active .room__desc { color: #A9B7C8; }
.room.is-active .room__count { color: var(--navy); background: var(--teal); border-radius: var(--radius-pill); padding: 1px 8px; font-weight: 700; }

.subtabs { background: var(--navy); padding: 0 22px; }
.subtabs__inner { display: flex; gap: 4px; padding-bottom: 2px; overflow-x: auto; }
.subtab { font-size: 13.5px; font-weight: 600; color: #A9B7C8; padding: 9px 14px; text-decoration: none; display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.subtab__n { font: 400 10.5px/1 var(--mono); color: #7FA0BF; }
.subtab.is-active { color: var(--navy); background: var(--surface); border-radius: 8px 8px 0 0; font-weight: 700; }
.subtab.is-active .subtab__n { color: var(--blue); }
.subtab.is-hot .subtab__n { color: var(--navy); background: var(--teal); border-radius: var(--radius-pill); padding: 0 7px; font-weight: 700; }
/* Zero-count sub-tabs are present but unclickable — honest, not hidden. */
.subtab.is-empty { color: #4A6784; font-weight: 500; cursor: default; }

/* ---------- Phase stepper ----------
   Four phases, each saying what it produced rather than merely
   that it finished. */
.phases { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.phase { display: flex; flex-direction: column; gap: 7px; }
.phase__bar { height: 6px; border-radius: var(--radius-pill); background: var(--grey-100); }
.phase--done .phase__bar { background: var(--success); }
.phase--here .phase__bar { background: linear-gradient(90deg, var(--blue) 55%, var(--grey-200) 55%); }
.phase__head { display: flex; align-items: baseline; gap: 7px; }
.phase__name { font-size: 13px; font-weight: 700; color: var(--text-muted); }
.phase--done .phase__name { color: var(--prov-human-ink); }
.phase--done .phase__name::before { content: "\2713\00a0"; }
.phase--here .phase__name { color: var(--indigo-600); font-weight: 800; }
.phase--here .phase__name::before { content: "\25CF\00a0"; }
.phase__steps { font: 400 10.5px/1 var(--mono); color: var(--text-3); }
.phase--here .phase__steps { color: var(--indigo-600); }
.phase__made { font-size: 12px; color: var(--text-3); }
.phase--here .phase__made { color: var(--text-2); font-weight: 500; }

/* ---------- Action queue ----------
   The primary object is a decision waiting for one person,
   sorted by what goes wrong if it is ignored. Bands are
   headings, not colours, so the rows underneath stay calm. */
.queue { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl); overflow: hidden; }
.queue__head { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.queue__head h2 { margin: 0; font-size: 15.5px; font-weight: 700; }
.queue__sort { font: 400 10.5px/1 var(--mono); color: var(--text-3); }
.queue__band { padding: 9px 18px 8px; background: var(--grey-50); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.queue__band-name { font: 700 10px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--text-2); }
.queue__band-say { font-size: 12.5px; color: var(--text-3); }
.queue__band--overdue { background: #FFF5F6; border-bottom-color: #FADCE0; }
.queue__band--overdue .queue__band-name { color: var(--danger-ink); }
.queue__band--overdue .queue__band-name::before { content: "\25B2\00a0"; }
.queue__band--overdue .queue__band-say { color: #8A2F3A; }
.qrow { display: flex; align-items: flex-start; gap: 14px; padding: 16px 18px; border-bottom: 1px solid var(--grey-50); }
.qrow__main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.qrow__title { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.qrow__title a { font-size: 15.5px; font-weight: 700; color: var(--text); }
.qrow__where { font-size: 13.5px; color: var(--text-3); }
.qrow__where .mono { font-size: 12px; }
/* The third line is always the honest caveat — "nothing is
   emailed until you send" does more for trust than any badge. */
.qrow__say { font-size: 13px; color: var(--text-2); }
.qrow__acts { display: flex; flex-direction: column; gap: 7px; flex: none; align-items: stretch; }
.qrow__acts .btn { text-align: center; justify-content: center; }
.queue__more { padding: 13px 18px; display: flex; align-items: center; justify-content: center; }

/* Filter tiles: a count is a way in, not an answer. */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 15px 17px; display: flex; flex-direction: column; gap: 6px; text-decoration: none; }
.tile__top { display: flex; align-items: center; gap: 8px; }
.tile__name { font-size: 12.5px; font-weight: 700; color: var(--text-2); }
.tile__n { font-size: 30px; font-weight: 800; letter-spacing: -.03em; line-height: 1; color: var(--text-2); }
.tile__sub { font: 400 10.5px/1.3 var(--mono); color: var(--text-3); }
.tile.is-active { border: 1.5px solid var(--blue); box-shadow: 0 2px 10px -4px rgba(34,102,255,.35); }
.tile.is-active .tile__name { color: var(--indigo-600); }
.tile.is-active .tile__n { color: var(--text); }

/* Agent activity rail. */
.agent-rail { background: var(--navy); border-radius: var(--radius-xl); overflow: hidden; }
.agent-rail__head { padding: 13px 16px; display: flex; align-items: center; gap: 9px; border-bottom: 1px solid rgba(255,255,255,.1); }
.agent-rail__head span:nth-child(2) { color: #fff; font-size: 14px; font-weight: 700; }
.agent-rail__poll { margin-left: auto; font: 400 9.5px/1 var(--mono); color: #7FA0BF; }
.agent-rail__body { padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.agent-rail__job { display: flex; flex-direction: column; gap: 7px; }
.agent-rail__what { font-size: 12.5px; color: #A9B7C8; }
.agent-rail__what strong { color: #fff; font-weight: 600; }
.agent-rail__say { margin: 0; font-size: 11.5px; line-height: 1.5; color: #7FA0BF; }
.agent-rail__hr { height: 1px; background: rgba(255,255,255,.1); }

/* ---------- Reading mode ----------
   Dark earns its keep in exactly one place: the specification
   reader, where a department head spends forty minutes at 9pm.
   A per-screen preference, not an app-wide theme — inverting the
   dashboard would cost weeks and buy nothing. */
.reader--dark { background: #0A2136; color: #DCE6F0; }
.reader--dark .prov__body { color: #DCE6F0; }
.reader--dark .prov--human { border-color: var(--success); }
.reader--dark .prov--human .prov__tag { color: #3FDCAE; }
.reader--dark .prov--ai { background: rgba(5,216,221,.07); }
.reader--dark .prov--ai .prov__tag { color: var(--teal); }
.reader--dark .prov--assume { background: rgba(255,176,32,.08); }
.reader--dark .prov--assume .prov__tag { color: #FFC85C; }
.reader--dark .prov__meta, .reader--dark .prov__note { color: #7FA0BF; }
.reader--dark h1, .reader--dark h2, .reader--dark h3 { color: #fff; }
.reader--dark .spec-doc, .reader--dark .spec-doc p, .reader--dark .spec-doc li { color: #DCE6F0; }
.reader--dark .spec-doc code { background: rgba(255,255,255,.08); color: #B0F8FF; }
.read-toggle { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); border-radius: var(--radius-pill); padding: 5px 11px; font-size: 12.5px; color: var(--text-2); text-decoration: none; }
.reader--dark .read-toggle { border-color: rgba(255,255,255,.18); color: #D3DDEA; }
.read-toggle__sw { width: 26px; height: 14px; border-radius: var(--radius-pill); background: var(--grey-200); position: relative; display: block; }
.read-toggle__sw::after { content: ""; position: absolute; top: 2px; left: 2px; width: 10px; height: 10px; border-radius: var(--radius-pill); background: #fff; }
.reader--dark .read-toggle__sw { background: var(--teal); }
.reader--dark .read-toggle__sw::after { left: auto; right: 2px; background: var(--navy); }

/* ---------- Responsive ----------
   PMs are on desktops and always will be; contributors are on
   phones. The phone case is therefore the contributor's screens
   done properly, and a workspace that stays usable rather than
   pretty. */

/* Tablet — sidebar collapses to the 60px rail reading mode already uses. */
@media (max-width: 1120px) {
  .app { grid-template-columns: 74px 1fr; }
  .sidebar { padding: 18px 8px; align-items: center; }
  .sidebar .nav-group-label, .sidebar .brand-sub, .sidebar .logo-text { display: none; }
  .nav-item, aside.sidebar a { justify-content: center; padding: 10px 6px; font-size: 11px; text-align: center; }
  .nav-count { margin-left: 0; }
  .rooms { grid-template-columns: repeat(2, 1fr); }
  .phases { grid-template-columns: repeat(2, 1fr); }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .dash-grid, .queue-layout { grid-template-columns: 1fr !important; }
  .ownership { flex-direction: column; }
  .ownership__aside { width: auto; border-left: none; border-top: 1px solid var(--border); }
}

/* Phone — sidebar becomes a navy top bar, nav in a <details>
   drawer, no JS. Tables reflow to the one list row — which is
   the whole reason there is only one row shape. */
@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: static; height: auto; flex-direction: row; flex-wrap: wrap;
    align-items: center; padding: 12px 14px; gap: 10px;
  }
  .sidebar .nav-group-label { display: none; }
  .nav-item, aside.sidebar a { width: auto; padding: 7px 11px; font-size: 12.5px; border-radius: var(--radius-pill); }
  .page { padding: 16px 14px 48px; }
  .topbar { padding: 0 14px; }
  .rooms, .phases, .tiles { grid-template-columns: 1fr; }
  .rooms { padding: 12px 14px 0; }
  .subtabs { padding: 0 14px; }
  .gate thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .gate tr { display: block; border-bottom: 1px solid var(--border); padding: 12px 4px; }
  .gate td { display: block; border: none; padding: 4px 16px; }
  .gate td::before { content: attr(data-label); display: block; font: 700 9.5px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--text-3); margin-bottom: 3px; }
  .qrow { flex-wrap: wrap; }
  .qrow__acts { flex-direction: row; width: 100%; }
  .qrow__acts .btn { flex: 1; }
  /* 48px minimum targets for a thumb on a phone. */
  .contrib .btn, .contrib button[type=submit] { min-height: 48px; }
  .prov__body { font-size: 15.5px; }
}

/* ---------- Contributor ----------
   A compliance officer opens an email link between meetings. No
   sidebar, no tabs, no breadcrumbs — one job per screen. */
.contrib { min-height: 100vh; background: var(--grey-50); display: flex; flex-direction: column; }
.contrib__head { background: var(--navy); padding: 16px 20px 18px; display: flex; flex-direction: column; gap: 10px; }
.contrib__brand { display: flex; align-items: center; gap: 7px; }
.contrib__who { margin-left: auto; font: 400 9.5px/1 var(--mono); color: #7FA0BF; }
.contrib__ask { margin: 0; font-size: 14px; line-height: 1.5; color: #D3DDEA; }
.contrib__ask strong { color: #fff; }
.contrib__body { padding: 18px 20px; display: flex; flex-direction: column; gap: 16px; flex: 1; width: 100%; max-width: 640px; margin: 0 auto; }
.contrib__card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 18px; display: flex; flex-direction: column; gap: 13px; }
.contrib__card h1 { margin: 0; font-size: 21px; font-weight: 800; line-height: 1.3; letter-spacing: -.015em; }
.contrib__progress { display: flex; align-items: center; gap: 7px; }
.contrib__progress span { flex: 1; height: 5px; border-radius: var(--radius-pill); background: var(--grey-200); }
.contrib__progress span.is-done { background: var(--blue); }
.contrib__progress em { flex: none; font: 400 10px/1 var(--mono); color: var(--text-3); font-style: normal; }
.contrib__fine { font: 400 10px/1.6 var(--mono); color: var(--text-3); text-align: center; }
.contrib textarea { width: 100%; min-height: 120px; resize: vertical; border: 1.5px solid var(--border); border-radius: 10px; padding: 12px; font-family: inherit; font-size: 15px; line-height: 1.55; color: var(--text); }
.contrib textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(34,102,255,.14); outline: none; }
/* You are not signing anything here — say so next to the button. */
.contrib__reassure { font-size: 12.5px; color: var(--text-3); line-height: 1.5; }
.diff { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; font: 400 12px/1.6 var(--mono); }
.diff__row { padding: 9px 11px; display: flex; gap: 8px; }
.diff__row--del { background: #FFF5F6; color: #8A2F3A; }
.diff__row--add { background: #F2FBF8; color: #0C5C46; }
.diff__row--del::before { content: "\2212"; color: var(--danger-ink); font-weight: 700; flex: none; }
.diff__row--add::before { content: "+"; color: var(--prov-human-ink); font-weight: 700; flex: none; }
