/* ============================================================
   FIVE GUYS — INVOICE AUTOMATION POC — FUTURISTIC DASHBOARD
   Deep-space cosmic theme  ·  cyan + magenta + lime accents
   ============================================================ */

:root {
  --bg-0: #04060e;
  --bg-1: #080c1e;
  --bg-2: #0c1230;
  --panel: rgba(16, 22, 48, 0.72);
  --panel-border: rgba(110, 220, 255, 0.18);
  --glass: rgba(255, 255, 255, 0.03);

  --cy: #00f0ff;
  --cy-dim: #22a5b3;
  --mg: #ff3eb7;
  --mg-dim: #a11671;
  --lm: #7cff8c;
  --lm-dim: #2f8f3c;
  --am: #ffb43e;
  --am-dim: #9c6a12;
  --rd: #ff5c6e;

  --text: #e6f0ff;
  --text-dim: #8b9ac8;
  --text-faint: #526088;

  --mono: "JetBrains Mono", "Consolas", "Menlo", monospace;
  --sans: "Inter", "Segoe UI", system-ui, sans-serif;

  --glow-cy: 0 0 14px rgba(0, 240, 255, 0.55), 0 0 32px rgba(0, 240, 255, 0.25);
  --glow-mg: 0 0 14px rgba(255, 62, 183, 0.55), 0 0 32px rgba(255, 62, 183, 0.2);
  --glow-lm: 0 0 14px rgba(124, 255, 140, 0.55);
  --glow-rd: 0 0 14px rgba(255, 92, 110, 0.55);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg-0);
  min-height: 100vh;
  /* `clip` stops horizontal page scrolling WITHOUT breaking `position: sticky`
     on descendants the way `hidden` does. */
  overflow-x: clip;
}

