/* SELS Workflow Insight — dark-mode operator console.
   Palette is inspired by premium consulting deliverables (McKinsey,
   BCG): deep navy canvas, warm off-white type, a single gold-ochre
   accent, and generous breathing room around tabular/dashboard data. */

:root {
  /* Canvas */
  --bg:            #051C2C;   /* deep navy */
  --bg-raised:    #0A2336;    /* surfaces */
  --bg-elevated:  #0E2E45;    /* cards */
  --bg-hover:     #13395A;
  --sidebar-bg:   #030F1A;

  /* Ink */
  --fg:           #F0EDE5;    /* warm off-white */
  --fg-muted:     #A7B2BF;
  --fg-dim:       #6F7D8C;

  /* Accent — single warm gold, used sparingly */
  --accent:       #C9A95C;
  --accent-soft:  rgba(201, 169, 92, 0.14);
  --accent-line:  rgba(201, 169, 92, 0.45);

  /* Secondary cool accent for "status positive" */
  --cool:         #4FB3D9;
  --cool-soft:    rgba(79, 179, 217, 0.14);

  /* Semantic */
  --danger:       #D97070;
  --danger-soft:  rgba(217, 112, 112, 0.14);
  --warn:         #E0A96D;
  --warn-soft:    rgba(224, 169, 109, 0.14);
  --success:      #7EC296;
  --success-soft: rgba(126, 194, 150, 0.14);

  /* Structure */
  --border:       rgba(240, 237, 229, 0.08);
  --border-strong: rgba(240, 237, 229, 0.16);
  --shadow:       0 1px 2px rgba(0,0,0,0.45), 0 8px 32px rgba(0,0,0,0.25);

  --radius-sm: 4px;
  --radius:    8px;
  --radius-lg: 14px;

  --font-sans:  'Inter', -apple-system, system-ui, 'Segoe UI', Roboto, sans-serif;
  --font-serif: 'Fraunces', Georgia, serif;
  --font-mono:  'JetBrains Mono', 'SF Mono', Menlo, monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  color: var(--fg);
  background: var(--bg);
  background-image:
    radial-gradient(1200px 600px at 15% -10%, rgba(79, 179, 217, 0.06), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(201, 169, 92, 0.05), transparent 60%);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--fg); }

h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 12px 0;
  color: var(--fg);
}
h1 { font-size: 30px; line-height: 1.2; }
h2 { font-size: 20px; line-height: 1.3; }
h3 { font-size: 16px; line-height: 1.4; letter-spacing: 0; }

p { margin: 0 0 12px 0; }

code, .mono {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-muted);
  background: rgba(240, 237, 229, 0.05);
  padding: 1px 6px;
  border-radius: 4px;
}

pre {
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: rgba(240, 237, 229, 0.04);
  color: var(--fg);
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow-x: auto;
  white-space: pre-wrap;
  line-height: 1.55;
}

.muted { color: var(--fg-muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }

/* Bilingual label pattern — every page title, nav link, section
   heading exposes the English primary plus a faded Korean gloss so
   the same UI reads cleanly for both audiences. Applied via the
   `bi(en, ko)` Jinja macro defined in base.html. */
.label-bi {
  display: inline-flex;
  align-items: baseline;
  gap: 0.45em;
  flex-wrap: wrap;
}
.label-bi .label-en {
  color: inherit;
}
.label-bi .label-ko {
  color: var(--fg-dim);
  font-size: 0.78em;
  font-weight: 400;
  letter-spacing: 0;
  opacity: 0.9;
}
/* Stack EN over KO when the label lives inside a large heading,
   otherwise keep inline. */
h1 .label-bi, h2 .label-bi {
  display: inline-flex;
  align-items: baseline;
  gap: 0.5em;
}
.nav-link .label-bi .label-ko {
  font-size: 0.82em;
}

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

.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

/* ---------- sidebar ---------- */

.sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 0 20px 0;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 22px 26px 22px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}
.brand-mark {
  width: 40px; height: 40px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--bg-elevated);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4),
              0 0 0 1px rgba(201, 169, 92, 0.25);
  flex-shrink: 0;
}
.brand-text .brand-name {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--fg);
}
.brand-text .brand-tag {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--fg-dim);
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 12px;
  overflow-y: auto;
}
.nav-section {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--fg-dim);
  padding: 18px 12px 6px 12px;
}
.nav-section:first-child { padding-top: 4px; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--fg-muted);
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.12s, color 0.12s;
}
.nav-link:hover { color: var(--fg); background: rgba(240, 237, 229, 0.03); }
.nav-link.active {
  color: var(--fg);
  background: var(--accent-soft);
  box-shadow: inset 2px 0 0 var(--accent);
}
/* Indented sub-nav link under a parent section like Overview. The
   faded icon + smaller font make the hierarchy visible without adding
   new UI chrome. */
.nav-link.nav-child {
  padding-left: 28px;
  font-size: 12px;
  opacity: 0.85;
}
.nav-link.nav-child .nav-icon { font-size: 10px; opacity: 0.7; }
.nav-icon {
  width: 16px; text-align: center;
  font-size: 12px;
  color: var(--accent);
  opacity: 0.9;
}
.nav-link:not(.active) .nav-icon { color: var(--fg-dim); }

