/* Live Lead Pro web app — dark dashboard theme.
   Custom props below are contractual; utility classes (.card .btn .badge …) are the
   shared vocabulary every view (builders C + D) uses. */

:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel2: #1d2129;
  --border: #2a2f3a;
  --text: #e6e9ef;
  --muted: #8b93a3;
  --accent: #4f8cff;
  --green: #34c98e;
  --red: #ff5d5d;
  --yellow: #ffc24b;

  --radius: 10px;
  --sidebar-w: 232px;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial,
    sans-serif;
}

/* ---------- reset / base ---------- */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { height: 100%; }
body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 8px; font-weight: 600; line-height: 1.25; }
h1 { font-size: 18px; }
h2 { font-size: 15px; }
h3 { font-size: 13px; }
p { margin: 0 0 10px; }
button { font-family: inherit; }
svg { display: block; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2c323e; border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #3a4150; }

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.boot-splash { min-height: 100vh; display: flex; align-items: center; justify-content: center; }

/* ---------- core utilities (contract) ---------- */

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.muted { color: var(--muted); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s;
}
.btn:hover { background: #232936; border-color: #353c4a; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #3e7df2; border-color: #3e7df2; }
.btn-danger { background: rgba(255, 93, 93, 0.12); border-color: rgba(255, 93, 93, 0.4); color: var(--red); }
.btn-danger:hover { background: rgba(255, 93, 93, 0.22); border-color: var(--red); }
.btn-success { background: rgba(52, 201, 142, 0.14); border-color: rgba(52, 201, 142, 0.45); color: var(--green); }
.btn-success:hover { background: rgba(52, 201, 142, 0.25); border-color: var(--green); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--panel2); color: var(--text); border-color: transparent; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.btn-block { width: 100%; }

.input, .select, textarea.input {
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  line-height: 1.4;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input::placeholder { color: #5d6575; }
.input:focus-visible, .select:focus-visible, textarea.input:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.2);
}
.select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238b93a3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
}
input[type='date'].input { color-scheme: dark; }
textarea.input { resize: vertical; min-height: 72px; }

label.field { display: block; font-size: 12px; color: var(--muted); margin-bottom: 10px; }
label.field > .input, label.field > .select { margin-top: 4px; }

/* tables */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover, .table tbody tr.clickable:focus-visible { background: rgba(79, 140, 255, 0.06); }
.table .num { text-align: right; }

/* badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.6;
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--muted);
  white-space: nowrap;
}
.badge-green { background: rgba(52, 201, 142, 0.13); border-color: rgba(52, 201, 142, 0.4); color: var(--green); }
.badge-red { background: rgba(255, 93, 93, 0.12); border-color: rgba(255, 93, 93, 0.38); color: var(--red); }
.badge-yellow { background: rgba(255, 194, 75, 0.12); border-color: rgba(255, 194, 75, 0.38); color: var(--yellow); }
.badge-blue { background: rgba(79, 140, 255, 0.13); border-color: rgba(79, 140, 255, 0.4); color: var(--accent); }
.badge-violet { background: rgba(167, 119, 255, 0.14); border-color: rgba(167, 119, 255, 0.42); color: #b79bff; }
.badge-amber { background: rgba(255, 159, 67, 0.14); border-color: rgba(255, 159, 67, 0.45); color: #ffab5e; }
.intent-badge { margin-left: 7px; font-size: 10.5px; padding: 1px 7px; vertical-align: middle; }
.review-badge { margin-left: 7px; font-size: 10.5px; padding: 1px 7px; vertical-align: middle; }

/* chips (quick filters) */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.chip:hover { color: var(--text); border-color: #3a4150; }
.chip-on { background: rgba(79, 140, 255, 0.15); border-color: var(--accent); color: var(--accent); }
/* "Needs review" chip: amber when active, so the verification filter reads as a caution, not a normal toggle. */
.chip-warn.chip-on { background: rgba(255, 159, 67, 0.16); border-color: #ff9f43; color: #ffab5e; }

/* tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 14px; overflow-x: auto; }
.tab {
  padding: 8px 14px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.tab-on, .tab[aria-selected='true'] { color: var(--accent); border-bottom-color: var(--accent); }

/* empty state + spinner */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 48px 20px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}
.empty .empty-icon { opacity: 0.5; }

.spinner {
  width: 22px;
  height: 22px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.spinner-wrap { display: flex; align-items: center; justify-content: center; padding: 40px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* stats */
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; min-width: 0; }
.stat-num { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
.stat-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); margin-top: 4px; }
.stat-sub { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* toolbar + pagination */
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; min-width: 0; }

.pagination { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 14px; }
.pagination .spacer { flex: 1; }
.page-btn { min-width: 32px; padding: 5px 8px; }
.page-on { background: var(--accent); border-color: var(--accent); color: #fff; }
.page-gap { color: var(--muted); padding: 0 2px; }

/* ---------- toasts ---------- */

.toasts {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(360px, calc(100vw - 32px));
}
.toast {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  box-shadow: var(--shadow);
  animation: toast-in 0.22s ease;
  word-break: break-word;
}
.toast-ok { border-left-color: var(--green); }
.toast-error { border-left-color: var(--red); }
.toast-warn { border-left-color: var(--yellow); }
.toast.toast-out { opacity: 0; transform: translateY(6px); transition: all 0.25s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- modal ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(8, 10, 14, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fade-in 0.15s ease;
}
.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: min(440px, 100%);
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  animation: pop-in 0.18s ease;
}
.modal-wide { width: min(580px, 100%); }
.modal-head { display: flex; align-items: center; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; flex: 1; font-size: 15px; }
.modal-body { padding: 16px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); }
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.icon-btn:hover { background: var(--panel2); color: var(--text); }
@keyframes fade-in { from { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: scale(0.96) translateY(6px); } }

/* ---------- drawer ---------- */

.drawer-backdrop { position: fixed; inset: 0; z-index: 55; background: rgba(8, 10, 14, 0.55); animation: fade-in 0.15s ease; }
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  width: min(480px, 100vw);
  background: var(--panel);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.22s ease;
  box-shadow: var(--shadow);
}
.drawer.open { transform: translateX(0); }
.drawer-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.drawer-head h2 { margin: 0; flex: 1; font-size: 15px; min-width: 120px; }
.drawer-nav-group { display: inline-flex; align-items: center; gap: 2px; }
.drawer-nav-pos { font-size: 11px; min-width: 44px; text-align: center; font-variant-numeric: tabular-nums; }
.icon-btn.drawer-nav:disabled { opacity: 0.35; cursor: default; }
.icon-btn.drawer-nav:disabled:hover { background: transparent; color: var(--muted); }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px; }
.drawer-section { margin-bottom: 18px; }
.drawer-section > h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin-bottom: 8px;
}
/* multi-intent / occurrences in the lead drawer */
.intent-banner { display: flex; align-items: center; gap: 8px; padding: 8px 10px; margin-bottom: 8px; border-radius: 8px; background: rgba(167, 119, 255, 0.10); border: 1px solid rgba(167, 119, 255, 0.30); flex-wrap: wrap; }
.intent-banner .muted { font-size: 12px; }
/* Secondary-verification banner at the top of the lead drawer (amber, matches the "Needs review" chip). */
.review-banner { display: flex; align-items: flex-start; gap: 9px; padding: 10px 12px; margin-bottom: 12px; border-radius: 9px; background: rgba(255, 159, 67, 0.09); border: 1px solid rgba(255, 159, 67, 0.32); flex-wrap: wrap; }
.review-banner-text { font-size: 12.5px; color: var(--text); line-height: 1.5; }
.review-banner-text em { color: var(--muted); font-style: normal; }
.review-suggest { color: #ffab5e; }
.occ-list { display: flex; flex-direction: column; gap: 4px; }
.occ-item { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.occ-head { display: flex; align-items: center; gap: 8px; padding: 7px 10px; font-size: 12.5px; }
.occ-head.occ-expandable { cursor: pointer; }
.occ-head.occ-expandable:hover { background: var(--panel2); }
.occ-cat { font-weight: 600; }
.occ-date { margin-left: auto; font-size: 11px; }
.occ-toggle { font-size: 11px; }
.occ-details { margin: 0; padding: 8px 10px 10px; border-top: 1px solid var(--border); background: var(--panel2); }
/* One-line verdict above the occurrence list: "Seen ×24 · 6 categories · 1 real · 1 callable · best: Roofing". */
.occ-verdict { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.occ-verdict .muted { font-size: 12px; }
/* The pinned best occurrence — a green-tinted, accented card so the most actionable submission stands out. */
.occ-item.occ-best { border-color: rgba(52, 201, 142, 0.5); box-shadow: 0 0 0 1px rgba(52, 201, 142, 0.25) inset; }
.occ-item.occ-best .occ-head { background: rgba(52, 201, 142, 0.07); }

.drawer-actions { border-top: 1px solid var(--border); padding: 14px 16px; }
.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.action-grid .btn { padding: 11px 10px; font-size: 13px; }

/* key/value detail rows */
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 5px 12px; font-size: 13px; }
.kv dt { color: var(--muted); margin: 0; overflow-wrap: anywhere; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* timeline */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline li { position: relative; padding: 0 0 14px 18px; }
.timeline li::before {
  content: '';
  position: absolute;
  left: 3px;
  top: 6px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
}
.timeline li::after {
  content: '';
  position: absolute;
  left: 6px;
  top: 16px;
  bottom: -2px;
  width: 1px;
  background: var(--border);
}
.timeline li:last-child::after { display: none; }
.timeline li.tl-green::before { background: var(--green); }
.timeline li.tl-red::before { background: var(--red); }
.timeline li.tl-yellow::before { background: var(--yellow); }
.timeline li.tl-blue::before { background: var(--accent); }
.timeline .tl-note { background: var(--panel2); border: 1px solid var(--border); border-radius: 7px; padding: 6px 9px; margin-top: 5px; font-size: 12.5px; white-space: pre-wrap; overflow-wrap: anywhere; }

/* copy button (phones) */
.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  padding: 2px 4px;
  margin: -2px -4px;
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  white-space: nowrap;
}
.copy-btn:hover { color: var(--accent); background: rgba(79, 140, 255, 0.08); }
.copy-btn svg { color: var(--muted); }
.copy-btn:hover svg { color: var(--accent); }

/* ---------- multiselect dropdown ---------- */

.dd { position: relative; }
.dd-trigger .dd-count {
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  min-width: 17px;
  height: 17px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}
.dd-trigger.dd-active { border-color: rgba(79, 140, 255, 0.55); }
.dd-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 50;
  width: min(250px, calc(100vw - 28px));
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  animation: pop-in 0.14s ease;
}
.dd-panel.dd-right { left: auto; right: 0; }
.dd-search-wrap { padding: 8px; border-bottom: 1px solid var(--border); }
.dd-list { max-height: 250px; overflow-y: auto; padding: 5px; }
.dd-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  overflow-wrap: anywhere;
}
.dd-item:hover { background: rgba(79, 140, 255, 0.08); }
.dd-item input[type='checkbox'] { accent-color: var(--accent); width: 14px; height: 14px; flex: none; cursor: pointer; }
.dd-item-grouped { padding-left: 18px; }
.dd-empty { padding: 12px; text-align: center; font-size: 12px; }
/* grouped multiselect (e.g. State → USA / Canada / …) */
.dd-group-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 8px; margin-top: 4px; border-radius: 6px; cursor: pointer;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted); background: var(--panel2); position: sticky; top: 0;
}
.dd-group-head:first-child { margin-top: 0; }
.dd-group-head:hover { color: var(--text); }
.dd-group-on { color: var(--accent); }
.dd-group-toggle { font-size: 10.5px; font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--accent); }
.dd-foot { padding: 6px 8px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; }

