/* ============================================================================
   DexMail Console — design system
   Enterprise email-infrastructure control plane. Restrained palette, one sans,
   fixed rem scale, layered neutral surfaces, full component state vocabulary.
   Light + dark, theme-aware. No build step; hand-authored tokens + components.
   ============================================================================ */

/* ---- tokens ---------------------------------------------------------------- */
:root {
  color-scheme: light;

  /* neutral surfaces — content is the lightest, chrome (sidebar/topbar) cooler */
  --bg:        oklch(0.985 0.003 265);   /* app content background */
  --panel:     oklch(0.965 0.004 265);   /* sidebar / rails / toolbars */
  --surface:   oklch(1 0 0);             /* cards, tables, inputs */
  --surface-2: oklch(0.975 0.004 265);   /* zebra / hover fills */
  --overlay:   oklch(0.22 0.03 265 / 0.42);

  --border:      oklch(0.918 0.006 265);
  --border-strong: oklch(0.86 0.008 265);

  --ink:     oklch(0.24 0.02 265);       /* primary text */
  --ink-2:   oklch(0.44 0.02 265);       /* secondary text */
  --muted:   oklch(0.50 0.02 265);       /* tertiary / captions (>=4.5:1 on all surfaces) */
  --faint:   oklch(0.60 0.016 265);      /* disabled-state text only (WCAG-exempt) */

  /* badge/status text — darkened for >=4.5:1 on the weak tint (light) */
  --ok-text:     oklch(0.46 0.12 155);
  --warn-text:   oklch(0.48 0.11 74);
  --danger-text: oklch(0.50 0.19 27);

  /* brand accent — refined indigo (deliverability control plane) */
  --accent:        oklch(0.54 0.19 268);
  --accent-hover:  oklch(0.49 0.19 268);
  --accent-press:  oklch(0.44 0.18 268);
  --accent-weak:   oklch(0.54 0.19 268 / 0.12);
  --accent-ink:    oklch(0.99 0.01 268);  /* text on accent */

  /* semantic */
  --ok:      oklch(0.60 0.14 155);
  --ok-weak: oklch(0.60 0.14 155 / 0.14);
  --warn:    oklch(0.70 0.15 74);
  --warn-weak: oklch(0.70 0.15 74 / 0.16);
  --danger:  oklch(0.57 0.20 27);
  --danger-weak: oklch(0.57 0.20 27 / 0.13);
  --danger-hover: oklch(0.52 0.20 27);
  --info:      var(--accent);
  --info-weak:  var(--accent-weak);

  /* charts (categorical) */
  --c1: oklch(0.54 0.19 268);
  --c2: oklch(0.60 0.14 155);
  --c3: oklch(0.70 0.15 74);
  --c4: oklch(0.62 0.17 330);
  --c5: oklch(0.65 0.13 210);

  /* type */
  --sans: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --fs-11: 0.6875rem; --fs-12: 0.75rem; --fs-13: 0.8125rem; --fs-14: 0.875rem;
  --fs-16: 1rem; --fs-18: 1.125rem; --fs-20: 1.25rem; --fs-24: 1.5rem; --fs-30: 1.875rem;

  /* spacing (4px base) */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px; --s10: 40px; --s12: 48px;

  --r-sm: 6px; --r-md: 8px; --r-lg: 12px; --r-xl: 16px; --r-full: 999px;

  --sh-1: 0 1px 2px oklch(0.24 0.03 265 / 0.06), 0 1px 1px oklch(0.24 0.03 265 / 0.04);
  --sh-2: 0 4px 12px oklch(0.24 0.03 265 / 0.08), 0 1px 3px oklch(0.24 0.03 265 / 0.06);
  --sh-3: 0 12px 32px oklch(0.24 0.03 265 / 0.14), 0 4px 10px oklch(0.24 0.03 265 / 0.08);

  --sidebar-w: 244px;
  --topbar-h: 56px;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);   /* ease-out-quart */
  --dur: 160ms;

  /* z-index scale */
  --z-sticky: 100; --z-drawer-backdrop: 200; --z-drawer: 210;
  --z-modal-backdrop: 300; --z-modal: 310; --z-toast: 400; --z-tooltip: 500;
}

