:root {
  --bg: #eef3f8;
  --ink: #12304c;
  --muted: #5b7388;
  --paper: #ffffff;
  --line: #d5e0ea;
  --header: #123a63;
  --accent: #1d5fa8;
  --accent-soft: #e8f1fa;
  --ok: #166534;
  --err: #9f1239;
  --shadow: 0 2px 8px rgba(18, 58, 99, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", "PT Sans", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
}

.top {
  display: flex;
  gap: 24px;
  align-items: center;
  padding: 14px 28px;
  background: var(--header);
  color: #f4f8fc;
}
.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  color: inherit;
  text-decoration: none;
}
.brand-mark {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  background: var(--accent);
  border-radius: 4px;
  font-weight: 700;
}
.brand small { display: block; color: #c5d6e8; font-size: 12px; }
.top nav { display: flex; gap: 16px; }
.top nav a { color: #f4f8fc; text-decoration: none; }
.flags { margin-left: auto; display: flex; gap: 8px; }

.wrap { width: min(1100px, calc(100% - 32px)); margin: 24px auto 64px; }
.foot {
  width: min(1100px, calc(100% - 32px));
  margin: 0 auto 28px;
  color: var(--muted);
  font-size: 13px;
}

h1, h2 { margin: 0 0 8px; font-weight: 650; }
.hero, .headline {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 16px;
}
.hero-actions, .inline { display: flex; gap: 8px; flex-wrap: wrap; }

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 18px;
  margin: 14px 0;
  box-shadow: var(--shadow);
}
.card.info { background: var(--accent-soft); }
.card.empty-choice { border-style: dashed; }
.grid {
  width: 100%;
  border-collapse: collapse;
  background: var(--paper);
  border-radius: 6px;
  overflow: hidden;
}
.grid th, .grid td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.grid.compact { box-shadow: none; border: 1px solid var(--line); }
.grid.finance td { font-variant-numeric: tabular-nums; white-space: nowrap; }
.empty { text-align: center; color: var(--muted); }
tr.is-active { background: var(--accent-soft); }

.btn {
  background: var(--accent);
  color: white;
  border: 0;
  border-radius: 3px;
  padding: 8px 14px;
  text-decoration: none;
  display: inline-block;
  cursor: pointer;
  font: inherit;
}
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn:disabled { background: #9bb4cc; cursor: not-allowed; }

.pill, .tag {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 3px;
  background: var(--accent-soft);
  color: var(--header);
  font-size: 12px;
}
.pill.muted { background: #2c4a6a; color: #e8f1fa; }
.pill.live { background: var(--ok); color: #ecfdf3; }
.badge { display: inline-block; padding: 2px 7px; border-radius: 3px; font-size: 12px; font-weight: 700; }
.badge.confirmed { background: #dcfce7; color: var(--ok); }
.badge.conflicting { background: #fee2e2; color: var(--err); }
.badge.unconfirmed { background: #e8f1fa; color: var(--header); }
.conflict-row { background: #fff1f2; }
.status {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 3px;
  background: var(--accent-soft);
  font-size: 12px;
}
.status.s-APPROVED, .status.s-ACTIVE_SEQUENCE { background: #dcfce7; color: var(--ok); }
.status.s-REPLIED, .status.s-MEETING { background: #dbeafe; }
.status.s-STOPPED { background: #fee2e2; color: var(--err); }

.flash {
  padding: 10px 12px;
  border-radius: 4px;
  margin-bottom: 16px;
}
.flash.ok { background: #ecfdf3; color: var(--ok); }
.flash.err { background: #fff1f2; color: var(--err); }
.hint { color: var(--muted); }
.form label, .letter label { display: block; margin: 10px 0; font-weight: 600; }
input, textarea {
  width: 100%;
  margin-top: 6px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 3px;
  font: inherit;
  background: white;
}
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 6px 16px; }
.kv dt { color: var(--muted); }
.prose { white-space: pre-wrap; line-height: 1.55; }
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.stats > div { background: var(--accent-soft); padding: 12px; border-radius: 4px; }
.stats strong, .stats span { display: block; }
.stats strong { font-size: 20px; }
.stats span { color: var(--muted); font-size: 13px; margin-top: 4px; }
.table-scroll { overflow-x: auto; }
.candidate-contact { margin: 8px 0; padding-top: 6px; border-top: 1px solid var(--line); }
.plain, .timeline, .hypotheses { padding-left: 18px; }
.hypotheses li { margin: 12px 0; }
.hypotheses li.selected { background: var(--accent-soft); padding: 10px; border-radius: 4px; list-style: none; }
.evidence, pre {
  white-space: pre-wrap;
  font-size: 13px;
  color: var(--muted);
  background: var(--accent-soft);
  padding: 8px;
  border-radius: 4px;
}
.warn-row { background: #f8fbfe; }
.ok-row { background: #f4fbf6; }
.sources-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.checko-blocks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.checko-blocks .mini {
  background: var(--accent-soft);
  border-radius: 4px;
  padding: 12px 14px;
}
.checko-blocks h3 { margin: 0 0 8px; font-size: 16px; }
.block-list { margin: 0; padding-left: 18px; }
.block-list li { margin: 4px 0; }
@media (max-width: 800px) {
  .sources-split, .checko-blocks { grid-template-columns: 1fr; }
}
.meta { color: var(--muted); font-size: 13px; }
code { font-family: Consolas, monospace; }
a { color: var(--accent); }

.tabs {
  display: flex;
  gap: 8px;
  margin: 0 0 16px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}
.audience-builder .tabs { flex-wrap: wrap; }
.audience-builder input[type="checkbox"] { width: auto; margin: 0; }
.audience-builder .audience-consent { display: flex; align-items: flex-start; gap: 10px; margin: 12px 0; }
.audience-builder .audience-consent input { margin-top: 4px; }
.audience-builder select { max-width: 100%; padding: 6px; }
.audience-builder .grid { min-width: 1020px; }
.audience-builder td:nth-child(3) { white-space: nowrap; }
@media (max-width: 720px) {
  body:has(.audience-builder) .top { flex-wrap: wrap; gap: 12px; padding: 14px 16px; }
  body:has(.audience-builder) .top nav { flex-wrap: wrap; }
  body:has(.audience-builder) .flags { margin-left: 0; }
}
.tab {
  padding: 8px 14px;
  border-radius: 4px;
  text-decoration: none;
  color: var(--muted);
  border: 1px solid transparent;
}
.tab.active {
  color: var(--ink);
  background: var(--paper);
  border-color: var(--line);
  font-weight: 600;
}
.recipient-list { display: flex; flex-direction: column; gap: 12px; }
.recipient-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 14px;
  background: #fbfdff;
}
.recipient-card-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: start;
  margin-bottom: 10px;
}
.recipient-meta { text-align: right; font-size: 13px; color: var(--muted); }
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.filters label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.flash.warn, .warn-text { color: #92400e; }
.manual-row td { background: #fafcff; font-size: 13px; }
.empty { color: var(--muted); padding: 24px; text-align: center; }

.stats-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.stats-grid-4 > div {
  min-height: 72px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  padding: 10px 12px;
  background: var(--accent-soft);
  border-radius: 4px;
}
@media (max-width: 960px) {
  .stats-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .stats-grid-4 { grid-template-columns: 1fr; }
}

.grid.compact th,
.grid.compact td {
  padding: 5px 8px;
  vertical-align: top;
  line-height: 1.35;
  font-size: 14px;
}
.grid.compact .hint,
.compact-hint {
  font-size: 13px;
  margin: 4px 0;
}
.col-revenue { min-width: 10.5rem; }
.nowrap-money { white-space: nowrap; }
.cell-fit { max-width: 16rem; }
.cell-tight { max-width: 11rem; }
.cell-company { min-width: 10rem; }
.badge-inline { display: inline-block; margin-left: 6px; font-size: 11px; }
.link-compact { font-size: 12px; word-break: break-all; }
.col-site { max-width: 14rem; font-size: 13px; }
.preview-body { white-space: pre-wrap; font-size: 14px; }
.inline-form { display: inline-flex; gap: 6px; flex-wrap: wrap; align-items: center; margin: 4px 0; }

.campaign-outreach-summary {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.campaign-outreach-summary .stats-row-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.campaign-outreach-summary .stats-row-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.campaign-outreach-summary .stats > div {
  padding: 12px 14px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 8px;
  background: var(--surface-muted, #f9fafb);
}
@media (max-width: 720px) {
  .campaign-outreach-summary .stats-row-3,
  .campaign-outreach-summary .stats-row-2 {
    grid-template-columns: 1fr;
  }
}

.campaign-economics {
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border, #e5e7eb);
}
.economics-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px 16px;
  margin: 12px 0;
}
.economics-grid > div {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.economics-grid span {
  font-size: 13px;
  color: var(--muted, #6b7280);
}
.economics-rate-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}
.economics-rate-form input[type="text"] {
  width: 5.5rem;
  padding: 6px 8px;
}
.rate-input-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
@media (max-width: 720px) {
  .economics-grid { grid-template-columns: 1fr; }
}

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 8px 0; border-bottom: 1px solid var(--border, #e5e7eb); }
.tech-block { font-size: 12px; white-space: pre-wrap; background: #f3f4f6; padding: 8px; border-radius: 6px; }
.experiment-editor .tabs { flex-wrap: wrap; }
.experiment-editor input[type="checkbox"], .experiment-editor input[type="radio"] { width: auto; margin: 0; }
@media (max-width: 720px) {
  body:has(.experiment-editor) .top { flex-wrap: wrap; gap: 12px; padding: 14px 16px; }
  body:has(.experiment-editor) .top nav { flex-wrap: wrap; }
  body:has(.experiment-editor) .flags { margin-left: 0; }
}