/* ---------- app shell ---------- */

.shell { min-height: 100vh; }

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 40;
  width: var(--sidebar-w);
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: transform 0.22s ease;
}
.sidebar-backdrop { position: fixed; inset: 0; z-index: 35; background: rgba(8, 10, 14, 0.55); }

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 18px 16px 14px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #7b5cff);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex: none;
}

.nav { flex: 1; overflow-y: auto; padding: 6px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 8px;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  width: 100%;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.13s, color 0.13s;
}
.nav-item:hover { background: var(--panel2); color: var(--text); text-decoration: none; }
.nav-item.nav-on { background: rgba(79, 140, 255, 0.13); color: var(--accent); }
.nav-item svg { flex: none; }
.sidebar-foot { padding: 10px; border-top: 1px solid var(--border); }
.sidebar-foot .nav-item:hover { color: var(--red); background: rgba(255, 93, 93, 0.08); }

.main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  background: rgba(15, 17, 21, 0.86);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  min-height: 54px;
}
.topbar-title { font-size: 16px; font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin: 0; }
.hamburger { display: none; }

.live-dot { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.live-dot i { width: 8px; height: 8px; border-radius: 50%; background: var(--red); flex: none; transition: background 0.2s; }
.live-dot.on i { background: var(--green); box-shadow: 0 0 0 0 rgba(52, 201, 142, 0.5); animation: pulse 2.2s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(52, 201, 142, 0.45); }
  70% { box-shadow: 0 0 0 6px rgba(52, 201, 142, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 201, 142, 0); }
}