.sidebar-user {
  padding: 16px 16px 0 16px;
  border-top: 1px solid var(--border);
  margin-top: 12px;
}
.sidebar-user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #8a7438);
  color: var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 14px;
}
.user-name { font-size: 13px; color: var(--fg); font-weight: 500; }
.user-role { font-size: 11px; color: var(--fg-dim); }

/* ---------- topbar / main ---------- */

.app-main {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 40px 14px 40px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,0.015) 0%, transparent 100%);
}
.topbar-name {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.topbar-tag {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--fg-dim);
  margin-top: 2px;
}
.topbar-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px var(--success-soft);
}

.content {
  flex: 1;
  padding: 32px 40px 48px 40px;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
}

.app-footer {
  padding: 18px 40px 22px 40px;
  border-top: 1px solid var(--border);
  color: var(--fg-dim);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  display: flex;
  gap: 10px;
}
.app-footer .divider { color: var(--fg-dim); opacity: 0.5; }

/* ---------------------------------------------------------- headers */

.page-header {
  margin-bottom: 28px;
  max-width: 880px;
}
.page-header-eyebrow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--accent);
  margin-bottom: 10px;
}
.page-header-sub {
  color: var(--fg-muted);
  font-size: 14.5px;
  max-width: 700px;
  line-height: 1.7;
}

/* ---------------------------------------------------------- panels */

.panel {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 20px;
}
.panel-elevated {
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
}
.panel-accent {
  border-left: 3px solid var(--accent);
}
.panel-heading {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.panel-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  color: var(--accent);
}
.panel-heading h2 { margin: 0; }

.section-sub {
  font-family: var(--font-serif);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--fg-muted);
  margin: 20px 0 10px 0;
  font-weight: 500;
}

/* ---------------------------------------------------------- buttons */

button, .button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--fg);
  font: 500 13px var(--font-sans);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
button:hover, .button:hover {
  background: var(--bg-hover);
  border-color: var(--accent-line);
  color: var(--fg);
}
button.primary, .button.primary {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
  font-weight: 600;
}
button.primary:hover, .button.primary:hover {
  background: #d9b667;
  color: var(--bg);
}
button.ghost, .button.ghost {
  background: transparent;
  color: var(--fg-muted);
}
button.secondary, .button.secondary {
  background: var(--bg-elevated);
  color: var(--fg);
}
button.danger, .button.danger {
  background: var(--danger);
  color: var(--bg);
  border-color: var(--danger);
}
.button-block { width: 100%; justify-content: center; }

form.inline { display: inline; }

/* ---------------------------------------------------------- forms */

input, select, textarea {
  background: var(--bg-raised);
  color: var(--fg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
label { color: var(--fg-muted); font-size: 12px; }

form.row { display: flex; flex-direction: column; gap: 10px; max-width: 560px; }
form.row label { display: flex; flex-direction: column; gap: 4px; }

/* ---------------------------------------------------------- pills / chips */

.pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--bg-elevated);
  color: var(--fg-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
  border: 1px solid var(--border);
}
.pill-neutral   { background: var(--bg-elevated); color: var(--fg-muted); }
.pill-accent    { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.pill-warn      { background: var(--warn-soft); color: var(--warn); border-color: rgba(224, 169, 109, 0.3); }
.pill-danger    { background: var(--danger-soft); color: var(--danger); border-color: rgba(217, 112, 112, 0.3); }
.pill-success   { background: var(--success-soft); color: var(--success); border-color: rgba(126, 194, 150, 0.3); }

.pill-band-critical { background: var(--danger-soft); color: var(--danger); }
.pill-band-high     { background: var(--warn-soft); color: var(--warn); }
.pill-band-medium   { background: var(--accent-soft); color: var(--accent); }
.pill-band-low      { background: var(--bg-elevated); color: var(--fg-muted); }

.pill-strength-strong   { background: var(--success-soft); color: var(--success); }
.pill-strength-moderate { background: var(--warn-soft); color: var(--warn); }
.pill-strength-weak     { background: var(--danger-soft); color: var(--danger); }
.pill-strength-absent   { background: var(--bg-elevated); color: var(--fg-muted); }

.pill-decision-auto_publish        { background: var(--success-soft); color: var(--success); }
.pill-decision-needs_human_review  { background: var(--warn-soft); color: var(--warn); }
.pill-decision-approved_by_human   { background: var(--success-soft); color: var(--success); }
.pill-decision-rejected_by_human   { background: var(--danger-soft); color: var(--danger); }

.chip {
  display: inline-block;
  padding: 3px 9px;
  margin: 0 4px 4px 0;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--fg-muted);
  font-size: 12px;
  border: 1px solid var(--border);
}
.chip-accent { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.chip-ghost  { background: transparent; border-style: dashed; }

/* ---------------------------------------------------------- tables */

table.data {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-elevated);
  border-radius: var(--radius);
  overflow: hidden;
}
table.data th, table.data td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
table.data th {
  background: rgba(255, 255, 255, 0.02);
  font-weight: 600;
  color: var(--fg-dim);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
table.data tbody tr:hover { background: var(--bg-hover); }
table.data tbody tr:last-child td { border-bottom: none; }

.queue-title-link {
  color: var(--fg);
  font-weight: 500;
  border-bottom: 1px dashed var(--accent-line);
}
.queue-title-link:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* --------------------------------------------------------- detail-grid */

.detail-grid {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 10px 22px;
  margin: 0;
}
.detail-grid dt {
  color: var(--fg-dim);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding-top: 3px;
}
.detail-grid dd { margin: 0; color: var(--fg); }

/* ---------------------------------------------------------- KPIs */

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.kpi-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}
.kpi-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent);
  opacity: 0.8;
}
.kpi-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--fg-dim);
  margin-bottom: 10px;
}
.kpi-value {
  font-family: var(--font-serif);
  font-size: 30px;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 6px;
  line-height: 1;
}
.kpi-unit { font-size: 14px; color: var(--fg-muted); margin-left: 3px; }
.kpi-hint { font-size: 12px; color: var(--fg-muted); line-height: 1.5; }

