/* ──────────────────────────────────────────────────────────────────────────
   SaaS Platform — Design System
   Refined minimalism · Off-white + Acid Lime · Light/Dark
   ────────────────────────────────────────────────────────────────────────── */

/* ── Typography: Geist Sans + Geist Mono via Google Fonts ─────────────── */
@import url('https://fonts.googleapis.com/css2?family=Geist:wght@300;400;500;600;700&family=Geist+Mono:wght@400;500&display=swap');

/* ── Design tokens ────────────────────────────────────────────────────── */
:root {
  /* Surfaces */
  --bg:           #FAFAF6;
  --bg-elevated:  #FFFFFF;
  --bg-subtle:    #F2F0EA;
  --bg-overlay:   rgba(15, 15, 14, 0.5);

  /* Foreground */
  --text:         #1A1A1A;
  --text-muted:   #6B6B6B;
  --text-subtle:  #9A9A9A;
  --text-inverse: #FAFAF6;

  /* Borders */
  --border:        #E8E5DD;
  --border-strong: #D4D0C5;
  --border-focus:  #1A1A1A;

  /* Accent — acid lime */
  --accent:       #C5F23E;
  --accent-hover: #B3DE2E;
  --accent-active:#A5CE25;
  --accent-text:  #0F1300;
  --accent-subtle:#F0FBC5;

  /* Semantic */
  --danger:     #E04220;
  --danger-bg:  #FDE8E2;
  --danger-text:#7A1F0E;

  --success:    #1F9D55;
  --success-bg: #E2F5EA;
  --success-text:#0E5A2E;

  --warning:    #B8730A;
  --warning-bg: #FBEFD3;
  --warning-text:#7A4A06;

  --info:       #1F6FB8;
  --info-bg:    #E1EEFA;
  --info-text:  #0E4378;

  /* Shadows — Stripe-style soft */
  --shadow-xs: 0 1px 1px rgba(15, 15, 14, 0.04);
  --shadow-sm: 0 1px 2px rgba(15, 15, 14, 0.06), 0 1px 1px rgba(15, 15, 14, 0.04);
  --shadow:    0 2px 8px rgba(15, 15, 14, 0.06), 0 1px 2px rgba(15, 15, 14, 0.04);
  --shadow-lg: 0 12px 32px rgba(15, 15, 14, 0.08), 0 4px 8px rgba(15, 15, 14, 0.04);
  --shadow-xl: 0 24px 48px rgba(15, 15, 14, 0.12), 0 8px 16px rgba(15, 15, 14, 0.06);

  /* Type scale */
  --font-sans: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, 'SF Mono', Monaco, Consolas, monospace;

  --text-xs:    0.75rem;   /* 12 */
  --text-sm:    0.8125rem; /* 13 */
  --text-base:  0.9375rem; /* 15 */
  --text-md:    1rem;      /* 16 */
  --text-lg:    1.125rem;  /* 18 */
  --text-xl:    1.375rem;  /* 22 */
  --text-2xl:   1.75rem;   /* 28 */
  --text-3xl:   2.25rem;   /* 36 */

  --leading-tight: 1.2;
  --leading-snug:  1.4;
  --leading:       1.55;

  --tracking-tight: -0.02em;
  --tracking:        0;
  --tracking-wide:   0.04em;

  /* Spacing scale (4-base) */
  --space-0_5: 0.125rem; /* 2  */
  --space-1:   0.25rem;  /* 4  */
  --space-1_5: 0.375rem; /* 6  */
  --space-2:   0.5rem;   /* 8  */
  --space-3:   0.75rem;  /* 12 */
  --space-4:   1rem;     /* 16 */
  --space-5:   1.25rem;  /* 20 */
  --space-6:   1.5rem;   /* 24 */
  --space-8:   2rem;     /* 32 */
  --space-10:  2.5rem;   /* 40 */
  --space-12:  3rem;     /* 48 */
  --space-16:  4rem;     /* 64 */

  /* Radii */
  --radius-xs:  3px;
  --radius-sm:  6px;
  --radius:     8px;
  --radius-lg:  12px;
  --radius-xl:  16px;
  --radius-full:9999px;

  /* Layout */
  --sidebar-w:  248px;
  --topbar-h:   56px;
  --content-max:1120px;

  /* Motion */
  --ease:   cubic-bezier(0.32, 0.72, 0, 1);
  --dur:    150ms;
  --dur-md: 220ms;
}

