/* Agent Connect — styles. Palette echoes the 3D Casas family (navy/orange);
   adjust freely when Agent Connect gets its own brand. */

:root {
  --navy: #0b2f5b;
  --navy-700: #0a274b;
  --orange: #ff7f27;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e2e6ec;
  --text: #1c2733;
  --muted: #687587;
  --success: #2e9e5b;
  --error: #d8453b;
  --warning: #e08a00;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 36, 64, 0.08), 0 6px 18px rgba(16, 36, 64, 0.06);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
.hidden { display: none !important; }

button, input, select { font: inherit; }

/* ---- buttons ---- */
.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 16px;
  cursor: pointer;
  font-weight: 600;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--navy-700); }
.btn-ghost { background: #fff; border-color: var(--border); color: var(--text); }
.btn-ghost:hover:not(:disabled) { border-color: var(--navy); color: var(--navy); }
.btn-block { width: 100%; margin-top: 8px; }

/* ---- brand ---- */
.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { margin: 0; font-size: 1.5rem; color: var(--navy); }
.brand-mark {
  display: inline-grid; place-items: center;
  width: 38px; height: 38px; border-radius: 9px;
  background: var(--navy); color: #fff; font-weight: 800; letter-spacing: .5px;
}
.brand-mark::after { content: ""; }
.brand-sm .brand-mark { width: 30px; height: 30px; font-size: .85rem; }

/* ---- login ---- */
.login-view { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  background: var(--surface); width: 360px; max-width: 100%;
  padding: 32px; border-radius: var(--radius); box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 14px;
}
.login-card .subtitle { margin: -6px 0 6px; color: var(--muted); }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: .85rem; color: var(--muted); }
.login-card input {
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; color: var(--text);
}
.login-card input:focus { outline: 2px solid var(--navy); border-color: var(--navy); }
.login-error { color: var(--error); font-size: .85rem; min-height: 1em; }

/* ---- topbar ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.topbar-right { display: flex; align-items: center; gap: 14px; }
.user-email { color: var(--muted); font-size: .9rem; }

/* ---- layout ---- */
.layout { display: grid; grid-template-columns: 280px 1fr; gap: 20px; padding: 20px; align-items: start; }
.sidebar {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; position: sticky; top: 72px; display: flex; flex-direction: column; gap: 14px;
}
.sidebar h2 { margin: 0 0 4px; font-size: 1.05rem; }
.sidebar label { display: flex; flex-direction: column; gap: 5px; font-size: .8rem; color: var(--muted); }
.sidebar input, .sidebar select {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 7px; color: var(--text); background: #fff;
}
.sidebar input:focus, .sidebar select:focus { outline: 2px solid var(--navy); border-color: var(--navy); }