.user-menu { position: relative; }
.user-btn { display: inline-flex; align-items: center; gap: 8px; max-width: 190px; }
.user-btn .avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(79, 140, 255, 0.2);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.user-btn .user-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 50;
  min-width: 190px;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 5px;
  animation: pop-in 0.14s ease;
}
.menu .menu-label { padding: 7px 10px 5px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.menu .menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: 7px;
  background: none;
  color: var(--text);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.menu .menu-item:hover { background: rgba(79, 140, 255, 0.1); }
.menu .menu-item.menu-danger:hover { background: rgba(255, 93, 93, 0.1); color: var(--red); }

.content { flex: 1; padding: 18px; max-width: 1320px; width: 100%; margin: 0 auto; min-width: 0; }

/* ---------- login ---------- */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    radial-gradient(700px 380px at 80% -10%, rgba(79, 140, 255, 0.13), transparent 65%),
    radial-gradient(600px 320px at 10% 110%, rgba(123, 92, 255, 0.1), transparent 65%),
    var(--bg);
}
.login-card { width: min(380px, 100%); padding: 28px; }
.login-brand { display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.login-sub { text-align: center; margin-bottom: 20px; }
.login-error {
  background: rgba(255, 93, 93, 0.1);
  border: 1px solid rgba(255, 93, 93, 0.4);
  color: var(--red);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12.5px;
  margin-bottom: 12px;
}

/* ---------- dashboard ---------- */

.stats-grid { margin-bottom: 14px; }

.announce-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: rgba(255, 194, 75, 0.08);
  border: 1px solid rgba(255, 194, 75, 0.35);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 14px;
  animation: pop-in 0.18s ease;
}
.announce-banner svg { color: var(--yellow); flex: none; margin-top: 1px; }
.announce-body { flex: 1; min-width: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.announce-time { font-size: 11.5px; color: var(--muted); margin-top: 3px; }

.feed-card { padding: 0; overflow: hidden; }
.feed-head { display: flex; align-items: center; gap: 10px; padding: 13px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.feed-head h2 { margin: 0; flex: 1; display: inline-flex; align-items: center; gap: 8px; }
.feed-head h2 svg { color: var(--accent); }
.feed-poll { font-size: 12px; }
.feed { max-height: 420px; overflow-y: auto; }
.feed-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  cursor: pointer;
}
.feed-row:last-child { border-bottom: none; }
.feed-row:hover { background: rgba(79, 140, 255, 0.05); }
.feed-id { color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }
.feed-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-meta { color: var(--muted); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-time { color: var(--muted); font-size: 11.5px; flex: none; }
.flash { animation: row-flash 1.4s ease; }
@keyframes row-flash { 0% { background: rgba(79, 140, 255, 0.28); } 100% { background: transparent; } }

/* ---------- leads view ---------- */

.leads-toolbar { margin-bottom: 12px; }
.toolbar-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; width: 100%; }
.toolbar-row + .toolbar-row { margin-top: 10px; }
.search-wrap { position: relative; flex: 1; min-width: 160px; max-width: 280px; }
.search-wrap svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-wrap .input { padding-left: 32px; }
.campaign-wrap { flex: 1; min-width: 130px; max-width: 220px; }
.date-input { width: 140px; }
.status-sel, .agent-sel { width: auto; min-width: 130px; }
.pp-sel { width: auto; }

.table-card { padding: 0; overflow: hidden; }
.table-scroll { overflow-x: auto; }
.table-scroll.loading { opacity: 0.55; pointer-events: none; transition: opacity 0.15s; }
.lead-name { font-weight: 600; }
.lead-subtopic { display: block; font-size: 11px; margin-top: 1px; }
.fields-cov { font-variant-numeric: tabular-nums; font-size: 12.5px; }
.cov-gap { color: var(--red); font-weight: 600; } /* not capturing + high volume → worth enabling */
.cov-low { color: var(--yellow); } /* capturing but most leads have no fields → backfill the old ones */
.cov-ok { color: var(--green); }
.dup-badge { font-variant-numeric: tabular-nums; }

/* deal modal */
.exp-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.exp-row .exp-label { flex: 1.4; }
.exp-row .exp-amount { flex: 1; }
.deal-preview { background: var(--panel2); border: 1px solid var(--border); border-radius: 9px; padding: 12px 14px; margin-top: 12px; }
.deal-preview .dp-row { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; font-size: 13px; }
.deal-preview .dp-row .muted { font-size: 12.5px; }
.deal-preview .dp-total { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 8px; font-weight: 600; }
.dp-neg { color: var(--red); }
.dp-pos { color: var(--green); }

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); box-shadow: none; }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow); }
  .main { margin-left: 0; }
  .hamburger { display: inline-flex; }
  .grid4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .content { padding: 14px; }
}

