/* ==========================================================================
   Mailing App — admin UI
   Tokens → base → layout (sidebar shell) → components → pages → utilities
   ========================================================================== */

:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --surface-3: #f2f4f7;
  --text: #101828;
  --text-2: #344054;
  --muted: #667085;
  --faint: #98a2b3;
  --border: #e4e7ec;
  --border-strong: #d0d5dd;

  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --primary-text: #4338ca;
  --ring: rgba(79, 70, 229, .22);

  --danger: #d92d20;
  --danger-hover: #b42318;
  --danger-soft: #fef3f2;
  --danger-border: #fecdca;
  --danger-text: #b42318;

  --success: #079455;
  --success-soft: #ecfdf3;
  --success-text: #067647;
  --warning: #dc6803;
  --warning-soft: #fffaeb;
  --warning-text: #b54708;
  --info-soft: #eff8ff;
  --info-text: #175cd3;
  --neutral-soft: #f2f4f7;
  --neutral-text: #475467;

  --sidebar-bg: #0f1424;
  --sidebar-text: #a4acbf;
  --sidebar-heading: #5d6780;
  --sidebar-hover: rgba(255, 255, 255, .06);
  --sidebar-active: rgba(255, 255, 255, .10);
  --sidebar-border: rgba(255, 255, 255, .08);

  --code-bg: #0f1424;
  --code-text: #e3e8f2;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 12px 32px -8px rgba(16, 24, 40, .18);

  --sidebar-w: 248px;
  --font: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Code", "JetBrains Mono", Consolas, Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b0f19;
    --surface: #131927;
    --surface-2: #171e2e;
    --surface-3: #1c2436;
    --text: #eef1f6;
    --text-2: #cdd3df;
    --muted: #8d97ab;
    --faint: #667085;
    --border: #252e42;
    --border-strong: #333d54;
    --primary: #7170f5;
    --primary-hover: #8584ff;
    --primary-soft: rgba(113, 112, 245, .14);
    --primary-text: #a5a4ff;
    --ring: rgba(113, 112, 245, .35);
    --danger: #f04438;
    --danger-hover: #f97066;
    --danger-soft: rgba(240, 68, 56, .12);
    --danger-border: rgba(240, 68, 56, .35);
    --danger-text: #fda29b;
    --success-soft: rgba(23, 178, 106, .14);
    --success-text: #75e0a7;
    --warning-soft: rgba(247, 144, 9, .14);
    --warning-text: #fec84b;
    --info-soft: rgba(46, 144, 250, .14);
    --info-text: #84caff;
    --neutral-soft: rgba(152, 162, 179, .14);
    --neutral-text: #cdd3df;
    --sidebar-bg: #080b13;
    --code-bg: #080b13;
    --shadow-xs: none;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-lg: 0 16px 40px -8px rgba(0, 0, 0, .6);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0f19;
  --surface: #131927;
  --surface-2: #171e2e;
  --surface-3: #1c2436;
  --text: #eef1f6;
  --text-2: #cdd3df;
  --muted: #8d97ab;
  --faint: #667085;
  --border: #252e42;
  --border-strong: #333d54;
  --primary: #7170f5;
  --primary-hover: #8584ff;
  --primary-soft: rgba(113, 112, 245, .14);
  --primary-text: #a5a4ff;
  --ring: rgba(113, 112, 245, .35);
  --danger: #f04438;
  --danger-hover: #f97066;
  --danger-soft: rgba(240, 68, 56, .12);
  --danger-border: rgba(240, 68, 56, .35);
  --danger-text: #fda29b;
  --success-soft: rgba(23, 178, 106, .14);
  --success-text: #75e0a7;
  --warning-soft: rgba(247, 144, 9, .14);
  --warning-text: #fec84b;
  --info-soft: rgba(46, 144, 250, .14);
  --info-text: #84caff;
  --neutral-soft: rgba(152, 162, 179, .14);
  --neutral-text: #cdd3df;
  --sidebar-bg: #080b13;
  --code-bg: #080b13;
  --shadow-xs: none;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-lg: 0 16px 40px -8px rgba(0, 0, 0, .6);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: var(--primary-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
h1, h2, h3 { color: var(--text); letter-spacing: -.01em; }
h1 { font-size: 1.5rem; line-height: 1.25; font-weight: 650; margin: 0; }
h2 { font-size: 1rem; line-height: 1.4; font-weight: 600; margin: 0 0 .25rem; }
h3 { font-size: .9rem; font-weight: 600; margin: 1.25rem 0 .5rem; }
p { margin: 0 0 .75rem; }
p:last-child { margin-bottom: 0; }
code, pre, kbd { font-family: var(--mono); font-size: .86em; }
code { background: var(--surface-3); border: 1px solid var(--border); padding: .05em .35em; border-radius: 4px; color: var(--text-2); }
pre { background: var(--code-bg); color: var(--code-text); padding: 14px 16px; border-radius: var(--radius-sm); overflow-x: auto; margin: 0 0 1rem; line-height: 1.6; }
pre code { background: none; border: 0; padding: 0; color: inherit; }
hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }
details summary { cursor: pointer; color: var(--muted); font-weight: 500; margin-top: 12px; }
::selection { background: var(--ring); }

