/* ═══════════════════════════════════════════════════════════════
   ChurnSense Dashboard — Luxury Cream Theme
   Sections:
     1. Design tokens (CSS variables)
     2. Reset & base
     3. Grain texture
     4. Login screen
     5. Sidebar
     6. Main layout
     7. Page header
     8. Model status strip
     9. Stats grid
    10. Section header & filters
    11. Accounts table
    12. Risk badges
    13. Score bar
    14. Detail panel
    15. Model page
    16. Loading & empty states
    17. Toast
    18. Animations & utilities
═══════════════════════════════════════════════════════════════ */


/* ─────────────────────────────────────────
   1. Design tokens
───────────────────────────────────────── */
:root {
  /* Backgrounds — warm dim parchment, not bright white */
  --cream:      #e8e0d0;
  --cream2:     #ddd4c0;
  --cream3:     #d0c8b4;
  --parchment:  #bfb8a8;

  /* Gold accent */
  --gold:       #b8922e;
  --gold2:      #d4a84a;
  --gold3:      #e8cc80;

  /* Ink (text) — deep and readable */
  --ink:        #1a1610;
  --ink2:       #2e2a20;
  --ink3:       #4a4030;
  --ink4:       #7a6e5a;

  /* Semantic colors */
  --red:        #7a2020;
  --red-bg:     rgba(122, 32, 32, 0.10);
  --amber:      #8a5a10;
  --amber-bg:   rgba(138, 90, 16, 0.10);
  --sage:       #2e5c3a;
  --sage-bg:    rgba(46, 92, 58, 0.10);

  /* Spacing & shape */
  --radius:     4px;
  --radius-lg:  8px;

  /* Shadows */
  --shadow:     0 1px 3px rgba(26, 22, 16, 0.10), 0 4px 16px rgba(26, 22, 16, 0.06);
  --shadow-lg:  0 8px 40px rgba(26, 22, 16, 0.16);

  /* ── Typography — font families ───────────────────────────────
     --font-display: Funnel Display — high-contrast geometric display
       font. Used for the largest text moments: login title, stat values.
       Distinctive without trying too hard.
     --font-serif: Cormorant Garamond — retained for the editorial
       serif moments that give ChurnSense its luxury B2B character.
       Page titles, wizard headings, admin panel title.
     --font-sans: Inter — the most readable UI sans-serif in existence.
       Replaces Jost. Used for all body text, nav, labels, buttons.
       Designed specifically for screen legibility at small sizes.
     --font-mono: DM Mono — unchanged. Code blocks, labels, mono UI.
  ── */
  --font-display: 'Funnel Display', 'Georgia', serif;
  --font-serif:   'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-sans:    'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:    'DM Mono', 'Courier New', monospace;

  /* ── Font weight scale ────────────────────────────────────────
     The previous codebase used weight 300 for almost everything,
     creating flat, undifferentiated text. This scale restores
     visual hierarchy. Rule: weight creates emphasis, color creates
     hierarchy within the same weight tier.

     300 — captions, placeholder text, secondary mono labels
     400 — body text, descriptions, serif headings (Cormorant)
     500 — subheadings, nav items, emphasized body
     600 — primary headings (Inter), strong labels, stat values
     700 — hero numbers, display text, login/wizard titles
  ── */
  --fw-light:    300;
  --fw-regular:  400;
  --fw-medium:   500;
  --fw-semibold: 600;
  --fw-bold:     700;

  /* ── Type scale — 11 named tiers replacing 26 ad-hoc sizes ──
     Tiers below --text-h3 are fixed: at small sizes fluid scaling
     adds complexity without visible benefit.
     Tiers from --text-h3 upward use clamp() so they scale smoothly
     between mobile (min) and wide desktop (max) without breakpoints.

     Scale ratio: ~1.25 (major third), anchored at 13px body text.

     Eliminated sizes: 5, 7, 8, 17, 19, 20, 24, 30, 32, 42, 44, 72px
     Replaced one-offs: 48px (login title → --text-display),
                        80px (ghost stat → --text-hero)
  */
  --text-label:    9px;                        /* mono UPPERCASE eyebrows & micro-labels  */
  --text-caption:  11px;                       /* secondary info, sub-labels              */
  --text-small:    12px;                       /* helper text, code, CSV column labels    */
  --text-body:     13px;                       /* primary body, descriptions              */
  --text-body-lg:  15px;                       /* emphasized body, step copy              */
  --text-ui:       16px;                       /* form inputs                             */
  --text-h4:       18px;                       /* card element titles, strong data values */
  --text-h3:       clamp(20px, 2.2vw, 26px);  /* section headings, sidebar logo          */
  --text-h2:       clamp(24px, 2.8vw, 32px);  /* panel company name, card titles         */
  --text-h1:       clamp(28px, 3.5vw, 44px);  /* page titles                             */
  --text-display:  clamp(34px, 4.5vw, 48px);  /* stat values, login brand title          */
  --text-hero:     clamp(56px, 7vw,   80px);  /* stat card ghost watermark only          */
}

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

body {
  font-family: var(--font-sans);
  background: var(--cream);
  color: var(--ink);
  min-height: 100vh;
  overflow-x: hidden;
}

button { cursor: pointer; }
em     { font-style: italic; }


/* ─────────────────────────────────────────
   3. Grain texture overlay
───────────────────────────────────────── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='0.025'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
  opacity: 0.6;
}


/* ─────────────────────────────────────────
   4. Login screen
───────────────────────────────────────── */
#login-screen,
#otp-screen,
#forgot-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--cream);
  z-index: 100;
}

.login-wrap {
  width: 440px;
  animation: fadeUp 0.6s ease both;
}

.login-eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.login-eyebrow::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, var(--gold3), transparent);
}

.login-title {
  font-family: var(--font-serif);
  font-size: 48px;
  font-weight: 300;
  letter-spacing: -1px;
  line-height: 1;
  color: var(--ink);
  margin-bottom: 6px;
}

.login-title em { color: var(--gold); }

.login-sub {
  font-size: 13px;
  font-weight: 300;
  color: var(--ink4);
  margin-bottom: 40px;
}

/* Form fields */
.field { margin-bottom: 20px; }

.field label {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink3);
  margin-bottom: 8px;
}

.field input {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--parchment);
  padding: 10px 0;
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 300;
  color: var(--ink);
  outline: none;
  transition: border-color 0.3s;
}

.field input:focus        { border-color: var(--gold); }
.field input::placeholder { color: var(--ink4); }

/* ─────────────────────────────────────────
  Password strength meter
───────────────────────────────────────── */
.pw-strength-bar {
  height: 2px;
  background: var(--cream3);
  margin-top: 6px;
  overflow: hidden;
}

.pw-strength-fill {
  height: 100%;
  width: 0%;
  transition: width 0.3s ease, background 0.3s ease;
}

.pw-strength-fill[data-score="0"] { width: 20%;  background: var(--red); }
.pw-strength-fill[data-score="1"] { width: 40%;  background: var(--red); }
.pw-strength-fill[data-score="2"] { width: 60%;  background: var(--amber); }
.pw-strength-fill[data-score="3"] { width: 80%;  background: var(--sage); }
.pw-strength-fill[data-score="4"] { width: 100%; background: var(--sage); }

.pw-strength-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  margin-top: 4px;
  min-height: 14px;
  transition: color 0.2s;
}

/* Login button */
.login-btn {
  width: 100%;
  margin-top: 8px;
  padding: 16px;
  background: var(--ink);
  border: none;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--cream);
  transition: background 0.3s;
  position: relative;
  overflow: hidden;
}

.login-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 40%, rgba(201, 168, 76, 0.15) 100%);
  opacity: 0;
  transition: opacity 0.3s;
}

.login-btn:hover          { background: var(--ink2); }
.login-btn:hover::after   { opacity: 1; }
.login-btn:disabled       { opacity: 0.4; cursor: not-allowed; }

.login-error {
  margin-top: 12px;
  padding: 10px 0;
  font-size: 12px;
  color: var(--red);
  display: none;
}

.login-divider {
  width: 100%;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--parchment), transparent);
  margin-top: 40px;
}