:root:not([data-theme="light"]) {
  @media (prefers-color-scheme: dark) {
    color-scheme: dark;
    --bg:        oklch(0.17 0.012 265);
    --panel:     oklch(0.20 0.014 265);
    --surface:   oklch(0.215 0.015 265);
    --surface-2: oklch(0.245 0.016 265);
    --overlay:   oklch(0.10 0.02 265 / 0.6);
    --border:      oklch(0.29 0.016 265);
    --border-strong: oklch(0.36 0.018 265);
    --ink:     oklch(0.96 0.01 265);
    --ink-2:   oklch(0.80 0.015 265);
    --muted:   oklch(0.68 0.02 265);
    --faint:   oklch(0.52 0.018 265);
    --accent:        oklch(0.68 0.16 268);
    --accent-hover:  oklch(0.73 0.16 268);
    --accent-press:  oklch(0.78 0.15 268);
    --accent-weak:   oklch(0.68 0.16 268 / 0.16);
    --accent-ink:    oklch(0.16 0.02 265);
    --ok:      oklch(0.70 0.14 155);
    --ok-weak: oklch(0.70 0.14 155 / 0.18);
    --warn:    oklch(0.78 0.14 78);
    --warn-weak: oklch(0.78 0.14 78 / 0.18);
    --danger:  oklch(0.68 0.18 27);
    --danger-weak: oklch(0.68 0.18 27 / 0.18);
    --danger-hover: oklch(0.73 0.18 27);
    --faint:   oklch(0.50 0.018 265);
    --ok-text:     oklch(0.78 0.13 155);
    --warn-text:   oklch(0.82 0.13 78);
    --danger-text: oklch(0.74 0.16 27);
    --sh-1: 0 1px 2px oklch(0 0 0 / 0.3);
    --sh-2: 0 4px 14px oklch(0 0 0 / 0.4);
    --sh-3: 0 16px 40px oklch(0 0 0 / 0.55);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg:        oklch(0.17 0.012 265);
  --panel:     oklch(0.20 0.014 265);
  --surface:   oklch(0.215 0.015 265);
  --surface-2: oklch(0.245 0.016 265);
  --overlay:   oklch(0.10 0.02 265 / 0.6);
  --border:      oklch(0.29 0.016 265);
  --border-strong: oklch(0.36 0.018 265);
  --ink:     oklch(0.96 0.01 265);
  --ink-2:   oklch(0.80 0.015 265);
  --muted:   oklch(0.68 0.02 265);
  --faint:   oklch(0.52 0.018 265);
  --accent:        oklch(0.68 0.16 268);
  --accent-hover:  oklch(0.73 0.16 268);
  --accent-press:  oklch(0.78 0.15 268);
  --accent-weak:   oklch(0.68 0.16 268 / 0.16);
  --accent-ink:    oklch(0.16 0.02 265);
  --ok:      oklch(0.70 0.14 155);
  --ok-weak: oklch(0.70 0.14 155 / 0.18);
  --warn:    oklch(0.78 0.14 78);
  --warn-weak: oklch(0.78 0.14 78 / 0.18);
  --danger:  oklch(0.68 0.18 27);
  --danger-weak: oklch(0.68 0.18 27 / 0.18);
  --danger-hover: oklch(0.73 0.18 27);
  --faint:   oklch(0.50 0.018 265);
  --ok-text:     oklch(0.78 0.13 155);
  --warn-text:   oklch(0.82 0.13 78);
  --danger-text: oklch(0.74 0.16 27);
  --sh-1: 0 1px 2px oklch(0 0 0 / 0.3);
  --sh-2: 0 4px 14px oklch(0 0 0 / 0.4);
  --sh-3: 0 16px 40px oklch(0 0 0 / 0.55);
}

/* ---- reset / base --------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--sans);
  font-size: var(--fs-14);
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { font-weight: 600; line-height: 1.25; text-wrap: balance; color: var(--ink); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-sm); }
::selection { background: var(--accent-weak); }
.mono { font-family: var(--mono); font-feature-settings: "tnum" 1; }
.tnum { font-variant-numeric: tabular-nums; }
svg.ic { width: 18px; height: 18px; flex-shrink: 0; }

/* scrollbars — subtle, standard */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 3px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--muted); }

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