@media (max-width: 720px) {
  .grid2 { grid-template-columns: 1fr; }
  .drawer { width: 100vw; border-left: none; }
  .live-dot .live-label { display: none; }
  .user-btn .user-name { display: none; }
  .search-wrap, .campaign-wrap { max-width: none; }
  .date-input { width: 124px; }

  /* stacked-cards table pattern */
  .table-cards thead { display: none; }
  .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
  .table-cards tr { border-bottom: 1px solid var(--border); padding: 8px 4px; }
  .table-cards tr:last-child { border-bottom: none; }
  .table-cards td { border: none; padding: 4px 10px; display: flex; align-items: baseline; gap: 10px; text-align: left !important; }
  .table-cards td::before {
    content: attr(data-label);
    flex: none;
    width: 86px;
    font-size: 10.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
  }
  .table-cards td[data-label=''], .table-cards td:not([data-label])::before { display: none; }
}

@media (max-width: 520px) {
  .grid3, .grid4 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .action-grid { grid-template-columns: 1fr; }
  .content { padding: 12px; }
  .modal-foot { flex-wrap: wrap; }
}

/* ====================================================================== */
/* v2 enhancements — global search, alerts, 2FA, system health, polish     */
/* ====================================================================== */

/* ---------- topbar: right cluster, search, sound toggle ---------- */

