:root {
  --bg: #0b0e13;
  --bg2: #10141b;
  --card: #151b24;
  --card2: #1a2230;
  --line: #232d3b;
  --txt: #e8ecf3;
  --dim: #8b97a8;
  --acc: #4f8cff;
  --acc2: #6ee7b7;
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 10px;
  --shadow: 0 8px 24px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", -apple-system, Roboto, sans-serif;
  background: var(--bg);
  color: var(--txt);
  font-size: 14px;
  min-height: 100vh;
}
.hidden { display: none !important; }
a { color: var(--acc); text-decoration: none; }
.dim { color: var(--dim); }
.mono { font-family: Consolas, ui-monospace, monospace; font-size: 12px; }

/* ---------- login ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 50% -10%, #17233a 0%, var(--bg) 55%);
  padding: 16px;
}
.login-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 36px 32px; width: 100%; max-width: 380px; box-shadow: var(--shadow);
  text-align: center;
}
.login-logo { width: 56px; height: 56px; border-radius: 14px; }
.login-card h1 { margin: 10px 0 4px; font-size: 22px; }
.login-card form { margin-top: 22px; text-align: left; display: flex; flex-direction: column; gap: 12px; }
.login-card label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--dim); }
.form-err { color: var(--danger); font-size: 13px; margin-top: 4px; }

/* ---------- inputs ---------- */
input, select, textarea {
  background: var(--bg2); color: var(--txt);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 11px; font-size: 14px; width: 100%; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--acc); }
label.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--dim); }

button {
  background: var(--acc); color: #fff; border: 0; border-radius: 8px;
  padding: 9px 16px; font-size: 14px; font-weight: 600; cursor: pointer;
}
button:hover { filter: brightness(1.1); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.ghost { background: transparent; border: 1px solid var(--line); color: var(--txt); }
button.danger { background: var(--danger); }
button.warn { background: var(--warn); color: #1c1400; }
button.small { padding: 5px 10px; font-size: 12px; border-radius: 6px; }

/* ---------- app shell ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 216px; flex-shrink: 0; background: var(--bg2);
  border-right: 1px solid var(--line); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand { padding: 18px 16px 14px; font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.brand-mark { width: 20px; height: 20px; border-radius: 5px; display: block; }
#nav { display: flex; flex-direction: column; gap: 2px; padding: 0 8px; flex: 1; }
#nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border-radius: 8px; color: var(--dim); font-weight: 500;
}
#nav a span { width: 20px; text-align: center; }
#nav a:hover { background: var(--card); color: var(--txt); }
#nav a.active { background: var(--card2); color: var(--txt); box-shadow: inset 2px 0 0 var(--acc); }
.sidebar-foot { padding: 12px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.user-chip { font-size: 12px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; border-bottom: 1px solid var(--line);
  background: var(--bg2); position: sticky; top: 0; z-index: 5;
}
.topbar h2 { margin: 0; font-size: 18px; }
#topbar-actions { display: flex; gap: 8px; }
.content { padding: 22px 24px 60px; max-width: 1280px; width: 100%; }

/* ---------- cards / grid ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-bottom: 14px; }
.kpi .kpi-label { color: var(--dim); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
.kpi .kpi-value { font-size: 26px; font-weight: 700; margin-top: 4px; }
.kpi .kpi-sub { font-size: 12px; color: var(--dim); margin-top: 2px; }
.cols-2 { grid-template-columns: 1fr 1fr; }
@media (max-width: 980px) { .cols-2 { grid-template-columns: 1fr; } .sidebar { width: 64px; } .sidebar .brand, #nav a { font-size: 0; } #nav a span { font-size: 18px; } }

.section-title { font-size: 13px; color: var(--dim); text-transform: uppercase; letter-spacing: .6px; margin: 4px 0 10px; }
.chart-box { height: 300px; position: relative; }

/* ---------- leaderboard ---------- */
.lb { display: flex; flex-direction: column; gap: 8px; }
.lb-row { display: flex; align-items: center; gap: 10px; }
.lb-rank { width: 24px; height: 24px; border-radius: 6px; background: var(--card2); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: var(--dim); flex-shrink: 0; }
.lb-rank.top1 { background: var(--acc); color: #fff; }
.lb-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-bar-wrap { width: 90px; height: 6px; background: var(--bg2); border-radius: 3px; overflow: hidden; flex-shrink: 0; }
.lb-bar { height: 100%; background: var(--acc); border-radius: 3px; }
.lb-bar.low { background: var(--warn); }
.lb-count { width: 34px; text-align: right; font-weight: 600; font-size: 13px; }

/* ---------- table ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: .4px; white-space: nowrap; }
tr:hover td { background: rgba(79, 140, 255, .04); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; align-items: flex-end; }
.toolbar .field { width: 170px; }
.toolbar .grow { flex: 1; min-width: 200px; }
.toolbar input[type=search] { width: 100%; }
.pager { display: flex; align-items: center; gap: 10px; margin-top: 12px; color: var(--dim); font-size: 13px; }

/* ---------- status pills ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.new { color: #93c5fd; background: rgba(59,130,246,.12); }
.pill.contacted { color: #fcd34d; background: rgba(251,191,36,.12); }
.pill.replied { color: #5eead4; background: rgba(45,212,191,.12); }
.pill.meeting { color: #c4b5fd; background: rgba(139,92,246,.12); }
.pill.customer { color: #86efac; background: rgba(34,197,94,.12); }
.pill.not_interested { color: #94a3b8; background: rgba(148,163,184,.12); }
.pill.invalid { color: #fca5a5; background: rgba(239,68,68,.12); }
select.status-select { width: auto; padding: 5px 8px; font-size: 12px; border-radius: 6px; }

/* ---------- chips ---------- */
.chip { display: inline-block; background: var(--card2); border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px; font-size: 11px; margin: 1px 3px 1px 0; color: var(--dim); }

/* ---------- modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 20px; width: 100%; max-width: 460px; max-height: 86vh; overflow: auto; box-shadow: var(--shadow); }
.modal h3 { margin: 0 0 14px; font-size: 16px; }
.modal .form { display: flex; flex-direction: column; gap: 12px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.warn-box { background: rgba(251,191,36,.08); border: 1px solid rgba(251,191,36,.35); color: #fde68a; border-radius: 8px; padding: 12px; font-size: 13px; margin: 10px 0; }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 22px; right: 22px; z-index: 99;
  background: var(--card2); border: 1px solid var(--acc); color: var(--txt);
  padding: 11px 16px; border-radius: 8px; box-shadow: var(--shadow); font-size: 13px;
}
.toast.err { border-color: var(--danger); }

/* ---------- misc ---------- */
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* row action icons: map + notes prominent, delete tiny & muted */
.icon-btn {
  background: transparent; border: 0; padding: 5px 7px; font-size: 15px;
  cursor: pointer; border-radius: 6px; line-height: 1; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--card2); }
.icon-btn.del { font-size: 11px; color: var(--dim); opacity: .55; }
.icon-btn.del:hover { color: var(--danger); opacity: 1; background: rgba(248,113,113,.12); }

/* click-to-copy phone */
.phone-copy { cursor: pointer; }
.phone-copy:hover { color: var(--acc); text-decoration: underline dotted; }
.feed { display: flex; flex-direction: column; gap: 10px; }
.feed-item { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.feed-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.feed-dot.done { background: var(--acc2); }
.feed-dot.failed { background: var(--danger); }
.toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.badge { background: var(--card2); border: 1px solid var(--line); color: var(--dim); border-radius: 6px; padding: 2px 8px; font-size: 11px; }