.sidebar {
  grid-row: 1 / -1; background: var(--panel); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: var(--s2); padding: 0 var(--s4);
  height: var(--topbar-h); font-weight: 700; font-size: var(--fs-16); letter-spacing: -0.01em; flex-shrink: 0; }
.brand .logo { width: 26px; height: 26px; border-radius: 7px;
  background: linear-gradient(150deg, var(--accent), oklch(0.62 0.19 300));
  display: grid; place-items: center; color: var(--accent-ink); font-weight: 800; font-size: 14px; box-shadow: var(--sh-1); }
.brand .sub { font-size: var(--fs-11); font-weight: 500; color: var(--muted); letter-spacing: 0.02em; }

.nav { flex: 1; overflow-y: auto; padding: var(--s3) var(--s2); display: flex; flex-direction: column; gap: 1px; }
.nav .group-label { font-size: var(--fs-11); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); padding: var(--s4) var(--s3) var(--s2); }
.nav-item { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) var(--s3); border-radius: var(--r-sm);
  color: var(--ink-2); font-weight: 500; cursor: pointer; user-select: none; transition: background var(--dur), color var(--dur); position: relative; }
.nav-item:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nav-item.active { background: var(--accent-weak); color: var(--accent); font-weight: 600; }
.nav-item .ic { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.9; }
.nav-item .tag { margin-left: auto; font-size: var(--fs-11); color: var(--muted); font-variant-numeric: tabular-nums; }
.nav-item.active .tag { color: var(--accent); }