/* Cosmic background */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(ellipse at 15% 10%, rgba(0, 180, 255, 0.18), transparent 55%),
    radial-gradient(ellipse at 85% 85%, rgba(255, 60, 180, 0.15), transparent 55%),
    radial-gradient(ellipse at 50% 60%, rgba(80, 0, 200, 0.12), transparent 70%),
    linear-gradient(180deg, #04060e 0%, #060818 50%, #03040a 100%);
}
body::after {
  /* subtle star field */
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    radial-gradient(1px 1px at 10% 20%, #ffffff55 0%, transparent 100%),
    radial-gradient(1px 1px at 80% 10%, #ffffff55 0%, transparent 100%),
    radial-gradient(1px 1px at 40% 70%, #ffffff33 0%, transparent 100%),
    radial-gradient(1px 1px at 70% 50%, #ffffff66 0%, transparent 100%),
    radial-gradient(1px 1px at 25% 85%, #ffffff44 0%, transparent 100%),
    radial-gradient(2px 2px at 60% 30%, #ffffff33 0%, transparent 100%),
    radial-gradient(1px 1px at 95% 45%, #ffffff55 0%, transparent 100%);
  background-size: 200px 200px, 240px 240px, 300px 300px, 260px 260px,
                   220px 220px, 280px 280px, 200px 200px;
  animation: drift 120s linear infinite;
  opacity: 0.6;
}
@keyframes drift {
  to { background-position: 200px 100px, -240px 120px, 150px -150px,
                            260px -260px, -220px 110px, 280px 140px, -200px 100px; }
}

/* ---------- View switcher in topbar ---------- */
.view-switch {
  display: flex; gap: 4px;
  padding: 4px;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  background: rgba(255,255,255,0.02);
}
.view-btn {
  padding: 8px 20px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 2px;
  cursor: pointer;
  border-radius: 999px;
  transition: all 0.2s;
}
.view-btn:hover { color: var(--text); }
.view-btn.active {
  background: linear-gradient(135deg, rgba(0,240,255,0.2), rgba(255,62,183,0.15));
  color: #fff;
  box-shadow: 0 0 16px rgba(0, 240, 255, 0.35);
}

/* ---------- Header ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  backdrop-filter: blur(12px);
  background: linear-gradient(180deg, rgba(4, 6, 14, 0.72), rgba(4, 6, 14, 0));
  border-bottom: 1px solid var(--panel-border);
  position: sticky;
  top: 0;
  z-index: 40;
}
.brand {
  display: flex; align-items: center; gap: 14px;
}
/* SCIKIQ icon-style logo — small square icon, shows on the dark background
   directly (no white pill) with a soft cyan/magenta halo. */
.brand-wordmark {
  height: 42px;
  width: 42px;
  padding: 6px;
  object-fit: contain;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  box-shadow:
    0 0 0 1px rgba(0, 240, 255, 0.25),
    0 0 14px rgba(0, 240, 255, 0.3),
    0 0 28px rgba(255, 62, 183, 0.15);
  flex-shrink: 0;
  transition: box-shadow 0.3s, transform 0.3s;
}
.brand-wordmark:hover {
  box-shadow:
    0 0 0 1px rgba(0, 240, 255, 0.5),
    0 0 20px rgba(0, 240, 255, 0.55),
    0 0 36px rgba(255, 62, 183, 0.3);
  transform: scale(1.04);
}

/* Animated monogram fallback — only appears if the wordmark image can't load */
.brand-mono {
  width: 44px; height: 44px; border-radius: 11px;
  background: conic-gradient(from 0deg, var(--cy), var(--mg), var(--cy));
  animation: spin 6s linear infinite;
  position: relative;
  flex-shrink: 0;
}
.brand-mono::after {
  content: "";
  position: absolute; inset: 3px;
  border-radius: 9px;
  background: radial-gradient(circle at 30% 30%, #0b1028, #020308);
}
.brand-mono::before {
  content: "S";
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--cy);
  font-family: var(--sans);
  font-weight: 800;
  font-size: 22px;
  z-index: 1;
  text-shadow: var(--glow-cy);
}

/* Thin vertical divider between the logo and the tagline block */
.brand-divider {
  width: 1px;
  height: 36px;
  background: linear-gradient(180deg,
              transparent,
              rgba(0, 240, 255, 0.35),
              transparent);
}
@keyframes spin { to { transform: rotate(360deg); } }
.brand-title {
  font-family: var(--mono);
  letter-spacing: 2px;
  font-size: 13px;
  color: var(--text-dim);
}
.brand-name {
  font-size: 19px; font-weight: 800; margin-top: 2px;
  letter-spacing: 0.5px;
  background: linear-gradient(90deg, var(--cy), #ffffff 55%, var(--mg));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.status-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 14px;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  background: var(--glass);
  font-family: var(--mono); font-size: 12px;
  color: var(--text-dim);
}
.status-pill .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--lm); box-shadow: var(--glow-lm);
  animation: pulse 2s ease-in-out infinite;
}
.status-pill.busy .dot { background: var(--am); box-shadow: 0 0 12px rgba(255,180,62,0.8); }
.status-pill.error .dot { background: var(--rd); box-shadow: var(--glow-rd); }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* ---------- Layout ---------- */
.shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 340px;
  gap: 20px;
  padding: 20px;
  max-width: 1800px;
  margin: 0 auto;
  align-items: start;
  transition: grid-template-columns 0.32s ease;
}
/* Right column stays docked while you scroll the centre panels */
.agentlog-col {
  position: sticky;
  top: 92px;                               /* clears the sticky topbar */
  align-self: start;
  max-height: calc(100vh - 110px);
  transition: opacity 0.2s ease, transform 0.32s ease;
}
/* Narrow laptops — drop the left sidebar under the centre; log stays on the right */
@media (max-width: 1200px) {
  .shell { grid-template-columns: minmax(0, 1fr) 320px; }
  .shell > aside:first-child { grid-column: 1 / -1; order: 2; }
  .shell > section           { grid-column: 1 / 2;  order: 1; }
  .agentlog-col              { grid-column: 2 / 3;  order: 1; grid-row: 1 / 3; }
}
/* Phone / tablet portrait — single column; log moves to the bottom and unsticks */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .shell > aside:first-child,
  .shell > section,
  .agentlog-col { grid-column: 1 / -1; grid-row: auto; }
  .agentlog-col { position: static; max-height: none; }
}

/* ---------- Collapsed log ---------- */
.shell.log-collapsed { grid-template-columns: 300px minmax(0, 1fr); }
@media (max-width: 1200px) {
  .shell.log-collapsed { grid-template-columns: minmax(0, 1fr); }
  .shell.log-collapsed > aside:first-child { grid-column: 1 / -1; order: 2; }
  .shell.log-collapsed > section           { grid-column: 1 / -1; order: 1; }
}
.shell.log-collapsed .agentlog-col {
  opacity: 0;
  transform: translateX(20px);
  pointer-events: none;
  position: absolute;                 /* take it out of the grid flow */
  visibility: hidden;
}

/* Inline toggle — the "›" chevron inside the panel header */
.log-toggle {
  width: 26px; height: 26px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0;
  border: 1px solid var(--panel-border);
  background: rgba(0, 240, 255, 0.06);
  color: var(--cy);
  border-radius: 7px;
  cursor: pointer;
  font-family: var(--mono); font-size: 16px; line-height: 1;
  transition: all 0.15s;
}
.log-toggle:hover {
  background: rgba(0, 240, 255, 0.18);
  border-color: var(--cy);
  box-shadow: var(--glow-cy);
}

/* Floating edge handle — only visible when the log is collapsed */
.log-handle {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translate(100%, -50%);   /* hidden off-screen by default */
  display: flex; flex-direction: column; align-items: center;
  gap: 12px;
  padding: 18px 12px;
  border: 1px solid var(--panel-border);
  border-right: none;
  border-radius: 14px 0 0 14px;
  background: linear-gradient(180deg, rgba(8,12,30,0.92), rgba(4,6,14,0.92));
  backdrop-filter: blur(12px);
  color: var(--cy);
  cursor: pointer;
  z-index: 30;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 2px;
  transition: transform 0.32s cubic-bezier(.4,.8,.3,1),
              box-shadow 0.2s, color 0.2s;
}
.shell.log-collapsed .log-handle {
  transform: translate(0, -50%);
  box-shadow: -6px 0 22px rgba(0, 240, 255, 0.15),
              0 0 0 1px rgba(0, 240, 255, 0.25);
}
.log-handle:hover {
  color: #ffffff;
  box-shadow: -6px 0 28px rgba(0, 240, 255, 0.35),
              0 0 0 1px rgba(0, 240, 255, 0.55);
}
.log-handle-icon {
  font-size: 22px; line-height: 1;
  color: var(--cy);
  text-shadow: var(--glow-cy);
}
.log-handle-label {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  color: var(--text-dim);
  text-transform: uppercase;
}
.log-handle:hover .log-handle-label { color: var(--text); }
.log-handle-badge {
  min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 11px;
  background: var(--mg);
  color: #fff;
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--glow-mg);
  animation: pulse 2s ease-in-out infinite;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  padding: 20px;
  backdrop-filter: blur(14px);
  position: relative;
  overflow: hidden;
}
.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 18px;
  padding: 1px;
  background: linear-gradient(135deg,
              rgba(0,240,255,0.35), rgba(255,62,183,0.0) 40%,
              rgba(255,62,183,0.25));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  pointer-events: none;
}
.panel-title {
  display: flex; align-items: center; justify-content: space-between;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--panel-border);
}
.panel-title .accent {
  color: var(--cy);
  text-shadow: var(--glow-cy);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 12px 16px;
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 1px;
  color: var(--text);
  background: linear-gradient(135deg, rgba(0,240,255,0.14), rgba(0,240,255,0.03));
  border: 1px solid rgba(0,240,255,0.35);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s;
  text-transform: uppercase;
  margin-bottom: 10px;
  position: relative;
  overflow: hidden;
}
.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  background: linear-gradient(135deg, rgba(0,240,255,0.28), rgba(0,240,255,0.08));
  box-shadow: var(--glow-cy);
  border-color: var(--cy);
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn .btn-num {
  width: 22px; height: 22px; border-radius: 6px;
  background: rgba(0,240,255,0.2);
  color: var(--cy);
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.btn.primary {
  background: linear-gradient(135deg, rgba(255,62,183,0.18), rgba(0,240,255,0.12));
  border-color: rgba(255,62,183,0.45);
  font-weight: 700;
}
.btn.primary:hover:not(:disabled) {
  box-shadow: var(--glow-mg);
  border-color: var(--mg);
}
.btn.primary .btn-num { background: rgba(255,62,183,0.25); color: var(--mg); }
.btn.ghost {
  background: transparent; border-color: var(--panel-border); color: var(--text-dim);
  font-weight: 400;
}
.btn.ghost:hover:not(:disabled) { color: var(--text); border-color: var(--text-dim); }

.btn-desc {
  font-size: 11px; color: var(--text-faint); margin-top: 4px;
  text-transform: none; letter-spacing: 0; font-family: var(--sans);
  line-height: 1.3;
}

/* ---------- Provider selector ---------- */
.provider-row {
  margin: 4px 0 14px;
  padding: 12px 12px 10px;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  background: rgba(0, 240, 255, 0.04);
  position: relative;
}
.provider-row::before {
  content: "◉";
  position: absolute; top: 10px; right: 12px;
  color: var(--cy); font-size: 10px;
  text-shadow: var(--glow-cy);
  animation: pulse 2s ease-in-out infinite;
}
.provider-label {
  display: block;
  font-family: var(--mono);
  font-size: 10px; letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.provider-sel {
  width: 100%;
  padding: 8px 10px;
  background: rgba(4, 6, 14, 0.8);
  color: var(--text);
  border: 1px solid rgba(0, 240, 255, 0.3);
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 12px;
  outline: none;
  cursor: pointer;
  transition: all 0.15s;
}
.provider-sel:focus,
.provider-sel:hover {
  border-color: var(--cy);
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.35);
}
.provider-sel option {
  background: #04060e;
  color: var(--text);
}
.provider-hint {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 8px;
  line-height: 1.4;
  font-family: var(--sans);
  min-height: 28px;
}
.provider-hint.warn { color: var(--am); }
.provider-hint.ok   { color: var(--lm); }

.btn-test-conn {
  width: 100%;
  margin-top: 10px;
  padding: 8px 12px;
  border: 1px solid rgba(0, 240, 255, 0.4);
  border-radius: 8px;
  background: rgba(0, 240, 255, 0.06);
  color: var(--cy);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-test-conn:hover {
  background: rgba(0, 240, 255, 0.18);
  border-color: var(--cy);
  box-shadow: var(--glow-cy);
  color: #fff;
}

/* ---------- Sidebar stats ---------- */
.stat-grid { display: grid; gap: 8px; margin-top: 6px; }
.stat-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 10px;
  background: rgba(255,255,255,0.02);
  border-radius: 8px;
  font-size: 13px;
}
.stat-row .label { color: var(--text-dim); font-family: var(--mono); font-size: 11px; }
.stat-row .value { color: var(--text); font-weight: 600; }

/* ---------- Pipeline diagram ---------- */
.pipeline-wrap {
  padding: 8px 4px 12px;
  min-height: 220px;
}
.pipeline {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 14px;
  margin-top: 16px;
  position: relative;
}
.stage {
  position: relative;
  padding: 18px 14px;
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(8,12,30,0.6), rgba(4,6,14,0.6));
  text-align: center;
  transition: all 0.35s ease;
  overflow: hidden;
}
.stage .stage-num {
  font-family: var(--mono); font-size: 10px; color: var(--text-faint);
  letter-spacing: 2px;
}
.stage .stage-name {
  font-weight: 700; font-size: 14px; margin: 8px 0 4px;
}
.stage .stage-detail {
  font-family: var(--mono); font-size: 10px; color: var(--text-dim);
  min-height: 16px;
  letter-spacing: 0.5px;
}
.stage .stage-icon {
  width: 36px; height: 36px; margin: 0 auto 8px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,240,255,0.06);
  color: var(--text-dim);
  transition: all 0.3s;
}
.stage.pending  { opacity: 0.5; }
.stage.running {
  border-color: var(--cy);
  box-shadow: var(--glow-cy);
  background: linear-gradient(180deg, rgba(0,240,255,0.14), rgba(4,6,14,0.6));
}
.stage.running .stage-icon {
  background: rgba(0,240,255,0.25);
  color: var(--cy);
  text-shadow: var(--glow-cy);
  animation: pulse-icon 1.1s ease-in-out infinite;
}
@keyframes pulse-icon {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}
.stage.running::after {
  content: "";
  position: absolute; left: 0; bottom: 0; height: 3px;
  width: 100%;
  background: linear-gradient(90deg, var(--cy), var(--mg), var(--cy));
  background-size: 200% 100%;
  animation: flow 1.8s linear infinite;
}
@keyframes flow {
  to { background-position: -200% 0; }
}
.stage.done {
  border-color: var(--lm);
  background: linear-gradient(180deg, rgba(124,255,140,0.10), rgba(4,6,14,0.6));
}
.stage.done .stage-icon {
  background: rgba(124,255,140,0.18);
  color: var(--lm);
  text-shadow: var(--glow-lm);
}
.stage.done .stage-num { color: var(--lm); }

