:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-2: #f4f4f5;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --text: #18181b;
  --text-2: #52525b;
  --text-3: #71717a;
  --accent: #4f46e5;
  --accent-soft: #eef2ff;
  --ok: #15803d;
  --ok-soft: #f0fdf4;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --bad: #b91c1c;
  --bad-soft: #fef2f2;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.04);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0a0b;
    --surface: #111113;
    --surface-2: #18181b;
    --border: #27272a;
    --border-strong: #3f3f46;
    --text: #fafafa;
    --text-2: #a1a1aa;
    --text-3: #8b8b94;
    --accent: #818cf8;
    --accent-soft: #1e1b4b;
    --ok: #4ade80;
    --ok-soft: #052e16;
    --warn: #fbbf24;
    --warn-soft: #2a1d05;
    --bad: #f87171;
    --bad-soft: #2a0b0b;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0a0a0b; --surface: #111113; --surface-2: #18181b; --border: #27272a; --border-strong: #3f3f46;
  --text: #fafafa; --text-2: #a1a1aa; --text-3: #8b8b94; --accent: #818cf8; --accent-soft: #1e1b4b;
  --ok: #4ade80; --ok-soft: #052e16; --warn: #fbbf24; --warn-soft: #2a1d05; --bad: #f87171; --bad-soft: #2a0b0b;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
a.ext { color: var(--accent); word-break: break-word; }

.top {
  position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border);
}
.top-inner { max-width: 1120px; margin: 0 auto; padding: 0 24px; height: 52px; display: flex; align-items: center; gap: 28px; }
.brand { font-weight: 600; letter-spacing: -0.01em; display: flex; align-items: center; gap: 8px; }
.brand-mark { width: 18px; height: 18px; border-radius: 5px; background: linear-gradient(135deg, var(--accent), #06b6d4); }
.nav { display: flex; gap: 4px; }
.nav a { padding: 6px 10px; border-radius: 6px; color: var(--text-2); }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); }
.top-note { margin-left: auto; color: var(--text-3); font-size: 12px; }

main { max-width: 1120px; margin: 0 auto; padding: 32px 24px 80px; }
h1 { font-size: 22px; letter-spacing: -0.02em; margin: 0 0 6px; font-weight: 600; }
h2 { font-size: 15px; margin: 32px 0 12px; font-weight: 600; letter-spacing: -0.01em; }
h3 { font-size: 14px; margin: 0; font-weight: 600; }
.lede { color: var(--text-2); margin: 0 0 24px; max-width: 70ch; }
.muted { color: var(--text-3); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); font-size: 12.5px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.grid { display: grid; gap: 16px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; }
.stat { padding: 16px 20px; border-right: 1px solid var(--border); }
.stat:last-child { border-right: 0; }
.stat .label { color: var(--text-3); font-size: 12px; }
.stat .value { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 500; color: var(--text-3); font-size: 12px; padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 999px; font-size: 12px; border: 1px solid var(--border); color: var(--text-2); background: var(--surface); white-space: nowrap; }
.badge.ok { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.badge.warn { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.badge.bad { color: var(--bad); background: var(--bad-soft); border-color: transparent; }
.badge.accent { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

form.inline { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
label.field { display: grid; gap: 6px; font-size: 12px; color: var(--text-2); }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 6px; padding: 7px 10px; min-height: 34px;
}
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.check { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); min-height: 34px; }
button, .btn {
  font: inherit; font-weight: 500; cursor: pointer; border-radius: 6px; padding: 7px 14px; min-height: 34px;
  border: 1px solid var(--text); background: var(--text); color: var(--bg);
}
button.secondary, .btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
button.ghost { background: transparent; color: var(--text-2); border-color: transparent; padding: 5px 8px; min-height: 0; }
button.ghost:hover { color: var(--text); background: var(--surface-2); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.outlet { margin-top: 16px; }
.outlet-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.outlet-head .rank { color: var(--text-3); font-variant-numeric: tabular-nums; }
.outlet-head .meta { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.outlet-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); }
.outlet-body > section { padding: 16px 20px; }
.outlet-body > section + section { border-left: 1px solid var(--border); }
.kv { display: grid; gap: 12px; }
.kv .k { font-size: 12px; color: var(--text-3); margin-bottom: 2px; }
.pitch { white-space: pre-wrap; font-size: 13.5px; line-height: 1.6; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 14px 16px; }
.owner { background: var(--warn-soft); color: var(--warn); border-radius: 3px; padding: 0 2px; }
.subject { font-weight: 500; margin-bottom: 8px; }
.notes { margin: 10px 0 0; padding-left: 18px; color: var(--text-2); font-size: 12.5px; }
.notes li { margin: 2px 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.empty { padding: 40px 20px; text-align: center; color: var(--text-3); }
.job { font-family: var(--mono); font-size: 12px; color: var(--text-2); background: var(--surface-2); border-radius: 6px; padding: 10px 12px; max-height: 180px; overflow: auto; white-space: pre-wrap; margin-top: 12px; }
.callout { border: 1px solid var(--border); border-left: 3px solid var(--accent); background: var(--surface); padding: 12px 16px; border-radius: 6px; color: var(--text-2); margin-bottom: 20px; }
.status-select { min-height: 28px; padding: 3px 8px; font-size: 12px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 8px 14px; border-radius: 6px; font-size: 13px; opacity: 0; transition: opacity 0.15s; pointer-events: none; }
.toast.show { opacity: 1; }

@media (max-width: 760px) {
  .top-inner { padding: 0 16px; gap: 12px; }
  .top-note { display: none; }
  main { padding: 24px 16px 60px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat:nth-child(2) { border-right: 0; }
  .stat:nth-child(-n + 2) { border-bottom: 1px solid var(--border); }
  .outlet-body { grid-template-columns: 1fr; }
  .outlet-body > section + section { border-left: 0; border-top: 1px solid var(--border); }
  .outlet-head .meta { margin-left: 0; }
}

/* Print: a clean light copy of a report for a client PDF. */
@media print {
  :root, :root[data-theme="dark"] {
    --bg: #fff; --surface: #fff; --surface-2: #f6f6f7; --border: #ddd; --border-strong: #ccc;
    --text: #111; --text-2: #444; --text-3: #666; --accent: #3730a3; --accent-soft: #eef2ff;
    --ok: #166534; --ok-soft: #f0fdf4; --warn: #92400e; --warn-soft: #fffbeb; --shadow: none;
    color-scheme: light;
  }
  body { font-size: 11pt; }
  .top, .btn, button, select, .toast, #jobs { display: none !important; }
  main { padding: 0; max-width: none; }
  .outlet { break-inside: avoid; }
  a.ext { color: var(--text); text-decoration: underline; }
}

/* Login, campaign editing, sending settings. */
main.login { max-width: 380px; padding-top: 12vh; }
.logout { margin-left: 8px; }
.top-note + .logout { margin-left: 8px; }
.bad-text { color: var(--bad); margin: 0; }
.warn-callout { border-left-color: var(--warn); }
button.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.draft-form textarea, .draft-form input, #campaign-form textarea, #settings-form input[name="optOutLine"] { width: 100%; }
textarea { font: inherit; line-height: 1.55; resize: vertical; }
input:disabled, textarea:disabled { color: var(--text-2); background: var(--surface-2); }
.field { min-width: 0; }