.topbar-right { gap: 6px; }

/* global search (topbar) */
.gs {
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 1;
  max-width: 420px;
  margin: 0 6px;
  padding: 0 10px;
  height: 36px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--panel2);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.gs > svg { color: var(--muted); flex: none; }
.gs.gs-open, .gs:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.18);
}
.gs-input {
  border: none;
  background: none;
  padding: 0;
  height: 100%;
  flex: 1;
  min-width: 0;
}
.gs-input:focus-visible { outline: none; box-shadow: none; }
.gs-input::-webkit-search-cancel-button { -webkit-appearance: none; }

.gs-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 60;
  max-height: min(440px, calc(100vh - 90px));
  overflow-y: auto;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 11px;
  box-shadow: var(--shadow);
  padding: 6px;
  animation: pop-in 0.14s ease;
}
.gs-loading { display: flex; align-items: center; justify-content: center; padding: 24px; }
.gs-group + .gs-group { margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--border); }
.gs-group-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px 4px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}
.gs-group-head svg { color: var(--muted); }
.gs-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: 7px;
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.gs-item:hover, .gs-item:focus-visible { background: rgba(79, 140, 255, 0.1); outline: none; }
.gs-item-primary { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gs-item-secondary { color: var(--muted); font-size: 12px; margin-left: auto; flex: none; max-width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gs-seeall { justify-content: center; color: var(--accent); font-weight: 600; font-size: 12.5px; margin-top: 4px; border-top: 1px solid var(--border); border-radius: 0 0 7px 7px; }
.gs-empty { padding: 18px; text-align: center; font-size: 12.5px; }

.gs-mobile-btn { display: none; }

/* sound (new-lead alert) toggle */
.sound-btn { color: var(--muted); }
.sound-btn:hover { color: var(--text); }
.sound-btn.sound-on { color: var(--accent); }

/* toast action button (e.g. "View" on a new-lead alert) */
.toast { display: flex; align-items: center; gap: 10px; }
.toast .toast-action { margin-left: auto; flex: none; }

/* ---------- two-factor modal ---------- */

.twofa-secret {
  flex: 1;
  font-family: 'SFMono-Regular', ui-monospace, 'Cascadia Code', Consolas, monospace;
  font-size: 16px;
  letter-spacing: 0.12em;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  word-break: break-all;
}
.twofa-uri {
  font-family: 'SFMono-Regular', ui-monospace, 'Cascadia Code', Consolas, monospace;
  font-size: 11.5px;
  color: var(--muted);
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 11px;
  word-break: break-all;
  user-select: all;
}
.twofa-sep { border: none; border-top: 1px solid var(--border); margin: 18px 0 12px; }
.twofa-disable summary { cursor: pointer; color: var(--muted); font-size: 12.5px; list-style: revert; }
.twofa-disable summary:hover { color: var(--text); }
.twofa-disable[open] summary { color: var(--text); margin-bottom: 4px; }

/* ---------- login 2FA step ---------- */

.login-step { display: block; }
.login-step .btn-block + .btn-block { margin-top: 8px; }

/* ---------- system health card (dashboard) ---------- */

.system-card { margin-bottom: 14px; }
.health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}
.health-metric {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 12px;
}
.health-label { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 5px; }
.health-value { font-size: 14px; font-weight: 600; }
.health-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; display: inline-block; }
.health-dot.health-ok { background: var(--green); box-shadow: 0 0 0 0 rgba(52, 201, 142, 0.5); animation: pulse 2.4s infinite; }
.health-dot.health-bad { background: var(--red); }

