:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --border: #e6e8eb;
  --text: #14181f;
  --muted: #6b7280;
  --side: #0f1115;
  --side-text: #d6d8dc;
  --side-muted: #7a8190;
  --accent: #ff7a1a;
  --accent-soft: #fff1e6;
  --green: #16a34a;
  --red: #dc2626;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 1px 8px rgba(0,0,0,.04);
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, "Segoe UI", Inter, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
}
a { color: inherit; text-decoration: none; }

/* Sidebar -------------------------------------------------- */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 220px;
  background: var(--side);
  color: var(--side-text);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.brand {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 15px;
  margin-bottom: 8px;
}
.brand-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(255,122,26,.25);
}
.brand-name { letter-spacing: .2px; }
.nav-label {
  font-size: 10px; letter-spacing: .12em; color: var(--side-muted);
  text-transform: uppercase; padding: 0 6px;
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px;
  color: var(--side-text);
  font-size: 13px;
}
.nav-item:hover { background: #1a1d25; }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-ico { width: 16px; display: inline-block; text-align: center; opacity: .9; }
.sidebar-foot { margin-top: auto; border-top: 1px solid #1d2129; padding-top: 12px; }
.user-row { display: flex; align-items: center; gap: 10px; }
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: grid; place-items: center; font-weight: 700;
}
.user-name { font-size: 12px; }
.user-plan { font-size: 10px; color: var(--side-muted); letter-spacing: .1em; }
.app-version { margin-top: 10px; font-size: 10px; color: var(--side-muted); letter-spacing: .08em; text-align: right; }

/* Main ---------------------------------------------------- */
.main {
  margin-left: 220px;
  padding: 22px 28px 80px;
}
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 18px;
}
.page-head h1 { margin: 0 0 4px; font-size: 22px; font-weight: 700; }
.muted { color: var(--muted); font-size: 12px; }
.back-link { font-size: 12px; color: var(--muted); }