.sidebar-foot { border-top: 1px solid var(--border); padding: var(--s3); }
.acct { display: flex; align-items: center; gap: var(--s3); padding: var(--s2); border-radius: var(--r-sm); cursor: pointer; }
.acct:hover { background: var(--surface-2); }
.avatar { width: 30px; height: 30px; border-radius: var(--r-full); background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-weight: 700; font-size: var(--fs-13); flex-shrink: 0; }
.acct .who { min-width: 0; }
.acct .who .n { font-weight: 600; font-size: var(--fs-13); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acct .who .e { font-size: var(--fs-11); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* main column */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar { height: var(--topbar-h); border-bottom: 1px solid var(--border); background: oklch(from var(--bg) l c h / 0.8);
  backdrop-filter: blur(8px); position: sticky; top: 0; z-index: var(--z-sticky);
  display: flex; align-items: center; gap: var(--s4); padding: 0 var(--s6); flex-shrink: 0; }
.topbar .crumb { display: flex; align-items: center; gap: var(--s2); font-size: var(--fs-13); color: var(--muted); }
.topbar .crumb b { color: var(--ink); font-weight: 600; font-size: var(--fs-16); }
.topbar .spacer { flex: 1; }
.icon-btn { width: 34px; height: 34px; border-radius: var(--r-sm); border: 1px solid transparent; background: transparent;
  display: grid; place-items: center; cursor: pointer; color: var(--ink-2); transition: background var(--dur), border-color var(--dur); }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.menu-toggle { display: none; }

.content { padding: var(--s6); max-width: 1320px; width: 100%; margin: 0 auto; flex: 1; }
.page-head { display: flex; align-items: flex-start; gap: var(--s4); margin-bottom: var(--s6); flex-wrap: wrap; }
.page-head .titles { min-width: 0; }
.page-head h1 { font-size: var(--fs-24); letter-spacing: -0.02em; }
.page-head .lede { color: var(--muted); font-size: var(--fs-13); margin-top: 2px; max-width: 70ch; }
.page-head .actions { margin-left: auto; display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; }

/* ---- buttons -------------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  height: 34px; padding: 0 var(--s4); border-radius: var(--r-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--ink); font-size: var(--fs-13); font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background var(--dur) var(--ease), border-color var(--dur), box-shadow var(--dur), transform var(--dur); }
.btn:hover { background: var(--surface-2); border-color: var(--muted); text-decoration: none; }
.btn:active { transform: translateY(0.5px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn .ic { width: 16px; height: 16px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.primary:active { background: var(--accent-press); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); border-color: transparent; }
.btn.danger { background: transparent; border-color: var(--border-strong); color: var(--danger); }
.btn.danger:hover { background: var(--danger-weak); border-color: var(--danger); }
.btn.sm { height: 28px; padding: 0 var(--s3); font-size: var(--fs-12); }
.btn.lg { height: 40px; padding: 0 var(--s5); font-size: var(--fs-14); }
.btn.block { width: 100%; }
.btn.loading { color: transparent !important; pointer-events: none; position: relative; }
.btn.loading::after { content: ""; position: absolute; width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent; animation: spin 0.6s linear infinite;
  color: var(--accent-ink); }
.btn.ghost.loading::after, .btn.danger.loading::after, .btn:not(.primary).loading::after { color: var(--ink); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- forms ---------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: var(--s2); margin-bottom: var(--s4); }
.field > label { font-size: var(--fs-13); font-weight: 600; color: var(--ink-2); }
.field .hint { font-size: var(--fs-12); color: var(--muted); }
.field .err { font-size: var(--fs-12); color: var(--danger); }
.input, .select, .textarea {
  width: 100%; height: 36px; padding: 0 var(--s3); border-radius: var(--r-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink);
  font-size: var(--fs-14); transition: border-color var(--dur), box-shadow var(--dur); }
.textarea { height: auto; min-height: 88px; padding: var(--s3); resize: vertical; line-height: 1.55; }
.input::placeholder, .textarea::placeholder { color: var(--muted); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--muted); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.input:disabled, .textarea:disabled { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }
.input.invalid { border-color: var(--danger); }
.select { appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px; }
.check { display: inline-flex; align-items: center; gap: var(--s2); font-size: var(--fs-13); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

/* switch */
.switch { position: relative; display: inline-block; width: 38px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track { position: absolute; inset: 0; background: var(--border-strong); border-radius: var(--r-full);
  transition: background var(--dur); cursor: pointer; }
.switch .track::before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: transform var(--dur) var(--ease); box-shadow: var(--sh-1); }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::before { transform: translateX(16px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px var(--accent-weak); }

/* ---- panels / sections ---------------------------------------------------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--sh-1); }
.panel-head { display: flex; align-items: center; gap: var(--s3); padding: var(--s4) var(--s5); border-bottom: 1px solid var(--border); }
.panel-head h2 { font-size: var(--fs-14); font-weight: 600; }
.panel-head .sub { font-size: var(--fs-12); color: var(--muted); }
.panel-head .actions { margin-left: auto; display: flex; gap: var(--s2); align-items: center; }
.panel-body { padding: var(--s5); }
.panel-body.flush { padding: 0; }

.grid { display: grid; gap: var(--s4); }
.cols-2 { grid-template-columns: repeat(2, 1fr); }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.autofit { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

/* ---- KPI strip (compact, not the giant-gradient cliché) ------------------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); overflow: hidden; box-shadow: var(--sh-1); }
.kpi { padding: var(--s4) var(--s5); border-right: 1px solid var(--border); }
.kpi:last-child { border-right: none; }
.kpi .k { font-size: var(--fs-12); color: var(--muted); font-weight: 500; display: flex; align-items: center; gap: var(--s2); }
.kpi .v { font-size: var(--fs-24); font-weight: 700; letter-spacing: -0.02em; margin-top: var(--s2); font-variant-numeric: tabular-nums; }
.kpi .d { font-size: var(--fs-12); margin-top: 2px; color: var(--muted); }
.kpi .d.up { color: var(--ok); } .kpi .d.down { color: var(--danger); }

/* ---- badges / pills ------------------------------------------------------- */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 8px; border-radius: var(--r-full);
  font-size: var(--fs-11); font-weight: 600; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--border); white-space: nowrap; }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--ok-weak); color: var(--ok-text); border-color: transparent; }
