/* Civic Bridge — brand system per "Civic Bridge Brand Theme" (Civic Bridge shared drive) */
:root {
  --navy: #17164F;
  --purple: #5A32C9;
  --magenta: #C23B92;
  --orange: #FF792E;
  --gold: #FFA329;
  --white: #FFFFFF;
  --soft-gray: #F5F5F7;
  --slate: #626575;
  --line: #E6E6EE;
  --gradient: linear-gradient(90deg, #5132C9 0%, #B63C9A 50%, #FF792E 100%);
  --radius: 14px;
  --shadow: 0 18px 50px -28px rgba(23, 22, 79, 0.35);
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--soft-gray); color: var(--navy);
  font-family: "Inter", "Avenir Next", "Montserrat", "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5; -webkit-font-smoothing: antialiased;
}
a { color: var(--purple); }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
h1 { font-size: clamp(24px, 3.4vw, 32px); font-weight: 800; }
h2 { font-size: 20px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 700; }
.muted { color: var(--slate); }
.small { font-size: 13px; }
.label {
  font-size: 11px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--purple);
}
.label.orange { color: var(--orange); }
.label.slate { color: var(--slate); }

/* Top bar */
.topbar { background: var(--white); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar::after { content: ""; display: block; height: 3px; background: var(--gradient); }
.topbar-inner { max-width: 1240px; margin: 0 auto; padding: 12px 20px; display: flex; align-items: center; gap: 20px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--navy); font-weight: 800; }
.brand img { height: 30px; width: auto; }
.brand span { font-size: 13px; font-weight: 600; color: var(--slate); border-left: 1px solid var(--line); padding-left: 10px; }
.nav { display: flex; gap: 4px; margin-left: auto; align-items: center; flex-wrap: wrap; }
.nav a { text-decoration: none; color: var(--navy); font-weight: 600; font-size: 14px; padding: 8px 12px; border-radius: 8px; }
.nav a.active, .nav a:hover { background: var(--soft-gray); }
.nav .who { font-size: 13px; color: var(--slate); margin-left: 8px; }

.page { max-width: 1240px; margin: 0 auto; padding: 28px 20px 80px; }
.page.narrow { max-width: 860px; }
.stack > * + * { margin-top: 18px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }

.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.card.flat { box-shadow: none; }
.card-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent;
  border-radius: 10px; padding: 10px 16px; font: inherit; font-weight: 700; font-size: 14px; cursor: pointer;
  text-decoration: none; transition: transform .05s, background .15s, box-shadow .15s; white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--orange); color: var(--white); box-shadow: 0 8px 20px -10px rgba(255, 121, 46, .8); }
.btn-primary:hover { background: #F06A1F; }
.btn-navy { background: var(--navy); color: var(--white); }
.btn-ghost { background: var(--white); color: var(--navy); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--purple); color: var(--purple); }
.btn-danger { background: var(--white); color: #B42318; border-color: #F3D0CC; }
.btn-sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--navy); }
input[type=text], input[type=email], input[type=password], select, textarea {
  font: inherit; font-size: 15px; color: var(--navy); background: var(--white); border: 1px solid #D9D9E3;
  border-radius: 10px; padding: 10px 12px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(90, 50, 201, .25); border-color: var(--purple); }
