:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f3f2ee;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);
  --accent: #2a78d6;
  --accent-ink: #fff;
  /* Sentiment is polarity: diverging blue <-> red with a gray midpoint. */
  --pos: #2a78d6;
  --neu: #b3b1a8;
  --neg: #e34948;
  --good: #006300;
  --warn-bg: #fff4d6;
  --warn-ink: #7a5600;
  --ok-bg: #dcf3e4;
  --ok-ink: #145c32;
  --bad-bg: #fde3e2;
  --bad-ink: #9b1c1b;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --surface-2: #232321; --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781;
    --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, 0.1); --accent: #3987e5;
    --pos: #3987e5; --neu: #6b6a64; --neg: #e66767; --good: #0ca30c;
    --warn-bg: #3a2f10; --warn-ink: #f3cf73; --ok-bg: #12321f; --ok-ink: #8fdcab; --bad-bg: #3b1716; --bad-ink: #f3a3a2;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--ink); font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif; }
a { color: var(--accent); }
button, select, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--border); background: var(--surface); border-radius: 6px; padding: 6px 12px; }
button:hover { background: var(--surface-2); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
button.primary:hover { filter: brightness(1.08); }
a.primary { background: var(--accent); color: var(--accent-ink); border-radius: 6px; padding: 6px 12px; text-decoration: none; }
button:disabled { opacity: 0.5; cursor: progress; }
select, input, textarea { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; }
textarea { width: 100%; }

header { display: flex; flex-wrap: wrap; row-gap: 8px; align-items: center; gap: 24px; padding: 10px 24px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
header h1 { font-size: 16px; margin: 0; white-space: nowrap; }
header h1 span { color: var(--muted); font-weight: 400; }
nav { display: flex; gap: 4px; flex-wrap: wrap; }
nav button { border: none; background: none; padding: 6px 10px; color: var(--ink-2); }
nav button.active { color: var(--ink); background: var(--surface-2); font-weight: 600; }
.badge-count { background: var(--neg); color: #fff; border-radius: 10px; padding: 0 6px; font-size: 11px; margin-inline-start: 4px; }
#who { margin-inline-start: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }

main { padding: 16px 24px 48px; max-width: 1400px; margin: 0 auto; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filters label { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 2px; }
.banner { padding: 10px 14px; border-radius: 8px; background: var(--warn-bg); color: var(--warn-ink); margin-bottom: 16px; }

.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-bottom: 16px; }
.cols-2 { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }
.cols-3 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; min-width: 0; }
.card h3 { margin: 0 0 10px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.kpi .v { font-size: 26px; font-weight: 600; }
.kpi .d { font-size: 12px; color: var(--muted); }
.kpi .d.up { color: var(--good); } .kpi .d.down { color: var(--neg); }
.chart { position: relative; height: 260px; }
.chart.tall { height: 340px; }

table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: start; padding: 6px 8px; border-bottom: 1px solid var(--grid); vertical-align: top; overflow-wrap: anywhere; }
.card { overflow-x: auto; }
th { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
td.num { font-variant-numeric: tabular-nums; text-align: end; }

.pill { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.s-positive { background: color-mix(in srgb, var(--pos) 18%, transparent); color: var(--pos); }
.s-neutral { background: var(--surface-2); color: var(--ink-2); }
.s-negative { background: color-mix(in srgb, var(--neg) 18%, transparent); color: var(--neg); }
.st-ai_generated { background: var(--warn-bg); color: var(--warn-ink); }
.st-validated { background: var(--ok-bg); color: var(--ok-ink); }
.st-rejected { background: var(--bad-bg); color: var(--bad-ink); }
.lg { display: inline-flex; align-items: center; justify-content: center; border-radius: 6px; padding: 3px; vertical-align: middle; }
.lg img { display: block; height: 22px; width: auto; max-width: 70px; object-fit: contain; }
.plate-light { background: #fff; box-shadow: inset 0 0 0 1px var(--border); }
.plate-dark { background: #0d1117; }
.rag-green { background: var(--ok-bg); color: var(--ok-ink); }
.rag-amber { background: var(--warn-bg); color: var(--warn-ink); }
.rag-red { background: var(--bad-bg); color: var(--bad-ink); }
.tag { display: inline-block; padding: 0 6px; border-radius: 4px; background: var(--surface-2); color: var(--ink-2); font-size: 11px; margin: 0 4px 2px 0; }

.post { border-bottom: 1px solid var(--grid); padding: 10px 0; }
.post .meta { font-size: 12px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.post .text { margin: 6px 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.post .why { font-size: 12px; color: var(--ink-2); }
.post .val { display: flex; gap: 4px; margin-top: 6px; }
.post .val button { padding: 2px 8px; font-size: 12px; }

.insight-list .row { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--grid); cursor: pointer; }
.insight-list .row:hover { background: var(--surface-2); }
.insight-list .row .t { flex: 1; }
.theme { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; }
.theme h4 { margin: 0 0 4px; }
.small { font-size: 12px; color: var(--muted); }
.evidence { max-height: 520px; overflow: auto; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 10px 0; }

.chat { display: flex; flex-direction: column; gap: 12px; }
.msg { padding: 12px 14px; border-radius: 10px; max-width: 900px; }
.msg.q { align-self: flex-end; background: var(--accent); color: var(--accent-ink); }
.msg.a { background: var(--surface); border: 1px solid var(--border); }
.ask-box { display: flex; gap: 8px; margin-top: 12px; }
.ask-box input { flex: 1; }
.suggest button { font-size: 12px; margin: 0 6px 6px 0; }

dialog { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--ink); max-width: 720px; width: 92vw; }
/* Entities filter: pick one, several or all */
.ms-wrap { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--muted); }
.ms { position: relative; }
.ms-btn { min-width: 200px; max-width: 280px; text-align: start; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.ms-btn::after { content: " ▾"; color: var(--muted); }
.ms-pop { position: absolute; z-index: 20; top: calc(100% + 4px); inset-inline-start: 0; width: 340px; max-width: calc(100vw - 32px);
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18); }
.ms-pop input#ms-q { width: 100%; }
.ms-acts { display: flex; gap: 6px; margin: 6px 0; } .ms-acts button { padding: 3px 10px; font-size: 12px; } .ms-acts .primary { margin-inline-start: auto; }
.ms-list { max-height: 320px; overflow-y: auto; }
.ms-list label { display: flex; flex-direction: row; align-items: flex-start; gap: 6px; padding: 3px 2px; color: var(--ink); font-size: 13px; cursor: pointer; }
.ms-list .grp { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin: 8px 0 2px; }
.tag.official { background: var(--accent); color: var(--accent-ink); }

/* Overview: what people say */
.voice { border-inline-start: 3px solid var(--grid); padding: 4px 10px; margin: 0 0 10px; }
.voice.positive { border-color: var(--pos, #2e8b57); } .voice.negative { border-color: var(--neg, #e34948); }
.voice p, .op q { display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; } /* full text on hover */
.voice p { margin: 0 0 2px; font-size: 13px; } .voice small { color: var(--muted); font-size: 11px; }
.opinions { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; } @media (max-width: 700px) { .opinions { grid-template-columns: 1fr; } }
.opinions h4 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.op { margin: 0 0 10px; } .op b { font-size: 13px; } .op q { font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.chg.up { color: var(--neg, #e34948); } .chg.down { color: var(--pos, #2e8b57); } .chg { font-size: 12px; white-space: nowrap; }

/* Outlook: predictive and prescriptive, as a conversation */
.ol-summary { font-size: 15px; line-height: 1.55; background: var(--surface-2); border-radius: 10px; padding: 12px 14px; margin: 6px 0 14px; }
.ol-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.ol-card { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.ol-card p { margin: 6px 0; font-size: 13px; }
.lik { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 10px; background: var(--surface-2); }
.lik.high, .pri.urgent { background: var(--neg, #e34948); color: #fff; } .lik.medium, .pri.high { background: var(--warn-bg); color: var(--warn-ink); }
.pri { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 10px; background: var(--surface-2); text-transform: capitalize; }
.ol-chat { margin-top: 12px; }
.pri, .lik { white-space: nowrap; overflow-wrap: normal; display: inline-block; }
td:has(> .pri) { width: 1%; overflow-wrap: normal; }

/* Voice mode */
.voice-btn { width: 34px; height: 34px; border-radius: 50%; display: inline-grid; place-items: center; padding: 0; background: var(--accent); color: var(--accent-ink); border: 0; }
.voice-btn:hover { filter: brightness(1.1); background: var(--accent); }
.voice-mode { position: fixed; inset: 0; z-index: 100; background: radial-gradient(ellipse at 50% 40%, #13213a 0%, #070a10 70%); color: #eef2f7;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px; padding: 24px; }
.voice-mode[hidden] { display: none; }
.vm-status { font-size: 15px; letter-spacing: .04em; color: #a9b8cc; min-height: 1.2em; }
.vm-orb { --s: 1; --c1: #4c9bff; --c2: #1d4ed8; width: 200px; height: 200px; border-radius: 50%; position: relative;
  transform: scale(var(--s)); transition: transform .08s linear;
  background: radial-gradient(circle at 35% 30%, #ffffffcc 0 8%, var(--c1) 30%, var(--c2) 70%, #0b1b3f 100%);
  box-shadow: 0 0 60px 10px color-mix(in srgb, var(--c1) 45%, transparent), inset 0 0 40px #ffffff22; }
.vm-orb span { position: absolute; inset: -14px; border-radius: 50%; border: 2px solid color-mix(in srgb, var(--c1) 50%, transparent); opacity: 0; }
.vm-orb.user { --c1: #f6c453; --c2: #b7791f; }
.vm-orb.thinking span { opacity: 1; animation: vm-spin 1.2s linear infinite; border-color: transparent; border-top-color: var(--c1); }
.vm-orb.idle { animation: vm-breathe 3.2s ease-in-out infinite; }
@keyframes vm-breathe { 50% { transform: scale(1.04); } }
@keyframes vm-spin { to { transform: rotate(360deg); } }
.vm-captions { max-width: 720px; width: 100%; min-height: 110px; display: flex; flex-direction: column; gap: 8px; text-align: center; }
.vm-captions p { margin: 0; font-size: 17px; line-height: 1.5; } .vm-captions p.you { color: #f6d58a; font-size: 15px; } .vm-captions p.old { opacity: .45; font-size: 14px; }
.vm-hint { font-size: 12px; color: #7d8ba0; text-align: center; }
.vm-tap { background: #f6c453; color: #111; border: 0; border-radius: 20px; padding: 10px 18px; font-size: 15px; font-weight: 600; }
.vm-status { text-align: center; max-width: 520px; }
.vm-controls { display: flex; gap: 18px; }
.vm-round { width: 56px; height: 56px; border-radius: 50%; border: 1px solid #ffffff33; background: #ffffff14; color: #fff; font-size: 20px; display: grid; place-items: center; }
.vm-round:hover { background: #ffffff26; } .vm-round[aria-pressed="true"] { background: #e34948; border-color: #e34948; }
.vm-end { background: #e34948; border-color: #e34948; } .vm-end:hover { background: #c73b3a; }
@media (prefers-reduced-motion: reduce) { .vm-orb, .vm-orb.idle, .vm-orb.thinking span { animation: none; transition: none; } }

/* Hard rules */
.hr-table tr.off td { opacity: .5; }
.hr-add { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; font-size: 13px; }
.hr-add input[data-h="value"] { flex: 1 1 260px; } .hr-add input[data-h="note"] { flex: 0 1 180px; }
#hr-msg ul { margin: 4px 0 0; padding-inline-start: 18px; }
/* Rules: the classifier's guidelines */
.rule { border-top: 1px solid var(--grid); padding: 14px 0; } .rule:first-of-type { border-top: 0; }
.rule h4 { margin: 0 0 2px; font-size: 14px; } .rule textarea { width: 100%; min-height: 84px; margin: 8px 0 6px; font-size: 13px; line-height: 1.45; }
.rule .ro { white-space: pre-wrap; background: var(--surface-2); border-radius: 6px; padding: 8px 10px; margin: 8px 0 6px; font-size: 13px; }

/* Channels: one row per entity, one column per platform */
.ch-grid td { vertical-align: top; }
.ch-grid td:last-child { width: 1%; white-space: nowrap; overflow-wrap: normal; } /* room for the Edit button */
.ch-grid button { white-space: nowrap; min-width: 64px; }
.ch-grid .h { display: block; white-space: nowrap; font-size: 12px; }
.ch-grid .h.off { opacity: 0.45; text-decoration: line-through; }
.ch-grid .ent { display: flex; gap: 8px; align-items: center; min-width: 220px; }
.conf { font-size: 10px; padding: 0 4px; border-radius: 3px; margin-inline-start: 3px; background: var(--surface-2); color: var(--muted); }
.conf.official-site { color: var(--pos, #2e8b57); }
#dlg:has(.ch-edit) { max-width: 960px; }
.ch-edit td { padding: 4px 6px 4px 0; overflow-wrap: normal; } .ch-edit button { white-space: nowrap; } .ch-edit input, .ch-edit select { width: 100%; }
/* Sync: last-synced label and progress in the header */
.sync { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); white-space: nowrap; margin-inline-start: 12px; }
.sync button { padding: 3px 10px; font-size: 12px; }
.sync .live { color: var(--accent); font-weight: 600; }
.progress { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin: 8px 0; }
.progress > div { height: 100%; background: var(--accent); transition: width 0.4s; }
.sync-steps { list-style: none; padding: 0; margin: 8px 0; font-size: 13px; }
.sync-steps li { padding: 3px 0; color: var(--muted); } .sync-steps li.on { color: var(--ink); font-weight: 600; } .sync-steps li.ok { color: var(--ink-2); }
dialog::backdrop { background: rgba(0, 0, 0, 0.35); }
/* Setup: the HQ picker shows the State page map's whole canvas (both layers fill the same 840:500 box, so clicks map straight to it) */
.hq-map { position: relative; width: 100%; aspect-ratio: 840 / 560; border-radius: 10px; overflow: hidden; cursor: crosshair; background: #030710; }
.hq-map img, .hq-map svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.hq-map img { object-fit: fill; }
.hq-map text { font: 700 7px ui-monospace, Consolas, monospace; paint-order: stroke; stroke: #030710; stroke-width: 2px; stroke-linejoin: round; }
.hq-map .other circle { fill: #9aa3ae; } .hq-map .other text { fill: #c9d1dc; }
.hq-map .me circle { fill: #e6c77a; stroke: #fff; stroke-width: .8; } .hq-map .me line { stroke: #e6c77a; stroke-width: .7; } .hq-map .me text { fill: #fff; }
.hq-warn { color: #9a5b00; }
.form { display: grid; gap: 10px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-2); }
.err { color: var(--neg); font-size: 12px; }
.hidden { display: none !important; }
.spinner::after { content: " …"; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0.2; } }

@media (max-width: 700px) {
  header { flex-wrap: wrap; padding: 10px 16px; gap: 8px; }
  main { padding: 12px 16px 40px; }
  .cols-2, .cols-3 { grid-template-columns: 1fr; }
}