.icon { width: 16px; height: 16px; flex: none; vertical-align: -3px; }
.icon-lg { width: 20px; height: 20px; }
.icon-xl { width: 28px; height: 28px; }

/* ---------- App shell ---------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 40;
  width: var(--sidebar-w);
  background: var(--sidebar-bg); color: var(--sidebar-text);
  display: flex; flex-direction: column;
  border-right: 1px solid var(--sidebar-border);
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 14px; color: #fff; font-weight: 650; font-size: .98rem; letter-spacing: -.01em;
}
.sidebar-brand:hover { text-decoration: none; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff;
  box-shadow: 0 2px 8px rgba(99, 102, 241, .45);
}
.brand-mark .icon { width: 16px; height: 16px; }
.brand-sub { display: block; font-size: .72rem; font-weight: 500; color: var(--sidebar-heading); letter-spacing: .02em; }

.project-switch { margin: 4px 12px 8px; position: relative; }
.project-switch label {
  display: block; margin: 0 0 4px 6px; font-size: .68rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--sidebar-heading);
}
.project-switch select {
  appearance: none; -webkit-appearance: none;
  width: 100%; margin: 0; padding: 8px 32px 8px 10px; font-weight: 550; font-size: .88rem;
  background: rgba(255, 255, 255, .05); color: #fff; border: 1px solid var(--sidebar-border); border-radius: 8px; cursor: pointer;
}
.project-switch select:hover { background: rgba(255, 255, 255, .08); }
.project-switch select:focus { outline: none; border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99, 102, 241, .35); }
.project-switch select option { color: #101828; background: #fff; }
.project-switch .icon { position: absolute; right: 10px; bottom: 10px; color: var(--sidebar-text); pointer-events: none; }
.project-switch .btn { margin-top: 6px; }

.nav { flex: 1; overflow-y: auto; padding: 6px 12px 12px; }
.nav-group { margin-top: 14px; }
.nav-heading {
  padding: 0 10px 6px; font-size: .68rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--sidebar-heading);
}
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; margin-bottom: 1px; border-radius: 7px;
  color: var(--sidebar-text); font-weight: 500; font-size: .9rem;
  transition: background .12s, color .12s;
}
.nav a .icon { opacity: .85; }
.nav a:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.nav a.active { background: var(--sidebar-active); color: #fff; }
.nav a.active .icon { color: #a5b4fc; opacity: 1; }

.sidebar-foot {
  border-top: 1px solid var(--sidebar-border); padding: 12px; display: flex; align-items: center; gap: 10px;
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: #273049; color: #e0e7ff; font-weight: 650; font-size: .82rem; text-transform: uppercase;
}
.sidebar-user { flex: 1; min-width: 0; line-height: 1.25; }
.sidebar-user strong { display: block; color: #fff; font-weight: 550; font-size: .86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user span { font-size: .74rem; color: var(--sidebar-heading); }
.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 7px; padding: 0;
  border: 0; background: transparent; color: var(--sidebar-text); cursor: pointer;
}
.icon-btn:hover { background: var(--sidebar-hover); color: #fff; }
.icon-btn:focus-visible { outline: 2px solid #6366f1; outline-offset: 1px; }

.main { flex: 1; min-width: 0; margin-left: var(--sidebar-w); display: flex; flex-direction: column; }

.mobilebar { display: none; }
.scrim { display: none; }

.container { width: 100%; max-width: 1180px; margin: 0 auto; padding: 28px 32px 72px; }

/* Status banners (sit above the content) */
.banner {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 32px; font-size: .88rem; border-bottom: 1px solid transparent;
}
.banner .icon { flex: none; }
.banner .banner-text { flex: 1; min-width: 220px; }
.banner-danger { background: var(--danger-soft); color: var(--danger-text); border-color: var(--danger-border); }
.banner-info { background: var(--info-soft); color: var(--info-text); border-color: rgba(46, 144, 250, .2); }
.banner code { background: rgba(255, 255, 255, .5); border-color: transparent; color: inherit; }

