/**
 * Benchmark Portal — Central Stylesheet
 *
 * Light is the default theme. Dark is toggled via data-theme="dark" on <html>.
 * The theme toggle is injected by nav.js and persisted in localStorage.
 *
 * Variable groups:
 *   --bg / --surface / --border       Page, card, divider surfaces
 *   --text / --muted                  Typography
 *   --dim / --ph-border / --ph-text   Phase accent (teal/cyan)
 *   --auto-*                          System-automated step callouts (green)
 *   --warn-*                          Warning / info notices (amber)
 *   --cond-*                          Conditional step blocks (purple)
 *   --cc-* / --br-* / --mb-*         Role badge colours: Client Care / Broker / Managing Broker
 *   --alert-*                         Urgent alert boxes (red)
 *   --filter-bg                       Filter bar background tint
 *   --step-ref-bg                     Step reference code chip background
 */

/* ── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Light theme (default) ──────────────────────────────────────────────────── */
:root {
  --bg:         #f2f5f8;
  --surface:    #ffffff;
  --border:     #dce3ea;
  --text:       #1b2e3c;
  --muted:      #5e7b90;

  /* Phase accent — teal */
  --dim:        rgba(14,116,144,0.09);
  --ph-border:  rgba(14,116,144,0.32);
  --ph-text:    #0c7a93;

  /* Auto / green */
  --auto:       rgba(22,163,74,0.09);
  --auto-border:rgba(22,163,74,0.32);
  --auto-text:  #166534;

  /* Warning / amber */
  --warn:       rgba(217,119,6,0.09);
  --warn-border:rgba(217,119,6,0.32);
  --warn-text:  #92400e;

  /* Conditional / purple */
  --cond:       rgba(109,40,217,0.07);
  --cond-border:rgba(109,40,217,0.28);
  --cond-text:  #5b21b6;

  /* Role: Client Care — green */
  --cc-bg:      rgba(5,150,105,0.09);
  --cc-border:  rgba(5,150,105,0.32);
  --cc-text:    #065f46;

  /* Role: Broker — amber */
  --br-bg:      rgba(217,119,6,0.09);
  --br-border:  rgba(217,119,6,0.30);
  --br-text:    #92400e;

  /* Role: Managing Broker — indigo */
  --mb-bg:      rgba(79,70,229,0.09);
  --mb-border:  rgba(79,70,229,0.28);
  --mb-text:    #3730a3;

  /* Alert — red */
  --alert:      rgba(220,38,38,0.09);
  --alert-border:rgba(220,38,38,0.28);
  --alert-text: #991b1b;

  /* Misc */
  --filter-bg:  rgba(235,241,246,0.85);
  --step-ref-bg:rgba(0,0,0,0.04);
}

/* ── Dark theme ─────────────────────────────────────────────────────────────── */
[data-theme="dark"] {
  --bg:         #021a2b;
  --surface:    #082a3d;
  --border:     #0f3f5a;
  --text:       #e8edf2;
  --muted:      #7a9aaf;

  --dim:        rgba(14,116,144,0.15);
  --ph-border:  rgba(14,116,144,0.35);
  --ph-text:    #5ec8e0;

  --auto:       rgba(34,197,94,0.12);
  --auto-border:rgba(34,197,94,0.3);
  --auto-text:  #4ade80;

  --warn:       rgba(245,158,11,0.12);
  --warn-border:rgba(245,158,11,0.3);
  --warn-text:  #fbbf24;

  --cond:       rgba(139,92,246,0.1);
  --cond-border:rgba(139,92,246,0.3);
  --cond-text:  #c4b5fd;

  --cc-bg:      rgba(16,185,129,0.1);
  --cc-border:  rgba(16,185,129,0.3);
  --cc-text:    #6ee7b7;

  --br-bg:      rgba(245,158,11,0.1);
  --br-border:  rgba(245,158,11,0.25);
  --br-text:    #fcd34d;

  --mb-bg:      rgba(99,102,241,0.12);
  --mb-border:  rgba(99,102,241,0.3);
  --mb-text:    #a5b4fc;

  --alert:      rgba(239,68,68,0.1);
  --alert-border:rgba(239,68,68,0.3);
  --alert-text: #fca5a5;

  --filter-bg:  rgba(8,42,61,0.6);
  --step-ref-bg:rgba(255,255,255,0.04);
}