.badge.warn { background: var(--warn-weak); color: var(--warn-text); border-color: transparent; }
.badge.danger { background: var(--danger-weak); color: var(--danger-text); border-color: transparent; }
.badge.accent { background: var(--accent-weak); color: var(--accent); border-color: transparent; }
.badge.neutral { background: var(--surface-2); color: var(--muted); }

/* ---- tables --------------------------------------------------------------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--sh-1); }
table.tbl { width: 100%; border-collapse: collapse; font-size: var(--fs-13); }
.tbl thead th { text-align: left; font-weight: 600; font-size: var(--fs-12); color: var(--muted); background: var(--surface-2);
  padding: var(--s3) var(--s4); border-bottom: 1px solid var(--border); white-space: nowrap; position: sticky; top: 0; }
.tbl tbody td { padding: var(--s3) var(--s4); border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr { transition: background var(--dur); }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl tbody tr.clickable { cursor: pointer; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .row-actions { display: flex; gap: var(--s1); justify-content: flex-end; opacity: 0.5; transition: opacity var(--dur); }
.tbl tr:hover .row-actions { opacity: 1; }
.lnk { cursor: pointer; }
.lnk:hover { color: var(--accent); text-decoration: underline; }
/* landing-page daily trend chart */
.lpbars { display: flex; align-items: flex-end; gap: 4px; height: 140px; }
.lpbar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.lpbar-stack { display: flex; align-items: flex-end; justify-content: center; gap: 2px; width: 100%; height: 112px; }
.lpbar { width: 42%; max-width: 12px; border-radius: 3px 3px 0 0; transition: height var(--dur); }
.lpbar.v { background: var(--c1); }
.lpbar.s { background: var(--c3); }
.lpbar-lbl { font-size: var(--fs-12); color: var(--muted); font-variant-numeric: tabular-nums; height: 1em; }
.lpkey { display: inline-block; width: 9px; height: 9px; border-radius: 2px; vertical-align: middle; }
.lpkey.v { background: var(--c1); }
.lpkey.s { background: var(--c3); }

/* ---- empty / loading / error states --------------------------------------- */
.empty { text-align: center; padding: var(--s12) var(--s6); color: var(--muted); }
.empty .ic { width: 44px; height: 44px; margin: 0 auto var(--s4); color: var(--faint);
  background: var(--surface-2); border-radius: var(--r-lg); display: grid; place-items: center; }
.empty .ic svg { width: 22px; height: 22px; }
.state-error svg.ic { width: 22px; height: 22px; }
.empty .et { font-size: var(--fs-16); color: var(--ink); margin-bottom: var(--s2); }
.empty p { font-size: var(--fs-13); max-width: 42ch; margin: 0 auto var(--s4); }
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 37%, var(--surface-2) 63%);
  background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: var(--r-sm); }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
.sk-row { height: 14px; margin: var(--s3) 0; }
.state-error { padding: var(--s6); text-align: center; color: var(--danger); font-size: var(--fs-13); }

/* ---- callouts / alerts (full border, no side-stripe) ---------------------- */
.callout { display: flex; gap: var(--s3); padding: var(--s3) var(--s4); border-radius: var(--r-md); font-size: var(--fs-13);
  border: 1px solid var(--border); background: var(--surface-2); }