/* ─────────────────────────────────────────
   5. Sidebar
───────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 200px;
  height: 100vh;
  background: var(--cream);
  border-right: 1px solid var(--cream3);
  display: flex;
  flex-direction: column;
  padding: 32px 0;
  z-index: 10;
}

.sidebar-logo {
  padding: 0 28px 28px;
  border-bottom: 1px solid var(--cream3);
  margin-bottom: 24px;
}

.logo-eyebrow {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 4px;
}

.logo-name {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 400;
  letter-spacing: -0.5px;
  color: var(--ink);
}

.logo-name em { color: var(--gold); }

.nav-label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink4);
  padding: 0 28px;
  margin-bottom: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 28px;
  font-size: 12px;
  font-weight: 400;
  color: var(--ink3);
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  letter-spacing: 0.01em;
}

/* Gold left border on active nav item */
.nav-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--gold);
  opacity: 0;
  transition: opacity 0.2s;
}

.nav-item:hover          { color: var(--ink); background: var(--cream2); }
.nav-item.active         { color: var(--ink); background: var(--cream2); }
.nav-item.active::before { opacity: 1; }

.nav-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  border: 1px solid currentColor;
  opacity: 0.5;
  flex-shrink: 0;
}

.nav-item.active .nav-dot {
  background: var(--gold);
  border-color: var(--gold);
  opacity: 1;
}

.sidebar-footer {
  margin-top: auto;
  padding: 20px 28px 0;
  border-top: 1px solid var(--cream3);
}

.tenant-name {
  font-family: var(--font-serif);
  font-size: 14px;
  font-style: italic;
  color: var(--ink2);
  margin-bottom: 4px;
}

.logout-btn {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink4);
  background: none;
  border: none;
  padding: 0;
  transition: color 0.2s;
}

.logout-btn:hover { color: var(--red); }

/* ─────────────────────────────────────────
   6. Main layout
───────────────────────────────────────── */
#app {
  display: none;
  position: relative;
  z-index: 1;
}

.main {
  margin-left: 200px;
  padding: 48px 52px;
  min-height: 100vh;
}

.page               { display: block; opacity: 1; transition: opacity 0.18s ease; }
.page.hidden        { display: none; }
/* Class applied for one paint frame before new page appears — triggers fade-in */
.page.page-entering { opacity: 0; transition: none; }

@media (prefers-reduced-motion: reduce) {
  .page { transition: none; }
  .page.page-entering { opacity: 1; }
}

/* ─────────────────────────────────────────
   7. Page header
───────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 40px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--cream3);
}

.page-eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 8px;
}

.page-title {
  font-family: var(--font-serif);
  font-size: 42px;
  font-weight: 300;
  letter-spacing: -1px;
  line-height: 1;
  color: var(--ink);
}

.page-title em, .login-title em {
  font-style: normal;
}

.page-sub {
  font-size: 13px;
  font-weight: 300;
  color: var(--ink4);
  margin-top: 6px;
}


/* ─────────────────────────────────────────
   8. Model status strip
───────────────────────────────────────── */
.model-strip {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: var(--cream2);
  border: 1px solid var(--cream3);
  margin-bottom: 32px;
  font-size: 12px;
  color: var(--ink3);
}

.model-pip {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--sage);
  flex-shrink: 0;
  box-shadow: 0 0 8px rgba(58, 107, 74, 0.4);
  animation: breathe 3s ease-in-out infinite;
}

.model-pip.off {
  background: var(--amber);
  box-shadow: none;
  animation: none;
}

.auc-pill {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 8px;
  background: var(--gold3);
  color: var(--amber);
  border: 1px solid var(--gold2);
}

.strip-right {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
}

.strip-btn {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 6px 14px;
  background: transparent;
  border: 1px solid var(--parchment);
  color: var(--ink3);
  transition: all 0.2s;
}

.strip-btn:hover {
  border-color: var(--gold);
  color: var(--ink);
  background: var(--cream2);
}


/* ─────────────────────────────────────────
   9. Stats grid
───────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--cream3);
  border: 1px solid var(--cream3);
  margin-bottom: 48px;
  overflow: hidden;
}

.stat-card {
  background: var(--cream);
  padding: 28px 28px 24px;
  position: relative;
  overflow: hidden;
  transition: background 0.2s;
}

.stat-card:hover { background: var(--cream2); }

/* Large ghost number watermark — disabled */
.stat-card::after { content: none; }

.stat-eyebrow {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink4);
  margin-bottom: 14px;
}

.stat-value {
  font-family: var(--font-serif);
  font-size: 44px;
  font-weight: 300;
  letter-spacing: -1.5px;
  line-height: 1;
  color: var(--ink);
  margin-bottom: 6px;
}

/* Semantic color variants */
.stat-value.danger { color: var(--red); }
.stat-value.warn   { color: var(--amber); }
.stat-value.good   { color: var(--sage); }
.stat-value.gold   { color: var(--gold); }

.stat-sub {
  font-size: 11px;
  font-weight: 300;
  color: var(--ink4);
}


/* ─────────────────────────────────────────
  10. Section header & filters
───────────────────────────────────────── */
.section-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.section-title {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 300;
  letter-spacing: -0.3px;
  color: var(--ink);
}

.filter-row { display: flex; gap: 2px; }

.ftab {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 6px 14px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink4);
  transition: all 0.2s;
}

.ftab:hover        { color: var(--ink); }
.ftab.active       { border-color: var(--parchment); color: var(--ink); background: var(--cream2); }
/* Retained tab gets a green active state to distinguish it from risk filters */
.ftab[data-filter="retained"].active { border-color: rgba(42,122,79,0.3); color: #2a7a4f; background: rgba(42,122,79,0.07); }


/* ─────────────────────────────────────────
  11. Accounts table
───────────────────────────────────────── */
.tbl-wrap {
  border: 1px solid var(--cream3);
  overflow: hidden;
  animation: fadeUp 0.4s ease both;
}

table { width: 100%; border-collapse: collapse; }

thead {
  background: var(--cream2);
  border-bottom: 1px solid var(--cream3);
}

thead th {
  padding: 12px 20px;
  text-align: left;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink4);
  font-weight: 400;
}

tbody tr {
  border-bottom: 1px solid var(--cream3);
  cursor: pointer;
  transition: background 0.15s;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover      { background: var(--cream2); }

td {
  padding: 18px 20px;
  vertical-align: middle;
}

.co-name {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 300;
  letter-spacing: -0.2px;
  color: var(--ink);
  margin-bottom: 2px;
}

.co-meta {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.05em;
  color: var(--ink4);
}

.mrr-val {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 300;
  color: var(--ink2);
}

.factor-tag {
  font-family: var(--font-serif);
  font-size: 13px;
  font-weight: 300;
  font-style: italic;
  color: var(--ink3);
}

.last-login {
  font-family: var(--font-serif);
  font-size: 13px;
  font-weight: 300;
  color: var(--ink4);
}


/* ─────────────────────────────────────────
  12. Risk badges
───────────────────────────────────────── */
.rbadge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border: 1px solid;
}

.rbadge.high    { color: var(--red);   border-color: rgba(139, 46, 46, 0.25);  background: var(--red-bg);   }
.rbadge.medium  { color: var(--amber); border-color: rgba(155, 107, 26, 0.25); background: var(--amber-bg); }
.rbadge.low     { color: var(--sage);  border-color: rgba(58, 107, 74, 0.25);  background: var(--sage-bg);  }
.rbadge.unknown { color: var(--ink4);  border-color: var(--cream3);            background: transparent;     }
/* Retained badge — a distinct business-outcome status, not a model prediction */
.rbadge.retained {
  color: #2a7a4f;
  border-color: rgba(42, 122, 79, 0.3);
  background: rgba(42, 122, 79, 0.08);
  font-weight: 600;
}
.rbadge.retained .rpip { background: #2a7a4f; }

.rpip {
  width: 5px;
  height: 5px;
  border-radius: 50%;
}

.rbadge.high .rpip   { background: var(--red);   animation: pulse 2s infinite; }
.rbadge.medium .rpip { background: var(--amber); }
.rbadge.low .rpip    { background: var(--sage);  }

/* ─────────────────────────────────────────
  Recently Retained section
───────────────────────────────────────── */
.retained-section {
  margin-top: 36px;
  border-top: 1px solid var(--cream3);
  padding-top: 20px;
}

.retained-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #2a7a4f;
  margin-bottom: 14px;
  font-weight: 600;
}

.retained-section-icon {
  font-size: 12px;
}

.retained-section-count {
  color: var(--ink4);
  font-weight: 400;
  margin-left: 4px;
}

