/* ── LedgerFix UI Styles ─────────────────────────────────────────── */

:root {
  --bg:        #0b0e14;
  --surface:   #13171f;
  --surface2:  #1a1f2a;
  --border:    #1e2530;
  --green:     #22c55e;
  --green-dim: #166534;
  --red:       #ef4444;
  --amber:     #f59e0b;
  --blue:      #3b82f6;
  --text:      #e2e8f0;
  --muted:     #64748b;
  --mono:      'IBM Plex Mono', 'Courier New', monospace;
  --sans:      'Inter', system-ui, sans-serif;
  --r:         8px;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.6;
}

/* ── Layout ── */
#app {
  max-width: 820px;
  margin: 0 auto;
  padding: 0 24px 64px;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 0 32px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-text {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 700;
  color: var(--green);
  letter-spacing: -0.5px;
}

.header-badge {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 20px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 28px;
  margin-bottom: 16px;
}

/* ── Drop zone ── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--r);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--green);
  background: rgba(34, 197, 94, 0.04);
}

.drop-zone p {
  color: var(--muted);
  font-size: 14px;
  margin: 8px 0 16px;
}

.drop-icon { margin-bottom: 12px; }

h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

/* ── API config ── */
.api-config {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.api-config label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.api-config input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}

.api-config input:focus { border-color: var(--green); }
.api-hint { font-size: 11px; color: var(--muted); margin-top: 6px; }

/* Key input + show/hide toggle share one row. */
.key-row { display: flex; gap: 8px; }
.key-row input { width: auto; flex: 1; min-width: 0; }

.key-toggle {
  flex-shrink: 0;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  padding: 0 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.key-toggle:hover { border-color: var(--green); color: var(--green); }

/* ── Settings ── */
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.settings-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 5px 12px;
  border-radius: 20px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.settings-btn:hover,
.settings-btn[aria-expanded="true"] { border-color: var(--green); color: var(--green); }

.settings-panel { padding: 20px 24px; }
.settings-panel.hidden { display: none; }

.settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

/* The panel already supplies spacing and the rule. */
.settings-panel .api-config {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.settings-note {
  font-size: 11px;
  line-height: 1.6;
  color: var(--muted);
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.key-status {
  flex-basis: 100%;
  font-size: 12px;
  color: var(--muted);
}
.key-status.loaded { color: var(--green); }

/* ── File preview ── */
.file-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--green);
  font-family: var(--mono);
}

.file-preview.hidden { display: none; }

/* ── Buttons ── */
#run-row {
  display: flex;
  justify-content: center;
  margin: 16px 0;
}
#run-row.hidden { display: none; }

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--green);
  color: #000;
  font-weight: 700;
  font-size: 15px;
  padding: 12px 28px;
  border: none;
  border-radius: var(--r);
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  font-family: var(--sans);
}
.btn-primary:hover { background: #16a34a; }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { background: var(--green-dim); cursor: not-allowed; }

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
  padding: 8px 18px;
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--sans);
  transition: border-color 0.2s, color 0.2s;
}
.btn-secondary:hover { border-color: var(--green); color: var(--green); }

.btn-ghost {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 2px 6px;
}
.btn-ghost:hover { color: var(--red); }

/* ── Loading ── */
#loading {
  text-align: center;
  padding: 48px;
  color: var(--muted);
}
#loading.hidden { display: none; }

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

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

/* ── Stats row ── */
.stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 20px;
  text-align: center;
}

.stat-card.highlight {
  border-color: var(--green-dim);
  background: rgba(34, 197, 94, 0.06);
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.stat-value {
  font-family: var(--mono);
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
}

.stat-card.highlight .stat-value { color: var(--green); }

/* ── Error banner ── */
.error-banner {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.4);
  border-left: 3px solid var(--red);
  border-radius: var(--r);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
}
.error-banner.hidden { display: none; }

/* ── Critical banner ── */
.alert-critical {
  display: flex;
  align-items: center;
  gap: 16px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--r);
  padding: 16px 20px;
  margin-bottom: 16px;
}
.alert-critical.hidden { display: none; }

.alert-badge {
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  padding: 4px 10px;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}

#critical-text {
  font-size: 14px;
  color: var(--text);
  line-height: 1.5;
}

/* ── Exception cards ── */
.exceptions-list { display: flex; flex-direction: column; gap: 10px; }

.exception-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 18px 20px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: start;
  transition: border-color 0.2s;
}