/* ── Dark theme ───────────────────────────────────────────────────────── */
[data-theme="dark"] {
  --bg:           #0F0F0E;
  --bg-elevated:  #18181A;
  --bg-subtle:    #1F1F22;
  --bg-overlay:   rgba(0, 0, 0, 0.65);

  --text:         #F0EFE9;
  --text-muted:   #9A9A93;
  --text-subtle:  #5C5C56;
  --text-inverse: #0F0F0E;

  --border:        #2A2826;
  --border-strong: #3A3833;
  --border-focus:  #F0EFE9;

  --accent:        #C5F23E;
  --accent-hover:  #D5FF55;
  --accent-active: #B3DE2E;
  --accent-text:   #0F1300;
  --accent-subtle: #2C3A09;

  --danger-bg:   #2C1410;
  --danger-text: #FDA28E;
  --success-bg:  #0E2A18;
  --success-text:#7DD89E;
  --warning-bg:  #2A1F0A;
  --warning-text:#F4C674;
  --info-bg:     #0E1F32;
  --info-text:   #88B7E8;

  --shadow-xs: 0 1px 1px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5), 0 1px 1px rgba(0, 0, 0, 0.3);
  --shadow:    0 2px 8px rgba(0, 0, 0, 0.5), 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.6), 0 4px 8px rgba(0, 0, 0, 0.3);
  --shadow-xl: 0 24px 48px rgba(0, 0, 0, 0.7), 0 8px 16px rgba(0, 0, 0, 0.4);
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv11', 'ss01', 'ss03';

  /* Subtle grain texture for light theme — atmosphere without noise */
  background-image:
    radial-gradient(at 12% 18%, rgba(197, 242, 62, 0.04) 0%, transparent 40%),
    radial-gradient(at 90% 80%, rgba(26, 26, 26, 0.02) 0%, transparent 50%);
  background-attachment: fixed;
  min-height: 100vh;
}

[data-theme="dark"] body {
  background-image:
    radial-gradient(at 12% 18%, rgba(197, 242, 62, 0.06) 0%, transparent 35%),
    radial-gradient(at 90% 80%, rgba(255, 255, 255, 0.02) 0%, transparent 50%);
}

img, svg, video { display: block; max-width: 100%; }
input, button, textarea, select { font: inherit; color: inherit; }
button { background: none; border: none; cursor: pointer; }
a { color: inherit; text-decoration: none; }

::selection { background: var(--accent); color: var(--accent-text); }