/* Connector arrow */
.pipeline .stage + .stage::before {
  content: "";
  position: absolute;
  left: -14px; top: 50%;
  width: 14px; height: 2px;
  background: linear-gradient(90deg, transparent, rgba(0,240,255,0.4));
}

.progress-bar {
  margin-top: 6px; height: 4px; border-radius: 3px;
  background: rgba(255,255,255,0.06);
  overflow: hidden;
}
.progress-bar > div {
  height: 100%;
  background: linear-gradient(90deg, var(--cy), var(--mg));
  transition: width 0.25s ease;
}

/* ---------- KPI row ---------- */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin-top: 14px;
}
.kpi {
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 12px 14px;
  background: rgba(255,255,255,0.02);
  position: relative;
  overflow: hidden;
}
.kpi .kpi-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-dim);
}
.kpi .kpi-value {
  font-size: 26px;
  font-weight: 700;
  margin-top: 4px;
  font-family: var(--mono);
  background: linear-gradient(135deg, var(--cy), #ffffff 70%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.kpi .kpi-sub { font-size: 11px; color: var(--text-faint); margin-top: 2px; }
.kpi.mg .kpi-value { background: linear-gradient(135deg, var(--mg), #ffffff 70%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.kpi.lm .kpi-value { background: linear-gradient(135deg, var(--lm), #ffffff 70%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.kpi.am .kpi-value { background: linear-gradient(135deg, var(--am), #ffffff 70%); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- Tabs + data panels ---------- */
.tabs {
  display: flex; gap: 6px; margin-bottom: 12px;
  border-bottom: 1px solid var(--panel-border);
}
.tab {
  padding: 10px 16px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-dim);
  border: none; background: transparent;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--cy);
  border-bottom-color: var(--cy);
  text-shadow: var(--glow-cy);
}
.tab .count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; padding: 0 6px; margin-left: 6px;
  background: rgba(0,240,255,0.15); color: var(--cy);
  font-size: 10px; border-radius: 6px; height: 16px;
}

.tab-panel { display: none; animation: fadeIn 0.3s ease; }
.tab-panel.active { display: block; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Data cards grid ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 12px;
  max-height: 480px;
  overflow-y: auto;
  padding-right: 4px;
}
.cards::-webkit-scrollbar { width: 8px; }
.cards::-webkit-scrollbar-track { background: transparent; }
.cards::-webkit-scrollbar-thumb {
  background: rgba(0,240,255,0.15);
  border-radius: 4px;
}

.card {
  padding: 14px;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  background: rgba(255,255,255,0.02);
  font-size: 13px;
  transition: all 0.2s;
  animation: slideIn 0.3s ease;
}
.card:hover {
  border-color: var(--cy);
  background: rgba(0,240,255,0.05);
}
@keyframes slideIn {
  from { opacity: 0; transform: translateX(-8px); }
  to { opacity: 1; transform: translateX(0); }
}
.card .card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.card .tag {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 1px;
  padding: 2px 8px;
  border-radius: 5px;
  background: rgba(0,240,255,0.12);
  color: var(--cy);
  text-transform: uppercase;
}
.card .tag.high { background: rgba(255,92,110,0.15); color: var(--rd); }
.card .tag.medium { background: rgba(255,180,62,0.15); color: var(--am); }
.card .tag.low { background: rgba(124,255,140,0.15); color: var(--lm); }
.card .tag.matched { background: rgba(124,255,140,0.15); color: var(--lm); }
.card .tag.exception { background: rgba(255,180,62,0.15); color: var(--am); }
.card .tag.unmatched { background: rgba(255,92,110,0.15); color: var(--rd); }
.card .card-title {
  font-weight: 600; color: var(--text);
  font-family: var(--mono); font-size: 12px;
}
.card .card-meta {
  color: var(--text-dim); font-size: 11px;
  display: flex; gap: 10px; flex-wrap: wrap;
  margin-top: 6px;
}
.card .card-meta b { color: var(--text); font-weight: 500; }
.card .amount {
  font-family: var(--mono); font-size: 13px; color: var(--cy); font-weight: 600;
}
.card .hint { color: var(--text-faint); font-size: 11px; margin-top: 8px; font-style: italic; }

/* ---------- Agent log panel ---------- */
.agentlog-col { display: flex; flex-direction: column; gap: 14px; }
.agentlog {
  flex: 1;
  display: flex; flex-direction: column;
  max-height: 720px;
}
.agent-stream {
  flex: 1;
  overflow-y: auto;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.6;
  padding: 8px 0 0;
}
.agent-stream::-webkit-scrollbar { width: 6px; }
.agent-stream::-webkit-scrollbar-thumb { background: rgba(255,62,183,0.2); border-radius: 3px; }

.log-entry {
  padding: 6px 10px;
  border-left: 2px solid rgba(0,240,255,0.3);
  margin-bottom: 4px;
  background: rgba(255,255,255,0.015);
  border-radius: 0 6px 6px 0;
  animation: slideIn 0.2s ease;
  word-break: break-word;
}
.log-entry .log-time {
  color: var(--text-faint); margin-right: 8px;
}
.log-entry .log-evt {
  color: var(--cy); font-weight: 600; margin-right: 6px;
}
.log-entry.high { border-left-color: var(--rd); background: rgba(255,92,110,0.06); }
.log-entry.medium { border-left-color: var(--am); background: rgba(255,180,62,0.05); }
.log-entry.ok { border-left-color: var(--lm); }
.log-entry.err { border-left-color: var(--rd); }
.log-entry.stage { border-left-color: var(--mg); background: rgba(255,62,183,0.05); }
.log-entry.stage .log-evt { color: var(--mg); }
.log-entry .log-data { color: var(--text-dim); }

/* Thinking dots */
.thinking {
  display: inline-flex; gap: 4px; padding: 4px 8px;
}
.thinking span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--cy);
  box-shadow: var(--glow-cy);
  animation: thinking 1.1s ease-in-out infinite;
}
.thinking span:nth-child(2) { animation-delay: 0.15s; }
.thinking span:nth-child(3) { animation-delay: 0.3s; }
@keyframes thinking {
  0%, 100% { opacity: 0.25; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.2); }
}