/* ---------- Page header ---------- */
.page-head {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap;
  margin-bottom: 24px;
}
.page-head h1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-title { min-width: 0; }
.eyebrow {
  display: flex; align-items: center; gap: 6px; margin-bottom: 6px;
  font-size: .78rem; font-weight: 600; color: var(--muted);
}
.eyebrow a { color: var(--muted); display: inline-flex; align-items: center; gap: 4px; }
.eyebrow a:hover { color: var(--text); text-decoration: none; }
.eyebrow .icon { width: 14px; height: 14px; }
.page-sub { color: var(--muted); margin: 6px 0 0; max-width: 72ch; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-xs); padding: 20px 24px; margin-bottom: 20px;
}
.card > h2:first-child { margin-bottom: 12px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.card-head h2 { margin: 0; display: flex; align-items: center; gap: 8px; }
.card-head h2 .icon { color: var(--muted); }
.card-head p { margin: 2px 0 0; color: var(--muted); font-size: .86rem; }
.card-body { padding: 20px; }
.card-foot {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap;
  padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2);
  border-radius: 0 0 var(--radius) var(--radius);
}
.card-foot.split { justify-content: space-between; }
.card.flush { padding: 0; }
.card.flush > .table-scroll:last-child .table tr:last-child td { border-bottom: 0; }
.highlight { border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); box-shadow: 0 0 0 3px var(--primary-soft); }

.danger-zone { border-color: var(--danger-border); }
.danger-zone .card-head { border-color: var(--danger-border); }
.danger-zone .card-head h2, .danger-zone .card-head h2 .icon { color: var(--danger-text); }
.danger-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 16px 20px; border-top: 1px solid var(--border);
}
.danger-row:first-of-type { border-top: 0; }
.danger-row > div:first-child { flex: 1; min-width: 240px; }
.danger-row strong { display: block; font-weight: 600; }
.danger-row p { color: var(--muted); font-size: .86rem; margin: 2px 0 0; }

/* Empty states */
.empty {
  text-align: center; padding: 48px 24px;
}
.empty-icon {
  width: 48px; height: 48px; margin: 0 auto 14px; border-radius: 12px; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary-text);
}
.empty-icon .icon { width: 22px; height: 22px; }
.empty h2 { margin-bottom: 4px; }
.empty p { color: var(--muted); max-width: 46ch; margin: 0 auto 16px; }
.empty p:last-child { margin-bottom: 0; }

