:root {
  --bg: #0d1017;
  --bg2: #12161f;
  --panel: #161b26;
  --panel2: #1b2230;
  --border: #242d3f;
  --border2: #2e3950;
  --text: #e7eaf2;
  --muted: #8b94a9;
  --accent: #5b8cff;
  --accent2: #8b5cf6;
  --ok: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --radius: 10px;
  --shadow: 0 8px 30px rgba(0,0,0,.45);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font-family: "Segoe UI", Inter, -apple-system, system-ui, sans-serif;
  font-size: 14px; overflow: hidden;
}
#app { display: flex; height: 100vh; }

/* ---------- sidebar ---------- */
#sidebar {
  width: 218px; flex-shrink: 0; background: var(--bg2);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 18px 16px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff; font-size: 14px;
}
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: .3px; }
.brand-name em { font-style: normal; color: var(--accent); }
#nav { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; flex: 1; }
#nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 500;
  transition: .15s;
}
#nav a .ic { width: 18px; text-align: center; opacity: .8; }
#nav a:hover { background: var(--panel); color: var(--text); }
#nav a.active { background: linear-gradient(90deg, rgba(91,140,255,.18), rgba(139,92,246,.10)); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }
.nav-badge { margin-left: auto; background: var(--bad); color: #fff; border-radius: 9px; font-size: 11px; padding: 1px 7px; }
.sidebar-foot { padding: 14px 18px; font-size: 11px; color: var(--muted); border-top: 1px solid var(--border); display: flex; align-items: center; gap: 8px; }
.db-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 6px var(--ok); }

#main { flex: 1; overflow-y: auto; padding: 26px 30px; }
#view { max-width: 1300px; margin: 0 auto; animation: fade .18s ease; }

/* ---------- login ---------- */
body.locked #sidebar { display: none; }
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 80vh; }
.login-card { width: 320px; }
.login-card input { padding: 10px 12px; }
.sidebar-foot .btn { padding: 3px 8px; font-size: 12px; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; } }