/* ---------- Welcome splash ---------- */
.welcome {
  text-align: center; padding: 80px 20px 40px;
  color: var(--text-dim);
}
.welcome h2 {
  font-size: 28px;
  background: linear-gradient(90deg, var(--cy), var(--mg));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 700;
  letter-spacing: 1px;
}

/* ---------- Misc ---------- */
.divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--panel-border), transparent);
  margin: 14px 0;
}

.download-row {
  display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px;
}
.download-row a {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  text-decoration: none;
  transition: all 0.2s;
}
.download-row a:hover {
  border-color: var(--cy);
  color: var(--cy);
  box-shadow: var(--glow-cy);
}

/* ---------- Enhanced planned-issue cards ---------- */
.planned-card {
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all 0.2s;
}
.planned-card::before {
  content: "";
  position: absolute; top: 0; left: 0;
  width: 3px; height: 100%;
  background: linear-gradient(180deg, var(--cy), var(--mg));
  opacity: 0.55;
  transition: opacity 0.2s;
}
.planned-card:hover {
  border-color: var(--mg);
  background: rgba(255, 62, 183, 0.06);
  transform: translateY(-1px);
}
.planned-card:hover::before { opacity: 1; }
.issue-icon {
  font-size: 16px;
  margin-right: 6px;
  filter: drop-shadow(0 0 6px rgba(0, 240, 255, 0.45));
}
.planned-cta {
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 1.5px;
  color: var(--text-faint);
  text-transform: uppercase;
  transition: color 0.2s;
}
.planned-card:hover .planned-cta {
  color: var(--mg);
}

