:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --ink: #1d1b19;
  --muted: #6b655e;
  --line: #e4dfd7;
  --accent: #8a1c1c;
  --accent-ink: #ffffff;
  --ok: #2f6b3a;
  --warn: #8a5a00;
  --bad: #a12222;
  --radius: 6px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); line-height: 1.5; }
[hidden] { display: none !important; }
h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; font-weight: normal; margin: 0 0 12px; }
h2 { font-size: 1.6rem; }
h3 { font-size: 1.2rem; margin-top: 32px; }
.eyebrow { display: block; font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }

button {
  font: inherit; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
  padding: 8px 16px; border-radius: var(--radius); cursor: pointer; min-height: 40px;
}
button:disabled { opacity: .5; cursor: not-allowed; }
button.quiet { background: transparent; color: var(--ink); border-color: var(--line); }
button.small { min-height: 32px; padding: 4px 10px; font-size: .88rem; }
input, select, textarea {
  font: inherit; width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--ink); min-height: 40px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: block; font-size: .9rem; color: var(--muted); margin-top: 12px; }
label.check { display: flex; gap: 8px; align-items: center; color: var(--ink); margin: 6px 0; }
label.check input { width: auto; min-height: 0; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px 12px; margin: 12px 0 0; }
legend { font-size: .9rem; color: var(--muted); padding: 0 4px; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-box { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; }
.login-box button { width: 100%; margin-top: 16px; }

.top { background: var(--surface); border-bottom: 1px solid var(--line); padding: 12px 16px; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.brand strong { font-family: Georgia, serif; font-weight: normal; font-size: 1.25rem; }
.tabs { display: flex; gap: 4px; overflow-x: auto; max-width: 100%; }
.tabs button { background: transparent; color: var(--ink); border: 1px solid transparent; white-space: nowrap; }
.tabs button.active { border-color: var(--line); background: var(--bg); color: var(--accent); }

main { max-width: 960px; margin: 0 auto; padding: 24px 16px 64px; }
.flash { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent); padding: 10px 14px; border-radius: var(--radius); }
.error { color: var(--bad); }
.hint { color: var(--muted); font-size: .9rem; }
.stack { display: flex; flex-direction: column; max-width: 560px; }
.stack button { align-self: flex-start; margin-top: 16px; }
.inline { max-width: 560px; margin: 16px 0; }
.row { display: flex; gap: 8px; }
.row input { flex: 1; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 0 0 16px; }
.grid div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.grid dt { font-size: .82rem; color: var(--muted); }
.grid dd { margin: 4px 0 0; font-size: 1.15rem; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: .94rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; font-size: .82rem; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.preview { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-top: 8px; white-space: pre-wrap; font-size: .94rem; }
.preview .problem { color: var(--bad); margin-top: 8px; }

.campaign { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-top: 16px; }
.campaign header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 8px; }
.campaign .meta { color: var(--muted); font-size: .88rem; }
.campaign .note { color: var(--warn); font-size: .9rem; margin: 6px 0 0; }
.counts { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 10px 0; font-size: .92rem; }
.counts b { font-variant-numeric: tabular-nums; }
.bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; align-items: center; }
.actions a { color: var(--accent); font-size: .88rem; padding: 4px 6px; }
.badge { font-size: .8rem; padding: 2px 8px; border-radius: 10px; border: 1px solid var(--line); }
.badge.running { color: var(--ok); border-color: var(--ok); }
.badge.paused { color: var(--warn); border-color: var(--warn); }
.badge.cancelled { color: var(--muted); }

.messages { list-style: none; padding: 0; margin: 0; }
.messages li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 8px; }
.messages .who { font-size: .85rem; color: var(--muted); }

@media (max-width: 560px) {
  .top { padding: 10px 16px; }
  h2 { font-size: 1.35rem; }
  .row { flex-direction: column; }
  .tabs { flex-wrap: wrap; overflow: visible; }
  .tabs button { padding: 6px 10px; }
}
