/* ── Reset & tokens ─────────────────────────────────────────────────── */
:root {
  --bg:       #0c1220;
  --bg2:      #111827;
  --panel:    #161f2e;
  --panel2:   #1c2a3a;
  --border:   rgba(255,255,255,.08);
  --text:     #e2e8f0;
  --muted:    #64748b;
  --accent:   #22d3ee;
  --accent2:  #818cf8;
  --green:    #10b981;
  --red:      #ef4444;
  --yellow:   #f59e0b;
  --radius:   14px;
  --radius-sm:8px;
  --shadow:   0 4px 24px rgba(0,0,0,.4);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body { font-family: Inter, system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); line-height: 1.6; }
a { color: var(--accent2); text-decoration: none; }
a:hover { color: var(--accent); }

/* ── Layout shell ───────────────────────────────────────────────────── */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }

/* ── Sidebar ────────────────────────────────────────────────────────── */
.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 20px 14px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}

.brand {
  width: 44px; height: 44px; border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: grid; place-items: center;
  font-weight: 900; font-size: 1rem; color: #0c1220;
  margin-bottom: 24px; flex-shrink: 0;
}

.sidebar nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }

.sidebar nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--muted); font-size: .9rem; font-weight: 500;
  transition: background .15s, color .15s;
}
.sidebar nav a:hover { background: rgba(255,255,255,.05); color: var(--text); }
.sidebar nav a.active { background: rgba(34,211,238,.12); color: var(--accent); }
.nav-icon { font-size: 1rem; width: 20px; text-align: center; }

.sidebar-footer {
  margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.logout-link { color: var(--muted); font-size: .82rem; }
.logout-link:hover { color: var(--red); }
.ver { color: var(--muted); font-size: .75rem; }

/* ── Main ───────────────────────────────────────────────────────────── */
.main { padding: 28px; width: 100%; }

/* ── Topbar ─────────────────────────────────────────────────────────── */
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.topbar h1 { font-size: 1.5rem; font-weight: 700; }
.topbar .sub { color: var(--muted); font-size: .88rem; margin-top: 2px; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

/* ── Buttons ────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--panel2);
  color: var(--text); font-size: .88rem; font-weight: 600;
  cursor: pointer; transition: background .15s, border-color .15s, opacity .15s;
  white-space: nowrap; font-family: inherit;
}
.btn:hover { background: var(--panel); border-color: rgba(255,255,255,.18); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-color: transparent; color: #0c1220; font-weight: 700;
}
.btn-primary:hover { opacity: .9; background: linear-gradient(135deg, var(--accent), var(--accent2)); }
.btn-danger { border-color: rgba(239,68,68,.4); color: var(--red); }
.btn-danger:hover { background: rgba(239,68,68,.12); }
.btn-sm { padding: 5px 10px; font-size: .82rem; }
.btn-full { width: 100%; justify-content: center; }

/* ── Cards ──────────────────────────────────────────────────────────── */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.card-head h2, .card-head h3 { font-size: 1rem; font-weight: 700; }
.link-sm { font-size: .82rem; color: var(--accent2); }
.mt { margin-top: 16px; }
.mt-sm { margin-top: 8px; }

/* ── Stat cards ─────────────────────────────────────────────────────── */
.stat-grid {
  display: grid; grid-template-columns: repeat(4,1fr);
  gap: 14px; margin-bottom: 16px;
}
.stat-card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
  display: flex; align-items: center; gap: 14px;
}
.stat-icon { font-size: 1.6rem; }
.stat-body { display: flex; flex-direction: column; }
.stat-val { font-size: 1.6rem; font-weight: 800; line-height: 1.1; }
.stat-label { font-size: .8rem; color: var(--muted); margin-top: 2px; }

/* ── Two col ────────────────────────────────────────────────────────── */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }

/* ── Tables ─────────────────────────────────────────────────────────── */
.tbl { width: 100%; border-collapse: collapse; font-size: .88rem; }
.tbl th {
  text-align: left; padding: 8px 10px;
  color: var(--muted); font-size: .78rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 1px solid var(--border);
}
.tbl td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl-hover tbody tr:hover { background: rgba(255,255,255,.03); }
.tbl-compact td, .tbl-compact th { padding: 7px 8px; }
.muted { color: var(--muted); }

/* ── Outcome badges ─────────────────────────────────────────────────── */
.badge-outcome {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: .78rem; font-weight: 600; text-transform: capitalize;
}
.badge-outcome.new       { background: rgba(100,116,139,.2);  color: var(--muted); }
.badge-outcome.called    { background: rgba(16,185,129,.15);  color: var(--green); }
.badge-outcome.no_answer { background: rgba(245,158,11,.15);  color: var(--yellow); }
.badge-outcome.voicemail { background: rgba(129,140,248,.15); color: var(--accent2); }
.badge-outcome.callback  { background: rgba(34,211,238,.15);  color: var(--accent); }
.badge-outcome.converted { background: rgba(16,185,129,.25);  color: var(--green); }
.badge-outcome.dnc       { background: rgba(239,68,68,.15);   color: var(--red); }