/* ---------- Grids ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; margin-bottom: 20px; }
.grid > .card { margin-bottom: 0; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.split-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }

/* ---------- Stat tiles ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-xs);
  padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; min-width: 0;
}
.stat-label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .82rem; font-weight: 550; }
.stat-label .icon { width: 15px; height: 15px; }
.stat-value { font-size: 1.75rem; line-height: 1.15; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-value small { font-size: .85rem; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.stat-meta { font-size: .8rem; color: var(--muted); }
.stat-tile.tone-success .stat-value { color: var(--success-text); }
.stat-tile.tone-danger .stat-value { color: var(--danger-text); }
.stat-tile.tone-warning .stat-value { color: var(--warning-text); }

/* legacy stat markup */
.stat { font-size: 1.75rem; font-weight: 650; margin: 4px 0; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat span { font-size: .85rem; font-weight: 500; color: var(--muted); }

/* ---------- Forms ---------- */
label { display: block; font-weight: 550; font-size: .88rem; color: var(--text-2); margin: 16px 0 6px; }
label:first-child, .field:first-child label { margin-top: 0; }
input, select, textarea {
  width: 100%; padding: 8px 11px; font: inherit; font-size: .9rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-xs); transition: border-color .12s, box-shadow .12s;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--border-strong) 60%, var(--muted)); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
input[type=file] { padding: 6px; background: var(--surface-2); }
input[type=file]::file-selector-button {
  font: inherit; font-weight: 550; font-size: .85rem; margin-right: 12px; padding: 6px 12px; cursor: pointer;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
}
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; padding: 0; box-shadow: none; accent-color: var(--primary); margin: 0; flex: none; }
select:not([multiple]) {
  appearance: none; -webkit-appearance: none; padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; background-size: 16px;
}
textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
textarea.code { font-family: var(--mono); font-size: 12.5px; line-height: 1.6; background: var(--surface-2); }

.form { max-width: none; }
.form-narrow { max-width: 560px; }
.help { color: var(--muted); font-size: .82rem; margin: 6px 0 0; line-height: 1.5; }
.field-error { color: var(--danger-text); font-size: .82rem; font-weight: 500; margin: 6px 0 0; }
.form-actions { margin-top: 24px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.checkbox { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; color: var(--text); cursor: pointer; }
.checkbox input { margin-top: 2px; }
.checkbox small { display: block; color: var(--muted); font-weight: 400; font-size: .82rem; }
.radio-card {
  display: flex; gap: 10px; align-items: center; padding: 10px 12px; margin: 0 0 8px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); font-weight: 500; color: var(--text); cursor: pointer;
}
.radio-card:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 16px; }

/* Settings-style sections: description on the left, fields on the right */
.form-section {
  display: grid; grid-template-columns: minmax(200px, 280px) minmax(0, 1fr); gap: 32px;
  padding: 24px; border-top: 1px solid var(--border);
}
.form-section:first-of-type { border-top: 0; }
.form-section-intro h2 { margin-bottom: 4px; }
.form-section-intro p { color: var(--muted); font-size: .85rem; margin: 0; }
.form-section-body { max-width: 560px; }
.form-section-body > label:first-child, .form-section-body > .row2:first-child label, .form-section-body > .field:first-child label { margin-top: 0; }

.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 0; }
.inline-form input, .inline-form select { width: auto; flex: 0 1 auto; }
.inline-form input[type=email] { flex: 1 1 220px; }
.grow { flex: 1 1 200px; }
.inline, form.inline { display: inline-flex; margin: 0; }
.narrow { width: 76px !important; }
.narrow-dt { max-width: 260px; }
form { margin: 0; }