/* ---------- Issue drill-down modal ---------- */
.modal-wide {
  max-width: 1180px !important;
  width: 96% !important;
  padding: 0 !important;
  max-height: 92vh !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
}
/* Keep the close button in view while the body scrolls underneath */
.modal-wide .close {
  position: sticky !important;
  top: 12px !important;
  right: 16px !important;
  float: right;
  z-index: 5;
  background: rgba(4, 6, 14, 0.72);
  backdrop-filter: blur(8px);
  border-radius: 8px;
  padding: 2px 8px;
  width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
}
.modal-wide #issueModalBody { padding: 6px 26px 28px; }

.modal-loading {
  padding: 80px 40px;
  text-align: center;
  color: var(--text-dim);
  font-family: var(--mono);
}

.issue-hero {
  display: flex; gap: 18px; align-items: flex-start;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--panel-border);
  margin-bottom: 22px;
}
.issue-hero-icon {
  font-size: 42px;
  width: 68px; height: 68px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(0,240,255,0.15), rgba(255,62,183,0.12));
  border: 1px solid rgba(0,240,255,0.4);
  box-shadow: 0 0 18px rgba(0, 240, 255, 0.18);
  flex-shrink: 0;
}
.issue-eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--mg);
  margin-bottom: 4px;
}
.issue-title {
  font-size: 26px;
  margin: 4px 0 8px;
  color: #fff;
  letter-spacing: -0.2px;
}
.issue-desc {
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.5;
  margin: 0 0 6px;
}
.issue-tag {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-faint);
  margin: 0;
}
.issue-tag b { color: var(--cy); }

.issue-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
}
@media (max-width: 900px) {
  .issue-grid { grid-template-columns: 1fr; }
}

.issue-col > * + * { margin-top: 16px; }

.issue-section-title {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 2.5px;
  color: var(--cy);
  text-shadow: var(--glow-cy);
  text-transform: uppercase;
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px dashed rgba(0, 240, 255, 0.2);
}

.issue-invoice {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 16px;
  padding: 12px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
}
@media (max-width: 1000px) {
  .issue-invoice { grid-template-columns: 1fr; }
}
.issue-invoice-img {
  width: 100%;
  height: auto;
  max-height: 250px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  cursor: zoom-in;
}
.issue-invoice-meta { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.issue-invoice-meta > div {
  display: flex; justify-content: space-between;
  padding: 5px 0;
  border-bottom: 1px dashed rgba(255,255,255,0.04);
}
.issue-invoice-meta > div:last-child { border-bottom: none; }
.issue-invoice-meta span { color: var(--text-dim); font-family: var(--mono); font-size: 11px; }
.issue-invoice-meta b { color: var(--text); font-weight: 500; }
.issue-invoice-meta .hl b { color: var(--cy); font-weight: 700; font-family: var(--mono); }
.issue-invoice-meta .hl { border-top: 1px solid var(--panel-border); padding-top: 8px !important; margin-top: 3px; }

.evidence-card {
  padding: 14px;
  background: rgba(255, 62, 183, 0.04);
  border: 1px solid rgba(255, 62, 183, 0.28);
  border-radius: 12px;
}

/* ---------- AI summary panel ---------- */
.ai-summary {
  position: relative;
  padding: 14px 16px;
  border-radius: 12px;
  background:
    linear-gradient(135deg, rgba(0,240,255,0.06), rgba(255,62,183,0.04));
  border: 1px solid rgba(0, 240, 255, 0.25);
  overflow: hidden;
}
.ai-summary::before {
  /* animated gradient border */
  content: "";
  position: absolute; inset: 0;
  border-radius: 12px;
  padding: 1px;
  background: linear-gradient(120deg,
              rgba(0,240,255,0.7), rgba(255,62,183,0.7),
              rgba(124,255,140,0.6), rgba(0,240,255,0.7));
  background-size: 300% 300%;
  animation: aiBorder 5s ease infinite;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  pointer-events: none;
  opacity: 0.9;
}
@keyframes aiBorder {
  0%, 100% { background-position: 0% 50%; }
  50%      { background-position: 100% 50%; }
}
.ai-summary-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px dashed rgba(0, 240, 255, 0.22);
}
.ai-tag {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--cy);
  text-shadow: var(--glow-cy);
  font-weight: 700;
}
.ai-status {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  display: inline-flex; align-items: center; gap: 6px;
}
.ai-status.err { color: var(--rd); }
.ai-provider {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--text-faint);
  padding: 2px 8px;
  border: 1px solid rgba(0, 240, 255, 0.2);
  border-radius: 6px;
  background: rgba(0, 240, 255, 0.05);
}
.ai-cached {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--lm);
  padding: 2px 8px;
  margin-right: 6px;
  border: 1px solid rgba(124, 255, 140, 0.35);
  border-radius: 6px;
  background: rgba(124, 255, 140, 0.08);
  cursor: help;
}
.ai-summary-body {
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.6;
}
.ai-summary-body p { margin: 6px 0; color: var(--text-dim); }
.ai-summary-body b  { color: var(--text); font-weight: 600; }
.ai-bullets {
  margin: 0;
  padding: 0;
  list-style: none;
}
.ai-bullets li {
  padding: 8px 0 8px 28px;
  position: relative;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.04);
  color: var(--text-dim);
}
.ai-bullets li:last-child { border-bottom: none; }
.ai-bullets li::before {
  content: "◆";
  position: absolute;
  left: 8px;
  top: 8px;
  color: var(--cy);
  font-size: 10px;
  text-shadow: var(--glow-cy);
}
.ai-bullets li b { color: var(--text); font-weight: 600; }
.ev-row {
  display: flex; justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px dashed rgba(255,255,255,0.05);
  font-size: 13px;
}
.ev-row:last-child { border-bottom: none; }
.ev-k { color: var(--text-dim); font-family: var(--sans); }
.ev-v {
  color: var(--text);
  font-family: var(--mono);
  font-weight: 500;
  text-align: right;
}
.ev-v.mono { font-family: var(--mono); }