.retained-table { width: 100%; }
.retained-table thead th { color: var(--ink4); }
.retained-row { opacity: 0.75; transition: opacity 0.15s; }
.retained-row:hover { opacity: 1; }

/* Retained notice inside detail panel (replaces the Mark as retained button) */
.retained-notice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(42, 122, 79, 0.07);
  border: 1px solid rgba(42, 122, 79, 0.25);
  border-radius: 6px;
  margin: 8px 0;
  font-size: 13px;
  color: #2a7a4f;
}

.retained-notice-icon {
  font-size: 16px;
  line-height: 1.3;
  flex-shrink: 0;
}

.retained-notice strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #2a7a4f;
}

.retained-notice-sub {
  font-size: 11px;
  color: var(--ink4);
  margin-top: 3px;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}


/* ─────────────────────────────────────────
  13. Score bar
───────────────────────────────────────── */
.sbar-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sbar-bg {
  width: 72px;
  height: 2px;
  background: var(--cream3);
}

.sbar-fill {
  height: 100%;
  transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.snum {
  font-family: var(--font-mono);
  font-size: 12px;
  min-width: 32px;
  font-weight: 400;
}


/* ─────────────────────────────────────────
  14. Detail panel (slide-in)
───────────────────────────────────────── */
.detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 22, 16, 0.4);
  z-index: 50;
  display: none;
  justify-content: flex-end;
  backdrop-filter: blur(2px);
}

.detail-overlay.open { display: flex; }

.detail-panel {
  width: 460px;
  height: 100vh;
  background: var(--cream);
  border-left: 1px solid var(--cream3);
  overflow-y: auto;
  animation: panelIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.panel-header {
  padding: 36px 36px 28px;
  border-bottom: 1px solid var(--cream3);
  position: relative;
}

.panel-close {
  position: absolute;
  top: 24px;
  right: 24px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--cream3);
  font-size: 14px;
  color: var(--ink4);
  transition: all 0.2s;
  background: none;
}

.panel-close:hover { border-color: var(--parchment); color: var(--ink); }

.panel-eyebrow {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 8px;
}

.panel-company {
  font-family: var(--font-serif);
  font-size: 30px;
  font-weight: 300;
  letter-spacing: -0.5px;
  color: var(--ink);
  margin-bottom: 12px;
}

.panel-score-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 20px 0 0;
}

.panel-score-big {
  font-family: var(--font-serif);
  font-size: 72px;
  font-weight: 300;
  letter-spacing: -3px;
  line-height: 1;
}

.panel-score-unit {
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 300;
  color: var(--ink4);
}

.panel-score-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--ink4);
  margin: 8px 0 20px;
}

.panel-body { padding: 28px 36px; }

.panel-section-title {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink4);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--cream3);
}

/* Factor rows */
.factor-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--cream3);
}

.factor-item:last-child { border-bottom: none; }

.fi-label {
  font-family: var(--font-serif);
  font-size: 15px;
  font-style: italic;
  font-weight: 300;
  color: var(--ink2);
  flex: 1;
}

.fi-bar-bg {
  width: 80px;
  height: 1px;
  background: var(--cream3);
}

.fi-bar-fill { height: 100%; background: var(--gold); }

.fi-pct {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink4);
  min-width: 28px;
  text-align: right;
}

/* ── Score history chart ── */
.score-history-chart {
  width: 100%;
  margin-bottom: 8px;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.score-history-chart svg {
  display: block;
  max-width: 100%;
}

.score-history-loading,
.score-history-empty {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink4);
  font-style: italic;
  padding: 12px 0;
}

/* Meta 2-col grid */
.meta-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--cream3);
  border: 1px solid var(--cream3);
  margin-bottom: 24px;
}

.meta-cell { background: var(--cream); padding: 14px 16px; }

.meta-cell-label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink4);
  margin-bottom: 4px;
}

.meta-cell-val {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 400;
  color: var(--ink);
}

/* Panel action buttons */
.panel-action {
  width: 100%;
  padding: 14px 20px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  border: none;
  transition: all 0.2s;
  margin-bottom: 8px;
  display: block;
}

.pa-primary   { background: var(--ink);  color: var(--cream); }
.pa-primary:hover   { background: var(--ink2); }

.pa-secondary { background: transparent; border: 1px solid var(--parchment); color: var(--ink3); }
.pa-secondary:hover { border-color: var(--gold); color: var(--ink); }

.pa-danger    { background: transparent; border: 1px solid rgba(139, 46, 46, 0.2); color: var(--red); }
.pa-danger:hover    { background: var(--red-bg); }
.int-reset-btn { background: transparent; border: 1px solid rgba(139, 46, 46, 0.3); color: var(--red); margin-top: 4px; }
.int-reset-btn:hover { background: var(--red-bg); }
.pa-success { background: transparent; border: 1px solid rgba(46, 100, 46, 0.25); color: #4a7c4a; }
.pa-success:hover   { background: rgba(46, 100, 46, 0.07); }


/* ─────────────────────────────────────────
  15. Model page
───────────────────────────────────────── */
.model-stat-box {
  padding: 48px;
  margin-bottom: 20px;
  text-align: center;
}

.model-auc-value {
  font-family: var(--font-serif);
  font-size: 80px;
  font-weight: 300;
  color: var(--gold);
  letter-spacing: -3px;
  line-height: 1;
  margin-bottom: 8px;
}

.model-auc-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink4);
  margin-bottom: 32px;
}

.model-meta-list {
  font-size: 13px;
  font-weight: 300;
  color: var(--ink3);
  line-height: 2;
  text-align: left;
  max-width: 400px;
  margin: 0 auto;
}

.model-meta-list span { color: var(--ink); }
.model-meta-list em   { color: var(--gold); font-style: italic; }

/* Training mode note — shown on the ML Model page */
.model-mode-note {
  margin-top: 20px;
  padding: 16px 18px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink2);
}

.model-mode-heuristic {
  background: var(--amber-bg);
  border-left: 3px solid var(--amber);
}

.model-mode-real {
  background: rgba(46, 107, 62, 0.08);
  border-left: 3px solid #2e6b3e;
}

[data-theme="dark"] .model-mode-real {
  background: rgba(46, 107, 62, 0.15);
}

.model-info-box { padding: 36px; }

.model-info-title {
  font-family: var(--font-serif);
  font-size: 20px;
  font-style: italic;
  font-weight: 300;
  margin-bottom: 20px;
  color: var(--ink);
}

.model-info-list {
  font-size: 13px;
  font-weight: 300;
  color: var(--ink3);
  line-height: 2.2;
}


/* ─────────────────────────────────────────
  16. Loading & empty states
───────────────────────────────────────── */
.loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  gap: 12px;
  color: var(--ink4);
  font-size: 12px;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 1px solid var(--parchment);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.empty-state {
  padding: 60px 20px;
  text-align: center;
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 300;
  font-style: italic;
  color: var(--ink4);
}

.hidden { display: none !important; }

/* ─────────────────────────────────────────
  17. Toast notification
───────────────────────────────────────── */
/* Toast container — stacks toasts bottom-right, newest on top */
#toast-container {
  position: fixed;
  bottom: 28px;
  right: 28px;
  display: flex;
  flex-direction: column-reverse; /* newest appears at bottom of stack */
  gap: 8px;
  z-index: 9999;
  pointer-events: none;
}

/* Individual toast item */
.toast-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--ink);
  color: var(--cream);
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: var(--text-label);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  min-width: 240px;
  max-width: 360px;
  pointer-events: auto;
  /* Entry: slide in from right */
  transform: translateX(calc(100% + 40px));
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1),
              opacity   0.25s ease;
}

.toast-item.toast-visible {
  transform: translateX(0);
  opacity: 1;
}

.toast-item.toast-exit {
  transform: translateX(calc(100% + 40px));
  opacity: 0;
}

/* Type variants */
.toast-item.success { background: var(--sage); }
.toast-item.error   { background: var(--red); }
.toast-item.warning { background: var(--amber); }
.toast-item.info    { background: var(--ink); }

/* Icon — fixed width so message text aligns cleanly */
.toast-icon {
  flex-shrink: 0;
  font-size: 11px;
  line-height: 1.6;
}

/* Message — wraps if long */
.toast-message {
  flex: 1;
  line-height: 1.5;
}