.input-icon { position: relative; flex: 1 1 260px; }
.input-icon .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.input-icon input { padding-left: 34px; width: 100%; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 14px; min-height: 36px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2);
  font: inherit; font-size: .875rem; font-weight: 600; line-height: 1.2; white-space: nowrap;
  cursor: pointer; text-decoration: none; box-shadow: var(--shadow-xs);
  transition: background .12s, border-color .12s, color .12s, box-shadow .12s;
}
.btn:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn .icon { width: 15px; height: 15px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 1px 2px rgba(79, 70, 229, .3); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); color: #fff; }
.btn-danger-outline { color: var(--danger-text); border-color: var(--danger-border); }
.btn-danger-outline:hover { background: var(--danger-soft); color: var(--danger-text); }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn-ghost:hover { background: var(--surface-3); }
.btn-link { border: none; background: none; box-shadow: none; color: var(--muted); padding: 4px; min-height: 0; font-weight: 500; }
.btn-link:hover { color: var(--text); background: none; }
.btn-small { padding: 5px 10px; min-height: 30px; font-size: .8rem; }
.btn-block { width: 100%; }

/* ---------- Alerts / flash ---------- */
.flash {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--radius-sm); margin-bottom: 20px; border: 1px solid transparent; font-size: .9rem;
}
.flash > .icon { margin-top: 2px; }
.flash > div { flex: 1; min-width: 0; }
.flash .flash-close { margin: -4px -6px -4px 0; color: inherit; opacity: .7; width: 28px; height: 28px; }
.flash .flash-close:hover { opacity: 1; background: rgba(0, 0, 0, .06); color: inherit; }
.flash-success { background: var(--success-soft); color: var(--success-text); border-color: color-mix(in srgb, var(--success-text) 22%, transparent); }
.flash-error { background: var(--danger-soft); color: var(--danger-text); border-color: var(--danger-border); }
.flash-warning { background: var(--warning-soft); color: var(--warning-text); border-color: color-mix(in srgb, var(--warning-text) 25%, transparent); }
.flash-info { background: var(--info-soft); color: var(--info-text); border-color: color-mix(in srgb, var(--info-text) 22%, transparent); }
.flash.is-hiding { opacity: 0; transform: translateY(-4px); transition: opacity .2s, transform .2s; }