textarea { min-height: 70px; resize: vertical; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 720px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.checks { display: flex; flex-wrap: wrap; gap: 10px; }
.check {
  display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px;
  cursor: pointer; background: var(--white); user-select: none;
}
.check:has(input:checked) { border-color: var(--purple); background: #F4F0FD; }
.check input { accent-color: var(--purple); width: 16px; height: 16px; }
.error { color: #B42318; font-size: 14px; font-weight: 600; }
.notice.ok { background: #ECFDF3; color: #05603A; border: 1px solid #ABEFC6; border-radius: 10px; padding: 10px 14px; font-size: 14px; font-weight: 600; }

/* Pills / chips */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--soft-gray); color: var(--slate); }
.pill.ok { background: #E7F6EE; color: #11753F; }
.pill.demo { background: #FFF3E3; color: #9A5A00; }
.pill.bad { background: #FDECEA; color: #B42318; }
.pill.purple { background: #EFE9FC; color: var(--purple); }
.pill.orange { background: #FFEDE2; color: #C2520F; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; display: inline-block; }

.login { max-width: 420px; margin: 8vh auto; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 20px); background: var(--navy); color: var(--white); padding: 10px 18px; border-radius: 10px; font-weight: 600; font-size: 14px; opacity: 0; transition: .2s; pointer-events: none; z-index: 100; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.empty { text-align: center; padding: 40px 20px; color: var(--slate); }
.hidden { display: none !important; }

/* ======================================================================
   Dashboard (civic-bridge-dashboard)
   Chart colors: six categorical slots validated with the dataviz palette
   validator on white (light mode): adjacent CVD ΔE ≥ 9.2, normal-vision ΔE ≥ 25.
   Slots 1 and 4 are the brand purple and magenta. Aqua and gold sit below 3:1
   contrast on white, so every chart ships a legend, end labels and a table view.
   Color follows the org/campaign (config order), never its rank.
   ====================================================================== */
:root {
  --series-1: #5A32C9; /* brand purple */
  --series-2: #eb6834; /* orange */
  --series-3: #1baf7a; /* aqua */
  --series-4: #C23B92; /* brand magenta */
  --series-5: #2a78d6; /* blue */
  --series-6: #eda100; /* gold */
  --series-other: #9a99a8;
  --ink: #17164F;
  --ink-2: #4a4c5c;
  --ink-muted: #7d7f8e;
  --grid: #ECECF2;
  --axis: #C9C9D6;
}
input[type=date] {
  font: inherit; font-size: 14px; color: var(--navy); background: var(--white); border: 1px solid #D9D9E3;
  border-radius: 10px; padding: 7px 10px;
}
select.compact { width: auto; font-size: 14px; padding: 7px 10px; }

.filters { display: flex; flex-wrap: wrap; gap: 14px 22px; align-items: flex-end; }
.filters .group { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.filters .group > .label { color: var(--slate); }
.seg { display: inline-flex; border: 1px solid #D9D9E3; border-radius: 10px; overflow: hidden; background: var(--white); }
.seg button { font: inherit; font-size: 14px; font-weight: 600; border: 0; background: none; color: var(--navy); padding: 7px 12px; cursor: pointer; }
.seg button + button { border-left: 1px solid #D9D9E3; }
.seg button[aria-pressed=true] { background: var(--navy); color: var(--white); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; font: inherit; font-size: 13px; font-weight: 600; color: var(--navy);
  border: 1px solid #D9D9E3; background: var(--white); border-radius: 999px; padding: 5px 11px 5px 9px; cursor: pointer;
}
.chip .key { width: 10px; height: 10px; border-radius: 3px; background: var(--series-other); }
.chip[aria-pressed=false] { color: var(--slate); background: var(--soft-gray); }
.chip[aria-pressed=false] .key { opacity: .25; }
.chip[aria-pressed=true] { border-color: var(--navy); }
.chip:focus-visible, .seg button:focus-visible, .btn:focus-visible { outline: 2px solid var(--purple); outline-offset: 2px; }
.custom-range { display: none; gap: 6px; align-items: center; }
.custom-range.on { display: flex; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.kpis[data-n="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 900px) { .kpis, .kpis[data-n="3"] { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.kpi .label { color: var(--slate); }
.kpi .value { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; margin-top: 4px; color: var(--ink); }
.kpi .sub { font-size: 13px; color: var(--slate); margin-top: 2px; }

.chart-card .card-title { margin-bottom: 4px; }
.chart-card .subtitle { font-size: 13px; color: var(--slate); margin: 0 0 12px; }
.chart-wrap { position: relative; }
.chart-wrap svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-wrap svg text { font-family: inherit; }
.axis-label { font-size: 11px; fill: var(--ink-muted); font-variant-numeric: tabular-nums; }
.end-label { font-size: 12px; font-weight: 600; fill: var(--ink-2); }
.election-label { font-size: 11px; font-weight: 700; fill: var(--ink-2); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0 0 10px; padding: 0; list-style: none; font-size: 13px; color: var(--ink-2); }
.legend li { display: inline-flex; align-items: center; gap: 7px; }
.legend .swatch { width: 16px; height: 0; border-top: 2px solid; border-radius: 2px; }
.tooltip {
  position: absolute; pointer-events: none; z-index: 5; min-width: 170px; max-width: 280px;
  background: var(--white); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 30px -12px rgba(23, 22, 79, .35);
  padding: 9px 11px; font-size: 13px; color: var(--ink-2); display: none;
}
.tooltip .tt-date { font-size: 12px; font-weight: 700; color: var(--slate); margin-bottom: 5px; }
.tooltip .tt-row { display: grid; grid-template-columns: 14px auto 1fr; gap: 7px; align-items: center; }
.tooltip .tt-row + .tt-row { margin-top: 3px; }
.tooltip .tt-key { width: 14px; border-top: 2px solid; }
.tooltip .tt-val { font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; }
.tooltip .tt-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { padding: 40px 0; text-align: center; color: var(--slate); font-size: 14px; }

table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data th { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--slate); }
.table-scroll { max-height: 340px; overflow: auto; margin-top: 12px; border: 1px solid var(--line); border-radius: 10px; }
.table-scroll table.data th { position: sticky; top: 0; background: var(--white); }
.link-btn { font: inherit; font-size: 13px; font-weight: 600; color: var(--purple); background: none; border: 0; padding: 0; cursor: pointer; }

.statusbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 13px; color: var(--slate); }
.sources { display: grid; gap: 10px; }
.source-row { display: grid; grid-template-columns: 1.6fr 1fr 1fr auto; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
@media (max-width: 760px) { .source-row { grid-template-columns: 1fr; } }
code { font-size: 12.5px; background: var(--soft-gray); border-radius: 6px; padding: 1px 5px; }
.hidden { display: none !important; }

/* Checkbox dropdowns (orgs, campaigns) */
.dd { position: relative; }
.dd-btn {
  display: inline-flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 190px; max-width: 280px;
  font: inherit; font-size: 14px; font-weight: 600; color: var(--navy); background: var(--white);
  border: 1px solid #D9D9E3; border-radius: 10px; padding: 7px 10px 7px 12px; cursor: pointer; text-align: left;
}
.dd-btn:hover, .dd-btn[aria-expanded=true] { border-color: var(--purple); }
.dd-btn:focus-visible { outline: 2px solid var(--purple); outline-offset: 2px; }
.dd-summary { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-caret { font-size: 11px; color: var(--slate); }
.dd-panel {
  position: absolute; z-index: 30; top: calc(100% + 6px); left: 0; width: 340px; max-width: calc(100vw - 32px);
  background: var(--white); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 18px 40px -16px rgba(23, 22, 79, .35);
  padding: 10px;
}
.dd-panel[hidden] { display: none; }
.dd-search { width: 100%; font: inherit; font-size: 14px; border: 1px solid #D9D9E3; border-radius: 8px; padding: 7px 10px; margin-bottom: 8px; }
.dd-search:focus { outline: 2px solid rgba(90, 50, 201, .25); border-color: var(--purple); }
.dd-actions { font-size: 13px; padding: 0 4px 6px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.dd-list { max-height: 320px; overflow: auto; }
.dd-item { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 6px; font-size: 14px; cursor: pointer; color: var(--navy); }
.dd-item:hover { background: var(--soft-gray); }
.dd-item input { accent-color: var(--purple); width: 15px; height: 15px; margin: 0; flex: none; }
.dd-item .key { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.dd-group { font-weight: 700; margin-top: 4px; }
.dd-group:not(:first-child) { border-top: 1px solid var(--line); border-radius: 0; padding-top: 8px; }
.dd-group + .dd-item, .dd-group ~ .dd-item:not(.dd-group) { padding-left: 22px; }
.dd-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-empty { padding: 8px 6px; font-size: 13px; }
@media (max-width: 600px) { .dd-btn { min-width: 0; width: 100%; } .filters .group { flex: 1 1 100%; } }

/* SMS / Door knocks tabs: each tab has its own filters, totals and chart. */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid #D9D9E3; }
.tabs button { font: inherit; font-size: 15px; font-weight: 700; color: var(--slate); background: none; border: 0; border-bottom: 3px solid transparent; margin-bottom: -2px; padding: 10px 16px; cursor: pointer; }
.tabs button:hover { color: var(--navy); }
.tabs button[aria-selected=true] { color: var(--navy); border-bottom-color: var(--purple); }
.tabs button:focus-visible { outline: 2px solid var(--purple); outline-offset: 2px; border-radius: 6px; }
.chart-card[hidden] { display: none; }
.filters .group[hidden], .seg button[hidden] { display: none; }