/* ── Base ───────────────────────────────────────────────────────────────────── */
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  min-height: 100vh;
  transition: background 0.2s, color 0.2s;
}

/* ── Page header ─────────────────────────────────────────────────────────────── */
.page-header {
  padding: 40px 48px 28px;
  border-bottom: 1px solid var(--border);
  max-width: 900px;
  margin: 0 auto;
}

.phase-crumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 16px;
  font-weight: 500;
}
.phase-crumb a { color: var(--muted); text-decoration: none; }
.phase-crumb a:hover { color: var(--text); }
.phase-crumb .sep { opacity: 0.4; }

.phase-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--dim);
  border: 1px solid var(--ph-border);
  color: var(--ph-text);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 20px;
  margin-bottom: 12px;
}

.page-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.page-subtitle {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.6;
}

/* ── Filter bar ──────────────────────────────────────────────────────────────── */
.filter-bar {
  max-width: 900px;
  margin: 0 auto;
  padding: 14px 48px;
  border-bottom: 1px solid var(--border);
  background: var(--filter-bg);
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.filter-group { display: flex; align-items: center; gap: 8px; }

.filter-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  white-space: nowrap;
}

.filter-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
  flex-shrink: 0;
}

.pill-row { display: flex; gap: 4px; flex-wrap: wrap; }

.pill {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  background: transparent;
  transition: all 0.12s;
  white-space: nowrap;
  font-family: inherit;
}
.pill:hover { border-color: var(--ph-border); color: var(--ph-text); }
.pill.active { background: var(--dim); border-color: var(--ph-border); color: var(--ph-text); }

/* ── Content layout ──────────────────────────────────────────────────────────── */
.content {
  max-width: 900px;
  margin: 0 auto;
  padding: 36px 48px 0;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.section-label {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 14px;
}

/* ── Stage flow ──────────────────────────────────────────────────────────────── */
.trigger-row { display: flex; align-items: stretch; }

.trigger-box {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 14px 16px;
}
.trigger-box.center {
  flex: 2;
  background: var(--dim);
  border-color: var(--ph-border);
  border-left: none;
  border-right: none;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.trigger-box:first-child { border-radius: 8px 0 0 8px; }
.trigger-box:last-child  { border-radius: 0 8px 8px 0; }

.trigger-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 6px;
}
.trigger-text  { font-size: 12px; color: var(--text); line-height: 1.5; }
.trigger-stage { font-size: 14px; font-weight: 700; color: var(--ph-text); }

/* ── Notice / warning box ────────────────────────────────────────────────────── */
.notice-box {
  background: var(--warn);
  border: 1px solid var(--warn-border);
  border-radius: 8px;
  padding: 14px 18px;
}
.notice-box p { font-size: 13px; color: var(--warn-text); line-height: 1.6; }
.notice-box p + p { margin-top: 8px; }

/* ── Alert box (urgent / red) ────────────────────────────────────────────────── */
.alert-box {
  background: var(--alert);
  border: 1px solid var(--alert-border);
  border-radius: 8px;
  padding: 14px 18px;
}
.alert-box p { font-size: 13px; color: var(--alert-text); line-height: 1.6; }
.alert-box p + p { margin-top: 8px; }
.alert-box strong { color: var(--alert-text); }

/* ── Steps ───────────────────────────────────────────────────────────────────── */
.steps { display: flex; flex-direction: column; gap: 10px; }

.step {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  transition: opacity 0.15s;
}
.step.hidden { display: none; }

.step-header { display: flex; gap: 12px; align-items: flex-start; }

.step-num {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--dim);
  border: 1px solid var(--ph-border);
  color: var(--ph-text);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.step-main { flex: 1; }

.step-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.step-title { font-size: 13px; font-weight: 700; color: var(--text); }
.step-desc  { font-size: 12px; color: var(--muted); line-height: 1.6; }

/* ── Role badges ─────────────────────────────────────────────────────────────── */
.role-badges { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 8px; }

.role-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  letter-spacing: 0.04em;
}
.role-uw { background: var(--dim);    border: 1px solid var(--ph-border); color: var(--ph-text); }
.role-cc { background: var(--cc-bg);  border: 1px solid var(--cc-border); color: var(--cc-text); }
.role-br { background: var(--br-bg);  border: 1px solid var(--br-border); color: var(--br-text); }
.role-mb { background: var(--mb-bg);  border: 1px solid var(--mb-border); color: var(--mb-text); }