/* ---------- Tables ---------- */
.table-wrap { padding: 0; overflow: hidden; }
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.table th, .table td { padding: 11px 16px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table th {
  font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  background: var(--surface-2); white-space: nowrap; padding-top: 9px; padding-bottom: 9px;
}
.table tbody tr { transition: background .1s; }
.table tbody tr:hover { background: var(--surface-2); }
.table tr:last-child td { border-bottom: none; }
.table td a strong, .table td > a { font-weight: 600; }
.table .sub { display: block; color: var(--muted); font-size: .8rem; margin-top: 1px; }
.table.compact td { padding: 9px 16px; }
.table.compact tbody tr:hover { background: transparent; }
.table tr.row-link { cursor: pointer; }
.num { text-align: right !important; white-space: nowrap; font-variant-numeric: tabular-nums; }
.cell-strong { font-weight: 600; color: var(--text); }
.cell-muted { color: var(--muted); }
.table-foot { padding: 10px 16px; border-top: 1px solid var(--border); color: var(--muted); font-size: .82rem; background: var(--surface-2); }

/* Activity list (dashboard) */
.activity { list-style: none; margin: 0; padding: 0; }
.activity li { display: flex; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--border); align-items: flex-start; }
.activity li:last-child { border-bottom: 0; }
.activity-dot { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex: none; }
.activity-dot .icon { width: 15px; height: 15px; }
.activity-dot.ok { background: var(--success-soft); color: var(--success-text); }
.activity-dot.bad { background: var(--danger-soft); color: var(--danger-text); }
.activity-body { flex: 1; min-width: 0; }
.activity-body .line1 { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-body .line2 { color: var(--muted); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-body .err { color: var(--danger-text); font-size: .8rem; }
.activity-time { color: var(--faint); font-size: .76rem; white-space: nowrap; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px 2px 8px; border-radius: 999px;
  font-size: .74rem; font-weight: 600; line-height: 1.5; white-space: nowrap; text-transform: capitalize;
  background: var(--neutral-soft); color: var(--neutral-text); vertical-align: middle;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge.plain::before { display: none; }
.badge-active, .badge-sent, .badge-completed, .badge-sending, .badge-running { background: var(--success-soft); color: var(--success-text); }
.badge-unsubscribed, .badge-cancelled, .badge-skipped, .badge-stopped, .badge-draft, .badge-off { background: var(--neutral-soft); color: var(--neutral-text); }
.badge-bounced, .badge-complained, .badge-failed { background: var(--danger-soft); color: var(--danger-text); }
.badge-pending, .badge-scheduled, .badge-paused { background: var(--warning-soft); color: var(--warning-text); }
.badge-event { background: var(--info-soft); color: var(--info-text); }
h1 .badge { font-size: .78rem; }

/* ---------- Tabs / segmented filters ---------- */
.tabs {
  display: inline-flex; gap: 2px; padding: 3px; border-radius: 9px; background: var(--surface-3); border: 1px solid var(--border);
  flex-wrap: wrap;
}
.tabs a {
  padding: 5px 12px; border-radius: 6px; color: var(--muted); font-weight: 550; font-size: .84rem; text-transform: capitalize;
}
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .count { color: var(--muted); font-size: .85rem; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.filters select { width: auto; min-width: 150px; }
.filter-links { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; margin: 0; }

/* ---------- Pagination ---------- */
.pagination { display: flex; gap: 12px; align-items: center; justify-content: space-between; margin: 16px 0 0; }
.pagination .muted { font-size: .85rem; }

/* ---------- Progress ---------- */
.progress { height: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; margin: 10px 0 8px; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--primary), #8b5cf6); border-radius: 999px; transition: width .3s; }
.progress.is-warn > div { background: var(--warning); }
.progress.is-full > div { background: var(--danger); }

.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: .82rem; color: var(--muted); }
.legend strong { color: var(--text); font-variant-numeric: tabular-nums; }

/* ---------- Definition lists ---------- */
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 10px 20px; margin: 0; font-size: .9rem; }
.dl dt { color: var(--muted); font-weight: 500; }
.dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: 10px 0; border-bottom: 1px solid var(--border); }
ul.plain li:last-child { border-bottom: 0; }

pre.light { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); white-space: pre-wrap; }

/* Key box */
.key-box { display: flex; gap: 8px; align-items: stretch; flex-wrap: wrap; margin: 16px 0; }
.key-box code {
  flex: 1; min-width: 0; padding: 10px 12px; word-break: break-all; font-size: .88rem;
  background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); display: flex; align-items: center;
}

/* Steps list (sequence editor) */
.steps { list-style: none; margin: 0; padding: 0; counter-reset: step; }
.step {
  display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 14px; align-items: start;
  padding: 16px 20px; border-bottom: 1px solid var(--border); position: relative;
}
.step:last-child { border-bottom: 0; }
.step-num {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 650; font-size: .82rem;
  background: var(--primary-soft); color: var(--primary-text);
}
.step-meta { margin-top: 6px; color: var(--muted); font-size: .8rem; }
.step-stats { display: flex; gap: 14px; font-size: .8rem; color: var(--muted); white-space: nowrap; align-items: center; }
.step-stats strong { color: var(--text); font-variant-numeric: tabular-nums; }
.step-add { padding: 16px 20px; background: var(--surface-2); border-top: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius); }
.step-add .label-inline { color: var(--muted); font-size: .86rem; }