/* Dismiss × button */
.toast-dismiss {
  flex-shrink: 0;
  background: none;
  border: none;
  color: inherit;
  opacity: 0.55;
  font-size: 15px;
  line-height: 1;
  padding: 0 0 0 6px;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: opacity 0.15s;
  margin-top: -1px;
}
.toast-dismiss:hover { opacity: 1; }

/* ─────────────────────────────────────────
  18. Search
───────────────────────────────────────── */
.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-input {
  width: 220px;
  padding: 8px 30px 8px 12px;
  border: 1px solid var(--cream3);
  background: transparent;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: var(--text-label);
  letter-spacing: 0.06em;
  outline: none;
  transition: border-color 0.2s, width 0.25s ease;
}

.search-input::placeholder { color: var(--ink4); }
.search-input:focus        { border-color: var(--ink3); width: 280px; }
/* Hide browser's built-in × in search inputs */
.search-input::-webkit-search-cancel-button { display: none; }

.search-clear {
  position: absolute;
  right: 6px;
  background: none;
  border: none;
  color: var(--ink3);
  font-size: 16px;
  line-height: 1;
  padding: 2px 4px;
  cursor: pointer;
  transition: color 0.15s;
}
.search-clear:hover { color: var(--ink); }

/* Recent searches dropdown */
.search-recent {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 220px;
  background: var(--bg);
  border: 1px solid var(--cream3);
  z-index: 200;
}

.search-recent-label {
  padding: 8px 12px 4px;
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink4);
}

.search-recent-item {
  padding: 8px 12px;
  font-family: var(--font-mono);
  font-size: var(--text-label);
  letter-spacing: 0.06em;
  color: var(--ink3);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.1s;
}
.search-recent-item:hover,
.search-recent-item:focus  { background: var(--cream2); color: var(--ink); outline: none; }

/* Matched term highlight */
mark.sh {
  background: transparent;
  color: var(--ink);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: var(--sage);
  text-underline-offset: 2px;
}

/* Empty / no-results state */
.search-empty {
  padding: 48px 24px;
  text-align: center;
}
.search-empty-title {
  font-family: var(--font-serif);
  font-size: var(--text-h4);
  color: var(--ink);
  margin-bottom: 8px;
}
.search-empty-hint {
  font-family: var(--font-mono);
  font-size: var(--text-label);
  letter-spacing: 0.06em;
  color: var(--ink3);
}

/* ─────────────────────────────────────────
  19. Animations & utilities
───────────────────────────────────────── */

/* Staggered reveal on load */
.reveal {
  opacity: 0;
  animation: fadeUp 0.5s ease both;
}

.reveal:nth-child(1) { animation-delay: 0.05s; }
.reveal:nth-child(2) { animation-delay: 0.1s;  }
.reveal:nth-child(3) { animation-delay: 0.15s; }
.reveal:nth-child(4) { animation-delay: 0.2s;  }

@keyframes fadeUp {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  @keyframes fadeUp {
    from { opacity: 1; }
    to   { opacity: 1; }
  }
}

@keyframes panelIn {
  from { transform: translateX(40px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

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

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

@keyframes breathe {
  0%, 100% { box-shadow: 0 0 6px  rgba(58, 107, 74, 0.3); }
  50%       { box-shadow: 0 0 14px rgba(58, 107, 74, 0.7); }
}


/* ═══════════════════════════════════════════════════════════════
   19. Integrations page
═══════════════════════════════════════════════════════════════ */

/* ── Integration tabs ── */
.int-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--cream3);
  margin-bottom: 32px;
}

.int-tab {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 10px 20px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--ink4);
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: -1px;
}

.int-tab:hover        { color: var(--ink2); }
.int-tab.active       { color: var(--ink);  border-bottom-color: var(--gold); }

/* ── Integration panel ── */
.int-panel        { display: block; animation: fadeUp 0.3s ease both; }
.int-panel.hidden { display: none; }

/* ── Integration card ── */
.int-card {
  border: 1px solid var(--cream3);
  padding: 36px;
  background: var(--cream);
  max-width: 760px;
}

.int-card-header { margin-bottom: 32px; }

.int-step {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 8px;
}

.int-card-title {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 400;
  letter-spacing: -0.3px;
  color: var(--ink);
  margin-bottom: 8px;
}

.int-card-sub {
  font-size: 14px;
  font-weight: 300;
  color: var(--ink3);
  line-height: 1.7;
  max-width: 560px;
}

/* ── Section labels ── */
.int-section-label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink4);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--cream3);
}

.int-hint {
  font-size: 13px;
  font-weight: 300;
  color: var(--ink3);
  margin-bottom: 12px;
  line-height: 1.6;
}

.int-hint code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--cream2);
  padding: 1px 6px;
  border: 1px solid var(--cream3);
  color: var(--ink2);
}

/* ── Code block ── */
.code-block {
  background: var(--ink);
  padding: 20px 24px;
  position: relative;
  margin-bottom: 8px;
  overflow-x: auto;
}

.code-block pre {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.8;
  color: var(--gold2);
  white-space: pre;
  margin: 0;
  padding-right: 60px;
}

.code-copy-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 5px 12px;
  background: transparent;
  border: 1px solid rgba(232, 201, 122, 0.3);
  color: var(--gold2);
  cursor: pointer;
  transition: all 0.2s;
}

.code-copy-btn:hover {
  background: rgba(232, 201, 122, 0.1);
  border-color: var(--gold2);
}

.code-copy-btn.copied {
  color: var(--sage);
  border-color: rgba(58, 107, 74, 0.5);
}

/* ── Status row ── */
.int-status-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--cream3);
  font-size: 12px;
  color: var(--ink4);
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
}

.int-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.int-status-dot.inactive { background: var(--parchment); }
.int-status-dot.active   { background: var(--sage); box-shadow: 0 0 8px rgba(58,107,74,0.5); animation: breathe 3s ease-in-out infinite; }

/* ── Steps list (Stripe) ── */
.steps-list { display: flex; flex-direction: column; gap: 0; }

.step-item {
  display: flex;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--cream3);
}

.step-item:last-child { border-bottom: none; }

.step-num {
  width: 28px;
  height: 28px;
  border: 1px solid var(--parchment);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink3);
  flex-shrink: 0;
  margin-top: 2px;
}

.step-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 4px;
}

.step-desc {
  font-size: 13px;
  font-weight: 300;
  color: var(--ink3);
  line-height: 1.6;
}

.int-link {
  color: var(--gold);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.event-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.event-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 3px 8px;
  background: var(--cream2);
  border: 1px solid var(--cream3);
  color: var(--ink2);
  letter-spacing: 0.03em;
}

/* ── CSV columns table ── */
.csv-columns {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1px;
  background: var(--cream3);
  border: 1px solid var(--cream3);
  margin-bottom: 8px;
}

.csv-col {
  background: var(--cream);
  padding: 14px 16px;
}

.csv-col-name {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 4px;
}

.csv-col-desc {
  font-size: 11px;
  font-weight: 300;
  color: var(--ink3);
  margin-bottom: 6px;
  line-height: 1.4;
}

.csv-col-example {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--gold);
  background: var(--cream2);
  padding: 2px 6px;
  display: inline-block;
}

/* ── Upload area ── */
.upload-area {
  border: 1px dashed var(--parchment);
  padding: 48px 32px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--cream);
}

.upload-area:hover,
.upload-area.dragover {
  border-color: var(--gold);
  background: var(--cream2);
}

.upload-icon {
  font-size: 28px;
  color: var(--parchment);
  margin-bottom: 12px;
  transition: color 0.2s;
}

.upload-area:hover .upload-icon { color: var(--gold); }

.upload-label {
  font-size: 14px;
  font-weight: 400;
  color: var(--ink2);
  margin-bottom: 6px;
}

.upload-link {
  color: var(--gold);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.upload-sub {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink4);
  letter-spacing: 0.08em;
}

/* ── Upload progress ── */
.upload-progress {
  margin-top: 16px;
  padding: 16px 20px;
  border: 1px solid var(--cream3);
  background: var(--cream2);
}

.progress-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--ink3);
  margin-bottom: 10px;
  text-transform: uppercase;
}

.progress-bar-bg {
  width: 100%;
  height: 2px;
  background: var(--cream3);
}

.progress-bar-fill {
  height: 100%;
  background: var(--gold);
  width: 0%;
  transition: width 0.4s ease;
}