/* Legacy KPI grid (admin overview) — keep working */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.kpi {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.kpi .label { color: var(--fg-dim); font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; }
.kpi .value { font-family: var(--font-serif); font-size: 26px; margin-top: 6px; }

/* ---------------------------------------------------------- review hero */

.review-hero {
  background: linear-gradient(135deg, var(--bg-elevated) 0%, var(--bg-raised) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 40px;
  margin-bottom: 28px;
  position: relative;
  overflow: hidden;
}
.review-hero::after {
  content: "";
  position: absolute;
  top: -80px; right: -80px;
  width: 260px; height: 260px;
  background: radial-gradient(circle, var(--accent-soft), transparent 70%);
  pointer-events: none;
}
.review-hero-eyebrow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.28em;
  color: var(--accent);
  margin-bottom: 16px;
}
.review-hero-title {
  font-size: 34px;
  margin-bottom: 12px;
}
.review-hero-sub {
  color: var(--fg-muted);
  font-size: 15px;
  max-width: 720px;
  line-height: 1.7;
}
.review-hero-sub-primary {
  color: var(--fg);
  display: block;
}
.review-hero-sub-ko {
  color: var(--fg-muted);
  display: block;
  font-size: 13px;
  margin-top: 6px;
}
.review-hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
  margin-top: 22px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
}
.review-hero-meta > div { display: flex; flex-direction: column; gap: 3px; }
.meta-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--fg-dim);
}
.meta-value { color: var(--fg); font-size: 13.5px; }

/* ---------------------------------------------------------- review grid */

.review-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}
@media (max-width: 1100px) {
  .review-grid { grid-template-columns: 1fr; }
}

.callout {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 14px;
}
.callout strong {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--accent);
  margin-bottom: 6px;
}
.callout p { margin: 0; color: var(--fg); line-height: 1.7; }
.callout.callout-accent { border-left-color: var(--accent); }
.callout.callout-warn   { border-left-color: var(--warn); }
.callout.callout-warn strong { color: var(--warn); }

.insight-list {
  margin: 0;
  padding: 0 0 0 18px;
  color: var(--fg);
}
.insight-list li {
  margin-bottom: 8px;
  line-height: 1.65;
}
.insight-list li::marker { color: var(--accent); }

.match-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.match-list li {
  padding: 12px 0;
  border-top: 1px solid var(--border);
}
.match-list li:first-child { border-top: none; padding-top: 0; }
.match-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}
.match-signals { margin-top: 4px; }

/* ---------------------------------------------------------- candidate cards */

.candidate-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}
.candidate-card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.candidate-card header {
  display: flex; justify-content: space-between; align-items: center;
  gap: 10px;
}
.candidate-card h3 {
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  color: var(--fg);
}
.candidate-summary {
  color: var(--fg-muted);
  font-size: 13px;
  margin: 0;
  line-height: 1.6;
}
.candidate-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 14px;
  font-size: 12px;
  margin: 0;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}
.candidate-meta dt {
  color: var(--fg-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 10px;
}
.candidate-meta dd { margin: 0; color: var(--fg); }

/* ---------------------------------------------------------- transcript */

.transcript-details summary {
  cursor: pointer;
  color: var(--accent);
  font-size: 13px;
  padding: 4px 0;
  list-style: none;
}
.transcript-details summary::-webkit-details-marker { display: none; }
.transcript-details summary::before {
  content: "▸ ";
  color: var(--accent);
}
.transcript-details[open] summary::before { content: "▾ "; }
.transcript-body {
  margin-top: 14px;
  max-height: 520px;
  overflow-y: auto;
}

.review-footer-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 20px;
}

/* --- Recommendation hero (headline output of the review page) --- */