/* Template editor */
.editor { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.editor aside { position: sticky; top: 20px; }
.preview-frame { width: 100%; height: 540px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; display: block; }
.preview-subject { margin: 0 0 12px; padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: .88rem; }
.preview-subject strong { color: var(--muted); font-weight: 550; margin-right: 6px; }
.var-list { display: grid; grid-template-columns: max-content 1fr; gap: 6px 12px; font-size: .82rem; margin: 0 0 12px; }
.var-list dt code { font-size: .78rem; }
.var-list dd { margin: 0; color: var(--muted); }

/* Import result tiles */
.result-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 4px 0 16px; }
.result-grid > div { padding: 14px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.result-grid .stat { margin: 0; font-size: 1.5rem; }
.result-grid p.muted { margin: 2px 0 0; font-size: .8rem; }

/* Tip / callout */
.callout {
  display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border);
  color: var(--muted); font-size: .86rem;
}
.callout > .icon { color: var(--primary-text); margin-top: 2px; }
.callout ul { margin: 4px 0 0; padding-left: 18px; }
.callout li { margin-bottom: 2px; }
.callout strong { color: var(--text); }

/* Health dot */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); margin-right: 6px; vertical-align: 1px; }
.dot.ok { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.dot.bad { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.dot.warn { background: var(--warning); box-shadow: 0 0 0 3px var(--warning-soft); }

/* ---------- Auth pages (login, unsubscribe, errors before login) ---------- */
.auth {
  min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background:
    radial-gradient(1200px 500px at 50% -10%, var(--primary-soft), transparent 70%),
    var(--bg);
}
.auth-box { width: 100%; max-width: 400px; }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 20px; font-weight: 650; font-size: 1.05rem; color: var(--text); }
.auth-brand:hover { text-decoration: none; }
.auth .card { padding: 28px; box-shadow: var(--shadow-lg); margin: 0; }
.auth .card h1 { font-size: 1.3rem; margin-bottom: 6px; }
.auth .card .lead { color: var(--muted); margin-bottom: 20px; }
.auth .btn-block { margin-top: 22px; min-height: 40px; }
.auth-foot { text-align: center; color: var(--faint); font-size: .78rem; margin-top: 18px; }
.login-box { max-width: 400px; margin: 0 auto; }

/* ---------- Utilities ---------- */
.muted { color: var(--muted); }
.small { font-size: .82rem; }
h1 .small { font-weight: 400; }
.nowrap { white-space: nowrap; }
.pad { padding-left: 20px; padding-right: 20px; }
.error-text { color: var(--danger-text); }
.hint { margin-top: 0; }
.hint-card { font-size: .86rem; color: var(--muted); }
.stack > * { margin-bottom: 8px; }
.mt-0 { margin-top: 0 !important; }
.mb-0 { margin-bottom: 0 !important; }
.mt-2 { margin-top: 16px; }
.text-right { text-align: right; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 360px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .split-layout { grid-template-columns: 1fr; }
  .editor { grid-template-columns: 1fr; }
  .editor aside { position: static; }
  .grid.three { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 960px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 30; background: rgba(8, 11, 19, .5); }
  .main { margin-left: 0; }
  .mobilebar {
    display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 20;
    padding: 10px 16px; background: var(--sidebar-bg); color: #fff;
  }
  .mobilebar .sidebar-brand { padding: 0; font-size: .95rem; }
  .mobilebar .mobile-project { margin-left: auto; font-size: .8rem; color: var(--sidebar-text); max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .container { padding: 20px 16px 56px; }
  .banner { padding: 10px 16px; }
  .form-section { grid-template-columns: 1fr; gap: 16px; padding: 20px 16px; }
  .grid.two { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .page-head { align-items: flex-start; }
  .page-head .actions { width: 100%; }
  .card { padding: 16px; }
  .card-head, .card-body, .card-foot, .danger-row { padding-left: 16px; padding-right: 16px; }
  .row2, .row3, .grid.three { grid-template-columns: 1fr; }
  .result-grid { grid-template-columns: 1fr 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
  .step { grid-template-columns: 30px minmax(0, 1fr); }
  .step-actions { grid-column: 2; }
  .filters select { flex: 1 1 140px; }
}
.auth .card.center { text-align: center; }
.card.bare { border: 0; box-shadow: none; background: transparent; }
.tabs a.no-cap { text-transform: none; }
