/* Election Ops — fast, high-contrast, large touch targets. */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #d8dce3;
  --text: #16181d;
  --muted: #5d6471;
  --sidebar: #1b2030;
  --sidebar-text: #c9cfdb;
  --accent: #1f5fd0;
  --accent-text: #ffffff;
  --good: #137a3c;
  --warn: #9a6200;
  --bad: #b3261e;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16,20,30,.08), 0 2px 8px rgba(16,20,30,.05);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font);
  font-size: 16px; line-height: 1.45;
  color: var(--text); background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.hidden { display: none !important; }

/* ---------------------------------------------------------------- shell */
#app { display: flex; min-height: 100%; }
#sidebar {
  width: 232px; flex: 0 0 232px; background: var(--sidebar);
  color: var(--sidebar-text); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand { padding: 16px 18px 10px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand h1 { font-size: 15px; margin: 0; color: #fff; letter-spacing: .2px; }
.brand .sub { font-size: 12px; color: #8d97aa; margin-top: 2px; }
.countdown {
  margin: 10px 14px; padding: 8px 10px; border-radius: var(--radius);
  background: rgba(255,255,255,.06); font-size: 12px; color: #d7deea;
}
.countdown strong { display: block; font-size: 19px; color: #fff; }
nav { padding: 6px 8px; flex: 1; overflow-y: auto; }
nav button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: none; border: 0; text-align: left; cursor: pointer;
  padding: 11px 12px; border-radius: 6px; color: var(--sidebar-text);
  font-size: 14.5px;
}
nav button:hover { background: rgba(255,255,255,.07); color: #fff; }
nav button[aria-current="page"] { background: var(--accent); color: #fff; font-weight: 600; }
nav .pill {
  margin-left: auto; background: rgba(255,255,255,.14); color: #fff;
  border-radius: 10px; padding: 1px 7px; font-size: 11.5px; font-variant-numeric: tabular-nums;
}
.sidebar-foot { padding: 12px 14px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12.5px; }
.sidebar-foot .who-btn {
  display: block; width: 100%; text-align: left; background: none; border: 0;
  padding: 4px 6px; margin: -4px -6px; border-radius: 6px; cursor: pointer;
  color: inherit; font: inherit;
}
.sidebar-foot .who-btn:hover { background: rgba(255,255,255,.07); }
.sidebar-foot .who { color: #fff; font-weight: 600; display: block; font-size: 12.5px; }
.sidebar-foot .role { color: #8d97aa; text-transform: capitalize; display: block;
                      font-size: 12.5px; }
.sidebar-foot button {
  margin-top: 8px; width: 100%; background: rgba(255,255,255,.08); color: #e7ebf3;
  border: 0; padding: 8px; border-radius: 6px; cursor: pointer;
}
main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 10px 18px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar h2 { font-size: 16px; margin: 0; flex: 1; }
.view { padding: 18px; max-width: 1280px; width: 100%; }

/* ------------------------------------------------------- connection chip */
.conn { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px;
        padding: 5px 10px; border-radius: 999px; border: 1px solid var(--border);
        background: var(--surface-2); white-space: nowrap; }
.conn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.conn[data-state="live"] { color: var(--good); border-color: #b9e0c7; background: #eef8f1; }
.conn[data-state="live"] .dot { background: var(--good); }
.conn[data-state="connecting"] { color: var(--warn); border-color: #f0dcae; background: #fdf6e6; }
.conn[data-state="connecting"] .dot { background: var(--warn); }
.conn[data-state="offline"] { color: var(--bad); border-color: #f0c2bf; background: #fdeeed; }
.conn[data-state="offline"] .dot { background: var(--bad); }

/* ---------------------------------------------------------------- cards */
.card { background: var(--surface); border: 1px solid var(--border);
        border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; }
.card > h3 { margin: 0; padding: 12px 16px; border-bottom: 1px solid var(--border);
             font-size: 14px; display: flex; align-items: center; gap: 8px; }
.card > h3 .right { margin-left: auto; font-weight: 400; color: var(--muted); font-size: 12.5px; }
.card-body { padding: 16px; }
.grid { display: grid; gap: 12px; }
.cols-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.cols-3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }

/* ---------------------------------------------------------------- metrics */
.metrics { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)); }
.metric { background: var(--surface); border: 1px solid var(--border);
          border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.metric .label { font-size: 12px; color: var(--muted); display: flex; gap: 5px; align-items: center; }
.metric .value { font-size: 27px; font-weight: 650; font-variant-numeric: tabular-nums;
                 line-height: 1.15; margin-top: 3px; }
.metric .foot { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.metric.accent .value { color: var(--accent); }
.metric.good .value { color: var(--good); }
.metric.warn .value { color: var(--warn); }
.metric.bad .value { color: var(--bad); }
/* The little "i" badge on a metric. Named distinctly so it cannot collide with
   the .tag.info modifier, which is a pill, not a 15px dot. */
.hintdot {
  display: inline-flex; width: 15px; height: 15px; border-radius: 50%;
  background: var(--border); color: var(--text); font-size: 10.5px;
  align-items: center; justify-content: center; cursor: help; flex: 0 0 auto;
}

/* ---------------------------------------------------------------- caller */
.caller { display: grid; gap: 16px; grid-template-columns: minmax(0,1.15fr) minmax(0,1fr); }
.record-name { font-size: 26px; font-weight: 680; margin: 0 0 2px; }
.record-sub { color: var(--muted); font-size: 14px; }
.phone-row { margin: 14px 0 4px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.phone-big { font-size: 27px; font-weight: 650; letter-spacing: .4px; font-variant-numeric: tabular-nums; }
.phone-big a { text-decoration: none; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.tag { font-size: 12px; padding: 3px 9px; border-radius: 999px;
       background: var(--surface-2); border: 1px solid var(--border); color: var(--muted);
       white-space: nowrap; flex: 0 0 auto; max-width: 100%; overflow: hidden;
       text-overflow: ellipsis; }
.tag.supportive { background: #eef8f1; border-color: #b9e0c7; color: var(--good); }
.tag.leaning { background: #fdf6e6; border-color: #f0dcae; color: var(--warn); }
.tag.alert { background: #fdeeed; border-color: #f0c2bf; color: var(--bad); }
.tag.info { background: #eef3fd; border-color: #c3d4f2; color: var(--accent); }

.outcomes { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.outcome-btn {
  padding: 18px 12px; border-radius: var(--radius); border: 2px solid var(--border);
  background: var(--surface); cursor: pointer; font-size: 15.5px; font-weight: 600;
  text-align: center; min-height: 64px; transition: none;
}
.outcome-btn:hover { border-color: var(--accent); }
.outcome-btn[aria-pressed="true"] { border-color: var(--accent); background: #eef3fd; color: var(--accent); }
.outcome-btn .hint { display: block; font-size: 11.5px; font-weight: 400; color: var(--muted); margin-top: 3px; }
.outcome-btn[data-tone="good"][aria-pressed="true"] { border-color: var(--good); background: #eef8f1; color: var(--good); }
.outcome-btn[data-tone="bad"][aria-pressed="true"] { border-color: var(--bad); background: #fdeeed; color: var(--bad); }

textarea, input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="datetime-local"], input[type="date"], select {
  width: 100%; padding: 10px 11px; border: 1px solid var(--border);
  border-radius: 6px; background: var(--surface); font-size: 15px;
}
textarea { min-height: 76px; resize: vertical; }
label.field { display: block; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
label.field > span { display: block; margin-bottom: 4px; font-weight: 600; color: var(--text); }
.inline { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.inline > * { flex: 1 1 160px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14.5px; }
.check input { width: 20px; height: 20px; flex: 0 0 auto; }

.btn {
  padding: 12px 18px; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; font-weight: 600; font-size: 15px;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { background: #1a51b4; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.big { width: 100%; padding: 16px; font-size: 17px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.sm { padding: 6px 11px; font-size: 13px; font-weight: 500; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

.savestate { font-size: 13px; color: var(--muted); min-height: 20px; display: flex;
             align-items: center; gap: 6px; }
.savestate[data-state="saving"] { color: var(--warn); }
.savestate[data-state="saved"] { color: var(--good); }
.savestate[data-state="error"], .savestate[data-state="queued"] { color: var(--bad); }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border);
         white-space: nowrap; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted);
     background: var(--surface-2); position: sticky; top: 0; }
tbody tr:hover { background: var(--surface-2); }
td.wrap, th.wrap { white-space: normal; }
.status { font-size: 11.5px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border);
          background: var(--surface-2); text-transform: capitalize; }
.status[data-s="available"] { color: var(--good); border-color: #b9e0c7; background: #eef8f1; }
.status[data-s="assigned"] { color: var(--accent); border-color: #c3d4f2; background: #eef3fd; }
.status[data-s="needs_review"] { color: var(--warn); border-color: #f0dcae; background: #fdf6e6; }
.status[data-s="dnc"] { color: var(--bad); border-color: #f0c2bf; background: #fdeeed; }

.feed { max-height: 330px; overflow-y: auto; font-size: 13px; }
.feed li { list-style: none; padding: 8px 0; border-bottom: 1px solid var(--border);
           display: flex; gap: 8px; }
.feed ul { margin: 0; padding: 0; }
.feed time { color: var(--muted); font-variant-numeric: tabular-nums; flex: 0 0 62px; }
.feed .sev { flex: 0 0 auto; }
.feed .sev[data-s="warning"]::before { content: "▲"; color: var(--warn); }
.feed .sev[data-s="error"]::before { content: "●"; color: var(--bad); }
.feed .sev[data-s="info"]::before { content: "·"; color: var(--muted); }

.banner { padding: 11px 14px; border-radius: var(--radius); margin-bottom: 14px;
          font-size: 14px; border: 1px solid; }
.banner.err { background: #fdeeed; border-color: #f0c2bf; color: #8c1d18; }
.banner.ok { background: #eef8f1; border-color: #b9e0c7; color: #0c5c2e; }
.banner.warn { background: #fdf6e6; border-color: #f0dcae; color: #7a4e00; }
.banner.info { background: #eef3fd; border-color: #c3d4f2; color: #16407f; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.empty { padding: 28px; text-align: center; color: var(--muted); }
.bar { height: 7px; border-radius: 4px; background: var(--border); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); }
.hist li { list-style: none; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.hist ul { margin: 0; padding: 0; }
.steps { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; font-size: 13px; }
.steps span { padding: 5px 11px; border-radius: 999px; background: var(--surface-2);
              border: 1px solid var(--border); color: var(--muted); }
.steps span[aria-current="step"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.steps span[data-done="1"] { color: var(--good); border-color: #b9e0c7; background: #eef8f1; }

/* ---------------------------------------------------------------- login */
.login-wrap { display: flex; align-items: center; justify-content: center;
              min-height: 100vh; width: 100%; padding: 20px; }
.login { max-width: 400px; width: 100%; }
.login h1 { font-size: 21px; margin: 0 0 2px; }
.login .sub { color: var(--muted); font-size: 13.5px; margin-bottom: 18px; }

/* ---------------------------------------------------------------- mobile */
#mobile-nav { display: none; }
@media (max-width: 860px) {
  #app { flex-direction: column; }
  #sidebar { display: none; }
  main { padding-bottom: 68px; }
  .view { padding: 12px; }
  .caller { grid-template-columns: 1fr; }
  .topbar { padding: 9px 12px; }
  .topbar h2 { font-size: 15px; }
  #mobile-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
    background: var(--sidebar); border-top: 1px solid rgba(255,255,255,.1);
    padding-bottom: env(safe-area-inset-bottom);
    overflow-x: auto; scrollbar-width: none;
  }
  #mobile-nav::-webkit-scrollbar { display: none; }
  #mobile-nav button {
    flex: 1 1 0; min-width: 0; background: none; border: 0; color: var(--sidebar-text);
    padding: 9px 1px 8px; font-size: 10px; cursor: pointer; line-height: 1.25;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  #mobile-nav button .ico { display: block; font-size: 18px; }
  #mobile-nav button[aria-current="page"] { color: #fff; background: rgba(255,255,255,.1); }
  .outcomes { grid-template-columns: 1fr 1fr; }
  .outcome-btn { min-height: 72px; font-size: 15px; }
  .record-name { font-size: 22px; }
  .phone-big { font-size: 24px; }
  th, td { padding: 8px 9px; }
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1218; --surface: #171b24; --surface-2: #1d222d; --border: #2b3240;
    --text: #e8ebf1; --muted: #9aa3b4; --sidebar: #0b0e14;
    --accent: #5b92f0; --good: #52c47f; --warn: #e2b046; --bad: #f0796f;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
  }
  :root:not([data-theme="light"]) .tag.supportive,
  :root:not([data-theme="light"]) .status[data-s="available"] { background: #10301d; border-color: #1f5c38; }
  :root:not([data-theme="light"]) .tag.leaning,
  :root:not([data-theme="light"]) .status[data-s="needs_review"] { background: #322607; border-color: #6b5214; }
  :root:not([data-theme="light"]) .tag.alert,
  :root:not([data-theme="light"]) .status[data-s="dnc"] { background: #3a1512; border-color: #7a2a24; }
  :root:not([data-theme="light"]) .tag.info,
  :root:not([data-theme="light"]) .status[data-s="assigned"],
  :root:not([data-theme="light"]) .outcome-btn[aria-pressed="true"] { background: #12213d; border-color: #2d4c82; }
  :root:not([data-theme="light"]) .banner.err { background: #3a1512; border-color: #7a2a24; color: #ffb4ad; }
  :root:not([data-theme="light"]) .banner.ok { background: #10301d; border-color: #1f5c38; color: #8ee0ab; }
  :root:not([data-theme="light"]) .banner.warn { background: #322607; border-color: #6b5214; color: #f0d08a; }
  :root:not([data-theme="light"]) .banner.info { background: #12213d; border-color: #2d4c82; color: #a9c6f7; }
  :root:not([data-theme="light"]) .conn[data-state="live"] { background: #10301d; border-color: #1f5c38; }
  :root:not([data-theme="light"]) .conn[data-state="connecting"] { background: #322607; border-color: #6b5214; }
  :root:not([data-theme="light"]) .conn[data-state="offline"] { background: #3a1512; border-color: #7a2a24; }
}

/* An irreversible outcome is kept out of the fast tap grid. */
.destructive-row { margin-top: 12px; }
.outcome-btn.destructive {
  width: 100%; min-height: 56px; font-size: 14.5px; border-style: dashed;
  border-color: var(--bad); color: var(--bad); background: var(--surface);
}
.outcome-btn.destructive[aria-pressed="true"] {
  background: #fdeeed; border-style: solid;
}
:root:not([data-theme="light"]) .outcome-btn.destructive[aria-pressed="true"] {
  background: #3a1512;
}
.barlabel { display: flex; justify-content: space-between; gap: 12px; }