/* ── Status badges ──────────────────────────────────────────────────── */
.badge-status {
  padding: 4px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600;
}
.badge-status.ok       { background: rgba(16,185,129,.15); color: var(--green); }
.badge-status.off      { background: rgba(100,116,139,.15); color: var(--muted); }
.badge-status.checking { background: rgba(245,158,11,.15); color: var(--yellow); }
.badge-status.error    { background: rgba(239,68,68,.15); color: var(--red); }

/* ── Integration grid ───────────────────────────────────────────────── */
.int-grid { display: flex; flex-direction: column; gap: 12px; }
.int-item {
  display: flex; align-items: center; gap: 14px; padding: 14px;
  background: var(--panel2); border-radius: var(--radius-sm); border: 1px solid var(--border);
}
.int-icon { font-size: 1.4rem; }
.int-info { flex: 1; }
.int-info strong { display: block; font-size: .92rem; }
.int-info p { font-size: .8rem; color: var(--muted); margin: 0; word-break: break-all; }

/* ── Alerts ─────────────────────────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: .9rem; }
.alert-ok  { background: rgba(16,185,129,.12); border: 1px solid rgba(16,185,129,.3); color: var(--green); }
.alert-err { background: rgba(239,68,68,.12);  border: 1px solid rgba(239,68,68,.3);  color: var(--red); }

/* ── Forms ──────────────────────────────────────────────────────────── */
label { display: block; font-size: .82rem; font-weight: 600; color: var(--muted); margin: 12px 0 4px; }
input, textarea, select {
  width: 100%; padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--panel2);
  color: var(--text); font-size: .9rem; font-family: inherit;
  transition: border-color .15s;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }
textarea { resize: vertical; }
select { cursor: pointer; }
.hint { font-size: .78rem; color: var(--muted); margin-top: 4px; }
.sel-inline { width: auto; padding: 4px 8px; font-size: .82rem; }

/* ── Modals ─────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.65);
  backdrop-filter: blur(4px); display: flex;
  align-items: center; justify-content: center; z-index: 1000;
}
.modal-box {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
  width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-head h3 { font-size: 1.1rem; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--muted); font-size: 1rem; cursor: pointer; padding: 4px; }
.modal-close:hover { color: var(--text); }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* ── Filter bar ─────────────────────────────────────────────────────── */
.filter-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-bar select { width: auto; padding: 7px 10px; font-size: .85rem; }
.status-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tab {
  padding: 5px 12px; border-radius: 999px; font-size: .8rem; font-weight: 600;
  color: var(--muted); background: var(--panel); border: 1px solid var(--border);
  transition: background .15s, color .15s;
}
.tab:hover { color: var(--text); }
.tab.active { background: rgba(34,211,238,.15); color: var(--accent); border-color: rgba(34,211,238,.3); }
.tab-count { font-size: .72rem; opacity: .7; margin-left: 3px; }

/* ── Empty state ─────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-state p { margin-bottom: 16px; }

/* ── Login ──────────────────────────────────────────────────────────── */
.login-body {
  display: grid; place-items: center; min-height: 100vh;
  background: radial-gradient(ellipse at top, #111827, var(--bg));
}
.login-wrap { width: 100%; max-width: 400px; text-align: center; padding: 20px; }
.login-logo {
  width: 60px; height: 60px; border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: grid; place-items: center; font-size: 1.2rem; font-weight: 900;
  color: #0c1220; margin: 0 auto 16px;
}
.login-wrap h1 { font-size: 1.5rem; font-weight: 800; margin-bottom: 4px; }
.login-form {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px; margin-top: 20px; text-align: left;
}
.login-form label { margin-top: 14px; }
.login-form .btn { margin-top: 20px; }

/* ── Settings ───────────────────────────────────────────────────────── */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.settings-section h2 { font-size: 1rem; font-weight: 700; margin-bottom: 6px; }
.settings-section > p { font-size: .85rem; color: var(--muted); margin-bottom: 4px; }
.save-bar {
  position: sticky; bottom: 0; background: var(--bg);
  border-top: 1px solid var(--border); padding: 14px 0; margin-top: 16px;
}
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font-size: .85rem; margin-top: 12px; }
.info-grid span { color: var(--muted); }

/* ── Campaign picker ─────────────────────────────────────────────────── */
.campaign-pick-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(200px,1fr)); gap: 14px; margin-top: 16px; }
.campaign-pick-card {
  display: flex; flex-direction: column; gap: 6px; padding: 18px;
  background: var(--panel2); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text);
  transition: border-color .15s, background .15s;
}
.campaign-pick-card:hover { border-color: var(--accent); background: rgba(34,211,238,.06); color: var(--text); }
.campaign-pick-card strong { font-size: .95rem; }
.campaign-pick-card span { font-size: .82rem; color: var(--muted); }