/* ── Typography ───────────────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-sans);
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-tight);
  color: var(--text);
}

h1 { font-size: var(--text-3xl); font-weight: 600; }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }
h5 { font-size: var(--text-md); }
h6 { font-size: var(--text-sm); text-transform: uppercase; letter-spacing: var(--tracking-wide); color: var(--text-muted); }

p { line-height: var(--leading); }
.muted     { color: var(--text-muted); }
.subtle    { color: var(--text-subtle); }
.strong    { font-weight: 600; }
.mono      { font-family: var(--font-mono); font-feature-settings: 'tnum' 1; }
.uppercase { text-transform: uppercase; letter-spacing: var(--tracking-wide); font-weight: 500; font-size: var(--text-xs); color: var(--text-muted); }
.tnum      { font-feature-settings: 'tnum' 1; }

.eyebrow {
  display: inline-block;
  font-size: var(--text-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}

a.link {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--border-strong);
  transition: text-decoration-color var(--dur) var(--ease);
}
a.link:hover { text-decoration-color: var(--text); }

/* ── Layout primitives ────────────────────────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: var(--space-5) 0;
  overflow-y: auto;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0 var(--space-5) var(--space-5);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-4);
}

.sidebar__logo {
  width: 28px;
  height: 28px;
  background: var(--text);
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  color: var(--bg);
  font-weight: 700;
  font-size: var(--text-base);
  letter-spacing: -0.04em;
}

.sidebar__brand-text {
  font-weight: 600;
  font-size: var(--text-md);
  letter-spacing: var(--tracking-tight);
}

.sidebar__tenant {
  padding: var(--space-3) var(--space-5);
  margin-bottom: var(--space-4);
}

.sidebar__tenant-label {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--text-subtle);
  margin-bottom: var(--space-1);
}

.sidebar__tenant-name {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar__nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-0_5);
  padding: 0 var(--space-3);
}

.sidebar__group-label {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--text-subtle);
  padding: var(--space-3) var(--space-3) var(--space-2);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  color: var(--text-muted);
  font-weight: 500;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}

.nav-item:hover {
  background: var(--bg-subtle);
  color: var(--text);
}

.nav-item[aria-current="page"] {
  background: var(--bg-subtle);
  color: var(--text);
  font-weight: 600;
  position: relative;
}

.nav-item[aria-current="page"]::before {
  content: '';
  position: absolute;
  left: -2px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 16px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

.nav-item__icon {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  opacity: 0.85;
}

.sidebar__footer {
  padding: var(--space-3) var(--space-3);
  border-top: 1px solid var(--border);
  margin-top: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.theme-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  color: var(--text-muted);
  font-weight: 500;
  width: 100%;
  text-align: left;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.theme-toggle:hover { background: var(--bg-subtle); color: var(--text); }

.theme-toggle__icon { width: 18px; height: 18px; }
[data-theme="light"] .theme-toggle__icon--moon { display: block; }
[data-theme="light"] .theme-toggle__icon--sun  { display: none; }
[data-theme="dark"]  .theme-toggle__icon--moon { display: none; }
[data-theme="dark"]  .theme-toggle__icon--sun  { display: block; }

/* Logout form sits inline with nav items */
.sidebar__logout-form { width: 100%; }
.sidebar__logout {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  color: var(--text-muted);
  font-weight: 500;
  width: 100%;
  text-align: left;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.sidebar__logout:hover { background: var(--bg-subtle); color: var(--danger); }

/* ── Main content area ────────────────────────────────────────────────── */
.main {
  min-width: 0; /* prevent grid blowout */
  padding: var(--space-8) var(--space-8);
  max-width: 100%;
}

.main__inner {
  max-width: var(--content-max);
  margin: 0 auto;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-6);
  margin-bottom: var(--space-8);
  padding-bottom: var(--space-5);
  border-bottom: 1px solid var(--border);
}

.page-head__title { font-size: var(--text-3xl); margin-bottom: var(--space-1); }
.page-head__sub   { color: var(--text-muted); font-size: var(--text-md); }
.page-head__actions { display: flex; gap: var(--space-2); flex-shrink: 0; }

/* Centered (auth/onboarding/404) layout — no sidebar.
   .auth-shell is the page-level container; max-width is set by inner card
   (.auth-card = 420px, .wizard = 720px), so the same wrapper works for both. */
.main--centered {
  padding: var(--space-6);
  display: grid;
  place-items: center;
  min-height: 100vh;
  width: 100%;
}

.main--centered .auth-shell {
  width: 100%;
  display: flex;
  justify-content: center;
}

.full-bleed { /* legacy fallback for hide_sidebar */
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: var(--space-6);
}

/* ── Cards ────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-xs);
}

.card--elevated { box-shadow: var(--shadow); }
.card--accent {
  background: linear-gradient(135deg, var(--accent-subtle) 0%, var(--bg-elevated) 60%);
  border-color: var(--accent);
}

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.card__title { font-size: var(--text-lg); font-weight: 600; }
.card__sub   { color: var(--text-muted); font-size: var(--text-sm); margin-top: var(--space-1); }
.card__body  { display: flex; flex-direction: column; gap: var(--space-4); }
.card__foot  {
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
}

/* ── Buttons ──────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0 var(--space-4);
  height: 38px;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: -0.005em;
  transition: background var(--dur) var(--ease), transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
  cursor: pointer;
  border: 1px solid transparent;
  white-space: nowrap;
  user-select: none;
}

.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; }

.btn--primary {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}
.btn--primary:hover:not(:disabled) { background: #2A2A2A; }
[data-theme="dark"] .btn--primary:hover:not(:disabled) { background: #DAD9D2; }

.btn--accent {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
  box-shadow: 0 1px 0 rgba(0,0,0,0.04), inset 0 0 0 1px rgba(255,255,255,0.3);
}
.btn--accent:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn--accent:active:not(:disabled) { background: var(--accent-active); }

.btn--ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn--ghost:hover:not(:disabled) { background: var(--bg-subtle); border-color: var(--border-strong); }

.btn--subtle {
  background: var(--bg-subtle);
  color: var(--text);
  border-color: transparent;
}
.btn--subtle:hover:not(:disabled) { background: var(--border); }

.btn--danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--border);
}
.btn--danger:hover:not(:disabled) { background: var(--danger-bg); color: var(--danger-text); border-color: var(--danger); }

.btn--lg { height: 44px; padding: 0 var(--space-5); font-size: var(--text-md); }
.btn--sm { height: 30px; padding: 0 var(--space-3); font-size: var(--text-xs); }
.btn--icon { width: 38px; padding: 0; }
.btn--icon.btn--sm { width: 30px; }
.btn--full { width: 100%; }

.btn__icon { width: 16px; height: 16px; flex: 0 0 16px; }

/* ── Forms ────────────────────────────────────────────────────────────── */
.form { display: flex; flex-direction: column; gap: var(--space-4); }

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1_5);
}