/* ── Upload result ── */
.upload-result {
  margin-top: 16px;
  padding: 16px 20px;
  border: 1px solid;
  font-size: 13px;
  font-weight: 300;
  line-height: 1.6;
}

.upload-result.success {
  border-color: rgba(58, 107, 74, 0.25);
  background: var(--sage-bg);
  color: var(--sage);
}

.upload-result.error {
  border-color: rgba(139, 46, 46, 0.25);
  background: var(--red-bg);
  color: var(--red);
}

/* ── Action button ── */
.int-action-btn {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 12px 20px;
  background: var(--ink);
  border: none;
  color: var(--cream);
  cursor: pointer;
  transition: background 0.2s;
  margin-bottom: 8px;
  display: inline-block;
}

.int-action-btn:hover { background: var(--ink2); }

/* ── Stripe signing secret input ── */
.int-secret-row {
  display: flex;
  gap: 10px;
  margin-top: 10px;
  max-width: 480px;
}

.int-secret-input {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 11px 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--ink);
}

.int-secret-input:focus {
  outline: none;
  border-color: var(--ink);
}

.int-secret-row .int-action-btn {
  margin-bottom: 0;
  white-space: nowrap;
}

#stripe-secret-status.success { color: var(--green, #2e6b3e); }
#stripe-secret-status.error   { color: var(--red); }

/* ── Danger zone ── */
.danger-zone {
  max-width: 760px;
  margin-top: 60px;
  padding-top: 32px;
  border-top: 1px solid var(--red);
}

.danger-zone-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--red);
  margin-bottom: 12px;
}

.danger-zone-text {
  font-size: 13px;
  font-weight: 300;
  line-height: 1.6;
  color: var(--ink3);
  margin-bottom: 16px;
}

.danger-zone .panel-action {
  max-width: 220px;
}

/* ─────────────────────────────────────────
   Auth toggle (login / signup)
───────────────────────────────────────── */
.auth-toggle {
  display: flex;
  gap: 0;
  border: 1px solid var(--parchment);
  margin-bottom: 32px;
  overflow: hidden;
}

.auth-toggle-btn {
  flex: 1;
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  background: transparent;
  border: none;
  color: var(--ink4);
  cursor: pointer;
  transition: all 0.2s;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}

.auth-toggle-btn:first-child {
  border-right: 1px solid var(--parchment);
}

.auth-toggle-btn.active {
  background: var(--ink);
  color: var(--cream);
}

.auth-toggle-btn:not(.active):hover {
  background: var(--cream2);
  color: var(--ink);
}

/* ═══════════════════════════════════════════════════════════════
   20. Dark mode
═══════════════════════════════════════════════════════════════ */

[data-theme="dark"] {
  --cream:     #141210;
  --cream2:    #1c1a17;
  --cream3:    #252220;
  --parchment: #2e2b27;
  --gold:      #c9a84c;
  --gold2:     #e8c97a;
  --gold3:     #3a3020;
  --ink:       #f0ece4;
  --ink2:      #d4cfc6;
  --ink3:      #a09890;
  --ink4:      #6b6560;
  --red:       #c0524a;
  --red-bg:    rgba(192, 82, 74, 0.12);
  --amber:     #b8892a;
  --amber-bg:  rgba(184, 137, 42, 0.12);
  --sage:      #4a8a5a;
  --sage-bg:   rgba(74, 138, 90, 0.12);
}

/* Dark mode sidebar border */
[data-theme="dark"] .sidebar { border-right-color: var(--cream3); }
[data-theme="dark"] .tbl-wrap { border-color: var(--cream3); }
[data-theme="dark"] thead { background: var(--cream2); border-color: var(--cream3); }
[data-theme="dark"] tbody tr { border-color: var(--cream3); }
[data-theme="dark"] .stats-grid { background: var(--cream3); border-color: var(--cream3); }
[data-theme="dark"] .stat-card { background: var(--cream2); }
[data-theme="dark"] .stat-card:hover { background: var(--cream3); }
[data-theme="dark"] .model-strip { background: var(--cream2); border-color: var(--cream3); }
[data-theme="dark"] .login-btn { background: var(--gold); color: #141210; }
[data-theme="dark"] .login-btn:hover { background: var(--gold2); }
[data-theme="dark"] .int-card { background: var(--cream2); border-color: var(--cream3); }
[data-theme="dark"] .meta-2col { background: var(--cream3); border-color: var(--cream3); }
[data-theme="dark"] .meta-cell { background: var(--cream2); }
[data-theme="dark"] .detail-panel { background: var(--cream2); border-color: var(--cream3); }
[data-theme="dark"] .panel-header { border-color: var(--cream3); }
[data-theme="dark"] .upload-area { background: var(--cream2); border-color: var(--parchment); }
[data-theme="dark"] .upload-area:hover { background: var(--cream3); }
[data-theme="dark"] .upload-progress { background: var(--cream3); border-color: var(--cream3); }
[data-theme="dark"] .csv-col { background: var(--cream2); }
[data-theme="dark"] .step-item { border-color: var(--cream3); }
[data-theme="dark"] .int-tabs { border-color: var(--cream3); }

/* Dark mode switch (Settings > Appearance) */
.theme-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  cursor: pointer;
  flex-shrink: 0;
}

.theme-switch input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}

.theme-switch-track {
  position: absolute;
  inset: 0;
  background: var(--cream2);
  border: 1px solid var(--parchment);
  border-radius: 999px;
  transition: background 0.2s, border-color 0.2s;
}

.theme-switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: var(--ink3);
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}

.theme-switch input:checked + .theme-switch-track {
  background: var(--gold);
  border-color: var(--gold);
}

.theme-switch input:checked + .theme-switch-track .theme-switch-thumb {
  transform: translateX(20px);
  background: var(--ink);
}

.theme-switch input:focus-visible + .theme-switch-track {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* ─────────────────────────────────────────
  Confirm modal
───────────────────────────────────────── */
.confirm-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.confirm-modal.hidden { display: none; }

.confirm-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(2px);
}

.confirm-dialog {
  position: relative;
  background: var(--cream);
  border: 1px solid var(--cream3);
  box-shadow: var(--shadow-lg);
  padding: 36px 32px 28px;
  max-width: 420px;
  width: calc(100% - 48px);
  z-index: 1;
}

.confirm-title {
  font-family: var(--font-serif);
  font-size: var(--text-h2);
  font-weight: 400;
  color: var(--ink);
  margin: 0 0 14px;
  line-height: 1.2;
}

.confirm-body {
  font-family: var(--font-sans);
  font-size: var(--text-body);
  color: var(--ink3);
  line-height: 1.65;
  margin: 0 0 32px;
}

.confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.confirm-btn {
  font-family: var(--font-mono);
  font-size: var(--text-small);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 11px 22px;
  border: 1px solid var(--cream3);
  background: transparent;
  color: var(--ink3);
  cursor: pointer;
  transition: all 0.15s;
}
.confirm-cancel:hover { background: var(--cream2); color: var(--ink); border-color: var(--parchment); }

.confirm-ok           { border-color: var(--ink); background: var(--ink); color: var(--cream); }
.confirm-ok:hover     { opacity: 0.85; }
.confirm-ok--danger   { border-color: var(--red); background: var(--red); color: var(--cream); }
.confirm-ok--danger:hover { opacity: 0.85; }

/* ─────────────────────────────────────────
  Onboarding Wizard
───────────────────────────────────────── */
.wizard-overlay {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.wizard-overlay.hidden { display: none; }

.wizard-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(26, 22, 16, 0.50);
  backdrop-filter: blur(3px);
}

.wizard-box {
  position: relative;
  background: var(--cream);
  border: 1px solid var(--cream3);
  padding: 44px 48px 40px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  z-index: 1;
  box-shadow: 0 24px 80px rgba(26, 22, 16, 0.28), 0 4px 16px rgba(26, 22, 16, 0.12);
}

/* Progress dots */
.wizard-dots {
  display: flex;
  gap: 6px;
  margin-bottom: 28px;
}
.wizard-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cream3);
  transition: background 0.25s;
}
.wizard-dot.done    { background: var(--sage); }
.wizard-dot.current { background: var(--ink); }

/* Close button */
.wizard-close-btn {
  position: absolute;
  top: 16px;
  right: 20px;
  background: none;
  border: none;
  font-size: 22px;
  color: var(--ink4);
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  transition: color 0.15s;
}
.wizard-close-btn:hover { color: var(--ink); }