/* ---------- agent portal ---------- */
body.agent-route #sidebar { display: none; }
body.agent-route #main { margin-left: 0; padding: 0; }
.agent-login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 0%, rgba(91,140,255,.12), transparent 55%), var(--bg);
}
.agent-login-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 18px;
  padding: 46px 42px; width: 360px; text-align: center; box-shadow: 0 22px 70px rgba(0,0,0,.35);
}
.agent-login-logo {
  width: 64px; height: 64px; margin: 0 auto 18px; border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: grid; place-items: center; color: #fff; font-size: 28px;
}
.agent-login-title { font-size: 24px; font-weight: 700; letter-spacing: .4px; }
.agent-login-title em { font-style: normal; color: var(--accent); }
.agent-login-subtitle { color: var(--muted); font-size: 13px; margin: 6px 0 28px; text-transform: uppercase; letter-spacing: 1.5px; }
.agent-login-field { text-align: left; margin-bottom: 16px; }
.agent-login-field label { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; margin-bottom: 5px; }
.agent-login-field select, .agent-login-field input { width: 100%; padding: 11px 13px; }
.agent-login-btn { width: 100%; margin-top: 6px; padding: 12px; font-size: 14px; }
.agent-login-error { color: var(--bad); font-size: 12px; margin-top: 12px; min-height: 16px; text-align: center; }
.agent-mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; margin-top: 10px; }
.agent-mode-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 18px; padding: 42px 24px;
  text-align: center; cursor: pointer; transition: .18s;
}
.agent-mode-card:hover { border-color: var(--accent); transform: translateY(-4px); box-shadow: 0 16px 40px rgba(0,0,0,.22); }
.agent-mode-icon { font-size: 46px; margin-bottom: 14px; }
.agent-mode-title { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.agent-mode-desc { color: var(--muted); font-size: 13px; line-height: 1.45; }
.status-idle { background: rgba(91,140,255,.15); color: #8fb3ff; }
.status-manual { background: rgba(139,92,246,.15); color: #b9a2ff; }
.status-auto { background: rgba(234,179,8,.15); color: #f6d365; }
.status-oncall { background: rgba(34,197,94,.18); color: #6ee7b7; animation: pulse 1.4s infinite; }
.status-offline { background: rgba(120,120,120,.12); color: var(--muted); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .55; } }

/* ---------- agent shell (header menu + pages) ---------- */
.agent-topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 0 22px; height: 56px;
  background: var(--panel); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 40;
}
.agent-topbar-left { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.agent-topbar-brand { font-size: 15px; font-weight: 700; }
.agent-topbar-brand em { font-style: normal; color: var(--accent); }
.agent-topbar-name {
  font-size: 13px; color: var(--muted); padding-left: 12px;
  border-left: 1px solid var(--border);
}
.agent-tabs { display: flex; gap: 2px; flex: 1; min-width: 0; overflow-x: auto; }
.agent-tab {
  background: none; border: none; color: var(--muted);
  font-size: 13px; font-weight: 500; padding: 8px 14px;
  border-radius: 8px; cursor: pointer; white-space: nowrap;
  transition: .14s;
}
.agent-tab:hover { color: var(--text); background: rgba(91,140,255,.08); }
.agent-tab.active {
  color: var(--text); background: rgba(91,140,255,.14);
  box-shadow: inset 0 -2px 0 var(--accent);
}
.agent-topbar-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.agent-page { padding: 22px 26px; max-width: 1100px; margin: 0 auto; }
.agent-lead-list { display: flex; flex-direction: column; }
.agent-lead-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 0; border-bottom: 1px solid var(--border);
}
.agent-lead-row:last-child { border-bottom: none; }
.agent-lead-row.muted-row { opacity: .55; }
.agent-lead-main { min-width: 0; }
.agent-lead-name { font-weight: 600; font-size: 15px; }
.agent-lead-meta { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.agent-lead-notes { color: var(--muted); font-size: 12px; margin-top: 4px; font-style: italic; }
.agent-lead-actions { flex-shrink: 0; display: flex; gap: 6px; }

/* ---------- admin call center dashboard ---------- */
.agent-row { transition: .12s; }
.agent-row:hover { background: rgba(91,140,255,.08); }
.agent-row.selected { background: rgba(91,140,255,.14); box-shadow: inset 3px 0 0 var(--accent); }
.agent-outcome-chips { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- agent <-> admin chat widget ---------- */
#chat-widget { position: fixed; right: 18px; bottom: 18px; z-index: 9000; font-family: inherit; }
#chat-btn {
  position: relative; width: 52px; height: 52px; border-radius: 50%;
  border: none; background: var(--accent); color: #fff; font-size: 22px;
  cursor: pointer; box-shadow: 0 4px 16px rgba(0,0,0,.35);
  display: flex; align-items: center; justify-content: center; transition: .15s;
}
#chat-btn:hover { transform: scale(1.06); }
#chat-badge {
  position: absolute; top: -2px; right: -2px; min-width: 18px; height: 18px;
  border-radius: 9px; background: #e5484d; color: #fff; font-size: 11px;
  font-weight: 700; display: flex; align-items: center; justify-content: center;
  padding: 0 5px; box-shadow: 0 1px 4px rgba(0,0,0,.4);
}
#chat-panel {
  position: absolute; right: 0; bottom: 62px; width: 330px; height: 420px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,.45); display: flex; flex-direction: column; overflow: hidden;
}
.chat-head {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  border-bottom: 1px solid var(--border); background: rgba(255,255,255,.02);
}
.chat-title { font-weight: 700; font-size: 14px; flex: 0 0 auto; }
.chat-to {
  flex: 1; min-width: 0; background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: 5px 8px; font-size: 12.5px;
}
.chat-close { background: none; border: none; color: var(--muted); font-size: 15px; cursor: pointer; padding: 2px 6px; }
.chat-close:hover { color: var(--text); }
.chat-msgs { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.chat-msg { display: flex; flex-direction: column; align-items: flex-start; max-width: 85%; }
.chat-msg.own { align-self: flex-end; align-items: flex-end; }
.chat-sender { font-size: 11px; color: var(--muted); margin: 0 4px 2px; }
.chat-bubble {
  padding: 8px 12px; border-radius: 14px; font-size: 13.5px; line-height: 1.4;
  background: rgba(255,255,255,.07); color: var(--text);
  border-bottom-left-radius: 4px; white-space: pre-wrap; word-break: break-word;
}
.chat-msg.own .chat-bubble { background: var(--accent); color: #fff; border-radius: 14px; border-bottom-right-radius: 4px; }
.chat-bubble a { color: #8ab4ff; text-decoration: underline; word-break: break-all; }
.chat-msg.own .chat-bubble a { color: #fff; font-weight: 600; }
.chat-time { font-size: 10.5px; color: var(--muted); margin: 2px 4px 0; }
.chat-bcast { font-size: 11px; }
.chat-input { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); }
.chat-input input {
  flex: 1; background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; font-size: 13px; outline: none;
}
.chat-input input:focus { border-color: var(--accent); }
.chat-input button {
  background: var(--accent); color: #fff; border: none; border-radius: 8px;
  padding: 8px 14px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.chat-input button:hover { filter: brightness(1.12); }

/* ---------- dialer ---------- */
.dialer-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 28px; border-bottom: 1px solid var(--border); background: var(--panel);
  gap: 14px; flex-wrap: wrap;
}
.dialer-title { display: flex; flex-direction: column; gap: 3px; }
.dialer-mode { font-size: 20px; font-weight: 700; }
.dialer-meta { color: var(--muted); font-size: 13px; }
.dialer-actions { display: flex; gap: 8px; }
.auto-banner {
  background: linear-gradient(90deg, rgba(91,140,255,.18), rgba(139,92,246,.12));
  border-left: 3px solid var(--accent); color: var(--text); padding: 10px 28px; font-size: 13px;
}
.dialer-layout {
  display: grid; grid-template-columns: 300px 1fr; gap: 0; height: calc(100vh - 68px);
}
.queue-card {
  border-right: 1px solid var(--border); background: var(--panel); display: flex; flex-direction: column;
  min-height: 0;
}
.queue-card-head {
  padding: 16px 18px; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px;
  color: var(--muted); border-bottom: 1px solid var(--border); display: flex; justify-content: space-between;
}
.queue-list { overflow-y: auto; flex: 1; }
.queue-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  border-bottom: 1px solid var(--border); cursor: pointer; transition: .12s;
}
.queue-item:hover, .queue-item.active { background: rgba(91,140,255,.10); }
.queue-item.active { border-left: 3px solid var(--accent); padding-left: 13px; }
.queue-num {
  width: 26px; height: 26px; border-radius: 50%; background: var(--panel2); color: var(--muted);
  display: grid; place-items: center; font-size: 11px; font-weight: 600; flex-shrink: 0;
}
.queue-info { flex: 1; min-width: 0; }
.queue-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.queue-phone { color: var(--muted); font-size: 11px; margin-top: 2px; }
.queue-city { color: var(--muted); font-size: 12px; text-align: right; max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue-empty { padding: 40px 20px; text-align: center; color: var(--muted); font-size: 14px; }
.lead-card { overflow-y: auto; background: var(--bg); }
.lead-card-inner { max-width: 720px; margin: 28px auto; padding: 0 28px; }
.lead-head { margin-bottom: 18px; }
.lead-head-name { font-size: 26px; font-weight: 700; letter-spacing: -.2px; }
.lead-head-meta { color: var(--muted); font-size: 14px; margin-top: 4px; }
.lead-phone-wrap { margin: 18px 0 22px; }
.lead-phone {
  font-size: 32px; font-weight: 700; color: var(--text); text-decoration: none;
  letter-spacing: -.5px; display: inline-block;
}
.lead-phone:hover { color: var(--accent); }
.lead-row { display: flex; gap: 16px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.lead-label { width: 110px; flex-shrink: 0; color: var(--muted); text-transform: uppercase; font-size: 10px; letter-spacing: .6px; padding-top: 2px; }
.lead-vals { flex: 1; color: var(--text); word-break: break-word; }
.lead-cf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-top: 18px; }
.lead-cf-item { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.lead-cf-label { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 4px; }
.lead-cf-val { font-size: 12px; word-break: break-word; }
.lead-notes { margin-top: 18px; }
.lead-notes .lead-label { margin-bottom: 6px; }
.lead-notes > div:last-child { white-space: pre-wrap; color: var(--text); font-size: 13px; line-height: 1.5; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; max-height: 160px; overflow-y: auto; }
.lead-actions { display: flex; gap: 12px; margin: 24px 0 10px; }
.btn-call { font-size: 16px; padding: 12px 22px; }
.btn-call:disabled { opacity: .45; cursor: not-allowed; }
.lead-hint { color: var(--muted); font-size: 12px; }

/* ---------- admin lead full info ---------- */
.lead-admin-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px;
  font-size: 13px; line-height: 1.45;
}
.lead-admin-head { margin-bottom: 10px; }
.lead-admin-name { font-size: 18px; font-weight: 700; }
.lead-admin-meta { color: var(--muted); font-size: 12px; margin-top: 3px; }
.lead-admin-status { margin-bottom: 10px; }
.lead-admin-row, .lead-admin-phone-row {
  display: flex; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--border); align-items: flex-start;
}
.lead-admin-phone-row { align-items: center; }
.lead-admin-label { width: 90px; flex-shrink: 0; color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .5px; padding-top: 2px; }
.lead-admin-cf-grid {
  display: grid; grid-template-columns: 130px 1fr; gap: 0; margin-top: 12px;
  border: 1px solid var(--border); border-radius: 8px; overflow: hidden;
}
.lead-admin-cf { display: contents; }
.lead-admin-cf-key {
  color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .4px;
  padding: 8px 10px; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border);
  background: rgba(255,255,255,.03);
}
.lead-admin-cf-val {
  font-size: 13px; word-break: break-word; padding: 7px 10px; border-bottom: 1px solid var(--border);
}
.lead-admin-cf:last-child .lead-admin-cf-key,
.lead-admin-cf:last-child .lead-admin-cf-val { border-bottom: none; }
.lead-admin-notes { margin-top: 12px; }
.lead-admin-notes-label { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 5px; }
.lead-admin-notes-body { background: var(--bg2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; white-space: pre-wrap; font-size: 12.5px; }

/* ---------- call popup ---------- */
.callpop-overlay { position: fixed; inset: 0; background: rgba(10,12,18,.72); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; backdrop-filter: blur(4px); }
.callpop {
  background: var(--panel); border: 1px solid var(--border); border-radius: 18px; width: 100%; max-width: 620px;
  max-height: 92vh; overflow-y: auto; box-shadow: 0 28px 80px rgba(0,0,0,.45); padding: 24px;
}
.callpop-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.callpop-timer-wrap { display: flex; align-items: center; gap: 10px; }
.callpop-timer { font-size: 18px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 600; }
.callpop-hint { color: var(--muted); font-size: 12px; }
.callpop-actions { display: flex; gap: 10px; margin: 18px 0 12px; }
.callpop-notes { flex: 1; padding: 10px 12px; }
.callpop-outcomes-title { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; margin: 10px 0 10px; }
.callpop-outcomes-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.callpop-outcomes-grid .btn { justify-content: center; }
.callpop-skip { display: flex; justify-content: flex-end; margin-top: 14px; }

@media (max-width: 760px) {
  .agent-mode-grid { grid-template-columns: 1fr; }
  .agent-login-card { width: auto; margin: 20px; }
  .dialer-layout { grid-template-columns: 1fr; height: auto; }
  .queue-card { border-right: none; border-bottom: 1px solid var(--border); max-height: 320px; }
  .lead-card-inner { margin: 18px; padding: 0; }
  .lead-phone { font-size: 24px; }
  .callpop-outcomes-grid { grid-template-columns: 1fr; }
}

/* ---------- common ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.page-title { font-size: 22px; font-weight: 700; }
.page-sub { color: var(--muted); font-size: 13px; margin-top: 3px; }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
.card-pad { padding: 18px; }
.card-title { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; margin-bottom: 12px; }

.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 15px;
  border-radius: 8px; border: 1px solid var(--border2); background: var(--panel2);
  color: var(--text); font-size: 13px; font-weight: 600; cursor: pointer; transition: .15s;
}
.btn:hover { border-color: var(--accent); background: #202a3d; }
.btn.primary { background: linear-gradient(135deg, var(--accent), #4a6fe0); border-color: transparent; color: #fff; }
.btn.primary:hover { filter: brightness(1.12); }
.btn.danger { color: var(--bad); border-color: rgba(248,113,113,.35); }
.btn.danger:hover { background: rgba(248,113,113,.12); }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

input, select, textarea {
  background: var(--bg2); border: 1px solid var(--border2); color: var(--text);
  border-radius: 8px; padding: 8px 11px; font-size: 13px; font-family: inherit;
  outline: none; transition: border .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(91,140,255,.15); }
textarea { resize: vertical; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.st-new { background: rgba(56,189,248,.15); color: #38bdf8; }
.st-contacted { background: rgba(251,191,36,.15); color: var(--warn); }
.st-qualified { background: rgba(52,211,153,.15); color: var(--ok); }
.st-unqualified { background: rgba(148,163,184,.15); color: #94a3b8; }
.st-converted { background: rgba(167,139,250,.18); color: #a78bfa; }
.st-lost { background: rgba(248,113,113,.15); color: var(--bad); }
.b-act-created { background: rgba(52,211,153,.15); color: var(--ok); }
.b-act-merged { background: rgba(91,140,255,.15); color: var(--accent); }
.b-act-skipped { background: rgba(251,191,36,.15); color: var(--warn); }
.b-act-error { background: rgba(248,113,113,.15); color: var(--bad); }
.tag-chip { display: inline-block; background: var(--panel2); border: 1px solid var(--border2); border-radius: 6px; padding: 1px 8px; font-size: 11px; color: var(--muted); margin: 1px 2px; }

/* ---------- tables ---------- */
.tbl-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; background: var(--panel); }
.tbl th {
  text-align: left; padding: 11px 14px; font-size: 11px; text-transform: uppercase;
  letter-spacing: .7px; color: var(--muted); border-bottom: 1px solid var(--border);
  background: var(--bg2); white-space: nowrap; cursor: pointer; user-select: none;
}
.tbl th:hover { color: var(--text); }
.tbl td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tbody tr { transition: background .12s; }
.tbl tbody tr:hover { background: rgba(91,140,255,.05); }
.tbl tbody tr.clickable { cursor: pointer; }
.tbl tbody tr:last-child td { border-bottom: none; }
.lead-name { font-weight: 600; }
.lead-sub { color: var(--muted); font-size: 12px; }
.lead-cell { display: flex; align-items: center; gap: 10px; min-width: 160px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  display: inline-grid; place-items: center; font-size: 12px; font-weight: 700;
}
.contact-cell { line-height: 1.35; max-width: 230px; overflow: hidden; text-overflow: ellipsis; }
.leads-tbl { max-height: calc(100vh - 250px); overflow-y: auto; }
.leads-tbl thead th { position: sticky; top: 0; z-index: 2; }
.leads-tbl td { white-space: nowrap; }
.mono { font-family: Consolas, monospace; font-size: 12px; }
.empty { padding: 50px; text-align: center; color: var(--muted); }
.extra-dot { color: var(--accent2); font-weight: 700; margin-left: 4px; }

/* ---------- dashboard ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; position: relative; overflow: hidden; }
.stat-card::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 2px; background: linear-gradient(90deg, var(--accent), var(--accent2)); }
.stat-num { font-size: 28px; font-weight: 700; }
.stat-label { color: var(--muted); font-size: 12px; margin-top: 2px; }
.stat-pct { position: absolute; top: 12px; right: 14px; font-size: 11px; color: var(--muted); background: var(--bg2); border-radius: 8px; padding: 2px 7px; }
.stat-card.clickable { cursor: pointer; transition: border-color .15s, transform .1s; }
.stat-card.clickable:hover { border-color: var(--accent); transform: translateY(-1px); }
.stat-card.cov-ok::before { background: linear-gradient(90deg, var(--good, #34d399), var(--accent)); }
.stat-card.cov-bad::before { background: linear-gradient(90deg, var(--bad), var(--accent2)); }
.bar-row.clickable { cursor: pointer; }
.bar-row.clickable:hover .bar-label { color: var(--text); }
.tbl td.r, .tbl th.r { text-align: right; }

/* ---------- call center / agent dialer ---------- */
.dial-grid { display: grid; grid-template-columns: 320px 1fr; gap: 16px; }
.dial-num { font-size: 30px; font-weight: 700; margin: 12px 0 4px; letter-spacing: 1px; }
.q-active { background: var(--bg2); border-left: 3px solid var(--accent); padding-left: 9px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.dot-on { background: var(--good, #34d399); }
.dot-off { background: var(--bad); }
.cf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px 14px; margin-top: 10px; }
.cf-item { border-left: 2px solid var(--border); padding-left: 8px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-grid label { font-size: 12px; color: var(--muted); display: block; }
.form-grid input { width: 100%; margin-top: 4px; }
.callpop-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.65); z-index: 60; display: flex; align-items: center; justify-content: center; }
.callpop { background: var(--panel); border: 1px solid var(--accent); border-radius: 14px; padding: 22px; width: min(640px, 92vw); max-height: 88vh; overflow-y: auto; box-shadow: 0 24px 70px rgba(0,0,0,.6); }
a.tel-link { color: inherit; text-decoration: none; border-bottom: 1px dashed var(--border); }
.dash-cols { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.bar-label { width: 100px; font-size: 12px; color: var(--muted); text-align: right; }
.bar-track { flex: 1; height: 9px; background: var(--bg2); border-radius: 5px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 5px; background: linear-gradient(90deg, var(--accent), var(--accent2)); }
.bar-num { width: 34px; font-size: 12px; }

/* ---------- leads toolbar ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input[type=search] { width: 260px; }
.spacer { flex: 1; }
.pager { display: flex; align-items: center; gap: 10px; margin-top: 14px; color: var(--muted); font-size: 13px; }

/* ---------- drawer ---------- */
#drawer-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 40; }
#drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 560px; z-index: 41;
  background: var(--bg2); border-left: 1px solid var(--border2);
  box-shadow: var(--shadow); overflow-y: auto; animation: slidein .2s ease;
}
@media (max-width: 620px) {
  #drawer { width: 100%; }
}
@keyframes slidein { from { transform: translateX(60px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-head { padding: 20px 22px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: flex-start; justify-content: space-between; }
.drawer-body { padding: 18px 22px; }
.drawer-close { background: none; border: none; color: var(--muted); font-size: 20px; cursor: pointer; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.field-grid .full { grid-column: 1 / -1; }
.fld label { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 4px; }
.fld input, .fld select, .fld textarea { width: 100%; }
.timeline { margin-top: 8px; }
.tl-item { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 12.5px; }
.tl-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-top: 5px; flex-shrink: 0; }
.tl-time { color: var(--muted); font-size: 11px; }
.contact-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.contact-type { font-size: 10px; text-transform: uppercase; color: var(--muted); width: 44px; }

/* ---------- modal ---------- */
#modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 60; display: grid; place-items: center; }
#modal { background: var(--bg2); border: 1px solid var(--border2); border-radius: 12px; padding: 24px; width: 420px; box-shadow: var(--shadow); max-height: 85vh; overflow-y: auto; }
#modal h3 { margin-bottom: 14px; }
#modal .modal-body-scroll { max-height: 55vh; overflow-y: auto; margin: 10px 0; font-size: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ---------- import wizard ---------- */
.steps { display: flex; gap: 6px; margin-bottom: 22px; }
.step { flex: 1; text-align: center; padding: 9px; font-size: 12.5px; font-weight: 600; color: var(--muted); border-bottom: 2px solid var(--border); }
.step.active { color: var(--accent); border-color: var(--accent); }
.step.done { color: var(--ok); border-color: var(--ok); }

.dropzone {
  border: 2px dashed var(--border2); border-radius: var(--radius); padding: 42px;
  text-align: center; color: var(--muted); cursor: pointer; transition: .15s;
  background: var(--panel);
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: rgba(91,140,255,.06); color: var(--text); }
.dropzone .dz-ic { font-size: 34px; margin-bottom: 10px; }
.paste-area { width: 100%; min-height: 130px; margin-top: 14px; font-family: Consolas, monospace; font-size: 12.5px; }
.import-opts { display: flex; gap: 14px; margin-top: 14px; align-items: center; flex-wrap: wrap; }
.import-opts label { display: flex; gap: 7px; align-items: center; font-size: 13px; color: var(--muted); }

.map-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.map-item { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; position: relative; }
.map-item .col-name { font-size: 12px; color: var(--muted); margin-bottom: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-right: 20px; }
.map-item select { width: 100%; }
.map-x { position: absolute; top: 7px; right: 7px; width: 18px; height: 18px; border: none; border-radius: 4px; background: transparent; color: var(--muted); font-size: 12px; line-height: 1; cursor: pointer; padding: 0; }
.map-x:hover { background: var(--bad); color: #fff; }
.map-item.ignored { opacity: .45; border-style: dashed; }
.map-item.ignored .map-x { background: var(--bad); color: #fff; }
.map-sample { font-size: 11px; color: var(--accent); margin-top: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-title .map-x { position: static; flex: none; }
.seg-ignored { opacity: .55; border-style: dashed; }

.summary-cards { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.sum-card { flex: 1; min-width: 120px; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px; text-align: center; }
.sum-card .n { font-size: 22px; font-weight: 700; }
.sum-card .l { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }

.radio-cards { display: flex; gap: 10px; margin: 14px 0; flex-wrap: wrap; }
.radio-card { flex: 1; min-width: 170px; background: var(--panel); border: 1.5px solid var(--border); border-radius: 10px; padding: 12px 14px; cursor: pointer; transition: .15s; }
.radio-card.sel { border-color: var(--accent); background: rgba(91,140,255,.08); }
.radio-card .rc-title { font-weight: 600; margin-bottom: 3px; }
.radio-card .rc-desc { font-size: 12px; color: var(--muted); }

/* ---------- duplicates ---------- */
.dup-group { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 14px; overflow: hidden; }
.dup-head { padding: 12px 16px; background: var(--bg2); border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.dup-reason { color: var(--warn); font-size: 12px; font-weight: 600; }
.dup-leads { display: flex; flex-direction: column; }
.dup-lead { display: flex; align-items: center; gap: 14px; padding: 11px 16px; border-bottom: 1px solid var(--border); font-size: 13px; }
.dup-lead:last-child { border-bottom: none; }
.dup-lead .grow { flex: 1; }

/* ---------- toasts ---------- */
#toasts { position: fixed; bottom: 20px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--panel2); border: 1px solid var(--border2); border-left: 3px solid var(--accent);
  border-radius: 8px; padding: 11px 16px; font-size: 13px; box-shadow: var(--shadow);
  animation: slidein .2s ease; max-width: 340px;
}
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--bad); }

.hidden { display: none !important; }
.muted { color: var(--muted); }
.mt { margin-top: 14px; }
.mb { margin-bottom: 14px; }

/* Tabs */
.tab-btn {
  background: none; border: none; color: var(--muted); padding: 8px 16px;
  cursor: pointer; font-weight: 500; border-bottom: 2px solid transparent;
  transition: .15s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-content { display: block; }
.tab-content.hidden { display: none; }
.flex { display: flex; gap: 10px; align-items: center; }

/* ---------- campaign editor modal ---------- */
#modal:has(.ce-sec) { width: 760px; max-width: 96vw; padding: 0; }
/* modals that carry tables/lists get a wider frame — the default 420px makes
   rows wrap and the dialog look like a squeezed page-in-a-page */
#modal:has(.modal-lg) { width: 920px; max-width: 96vw; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 18px 22px; border-bottom: 1px solid var(--border);
}
.modal-body { padding: 18px 22px; }
.modal-body label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.modal-body label input, .modal-body label select, .modal-body label textarea { width: 100%; margin-top: 4px; }
.modal-foot {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  padding: 14px 22px; border-top: 1px solid var(--border); background: var(--bg2);
  border-radius: 0 0 12px 12px;
}

.ce-sec { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 10px; background: var(--bg2); }
.ce-sec > summary {
  display: flex; align-items: baseline; gap: 10px; cursor: pointer;
  padding: 11px 14px; list-style: none; user-select: none;
}
.ce-sec > summary::-webkit-details-marker { display: none; }
.ce-sec > summary::before { content: "▸"; color: var(--muted); font-size: 11px; transition: transform .15s; }
.ce-sec[open] > summary::before { content: "▾"; }
.ce-sec-title { font-weight: 600; font-size: 13px; }
.ce-sec-hint { font-size: 11px; margin-left: auto; text-align: right; }
.ce-sec-body { padding: 4px 14px 14px; border-top: 1px solid var(--border); }
.ce-sec-body label { margin-top: 10px; }
.ce-sec-body .form-grid label { margin-top: 0; }

@media (max-width: 820px) {
  #modal:has(.ce-sec) { width: 96vw; }
  .form-grid { grid-template-columns: 1fr; }
}

/* parallel send-session chips under a running campaign / in the send modal */
.sess-panel { display: flex; flex-wrap: wrap; gap: 8px; }
.sess-chip {
  display: inline-flex; align-items: baseline; gap: 7px;
  font-size: 11px; padding: 4px 10px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--bg2); color: var(--fg);
}
.sess-chip b { color: #f59e0b; }
.sess-chip.done { opacity: .7; }
.sess-chip.done b { color: #34d399; }
.sess-time { font-variant-numeric: tabular-nums; font-weight: 600; }
.sess-cur { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