.issue-subtable { margin-top: 12px; }
.issue-subtable-title {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 1.5px;
  color: var(--text-faint);
  text-transform: uppercase;
  margin-bottom: 6px;
}
.issue-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  font-family: var(--mono);
}
.issue-table th {
  text-align: left;
  padding: 6px 8px;
  background: rgba(0, 240, 255, 0.08);
  color: var(--cy);
  font-size: 10px;
  letter-spacing: 1.5px;
  font-weight: 700;
  text-transform: uppercase;
}
.issue-table td {
  padding: 6px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  color: var(--text-dim);
}
.issue-table td.num { text-align: right; color: var(--text); }
.issue-table td.mono { font-size: 11px; }
.issue-table tr:last-child td { border-bottom: none; }

/* Exception meta strip under the title */
.exc-meta {
  display: flex; gap: 20px; flex-wrap: wrap;
  margin-top: 12px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-faint);
}
.exc-meta span { white-space: nowrap; }
.exc-meta b {
  color: var(--text-dim);
  font-weight: 600;
  margin-right: 4px;
  letter-spacing: 1px;
}
.exception-card { cursor: pointer; }
.exception-card::before {
  content: "";
  position: absolute; top: 0; left: 0;
  width: 3px; height: 100%;
  background: linear-gradient(180deg, var(--rd), var(--am));
  opacity: 0.6; transition: opacity 0.2s;
}
.exception-card:hover { border-color: var(--rd); }
.exception-card:hover::before { opacity: 1; }
.exception-card:hover .planned-cta { color: var(--rd); }
.reconciliation-card { cursor: pointer; }
.reconciliation-card::before {
  content: "";
  position: absolute; top: 0; left: 0;
  width: 3px; height: 100%;
  background: linear-gradient(180deg, var(--cy), var(--lm));
  opacity: 0.6; transition: opacity 0.2s;
}
.reconciliation-card:hover { border-color: var(--cy); }
.reconciliation-card:hover::before { opacity: 1; }

/* ---------- Reconciliation modal: KPI strip + totals + xref table ---------- */
.rx-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 8px;
  margin: 16px 0;
}
.rx-kpi {
  padding: 10px 12px;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  background: rgba(255,255,255,0.02);
  text-align: center;
}
.rx-kpi .rx-v {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}
.rx-kpi .rx-l {
  font-size: 10px;
  color: var(--text-dim);
  font-family: var(--mono);
  letter-spacing: 1px;
  margin-top: 2px;
}
.rx-kpi.ok {
  background: rgba(124,255,140,0.08);
  border-color: rgba(124,255,140,0.35);
}
.rx-kpi.ok .rx-v { color: var(--lm); }
.rx-kpi.warn {
  background: rgba(255,180,62,0.08);
  border-color: rgba(255,180,62,0.35);
}
.rx-kpi.warn .rx-v { color: var(--am); }
.rx-kpi.bad {
  background: rgba(255,92,110,0.08);
  border-color: rgba(255,92,110,0.35);
}
.rx-kpi.bad .rx-v { color: var(--rd); }