/* Step content */
.wizard-eyebrow {
  font-family: var(--font-mono);
  font-size: var(--text-label);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink4);
  margin-bottom: 12px;
}

.wizard-heading {
  font-family: var(--font-serif);
  font-size: clamp(28px, 4vw, 40px);
  font-weight: 400;
  line-height: 1.1;
  color: var(--ink);
  margin-bottom: 16px;
}
.wizard-heading em { font-style: italic; color: var(--ink3); }

.wizard-text {
  font-family: var(--font-sans);
  font-size: var(--text-body-lg);
  color: var(--ink3);
  line-height: 1.65;
  margin-bottom: 24px;
}

/* Feature list (welcome screen) */
.wizard-feature-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 32px;
}

.wizard-feature {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.wizard-feature-num {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border: 1.5px solid var(--cream3);
  border-radius: 50%;
  display: flex !important;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--ink3);
  margin-top: 1px;
  background: var(--cream);
  line-height: 1;
}

.wizard-feature > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.wizard-feature strong {
  font-family: var(--font-sans);
  font-size: var(--text-body);
  font-weight: 500;
  color: var(--ink);
}
.wizard-feature span {
  font-family: var(--font-mono);
  font-size: var(--text-label);
  letter-spacing: 0.04em;
  color: var(--ink4);
  line-height: 1.5;
}

/* Download button */
.wizard-download-btn {
  display: inline-block;
  padding: 9px 18px;
  border: 1px solid var(--cream3);
  background: transparent;
  color: var(--ink3);
  font-family: var(--font-mono);
  font-size: var(--text-label);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  margin-bottom: 16px;
  transition: all 0.15s;
}
.wizard-download-btn:hover { background: var(--cream2); color: var(--ink); }

/* CSV dropzone */
.wizard-dropzone {
  border: 1px dashed var(--cream3);
  background: var(--cream);
  margin-bottom: 16px;
  transition: border-color 0.2s, background 0.2s;
  min-height: 100px;
}
.wizard-dropzone.dz-hover {
  border-color: var(--ink3);
  background: var(--cream2);
}

.wizard-drop-inner {
  padding: 28px 24px;
  text-align: center;
  cursor: pointer;
}
.wizard-drop-icon {
  font-size: 20px;
  color: var(--ink4);
  margin-bottom: 8px;
}
.wizard-drop-label {
  font-family: var(--font-sans);
  font-size: var(--text-body);
  color: var(--ink3);
  margin-bottom: 4px;
}
.wizard-drop-hint {
  font-family: var(--font-mono);
  font-size: var(--text-label);
  color: var(--ink4);
  letter-spacing: 0.06em;
}

/* Upload progress */
.wizard-upload-progress {
  padding: 20px 24px;
}
.wizard-upload-bar {
  height: 2px;
  background: var(--cream3);
  margin-bottom: 10px;
}
.wizard-upload-fill {
  height: 100%;
  background: var(--ink);
  width: 0%;
  transition: width 0.3s ease;
}
.wizard-upload-label {
  font-family: var(--font-mono);
  font-size: var(--text-label);
  letter-spacing: 0.06em;
  color: var(--ink3);
}

/* Upload result */
.wizard-result {
  padding: 12px 16px;
  font-family: var(--font-mono);
  font-size: var(--text-label);
  letter-spacing: 0.04em;
  line-height: 1.5;
  margin-bottom: 12px;
}
.wizard-result--success { background: var(--sage-bg);  color: var(--sage); }
.wizard-result--error   { background: var(--red-bg);   color: var(--red); }

/* Alt links (JS snippet / Stripe) */
.wizard-alt {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 24px;
  font-family: var(--font-mono);
  font-size: var(--text-label);
  letter-spacing: 0.04em;
  color: var(--ink4);
}

.wizard-link-btn {
  background: none;
  border: none;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: var(--text-label);
  letter-spacing: 0.04em;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  padding: 0;
}

/* Success row (accounts imported indicator) */
.wizard-success-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--sage-bg);
  margin-bottom: 20px;
  font-family: var(--font-sans);
  font-size: var(--text-body);
  color: var(--sage);
}
.wizard-check {
  font-size: 16px;
  font-weight: 600;
}

/* Training spinner */
.wizard-training-status {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 0;
}
.wizard-training-title {
  font-family: var(--font-sans);
  font-size: var(--text-body);
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 4px;
}
.wizard-training-sub {
  font-family: var(--font-mono);
  font-size: var(--text-label);
  color: var(--ink3);
  letter-spacing: 0.04em;
}

.wizard-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--cream3);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Complete step */
.wizard-complete-stats {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}
.wizard-stat-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--cream2);
}
.wizard-stat-row:last-child { border-bottom: none; }
.wizard-stat-icon { width: 18px; height: 18px; stroke-width: 1.75; flex-shrink: 0; margin-top: 2px; }
.wizard-stat-row > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.wizard-stat-row strong {
  font-family: var(--font-sans);
  font-size: var(--text-body);
  color: var(--ink);
}
.wizard-stat-row span {
  font-family: var(--font-mono);
  font-size: var(--text-label);
  color: var(--ink3);
  letter-spacing: 0.04em;
}

/* Navigation row */
.wizard-nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--cream2);
}
.wizard-nav--back { justify-content: space-between; }

.wizard-primary-btn {
  padding: 11px 24px;
  background: var(--ink);
  color: var(--cream);
  border: none;
  font-family: var(--font-mono);
  font-size: var(--text-label);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: opacity 0.15s;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.wizard-primary-btn:hover    { opacity: 0.85; }
.wizard-primary-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.wizard-primary-btn--full    { width: 100%; }
.wizard-primary-btn i[data-lucide] { width: 1em; height: 1em; stroke-width: 1.75; flex-shrink: 0; }
#wizard-train-btn { font-size: var(--text-small); }

.wizard-secondary-btn {
  padding: 11px 24px;
  background: transparent;
  color: var(--ink3);
  border: 1px solid var(--cream3);
  font-family: var(--font-mono);
  font-size: var(--text-label);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 0.15s;
}
.wizard-secondary-btn:hover { border-color: var(--ink3); }

.wizard-skip-btn {
  background: none;
  border: none;
  color: var(--ink4);
  font-family: var(--font-mono);
  font-size: var(--text-label);
  letter-spacing: 0.06em;
  cursor: pointer;
  padding: 0;
  transition: color 0.15s;
}
.wizard-skip-btn:hover { color: var(--ink3); }

.wizard-back-btn {
  background: none;
  border: none;
  color: var(--ink3);
  font-family: var(--font-mono);
  font-size: var(--text-label);
  letter-spacing: 0.06em;
  cursor: pointer;
  padding: 0;
  transition: color 0.15s;
}
.wizard-back-btn:hover { color: var(--ink); }

/* ─────────────────────────────────────────
  Settings page
───────────────────────────────────────── */
.settings-grid {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 760px;
}

/* Mirror int-card */
.settings-section {
  border: 1px solid var(--cream3);
  padding: 36px;
  background: var(--cream);
}

.settings-danger {
  border-color: rgba(139, 46, 46, 0.2);
}

/* Mirror int-card-header + int-section-label */
.settings-section-header {
  margin-bottom: 28px;
}

.settings-section-title {
  font-family: var(--font-mono);
  font-size: var(--text-label);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink4);
  margin: 0 0 20px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--cream3);
}

.settings-danger-title { color: var(--red); }

.settings-section-sub {
  display: none; /* sub text now lives as int-hint inline */
}

.settings-field {
  padding: 16px 0;
  border-bottom: 1px solid var(--cream2);
}
.settings-field:last-child  { border-bottom: none; padding-bottom: 0; }
.settings-field:first-child { padding-top: 0; }

/* Mirror .field label */
.settings-label {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--text-caption);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink3);
  margin-bottom: 10px;
}