.field__label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.field__hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.field__error {
  font-size: var(--text-xs);
  color: var(--danger-text);
}

.field--inline { flex-direction: row; align-items: center; gap: var(--space-3); }

.input, .select, .textarea {
  width: 100%;
  padding: 0 var(--space-3);
  height: 38px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  color: var(--text);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background var(--dur) var(--ease);
  font-family: var(--font-sans);
}

.input::placeholder, .textarea::placeholder { color: var(--text-subtle); }

.input:hover, .select:hover, .textarea:hover {
  border-color: var(--text-muted);
}

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

.textarea {
  height: auto;
  min-height: 96px;
  padding: var(--space-3);
  line-height: var(--leading);
  resize: vertical;
}

.input--mono { font-family: var(--font-mono); font-size: var(--text-sm); }
.input--lg   { height: 44px; font-size: var(--text-md); }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
}
.checkbox-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ── Alerts / Flash ───────────────────────────────────────────────────── */
.flash, .alert {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  border: 1px solid transparent;
  line-height: var(--leading-snug);
}

.flash__icon, .alert__icon {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  margin-top: 1px;
}

.flash--error, .flash-error, .alert--error {
  background: var(--danger-bg);
  color: var(--danger-text);
  border-color: rgba(224, 66, 32, 0.25);
}

.flash--ok, .flash-ok, .alert--success {
  background: var(--success-bg);
  color: var(--success-text);
  border-color: rgba(31, 157, 85, 0.25);
}

.flash--warn, .alert--warning {
  background: var(--warning-bg);
  color: var(--warning-text);
  border-color: rgba(184, 115, 10, 0.25);
}

.flash--info, .alert--info {
  background: var(--info-bg);
  color: var(--info-text);
  border-color: rgba(31, 111, 184, 0.25);
}

/* ── Badges / Pills ───────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  font-size: var(--text-xs);
  font-weight: 500;
  border-radius: var(--radius-full);
  background: var(--bg-subtle);
  color: var(--text-muted);
  border: 1px solid var(--border);
  letter-spacing: 0.01em;
}

.badge--accent  { background: var(--accent-subtle); color: var(--accent-text); border-color: var(--accent); }
.badge--success { background: var(--success-bg);    color: var(--success-text); border-color: rgba(31,157,85,0.2); }
.badge--danger  { background: var(--danger-bg);     color: var(--danger-text);  border-color: rgba(224,66,32,0.2); }
.badge--warn    { background: var(--warning-bg);    color: var(--warning-text); border-color: rgba(184,115,10,0.2); }

.dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  display: inline-block;
}
.dot--accent  { background: var(--accent); }
.dot--success { background: var(--success); }
.dot--danger  { background: var(--danger); }
.dot--warn    { background: var(--warning); }
.dot--muted   { background: var(--text-subtle); }

/* ── Tables ───────────────────────────────────────────────────────────── */
.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-elevated);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.table th, .table td {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  vertical-align: middle;
}

.table th {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--text-muted);
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
}

.table td  { border-bottom: 1px solid var(--border); }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: var(--bg-subtle); }

.table .num { font-family: var(--font-mono); font-feature-settings: 'tnum' 1; text-align: right; }

/* ── Progress ─────────────────────────────────────────────────────────── */
.progress {
  height: 6px;
  background: var(--bg-subtle);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}