.rx-totals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.rx-totals > div {
  padding: 10px 14px;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  background: rgba(0,240,255,0.03);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.rx-lbl {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  text-transform: uppercase;
}
.rx-tot {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.rx-table { font-size: 12px; }
.rx-table thead th {
  position: sticky; top: 0;
  background: rgba(0, 240, 255, 0.14);
}
.rx-row-flag td {
  background: rgba(255, 62, 183, 0.05);
}
.rx-ok {
  color: var(--lm);
  font-weight: 700;
  font-family: var(--mono);
}
.rx-err {
  color: var(--rd);
  font-weight: 700;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 1px;
}
.rx-warn {
  color: var(--am);
  font-weight: 700;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 1px;
}

/* ---------- Test Connection modal ---------- */
.btn-rerun {
  flex-shrink: 0;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: var(--glass);
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 1.5px;
  cursor: pointer;
  transition: all 0.15s;
  height: fit-content;
  align-self: center;
}
.btn-rerun:hover {
  color: var(--cy);
  border-color: var(--cy);
  box-shadow: var(--glow-cy);
}

.test-banner {
  padding: 10px 14px;
  border-radius: 10px;
  margin-bottom: 14px;
  font-family: var(--mono);
  font-size: 13px;
}
.test-banner.ok {
  background: rgba(124, 255, 140, 0.08);
  border: 1px solid rgba(124, 255, 140, 0.4);
  color: var(--lm);
}
.test-banner.err {
  background: rgba(255, 92, 110, 0.08);
  border: 1px solid rgba(255, 92, 110, 0.4);
  color: var(--rd);
}
.test-banner b { color: inherit; font-weight: 700; letter-spacing: 1px; }

.test-checks {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.test-step {
  display: flex;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.02);
}
.test-step.ok      { border-color: rgba(124, 255, 140, 0.35); background: rgba(124, 255, 140, 0.04); }
.test-step.err     { border-color: rgba(255, 92, 110, 0.4);  background: rgba(255, 92, 110, 0.04); }
.test-step.running { border-color: rgba(0, 240, 255, 0.4);   background: rgba(0, 240, 255, 0.04); }

.test-step-icon {
  font-size: 20px;
  font-weight: 700;
  font-family: var(--mono);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.test-step.ok  .test-step-icon { color: var(--lm); text-shadow: var(--glow-lm); }
.test-step.err .test-step-icon { color: var(--rd); text-shadow: var(--glow-rd); }

.test-step-body { flex: 1; }
.test-step-name {
  font-weight: 600;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text);
}
.test-step-detail {
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.5;
  margin-top: 4px;
  font-family: var(--mono);
  word-break: break-word;
}
.test-step.err .test-step-detail { color: var(--rd); }
.test-step.ok  .test-step-detail { color: var(--text-dim); }

.test-step-meta {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(4, 6, 14, 0.5);
  border: 1px dashed rgba(255, 255, 255, 0.08);
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 4px 12px;
  font-size: 12px;
}
.test-step-meta > div {
  display: contents;
}
.test-step-meta span {
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 3px 0;
}
.test-step-meta b {
  color: var(--text);
  font-weight: 500;
  font-family: var(--mono);
  word-break: break-word;
  padding: 3px 0;
}

.test-step-hint {
  margin-top: 10px;
  padding: 10px 12px;
  background: rgba(255, 180, 62, 0.08);
  border-left: 3px solid var(--am);
  border-radius: 0 8px 8px 0;
  color: var(--text);
  font-size: 12.5px;
  line-height: 1.5;
}

/* ---------- Invoice modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(2, 4, 12, 0.85);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center; justify-content: center;
  z-index: 100;
  animation: fadeIn 0.2s ease;
}
.modal-backdrop.visible { display: flex; }
.modal {
  max-width: 880px;
  width: 92%;
  max-height: 92vh;
  overflow: auto;
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  background: var(--bg-1);
  padding: 20px;
  position: relative;
}
.modal img {
  max-width: 100%; height: auto;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
}
.modal .close {
  position: absolute; top: 12px; right: 16px;
  border: none; background: transparent;
  color: var(--text-dim); font-size: 22px;
  cursor: pointer;
}
.modal .close:hover { color: var(--cy); }

/* ============================================================
   EXPLAIN / HOW-IT-WORKS VIEW
   ============================================================ */

.explain {
  max-width: 1500px;
  margin: 0 auto;
  padding: 30px 24px 60px;
}

.explain-hero {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 24px;
  padding: 8px 0 26px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--panel-border);
}
.explain-hero-title { max-width: 900px; }
.explain-eyebrow {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 3px;
  color: var(--cy);
  text-shadow: var(--glow-cy);
  padding: 4px 12px;
  border: 1px solid rgba(0,240,255,0.3);
  border-radius: 999px;
  margin-bottom: 14px;
}
.explain-hero h1 {
  font-size: 44px;
  margin: 4px 0 12px;
  background: linear-gradient(90deg, var(--cy), #ffffff 55%, var(--mg));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  letter-spacing: -0.5px;
}
.explain-sub {
  font-size: 15px; color: var(--text-dim); line-height: 1.55;
  max-width: 780px; margin: 0;
}
.explain-controls {
  display: flex; gap: 10px;
  flex-shrink: 0;
}
.ex-btn {
  width: 48px; height: 48px;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: var(--glass);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--mono);
}
.ex-btn:hover {
  border-color: var(--cy); color: var(--cy);
  box-shadow: var(--glow-cy);
}
.ex-btn.primary {
  background: linear-gradient(135deg, rgba(255,62,183,0.25), rgba(0,240,255,0.15));
  border-color: var(--mg);
  color: #fff;
  width: 64px;
  box-shadow: var(--glow-mg);
}
.ex-btn.primary:hover {
  background: linear-gradient(135deg, rgba(255,62,183,0.45), rgba(0,240,255,0.3));
}

.explain-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
@media (max-width: 900px) {
  .explain-shell { grid-template-columns: 1fr; }
}

/* ----- Scene navigator (left rail) ----- */
.scene-nav {
  display: flex; flex-direction: column; gap: 8px;
  position: sticky;
  top: 92px;
}
.scene-step {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 14px;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  background: var(--glass);
  color: var(--text-dim);
  font-family: var(--sans);
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
  backdrop-filter: blur(8px);
}
.scene-step:hover {
  color: var(--text); border-color: rgba(0,240,255,0.3);
}
.scene-step.active {
  color: #fff;
  background: linear-gradient(135deg, rgba(0,240,255,0.2), rgba(0,240,255,0.05));
  border-color: var(--cy);
  box-shadow: 0 0 14px rgba(0,240,255,0.25);
}
.scene-step .sn-num {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 1.5px;
  color: var(--text-faint);
  padding: 4px 8px;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  min-width: 32px;
  text-align: center;
}
.scene-step.active .sn-num {
  color: var(--cy);
  border-color: var(--cy);
  text-shadow: var(--glow-cy);
}
.scene-step.done .sn-num {
  color: var(--lm);
  border-color: var(--lm);
}
.scene-step .sn-label {
  font-weight: 500;
  letter-spacing: 0.3px;
}

/* ----- Scene stage (right) ----- */
.scene-stage {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  padding: 24px;
  backdrop-filter: blur(14px);
  min-height: 560px;
  overflow: hidden;
}
.scene-stage::before {
  content: "";
  position: absolute; inset: 0;
  border-radius: 18px;
  padding: 1px;
  background: linear-gradient(135deg, rgba(0,240,255,0.35), rgba(255,62,183,0.0) 40%, rgba(255,62,183,0.25));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  pointer-events: none;
}

.scene-progress {
  position: absolute; top: 0; left: 0; right: 0;
  height: 3px; background: rgba(255,255,255,0.04);
  overflow: hidden;
}
.scene-progress > div {
  height: 100%;
  background: linear-gradient(90deg, var(--cy), var(--mg));
  width: 0%;
  transition: width 0.18s linear;
}

.scene {
  display: none;
}
.scene.active { display: block; animation: sceneIn 0.55s ease both; }
@keyframes sceneIn {
  from { opacity: 0; transform: translateY(14px); filter: blur(4px); }
  to   { opacity: 1; transform: translateY(0);    filter: blur(0); }
}

.scene-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 30px;
  align-items: center;
  padding: 14px 6px;
}
@media (max-width: 1100px) {
  .scene-grid { grid-template-columns: 1fr; }
}

