:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --ink: #1c1f26;
  --muted: #6b7280;
  --line: #e3e5ea;
  --accent: #1f3a93;
  --accent-ink: #ffffff;
  --danger: #b42318;
  --ok: #1a7f4b;
  --warn: #b7791f;
  --radius: 10px;
  --font: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161b; --card: #1d2026; --ink: #e8eaee; --muted: #9aa0ab; --line: #2c3038;
    --accent: #6b86e8; --accent-ink: #0f1220;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); }
main, .login { max-width: 1040px; margin: 0 auto; padding: 24px 16px 64px; }
.login { max-width: 380px; margin-top: 15vh; }
.hidden { display: none !important; }
h1 { font-size: 24px; margin: 0 0 16px; }
h2 { font-size: 18px; margin: 0 0 4px; }
.eyebrow { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0 0 4px; }
.muted { color: var(--muted); margin: 0; }
small { color: var(--muted); font-size: 13px; }
header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; gap: 16px; }
nav { display: flex; gap: 4px; margin-top: 4px; }
nav a { padding: 6px 12px; border-radius: 6px; color: var(--muted); text-decoration: none; }
nav a.active { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / .06); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.actions { align-items: end; }
@media (max-width: 720px) { .grid { grid-template-columns: 1fr; } header { flex-direction: column; } }
label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 14px; }
label > input, label > textarea, form > input, .row > input { display: block; width: 100%; margin-top: 6px; padding: 9px 11px; font: inherit; font-weight: 400;
  color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 7px; }
textarea { resize: vertical; }
textarea[name="html"] { font: 13px/1.45 var(--mono); }
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
button { font: inherit; font-weight: 600; padding: 9px 16px; border-radius: 7px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); cursor: pointer; white-space: nowrap; }
button.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
button.ghost:hover { border-color: var(--accent); }
button.danger { color: var(--danger); }
button:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 10px; align-items: center; }
.row > input { margin-top: 0; width: auto; flex: 1 1 240px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.file { display: inline-block; font-weight: 600; font-size: 13px; color: var(--accent); cursor: pointer; margin: 0; }
.file input { display: none; }
.err { color: var(--danger); margin: 0; min-height: 1.5em; }
.err.ok { color: var(--ok); }
.progress { height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden; margin: 14px 0 8px; }
.progress div { height: 100%; background: var(--accent); width: 0; transition: width .4s; }
.counts { margin: 0; font-variant-numeric: tabular-nums; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
tbody tr[data-id] { cursor: pointer; }
tbody tr[data-id]:hover { background: var(--bg); }
td.mono { font: 12px/1.4 var(--mono); word-break: break-all; }
.st { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; background: var(--bg); }
.st-SENT, .st-DONE { color: var(--ok); }
.st-FAILED, .st-STOPPED { color: var(--danger); }
.st-RUNNING, .st-SENDING { color: var(--accent); }
.st-PAUSED, .st-SKIPPED, .st-PENDING { color: var(--warn); }
#html-preview { width: 100%; height: 520px; border: 1px solid var(--line); border-radius: 7px; background: #fff; margin-bottom: 14px; }
.tpl-row { margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
label.inline { display: flex; align-items: center; gap: 10px; margin: 0; }
select { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--bg); color: var(--ink); min-width: 260px; }
.deliv { display: block; margin-top: 6px; }
.deliv span { display: inline-block; margin-right: 10px; }
.deliv .ok { color: var(--ok); }
.deliv .bad { color: var(--danger); }
.tips { margin: 0; padding-left: 18px; }
.tips li { margin-bottom: 8px; }
#senders-table td:last-child { text-align: right; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--card);
  padding: 10px 16px; border-radius: 8px; font-size: 14px; box-shadow: 0 6px 24px rgb(0 0 0 / .2); max-width: 90vw; }
