/* Political Opportunity Finder - UI styles. Tokens first; components below. */
:root {
  color-scheme: light;
  --page: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f3f4f6;
  --surface-3: #e9ebef;
  --border: rgba(11, 11, 11, 0.10);
  --border-strong: #cfd3d9;
  --text: #191919;
  --text-2: #5f6368;
  --text-3: #80868b;
  --accent: #1b64be;
  --accent-hover: #1757ac;
  --accent-soft: #e6f0fc;
  --accent-text: #1757ac;
  --on-accent: #ffffff;
  --sidebar: #0f1b2d;
  --sidebar-text: #c7d0dc;
  --sidebar-active: #1b2b44;
  --series-1: #257de0;
  --grid: #e7e7e7;
  --baseline: #c2c2c2;
  --good: #0aac23;
  --good-text: #006c10;
  --good-soft: #e5f6e8;
  --warning: #fbb315;
  --warning-soft: #fff4d6;
  --serious: #f18a59;
  --serious-soft: #fde9de;
  --critical: #dc3c3d;
  --critical-text: #b42323;
  --critical-soft: #fde4e4;
  --map-0: #efefef;
  --map-1: #84b9f3;
  --map-2: #519ced;
  --map-3: #257de0;
  --map-4: #1b64be;
  --map-5: #0e3d7e;
  --map-ink-0: #666666;
  --map-ink-1: #0b0b0b;
  --map-ink-2: #0b0b0b;
  --map-ink-3: #0b0b0b;
  --map-ink-4: #ffffff;
  --map-ink-5: #ffffff;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.18);
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0b0b0b; --surface: #191919; --surface-2: #222222; --surface-3: #2c2c2c;
    --border: rgba(255, 255, 255, 0.10); --border-strong: #3a3a3a;
    --text: #efefef; --text-2: #a3a3a3; --text-3: #8a8a8a;
    --accent: #338ced; --accent-hover: #519ced; --accent-soft: #15253b; --accent-text: #84b9f3; --on-accent: #0b0b0b;
    --sidebar: #111111; --sidebar-text: #b9b9b9; --sidebar-active: #222c3b;
    --series-1: #338ced; --grid: #303030; --baseline: #474747;
    --good-text: #53c556; --good-soft: #13291a; --warning-soft: #33290f; --serious-soft: #35211a;
    --critical-text: #f08080; --critical-soft: #3a1a1a;
    --map-0: #383838; --map-1: #1757ac; --map-2: #2370cd; --map-3: #338ced; --map-4: #6aabf1; --map-5: #9dc8f7;
    --map-ink-0: #9c9c9c; --map-ink-1: #ffffff; --map-ink-2: #ffffff; --map-ink-3: #0b0b0b; --map-ink-4: #0b0b0b; --map-ink-5: #0b0b0b;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.5); --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.6);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0b0b0b; --surface: #191919; --surface-2: #222222; --surface-3: #2c2c2c;
  --border: rgba(255, 255, 255, 0.10); --border-strong: #3a3a3a;
  --text: #efefef; --text-2: #a3a3a3; --text-3: #8a8a8a;
  --accent: #338ced; --accent-hover: #519ced; --accent-soft: #15253b; --accent-text: #84b9f3; --on-accent: #0b0b0b;
  --sidebar: #111111; --sidebar-text: #b9b9b9; --sidebar-active: #222c3b;
  --series-1: #338ced; --grid: #303030; --baseline: #474747;
  --good-text: #53c556; --good-soft: #13291a; --warning-soft: #33290f; --serious-soft: #35211a;
  --critical-text: #f08080; --critical-soft: #3a1a1a;
  --map-0: #383838; --map-1: #1757ac; --map-2: #2370cd; --map-3: #338ced; --map-4: #6aabf1; --map-5: #9dc8f7;
  --map-ink-0: #9c9c9c; --map-ink-1: #ffffff; --map-ink-2: #ffffff; --map-ink-3: #0b0b0b; --map-ink-4: #0b0b0b; --map-ink-5: #0b0b0b;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.5); --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 var(--font); color: var(--text); background: var(--page); }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p { margin: 0 0 8px; }
small, .muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.num { font-variant-numeric: tabular-nums; }
.hidden, [hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: var(--sidebar); color: var(--sidebar-text); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { padding: 18px 18px 12px; color: #fff; font-weight: 700; font-size: 15px; line-height: 1.25; }
.brand small { display: block; color: var(--sidebar-text); font-weight: 400; font-size: 12px; margin-top: 2px; }
.nav-group { padding: 6px 10px; }
.nav-group > span { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; opacity: .6; padding: 8px 8px 4px; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 7px; color: var(--sidebar-text); font-size: 14px; }
.nav-link:hover { background: var(--sidebar-active); text-decoration: none; color: #fff; }
.nav-link.active { background: var(--sidebar-active); color: #fff; font-weight: 600; }
.nav-link .icon { width: 18px; text-align: center; opacity: .85; }
.nav-link .count { margin-left: auto; background: #dc3c3d; color: #fff; border-radius: 10px; font-size: 11px; padding: 0 7px; font-weight: 600; }
.sidebar-foot { margin-top: auto; padding: 12px 14px 16px; border-top: 1px solid rgba(255,255,255,.08); font-size: 13px; }
.sidebar-foot .who { color: #fff; font-weight: 600; }
.sidebar-foot select { width: 100%; margin: 8px 0; background: var(--sidebar-active); color: #fff; border: 1px solid rgba(255,255,255,.15); }
.sidebar-foot .row-links { display: flex; gap: 10px; flex-wrap: wrap; }
.sidebar-foot .row-links a, .sidebar-foot .row-links button { color: var(--sidebar-text); background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }
.main { min-width: 0; padding: 22px 28px 60px; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .sub { color: var(--text-2); margin-top: 2px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.mobile-bar { display: none; }
.main-wrap { min-width: 0; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 50; width: 240px; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .mobile-bar { display: flex; position: sticky; top: 0; z-index: 40; background: var(--page, #f5f6f8);
    padding: calc(8px + env(safe-area-inset-top)) 14px 6px; } /* Menu stays reachable while scrolling; clears the notch */
  .main { padding: 14px; }
}

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 16px 18px; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-head .actions { margin-left: auto; display: flex; gap: 6px; }
.card-body { padding: 14px 18px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-main-side { grid-template-columns: minmax(0, 1fr) 380px; }
.grid-side-main { grid-template-columns: 380px minmax(0, 1fr); }
@media (max-width: 1200px) { .grid-main-side, .grid-side-main { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 800px) { .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); } }
.grid > * { min-width: 0; } /* a wide child (tabs, tables) scrolls inside its card instead of widening the page */
@media (max-width: 1200px) { .ws-root .grid-side-main > :last-child { order: -1; } } /* call / text / email first on phones */
.stack > * + * { margin-top: 16px; }
.stack-sm > * + * { margin-top: 8px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }

/* ---------- KPI tiles ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .label { color: var(--text-2); font-size: 13px; }
.kpi .value { font-size: 26px; font-weight: 600; margin-top: 2px; }
.kpi .delta { font-size: 12px; color: var(--text-2); }
.hero { font-size: 48px; font-weight: 600; line-height: 1.05; }
.meter { height: 8px; border-radius: 4px; background: var(--accent-soft); overflow: hidden; margin-top: 8px; }
.meter > i { display: block; height: 100%; background: var(--series-1); border-radius: 4px; }

/* ---------- forms ---------- */
input, select, textarea, button { font: inherit; color: inherit; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], input[type=url], input[type=tel], input[type=datetime-local], input[type=date], select, textarea {
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 7px; padding: 7px 10px; min-height: 34px; max-width: 100%;
}
textarea { width: 100%; min-height: 90px; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 4px; }
label.field input, label.field select, label.field textarea { width: 100%; }
label.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 34px; padding: 6px 14px; border-radius: 7px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.success { background: var(--good-text); border-color: var(--good-text); color: #fff; }
.btn.danger { color: var(--critical-text); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { min-height: 28px; padding: 3px 10px; font-size: 13px; }
.btn.lg { min-height: 42px; padding: 8px 20px; font-size: 15px; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: 7px 0 0 7px; margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 7px 7px 0; }
.btn-group .btn.on { background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent); position: relative; z-index: 1; font-weight: 600; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters input[type=search] { min-width: 220px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { font-size: 12px; font-weight: 600; color: var(--text-2); background: var(--surface-2); position: sticky; top: 0; white-space: nowrap; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table tbody tr:hover { background: var(--surface-2); }
.table tr.clickable { cursor: pointer; }
.empty { padding: 36px 16px; text-align: center; color: var(--text-2); }
.empty b { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }

/* ---------- badges & chips ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-3); color: var(--text); white-space: nowrap; }
.badge .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.badge.hot { background: var(--critical-soft); }
.badge.hot .dot { background: var(--critical); }
.badge.warm { background: var(--warning-soft); }
.badge.warm .dot { background: var(--warning); }
.badge.cold { background: var(--accent-soft); }
.badge.cold .dot { background: var(--series-1); }
.badge.good { background: var(--good-soft); }
.badge.good .dot { background: var(--good); }
.badge.warn { background: var(--warning-soft); }
.badge.warn .dot { background: var(--warning); }
.badge.bad { background: var(--critical-soft); }
.badge.bad .dot { background: var(--critical); }
.badge.info { background: var(--accent-soft); }
.badge.info .dot { background: var(--series-1); }
.badge.neutral .dot { background: var(--text-3); }
.chip { display: inline-block; padding: 1px 8px; border: 1px solid var(--border-strong); border-radius: 6px; font-size: 12px; color: var(--text-2); white-space: nowrap; }
.score { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 24px; border-radius: 6px; font-weight: 700; font-size: 13px; background: var(--surface-3); font-variant-numeric: tabular-nums; }
.score.s-high { background: var(--accent); color: var(--on-accent); }
.score.s-mid { background: var(--accent-soft); color: var(--accent-text); }

/* ---------- opportunity feed ---------- */
.feed { display: flex; flex-direction: column; gap: 10px; }
.opp { display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; padding: 14px 16px; }
.opp .title { font-weight: 600; font-size: 15px; color: var(--text); }
.opp .meta { margin-top: 4px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--text-2); }
.opp .summary { margin-top: 6px; color: var(--text); }
.opp .angle { margin-top: 6px; padding: 6px 10px; border-left: 3px solid var(--series-1); background: var(--accent-soft); border-radius: 0 6px 6px 0; font-size: 13px; }
.opp .side { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }

/* ---------- tile map ---------- */
.tilemap { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 3px; max-width: 640px; }
.tile { aspect-ratio: 1.15; border-radius: 4px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; cursor: pointer; border: 0; padding: 0; line-height: 1.05; }
.tile small { font-weight: 500; font-size: 10px; color: inherit; opacity: .9; }
.tile:hover { filter: brightness(1.08); }
.tile.selected { outline: 2px solid var(--text); outline-offset: 1px; }
.legend { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; font-size: 12px; color: var(--text-2); margin-top: 10px; }
.legend .sw { display: inline-block; width: 14px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.tooltip { position: fixed; z-index: 100; pointer-events: none; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow-lg); padding: 7px 10px; font-size: 12px; max-width: 260px; }
.tooltip strong { display: block; font-size: 14px; }

/* ---------- bar charts ---------- */
.hbars { display: grid; grid-template-columns: max-content 1fr; gap: 8px 12px; align-items: center; }
.hbars .lbl { font-size: 13px; color: var(--text); white-space: nowrap; }
.hbars .track { position: relative; height: 20px; display: flex; align-items: center; }
.hbars .bar { height: 18px; background: var(--series-1); border-radius: 0 4px 4px 0; min-width: 2px; }
.hbars .val { margin-left: 8px; font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cols { display: flex; align-items: flex-end; gap: 2px; height: 80px; border-bottom: 1px solid var(--baseline); padding-top: 4px; }
.cols .c { flex: 1; display: flex; align-items: flex-end; justify-content: center; height: 100%; cursor: default; }
.cols .c i { display: block; width: 100%; max-width: 24px; background: var(--series-1); border-radius: 4px 4px 0 0; min-height: 0; }
.cols .c:hover i { filter: brightness(1.15); }
.cols-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-2); margin-top: 4px; }
.multiples { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; }
.multiples .m-title { font-size: 13px; color: var(--text-2); }
.multiples .m-value { font-size: 20px; font-weight: 600; }

/* ---------- pipeline board ---------- */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(200px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.col { background: var(--surface-2); border-radius: var(--radius); padding: 10px; min-height: 200px; }
.col.drop { outline: 2px dashed var(--accent); }
.col-head { display: flex; justify-content: space-between; font-weight: 600; font-size: 13px; margin-bottom: 8px; padding: 0 2px; }
.col-head .muted { font-weight: 400; }
.lead-card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 9px 10px; margin-bottom: 8px; cursor: grab; box-shadow: var(--shadow); }
.lead-card:active { cursor: grabbing; }
.lead-card .name { font-weight: 600; font-size: 13px; }
.lead-card .row { margin-top: 5px; gap: 5px; }

/* ---------- lead workspace ---------- */
.contact { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.contact:last-child { border-bottom: 0; }
.contact .n { font-weight: 600; }
.contact .t { color: var(--text-2); font-size: 13px; }
.contact .links { grid-column: 1 / -1; display: flex; gap: 12px; flex-wrap: wrap; font-size: 13px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); padding: 0 12px; overflow-x: auto; }
.tab { padding: 10px 12px; border: 0; background: none; cursor: pointer; color: var(--text-2); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab.on { color: var(--accent-text); border-bottom-color: var(--accent); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 28px 1fr; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.timeline .ic { width: 28px; height: 28px; border-radius: 50%; background: var(--surface-3); display: flex; align-items: center; justify-content: center; font-size: 13px; }
.timeline .head { display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; }
.timeline .body { white-space: pre-wrap; margin-top: 3px; color: var(--text); font-size: 13px; }
.dispositions { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.dispositions .btn { justify-content: flex-start; }
.dispositions .btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.timer { font-size: 28px; font-weight: 600; font-variant-numeric: tabular-nums; }
.script { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; font-size: 13px; }
.script + .script { margin-top: 8px; }
.script b { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); margin-bottom: 3px; }
details.obj { border-bottom: 1px solid var(--border); padding: 7px 0; }
details.obj summary { cursor: pointer; font-weight: 600; font-size: 13px; }
details.obj p { margin: 6px 0 0; font-size: 13px; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 10px; font-size: 13px; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.nba { background: var(--accent-soft); border: 1px solid var(--accent); border-radius: 8px; padding: 10px 12px; }
.nba b { color: var(--accent-text); }

/* ---------- modal & toast ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 80; display: flex; align-items: flex-start; justify-content: center; padding: 60px 16px; overflow-y: auto; }
.modal { background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-lg); width: 100%; max-width: 620px; }
.modal.wide { max-width: 900px; }
.modal-head { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head .x { margin-left: auto; }
.modal-body { padding: 18px 20px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 20px; border-top: 1px solid var(--border); }
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 120; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--text); color: var(--surface); padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow-lg); max-width: 380px; font-size: 13px; }
.toast.error { background: var(--critical); color: #fff; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: linear-gradient(160deg, #0f1b2d 0%, #1b3a63 100%); }
.login .card { width: 100%; max-width: 380px; padding: 28px; }
.login h1 { margin-bottom: 4px; }
.notice { padding: 10px 12px; border-radius: 8px; background: var(--warning-soft); font-size: 13px; }
.notice.info { background: var(--accent-soft); }
.pre { white-space: pre-wrap; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; background: var(--surface-2); padding: 10px; border-radius: 8px; max-height: 420px; overflow: auto; }
.loading { opacity: .55; pointer-events: none; transition: opacity .15s; }

/* ---------- Feedback: pressed buttons, busy buttons, loading bar, spinners ---------- */
.btn { transition: background-color .12s, border-color .12s, transform .06s, box-shadow .12s; position: relative; }
.btn:active:not(:disabled) { transform: translateY(1px) scale(.98); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.is-busy { color: transparent !important; pointer-events: none; }
.btn.is-busy > * { visibility: hidden; }
.btn.is-busy::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-color: var(--text-2) transparent var(--text-2) transparent;
  animation: spin .7s linear infinite;
}
.btn.primary.is-busy::after, .btn.success.is-busy::after { border-color: var(--on-accent) transparent var(--on-accent) transparent; }
.btn.sm.is-busy::after { width: 13px; height: 13px; }
.top-progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 1000; overflow: hidden; pointer-events: none; opacity: 0; transition: opacity .2s; }
.top-progress::before { content: ""; position: absolute; top: 0; bottom: 0; width: 35%; background: var(--accent); border-radius: 3px; animation: progress 1.1s ease-in-out infinite; }
html.is-loading .top-progress { opacity: 1; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--border-strong); border-top-color: var(--accent); animation: spin .8s linear infinite; }
.loading-view { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 64px 16px; color: var(--text-2); }
.boot { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; color: var(--text-2); font: 15px system-ui, sans-serif; }
.main > .view, .main > .page-head, .main > :first-child { animation: fade-in .18s ease-out; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes progress { 0% { left: -35%; } 100% { left: 100%; } }
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .btn, .btn:active:not(:disabled) { transition: none; transform: none; }
  .btn.is-busy::after, .spinner { animation-duration: 2s; }
  .top-progress::before { animation: none; left: 0; width: 100%; opacity: .6; }
  .main > .view, .main > .page-head, .main > :first-child { animation: none; }
}
.spinner.sm { width: 15px; height: 15px; border-width: 2px; border-color: currentColor; border-top-color: transparent; opacity: .9; }
.btn.working:disabled { opacity: .9; cursor: progress; }
.btn.is-busy:disabled { opacity: .9; }

/* ---------- Election cycles & freshness ---------- */
.chip.cycle { border-color: var(--accent); color: var(--accent-text, var(--accent)); }
.chip.past { opacity: .7; }
.chip.fact { background: var(--surface-2); }
.dates { color: var(--text-2); font-size: 12px; }
.dates .updated { color: var(--accent-text, var(--accent)); font-weight: 600; }
.change { font-size: 13px; padding: 4px 0; border-bottom: 1px solid var(--border); }
.change:last-child { border-bottom: 0; }
.live-bar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 8px 12px; margin: 0 0 12px; border-radius: 8px; background: var(--accent); color: var(--on-accent); font-size: 14px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .15); animation: fade-in .2s ease-out; }
.live-bar .btn { min-height: 28px; padding: 2px 10px; background: transparent; color: inherit; border-color: currentColor; }

/* Browser phone (bottom-left so it never covers toasts) */
.softphone { position: fixed; left: 18px; bottom: 18px; z-index: 110; }
.softphone .sp-pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-size: 12px; cursor: pointer; }
.softphone .sp-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint, #9ca3af); }
.softphone .sp-pill .dot.on { background: var(--good); }
.softphone .sp-card { width: 280px; padding: 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg); animation: fade-in .15s ease-out; }
.softphone .sp-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.softphone .sp-link { display: inline-block; font-size: 12px; margin-top: 4px; }
.softphone .sp-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.softphone .sp-keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 10px; }
@media (max-width: 720px) { .softphone { left: 10px; bottom: 10px; } .softphone .sp-card { width: calc(100vw - 20px); } }

/* Text thread on a lead */
.sms-thread { display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; padding: 4px 2px 8px; }
.sms { max-width: 78%; padding: 8px 11px; border-radius: 14px; font-size: 14px; white-space: pre-wrap; word-wrap: break-word; }
.sms.in { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 4px; }
.sms.out { align-self: flex-end; background: var(--accent); color: var(--on-accent); border-bottom-right-radius: 4px; }
.sms .meta { display: block; font-size: 11px; opacity: .75; margin-top: 3px; }

/* Petitions: ballot-status tiles */
.pet-tile { cursor: pointer; border: 1px solid transparent; transition: border-color .15s; }
.pet-tile:hover { border-color: var(--border); }
.pet-tile.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }


/* ---------- phones & touch screens ---------- */
@media (pointer: coarse) {
  .btn, .btn.sm { min-height: 40px !important; }
  .btn.sm { padding: 6px 12px; }
  .tab { min-height: 44px; }
  .nav-link { min-height: 44px; }
  input[type=checkbox], input[type=radio] { width: 20px; height: 20px; }
}
@media (max-width: 900px) {
  input, select, textarea { font-size: 16px; } /* below 16px iPhones zoom the page in on focus */
  .page-head { flex-wrap: wrap; gap: 10px; }
  .page-head .actions { margin-left: 0; }
  .filters > * { flex: 1 1 140px; min-width: 0; }
  .card-head { flex-wrap: wrap; }
  .opp { grid-template-columns: 40px minmax(0, 1fr); }
  .opp .side { grid-column: 1 / -1; align-items: center; flex-direction: row; flex-wrap: wrap; }
  .filters input[type=search] { min-width: 0; flex-basis: 100%; }
  .opp .side > div:first-child { text-align: left !important; width: 100%; }
}