.callout .ic { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.callout.info { background: var(--accent-weak); border-color: transparent; color: var(--ink); }
.callout.info .ic { color: var(--accent); }
.callout.warn { background: var(--warn-weak); border-color: transparent; }
.callout.warn .ic { color: oklch(0.55 0.14 74); }
.callout.danger { background: var(--danger-weak); border-color: transparent; }
.callout.danger .ic { color: var(--danger); }
.callout.ok { background: var(--ok-weak); border-color: transparent; }
.callout.ok .ic { color: var(--ok); }
.callout b { font-weight: 600; }

/* ---- tabs ----------------------------------------------------------------- */
.tabs { display: flex; gap: var(--s1); border-bottom: 1px solid var(--border); margin-bottom: var(--s5); }
.tab { padding: var(--s3) var(--s3); font-size: var(--fs-13); font-weight: 600; color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color var(--dur), border-color var(--dur); }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---- drawer / modal ------------------------------------------------------- */
.scrim { position: fixed; inset: 0; background: var(--overlay); z-index: var(--z-drawer-backdrop);
  opacity: 0; animation: fade var(--dur) var(--ease) forwards; }
@keyframes fade { to { opacity: 1; } }
.drawer { position: fixed; top: 0; right: 0; height: 100vh; width: min(560px, 94vw); background: var(--surface);
  border-left: 1px solid var(--border); box-shadow: var(--sh-3); z-index: var(--z-drawer); display: flex; flex-direction: column;
  transform: translateX(100%); animation: slidein 220ms var(--ease) forwards; }
@keyframes slidein { to { transform: translateX(0); } }
.drawer-head { display: flex; align-items: center; gap: var(--s3); padding: var(--s4) var(--s5); border-bottom: 1px solid var(--border); }
.drawer-head h2 { font-size: var(--fs-16); }
.drawer-head .close { margin-left: auto; }
.drawer-body { flex: 1; overflow-y: auto; padding: var(--s5); }
.drawer-foot { display: flex; gap: var(--s2); justify-content: flex-end; padding: var(--s4) var(--s5); border-top: 1px solid var(--border); }

.modal-scrim { position: fixed; inset: 0; background: var(--overlay); z-index: var(--z-modal-backdrop);
  display: grid; place-items: center; padding: var(--s6); opacity: 0; animation: fade var(--dur) var(--ease) forwards; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--sh-3);
  width: min(460px, 96vw); z-index: var(--z-modal); transform: scale(0.97); opacity: 0; animation: pop 180ms var(--ease) forwards; }
@keyframes pop { to { transform: scale(1); opacity: 1; } }
.modal-body { padding: var(--s5); }
.modal-body h2 { font-size: var(--fs-16); margin-bottom: var(--s2); }
.modal-body p { color: var(--muted); font-size: var(--fs-13); }
.modal-foot { display: flex; gap: var(--s2); justify-content: flex-end; padding: var(--s4) var(--s5); border-top: 1px solid var(--border); }

/* ---- toasts --------------------------------------------------------------- */
.toasts { position: fixed; bottom: var(--s5); right: var(--s5); z-index: var(--z-toast); display: flex; flex-direction: column; gap: var(--s2); max-width: 380px; }
.toast { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s3) var(--s4); border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--sh-2); font-size: var(--fs-13);
  transform: translateX(120%); animation: toastin 260ms var(--ease) forwards; }
@keyframes toastin { to { transform: translateX(0); } }
.toast.out { animation: toastout 200ms var(--ease) forwards; }
@keyframes toastout { to { transform: translateX(120%); opacity: 0; } }
.toast .ic { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.toast.ok .ic { color: var(--ok); } .toast.danger .ic { color: var(--danger); } .toast.info .ic { color: var(--accent); }
.toast .msg { flex: 1; } .toast .msg b { display: block; font-weight: 600; }
.toast .msg span { color: var(--muted); }

/* ---- tooltip -------------------------------------------------------------- */
[data-tip] { position: relative; }
[data-tip]:hover::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); font-size: var(--fs-11); font-weight: 500; padding: 4px 8px; border-radius: var(--r-sm);
  white-space: nowrap; z-index: var(--z-tooltip); pointer-events: none; box-shadow: var(--sh-2); }