/* ---------- polish: skeleton loaders ---------- */

.skel {
  background: linear-gradient(90deg, var(--panel2) 25%, #232936 37%, var(--panel2) 63%);
  background-size: 400% 100%;
  border-radius: 6px;
  animation: skel-shimmer 1.4s ease infinite;
}
.skel-line { height: 12px; margin: 7px 0; }
.skel-row { display: flex; gap: 12px; align-items: center; padding: 12px 10px; border-bottom: 1px solid var(--border); }
.skel-row > .skel { height: 13px; flex: 1; }
.skel-row > .skel.skel-sm { flex: 0 0 48px; }
.skel-row > .skel.skel-lg { flex: 2; }
@keyframes skel-shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* ---------- polish: sticky table headers + scroll ---------- */

.table-scroll { max-height: none; }
.table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--panel);
  background-clip: padding-box;
}
.table-card .table thead th { background: var(--panel); }

/* ---------- polish: empty-state icon emphasis ---------- */

.empty .empty-icon svg { color: var(--muted); }

/* ---------- polish: badges (subtle dot variant + hover lift on chips) ---------- */

.badge-dot::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
}
.chip:active { transform: translateY(1px); }

/* ---------- polish: card hover + focus affordances ---------- */

.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.nav-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ---------- responsive: global search + topbar ---------- */