.recommendation-hero {
  background:
    linear-gradient(135deg, rgba(201, 169, 92, 0.06) 0%, transparent 50%),
    var(--bg-elevated);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  margin-bottom: 22px;
  position: relative;
  overflow: hidden;
}
.recommendation-hero::before {
  content: "";
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 240px;
  background: radial-gradient(circle at 80% 30%, var(--accent-soft), transparent 70%);
  pointer-events: none;
  opacity: 0.5;
}
.recommendation-primary {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius);
  padding: 22px 26px;
  margin-bottom: 22px;
  position: relative;
}
.recommendation-primary-fallback {
  border-color: rgba(224, 169, 109, 0.35);
  background: rgba(224, 169, 109, 0.05);
}
.recommendation-label {
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
  font-weight: 600;
}
.recommendation-primary-fallback .recommendation-label { color: var(--warn); }
.recommendation-body {
  font-family: var(--font-serif);
  font-size: 19px;
  line-height: 1.55;
  color: var(--fg);
  margin: 0;
}
.recommendation-section { margin-top: 22px; }
.recommendation-section:first-of-type { margin-top: 10px; }

/* --- Business summary grid --- */

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
  padding-bottom: 20px;
  border-bottom: 1px dashed var(--border);
}
.summary-item {
  padding: 14px 16px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.summary-key {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--fg-dim);
  margin-bottom: 6px;
}
.summary-val {
  font-size: 14px;
  color: var(--fg);
}

.summary-body-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
}
@media (max-width: 860px) {
  .summary-body-grid { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------------- surveys list */

.survey-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 18px;
}
.survey-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  transition: border-color 0.15s, transform 0.15s;
}
.survey-card:hover {
  border-color: var(--accent-line);
  transform: translateY(-1px);
}
.survey-card-head { display: flex; flex-direction: column; gap: 10px; }
.survey-card-status {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-bottom: 4px;
}
.survey-card h2 {
  font-size: 18px;
  margin: 0;
}
.survey-card-desc {
  color: var(--fg-muted);
  font-size: 13.5px;
  line-height: 1.65;
  margin: 0;
}
.survey-card-meta {
  display: grid;
  grid-template-columns: auto 1fr auto 1fr;
  gap: 4px 10px;
  font-size: 12px;
  color: var(--fg-muted);
}
.survey-card-meta dt {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 10px;
  color: var(--fg-dim);
}
.survey-card-meta dd { margin: 0; color: var(--fg); }
.survey-card-actions {
  display: flex; gap: 10px; justify-content: flex-end;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--fg-muted);
  background: var(--bg-elevated);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}

/* ---------------------------------------------------------- chat */

.chat-thread {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 560px;
  min-height: 360px;
  overflow-y: auto;
  padding: 20px 24px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 14px;
  scroll-behavior: smooth;
}
.chat-turn {
  display: flex;
  flex-direction: column;
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 12px;
  line-height: 1.6;
}
.chat-turn.user {
  align-self: flex-end;
  background: var(--accent);
  color: var(--bg);
  border-bottom-right-radius: 3px;
}
.chat-turn.assistant {
  align-self: flex-start;
  background: var(--bg-raised);
  color: var(--fg);
  border: 1px solid var(--border);
  border-bottom-left-radius: 3px;
}
.chat-turn.system {
  align-self: center;
  background: transparent;
  color: var(--fg-dim);
  font-style: italic;
  font-size: 12px;
  max-width: 92%;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: 4px;
  padding: 7px 12px;
}
.chat-turn-role {
  font-size: 10px;
  color: inherit;
  opacity: 0.65;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  margin-bottom: 4px;
}
.chat-turn.user .chat-turn-role { text-align: right; }
.chat-turn-body { white-space: pre-wrap; font-size: 14px; }

.chat-composer {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--bg-raised);
  padding: 8px 8px 8px 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.chat-input-row:focus-within {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.chat-composer textarea {
  flex: 1;
  padding: 8px 0;
  border: none;
  outline: none;
  background: transparent;
  color: var(--fg);
  font: inherit;
  resize: none;
  line-height: 1.5;
  max-height: 200px;
  overflow-y: auto;
}
.chat-composer textarea::placeholder { color: var(--fg-dim); }
button.chat-send {
  flex: 0 0 auto;
  width: 38px; height: 38px;
  padding: 0;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: var(--bg);
  font-size: 15px;
  cursor: pointer;
  transition: background 0.15s;
}
button.chat-send:hover { background: #d9b667; }

.chat-submit-banner {
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
  margin-top: 18px;
  padding: 16px 18px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius);
  flex-wrap: wrap;
}
.chat-submit-banner .chat-submit-copy { flex: 1 1 280px; color: var(--fg); }
.chat-submit-banner .chat-submit-copy strong {
  display: block;
  font-family: var(--font-serif);
  font-size: 15px;
  margin-bottom: 3px;
}
button.chat-final-submit {
  padding: 10px 24px;
  font-weight: 600;
  font-size: 14px;
}

/* ---------------------------------------------------------- flash */

.flash {
  margin-bottom: 18px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
}
.flash.success {
  background: var(--success-soft);
  border-color: rgba(126, 194, 150, 0.3);
  color: var(--success);
}
.flash.error {
  background: var(--danger-soft);
  border-color: rgba(217, 112, 112, 0.3);
  color: var(--danger);
}

/* ---------------------------------------------------------- filters */

.filter-bar form {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 16px;
}
.filter-bar label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--fg-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.filter-bar input, .filter-bar select {
  min-width: 160px;
}

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

@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static; height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .sidebar-nav { flex-direction: row; overflow-x: auto; gap: 4px; }
  .nav-section { display: none; }
  .content { padding: 20px; }
  .review-hero { padding: 24px 22px; }
}

