:root {
  --bg: #f6f6f4; --surface: #ffffff; --surface-2: #f0f0ec; --border: #e3e3de; --border-strong: #cfcfc8;
  --text: #1b1c1e; --muted: #6b6d72; --faint: #9a9ca1;
  --accent: #2f5bd3; --accent-soft: #e8eefc; --accent-text: #ffffff;
  --ok: #1f7a4d; --ok-soft: #e3f3ea; --warn: #9a6200; --warn-soft: #fbf0d9; --fail: #b3261e; --fail-soft: #fbe6e4;
  --radius: 8px; --shadow: 0 1px 2px rgba(20,20,20,.04), 0 1px 1px rgba(20,20,20,.03);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131416; --surface: #1b1c1f; --surface-2: #222327; --border: #2c2d32; --border-strong: #3a3b41;
    --text: #e8e8ea; --muted: #9a9ca3; --faint: #6c6e75;
    --accent: #6d8ff0; --accent-soft: #1f2a47; --accent-text: #0f1320;
    --ok: #5cc28d; --ok-soft: #173326; --warn: #e0a84a; --warn-soft: #36290f; --fail: #f07a70; --fail-soft: #3d1b19;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); font-feature-settings: "tnum" 1; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; font-weight: 650; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 12px; }
h3 { font-size: 13px; font-weight: 600; margin: 0 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.layout { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 20px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 2px; }
.brand { font-weight: 700; font-size: 16px; padding: 4px 10px 18px; display: flex; align-items: center; gap: 8px; }
.brand .dot { width: 10px; height: 10px; border-radius: 3px; background: var(--accent); }
.nav a { display: flex; justify-content: space-between; align-items: center; padding: 7px 10px; border-radius: 6px; color: var(--text); }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav .count { font-size: 12px; background: var(--accent); color: var(--accent-text); border-radius: 10px; padding: 0 7px; }
.sidebar .foot { margin-top: auto; font-size: 12px; color: var(--muted); padding: 10px; display: grid; gap: 6px; }
.main { padding: 28px 32px 60px; max-width: 1320px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-side { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.stat .v { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; }
.stat .l { color: var(--muted); font-size: 12.5px; }
.stat .d { color: var(--faint); font-size: 12px; margin-top: 2px; }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); padding: 7px 13px; border-radius: 6px; font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--fail); }
.btn.small { padding: 4px 9px; font-size: 13px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn[disabled], .btn.htmx-request { opacity: .6; pointer-events: none; }
form.inline { display: inline; }
label { display: block; font-size: 12.5px; color: var(--muted); margin: 0 0 4px; font-weight: 500; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); border-radius: 6px; padding: 7px 10px; font: inherit;
}
textarea { font-family: var(--mono); font-size: 13px; line-height: 1.55; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.field { margin-bottom: 14px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > .field { flex: 1 1 160px; }
.check { display: inline-flex; align-items: center; gap: 6px; color: var(--text); font-size: 14px; margin-right: 12px; }
.hint { color: var(--faint); font-size: 12px; margin-top: 4px; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12.5px; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
.table-wrap { overflow-x: auto; margin: -6px -8px; }
td.num, th.num { text-align: right; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; font-weight: 500; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.ok, .badge.valid, .badge.active, .badge.interested, .badge.inbox, .badge.sent, .badge.done { background: var(--ok-soft); color: var(--ok); }
.badge.warn, .badge.risky, .badge.paused, .badge.auto_reply, .badge.queued, .badge.pending, .badge.other, .badge.missing { background: var(--warn-soft); color: var(--warn); }
.badge.fail, .badge.invalid, .badge.bounced, .badge.bounce, .badge.not_interested, .badge.unsubscribed, .badge.unsubscribe, .badge.spam, .badge.failed { background: var(--fail-soft); color: var(--fail); }
.badge.dry_run { background: var(--warn-soft); color: var(--warn); }
.badge.replied { background: var(--accent-soft); color: var(--accent); }
.alert { padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; border: 1px solid; }
.alert.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.alert.error { background: var(--fail-soft); color: var(--fail); border-color: transparent; }
.alert.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.muted { color: var(--muted); } .small { font-size: 12.5px; } .mono { font-family: var(--mono); font-size: 12.5px; }
.pre { white-space: pre-wrap; font-family: var(--font); font-size: 14px; background: var(--surface-2); border-radius: 6px; padding: 12px; margin: 4px 0 12px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--text); border-color: var(--accent); font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--text); }
.pills { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.pills a { padding: 4px 11px; border-radius: 14px; border: 1px solid var(--border); color: var(--muted); font-size: 13px; }
.pills a.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.pills a:hover { text-decoration: none; border-color: var(--border-strong); }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 120px; padding-top: 8px; }
.bars .b { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 2px; height: 100%; }
.bars .col { width: 100%; max-width: 26px; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 1px; opacity: .85; }
.bars .col.r { background: var(--ok); }
.bars .lbl { font-size: 10.5px; color: var(--faint); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.progress { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); }
.ladder { display: flex; gap: 6px; }
.ladder .s { flex: 1; text-align: center; padding: 8px 4px; border-radius: 6px; background: var(--surface-2); font-size: 12px; color: var(--muted); }
.ladder .s b { display: block; font-size: 16px; color: var(--text); }
.ladder .s.on { background: var(--accent); color: var(--accent-text); }
.ladder .s.on b { color: var(--accent-text); }
.ladder .s.done { background: var(--accent-soft); }
.step-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; background: var(--surface); }
.step-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 10px; }
.step-head .n { font-weight: 600; }
.step-tools { display: flex; gap: 6px; flex-wrap: wrap; }
.ai-slot:empty { display: none; }
.ai-result { border: 1px dashed var(--accent); border-radius: 6px; padding: 12px; margin-top: 10px; background: var(--accent-soft); }
.ai-result .pre { background: var(--surface); }
.ai-result-head { font-weight: 600; margin-bottom: 8px; }
.issues { margin: 0 0 10px; padding-left: 18px; }
.msg { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; background: var(--surface); }
.msg.in { border-left: 3px solid var(--ok); }
.msg.out { border-left: 3px solid var(--accent); }
.msg-head { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 12.5px; margin-bottom: 8px; flex-wrap: wrap; }
.msg-body { white-space: pre-wrap; }
.empty { text-align: center; color: var(--muted); padding: 36px 10px; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 6px 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-word; }
.login { max-width: 360px; margin: 14vh auto; }
.spinner { display: none; } .htmx-request .spinner, .htmx-request.spinner { display: inline-block; }
.pager { display: flex; gap: 6px; margin-top: 14px; align-items: center; }
.vars { display: flex; flex-wrap: wrap; gap: 4px; }
.vars code { background: var(--surface-2); border-radius: 4px; padding: 1px 6px; font-size: 12px; cursor: pointer; }
.dry { background: var(--warn-soft); color: var(--warn); padding: 6px 10px; border-radius: 6px; font-weight: 500; }
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: 10px; }
  .sidebar .foot { display: none; }
  .brand { padding: 4px 10px; }
  .main { padding: 18px 16px 40px; }
  .g2, .g3, .g4, .g-side { grid-template-columns: 1fr; }
}