.content { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

/* ---- stats ---- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.stats.loading { opacity: .55; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; display: flex; flex-direction: column; gap: 4px;
}
.stat-num { font-size: 1.8rem; font-weight: 800; color: var(--navy); }
.stat-label { font-size: .78rem; color: var(--muted); }
.stat-note { margin: 0; color: var(--muted); font-size: .82rem; }

/* ---- actions ---- */
.actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---- yamm import ---- */
.yamm-import {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px;
}
.yamm-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.yamm-head select { padding: 7px 10px; border: 1px solid var(--border); border-radius: 7px; }
.file-pick { display: inline-block; }
.dropzone {
  border: 2px dashed var(--border); border-radius: 8px; padding: 22px; text-align: center;
  color: var(--muted); transition: border-color .15s, background .15s;
}
.dropzone.dragover { border-color: var(--orange); background: #fff6ef; color: var(--text); }

/* ---- table ---- */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
table.preview { width: 100%; border-collapse: collapse; font-size: .86rem; }
table.preview th, table.preview td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.preview th { background: #f0f3f7; color: var(--muted); font-weight: 600; position: sticky; top: 0; }
table.preview td { max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
table.preview tr:hover td { background: #f8fafc; }
td.empty { text-align: center; color: var(--muted); padding: 28px; }
.table-foot { margin: 0; padding: 10px 12px; color: var(--muted); font-size: .78rem; background: #fafbfc; }

/* ---- toasts ---- */
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 1000; }
.toast {
  background: var(--navy); color: #fff; padding: 11px 16px; border-radius: 8px; box-shadow: var(--shadow);
  opacity: 0; transform: translateY(8px); transition: opacity .25s, transform .25s; max-width: 360px; font-size: .88rem;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { background: var(--success); }
.toast-error { background: var(--error); }
.toast-warning { background: var(--warning); }

/* ---- verify free-only toggle ---- */
.verify-free { display: inline-flex; align-items: center; gap: 5px; font-size: .8rem; color: var(--muted); }
.verify-free input { margin: 0; }

/* ---- review action inbox ---- */
.review-actions { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.review-list { display: flex; flex-direction: column; gap: 12px; max-width: 760px; }
.review-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.review-type {
  display: inline-block; font-size: .7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .4px; padding: 2px 8px; border-radius: 6px; margin-bottom: 8px;
}
.review-new { background: #e6f4ea; color: var(--success); }
.review-left { background: #fdecea; color: var(--error); }
.review-line { font-size: .9rem; margin-bottom: 4px; }
.review-source { font-size: .78rem; margin-top: 6px; }
.review-buttons { display: flex; gap: 10px; margin-top: 12px; }

/* ---- edit record modal ---- */
table.preview tr.row-edit { cursor: pointer; }
.modal-overlay {
  position: fixed; inset: 0; background: rgba(11, 24, 41, 0.45);
  display: grid; place-items: center; z-index: 1000; padding: 20px;
}
.modal-card {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  width: 560px; max-width: 100%; max-height: 90vh; overflow: auto; padding: 22px 24px;
}
.modal-card h3 { margin: 0 0 4px; }
.modal-sub { margin: 0 0 16px; color: var(--muted); font-size: .85rem; }
.edit-email { background: #f7f9fc; border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; margin-bottom: 16px; }
.edit-email-current { font-size: .82rem; color: var(--muted); margin-bottom: 8px; }
.edit-email label { display: flex; flex-direction: column; gap: 5px; font-size: .8rem; color: var(--muted); }
.edit-email-row { display: flex; gap: 8px; }
.edit-email-row input { flex: 1; padding: 9px 11px; border: 1px solid var(--border); border-radius: 7px; color: var(--text); }
.edit-check-result { margin-top: 8px; font-size: .85rem; color: var(--text); min-height: 1em; }
.edit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.edit-grid label, .edit-wide { display: flex; flex-direction: column; gap: 5px; font-size: .8rem; color: var(--muted); }
.edit-grid .edit-wide { grid-column: 1 / -1; }
.edit-grid input { padding: 8px 10px; border: 1px solid var(--border); border-radius: 7px; color: var(--text); }
.modal-note { font-size: .78rem; color: var(--muted); margin: 14px 0; line-height: 1.5; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
.muted { color: var(--muted); }

/* ---- status tags ---- */
.tag {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: .72rem; font-weight: 700; white-space: nowrap;
}
.tag-cust { background: #e6f4ea; color: var(--success); }
.tag-cold { background: #e6f0f7; color: #1b5e8c; }
.tag-bounced { background: #fdecea; color: var(--error); }
.tag-unsub { background: #fff3e0; color: var(--warning); }

/* ---- top nav ---- */
.topnav { display: flex; gap: 6px; margin-left: 22px; }
.navlink {
  background: transparent; border: none; color: var(--muted); cursor: pointer;
  padding: 8px 12px; border-radius: 7px; font-weight: 600; display: inline-flex; align-items: center; gap: 7px;
}
.navlink:hover { color: var(--navy); background: #f0f3f7; }
.navlink.active { color: var(--navy); background: #eaf0f7; }
.badge {
  background: var(--orange); color: #fff; border-radius: 10px; padding: 1px 8px;
  font-size: .72rem; font-weight: 700; min-width: 20px; text-align: center;
}

/* ---- NAR recheck view ---- */
.nar-view { padding: 24px; max-width: 760px; margin: 0 auto; }
.nar-view h2 { margin: 0 0 6px; }
.nar-intro { color: var(--muted); margin: 0 0 18px; font-size: .9rem; line-height: 1.5; }
.nar-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.nar-controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-bottom: 16px; }
.nar-controls label { display: flex; flex-direction: column; gap: 5px; font-size: .78rem; color: var(--muted); }
.nar-controls input {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 7px; width: 110px; color: var(--text);
}
.nar-progress-wrap { background: #e9edf2; border-radius: 6px; height: 10px; overflow: hidden; margin-bottom: 10px; }
.nar-progress { background: var(--navy); height: 100%; width: 0; transition: width .2s; }
.nar-status-line { color: var(--text); font-size: .9rem; margin-bottom: 12px; }
.nar-log {
  background: #0e1726; color: #cfe0f5; border-radius: 8px; padding: 14px; font-size: .8rem;
  line-height: 1.5; max-height: 320px; overflow: auto; white-space: pre-wrap; margin: 0;
}
.nar-log .ok   { color: #22c55e; }
.nar-log .no   { color: #ef4444; }
.nar-log .warn { color: #f59e0b; }

/* ---- New Agents (imports) report ---- */
.imports-table-wrap { overflow: auto; max-height: 70vh; margin-top: 12px; }
.imports-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.imports-table th, .imports-table td { text-align: left; padding: 6px 10px; border-bottom: 1px solid #e5e7eb; white-space: nowrap; }
.imports-table th { position: sticky; top: 0; background: var(--light-gray, #f5f5f5); z-index: 1; }
.imports-table tbody tr:hover { background: #fafafa; }
.imports-table .ok   { color: #16a34a; font-weight: 600; }
.imports-table .no   { color: #dc2626; font-weight: 600; }
.imports-table .warn { color: #d97706; }

/* ---- portal customer sync ---- */
.portal-form { display: flex; flex-direction: column; gap: 12px; max-width: 360px; }
.portal-form label { display: flex; flex-direction: column; gap: 5px; font-size: .8rem; color: var(--muted); }
.portal-form input { padding: 9px 11px; border: 1px solid var(--border); border-radius: 7px; color: var(--text); }
.portal-status {
  display: inline-block; padding: 7px 12px; border-radius: 7px; font-size: .82rem;
  background: #f0f3f7; color: var(--muted); border: 1px solid var(--border); margin-bottom: 4px;
}
.portal-status.connected { background: #e6f4ea; color: var(--success); border-color: #cce8d5; }

/* ---- responsive ---- */
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .stats { grid-template-columns: 1fr; }
}

/* ===================== Emailer (Phase 5) ===================== */
.emailer-tabs { display: flex; gap: 6px; margin: 0 0 16px; border-bottom: 1px solid var(--border); }
.emailer-grid { display: grid; grid-template-columns: 1fr 1.3fr; gap: 20px; align-items: start; }
@media (max-width: 900px) { .emailer-grid { grid-template-columns: 1fr; } }

.tpl-list, .camp-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.tpl-item {
  text-align: left; display: flex; flex-direction: column; gap: 2px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 12px; font: inherit; color: var(--text);
}
.tpl-item:hover { border-color: var(--navy); }
.tpl-item .muted { font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tpl-form { display: flex; flex-direction: column; gap: 10px; }
.tpl-form label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--muted); }
.tpl-form input, .tpl-form select, .tpl-form textarea {
  font: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; color: var(--text);
}
.tpl-form textarea { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .82rem; resize: vertical; }

.tpl-preview { margin-top: 16px; }
.tpl-preview-subject { font-size: .85rem; margin: 6px 0; color: var(--text); font-weight: 600; }
.tpl-preview-frame { width: 100%; height: 280px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }

.camp-filters { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 6px 0; }
.camp-preview-result { margin-top: 10px; font-size: .9rem; }
.camp-preview-ok strong { font-size: 1.4rem; color: var(--navy); }
.camp-dropped { font-size: .8rem; color: var(--muted); margin-top: 4px; }

.camp-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.camp-item-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.camp-item-meta { font-size: .78rem; margin: 4px 0; }
.camp-counts { font-size: .8rem; color: var(--text); margin: 6px 0; }
.camp-item-actions { display: flex; gap: 8px; margin-top: 8px; }
.camp-status { font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; text-transform: uppercase; letter-spacing: .03em; }
.camp-status-draft { background: #eef1f5; color: var(--muted); }
.camp-status-building, .camp-status-ready { background: #fff2e0; color: var(--warning); }
.camp-status-sending { background: #e6f4ec; color: var(--success); }
.camp-status-paused { background: #fdeceb; color: var(--error); }
.camp-status-done { background: #e6f4ec; color: var(--success); }
.camp-status-cancelled { background: #eef1f5; color: var(--muted); }

/* ZeroBounce credits + background-verify controls */
.bulk-verify { align-items: center; gap: 10px; margin-top: 8px; }
.zb-credits { font-size: .82rem; font-weight: 600; color: var(--navy); background: #eaf0f7; border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px; }
#verifyDrainStatus { font-size: .82rem; }

/* ---- Coverage map (dashboard heads-up) ---------------------------------- */
.coverage {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 18px;
  margin-bottom: 18px;
}
.coverage > summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--navy);
  list-style: none;
}
.coverage > summary::-webkit-details-marker { display: none; }
.coverage > summary::before { content: "▸ "; color: var(--muted); }
.coverage[open] > summary::before { content: "▾ "; }
.cov-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 10px 2px 4px;
  gap: 12px;
}
.cov-crumb { font-size: .95rem; }
.cov-crumb a { color: var(--navy); text-decoration: none; }
.cov-crumb a:hover { text-decoration: underline; }
.cov-headline { font-size: .85rem; color: var(--muted); white-space: nowrap; }
.cov-todo { color: var(--warning); }
.cov-svg { width: 100%; height: auto; display: block; }

.cov-state { fill: #eef1f5; stroke: #fff; stroke-width: 1; }
.cov-state.covered { fill: rgba(11, 47, 91, 0.14); cursor: pointer; }
.cov-state.covered:hover { fill: rgba(11, 47, 91, 0.28); }

.cov-bubble {
  fill: rgba(255, 127, 39, 0.55);
  stroke: var(--orange);
  stroke-width: 1.25;
}
.cov-bubble.clickable { cursor: pointer; }
.cov-bubble.clickable:hover { fill: rgba(255, 127, 39, 0.8); }
.cov-bubble.dim { fill: rgba(104, 117, 135, 0.28); stroke: var(--muted); }
.cov-label {
  fill: #3a2410;
  font-size: 11px;
  text-anchor: middle;
  pointer-events: none;
  font-weight: 600;
}
.cov-tip {
  position: fixed;
  display: none;
  z-index: 50;
  background: var(--navy);
  color: #fff;
  padding: 6px 9px;
  border-radius: 6px;
  font-size: .8rem;
  line-height: 1.25;
  pointer-events: none;
  box-shadow: var(--shadow);
}

/* ---- Coverage map: state/county geographic drill ------------------------ */
.cov-county { fill: #eef1f5; stroke: #fff; stroke-width: 0.5; }
.cov-county.covered { fill: rgba(11, 47, 91, 0.12); cursor: pointer; }
.cov-county.covered:hover { fill: rgba(11, 47, 91, 0.26); }
.cov-state-outline { fill: none; stroke: var(--navy); stroke-width: 1.4; pointer-events: none; }
.cov-empty { fill: var(--muted); font-size: 14px; text-anchor: middle; }

/* ---- Coverage map: City/County toggle ----------------------------------- */
.cov-toggle { display: flex; gap: 0; margin: 0 2px 8px; }
.cov-toggle button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  padding: 4px 14px;
  font-size: .82rem;
  cursor: pointer;
}
.cov-toggle button:first-child { border-radius: 6px 0 0 6px; }
.cov-toggle button:last-child { border-radius: 0 6px 6px 0; border-left: 0; }
.cov-toggle button.on { background: var(--navy); color: #fff; border-color: var(--navy); }

/* ── Multi-account send console ─────────────────────────────────────────── */
.sender-list { display: flex; flex-direction: column; gap: 12px; }
.sender-item { border: 1px solid #e4e7eb; border-radius: 10px; padding: 12px 14px; background: #fff; }
.sender-cap { padding: 2px 6px; border: 1px solid #cbd2d9; border-radius: 6px; }
.camp-progress { height: 6px; background: #eceff1; border-radius: 4px; overflow: hidden; margin: 8px 0; }
.camp-progress-bar { height: 100%; background: #3b82f6; transition: width .4s ease; }
.camp-byaccount { font-size: 12px; margin: 2px 0 6px; }

/* ── Multi-select dropdown (county picker) ──────────────────────────────── */
.msel { position: relative; }
.msel-btn { width: 100%; text-align: left; padding: 8px 10px; border: 1px solid #cbd2d9;
  border-radius: 8px; background: #fff; cursor: pointer; font-size: 14px; color: #1f2933; }
.msel-btn:hover { border-color: #9aa5b1; }
.msel-pop { position: absolute; z-index: 60; top: calc(100% + 4px); left: 0; right: 0;
  background: #fff; border: 1px solid #cbd2d9; border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0,0,0,.14); padding: 8px; max-height: 280px;
  display: flex; flex-direction: column; }
.msel-search { width: 100%; padding: 6px 8px; border: 1px solid #cbd2d9; border-radius: 6px;
  margin-bottom: 6px; box-sizing: border-box; font-size: 14px; }
.msel-tools { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.msel-list { overflow-y: auto; display: flex; flex-direction: column; gap: 1px; }
.msel-list label { display: flex; align-items: center; gap: 7px; padding: 4px 5px; font-size: 14px;
  cursor: pointer; font-weight: normal; margin: 0; }
.msel-list label:hover { background: #f1f5f9; border-radius: 4px; }
.msel-list input[type="checkbox"] { width: auto; margin: 0; }
.linklike { background: none; border: none; color: #3b82f6; cursor: pointer; font-size: 12px; padding: 0; }
