/* ============================================================================
   UAT Studio — Institutional 2026 Fintech Design System
   Pure CSS · Dark (default) & Light themes · Full LTR / Arabic RTL support
   ============================================================================ */

:root {
  --bg: #070b14;
  --bg-subtle: #0b1120;
  --surface: #0f172a;
  --surface-2: #151f36;
  --surface-3: #1c2947;
  --border: rgba(148, 163, 184, 0.16);
  --border-strong: rgba(148, 163, 184, 0.28);
  --text: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #8b9bb4;
  --accent: #38bdf8;
  --accent-strong: #0284c7;
  --accent-soft: rgba(56, 189, 248, 0.12);
  --accent-border: rgba(56, 189, 248, 0.34);

  --pass: #10b981;
  --pass-soft: rgba(16, 185, 129, 0.14);
  --fail: #f43f5e;
  --fail-soft: rgba(244, 63, 94, 0.14);
  --warn: #f59e0b;
  --warn-soft: rgba(245, 158, 11, 0.14);
  --info: #6366f1;
  --info-soft: rgba(99, 102, 241, 0.15);
  --rust501: #a855f7;
  --rust501-soft: rgba(168, 85, 247, 0.16);
  --muted-pill: rgba(148, 163, 184, 0.14);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.42);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.65);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-pill: 999px;

  --sans: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans Arabic", "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", "Fira Code", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  --topbar-h: 60px;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f4f7fb;
  --bg-subtle: #eaf0f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f7;
  --border: rgba(15, 23, 42, 0.11);
  --border-strong: rgba(15, 23, 42, 0.22);
  --text: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --accent: #0284c7;
  --accent-strong: #0369a1;
  --accent-soft: rgba(2, 132, 199, 0.1);
  --accent-border: rgba(2, 132, 199, 0.32);

  --pass: #059669;
  --pass-soft: rgba(5, 150, 105, 0.11);
  --fail: #e11d48;
  --fail-soft: rgba(225, 29, 72, 0.1);
  --warn: #d97706;
  --warn-soft: rgba(217, 119, 6, 0.12);
  --info: #4f46e5;
  --info-soft: rgba(79, 70, 229, 0.11);
  --rust501: #7e22ce;
  --rust501-soft: rgba(126, 34, 206, 0.11);
  --muted-pill: rgba(100, 116, 139, 0.12);

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 24px 56px rgba(15, 23, 42, 0.18);
  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

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

a:hover {
  text-decoration: underline;
}

code,
pre,
.mono {
  font-family: var(--mono);
}

/* Boot Loader */
.boot-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  gap: 14px;
  color: var(--text-muted);
}

.boot-spinner {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2.5px solid var(--border-strong);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ============================================================================
   App Shell & Top Navigation Bar
   ============================================================================ */

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-inline: 20px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex-shrink: 0;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.2), rgba(16, 185, 129, 0.18));
  border: 1px solid var(--accent-border);
  display: grid;
  place-items: center;
  color: var(--accent);
  font-weight: 800;
  font-size: 13px;
  font-family: var(--mono);
}

.brand-title {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.brand-sub {
  font-size: 11px;
  color: var(--text-muted);
  display: block;
  line-height: 1.1;
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-subtle);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  overflow-x: auto;
}