/* ── Conditional tag ─────────────────────────────────────────────────────────── */
.cond-tag {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--cond);
  border: 1px solid var(--cond-border);
  color: var(--cond-text);
  flex-shrink: 0;
}

/* ── If / then blocks ────────────────────────────────────────────────────────── */
.if-block {
  margin-top: 10px;
  border-left: 2px solid var(--cond-border);
  border-radius: 0 6px 6px 0;
  background: var(--cond);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.if-branch {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: baseline;
  font-size: 12px;
}

.if-cond   { font-weight: 700; color: var(--cond-text); white-space: nowrap; font-size: 11px; }
.if-action { color: var(--text); line-height: 1.5; }

.if-block-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--cond-text);
  opacity: 0.7;
  margin-bottom: 2px;
}

/* ── Auto / inline note tags ─────────────────────────────────────────────────── */
.auto-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--auto);
  border: 1px solid var(--auto-border);
  color: var(--auto-text);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 4px;
  margin-top: 8px;
}

.inline-note {
  background: var(--warn);
  border: 1px solid var(--warn-border);
  border-radius: 6px;
  padding: 10px 14px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--warn-text);
  line-height: 1.5;
}
.inline-note strong { color: var(--warn-text); }

/* ── Step reference codes ────────────────────────────────────────────────────── */
.step-ref {
  font-size: 9px;
  font-weight: 700;
  font-family: 'Menlo', 'Consolas', monospace;
  background: var(--step-ref-bg);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 2px 6px;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.12s;
  flex-shrink: 0;
}
.step-ref:hover {
  color: var(--ph-text);
  border-color: var(--ph-border);
  background: var(--dim);
}

/* ── No results ──────────────────────────────────────────────────────────────── */
.no-results {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  padding: 24px 0;
  display: none;
  font-style: italic;
}

/* ── Gap list ────────────────────────────────────────────────────────────────── */
.gap-list { display: flex; flex-direction: column; gap: 6px; }

.gap-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
}

.gap-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--warn-text);
  margin-top: 5px;
  flex-shrink: 0;
}
.gap-text { font-size: 12px; color: var(--muted); line-height: 1.5; }

/* ── Funded box (D7) ─────────────────────────────────────────────────────────── */
.funded-box {
  background: var(--auto);
  border: 1px solid var(--auto-border);
  border-radius: 8px;
  padding: 16px 20px;
  margin-top: 10px;
}
.funded-box ol {
  margin: 8px 0 0 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.funded-box li { font-size: 12px; color: var(--auto-text); line-height: 1.6; }
.funded-box p  { font-size: 12px; color: var(--auto-text); line-height: 1.6; }
.funded-box strong { color: var(--auto-text); }

/* ── Page footer ─────────────────────────────────────────────────────────────── */
.page-footer {
  max-width: 900px;
  margin: 40px auto 0;
  padding: 24px 48px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.footer-meta { font-size: 11px; color: var(--muted); }

.feedback-btn {
  font-size: 11px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: var(--surface);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.12s;
}
.feedback-btn:hover { border-color: var(--ph-border); color: var(--ph-text); }

/* ── Feedback form section ───────────────────────────────────────────────────── */
.feedback-section {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 48px 60px;
}

/* ── Theme toggle button (injected by nav.js) ────────────────────────────────── */
#theme-toggle {
  background: none;
  border: 1px solid rgba(255,255,255,0.12);
  color: #8aa5b8;
  font-size: 12px;
  font-weight: 600;
  font-family: 'Inter', -apple-system, sans-serif;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
#theme-toggle:hover {
  border-color: rgba(255,255,255,0.25);
  color: #c8d8e4;
}

/* Light-mode adjustments to toggle button (nav bg is always dark) */
/* nav bg is always #021a2b regardless of theme, so toggle colours stay the same */

/* ── Responsive ──────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .page-header, .filter-bar, .content, .feedback-section, .page-footer {
    padding-left: 20px;
    padding-right: 20px;
  }
  .trigger-row { flex-direction: column; }
  .trigger-box.center {
    border: 1px solid var(--ph-border);
    border-top: none;
    border-bottom: none;
  }
  .filter-divider { display: none; }
}