/* -----------------------------------------------------------------
   Admin edit form (used on admin_user_detail). Label-on-left,
   input-on-right; a single-column stack on narrow screens.
   ----------------------------------------------------------------- */
.form-grid { display: grid; gap: 14px; max-width: 560px; }
.form-row { display: grid; grid-template-columns: 160px 1fr; gap: 14px; align-items: center; }
.form-label {
  color: var(--fg-dim);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.01em;
}
.form-input {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--fg);
  border-radius: 6px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 14px;
  width: 100%;
}
.form-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(201, 169, 92, 0.2);
}
.form-actions { margin-top: 4px; }
@media (max-width: 720px) {
  .form-row { grid-template-columns: 1fr; }
}

/* -----------------------------------------------------------------
   Overview sub-nav: inline tabs rendered above the content area.
   ----------------------------------------------------------------- */
.subnav {
  display: flex;
  gap: 4px;
  margin: -8px 0 24px;
  padding: 4px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: fit-content;
}
.subnav a {
  padding: 7px 14px;
  border-radius: 6px;
  color: var(--fg-dim);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.1s ease, color 0.1s ease;
}
.subnav a:hover { color: var(--fg); }
.subnav a.active {
  background: var(--bg);
  color: var(--fg);
  box-shadow: 0 0 0 1px var(--border);
}

/* -----------------------------------------------------------------
   Campaign Overview cards. Large, breathable, consulting-feel.
   ----------------------------------------------------------------- */