.nav-tab {
  appearance: none;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.nav-tab:hover {
  color: var(--text);
  background: var(--surface-2);
}

.nav-tab.active {
  color: var(--text);
  background: var(--surface);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.run-select {
  appearance: none;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 28px 6px 10px;
  font-size: 12.5px;
  font-weight: 500;
  max-width: 220px;
  cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 14px) 50%, calc(100% - 9px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}

[dir="rtl"] .run-select {
  padding: 6px 10px 6px 28px;
  background-position: 9px 50%, 14px 50%;
}

.kbd-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.kbd-btn:hover {
  border-color: var(--accent-border);
  color: var(--text);
}

.kbd {
  font-family: var(--mono);
  font-size: 10.5px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--text-secondary);
}

.icon-btn {
  appearance: none;
  background: var(--surface-2);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  height: 32px;
  padding-inline: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

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

/* Main Workspace Container */
.main-content {
  flex: 1;
  width: 100%;
  max-width: 1560px;
  margin-inline: auto;
  padding: 20px 24px 48px;
}

.main-content.story-mode {
  max-width: 100%;
  padding: 0;
}

/* ============================================================================
   Shared Primitives: Cards, Buttons, Pills, Forms, Progress Bars
   ============================================================================ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}

.card-subtle {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.section-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-sub {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--text-muted);
}

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.08s;
}

.btn:hover:not(:disabled) {
  background: var(--surface-3);
  border-color: var(--accent-border);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-sm {
  font-size: 12px;
  padding: 5px 10px;
}

.btn-xs {
  font-size: 11.5px;
  padding: 3px 8px;
}

.btn-primary {
  background: var(--accent);
  color: #04121f;
  border-color: transparent;
}

[data-theme="light"] .btn-primary {
  color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-strong);
  color: #ffffff;
  border-color: transparent;
}

.btn-pass {
  background: var(--pass-soft);
  color: var(--pass);
  border-color: color-mix(in srgb, var(--pass) 35%, transparent);
}

.btn-fail {
  background: var(--fail-soft);
  color: var(--fail);
  border-color: color-mix(in srgb, var(--fail) 35%, transparent);
}

.btn-warn {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 35%, transparent);
}

.btn-rust {
  background: var(--rust501-soft);
  color: var(--rust501);
  border-color: color-mix(in srgb, var(--rust501) 35%, transparent);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}

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

/* Status & Semantic Pills */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
  white-space: nowrap;
}

.pill-pass {
  background: var(--pass-soft);
  color: var(--pass);
  border-color: color-mix(in srgb, var(--pass) 30%, transparent);
}

.pill-fail {
  background: var(--fail-soft);
  color: var(--fail);
  border-color: color-mix(in srgb, var(--fail) 30%, transparent);
}

.pill-warn {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 30%, transparent);
}

.pill-info {
  background: var(--info-soft);
  color: var(--info);
  border-color: color-mix(in srgb, var(--info) 30%, transparent);
}

.pill-accent {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent-border);
}

.pill-rust {
  background: var(--rust501-soft);
  color: var(--rust501);
  border-color: color-mix(in srgb, var(--rust501) 32%, transparent);
}

.pill-muted {
  background: var(--muted-pill);
  color: var(--text-secondary);
  border-color: var(--border);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.dot-pass { background: var(--pass); }
.dot-fail { background: var(--fail); }
.dot-warn { background: var(--warn); }
.dot-info { background: var(--accent); }
.dot-rust { background: var(--rust501); }
.dot-muted { background: var(--text-muted); opacity: 0.45; }

/* Progress Bars */
.progress-track {
  width: 100%;
  height: 8px;
  background: var(--bg-subtle);
  border-radius: var(--radius-pill);
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-track.slim {
  height: 5px;
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--accent), var(--pass));
  transition: width 0.25s ease;
}

.progress-fill.pass { background: var(--pass); }
.progress-fill.fail { background: var(--fail); }
.progress-fill.accent { background: var(--accent); }