.settings-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Mirror .field input — bottom border only */
.settings-input {
  flex: 1;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--parchment);
  padding: 10px 0;
  font-family: var(--font-sans);
  font-size: var(--text-body-lg);
  font-weight: 300;
  color: var(--ink);
  outline: none;
  transition: border-color 0.3s;
  min-width: 0;
}
.settings-input:focus        { border-bottom-color: var(--gold); }
.settings-input--loading     {
  background: linear-gradient(90deg, var(--cream2) 25%, var(--cream3) 50%, var(--cream2) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
  pointer-events: none;
}
.settings-input[readonly]    { color: var(--ink3); cursor: default; }
.settings-input::placeholder { color: var(--ink4); }
.settings-input--narrow      { flex: none; width: 100px; }

.settings-pw-fields {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 4px;
}

/* Mirror .panel-action.pa-primary */
.settings-save-btn {
  flex-shrink: 0;
  padding: 11px 20px;
  background: var(--ink);
  color: var(--cream);
  border: none;
  font-family: var(--font-mono);
  font-size: var(--text-caption);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: opacity 0.2s;
  white-space: nowrap;
}
.settings-save-btn:hover    { opacity: 0.8; }
.settings-save-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Mirror .panel-action.pa-secondary */
.settings-cancel-btn {
  padding: 11px 20px;
  background: transparent;
  color: var(--ink3);
  border: 1px solid var(--parchment);
  font-family: var(--font-mono);
  font-size: var(--text-caption);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.settings-cancel-btn:hover { border-color: var(--gold); color: var(--ink); }

.settings-link-btn {
  background: none;
  border: none;
  color: var(--ink3);
  font-family: var(--font-mono);
  font-size: var(--text-caption);
  letter-spacing: 0.08em;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 0;
  flex-shrink: 0;
  transition: color 0.2s;
}
.settings-link-btn:hover { color: var(--ink); }

/* Mirror .int-card-sub value display */
.settings-value {
  font-family: var(--font-sans);
  font-size: var(--text-body-lg);
  font-weight: 300;
  color: var(--ink3);
}

/* Mirror .int-hint */
.settings-hint {
  font-size: var(--text-body);
  font-weight: 300;
  color: var(--ink3);
  margin: 8px 0 0;
  line-height: 1.6;
  display: block;
}

.settings-badge {
  flex-shrink: 0;
  padding: 3px 10px;
  background: color-mix(in srgb, var(--sage) 20%, transparent);
  color: var(--sage);
  font-family: var(--font-mono);
  font-size: var(--text-label);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.settings-plan-badge {
  padding: 3px 10px;
  background: var(--cream2);
  font-family: var(--font-mono);
  font-size: var(--text-label);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink);
}

.settings-threshold-row {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  align-items: center;
}

.settings-threshold-field {
  display: flex;
  align-items: center;
  gap: 12px;
}

.settings-threshold-label {
  font-family: var(--font-mono);
  font-size: var(--text-caption);
  color: var(--ink3);
  white-space: nowrap;
}

/* Mirror .panel-action.pa-danger */
.settings-danger-btn {
  margin-top: 4px;
  padding: 11px 20px;
  background: transparent;
  border: 1px solid rgba(139, 46, 46, 0.2);
  color: var(--red);
  font-family: var(--font-mono);
  font-size: var(--text-caption);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s;
}
.settings-danger-btn:hover {
  background: var(--red-bg);
}

.settings-error {
  font-family: var(--font-mono);
  font-size: var(--text-caption);
  color: var(--red);
  margin-top: 10px;
  letter-spacing: 0.04em;
  line-height: 1.5;
}

/* ─────────────────────────────────────────
  OTP verification screen
───────────────────────────────────────── */

.otp-inputs {
  display: flex;
  gap: 10px;
  margin: 28px 0 8px;
  justify-content: center;
}

.otp-digit {
  width: 46px;
  height: 56px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 500;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--cream3);
  outline: none;
  caret-color: transparent;
  transition: border-color 0.2s, background 0.2s;
  /* Remove browser spinner on number inputs */
  -moz-appearance: textfield;
  appearance: textfield;
}
.otp-digit::-webkit-inner-spin-button,
.otp-digit::-webkit-outer-spin-button { display: none; }

.otp-digit:focus {
  border-color: var(--ink);
  background: var(--cream2);
}

.otp-digit.otp-filled {
  border-color: var(--sage);
  background: var(--cream2);
}

.otp-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 20px;
  font-family: var(--font-mono);
  font-size: var(--text-label);
  letter-spacing: 0.06em;
  color: var(--ink3);
}

.otp-resend-btn {
  background: none;
  border: none;
  font-family: var(--font-mono);
  font-size: var(--text-label);
  letter-spacing: 0.06em;
  color: var(--ink);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  padding: 0;
  transition: opacity 0.15s;
}
.otp-resend-btn:disabled {
  color: var(--ink3);
  text-decoration: none;
  cursor: default;
}

.otp-back-btn {
  background: none;
  border: none;
  font-family: var(--font-mono);
  font-size: var(--text-label);
  letter-spacing: 0.06em;
  color: var(--ink3);
  cursor: pointer;
  padding: 0;
  transition: color 0.15s;
}
.otp-back-btn:hover { color: var(--ink); }

/* Smooth theme transition */
body, .sidebar, .main, .stat-card, .tbl-wrap, table,
.detail-panel, .model-strip, .int-card, .meta-cell,
.upload-area, .toast-item, .login-wrap, #login-screen {
  transition: background 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* ═══════════════════════════════════════════════════════════════
   21. Type scale application
   Maps every component to a named tier from the --text-* scale
   defined in Section 1. No !important needed — cascade order
   (later in file = higher priority at equal specificity) ensures
   these values win over the per-component declarations above.

   Fluid tiers (--text-h3 and up) automatically scale between
   min and max values using clamp() as viewport width changes.
═══════════════════════════════════════════════════════════════ */

/* ── LABEL tier (9px) — mono uppercase micro-labels ─────── */
.stat-eyebrow, .nav-label, .logo-eyebrow, .panel-eyebrow,
.panel-section-title, .meta-cell-label, .int-section-label,
.strip-btn, .logout-btn                        { font-size: var(--text-label); }

/* Colour overrides that belong with the label tier */
.stat-eyebrow      { color: var(--ink3); letter-spacing: 0.12em; }
.panel-eyebrow     { color: var(--ink4); }
.panel-section-title, .meta-cell-label,
.int-section-label { color: var(--ink3); }

/* Strip button and logout sizing */
.strip-btn  { padding: 8px 16px; }

/* ── CAPTION tier (11px) — secondary / supporting text ───── */
.stat-eyebrow ~ *, .panel-score-label, .fi-pct,
.upload-sub, .auth-toggle-btn, .ftab,
.panel-action, .field label                    { font-size: var(--text-caption); }

/* Selective colour overrides for caption tier */
.panel-score-label, .upload-sub { color: var(--ink3); }

/* Layout overrides that belong with caption elements */
.ftab         { padding: 7px 16px; }
.panel-action { padding: 15px 20px; }
.field label  { letter-spacing: 0.12em; text-transform: uppercase; }

/* ── SMALL tier (12px) — helper text, badge labels ─────── */
.co-meta, .csv-col-name, .csv-col-desc,
.login-btn                                     { font-size: var(--text-small); }
.login-btn { padding: 18px; }

/* Code block — not uppercase so uses small but no tracking */
.code-block pre { font-size: 12.5px; letter-spacing: 0; text-transform: none; }

/* ── BODY tier (13px) — primary body and descriptions ───── */
.stat-sub, .last-login, .factor-tag, .step-desc,
.model-strip, #model-status-text               { font-size: var(--text-body); }
.stat-sub { color: var(--ink3); }

/* ── BODY-LG tier (15px) — emphasized body ──────────────── */
.int-card-sub, .step-title, .upload-label,
.login-sub, .tenant-name                       { font-size: var(--text-body-lg); }
.login-sub { color: var(--ink3); }

/* ── UI tier (16px) — form inputs ───────────────────────── */
.field input { font-size: var(--text-ui); }

/* ── 14px — table cells and hints (between body and body-lg) */
td, .fi-label, .int-hint, .nav-item, .page-sub,
.snum                                          { font-size: 14px; }
.page-sub { color: var(--ink3); }

/* ── H4 tier (18px) — card titles, data callouts ────────── */
.co-name, .mrr-val, .meta-cell-val             { font-size: var(--text-h4); }

/* ── H3 tier (clamp 20–26px) — section headings ─────────── */
.section-title, .logo-name                     { font-size: var(--text-h3); }
.logo-name     { font-size: var(--text-h3); }

/* ── H2 tier (clamp 24–32px) — panel and card titles ─────── */
.panel-company, .int-card-title                { font-size: var(--text-h2); }

/* ── H1 tier (clamp 28–44px) — page titles ─────────────── */
.page-title                                    { font-size: var(--text-h1); }