/* ---- misc utilities ------------------------------------------------------- */
.row { display: flex; align-items: center; gap: var(--s2); }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: var(--s2); }
.muted { color: var(--muted); }
.small { font-size: var(--fs-12); }
.spacer { flex: 1; }
.divider { height: 1px; background: var(--border); margin: var(--s4) 0; }
.pill-group { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--r-sm); overflow: hidden; }
.pill-group button { border: none; background: var(--surface); padding: var(--s2) var(--s3); font-size: var(--fs-12); font-weight: 600; color: var(--muted); cursor: pointer; }
.pill-group button.active { background: var(--accent-weak); color: var(--accent); }
.pill-group button + button { border-left: 1px solid var(--border); }

/* code / html preview */
.code { font-family: var(--mono); font-size: var(--fs-12); background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: var(--s3); overflow-x: auto; white-space: pre-wrap; word-break: break-word; }

/* progress meter */
.meter { height: 8px; border-radius: var(--r-full); background: var(--surface-2); overflow: hidden; }
.meter > span { display: block; height: 100%; width: 100%; background: var(--accent); border-radius: var(--r-full);
  transform-origin: left center; transform: scaleX(0); transition: transform 300ms var(--ease); }
.meter.ok > span { background: var(--ok); } .meter.warn > span { background: var(--warn); } .meter.danger > span { background: var(--danger); }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: var(--s6);
  background: radial-gradient(1200px 600px at 50% -10%, var(--accent-weak), transparent 60%), var(--bg); }
.login .card { width: min(400px, 96vw); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl);
  box-shadow: var(--sh-3); padding: var(--s8); }
.login .brand { height: auto; padding: 0; margin-bottom: var(--s6); }

/* ---- responsive ----------------------------------------------------------- */
@media (max-width: 1000px) {
  .cols-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: var(--z-drawer); transform: translateX(-100%); transition: transform 220ms var(--ease); width: 260px; }
  .app.nav-open .sidebar { transform: translateX(0); box-shadow: var(--sh-3); }
  .app.nav-open .nav-scrim { position: fixed; inset: 0; background: var(--overlay); z-index: var(--z-drawer-backdrop); }
  .menu-toggle { display: grid; }
  .cols-2, .cols-3 { grid-template-columns: 1fr; }
  .content { padding: var(--s4); }
  .kpi { border-right: none; border-bottom: 1px solid var(--border); }
}
/* Comfortable touch targets on touch devices (>= WCAG 2.5.5 44px). */
@media (pointer: coarse) {
  .btn, .icon-btn { min-height: 44px; }
  .btn.sm { min-height: 40px; padding: 0 var(--s4); }
  .input, .select { min-height: 44px; }
  .nav-item { padding-top: 11px; padding-bottom: 11px; }
  .tab { padding-top: var(--s3); padding-bottom: var(--s3); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* ---- campaign composer --------------------------------------------------- */
.composer { display: grid; grid-template-columns: 320px 1fr; gap: var(--s5); align-items: stretch; }
.composer .meta { min-width: 0; }
.composer .editor { display: flex; flex-direction: column; min-width: 0; }
.composer .editor-head { display: flex; align-items: center; gap: var(--s2); margin-bottom: var(--s2); }
.tplchips { display: flex; gap: var(--s1); flex-wrap: wrap; }
.composer .code-ed { flex: 1; min-height: 340px; font-family: var(--mono); font-size: var(--fs-12); line-height: 1.55;
  padding: var(--s3); border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); resize: vertical; }
.composer .code-ed:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.composer .preview-wrap { flex: 1; min-height: 340px; border: 1px solid var(--border); border-radius: var(--r-sm); overflow: hidden; }
.composer .preview-doc { width: 100%; height: 100%; min-height: 340px; max-height: 60vh; overflow: auto; background: #f4f5f7; color: #1a1d24; }
.composer .subtabs { display: flex; gap: var(--s1); margin-left: auto; }
.composer .subtab { font-size: var(--fs-12); font-weight: 600; color: var(--muted); padding: var(--s1) var(--s3); border-radius: var(--r-sm); cursor: pointer; }
.composer .subtab.active { background: var(--accent-weak); color: var(--accent); }
@media (max-width: 820px) { .composer { grid-template-columns: 1fr; } }