/* Inputs */
.input,
.textarea,
.select {
  width: 100%;
  background: var(--bg-subtle);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  font-family: var(--sans);
  font-size: 13px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus,
.textarea:focus,
.select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.textarea {
  resize: vertical;
  min-height: 86px;
}

.field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

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

/* ============================================================================
   Dashboard View
   ============================================================================ */

.dashboard-stack {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.hero-card {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: center;
}

.hero-top {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.hero-title {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.hero-meta {
  font-size: 12.5px;
  color: var(--text-muted);
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.hero-bars {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.bar-stat-head {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 6px;
  color: var(--text-secondary);
}

.verdict-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.progress-ring-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 128px;
}

.progress-ring {
  width: 112px;
  height: 112px;
  transform: rotate(-90deg);
}

.ring-bg {
  fill: none;
  stroke: var(--border-strong);
  stroke-width: 8;
}

.ring-fg {
  fill: none;
  stroke: var(--accent);
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.35s ease;
}

.ring-center {
  position: relative;
  display: grid;
  place-items: center;
}

.ring-pct {
  position: absolute;
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 800;
}

/* Live Stack Health Grid */
.portal-launch-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

.health-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 11px 13px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.health-card.ok {
  border-inline-start: 3px solid var(--pass);
}

.health-card.fail {
  border-inline-start: 3px solid var(--fail);
}

.health-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.health-name {
  font-weight: 600;
  font-size: 13px;
}

.health-url {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 17-Act Roadmap Grid */
.acts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}

.act-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 15px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.12s, box-shadow 0.15s;
}

.act-card:hover {
  border-color: var(--accent-border);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.act-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.act-num {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
}

.act-title {
  margin: 2px 0 0;
  font-size: 14.5px;
  font-weight: 700;
}

.act-subtitle {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

/* Watchlist two-column split */
.two-col-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 16px;
}

.list-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.list-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ============================================================================
   Story View — Sticky Split-Pane Learning & Testing Reader
   ============================================================================ */

.story-layout {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  min-height: calc(100vh - var(--topbar-h));
}

.story-rail {
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  background: var(--surface);
  border-inline-end: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.rail-controls {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rail-list {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rail-act {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  overflow: hidden;
}

.rail-act-head {
  width: 100%;
  appearance: none;
  background: transparent;
  color: var(--text);
  border: none;
  padding: 9px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  text-align: start;
  font-size: 12.5px;
  font-weight: 700;
}

.rail-act-head:hover {
  background: var(--surface-3);
}

.rail-steps {
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.rail-step {
  width: 100%;
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  border-radius: 6px;
  padding: 7px 8px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
  text-align: start;
  font-size: 12px;
  transition: background 0.12s, border-color 0.12s;
}

.rail-step:hover {
  background: var(--surface-2);
  color: var(--text);
}

.rail-step.active {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--text);
}

.rail-step-body {
  flex: 1;
  min-width: 0;
}

.rail-step-title {
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 3px;
}

.rail-step-meta {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  font-size: 10.5px;
  color: var(--text-muted);
}

/* Main Story Stage */
.story-stage {
  padding: 24px 32px 64px;
  max-width: 1060px;
  width: 100%;
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.prologue-banner {
  background: linear-gradient(135deg, var(--accent-soft), var(--info-soft));
  border: 1px solid var(--accent-border);
  border-inline-start: 4px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 15px 18px;
}

.epilogue-banner {
  background: linear-gradient(135deg, var(--pass-soft), var(--accent-soft));
  border: 1px solid color-mix(in srgb, var(--pass) 35%, transparent);
  border-inline-start: 4px solid var(--pass);
  border-radius: var(--radius-md);
  padding: 15px 18px;
}

.banner-eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 4px;
}

.epilogue-banner .banner-eyebrow {
  color: var(--pass);
}

.scene-header {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.scene-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.scene-title {
  margin: 0;
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.scene-meta-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.bug-callout {
  background: var(--fail-soft);
  border: 1px solid color-mix(in srgb, var(--fail) 36%, transparent);
  border-inline-start: 4px solid var(--fail);
  border-radius: var(--radius-md);
  padding: 12px 15px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rust-callout {
  background: var(--rust501-soft);
  border: 1px solid color-mix(in srgb, var(--rust501) 36%, transparent);
  border-inline-start: 4px solid var(--rust501);
  border-radius: var(--radius-md);
  padding: 11px 14px;
  font-size: 13px;
}

.narrative-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-inline-start: 3px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  font-size: 14.5px;
  line-height: 1.65;
  color: var(--text);
}

/* Deep System Learning Brief Tabs */
.tabs-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
  margin-bottom: 14px;
}

.tab-pill {
  appearance: none;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.14s, color 0.14s, border-color 0.14s;
}

.tab-pill:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.tab-pill.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent-border);
}

.brief-prose {
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--text-secondary);
  margin: 0;
}

.brief-list {
  margin: 0;
  padding-inline-start: 20px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: var(--text-secondary);
}

/* Checklist */
.checklist-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.check-row:hover {
  border-color: var(--border-strong);
}

.check-row.checked {
  background: color-mix(in srgb, var(--pass-soft) 55%, var(--surface-2));
  border-color: color-mix(in srgb, var(--pass) 32%, transparent);
}

.check-box {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--pass);
  cursor: pointer;
  flex-shrink: 0;
}

.check-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.check-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.check-label {
  font-weight: 700;
  font-size: 13.5px;
}

.check-row.checked .check-label {
  text-decoration: line-through;
  color: var(--text-muted);
}

.check-detail {
  font-size: 12.5px;
  color: var(--text-secondary);
}

.check-expected {
  font-size: 12px;
  color: var(--pass);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 9px;
  margin-top: 2px;
}

/* Technical Reference Strip */
.tech-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.code-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 11.5px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  color: var(--accent);
  cursor: pointer;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.code-chip:hover {
  border-color: var(--accent-border);
  background: var(--accent-soft);
}

/* Verdict Control Bar */
.verdict-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 14px;
}

.verdict-btn {
  appearance: none;
  background: var(--surface-2);
  color: var(--text-secondary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.14s;
}

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

.verdict-btn.active[data-verdict="NOT_STARTED"] { background: var(--muted-pill); color: var(--text); border-color: var(--text-muted); }
.verdict-btn.active[data-verdict="IN_PROGRESS"] { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.verdict-btn.active[data-verdict="PASSED"] { background: var(--pass-soft); color: var(--pass); border-color: var(--pass); }
.verdict-btn.active[data-verdict="FAILED"] { background: var(--fail-soft); color: var(--fail); border-color: var(--fail); }
.verdict-btn.active[data-verdict="BLOCKED"] { background: var(--warn-soft); color: var(--warn); border-color: var(--warn); }
.verdict-btn.active[data-verdict="RUST_501_EXPECTED"] { background: var(--rust501-soft); color: var(--rust501); border-color: var(--rust501); }
.verdict-btn.active[data-verdict="SKIPPED"] { background: var(--muted-pill); color: var(--text-muted); border-color: var(--border-strong); }

.story-nav-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* ============================================================================
   Data Lab & Code Console
   ============================================================================ */

.safety-banner {
  background: var(--warn-soft);
  border: 1px solid color-mix(in srgb, var(--warn) 38%, transparent);
  border-inline-start: 4px solid var(--warn);
  border-radius: var(--radius-md);
  padding: 14px 18px;
}

.actions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 14px;
}

.action-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.console-box {
  background: #05080f;
  color: #e2e8f0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 360px;
  overflow: auto;
}

/* ============================================================================
   Tables (Coverage Explorer, History, Comparison Diff)
   ============================================================================ */

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.data-table th {
  text-align: start;
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}

.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  color: var(--text-secondary);
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover {
  background: var(--surface-2);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.kpi-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.kpi-value {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 800;
  line-height: 1.15;
}

.kpi-label {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 3px;
}

/* ============================================================================
   Modals & Command Palette
   ============================================================================ */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(2, 6, 18, 0.72);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 56px 16px 24px;
  overflow-y: auto;
}

.modal-panel {
  width: 100%;
  max-width: 680px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-panel.wide {
  max-width: 820px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.modal-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.modal-body {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 75vh;
  overflow-y: auto;
}

.modal-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Command Palette */
.palette-input-wrap {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.palette-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 15px;
  outline: none;
}

.palette-results {
  max-height: 440px;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.palette-item {
  width: 100%;
  appearance: none;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  color: var(--text);
  text-align: start;
}

.palette-item:hover,
.palette-item.selected {
  background: var(--accent-soft);
  border-color: var(--accent-border);
}

.palette-item-title {
  font-weight: 600;
  font-size: 13px;
}

.palette-item-sub {
  font-size: 11.5px;
  color: var(--text-muted);
}

/* Toasts */
.toast-container {
  position: fixed;
  bottom: 20px;
  inset-inline-end: 20px;
  z-index: 150;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 380px;
}

.toast {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-inline-start: 4px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 11px 14px;
  box-shadow: var(--shadow-md);
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.toast.pass { border-inline-start-color: var(--pass); }
.toast.fail { border-inline-start-color: var(--fail); }
.toast.warn { border-inline-start-color: var(--warn); }

.empty-state {
  text-align: center;
  padding: 36px 20px;
  color: var(--text-muted);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
}

/* ============================================================================
   Responsive Breakpoints
   ============================================================================ */

@media (max-width: 1080px) {
  .topbar {
    height: auto;
    flex-wrap: wrap;
    padding-block: 10px;
  }

  .story-layout {
    grid-template-columns: 1fr;
  }

  .story-rail {
    position: static;
    height: auto;
    max-height: 360px;
    border-inline-end: none;
    border-bottom: 1px solid var(--border);
  }

  .story-stage {
    padding: 18px 16px 48px;
  }
}

@media (max-width: 720px) {
  .hero-card {
    grid-template-columns: 1fr;
  }

  .main-content {
    padding: 14px;
  }

  .actions-grid,
  .acts-grid,
  .two-col-grid {
    grid-template-columns: 1fr;
  }
}