.campaign-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 20px;
  margin-top: 12px;
}
.campaign-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: border-color 0.15s ease, transform 0.15s ease;
  text-decoration: none;
  color: var(--fg);
}
.campaign-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.campaign-card h3 {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 20px;
  line-height: 1.25;
  margin: 0;
  color: var(--fg);
}
.campaign-card .subtitle {
  color: var(--fg-dim);
  font-size: 13px;
  line-height: 1.5;
  min-height: 2.5em;
}
.campaign-card .kpis {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.campaign-card .kpi-label {
  color: var(--fg-dim);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.campaign-card .kpi-value {
  font-family: 'Fraunces', serif;
  font-size: 26px;
  font-weight: 600;
  color: var(--accent);
  line-height: 1.1;
  margin-top: 2px;
}
.campaign-card .status-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: rgba(201, 169, 92, 0.15);
  color: var(--accent);
}
.campaign-card .status-pill.closed { background: rgba(120,120,120,0.2); color: var(--fg-dim); }
.campaign-card .status-pill.draft  { background: rgba(120,120,120,0.2); color: var(--fg-dim); }

/* -----------------------------------------------------------------
   CSS-only horizontal bar chart. One row per data point; the bar
   width is set inline as `style="--bar-pct: NN%"`. No JS.
   ----------------------------------------------------------------- */
.bar-chart {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}
.bar-row {
  display: grid;
  grid-template-columns: 160px 1fr 60px;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}
.bar-row .bar-label { color: var(--fg); }
.bar-row .bar-value { color: var(--fg-dim); font-variant-numeric: tabular-nums; text-align: right; }
.bar-track {
  position: relative;
  height: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.bar-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: var(--bar-pct, 0%);
  background: linear-gradient(90deg, rgba(201,169,92,0.35), var(--accent));
  border-radius: 999px;
}
@media (max-width: 720px) {
  .bar-row { grid-template-columns: 1fr; gap: 4px; }
  .bar-row .bar-value { text-align: left; }
}

/* -----------------------------------------------------------------
   Metric row used at the top of the campaign-detail page.
   ----------------------------------------------------------------- */
.metric-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin: 16px 0 28px;
}
.metric {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
}
.metric-label {
  color: var(--fg-dim);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.metric-value {
  font-family: 'Fraunces', serif;
  font-size: 30px;
  font-weight: 600;
  color: var(--fg);
  margin-top: 4px;
  line-height: 1.1;
}
.metric-sub {
  color: var(--fg-dim);
  font-size: 12px;
  margin-top: 4px;
}

/* Top-10 automation table: denser layout than `.data` */
table.top-items { width: 100%; border-collapse: collapse; margin-top: 8px; }
table.top-items th, table.top-items td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  font-size: 13px;
  text-align: left;
}
table.top-items th {
  color: var(--fg-dim);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
table.top-items td.dept { white-space: nowrap; color: var(--fg-dim); }
table.top-items td.pri  { white-space: nowrap; color: var(--accent); font-weight: 600; }

/* ---- wiki dashboard (Phase 2 Step 1) ---- */
.kpi-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin: 1rem 0 1.5rem;
}
.kpi-card {
  flex: 1 1 180px;
  padding: 1rem 1.1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.kpi-card .value {
  font-family: var(--font-serif);
  font-size: 2rem;
  line-height: 1.1;
  color: var(--accent);
}
.kpi-card .label {
  margin-top: 0.35rem;
  color: var(--fg-muted);
  font-size: 12px;
  letter-spacing: 0.03em;
}
ul.inline-list {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
}
ul.inline-list li {
  font-size: 13px;
  color: var(--fg-muted);
}

/* ---- entity relationship graph (Phase 2 Step 4) ---- */
.entity-graph .graph-warning {
  padding: 0.5rem 0.75rem;
  background: var(--warn-soft);
  border-left: 3px solid var(--warn);
  border-radius: var(--radius-sm);
}
.entity-graph-svg {
  width: 100%;
  height: auto;
  max-height: 640px;
  display: block;
  margin: 0.75rem 0;
}
.entity-graph-svg .node-shape {
  stroke-width: 1.5;
  fill: var(--bg-elevated);
}
.entity-graph-svg .node-label {
  fill: var(--fg);
  font-size: 12px;
  font-family: var(--font-sans);
  pointer-events: none;
}
/* Node-type colouring */
.entity-graph-svg .node-process    .node-shape { stroke: var(--cool);    fill: var(--cool-soft); }
.entity-graph-svg .node-opportunity .node-shape { stroke: var(--success); fill: var(--success-soft); }
.entity-graph-svg .node-automation .node-shape { stroke: var(--accent);  fill: var(--accent-soft); }
.entity-graph-svg .node-department .node-shape { stroke: var(--fg-muted); fill: transparent; }
.entity-graph-svg .node-bottleneck .node-shape { stroke: var(--fg-dim); fill: var(--bg-elevated); }
.entity-graph-svg .node-bottleneck.sev-high   .node-shape { stroke: var(--danger); fill: var(--danger-soft); }
.entity-graph-svg .node-bottleneck.sev-medium .node-shape { stroke: var(--warn);   fill: var(--warn-soft); }
.entity-graph-svg .node-bottleneck.sev-low    .node-shape { stroke: var(--fg-dim); fill: var(--bg-elevated); }
/* Ego-graph focus node */
.entity-graph-svg .is-center .node-shape { stroke-width: 3; }
/* Interactive cursor on clickable nodes */
.entity-graph-svg .graph-node-link:hover .node-shape {
  filter: brightness(1.2);
}
/* Edge styling */
.entity-graph-svg .edge { stroke-width: 1.5; }
.entity-graph-svg .edge-has          { stroke: var(--fg-dim); }
.entity-graph-svg .edge-addressed_by { stroke: var(--accent); stroke-width: 2; }
.entity-graph-svg .edge-realised_by  { stroke: var(--accent); stroke-width: 2; }
.entity-graph-svg .edge-covers       { stroke: var(--fg-dim); stroke-dasharray: 4 4; }
.entity-graph-svg .arrow-muted  { fill: var(--fg-dim); }
.entity-graph-svg .arrow-accent { fill: var(--accent); }
/* Legend row */
.graph-legend {
  margin-top: 0.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.5rem;
}
.graph-legend .legend-swatch {
  display: inline-block;
  width: 14px;
  height: 10px;
  margin-right: 3px;
  vertical-align: middle;
  border-radius: 2px;
  border: 1px solid;
}
.graph-legend .legend-process    { background: var(--cool-soft);    border-color: var(--cool); }
.graph-legend .legend-bottleneck { background: var(--danger-soft);  border-color: var(--danger); }
.graph-legend .legend-opportunity{ background: var(--success-soft); border-color: var(--success); }
.graph-legend .legend-automation { background: var(--accent-soft);  border-color: var(--accent); }
.graph-legend .legend-severity-key { font-size: 11px; }
.graph-legend .legend-edge { color: var(--fg-dim); font-family: var(--font-mono); }

/* ---- graph depth toggle + depth-2 muting (Phase 2 Step 9) ---- */
.graph-depth-toggle {
  display: inline-flex;
  gap: 0;
  margin: 0.25rem 0 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.graph-depth-pill {
  padding: 0.25rem 0.75rem;
  font-size: 12px;
  color: var(--fg-muted);
  background: var(--bg-elevated);
  text-decoration: none;
  border-right: 1px solid var(--border);
}
.graph-depth-pill:last-child { border-right: none; }
.graph-depth-pill:hover { color: var(--fg); }
.graph-depth-pill.is-active {
  color: var(--fg);
  background: var(--border);
  font-weight: 600;
}
.entity-graph .graph-truncated-banner {
  padding: 0.4rem 0.6rem;
  background: var(--bg-elevated);
  border-left: 3px solid var(--fg-muted);
  border-radius: var(--radius-sm);
  margin: 0.25rem 0 0.5rem;
}
/* Depth-2 nodes: dashed stroke + softened opacity so the focus
   stays on depth-0/1 while 2-hop context reads clearly. */
.entity-graph-svg .depth-2 .node-shape {
  stroke-dasharray: 3 3;
  opacity: 0.8;
}
.entity-graph-svg .depth-2 .node-label {
  fill: var(--fg-muted);
}
.entity-graph-svg .edge-depth-2 {
  opacity: 0.55;
}

/* ---- filter bar (Phase 2 Step 5) ---- */
.filter-bar h3 {
  margin: 0 0 0.5rem;
  font-size: 14px;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.filter-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: flex-end;
}
.filter-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 13px;
}
.filter-field .filter-label {
  color: var(--fg-muted);
  font-size: 11px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.filter-field select {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 0.3rem 0.5rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 13px;
  min-width: 160px;
}
.filter-field-checkbox {
  flex-direction: row;
  align-items: center;
  gap: 0.4rem;
  padding-bottom: 0.35rem;
}
.filter-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding-bottom: 0.1rem;
}
.filter-actions button {
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  color: var(--accent);
  padding: 0.35rem 0.9rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 13px;
  cursor: pointer;
}
.filter-actions button:hover {
  filter: brightness(1.1);
}
.filter-clear {
  font-size: 12px;
  color: var(--fg-muted);
  text-decoration: underline;
}
.filter-active-summary {
  margin: 0.5rem 0 0;
  padding: 0.4rem 0.55rem;
  background: var(--accent-soft);
  border-left: 3px solid var(--accent-line);
  border-radius: var(--radius-sm);
}
.filter-active-summary code {
  color: var(--fg);
  font-size: 12px;
}

/* ---- export links (Phase 2 Step 6) ---- */
.filter-export {
  margin-top: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.75rem;
}
.filter-export-label {
  color: var(--fg-muted);
  font-size: 11px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.filter-export-link {
  font-size: 13px;
  font-family: var(--font-mono);
  color: var(--accent);
}
.filter-export-link:hover { text-decoration: underline; }
.filter-export-notice {
  flex-basis: 100%;
  margin: 0.35rem 0 0;
  font-size: 11px;
}

/* ---- archive view (Phase 2 Step 7) ----
   Subdued historical tone: reuse the existing muted/elevated/border
   tokens — no new colours introduced — so the page reads as a
   retrospective record, not a live operational surface. */
.archive-view {
  /* Slight global dimming so the whole page feels "set aside".
     Links / interactive elements remain full-strength via scoped
     overrides below. */
  color: var(--fg-muted);
}
.archive-view h1,
.archive-view h2,
.archive-view h3 {
  color: var(--fg);
}
.archive-title {
  font-style: italic;
}
.archive-kpi-grid .kpi-card {
  /* Dashed border + elevated bg to visually mark "not active now". */
  border-style: dashed;
  border-color: var(--border-strong);
  background: var(--bg-elevated);
}
.archive-kpi-grid .kpi-card .value {
  color: var(--fg-muted);
}
.archive-context-hint {
  display: block;
  margin: 0.75rem 0 0;
  padding: 0.55rem 0.8rem;
  background: var(--bg-elevated);
  border-left: 3px solid var(--border-strong);
  border-radius: var(--radius-sm);
}
.archive-context-hint strong { color: var(--fg); }

.archive-filter-bar {
  border-style: dashed;
  border-color: var(--border);
}
.archive-filter-bar input[type="text"],
.archive-filter-bar select {
  background: var(--bg-elevated);
  color: var(--fg);
  border: 1px solid var(--border);
  padding: 0.3rem 0.5rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 13px;
  min-width: 180px;
}

.archive-view table.archive-table tbody td { color: var(--fg-muted); }
.archive-view table.archive-table tbody td a { color: var(--fg); }
.archive-view table.archive-table .archive-description {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.archive-empty {
  padding: 0.9rem 1rem;
  background: var(--bg-elevated);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  text-align: center;
}

.archive-privacy-notice {
  margin-top: 1rem;
  padding: 0.5rem 0.75rem;
  border-top: 1px dashed var(--border);
}

/* Status pills + severity chips (reusable, scoped under archive-view
   so they don't bleed onto active surfaces). */
.archive-view .status-pill {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 99px;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-family: var(--font-mono);
  border: 1px solid var(--border-strong);
  color: var(--fg-muted);
  background: var(--bg-elevated);
}
.archive-view .sev-chip {
  display: inline-block;
  padding: 0 0.35rem;
  margin-left: 0.2rem;
  border-radius: 3px;
  font-size: 10px;
  font-family: var(--font-mono);
  border: 1px solid var(--border);
  color: var(--fg-muted);
}
.archive-view .sev-chip.sev-high   { color: var(--danger);  border-color: var(--danger); }
.archive-view .sev-chip.sev-medium { color: var(--warn);    border-color: var(--warn); }
.archive-view .sev-chip.sev-low    { color: var(--fg-dim);  border-color: var(--fg-dim); }


/* ================================================================
   Executive Summary Report (Phase 2 Step 10) — additive only.
   No existing rule is modified; all declarations scope under
   `.summary-report` or the `@media print` block.
   ================================================================ */

.summary-report {
  max-width: 960px;
  margin: 0 auto;
  padding: 0.5rem 0;
}
.summary-report h1 {
  margin: 0 0 0.25rem;
}
.summary-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.75rem;
  margin-bottom: 1rem;
}
.summary-meta {
  margin: 0.1rem 0 0.5rem;
}
.filter-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.25rem;
}
.filter-badge {
  display: inline-flex;
  gap: 0.35rem;
  align-items: baseline;
  padding: 0.15rem 0.5rem;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
}
.filter-badge-label { color: var(--fg-muted); }
.filter-badge-value {
  font-family: var(--font-mono);
  color: var(--fg);
}
.filter-badge-none { color: var(--fg-muted); font-style: italic; }

.summary-section {
  margin: 1.25rem 0;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
}
.summary-section > h2 {
  margin: 0 0 0.5rem;
  font-size: 16px;
}
.section-lede {
  margin: 0 0 0.5rem;
}
.muted-sub {
  display: block;
  color: var(--fg-dim);
  font-size: 11px;
  margin-top: 1px;
}
.section-footnote {
  margin-top: 0.6rem;
  text-align: right;
}
.section-footnote a { color: var(--fg-muted); }

.summary-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.summary-kpi-grid-compact {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}
.summary-kpi {
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
}
.summary-kpi .value {
  font-size: 22px;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--fg);
}
.summary-kpi .label {
  font-size: 11px;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-top: 2px;
}
.summary-headline {
  margin: 0.5rem 0 0;
  line-height: 1.45;
}
.summary-headline-en { display: block; color: var(--fg); }
.summary-headline-ko { display: block; color: var(--fg-dim); font-size: 12px; }
.summary-sentence { margin-top: 2px; }