/* ── Dial layout ─────────────────────────────────────────────────────── */
.dial-layout { display: grid; grid-template-columns: 1fr 300px; gap: 16px; align-items: start; }

.dial-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
.dial-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; font-size: .85rem; }
.dial-progress { color: var(--accent2); font-weight: 600; }

.lead-info { display: flex; align-items: flex-start; gap: 18px; margin-bottom: 24px; min-height: 80px; }
.lead-avatar {
  width: 56px; height: 56px; border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: grid; place-items: center; font-size: 1.4rem; font-weight: 800;
  color: #0c1220; flex-shrink: 0;
}
.lead-info h2 { font-size: 1.25rem; font-weight: 700; }
.lead-phone { font-size: 1.1rem; font-weight: 600; color: var(--accent); margin-top: 2px; }
.lead-meta { font-size: .82rem; color: var(--muted); margin-top: 4px; }

/* ── Call controls ───────────────────────────────────────────────────── */
.call-controls { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }

.btn-call {
  padding: 14px 32px; border-radius: 999px;
  background: linear-gradient(135deg, #10b981, #059669);
  border: none; color: #fff; font-size: 1rem; font-weight: 800;
  cursor: pointer; transition: opacity .15s, transform .1s;
  box-shadow: 0 0 0 0 rgba(16,185,129,.5);
}
.btn-call:hover:not(:disabled) { opacity: .9; transform: scale(1.02); }
.btn-call:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn-call.ringing { animation: ring-pulse 1.2s infinite; }

@keyframes ring-pulse {
  0%   { box-shadow: 0 0 0 0   rgba(16,185,129,.5); }
  70%  { box-shadow: 0 0 0 16px rgba(16,185,129,0); }
  100% { box-shadow: 0 0 0 0   rgba(16,185,129,0); }
}

.call-timer { font-size: 1.1rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--green); }

/* ── Keypad ──────────────────────────────────────────────────────────── */
.keypad { margin-bottom: 20px; }
.dial-input { font-size: 1.2rem; font-weight: 700; text-align: center; letter-spacing: .08em; margin-bottom: 10px; }
.keypad-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 6px; }
.keypad-btn {
  padding: 12px; border-radius: var(--radius-sm);
  background: var(--panel2); border: 1px solid var(--border);
  color: var(--text); font-size: 1rem; font-weight: 700;
  cursor: pointer; transition: background .1s; font-family: inherit;
}
.keypad-btn:hover { background: var(--panel); }
.keypad-btn:active { transform: scale(.95); }

/* ── Outcome bar ─────────────────────────────────────────────────────── */
.outcome-bar {
  background: var(--panel2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; margin-bottom: 14px;
}
.outcome-bar > p { font-size: .85rem; color: var(--muted); margin-bottom: 10px; }
.outcome-btns { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; margin-bottom: 12px; }
.out-btn {
  padding: 10px 6px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--panel); color: var(--text); font-size: .78rem; font-weight: 700;
  cursor: pointer; text-align: center; transition: background .15s, border-color .15s;
  font-family: inherit;
}
.out-btn:hover { background: var(--panel2); }
.out-btn.selected { border-color: var(--accent); background: rgba(34,211,238,.1); color: var(--accent); }
.outcome-notes { margin-bottom: 10px; resize: vertical; min-height: 60px; }
.outcome-footer { display: flex; justify-content: flex-end; gap: 8px; }
.dial-nav-btns { display: flex; justify-content: space-between; margin-top: 8px; }

/* ── Queue ───────────────────────────────────────────────────────────── */
.dial-queue { display: flex; flex-direction: column; gap: 12px; }
.queue-list { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.queue-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  font-size: .85rem; cursor: pointer;
}
.queue-item:last-child { border-bottom: none; }
.queue-item:hover { background: rgba(255,255,255,.03); }
.queue-item.current { background: rgba(34,211,238,.08); border-left: 3px solid var(--accent); }
.queue-item .qi-num  { color: var(--muted); font-size: .75rem; min-width: 18px; }
.queue-item .qi-name { flex: 1; font-weight: 600; }
.queue-item .qi-phone{ color: var(--muted); font-size: .78rem; }
.sess-stat { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: .85rem; }
.sess-stat:last-child { border-bottom: none; }
.sess-stat span { color: var(--muted); }

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 1100px) { .settings-grid { grid-template-columns: 1fr; } }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .stat-grid { grid-template-columns: repeat(2,1fr); }
  .two-col, .dial-layout { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .main { padding: 16px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .outcome-btns { grid-template-columns: repeat(2,1fr); }
}