/* ── DISPLAY tier (clamp 34–48px) — stat values & login ── */
.stat-value, .login-title                      { font-size: var(--text-display); }

/* ── HERO tier (clamp 56–80px) — ghost watermark only ───── */
.stat-card::after                              { font-size: var(--text-hero); }

/* Table header colours */
thead th { font-size: var(--text-caption); color: var(--ink3); }

/* ═══════════════════════════════════════════════════════════════
   22. Code block dark mode fix
═══════════════════════════════════════════════════════════════ */

/* Light mode — dark background, gold text (already good) */
.code-block {
  background: #1a1610;
  border: 1px solid rgba(201,168,76,0.15);
}

.code-block pre { color: #e8c97a; }

/* The API-key recovery message (.int-hint) is rendered inside this same
   dark .code-block when state.apiKey is missing — without this, it
   inherits the default .int-hint color meant for the light cream
   background elsewhere on the page, which is nearly invisible against
   this near-black background. Match it to the code text color instead. */
.code-block .int-hint { color: #e8c97a; }

/* Buttons inside .code-block (e.g. "Generate new key" in the API-key
   recovery state) need their own style — the default .int-action-btn
   background is var(--ink), which in light mode is the EXACT same hex
   (#1a1610) as this block's background, making the button completely
   invisible against it (it only happened to look okay in dark mode,
   where --ink flips to a light color — not something to rely on).
   Gold-bordered, transparent fill, matches the existing .code-copy-btn
   treatment already used in this same dark context. */
.code-block .int-action-btn {
  background: transparent;
  border: 1px solid rgba(232,201,122,0.45);
  color: #e8c97a;
}

.code-block .int-action-btn:hover {
  background: rgba(232,201,122,0.12);
  border-color: rgba(232,201,122,0.8);
}

.code-block .int-action-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.code-copy-btn {
  color: rgba(232,201,122,0.6);
  border-color: rgba(232,201,122,0.2);
}

.code-copy-btn:hover {
  color: #e8c97a;
  border-color: rgba(232,201,122,0.5);
  background: rgba(232,201,122,0.08);
}

/* Dark mode — even deeper background, brighter text */
[data-theme="dark"] .code-block {
  background: #0d0b09;
  border: 1px solid rgba(201,168,76,0.2);
}

[data-theme="dark"] .code-block pre { color: #f0d98a; }
[data-theme="dark"] .code-block .int-hint { color: #f0d98a; }

[data-theme="dark"] .code-copy-btn {
  color: rgba(240,217,138,0.5);
  border-color: rgba(240,217,138,0.2);
}

[data-theme="dark"] .code-copy-btn:hover {
  color: #f0d98a;
  border-color: rgba(240,217,138,0.5);
  background: rgba(240,217,138,0.06);
}

/* Inline code tag */
.int-hint code {
  background: rgba(201,168,76,0.1);
  border-color: rgba(201,168,76,0.2);
  color: var(--gold);
}

[data-theme="dark"] .int-hint code {
  background: rgba(201,168,76,0.08);
  border-color: rgba(201,168,76,0.15);
  color: var(--gold2);
}

/* Event tags in Stripe section */
.event-tag {
  background: rgba(201,168,76,0.08);
  border-color: rgba(201,168,76,0.2);
  color: var(--gold);
}

[data-theme="dark"] .event-tag {
  background: rgba(201,168,76,0.06);
  color: var(--gold2);
}


/* ═══════════════════════════════════════════════════════════════
   23. Light mode depth fixes
═══════════════════════════════════════════════════════════════ */

/* Richer body background in light mode */
body { background: var(--cream2); }

/* Sidebar slightly darker than main */
.sidebar { background: var(--cream); }

/* Main content area */
.main { background: var(--cream2); }

/* Stat cards stand out from background */
.stat-card { background: var(--cream); box-shadow: 0 1px 4px rgba(26,22,16,0.08); }
.stat-card:hover { background: var(--cream2); }

/* Table header darker */
thead { background: var(--cream3) !important; }

/* Table wrap has slight shadow */
.tbl-wrap { box-shadow: 0 2px 8px rgba(26,22,16,0.06); }

/* Model strip */
.model-strip { background: var(--cream); }

/* Login screen */
#login-screen,
#otp-screen,
#forgot-screen { background: var(--cream2); }

/* Detail panel */
.detail-panel { background: var(--cream); }

/* Int card */
.int-card { background: var(--cream); }

/* Meta cells */
.meta-cell { background: var(--cream2); }

/* Upload area */
.upload-area { background: var(--cream); }

/* Nav items hover */
.nav-item:hover { background: var(--cream3); }
.nav-item.active { background: var(--cream3); }

/* Page header border */
.page-header { border-bottom-color: var(--cream3); }

/* Auth toggle border */
.auth-toggle { border-color: var(--cream3); }

/* Login button stays sharp */
.login-btn { background: var(--ink); color: var(--cream); }

/* Int tabs border */
.int-tabs { border-color: var(--cream3); }

/* Section row */
.section-row { border-bottom: none; }

/* Sidebar footer border */
.sidebar-footer { border-color: var(--cream3); }
.sidebar-logo { border-color: var(--cream3); }

/* ─────────────────────────────────────────
   ACCESSIBILITY FIXES (WCAG 2.1 AA)
───────────────────────────────────────── */

/* Fix 1: Visible focus styles for all interactive elements */
:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
  border-radius: var(--radius);
}

/* Override the two outline:none rules with proper focus-visible */
.field input:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-color: var(--gold);
}

.auth-toggle-btn:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* Fix 2: Skip link — hidden until focused */
.skip-link {
  position: fixed;
  top: -9999px;
  left: -9999px;
  z-index: 9999;
  background: var(--ink);
  color: var(--cream);
  padding: 10px 18px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-decoration: none;
  border-radius: var(--radius);
  transition: none;
}
.skip-link:focus {
  top: 16px;
  left: 16px;
}

/* Fix 5: Respect reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Fix 11: Brand name italic span (not semantic em) */
.brand-em { font-style: italic; }

/* Fix 2: nav-item buttons — reset button defaults, match original div appearance */
button.nav-item {
  display: flex;
  align-items: center;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  font-family: var(--font-sans);
  font-size: inherit;
  color: inherit;
  cursor: pointer;
}

/* ─── Lucide Icons ─────────────────────────────────────────────────────────── */
.nav-icon {
  width: 14px;
  height: 14px;
  stroke-width: 1.25;
  vertical-align: middle;
  margin-right: 2px;
  margin-top: -1px;
  flex-shrink: 0;
}

/* ─── Skeleton loading states ──────────────────────────────────────────────── */
@keyframes skeleton-shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position:  400px 0; }
}

.skeleton-line {
  background: linear-gradient(
    90deg,
    var(--surface-2) 25%,
    var(--surface-3, #e8e4d9) 50%,
    var(--surface-2) 75%
  );
  background-size: 800px 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
  border-radius: 4px;
  display: block;
}

.skeleton-line.sk-title  { height: 14px; width: 55%; margin-bottom: 10px; }
.skeleton-line.sk-value  { height: 32px; width: 40%; margin-bottom: 8px; }
.skeleton-line.sk-sub    { height: 11px; width: 70%; }
.skeleton-line.sk-cell   { height: 14px; width: 80%; }
.skeleton-line.sk-badge  { height: 22px; width: 60px; border-radius: 12px; }
.skeleton-line.sk-bar    { height: 6px;  width: 100%; border-radius: 3px; }

.skeleton-row td { padding: 14px 16px; }

.stat-card.skeleton-card {
  pointer-events: none;
}

/* ── Load More pagination button ── */
.load-more-btn {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 14px 20px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  background: transparent;
  border: 1px solid var(--parchment);
  color: var(--ink3);
  cursor: pointer;
  transition: all 0.2s;
}
.load-more-btn:hover:not(:disabled) {
  border-color: var(--gold);
  color: var(--ink);
}
.load-more-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Back to Top button ── */
.back-to-top-btn {
  position: fixed;
  bottom: 32px;
  right: 32px;
  padding: 10px 16px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: var(--ink);
  color: var(--cream);
  border: none;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 999;
}
.back-to-top-btn.visible {
  opacity: 1;
  pointer-events: auto;
}
.back-to-top-btn.page-disabled {
  display: none !important;
}

.back-to-top-btn:hover {
  background: var(--ink2);
}