.progress__bar {
  height: 100%;
  background: var(--accent);
  border-radius: var(--radius-full);
  transition: width var(--dur-md) var(--ease);
}

.progress--warn .progress__bar { background: var(--warning); }
.progress--danger .progress__bar { background: var(--danger); }

/* ── Demo banner (legacy markup compat) ───────────────────────────────── */
.demo-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  background: var(--accent-subtle);
  color: var(--accent-text);
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-weight: 500;
  border-bottom: 1px solid var(--accent);
  position: sticky;
  top: 0;
  z-index: 10;
}
.demo-banner__cta {
  background: var(--text);
  color: var(--bg);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: var(--text-xs);
}
.demo-banner__cta:hover { background: var(--text-muted); color: var(--bg); }

/* ── Wizard / Stepper ─────────────────────────────────────────────────── */
.wizard {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 760px;
  padding: var(--space-8);
}

.wizard__head {
  margin-bottom: var(--space-8);
}

.wizard__progress {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-6);
  list-style: none;
}

.wizard__step {
  flex: 1;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--text-subtle);
  font-weight: 500;
  position: relative;
  min-width: 0;
}

.wizard__step:not(:last-child)::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
  margin: 0 var(--space-2);
}

.wizard__step-num {
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  border-radius: var(--radius-full);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  display: grid;
  place-items: center;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
}

.wizard__step--done .wizard__step-num {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}
.wizard__step--done { color: var(--text); }
.wizard__step--done:not(:last-child)::after { background: var(--text); }

.wizard__step--active .wizard__step-num {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-subtle);
}
.wizard__step--active { color: var(--text); font-weight: 600; }

.wizard__title {
  font-size: var(--text-3xl);
  margin-bottom: var(--space-2);
}

.wizard__sub {
  color: var(--text-muted);
  font-size: var(--text-md);
}

.wizard__body { margin-bottom: var(--space-6); }

.wizard__nav {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  padding-top: var(--space-5);
  border-top: 1px solid var(--border);
}

/* ── Stat boxes ───────────────────────────────────────────────────────── */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.stat {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  position: relative;
  overflow: hidden;
}

.stat__label {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--text-muted);
  font-weight: 500;
}

.stat__value {
  font-size: var(--text-3xl);
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
  font-feature-settings: 'tnum' 1;
  line-height: 1;
}

.stat__sub {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.stat--featured {
  background: linear-gradient(135deg, var(--accent-subtle) 0%, var(--bg-elevated) 70%);
  border-color: var(--accent);
}
.stat--featured::after {
  content: '';
  position: absolute;
  bottom: -32px;
  right: -32px;
  width: 96px;
  height: 96px;
  background: var(--accent);
  border-radius: var(--radius-full);
  filter: blur(36px);
  opacity: 0.5;
  pointer-events: none;
}

/* ── Checklist ────────────────────────────────────────────────────────── */
.checklist {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.checklist__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-3);
}
.checklist__title { font-size: var(--text-lg); font-weight: 600; }
.checklist__sub   { font-size: var(--text-sm); color: var(--text-muted); margin-top: 2px; }

.checklist__items {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.checklist__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  transition: background var(--dur) var(--ease);
}
.checklist__item:hover { background: var(--bg-subtle); }

.checklist__item--done { color: var(--text-muted); }
.checklist__item--done .checklist__label { text-decoration: line-through; }

.checklist__check {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  background: var(--bg-elevated);
}
.checklist__item--done .checklist__check {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.checklist__check svg { width: 12px; height: 12px; }
.checklist__item:not(.checklist__item--done) .checklist__check svg { display: none; }

.checklist__label { flex: 1; }
.checklist__action { margin-left: auto; }

/* ── Code block (for help / TTS preview) ──────────────────────────────── */
.code, code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--bg-subtle);
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  color: var(--text);
}

pre.code, pre {
  padding: var(--space-4);
  overflow-x: auto;
  line-height: var(--leading);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

pre code, pre.code code {
  background: transparent;
  border: none;
  padding: 0;
}

/* Markdown body */
.markdown-body { line-height: var(--leading); }
.markdown-body h1 { margin: var(--space-8) 0 var(--space-4); font-size: var(--text-2xl); }
.markdown-body h2 { margin: var(--space-6) 0 var(--space-3); font-size: var(--text-xl); }
.markdown-body h3 { margin: var(--space-5) 0 var(--space-2); font-size: var(--text-lg); }
.markdown-body p, .markdown-body ul, .markdown-body ol { margin: var(--space-3) 0; }
.markdown-body ul, .markdown-body ol { padding-left: var(--space-5); }
.markdown-body li { margin: var(--space-1) 0; }
.markdown-body a { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.markdown-body a:hover { text-decoration-color: var(--accent); }

/* ── DTMF grid (scenarios/edit) ───────────────────────────────────────── */
.dtmf-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-3);
}

