/* MailFlow design system — one hand-written stylesheet, no build step.
   Tokens → base → layout → components → utilities. Light and dark. */

/* ---------- tokens ---------- */
:root {
  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --surface-3: #eef1f4;
  --fg: #161a20;
  --fg-2: #3f4650;
  --fg-muted: #6b7480;
  --fg-faint: #98a1ad;
  --line: #e3e7ec;
  --line-strong: #cdd3db;
  --accent: #0b6e8f;
  --accent-strong: #095a75;
  --accent-fg: #ffffff;
  --accent-soft: #e1f0f6;
  --accent-ink: #0a5570;
  --ok: #1e7b4e;
  --ok-soft: #e4f3ea;
  --warn: #9a5b06;
  --warn-soft: #fbefd9;
  --danger: #b3261e;
  --danger-soft: #fbe8e6;
  --info: #2f5fcf;
  --info-soft: #e7edfb;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-lg: 0 10px 30px rgba(16, 24, 40, .12);
  --radius: 10px;
  --radius-sm: 7px;
  --radius-xs: 5px;
  --sidebar-w: 236px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
/* data-theme is set on <html> before first paint (see base.html): the saved
   choice, else the OS preference. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111419;
  --surface: #181c22;
  --surface-2: #1d2229;
  --surface-3: #242a32;
  --fg: #e8ebef;
  --fg-2: #c3c9d1;
  --fg-muted: #929ba6;
  --fg-faint: #67707b;
  --line: #262c35;
  --line-strong: #353d48;
  --accent: #4db2d0;
  --accent-strong: #6cc3dd;
  --accent-fg: #0b1317;
  --accent-soft: #163038;
  --accent-ink: #8fd3e8;
  --ok: #4fc083;
  --ok-soft: #15301f;
  --warn: #e5a640;
  --warn-soft: #3a2a0e;
  --danger: #f0776e;
  --danger-soft: #3b1a17;
  --info: #7ea2f0;
  --info-soft: #1b2740;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-lg: 0 14px 40px rgba(0, 0, 0, .5);
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; line-height: 1.25; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
strong { font-weight: 600; }
code, kbd, .mono { font-family: var(--mono); font-size: .92em; }
code { background: var(--surface-3); padding: .1em .4em; border-radius: var(--radius-xs); }
pre { background: var(--surface-3); border-radius: var(--radius-sm); padding: 12px 14px; overflow: auto; font-family: var(--mono); font-size: 12px; line-height: 1.55; margin: 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
::selection { background: var(--accent-soft); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 6px; border: 2px solid var(--bg); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* ---------- app frame ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; z-index: 30;
  transition: transform .18s ease;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px; height: 56px; padding: 0 14px 0 18px;
  border-bottom: 1px solid var(--line); color: var(--fg); font-weight: 600; font-size: 14px;
}
.sidebar-brand a { color: inherit; display: flex; align-items: center; gap: 10px; flex: 1; }
.sidebar-brand a:hover { text-decoration: none; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 8px; background: var(--accent); color: var(--accent-fg);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px;
}
.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 10px 8px; }
.nav-group { margin-bottom: 14px; }
.nav-group-title {
  font-size: 11px; font-weight: 500; color: var(--fg-faint); padding: 4px 10px 6px; letter-spacing: .01em;
}
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--radius-sm);
  color: var(--fg-2); font-size: 13px; font-weight: 500; position: relative;
}
.nav-link:hover { background: var(--surface-2); color: var(--fg); text-decoration: none; }
.nav-link.active { background: var(--accent-soft); color: var(--accent-ink); }
.nav-link.active::before {
  content: ""; position: absolute; left: -10px; top: 7px; bottom: 7px; width: 3px; border-radius: 2px; background: var(--accent);
}
.nav-link .ico { width: 17px; height: 17px; flex: none; opacity: .85; }
.nav-link .nav-count { margin-left: auto; font-size: 11px; color: var(--fg-faint); font-variant-numeric: tabular-nums; }
.sidebar-foot { border-top: 1px solid var(--line); padding: 10px; display: flex; flex-direction: column; gap: 4px; }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 6px 10px; font-size: 12.5px; color: var(--fg-muted); }
.avatar {
  width: 26px; height: 26px; border-radius: 50%; background: var(--surface-3); color: var(--fg-2);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: 11px; flex: none;
}
.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; transition: margin .18s ease; }
.content { padding: 24px 32px 48px; max-width: 1320px; }
.topbar-mobile { display: none; }
.sidebar-collapsed .sidebar { transform: translateX(-100%); }
.sidebar-collapsed .main { margin-left: 0; }
.sidebar-show { position: fixed; top: 12px; left: 12px; z-index: 31; }
html:not(.sidebar-collapsed) .sidebar-show { display: none !important; }

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .sidebar-open .sidebar { transform: none; }
  .main { margin-left: 0 !important; }
  .content { padding: 16px 16px 40px; }
  .topbar-mobile {
    display: flex; align-items: center; justify-content: space-between; height: 52px; padding: 0 12px 0 16px;
    background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
    font-weight: 600;
  }
  .sidebar-show { display: none !important; }
  .scrim { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 29; display: none; }
  .sidebar-open .scrim { display: block; }
}

/* ---------- page header ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { display: flex; align-items: center; gap: 10px; }
.page-sub { color: var(--fg-muted); margin-top: 4px; font-size: 13px; }
.crumbs { font-size: 12.5px; color: var(--fg-muted); margin-bottom: 6px; display: flex; gap: 6px; align-items: center; }
.crumbs a { color: var(--fg-muted); }
.crumbs .sep { color: var(--fg-faint); }
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- sections & cards ---------- */
.section { margin-bottom: 28px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.section-head h2 { font-size: 14.5px; }
.section-head .aside { font-size: 12.5px; color: var(--fg-muted); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.card-head h2, .card-head h3 { font-size: 13.5px; font-weight: 600; }
.card-body { padding: 18px; }
.card-body + .card-body { border-top: 1px solid var(--line); }
.card-foot { padding: 12px 18px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); display: flex; gap: 8px; align-items: center; justify-content: flex-end; }
.card.flush .card-body { padding: 0; }
.subcard { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.stats.tight { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px 12px; min-width: 0; }
.stat-label { font-size: 12px; color: var(--fg-muted); display: flex; align-items: center; gap: 6px; }
.stat-value { font-size: 26px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; margin-top: 4px; line-height: 1.1; }
.stat-value small { font-size: 13px; font-weight: 500; color: var(--fg-muted); letter-spacing: 0; margin-left: 4px; }
.stat-sub { font-size: 12px; color: var(--fg-muted); margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat.accent { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); background: linear-gradient(180deg, var(--accent-soft), var(--surface) 70%); }
.stat.accent .stat-value { color: var(--accent-ink); }

/* the live rail — the one bold element */
.rail {
  background: var(--fg); color: var(--bg); border-radius: var(--radius); padding: 16px 20px;
  display: grid; grid-template-columns: auto 1fr auto; gap: 20px; align-items: center; margin-bottom: 22px;
}
:root[data-theme="dark"] .rail { background: var(--surface-3); color: var(--fg); }
.rail-rate { font-size: 34px; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1; }
.rail-rate small { font-size: 13px; font-weight: 500; opacity: .7; letter-spacing: 0; margin-left: 6px; }
.rail-meta { display: flex; gap: 22px; flex-wrap: wrap; font-size: 12.5px; opacity: .85; font-variant-numeric: tabular-nums; }
.rail-meta b { font-weight: 600; opacity: 1; }
.rail-track { grid-column: 1 / -1; height: 6px; border-radius: 4px; background: rgba(255,255,255,.14); overflow: hidden; }
.rail-fill { height: 100%; background: var(--accent); border-radius: 4px; transition: width .6s ease; }
.pulse { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 var(--ok); animation: pulse 1.8s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 45%, transparent); } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; font-weight: 500; font-size: 12px; color: var(--fg-muted);
  padding: 9px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap;
  position: sticky; top: 0; z-index: 1;
}
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table th:first-child, .table td:first-child { padding-left: 18px; }
.table th:last-child, .table td:last-child { padding-right: 18px; }
.table .num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions form { display: inline; }
.table .primary { font-weight: 500; color: var(--fg); }
.table .muted { color: var(--fg-muted); }
.table.compact th, .table.compact td { padding: 6px 10px; }
.table.plain th { background: transparent; }
.empty { padding: 36px 18px; text-align: center; color: var(--fg-muted); font-size: 13px; }
.empty .ico { width: 28px; height: 28px; color: var(--fg-faint); margin-bottom: 8px; }
.empty b { display: block; color: var(--fg); font-weight: 600; margin-bottom: 4px; }

/* ---------- status ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 500; line-height: 1.6; white-space: nowrap;
  background: var(--surface-3); color: var(--fg-2);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.nodot::before { display: none; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-accent { background: var(--accent-soft); color: var(--accent-ink); }
.badge-muted { background: var(--surface-3); color: var(--fg-muted); }
.status { display: inline-flex; align-items: center; gap: 7px; font-weight: 500; white-space: nowrap; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--fg-faint); flex: none; }
.status-ok::before { background: var(--ok); }
.status-warn::before { background: var(--warn); }
.status-danger::before { background: var(--danger); }
.status-info::before { background: var(--info); }
.status-accent::before { background: var(--accent); }
.status-live::before { background: var(--ok); box-shadow: 0 0 0 0 var(--ok); animation: pulse 1.8s infinite; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; cursor: pointer;
  font: inherit; font-size: 13px; font-weight: 500; line-height: 1; padding: 8px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--fg); white-space: nowrap;
  transition: background .12s ease, border-color .12s ease, color .12s ease, box-shadow .12s ease;
  text-decoration: none !important;
}
.btn .ico { width: 15px; height: 15px; }
.btn:hover { background: var(--surface-2); border-color: var(--fg-faint); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn-primary:disabled { background: var(--surface-3); color: var(--fg-muted); border-color: var(--line); opacity: 1; box-shadow: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--accent-fg); }
.btn-dark { background: var(--fg); border-color: var(--fg); color: var(--bg); }
.btn-dark:hover { background: var(--fg-2); border-color: var(--fg-2); color: var(--bg); }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--fg-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--fg); }
.btn-sm { padding: 5px 9px; font-size: 12px; border-radius: var(--radius-xs); }
.btn-sm .ico { width: 13px; height: 13px; }
.btn-xs { padding: 3px 7px; font-size: 11.5px; border-radius: var(--radius-xs); }
.btn-icon { padding: 7px; }
.btn-icon.btn-sm { padding: 5px; }
.btn-block { width: 100%; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.btn-group .btn.active { background: var(--fg); color: var(--bg); border-color: var(--fg); position: relative; z-index: 1; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field + .field, .form-row + .form-row, .form-row + .field, .field + .form-row { margin-top: 14px; }
.label { font-size: 12.5px; font-weight: 500; color: var(--fg-2); }
.label .opt { color: var(--fg-faint); font-weight: 400; margin-left: 4px; }
.help { font-size: 12px; color: var(--fg-muted); line-height: 1.45; }
.input, .select, .textarea {
  font: inherit; font-size: 13.5px; color: var(--fg); background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); padding: 8px 10px; width: 100%; min-width: 0; line-height: 1.4;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.input::placeholder, .textarea::placeholder { color: var(--fg-faint); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.sm, .select.sm { padding: 5px 8px; font-size: 12.5px; }
.input.w-xs { width: 90px; } .input.w-sm { width: 140px; } .input.w-md { width: 220px; } .input.w-lg { width: 300px; }
.select { appearance: none; padding-right: 30px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%236b7480' stroke-width='1.6'%3E%3Cpath d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center; background-size: 16px; }
.textarea { min-height: 120px; resize: vertical; }
.textarea.code { font-family: var(--mono); font-size: 12.5px; line-height: 1.55; }
.check { display: flex; align-items: flex-start; gap: 9px; font-size: 13px; cursor: pointer; }
.check input { margin: 3px 0 0; accent-color: var(--accent); width: 15px; height: 15px; flex: none; }
.check .help { margin-top: 1px; }
.form-row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.form-actions { display: flex; gap: 8px; align-items: center; margin-top: 18px; }
.choice { display: block; cursor: pointer; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice-box { border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 10px 12px; height: 100%; background: var(--surface); transition: border-color .12s ease, background .12s ease; }
.choice-box b { display: block; font-size: 13px; }
.choice-box span { font-size: 12px; color: var(--fg-muted); }
.choice input:checked + .choice-box { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.choice input:focus-visible + .choice-box { outline: 2px solid var(--accent); outline-offset: 2px; }
.tagbar { display: flex; flex-wrap: wrap; gap: 5px; }
.tag { font-family: var(--mono); font-size: 11px; padding: 2px 7px; border-radius: var(--radius-xs); border: 1px solid var(--line); background: var(--surface-2); cursor: pointer; color: var(--fg-2); }
.tag:hover { border-color: var(--accent); color: var(--accent-ink); }
.upload { border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); padding: 14px; background: var(--surface-2); font-size: 12.5px; color: var(--fg-muted); }
input[type="file"] { font-size: 12.5px; }

/* ---------- alerts / toasts ---------- */
.alert { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 14px; font-size: 13px; display: flex; gap: 10px; align-items: flex-start; background: var(--surface); }
.alert .ico { width: 16px; height: 16px; flex: none; margin-top: 1px; }
.alert-ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 30%, var(--line)); color: var(--ok); }
.alert-warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, var(--line)); color: var(--warn); }
.alert-danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 30%, var(--line)); color: var(--danger); }
.alert-info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 30%, var(--line)); color: var(--info); }
.alert-accent { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); color: var(--accent-ink); }
.alert b { font-weight: 600; }
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 50; display: flex; flex-direction: column; gap: 8px; max-width: 420px; }
.toast {
  background: var(--fg); color: var(--bg); padding: 11px 14px; border-radius: var(--radius-sm); font-size: 13px;
  display: flex; gap: 10px; align-items: flex-start; box-shadow: var(--shadow-lg); animation: toast-in .2s ease;
}
:root[data-theme="dark"] .toast { background: var(--surface-3); color: var(--fg); border: 1px solid var(--line-strong); }
.toast .ico { width: 16px; height: 16px; flex: none; margin-top: 1px; }
.toast-ok .ico { color: var(--ok); } .toast-danger .ico { color: var(--danger); } .toast-warn .ico { color: var(--warn); } .toast-info .ico { color: var(--accent); }
.toast .close { margin-left: auto; background: none; border: 0; color: inherit; opacity: .6; cursor: pointer; font-size: 16px; line-height: 1; padding: 0 2px; }
.toast .close:hover { opacity: 1; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tab { padding: 9px 12px; font-size: 13px; font-weight: 500; color: var(--fg-muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; background: none; border-top: 0; border-left: 0; border-right: 0; cursor: pointer; font-family: inherit; }
.tab:hover { color: var(--fg); text-decoration: none; }
.tab.active { color: var(--fg); border-bottom-color: var(--accent); }
.tab .count { font-size: 11px; color: var(--fg-faint); margin-left: 5px; font-variant-numeric: tabular-nums; }
.pills { display: inline-flex; gap: 4px; background: var(--surface-3); padding: 3px; border-radius: var(--radius-sm); }
.pill { white-space: nowrap; padding: 4px 10px; font-size: 12px; font-weight: 500; border-radius: var(--radius-xs); color: var(--fg-muted); cursor: pointer; border: 0; background: transparent; font-family: inherit; }
.pill:hover { color: var(--fg); text-decoration: none; }
.pill.active { background: var(--surface); color: var(--fg); box-shadow: var(--shadow); }

/* ---------- progress ---------- */
.progress { height: 6px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--accent); border-radius: 4px; transition: width .5s ease; }
.progress-bar.ok { background: var(--ok); } .progress-bar.warn { background: var(--warn); } .progress-bar.danger { background: var(--danger); }
.meter { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--fg-muted); font-variant-numeric: tabular-nums; }
.meter .progress { flex: 1; }

