:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --border: #e3e6ea;
  --text: #1c2430;
  --muted: #6b7684;
  --accent: #2456e6;
  --accent-soft: #e8eefc;
  --green: #1a9b62;
  --amber: #c07d10;
  --red: #cc3b3b;
  --radius: 10px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 210px; flex-shrink: 0; color: #c6cede;
  padding: 20px 0; display: flex; flex-direction: column; gap: 2px;
  background:
    radial-gradient(500px 300px at 0% -5%, rgba(64, 110, 235, .28), transparent 60%),
    radial-gradient(400px 400px at 120% 110%, rgba(38, 70, 160, .30), transparent 55%),
    linear-gradient(165deg, #0b1526 0%, #101d38 60%, #0c1830 100%);
}
.brand-chip {
  background: #fff; border-radius: 10px; margin: 0 16px 8px; padding: 9px 14px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .3);
}
.brand-chip img { display: block; height: 30px; max-width: 100%; }
.brand-sub {
  padding: 0 20px 16px; color: #7f93b6; font-size: 10.5px; font-weight: 700;
  letter-spacing: 2.5px; text-transform: uppercase;
}
.sidebar a {
  color: #c6cede; padding: 9px 20px; display: block; border-left: 3px solid transparent;
}
.sidebar a:hover { background: #182338; text-decoration: none; }
.sidebar a.active { background: #1b2a45; color: #fff; border-left-color: #6f9bff; }
.sidebar .foot { margin-top: auto; padding: 12px 20px; font-size: 12px; color: #5d6a80; }
.ver-tag { font-size: 10.5px; color: #5d6a80; letter-spacing: .4px; }
.sidebar .foot a { padding: 0; display: inline; border: none; color: #8fa2c0; }

.main { flex: 1; padding: 26px 32px; max-width: 1200px; }
h1 { font-size: 21px; margin: 0 0 18px; }
h2 { font-size: 16px; margin: 22px 0 10px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-bottom: 20px; }
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; position: relative; overflow: hidden;
}
.card::before {
  content: ""; position: absolute; inset: 0 auto auto 0; width: 100%; height: 3px;
  background: linear-gradient(90deg, var(--accent), #6f9bff);
  opacity: .85;
}
.card .num { font-size: 24px; font-weight: 700; color: #16223a; }
a.card { text-decoration: none; color: inherit; transition: transform .12s, box-shadow .12s; }
a.card:hover {
  text-decoration: none; transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(16, 25, 43, .10); border-color: #c9d3e4;
}
a.card:hover .lbl { color: var(--accent); }
.card .lbl { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }

.panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; margin-bottom: 18px;
}

table { width: 100%; border-collapse: collapse; }
th { text-align: left; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; padding: 8px 10px; border-bottom: 1px solid var(--border); }
td { padding: 9px 10px; border-bottom: 1px solid #eef0f3; vertical-align: top; }
tr:last-child td { border-bottom: none; }
th.sortable a {
  color: inherit; text-decoration: none; display: inline-block; white-space: nowrap;
}
th.sortable a:hover { color: var(--accent); text-decoration: none; }
th.sortable.active a { color: var(--accent); }
tr.click { cursor: pointer; }
tr.click:hover td { background: #f7f9fd; }

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px;
  font-weight: 600; background: #eef0f3; color: var(--muted);
}
.badge.new { background: var(--accent-soft); color: var(--accent); }
.badge.engaged { background: #e2f6ec; color: var(--green); }
.badge.customer { background: #fdf1dd; color: var(--amber); }
.badge.unsub { background: #fdeaea; color: var(--red); }
.badge.sent { background: #e2f6ec; color: var(--green); }
.badge.draft { background: #eef0f3; color: var(--muted); }
.badge.on { background: #e2f6ec; color: var(--green); }
.badge.off { background: #fdeaea; color: var(--red); }

.score {
  display: inline-block; min-width: 34px; text-align: center; font-weight: 700;
  padding: 2px 8px; border-radius: 6px; background: var(--accent-soft); color: var(--accent);
}
.score.hot { background: #fdeaea; color: var(--red); }
.score.warm { background: #fdf1dd; color: var(--amber); }

button, .btn {
  font: inherit; border: 1px solid var(--border); background: var(--panel); color: var(--text);
  padding: 7px 14px; border-radius: 8px; cursor: pointer;
}
button:hover, .btn:hover { border-color: #c6ccd4; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: #1d49c8; }
button.danger { color: var(--red); }
button:disabled { opacity: .5; cursor: default; }

input, select, textarea {
  font: inherit; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
  width: 100%; background: #fff; color: var(--text);
}
textarea { min-height: 130px; font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 4px; font-weight: 600; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; align-items: center; flex-wrap: wrap; }
.toolbar input, .toolbar select { width: auto; }
.toolbar button, .toolbar .btn { white-space: nowrap; }
.toolbar .spacer { flex: 1; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  padding: 10px 0 10px 26px; border-left: 2px solid var(--border); margin-left: 8px;
  position: relative;
}
.timeline li::before {
  content: ""; position: absolute; left: -6px; top: 16px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--accent); border: 2px solid #fff;
}
.timeline li.t-email_received::before { background: var(--green); }
.timeline li.t-email_open::before { background: var(--amber); }
.timeline li.t-link_click::before { background: var(--red); }
.timeline li.t-site_visit::before { background: #8a5be0; }
.timeline .when { color: var(--muted); font-size: 12px; }
.timeline .what { font-weight: 600; }
.timeline .detail { color: var(--muted); font-size: 13px; word-break: break-all; }

/* ── Realtime panel (dashboard) ────────────────────────────────────────── */
.rt-panel { padding: 16px 20px; }
.rt-top { display: flex; gap: 32px; align-items: flex-start; flex-wrap: wrap; }
.rt-metric { min-width: 150px; }
.rt-metric .lbl { display: flex; align-items: center; gap: 7px; }
.rt-num { font-size: 34px; font-weight: 700; line-height: 1.15; color: #16223a; }
.rt-chart { flex: 1; min-width: 260px; }
.rt-bars {
  display: flex; align-items: flex-end; gap: 2px; height: 54px; margin-top: 6px;
}
.rt-bar {
  flex: 1; background: var(--accent); border-radius: 2px 2px 0 0; opacity: .85;
  transition: height .3s ease;
}
.rt-bar:hover { opacity: 1; background: #1d49c8; }
.rt-axis {
  display: flex; justify-content: space-between; color: var(--muted);
  font-size: 11px; margin-top: 4px;
}
.rt-lists {
  display: flex; gap: 26px; flex-wrap: wrap; margin-top: 18px;
  padding-top: 14px; border-top: 1px solid var(--border);
}
.rt-list { flex: 1; min-width: 190px; }
.rt-list-row {
  display: flex; justify-content: space-between; gap: 10px; font-size: 13px;
  padding: 3px 0;
}
.rt-list-row span {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 75%;
}

/* ── Live activity (dashboard) ─────────────────────────────────────────── */
.act-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 8px;
  border-bottom: 1px solid #eef0f3; cursor: pointer; border-radius: 8px;
}
.act-row:last-child { border-bottom: none; }
.act-row:hover { background: #f7f9fd; }
.act-main { flex: 1; min-width: 0; }
.act-badges { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.act-pulse {
  width: 10px; height: 10px; border-radius: 50%; background: #cbd3de; flex-shrink: 0;
}
.act-pulse.on {
  background: var(--green);
  animation: act-pulse 1.8s ease-out infinite;
}
@keyframes act-pulse {
  0% { box-shadow: 0 0 0 0 rgba(26, 155, 98, .45); }
  70% { box-shadow: 0 0 0 8px rgba(26, 155, 98, 0); }
  100% { box-shadow: 0 0 0 0 rgba(26, 155, 98, 0); }
}

/* ── Login page ─────────────────────────────────────────────────────────── */
.login-center {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 32px 16px;
  background:
    radial-gradient(1000px 600px at 15% -10%, rgba(64, 110, 235, .35), transparent 60%),
    radial-gradient(800px 500px at 110% 110%, rgba(38, 70, 160, .35), transparent 55%),
    linear-gradient(155deg, #0b1526 0%, #101d38 55%, #0c1830 100%);
}
.login-logo-box { text-align: center; margin-bottom: 24px; }
.login-logo { display: inline-block; height: 52px; max-width: 100%; }
.login-card {
  width: 100%; max-width: 400px; background: var(--panel);
  border: 1px solid var(--border); border-radius: 16px;
  padding: 38px 36px 28px; box-shadow: 0 18px 60px rgba(0, 0, 0, .35);
}
.login-card h1 { font-size: 22px; margin: 0 0 6px; text-align: center; }
.login-card .sub { text-align: center; }
.login-card .sub { color: var(--muted); font-size: 14px; margin: 0 0 22px; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 44px; }
.pw-toggle {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  border: none; background: none; padding: 6px 8px; cursor: pointer;
  color: var(--muted); font-size: 15px;
}
.pw-toggle:hover { color: var(--text); border: none; }
.login-submit {
  width: 100%; margin-top: 18px; padding: 11px 14px; font-size: 15px; font-weight: 600;
  border-radius: 10px;
}
.login-or {
  display: flex; align-items: center; gap: 12px; margin: 18px 0 14px;
  color: var(--muted); font-size: 12px;
}
.login-or::before, .login-or::after {
  content: ""; flex: 1; height: 1px; background: var(--border);
}
.login-foot {
  margin: 26px 0 0; padding-top: 16px; border-top: 1px solid var(--border);
  color: var(--muted); font-size: 12px; text-align: center;
}
.error { color: var(--red); margin-top: 10px; font-size: 13px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 6px; }
.empty { color: var(--muted); padding: 24px; text-align: center; }
pre.snippet {
  background: #10192b; color: #c9e3ff; padding: 12px 14px; border-radius: 8px;
  overflow-x: auto; font-size: 12.5px;
}
.msg-body {
  background: #f7f9fd; border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; margin-top: 6px; white-space: pre-wrap; font-size: 13px;
  max-height: 160px; overflow-y: auto;
}
.toast {
  position: fixed; bottom: 20px; right: 20px; background: #10192b; color: #fff;
  padding: 12px 18px; border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.25);
  z-index: 50;
}

/* ── Contact record ──────────────────────────────────────────────────────── */
.scroll-x { overflow-x: auto; }
.fieldgroup { border-top: 1px solid var(--border); padding-top: 10px; margin-top: 14px; }
.fieldgroup:first-of-type { border-top: 0; padding-top: 0; margin-top: 0; }
.fieldgroup-title {
  font-size: 11px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase;
  color: var(--accent);
}
.fieldgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.fieldgrid > div { min-width: 0; }
.fieldgrid label { margin-top: 10px; }
.readonly {
  padding: 8px 0 0; font-size: 13px; word-break: break-all;
}
@media (max-width: 900px) { .fieldgrid { grid-template-columns: 1fr; } }

/* Personal tracking links */
.tlink {
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px;
}
.tlink-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tlink-url {
  background: #f7f9fd; border: 1px solid var(--border); border-radius: 6px;
  padding: 6px 8px; margin-top: 8px; overflow-x: auto;
}
.tlink-url code { font-size: 12px; white-space: nowrap; }
.tlink-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.tlink-actions button { font-size: 12px; padding: 5px 9px; }

/* Contradiction callout on the visitor assessment */
.conflict {
  background: #fff6e8; border: 1px solid var(--amber); border-radius: 8px;
  padding: 8px 10px; margin: 10px 0; font-size: 12.5px;
}
.conflict strong { display: block; margin-bottom: 4px; }

/* ── Live activity drill-down ─────────────────────────────────────────── */
/* The realtime counters are links into #/live — make them feel like it. */
a.rt-metric {
  display: block; color: inherit; text-decoration: none; border-radius: 8px;
  padding: 6px 10px; margin: -6px -10px; transition: background .12s;
}
a.rt-metric:hover { background: var(--accent-soft); text-decoration: none; }
a.rt-metric:hover .rt-num, a.rt-metric:hover .hint { color: var(--accent); }
a.rt-metric .hint { margin-top: 2px; }

a.rt-list-row { color: inherit; text-decoration: none; border-radius: 6px; }
a.rt-list-row:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }

.live-page {
  display: flex; gap: 8px; align-items: baseline; font-size: 13px; padding: 2px 0;
}
.live-when {
  flex: 0 0 68px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums;
}
.live-page .hint { margin: 0; }

/* ── Contact cleanup ─────────────────────────────────────────────────────── */
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px;
  border: 1px solid var(--border); border-radius: 999px; font-size: 12px;
  color: var(--text); background: var(--panel); white-space: nowrap;
}
.chip:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.chip.zero { opacity: .5; }
.chip strong { font-size: 12px; }

.bulkbar {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  background: var(--accent-soft); border: 1px solid #c9d7f8; border-radius: 10px;
  padding: 8px 12px; margin-bottom: 12px;
}
.bulkbar select, .bulkbar input { width: auto; padding: 6px 8px; font-size: 13px; }
.bulkbar button { font-size: 13px; padding: 6px 10px; }

.dup-pair { display: flex; gap: 14px; align-items: stretch; }
.dup-card {
  flex: 1; border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px;
  min-width: 0;
}
.dup-mid {
  display: flex; flex-direction: column; gap: 8px; justify-content: center;
  flex: 0 0 auto;
}
@media (max-width: 900px) { .dup-pair { flex-direction: column; } }

/* Cross-filterable demographics bars */
a.demo-bar {
  display: block; color: inherit; text-decoration: none; margin-bottom: 6px;
  border-radius: 6px; padding: 2px 4px; margin-left: -4px; margin-right: -4px;
}
a.demo-bar:hover { background: var(--accent-soft); text-decoration: none; }
a.demo-bar.on { background: var(--accent-soft); outline: 1px solid #c9d7f8; }
a.demo-bar.on span:first-child { color: var(--accent); font-weight: 600; }

.toast-action {
  margin-left: 12px; background: transparent; border: 1px solid #5b6b8c;
  color: #9db8ff; padding: 3px 10px; border-radius: 6px; font-size: 12.5px;
}
.toast-action:hover { border-color: #9db8ff; }

/* ── Audience builder (Lists) ────────────────────────────────────────────── */
.seg-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px;
}
.seg-grid input, .seg-grid select { width: 100%; padding: 7px 10px; font-size: 13px; }
.seg-chips { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.seg-chips > div { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.seg-chips .lbl { min-width: 100px; }

/* ── SEO portal ──────────────────────────────────────────────────────────── */

/* Pipeline board: one column per stage of the content process. */
.pipeline { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.stage {
  flex: 1; min-width: 108px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--panel); padding: 10px 12px; color: inherit; text-decoration: none;
  display: block; transition: transform .12s, box-shadow .12s;
}
.stage:hover {
  text-decoration: none; transform: translateY(-2px); border-color: #c9d3e4;
  box-shadow: 0 8px 20px rgba(16, 25, 43, .10);
}
.stage.on { border-color: var(--accent); background: var(--accent-soft); }
.stage .n { font-size: 22px; font-weight: 700; color: #16223a; }
.stage .s { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.stage.on .n, .stage.on .s { color: var(--accent); }

/* Stage badges follow the pipeline: grey while planned, blue while worked,
   green once live, amber when it needs another pass. */
.badge.st-idea, .badge.st-research { background: #eef0f3; color: var(--muted); }
.badge.st-brief, .badge.st-writing, .badge.st-review { background: var(--accent-soft); color: var(--accent); }
.badge.st-published, .badge.st-monitoring { background: #e2f6ec; color: var(--green); }
.badge.st-needs_update { background: #fdf1dd; color: var(--amber); }

.badge.intent-informational { background: var(--accent-soft); color: var(--accent); }
.badge.intent-transactional { background: #e2f6ec; color: var(--green); }
.badge.intent-mixed { background: #fdf1dd; color: var(--amber); }

.badge.conflict-same { background: #fdeaea; color: var(--red); }
.badge.conflict-overlap { background: #fdf1dd; color: var(--amber); }

/* Keyword conflict callout — the check the troubleshooting workflow runs. */
.clash {
  background: #fdeaea; border: 1px solid #f0c2c2; border-radius: 10px;
  padding: 10px 12px; margin-bottom: 14px;
}
.clash.soft { background: #fff6e8; border-color: #ecd3a6; }
.clash strong { display: block; margin-bottom: 4px; }
.clash ul { margin: 6px 0 0; padding-left: 18px; }
.clash li { margin: 2px 0; }

/* Main-keyword selection checklist */
.check-list { list-style: none; margin: 0; padding: 0; }
.check-list li {
  display: flex; gap: 10px; align-items: flex-start; padding: 8px 0;
  border-bottom: 1px solid #eef0f3;
}
.check-list li:last-child { border-bottom: none; }
.check-list input[type="checkbox"] { width: auto; margin-top: 2px; flex-shrink: 0; }
.check-list .auto { color: var(--muted); font-size: 12px; }
.check-list .lbl-txt { font-weight: 600; }

.split { display: flex; gap: 18px; align-items: flex-start; }
.split > .col-main { flex: 2; min-width: 0; }
.split > .col-side { flex: 1; min-width: 260px; }
@media (max-width: 900px) { .split { flex-direction: column; } .split > * { width: 100%; } }

td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.tight { white-space: nowrap; }
.kw-edit input, .kw-edit select { padding: 5px 7px; font-size: 13px; }
.import-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.import-grid .card { padding: 10px 12px; }
.import-grid .card .num { font-size: 20px; }