.scene-art {
  width: 100%;
  border-radius: 14px;
  overflow: hidden;
}
.scene-art .art { width: 100%; height: auto; display: block; }

.scene-text .scene-kicker {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 3px;
  color: var(--mg);
  text-transform: uppercase;
  margin-bottom: 10px;
  padding: 3px 10px;
  border: 1px solid rgba(255,62,183,0.35);
  border-radius: 6px;
  background: rgba(255,62,183,0.08);
}
.scene-text h2 {
  font-size: 28px;
  margin: 6px 0 14px;
  color: #fff;
  letter-spacing: -0.3px;
  line-height: 1.2;
}
.scene-text p {
  color: var(--text-dim);
  font-size: 14.5px;
  line-height: 1.6;
  margin: 0 0 14px;
}
.scene-text p b { color: var(--text); font-weight: 600; }

.bullets {
  list-style: none;
  padding: 0; margin: 8px 0 14px;
}
.bullets li {
  padding: 7px 0;
  color: var(--text-dim);
  font-size: 13.5px;
  line-height: 1.5;
  border-left: 2px solid rgba(0,240,255,0.25);
  padding-left: 12px;
  margin-bottom: 6px;
}
.bullets li b { color: var(--text); }

.mini-tiles {
  display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px;
}
.mini-tiles .tile {
  padding: 6px 14px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--cy);
  background: rgba(0,240,255,0.04);
  letter-spacing: 1px;
}

.impact-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
  margin-top: 10px;
}
.ikpi {
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 12px;
  background: rgba(124,255,140,0.05);
}
.ikpi .iv {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 700;
  color: var(--lm);
  text-shadow: var(--glow-lm);
}
.ikpi .il {
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--mono);
  letter-spacing: 1px;
  margin-top: 2px;
}

/* ----- Scene-specific SVG animations ----- */

/* Scene 0 — growing paper stacks */
.paper-stack rect {
  transform-origin: bottom center;
  animation: stackGrow 2.4s ease-in-out infinite;
}
.paper-stack rect.p1 { animation-delay: 0.0s; }
.paper-stack rect.p2 { animation-delay: 0.4s; }
.paper-stack rect.p3 { animation-delay: 0.8s; }
@keyframes stackGrow {
  0%   { transform: translateY(20px); opacity: 0; }
  40%  { transform: translateY(0);    opacity: 1; }
  100% { transform: translateY(0);    opacity: 1; }
}
.dash-flow { animation: dashmove 1.2s linear infinite; }
@keyframes dashmove { to { stroke-dashoffset: -22; } }

/* Scene 1 — flying docs into the folder */
.fly-doc {
  animation: flyToFolder 2.4s cubic-bezier(.4,0,.3,1) infinite;
  animation-delay: var(--delay, 0s);
  transform-origin: center;
}
@keyframes flyToFolder {
  0%   { transform: translate(60px, 290px)  rotate(-15deg); opacity: 0; }
  15%  { opacity: 1; }
  80%  { transform: translate(420px, 140px) rotate(0);   opacity: 1; }
  95%  { transform: translate(440px, 160px) rotate(20deg); opacity: 0; }
  100% { opacity: 0; }
}

/* Scene 2 — scan + JSON reveal */
.reveal {
  opacity: 0;
  animation: reveal 0.5s ease forwards;
  animation-delay: var(--d, 0s);
}
@keyframes reveal {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* Scene 3 — triangle connectors */
.connect {
  stroke-dashoffset: 0;
  animation: linemove 1.8s linear infinite;
  animation-delay: var(--d, 0s);
}
@keyframes linemove { to { stroke-dashoffset: -40; } }

/* Scene 4 — exception cards fade-in (opacity only; SVG transform must be
   preserved, so we don't animate transform on these <g> nodes) */
.exc-card {
  opacity: 0;
  animation: excFade 0.5s ease forwards;
  animation-delay: var(--d, 0s);
}
@keyframes excFade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.exc-route {
  opacity: 0;
  animation: fadeInLate 0.6s ease 1s forwards;
}
@keyframes fadeInLate { to { opacity: 1; } }

/* Scene 5 — artefact cards fade in (opacity only — same SVG transform reason) */
.out-card {
  opacity: 0;
  animation: excFade 0.6s ease forwards;
  animation-delay: var(--d, 0s);
}

/* Scene 6 — lightning bolt flash */
.lightning {
  filter: drop-shadow(0 0 8px #7cff8c);
  animation: boltFlash 1.8s ease-in-out infinite;
}
@keyframes boltFlash {
  0%, 100% { filter: drop-shadow(0 0 8px #7cff8c); transform: scale(1); }
  50%      { filter: drop-shadow(0 0 24px #7cff8c); transform: scale(1.08); }
}

/* ---------- Sparkle on hero numbers ---------- */
.sparkle {
  display: inline-block;
  background: linear-gradient(135deg, var(--cy), var(--mg), var(--cy));
  background-size: 200% 200%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: sparkle 3s ease infinite;
  font-weight: 700;
}
@keyframes sparkle {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}