/* ---------- misc ---------- */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 13px; }
.kv dt { color: var(--fg-muted); margin: 0; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 18px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--fg-muted); }
.pager .btns { display: flex; gap: 6px; }
.preview-frame { width: 100%; height: 420px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; }
.inbox-row { display: flex; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.inbox-row .avatar { width: 34px; height: 34px; font-size: 13px; }
.inbox-row .from { font-weight: 600; font-size: 13px; }
.inbox-row .subj { font-size: 13px; margin-top: 1px; }
.inbox-row .snip { font-size: 12px; color: var(--fg-muted); margin-top: 1px; }
.dropzone { border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); padding: 12px 14px; background: var(--surface-2); }
.notice { font-size: 12.5px; color: var(--fg-muted); }
.divider { border-top: 1px solid var(--line); margin: 16px 0; }
.ico { width: 16px; height: 16px; display: inline-block; vertical-align: -3px; flex: none; }
details > summary { cursor: pointer; font-weight: 500; font-size: 13px; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary:not(.btn)::before { content: "▸"; display: inline-block; margin-right: 6px; color: var(--fg-faint); transition: transform .12s; }
details[open] > summary::before { transform: rotate(90deg); }
.sparkline { display: flex; align-items: flex-end; gap: 2px; height: 28px; }
.sparkline i { flex: 1; background: var(--accent); opacity: .35; border-radius: 2px 2px 0 0; min-height: 2px; }
.sparkline i:last-child { opacity: 1; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 380px; }

/* ---------- utilities ---------- */
.hidden { display: none !important; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-lg { display: flex; flex-direction: column; gap: 24px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.grid-main { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
@media (max-width: 1100px) { .grid-2, .grid-3, .grid-main { grid-template-columns: 1fr; } }
.muted { color: var(--fg-muted); }
.faint { color: var(--fg-faint); }
.small { font-size: 12px; }
.xs { font-size: 11.5px; }
.num { font-variant-numeric: tabular-nums; }
.ok { color: var(--ok); } .warn { color: var(--warn); } .danger { color: var(--danger); } .accent { color: var(--accent-ink); }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-0 { margin-top: 0 !important; } .mt-1 { margin-top: 6px; } .mt-2 { margin-top: 12px; } .mt-3 { margin-top: 18px; } .mt-4 { margin-top: 24px; }
.mb-1 { margin-bottom: 6px; } .mb-2 { margin-bottom: 12px; } .mb-3 { margin-bottom: 18px; }
.ml-auto { margin-left: auto; }
.w-full { width: 100%; }
.right { text-align: right; }
.center { text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- campaign list rows ---------- */
.camp-row { display: grid; grid-template-columns: minmax(0, 1fr) 390px max-content; gap: 22px; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.camp-row:last-child { border-bottom: 0; }
.camp-row:hover { background: var(--surface-2); }
.camp-row.live { box-shadow: inset 3px 0 0 var(--ok); }
.camp-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.camp-title a { font-weight: 600; font-size: 14px; color: var(--fg); }
.camp-meta { font-size: 12px; color: var(--fg-muted); margin-top: 3px; line-height: 1.6; }
.camp-meta .sep { color: var(--line-strong); margin: 0 6px; }
.camp-meta b { font-weight: 500; color: var(--fg-2); }
.camp-nums { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; text-align: right; }
.camp-nums .v { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.2; }
.camp-nums .l { font-size: 11px; color: var(--fg-faint); }
.camp-actions { display: flex; gap: 6px; justify-content: flex-end; align-items: center; }
.camp-actions form { display: inline; }
.live-tag { display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px; font-weight: 600; letter-spacing: .02em; color: var(--ok); background: var(--ok-soft); padding: 1px 7px; border-radius: 999px; }
@media (max-width: 1200px) { .camp-row { grid-template-columns: 1fr; gap: 10px; } .camp-nums { text-align: left; } .camp-actions { justify-content: flex-start; } }

/* ---------- additions from the page conversions ---------- */
.form-row > .field { margin-top: 0 !important; }
.form-row > .field.span { grid-column: 1 / -1; }
.card-body.flush { padding: 0; }
.card-body + .table-wrap, .card-body + .table { border-top: 1px solid var(--line); }
.grow { flex: 1 1 auto; min-width: 0; }
.grid-2.start, .grid-3.start, .grid-main.start { align-items: start; }
.select.w-sm { width: 140px; } .select.w-md { width: 220px; } .select.w-lg { width: 320px; } .select.auto { width: auto; }
.row.bottom { align-items: flex-end; }
.check.center { align-items: center; }
.wrap-any { overflow-wrap: anywhere; }
.row.wrap { flex-wrap: wrap; }
.progress.w-sm { width: 96px; flex: none; }
.ico-lg { width: 40px; height: 40px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; }
.ico-lg .ico { width: 20px; height: 20px; }
.rail-fill.warn { background: var(--warn); }

/* ---------- modal (native <dialog>) ---------- */
.modal { border: 1px solid var(--line); border-radius: 14px; padding: 0; width: min(640px, calc(100vw - 32px)); background: var(--surface); color: var(--fg); box-shadow: 0 24px 64px rgba(0,0,0,.28); }
.modal::backdrop { background: rgba(10, 12, 20, .55); backdrop-filter: blur(2px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.modal-body { padding: 18px 20px; max-height: min(70vh, 640px); overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--surface-2, var(--surface)); border-radius: 0 0 14px 14px; }
.modal .stat-value.ok { color: var(--ok); }

/* ---------- bulk selection bar ---------- */
.bulk-bar { display: none; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; margin-bottom: 12px; border: 1px solid var(--accent-line, var(--line)); background: var(--accent-soft, var(--surface-2, var(--surface))); border-radius: 10px; }
.bulk-bar.on { display: flex; }
.bulk-bar .count { font-weight: 600; margin-right: auto; }
.table td.chk, .table th.chk { width: 28px; padding-right: 0; }
.table .chk input { width: 15px; height: 15px; vertical-align: middle; cursor: pointer; }
.table tr.subrow td { background: var(--surface-2); font-size: 12.5px; padding-top: 5px; padding-bottom: 5px; border-top: 0; }

/* ---------- heat grid (best time to send) ---------- */
.heat { border-collapse: separate; border-spacing: 3px; width: 100%; font-size: 12px; }
.heat th { font-weight: 500; color: var(--fg-muted); text-align: center; padding: 2px 0; font-size: 11px; }
.heat tbody th { text-align: right; padding-right: 8px; white-space: nowrap; }
.heat td.cell { height: 30px; min-width: 24px; border-radius: 5px; background: color-mix(in srgb, var(--accent) calc(var(--v, 0) * 100%), var(--surface-3)); text-align: center; color: #fff; font-size: 10.5px; font-weight: 600; }
.heat td.cell span { text-shadow: 0 1px 2px rgba(0,0,0,.35); }
.heat td.rowtotal, .heat th.rowtotal { padding-left: 8px; color: var(--fg-muted); white-space: nowrap; }
.heat tr.coltotal td.cell.bar { background: transparent; height: 34px; vertical-align: bottom; padding: 0; }
.heat tr.coltotal td.cell.bar i { display: block; height: calc(4px + var(--v, 0) * 30px); background: var(--accent); border-radius: 3px 3px 0 0; opacity: .85; }
@supports not (background: color-mix(in srgb, red 50%, blue)) {
  .heat td.cell { background: var(--accent); opacity: calc(0.12 + var(--v, 0) * 0.88); }
}
.tag.tag-spin { border-style: dashed; color: var(--accent-ink); }