/* Stat cards ---------------------------------------------- */
.stat-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px;
  margin-bottom: 18px;
}
.stat {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
  box-shadow: var(--shadow);
}
.stat-label { font-size: 10px; letter-spacing: .12em; color: var(--muted); text-transform: uppercase; }
.stat-value { font-size: 28px; font-weight: 700; margin-top: 4px; }
.stat-value.sm { font-size: 18px; }
.stat-value.green { color: var(--green); }
.stat-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* Filter bar ---------------------------------------------- */
.filter-bar {
  display: flex; gap: 12px; align-items: end;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.filter { display: flex; flex-direction: column; gap: 4px; }
.filter.grow { flex: 1; }
.filter label { font-size: 10px; letter-spacing: .12em; color: var(--muted); text-transform: uppercase; }
.filter input, .filter select {
  border: 1px solid var(--border); border-radius: 6px;
  padding: 6px 10px; font-size: 13px; font-family: inherit; min-width: 130px;
}
.filter.grow input { width: 100%; }

/* Buttons ------------------------------------------------- */
.btn {
  border: 1px solid var(--border); background: #fff;
  border-radius: 8px; padding: 7px 14px; font-size: 13px; cursor: pointer;
  font-family: inherit; color: var(--text);
}
.btn:hover { background: #f3f4f6; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #e96a0d; }
.btn.ghost { background: transparent; }
.btn.lg { padding: 9px 18px; font-weight: 600; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.danger:hover { background: #b91c1c; }

/* Table --------------------------------------------------- */
.table-wrap {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: auto;
  box-shadow: var(--shadow);
}
.data-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.data-table thead th {
  background: #fafbfc;
  text-align: left;
  font-size: 10px; letter-spacing: .1em; color: var(--muted); text-transform: uppercase;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
}
.data-table tbody tr {
  height: 36px;
  cursor: pointer;
}
.data-table tbody td {
  padding: 6px 12px; border-bottom: 1px solid #f0f1f4;
  vertical-align: middle;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}
.data-table tbody tr:hover { background: #fafbfc; }
.data-table .empty { text-align: center; color: var(--muted); padding: 30px; cursor: default; }
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  background: #ede9fe; color: #6d28d9; font-weight: 600; font-size: 10px; letter-spacing: .04em;
  text-transform: uppercase; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; vertical-align: middle;
}
.entity-badge { background: #fef3c7; color: #92400e; }

/* DCAD enrichment toggle ----------------------------------------- */
.dcad-switch {
  position: relative; display: inline-flex; align-items: center;
  cursor: pointer; user-select: none; gap: 10px;
}
.dcad-switch input { display: none; }
.dcad-slider {
  width: 44px; height: 22px; background: #d1d5db; border-radius: 999px;
  position: relative; transition: background 0.15s;
}
.dcad-slider::before {
  content: ""; position: absolute; left: 3px; top: 3px;
  width: 16px; height: 16px; background: white; border-radius: 50%;
  transition: transform 0.15s;
}
.dcad-switch input:checked + .dcad-slider { background: var(--accent, #f97316); }
.dcad-switch input:checked + .dcad-slider::before { transform: translateX(22px); }
.dcad-label { font-weight: 600; font-size: 13px; }
.flag {
  display: inline-block; padding: 2px 6px; border-radius: 4px;
  background: #fef3c7; color: #92400e; font-size: 11px;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; vertical-align: middle;
}
.notes { max-width: 220px; }
.trustees { max-width: 200px; font-size: 11px; color: var(--muted); }

/* Modal --------------------------------------------------- */
.modal {
  position: fixed; inset: 0; background: rgba(15,17,21,.45);
  display: grid; place-items: center; z-index: 50;
}
.modal.hidden { display: none; }
.modal-card {
  width: 460px; max-width: 90vw; background: #fff; border-radius: var(--radius);
  border: 1px solid var(--border); box-shadow: 0 12px 40px rgba(0,0,0,.18);
  display: flex; flex-direction: column;
}
.modal-card.wide { width: 720px; }
.modal-head, .modal-foot {
  padding: 14px 18px; display: flex; align-items: center; justify-content: space-between;
}
.modal-head { border-bottom: 1px solid var(--border); }
.modal-foot { border-top: 1px solid var(--border); gap: 8px; justify-content: flex-end; }
.modal-head h3 { margin: 0; font-size: 15px; }
.modal-close { background: none; border: none; font-size: 24px; cursor: pointer; color: var(--muted); }
.modal-body { padding: 16px 18px; max-height: 70vh; overflow: auto; }
.form-row { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.form-row.checkbox { flex-direction: row; align-items: center; gap: 8px; }
.form-row label { font-size: 12px; color: var(--muted); }
.form-row input[type=date], .form-row input[type=number], .form-row input[type=text] {
  border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 10px; font-size: 13px; font-family: inherit;
}
.hidden { display: none !important; }

.btn.sm { padding: 4px 10px; font-size: 12px; }
.preset-row { display: flex; flex-wrap: wrap; gap: 6px; }
.preset-row .btn.active {
  background: var(--accent); border-color: var(--accent); color: #fff;
}

/* County picker (Run Scrape modal) ------------------------ */
.county-actions { display: flex; gap: 6px; margin-bottom: 6px; }
.county-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(140px, 1fr));
  gap: 4px 12px;
  max-height: 250px; overflow-y: auto;
  padding: 8px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 6px;
  background: #fafafa;
}
.county-grid label {
  font-size: 12px;
  display: flex; align-items: center; gap: 6px;
  padding: 2px 4px;
  cursor: pointer;
}
.county-grid label:hover { background: #f3f4f6; }
.county-grid .star { color: #f59e0b; font-size: 10px; }

.mode-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.radio-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 12px; border: 1px solid var(--border, #e5e7eb);
  border-radius: 999px; cursor: pointer; font-size: 13px;
  background: white;
}
.radio-pill input { margin: 0; }
.radio-pill:has(input:checked) {
  background: var(--accent, #f97316); color: white; border-color: var(--accent, #f97316);
}

/* County filter popover (Leads page) ----------------------- */
.county-filter-trigger {
  white-space: nowrap; min-width: 130px; text-align: left;
}
.county-filter-pop {
  position: absolute; top: 100%; left: 0; z-index: 30;
  margin-top: 4px; padding: 8px;
  background: white; border: 1px solid var(--border, #e5e7eb);
  border-radius: 6px; box-shadow: 0 6px 24px rgba(0,0,0,0.12);
  width: 460px;
}
.county-filter-pop.hidden { display: none; }
.county-filter-pop .county-grid {
  background: white;
  max-height: 300px;
}

/* Resume interrupted-job items ----------------------------- */
.resume-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 10px; border-bottom: 1px solid var(--border, #e5e7eb);
  gap: 10px;
}
.resume-item:last-child { border-bottom: none; }
.resume-info { flex: 1; }
.resume-actions { display: flex; gap: 6px; }

/* County pill (Leads table) -------------------------------- */
.county-pill {
  display: inline-block; padding: 2px 7px;
  font-size: 11px; font-weight: 600;
  background: #e0e7ff; color: #3730a3;
  border-radius: 4px; white-space: nowrap;
}

/* Documents Available indicators --------------------------- */
.docs-yes { color: #047857; font-weight: 600; font-size: 11px; }
.docs-no  { color: #9ca3af; font-weight: 600; font-size: 11px; }

/* Status pill (Complete / Incomplete) --------------------- */
.status-pill {
  display: inline-block; padding: 2px 7px;
  font-size: 11px; font-weight: 600;
  border-radius: 4px; white-space: nowrap;
}
.status-complete   { background: #d1fae5; color: #047857; }
.status-incomplete { background: #fef3c7; color: #92400e; }

/* Owner-type pill (Person / Entity) ----------------------- */
.owner-type-pill {
  display: inline-block; padding: 2px 7px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.05em;
  border-radius: 4px; white-space: nowrap;
}
.owner-type-person { background: #dbeafe; color: #1d4ed8; }
.owner-type-entity { background: #fef3c7; color: #92400e; }

/* Address-source provenance badge (P1 = original doc, P2 = DCAD) -------- */
.src-badge {
  display: inline-block; padding: 1px 6px; margin-left: 4px;
  font-size: 9px; font-weight: 700; letter-spacing: 0.04em;
  border-radius: 4px; white-space: nowrap; vertical-align: middle;
}
.src-p1 { background: #e0e7ff; color: #3730a3; }   /* phase-1 / original doc */
.src-p2 { background: #dcfce7; color: #166534; }   /* phase-2 / DCAD site */

/* Per-column filter button + popover ----------------------- */
.col-filter-btn {
  background: transparent; border: none; padding: 0 2px; margin-left: 4px;
  cursor: pointer; color: #9ca3af; font-size: 11px;
  vertical-align: middle;
}
.col-filter-btn:hover { color: #111; }
.col-filter-btn.active { color: var(--accent, #f97316); }

.col-filter-pop {
  position: absolute; z-index: 50;
  background: white; border: 1px solid var(--border, #e5e7eb);
  border-radius: 6px; box-shadow: 0 6px 24px rgba(0,0,0,0.15);
  min-width: 220px; max-width: 360px;
  padding: 8px;
}
.col-filter-pop.hidden { display: none; }
.col-filter-body {
  max-height: 280px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 4px;
}
.col-filter-body input[type=text],
.col-filter-body input[type=search] {
  width: 100%; box-sizing: border-box;
  padding: 6px 8px; font-size: 13px;
  border: 1px solid var(--border, #e5e7eb); border-radius: 4px;
}
.col-filter-body label {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; padding: 2px 4px; cursor: pointer;
}
.col-filter-body label:hover { background: #f3f4f6; }
.col-filter-foot {
  display: flex; gap: 6px; justify-content: flex-end;
  margin-top: 6px; padding-top: 6px;
  border-top: 1px solid var(--border, #e5e7eb);
}

/* Progress bar ------------------------------------------- */
.progress-bar {
  position: fixed; left: 220px; right: 0; bottom: 0;
  background: var(--side); color: #fff;
  padding: 10px 18px; z-index: 40;
  display: flex; justify-content: center;
}
.progress-bar-inner { display: flex; align-items: center; gap: 16px; max-width: 1200px; width: 100%; }
.pb-step { font-weight: 600; }
.pb-counts { color: #c5cad3; font-size: 12px; }
.pb-counts b { color: #fff; }

/* Case detail ------------------------------------------- */
.case-grid {
  display: grid; grid-template-columns: 2fr 1fr; gap: 16px;
}
.case-pdf {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); min-height: 720px; overflow: hidden;
  box-shadow: var(--shadow);
}
.case-pdf iframe { width: 100%; height: 100%; border: 0; min-height: 720px; }
.page-stack { display: flex; flex-direction: column; gap: 10px; padding: 10px; max-height: 80vh; overflow: auto; background: #1f1f23; }
.page-stack img { width: 100%; height: auto; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.center { text-align: center; padding: 40px; }
.case-side { display: flex; flex-direction: column; gap: 14px; }
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 10px; font-size: 13px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.card.warn { background: #fff7ed; border-color: #fed7aa; }
.card.warn h3 { color: #c2410c; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 10px; margin: 0; }
.kv dt { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.kv dd { margin: 0; }
/* Section divider rows inside the key/value grid. */
.kv dt.kv-subhead {
  grid-column: 1 / -1; margin-top: 8px; padding-top: 6px;
  border-top: 1px solid var(--border, #e5e7eb);
  color: var(--accent, #f97316); font-weight: 700; font-size: 10px;
}
.kv dd.kv-subhead-sp { display: none; }
.raw-html { font-size: 10px; background: #f3f4f6; padding: 10px; border-radius: 6px; overflow: auto; max-height: 240px; }
.legal-desc { font-size: 11px; line-height: 1.5; color: var(--text); white-space: pre-wrap; }

/* Inline-editable fields ---------------------------------- */
.editable { cursor: text; border-radius: 4px; padding: 2px 6px; margin: -2px -6px; transition: background .1s; }
.editable:hover { background: #f3f4f6; }
.editable:focus { outline: 2px solid var(--accent); outline-offset: -1px; background: #fff; }
.editable .val { display: block; min-height: 18px; }
.editable.is-blank .val { color: var(--muted); font-style: italic; }
.editable.is-verified { background: #f0fdf4; }
.editable.is-verified:hover { background: #dcfce7; }
.field-edit-input {
  width: 100%; border: 1px solid var(--accent); border-radius: 4px;
  padding: 4px 6px; font-size: 13px; font-family: inherit;
  background: #fff; color: var(--text); resize: vertical;
}
.field-edit-input:focus { outline: none; box-shadow: 0 0 0 2px rgba(255,122,26,.2); }
.vchk {
  display: inline-block; color: var(--green); font-weight: 700;
  font-size: 11px; cursor: pointer; user-select: none; margin-left: 4px;
}
.vchk:hover { color: var(--red); }
.ok-text { color: var(--green); font-weight: 600; }
.kb-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.kb-table td { padding: 6px 8px; vertical-align: top; }
.kb-table tr:nth-child(odd) { background: #fafbfc; }
.kb-table kbd {
  display: inline-block; padding: 2px 6px; border-radius: 4px;
  background: #f3f4f6; border: 1px solid var(--border);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px; min-width: 18px; text-align: center;
}

/* Dashboard log stream ----------------------------------- */
.lvl-toggle { display: inline-block; font-size: 11px; margin-right: 8px; color: var(--text); cursor: pointer; }
.lvl-toggle input { margin-right: 3px; vertical-align: middle; }
.log-stream {
  background: #0f1115; color: #d6d8dc;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 11.5px; line-height: 1.55;
  border-radius: 8px; padding: 12px 14px;
  height: 480px; overflow: auto;
  white-space: pre-wrap; word-break: break-word;
}
.log-line { display: flex; gap: 10px; padding: 1px 0; }
.log-ts { color: #7a8190; flex: 0 0 auto; }
.log-lvl { flex: 0 0 50px; font-weight: 700; }
.log-lvl.info  { color: #60a5fa; }
.log-lvl.warn  { color: #fbbf24; }
.log-lvl.error { color: #f87171; }
.log-lvl.debug { color: #6b7280; }
.log-step { color: #a78bfa; flex: 0 0 auto; }
.log-msg { flex: 1 1 auto; color: #e5e7eb; }
.log-job { color: #7a8190; font-size: 10px; margin-left: 6px; }

/* ========================================================
   County Pull page
   ======================================================== */
.cp-hero {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; margin-bottom: 14px;
}
.cp-hero-left { display: flex; flex-direction: column; gap: 4px; }
.cp-status-line {
  display: flex; align-items: center; gap: 10px;
  font-size: 16px; font-weight: 600;
}
.cp-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: #9ca3af; flex: 0 0 auto;
}
.cp-dot.online  { background: #10b981; box-shadow: 0 0 0 4px rgba(16,185,129,0.15); }
.cp-dot.offline { background: #ef4444; box-shadow: 0 0 0 4px rgba(239,68,68,0.15); }
.cp-dot.idle    { background: #f59e0b; }
.cp-hero-meta { font-size: 13px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.cp-sep { opacity: 0.4; padding: 0 2px; }

/* Two-column layout */
.cp-grid {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(360px, 1.2fr);
  gap: 14px;
}
@media (max-width: 980px) {
  .cp-grid { grid-template-columns: 1fr; }
}
.cp-right-col { display: flex; flex-direction: column; gap: 14px; }

/* Push card */
.cp-push-card .cp-big-stat {
  text-align: center; padding: 12px 0 8px;
}
.cp-big-num {
  font-size: 56px; font-weight: 700; line-height: 1;
  color: var(--accent, #f97316);
  font-variant-numeric: tabular-nums;
}
.cp-big-label { color: #6b7280; font-size: 13px; margin-top: 4px; }
.cp-substat { font-size: 12px; text-align: center; display: flex; gap: 4px;
  justify-content: center; flex-wrap: wrap; align-items: center; }
.cp-push-btn {
  width: 100%; margin-top: 14px; padding: 12px 18px;
  font-size: 15px; font-weight: 600;
}
.cp-row { display: flex; gap: 6px; justify-content: center; }
.cp-preview {
  margin-top: 12px; background: #0f172a; color: #cbd5e1;
  padding: 10px; border-radius: 6px;
  max-height: 280px; overflow: auto;
  font-size: 11px; font-family: ui-monospace, Menlo, Consolas, monospace;
  white-space: pre; line-height: 1.45;
}
.cp-push-result {
  margin-top: 12px; padding: 10px 12px; border-radius: 6px;
  font-size: 13px; font-weight: 500;
}
.cp-push-result.sent   { background: #d1fae5; color: #065f46; }
.cp-push-result.empty  { background: #fef3c7; color: #92400e; }
.cp-push-result.error  { background: #fee2e2; color: #991b1b; }

/* Auto-sync compact row */
.cp-auto-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 14px;
}
.cp-inline-select, .cp-inline-time {
  padding: 6px 8px; border: 1px solid var(--border, #e5e7eb);
  border-radius: 4px; font-size: 14px; background: white;
}
.cp-inline-word { font-size: 14px; }
.cp-auto-save { margin-left: 4px; }
.cp-auto-meta { font-size: 11px; margin-top: 10px; }

/* History timeline */
.cp-timeline { display: flex; flex-direction: column; }
.cp-timeline-empty { padding: 14px; text-align: center; font-size: 13px; }
.cp-timeline-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border, #f1f5f9);
}
.cp-timeline-row:last-child { border-bottom: none; }
.cp-timeline-icon {
  flex: 0 0 22px; height: 22px; width: 22px;
  border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.cp-timeline-icon.sent  { background: #d1fae5; color: #065f46; }
.cp-timeline-icon.empty { background: #fef3c7; color: #92400e; }
.cp-timeline-icon.error { background: #fee2e2; color: #991b1b; }
.cp-timeline-body { flex: 1; min-width: 0; }
.cp-timeline-title { font-size: 13px; font-weight: 500; }
.cp-timeline-sub { font-size: 11px; color: #6b7280; margin-top: 2px; }
.cp-timeline-trigger {
  font-size: 10px; padding: 1px 6px; border-radius: 999px;
  background: #dbeafe; color: #1e40af; margin-left: 6px;
  text-transform: uppercase; font-weight: 600; letter-spacing: 0.04em;
}
.cp-timeline-trigger.manual {
  background: #f3f4f6; color: #4b5563;
}

/* County picker (single-select dropdown + advanced multi) */
.cp-county-picker {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 10px;
}
.cp-county-label {
  font-size: 12px; font-weight: 600; color: #475569;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.cp-county-select {
  flex: 1; padding: 6px 10px; font-size: 14px;
  border: 1px solid #cbd5e1; border-radius: 6px;
  background: white;
}
.cp-county-multi {
  margin-bottom: 10px;
  padding: 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}
.cp-county-multi.hidden { display: none; }
.cp-county-multi-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; color: #64748b; margin-bottom: 8px;
}
.cp-county-multi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 4px 10px;
  max-height: 200px; overflow-y: auto;
}
.cp-county-multi-grid label {
  font-size: 13px;
  display: flex; align-items: center; gap: 6px;
  cursor: pointer; user-select: none;
}
.cp-county-multi-grid label .cnt {
  color: #94a3b8; font-size: 11px;
  font-variant-numeric: tabular-nums;
  margin-left: auto;
}
.btn.xs { padding: 2px 8px; font-size: 11px; }

/* Include-already-sent toggle */
.cp-include-sent-row {
  margin-top: 10px; gap: 10px;
  display: flex; flex-direction: column; align-items: flex-start;
}
.cp-include-sent-label {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; cursor: pointer; user-select: none;
}
.cp-include-sent-hint {
  font-size: 11px; padding-left: 22px;
}

/* Push progress bar */
.cp-progress {
  margin-top: 14px;
  padding: 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}
.cp-progress.hidden { display: none; }
.cp-progress-head {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 13px; font-weight: 500; margin-bottom: 6px;
}
.cp-progress-head #cp-progress-percent {
  font-variant-numeric: tabular-nums;
  color: #1e40af;
  font-weight: 600;
}
.cp-progress-track {
  height: 8px; background: #e2e8f0; border-radius: 999px; overflow: hidden;
}
.cp-progress-fill {
  height: 100%; background: linear-gradient(90deg, #3b82f6, #2563eb);
  transition: width 0.3s ease;
  border-radius: 999px;
}
.cp-progress.error .cp-progress-fill {
  background: linear-gradient(90deg, #f87171, #dc2626);
}
.cp-progress.done .cp-progress-fill {
  background: linear-gradient(90deg, #34d399, #059669);
}
.cp-progress-sub {
  font-size: 11px; margin-top: 6px;
  font-variant-numeric: tabular-nums;
}

/* Settings drawer/modal */
.cp-settings-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
}
.cp-settings-overlay.hidden { display: none; }
.cp-settings-panel {
  background: white; border-radius: 8px;
  width: 480px; max-width: 92vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  display: flex; flex-direction: column;
}
.cp-settings-head, .cp-settings-foot {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px;
}
.cp-settings-head { border-bottom: 1px solid var(--border, #e5e7eb); }
.cp-settings-head h3 { margin: 0; font-size: 15px; }
.cp-settings-foot {
  gap: 8px; justify-content: flex-end;
  border-top: 1px solid var(--border, #e5e7eb);
}
.cp-settings-body { padding: 14px 16px; }

/* ----- AI Assistant page ----- */
.assistant-wrap {
  display: flex; flex-direction: column;
  height: calc(100vh - 160px); min-height: 420px;
  padding: 0; overflow: hidden;
}
.assistant-log {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
}
.chat-msg { display: flex; }
.chat-msg.user { justify-content: flex-end; }
.chat-msg.bot { justify-content: flex-start; }
.chat-bubble {
  max-width: 80%; padding: 10px 13px; border-radius: 12px;
  font-size: 14px; line-height: 1.5; white-space: normal;
}
.chat-msg.user .chat-bubble {
  background: var(--accent); color: #fff; border-bottom-right-radius: 3px;
}
.chat-msg.bot .chat-bubble {
  background: var(--bg); border: 1px solid var(--border);
  color: var(--text); border-bottom-left-radius: 3px;
}
.assistant-error { color: var(--red); }
.chat-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  border: 1px solid var(--border); background: #fff; color: var(--text);
  border-radius: 999px; padding: 4px 10px; font-size: 12px; cursor: pointer;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.assistant-details { margin-top: 8px; font-size: 12px; }
.assistant-details summary { cursor: pointer; color: var(--muted); }
.assistant-details pre {
  margin: 6px 0 0; padding: 8px; background: #0f1115; color: #d6d8dc;
  border-radius: 6px; overflow-x: auto; font-size: 12px; white-space: pre-wrap;
}
.assistant-rows { margin-top: 6px; overflow-x: auto; }
.assistant-rows table { border-collapse: collapse; width: 100%; font-size: 12px; }
.assistant-rows th, .assistant-rows td {
  border: 1px solid var(--border); padding: 4px 6px; text-align: left;
  white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis;
}
.assistant-rows th { background: var(--bg); color: var(--muted); }
.assistant-input {
  display: flex; gap: 8px; padding: 12px 16px;
  border-top: 1px solid var(--border); background: var(--panel);
}
.assistant-input textarea {
  flex: 1; resize: none; border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; font-family: inherit; font-size: 14px; color: var(--text);
}
.assistant-input .btn { align-self: stretch; }

/* ----- Login page ----- */
.login-body {
  display: grid; place-items: center; min-height: 100vh;
  background: var(--side); margin: 0;
}
.login-card {
  width: 340px; max-width: 92vw; background: var(--panel);
  border-radius: 14px; padding: 28px 26px; box-shadow: var(--shadow);
}
.login-brand { display: flex; align-items: center; gap: 8px; margin-bottom: 18px; }
.login-brand .brand-dot {
  width: 10px; height: 10px; border-radius: 50%; background: var(--accent); display: inline-block;
}
.login-brand .brand-name { font-weight: 700; font-size: 15px; color: var(--text); }
.login-title { margin: 0 0 16px; font-size: 20px; }
.login-form { display: flex; flex-direction: column; gap: 6px; }
.login-form label { font-size: 11px; letter-spacing: .08em; color: var(--muted); text-transform: uppercase; margin-top: 8px; }
.login-form input {
  border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px;
  font-size: 14px; font-family: inherit; color: var(--text);
}
.login-btn { margin-top: 18px; width: 100%; justify-content: center; padding: 10px; }
.login-error {
  background: #fee2e2; color: #991b1b; border-radius: 8px;
  padding: 8px 11px; font-size: 13px; margin-bottom: 12px;
}

/* ----- Sidebar logout + role footer ----- */
.sidebar-actions {
  display: flex; align-items: center; justify-content: space-between; margin-top: 10px;
}
.logout-link { color: var(--side-muted); font-size: 11px; text-decoration: none; }
.logout-link:hover { color: var(--side-text); text-decoration: underline; }
.sidebar-actions .app-version { margin-top: 0; }

/* ----- Admin / Users page ----- */
.role-badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; background: var(--bg); border: 1px solid var(--border); color: var(--muted);
}
.role-badge.admin { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.user-county-grid, #user-county-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 10px;
  max-height: 260px; overflow-y: auto; margin-top: 6px;
}
.county-chip { font-size: 13px; display: flex; align-items: center; gap: 6px; }