@media (max-width: 720px) {
  .dtmf-grid { grid-template-columns: repeat(3, 1fr); }
}

.dtmf-cell {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.dtmf-cell__key {
  font-family: var(--font-mono);
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--text);
  width: 32px;
  height: 32px;
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
}

.dtmf-cell__select { font-size: var(--text-xs); }

/* ── Audio preview ────────────────────────────────────────────────────── */
.audio-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--bg-subtle);
  border-radius: var(--radius);
}
.audio-row audio { flex: 1; }

/* ── Empty states ─────────────────────────────────────────────────────── */
.empty {
  text-align: center;
  padding: var(--space-12) var(--space-6);
  color: var(--text-muted);
}
.empty__icon {
  width: 48px;
  height: 48px;
  margin: 0 auto var(--space-4);
  color: var(--text-subtle);
}
.empty__title { color: var(--text); font-size: var(--text-lg); font-weight: 600; margin-bottom: var(--space-2); }
.empty__msg { font-size: var(--text-sm); }

/* ── Auth / centered shell ────────────────────────────────────────────── */
.auth-shell {
  width: 100%;
  max-width: 420px;
}

.auth-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
}

.auth-card__brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  margin-bottom: var(--space-6);
}
.auth-card__logo {
  width: 36px;
  height: 36px;
  background: var(--text);
  color: var(--bg);
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  font-weight: 700;
  letter-spacing: -0.04em;
}
.auth-card__brand-text { font-size: var(--text-lg); font-weight: 600; }

.auth-card__title {
  font-size: var(--text-2xl);
  margin-bottom: var(--space-2);
  text-align: center;
}
.auth-card__sub {
  color: var(--text-muted);
  font-size: var(--text-sm);
  text-align: center;
  margin-bottom: var(--space-6);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.auth-footer {
  text-align: center;
  margin-top: var(--space-5);
  font-size: var(--text-sm);
  color: var(--text-muted);
}
.auth-footer a { color: var(--text); font-weight: 500; }
.auth-footer a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ── Topbar (small/responsive) ────────────────────────────────────────── */
.topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  height: var(--topbar-h);
  padding: 0 var(--space-4);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 9;
}

/* ── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 960px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-w);
    z-index: 11;
    box-shadow: var(--shadow-xl);
  }
  .sidebar[data-open="true"] { display: flex; }
  .topbar { display: flex; }
  .main { padding: var(--space-5) var(--space-4); }
  .page-head { flex-direction: column; align-items: flex-start; gap: var(--space-3); }
}

@media (max-width: 480px) {
  .auth-card { padding: var(--space-6); }
  .stats { grid-template-columns: 1fr; }
  .wizard { padding: var(--space-5) var(--space-3); }
}

/* ── Reduced motion ───────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ── Utility ──────────────────────────────────────────────────────────── */
.stack       { display: flex; flex-direction: column; gap: var(--space-3); }
.stack-sm    { display: flex; flex-direction: column; gap: var(--space-2); }
.stack-lg    { display: flex; flex-direction: column; gap: var(--space-5); }
.row         { display: flex; gap: var(--space-3); align-items: center; }
.row-tight   { display: flex; gap: var(--space-2); align-items: center; }
.row-wrap    { flex-wrap: wrap; }
.row-end     { justify-content: flex-end; }
.row-between { justify-content: space-between; }
.flex-1      { flex: 1; min-width: 0; }
.text-right  { text-align: right; }
.text-center { text-align: center; }
.hidden      { display: none !important; }

.divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-5) 0;
  border: none;
}

/* Print */
@media print {
  .sidebar, .topbar, .demo-banner { display: none; }
  .app-shell { grid-template-columns: 1fr; }
  .main { padding: 0; }
  .card, .table-wrap { box-shadow: none; border: 1px solid #999; }
}