.summary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.summary-table th,
.summary-table td {
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
.summary-table th {
  color: var(--fg-muted);
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.summary-table td.num,
.summary-table th.num { text-align: right; font-family: var(--font-mono); }
.chain-table td { white-space: nowrap; }
.chain-row-gap td { background: color-mix(in srgb, var(--warn-soft, #ffeaa7) 25%, transparent); }

.summary-report .sev-tag {
  display: inline-block;
  padding: 0 0.35rem;
  font-size: 10px;
  font-family: var(--font-mono);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--fg-muted);
}
.summary-report .sev-tag.sev-high   { color: var(--danger); border-color: var(--danger); }
.summary-report .sev-tag.sev-medium { color: var(--warn);   border-color: var(--warn); }
.summary-report .sev-tag.sev-low    { color: var(--fg-dim); border-color: var(--fg-dim); }
.summary-report .sev-tag.sev-unassessed { color: var(--fg-dim); }
.summary-report .kpi-cell code {
  font-family: var(--font-mono);
  color: var(--fg-muted);
}

/* ---------------- Print stylesheet ---------------- */
@media print {
  /* Force readable black-on-white regardless of the user theme. */
  body.theme-dark,
  body {
    background: #fff !important;
    color: #000 !important;
  }

  /* Drop the chrome — the summary is a document, not an app view. */
  .sidebar,
  .topbar,
  .app-footer {
    display: none !important;
  }

  /* Flatten the app shell so the content fills the printable area. */
  .app-shell,
  .app-main,
  .content {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
    color: #000 !important;
  }

  .summary-report {
    max-width: 100% !important;
    padding: 0 !important;
  }

  /* Section layout — keep each card together, keep heading with body. */
  .summary-section {
    background: #fff !important;
    border: 1px solid #999 !important;
    page-break-inside: avoid;
    break-inside: avoid;
    margin: 0.75rem 0;
  }
  .summary-section h2 {
    page-break-after: avoid;
    break-after: avoid;
    color: #000 !important;
  }

  .summary-kpi {
    background: #fff !important;
    border: 1px solid #ccc !important;
    color: #000 !important;
  }
  .summary-kpi .value,
  .summary-kpi .label,
  .summary-headline-en {
    color: #000 !important;
  }
  .summary-headline-ko,
  .muted,
  .muted-sub,
  .filter-badge-label,
  .section-footnote a {
    color: #444 !important;
  }

  /* Tables break across pages row-by-row. */
  .summary-table { page-break-inside: auto; }
  .summary-table thead { display: table-header-group; }
  .summary-table tr { page-break-inside: avoid; page-break-after: auto; }
  .summary-table th,
  .summary-table td {
    border-bottom: 1px solid #ccc !important;
    color: #000 !important;
  }

  /* Preserve anchor meaning on paper — show the destination URL
     after the link text, small and grey so the prose still flows. */
  .summary-report a[href^="/wiki/"] {
    color: #000 !important;
    text-decoration: underline;
  }
  .summary-report a[href^="/wiki/"]::after {
    content: " (" attr(href) ")";
    font-size: 0.75em;
    color: #666;
    font-family: var(--font-mono);
  }

  /* Filter badges render as black-bordered chips. */
  .filter-badge {
    background: #fff !important;
    border: 1px solid #999 !important;
    color: #000 !important;
  }
  .filter-badge-value { color: #000 !important; }

  /* Severity tags keep their semantic emphasis without using dark
     theme backgrounds. */
  .summary-report .sev-tag.sev-high   { color: #a30000 !important; border-color: #a30000 !important; }
  .summary-report .sev-tag.sev-medium { color: #8a5a00 !important; border-color: #8a5a00 !important; }
  .summary-report .sev-tag.sev-low    { color: #555 !important; border-color: #888 !important; }

  /* Action-gap chain rows keep a subtle tint so reviewers still
     notice the missing automation when reading the printed page. */
  .chain-row-gap td {
    background: #fff7d6 !important;
  }
}
