:root {
  --bg: #0f1420;
  --panel: #171e2e;
  --panel-2: #1d2638;
  --border: #2a3550;
  --text: #e6ecf7;
  --muted: #8b97ad;
  --accent: #22c55e;
  --accent-dim: #16a34a;
  --warn: #f59e0b;
  --danger: #ef4444;
  --info: #38bdf8;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
}

a { color: var(--info); text-decoration: none; }

/* ---------- login ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px;
}
.auth-card h1 { margin: 0 0 6px; font-size: 20px; }
.auth-card p.sub { margin: 0 0 24px; color: var(--muted); }
.auth-card .error { color: var(--danger); font-size: 13px; margin: 0 0 12px; min-height: 16px; }

/* ---------- layout ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar h1 { font-size: 17px; margin: 0; display: flex; align-items: center; gap: 10px; }
.topbar .brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.topbar .right { display: flex; align-items: center; gap: 12px; }
.topbar .user { color: var(--muted); font-size: 13px; }

main { max-width: 1100px; margin: 24px auto; padding: 0 24px; }

section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  margin-bottom: 24px;
  overflow: hidden;
}
section > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
section > header h2 { margin: 0; font-size: 15px; }

/* ---------- buttons / inputs ---------- */
.btn {
  border: 0;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
  background: var(--accent-dim);
  transition: opacity .15s;
}
.btn:hover { opacity: .88; }
.btn.ghost { background: var(--panel-2); border: 1px solid var(--border); color: var(--text); }
.btn.danger { background: var(--danger); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.input {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
}
.input:focus { border-color: var(--info); }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 18px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
tr:last-child td { border-bottom: 0; }

/* ---------- status badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.idle { color: var(--accent); background: rgba(34,197,94,.12); }
.badge.busy { color: var(--warn); background: rgba(245,158,11,.12); }
.badge.offline { color: var(--muted); background: rgba(139,151,173,.12); }
.badge.online { color: var(--info); background: rgba(56,189,248,.12); }
.badge.call { color: var(--danger); background: rgba(239,68,68,.12); }
.badge.connecting { color: var(--warn); }
.badge.ended { color: var(--muted); }
.badge.failed { color: var(--danger); }
.badge.active { color: var(--accent); }

.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.center { text-align: center; }

#liveDot { display: none; }
.connected #liveDot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

/* ---------- simulator popup ---------- */
.sim {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.sim .card {
  width: 100%;
  max-width: 360px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
}
.sim .card h1 { margin: 0 0 4px; font-size: 18px; text-align: center; }
.sim .card p.sub { margin: 0 0 20px; text-align: center; color: var(--muted); font-size: 13px; }
.sim label { display: block; font-size: 12px; color: var(--muted); margin: 14px 0 6px; }
.sim .phone-row { display: flex; gap: 8px; }
.sim .btn.call {
  flex: 1;
  background: var(--accent-dim);
  padding: 12px 16px;
  font-size: 15px;
  border-radius: 10px;
}
.sim .btn.hangup { flex: 1; background: var(--danger); }

.status {
  margin-top: 18px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  font-size: 13px;
  min-height: 60px;
  white-space: pre-line;
}
.status .line { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.spin { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--muted); border-top-color: var(--info); border-radius: 50%; animation: rot .8s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }
.code-block {
  background: #0b0f18; border: 1px solid var(--border); border-radius: 8px;
  padding: 10px; font-family: ui-monospace, monospace; font-size: 12px; overflow: auto;
}