.exception-card:hover { border-color: var(--surface2); }

.severity-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  margin-bottom: 6px;
}
.severity-CRITICAL { background: var(--red); color: #fff; }
.severity-HIGH     { background: var(--amber); color: #000; }
.severity-MEDIUM   { background: var(--blue); color: #fff; }
.severity-LOW      { background: var(--muted); color: #fff; }

.type-tag {
  font-size: 10px;
  font-family: var(--mono);
  color: var(--muted);
  letter-spacing: 0.5px;
}

.exception-body { min-width: 0; }
.exception-claim {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}
.exception-finding {
  font-size: 14px;
  color: var(--text);
  line-height: 1.5;
  margin-bottom: 6px;
}
.exception-action {
  font-size: 12px;
  color: var(--green);
  font-style: italic;
}

.exception-amount {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 700;
  text-align: right;
  white-space: nowrap;
}
.exception-amount.recoverable { color: var(--green); }
.exception-amount.underpay { color: var(--red); }
.exception-amount.zero { color: var(--muted); }

/* ── Lower severity toggle ── */
.lower-toggle {
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: var(--r);
  color: var(--muted);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  padding: 10px 16px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.2s, color 0.2s;
}
.lower-toggle:hover { border-color: var(--green); color: var(--green); }

.lower-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.lower-list.hidden { display: none; }

/* ── Voice section ── */
.voice-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 20px 24px;
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.voice-header {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.btn-voice {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface2);
  border: 1px solid var(--green-dim);
  color: var(--green);
  font-weight: 600;
  font-size: 14px;
  padding: 10px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--sans);
  transition: background 0.2s, border-color 0.2s;
}
.btn-voice:hover { background: rgba(34, 197, 94, 0.1); border-color: var(--green); }
.btn-voice:disabled { opacity: 0.5; cursor: not-allowed; }

/* Secondary fallback: quieter than Play Findings until it is the thing you need. */
.btn-fallback {
  border-color: var(--border);
  color: var(--muted);
  font-weight: 500;
}
.btn-fallback:hover { color: var(--green); border-color: var(--green); }

/* Highlighted when live narration failed or timed out — the button becomes the path. */
.btn-fallback.highlight {
  border-color: var(--amber);
  color: var(--amber);
  background: rgba(245, 158, 11, 0.12);
  animation: fallback-pulse 1.6s ease-in-out 3;
}

@keyframes fallback-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
  50%      { box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.18); }
}

.fallback-notice {
  flex-basis: 100%;
  font-size: 12px;
  line-height: 1.5;
  color: var(--amber);
  border-left: 2px solid var(--amber);
  padding-left: 10px;
}
.fallback-notice.hidden { display: none; }

.voice-status {
  font-size: 13px;
  color: var(--muted);
  flex: 1;
  min-width: 120px;
}
.voice-status.playing { color: var(--green); }

/* ── Footer ── */
.site-footer {
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.3px;
  color: var(--muted);
}

/* ── Utilities ── */
.hidden { display: none !important; }

/* ══════════════════════════════════════════════════════════════════
   Elevation — editorial pass: drawer, hero, typography.
   Overrides only; the base tokens above are untouched. Sits before the
   responsive block so the narrow-screen rules below still win.
   ══════════════════════════════════════════════════════════════════ */

:root {
  --display: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  --hairline: rgba(255, 255, 255, 0.045);
  --lift: 0 1px 0 rgba(255, 255, 255, 0.035) inset, 0 18px 40px -24px rgba(0, 0, 0, 0.9);
  --scrim: rgba(4, 6, 10, 0.74);
}

/* A soft top glow keeps the canvas from reading as flat black. */
body {
  background:
    radial-gradient(1100px 520px at 18% -8%, rgba(34, 197, 94, 0.055), transparent 60%),
    radial-gradient(900px 460px at 100% 0%, rgba(59, 130, 246, 0.05), transparent 55%),
    var(--bg);
}

body.drawer-open { overflow: hidden; }

#app { max-width: 980px; }

/* ── Header + brand lockup ── */
header {
  position: sticky;
  top: 0;
  z-index: 30;
  padding: 18px 0 16px;
  border-bottom: 1px solid var(--hairline);
  background: linear-gradient(180deg, rgba(11, 14, 20, 0.94), rgba(11, 14, 20, 0.72));
  backdrop-filter: blur(14px);
}

.logo-lockup {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.logo-text {
  font-family: var(--display);
  font-size: 23px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.logo-tagline {
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ── Depth: an inset highlight instead of a flat hairline ── */
.card,
.stat-card,
.exception-card,
.voice-section {
  background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.028), rgba(255, 255, 255, 0) 42%);
  box-shadow: var(--lift);
}

/* ── Section overlines ── */
/* The header is sticky, so a scrolled-to section lands underneath it. Clearance
   here is what keeps the hero visible after Run Reconciliation. */
#results,
#drop-section { scroll-margin-top: 96px; }

.results-head { margin: 26px 0 14px; }
.results-head.findings-head { margin-top: 30px; }

.results-overline {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}
.results-overline::after {
  content: '';
  width: 54px;
  height: 1px;
  background: linear-gradient(90deg, var(--green-dim), transparent);
}

/* ── Hero — Recoverable is the focal point ── */
.stats-row {
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.stat-hero {
  grid-column: 1 / -1;
  text-align: left;
  padding: 30px 34px 32px;
  border-color: var(--green-dim);
  background-image:
    radial-gradient(560px 200px at 0% 0%, rgba(34, 197, 94, 0.14), transparent 70%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0) 46%);
}

.stat-hero .stat-label { margin-bottom: 14px; }

.stat-hero .stat-value {
  font-family: var(--display);
  font-size: 66px;
  font-weight: 600;
  line-height: 0.98;
  letter-spacing: -0.035em;
  color: var(--green);
}

.stats-row .stat-card:not(.stat-hero) .stat-value {
  font-family: var(--mono);
  font-size: 26px;
}

/* ── Exception cards: severity rail + calmer rhythm ── */
.exception-card {
  position: relative;
  padding-left: 24px;
  gap: 20px;
}
.exception-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 14px;
  bottom: 14px;
  width: 2px;
  border-radius: 2px;
  background: var(--border);
}
.exception-card:has(.severity-CRITICAL)::before { background: var(--red); }
.exception-card:has(.severity-HIGH)::before { background: var(--amber); }
.exception-card:has(.severity-MEDIUM)::before { background: var(--blue); }

.exception-finding { font-size: 14.5px; line-height: 1.6; }
.exception-amount { font-size: 23px; letter-spacing: -0.01em; }

/* ── Critical banner should stop the eye ── */
.alert-critical {
  padding: 20px 24px;
  background: linear-gradient(180deg, rgba(239, 68, 68, 0.13), rgba(239, 68, 68, 0.05));
  box-shadow: 0 18px 40px -28px rgba(239, 68, 68, 0.55);
}
#critical-text { font-size: 14.5px; line-height: 1.65; }

/* ── Display face for headings ── */
h2 {
  font-family: var(--display);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.drop-zone h2 { font-size: 21px; }

.btn-primary { box-shadow: 0 14px 32px -18px rgba(34, 197, 94, 0.7); }

/* ── Settings drawer + scrim ── */
.scrim {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: var(--scrim);
  backdrop-filter: blur(3px);
}
.scrim.hidden { display: none; }

.settings-panel {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 50;
  width: 340px;
  max-width: 92vw;
  height: 100vh;
  overflow-y: auto;
  padding: 26px 26px 40px;
  border: none;
  border-left: 1px solid var(--border);
  border-radius: 0;
  background: var(--surface);
  background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0) 30%);
  box-shadow: -30px 0 70px -30px rgba(0, 0, 0, 0.95);
}
.settings-panel.hidden { display: none; }

.settings-head {
  padding-bottom: 16px;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--border);
}
.settings-title { font-size: 20px; }

.settings-group { margin-bottom: 26px; }

.settings-overline {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
}

/* Locked model and voice — shown for confidence, not offered as a choice. */
.voice-lock {
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.02);
}
.lock-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 0;
  font-size: 12px;
}
.lock-key {
  font-family: var(--sans);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.lock-val { font-family: var(--mono); color: var(--text); }
.lock-note {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  line-height: 1.5;
  color: var(--muted);
}

.settings-panel .settings-note {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

/* ── Responsive ── */
@media (max-width: 600px) {
  .stats-row { grid-template-columns: 1fr; }
  .stat-hero { padding: 24px 22px 26px; }
  .stat-hero .stat-value { font-size: 46px; }
  .settings-panel { width: 100vw; max-width: 100vw; }
  .exception-card { grid-template-columns: 1fr; padding-left: 18px; }
  .exception-amount { text-align: left; }
  .voice-section { flex-direction: column; align-items: flex-start; }
}