@media (max-width: 900px) {
  .gs {
    position: fixed;
    top: 8px;
    left: 8px;
    right: 8px;
    z-index: 45;
    max-width: none;
    margin: 0;
    height: 40px;
    display: none;
  }
  .gs.gs-mobile-open { display: flex; }
  .gs.gs-mobile-open .gs-panel { left: 0; right: 0; }
  .gs-mobile-btn { display: inline-flex; }
}

@media (max-width: 520px) {
  .health-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .gs-item-secondary { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  .skel { animation: none; }
}

/* Visually hidden but available to screen readers (used for aria-live announcements). */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ============================ Statistics page ============================ */
.stats-filters { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.seg-row { display: flex; flex-wrap: wrap; gap: 6px; }
.seg {
  background: var(--panel2); border: 1px solid var(--border); color: var(--muted);
  border-radius: 7px; cursor: pointer; white-space: nowrap;
}
.seg:hover { color: var(--text); border-color: #3a4150; }
.seg-on { background: rgba(79, 140, 255, 0.15); border-color: var(--accent); color: var(--accent); }
.stats-filter-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.stats-daterange { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.stats-daterange .input { width: auto; }
.stats-unique-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; margin-left: auto; }
.stats-unique-toggle input { accent-color: var(--accent); }
.stats-grid { margin-bottom: 16px; }
.stats-hint { font-size: 12px; margin: -4px 0 12px; }

/* Breakdown bars */
.stats-breakdown-body { display: flex; flex-direction: column; gap: 6px; max-height: 520px; overflow-y: auto; margin-top: 12px; }
.bd-row { display: grid; grid-template-columns: minmax(120px, 200px) 1fr minmax(180px, auto); gap: 12px; align-items: center; }
.bd-label { font-size: 13px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bd-track { background: var(--panel2); border-radius: 6px; height: 18px; overflow: hidden; }
.bd-fill { background: linear-gradient(90deg, var(--accent), #6aa1ff); height: 100%; border-radius: 6px; min-width: 2px; }
.bd-val { display: flex; gap: 8px; align-items: baseline; justify-content: flex-end; font-size: 13px; }
.bd-count { font-weight: 600; font-variant-numeric: tabular-nums; }
.bd-pct, .bd-extra { font-size: 11px; }
.bd-perday { font-size: 11px; color: var(--accent); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Distribution chart (CSS bars, no script) */
.stats-dist-body { margin-top: 12px; }
.dist-chart { display: flex; align-items: flex-end; gap: 2px; height: 160px; padding-top: 8px; }
.dist-bar { flex: 1 1 0; min-width: 2px; background: linear-gradient(180deg, #6aa1ff, var(--accent)); border-radius: 2px 2px 0 0; transition: opacity 0.1s; }
.dist-bar:hover { opacity: 0.7; }

/* Category × State matrix */
.stats-matrix-body { margin-top: 4px; }
.matrix-scroll { overflow-x: auto; }
.matrix-table { font-size: 12px; }
.matrix-table th, .matrix-table td { padding: 6px 8px; text-align: center; white-space: nowrap; }
.matrix-corner { text-align: left !important; color: var(--muted); position: sticky; left: 0; background: var(--panel); z-index: 1; }
.matrix-col { color: var(--muted); font-weight: 600; }
.matrix-row { text-align: left !important; color: var(--text); position: sticky; left: 0; background: var(--panel); max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.matrix-cell { font-variant-numeric: tabular-nums; border-radius: 4px; }
.matrix-zero { color: var(--border); }

@media (max-width: 720px) {
  .bd-row { grid-template-columns: minmax(90px, 1fr) 1.2fr auto; }
  .stats-unique-toggle { margin-left: 0; }
}
