:root {
  --bg: #0f1115;
  --bg2: #161a21;
  --bg3: #1e232c;
  --panel: #1a1f27;
  --border: #2a313c;
  --text: #e6eaf0;
  --muted: #8a94a3;
  --accent: #3b82f6;
  --accent2: #2563eb;
  --green: #22c55e;
  --red: #ef4444;
  --amber: #f59e0b;
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, Segoe UI, Roboto, Ubuntu, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
code { background: var(--bg3); padding: 2px 6px; border-radius: 6px; }

/* ── login ── */
.login {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: radial-gradient(1200px 600px at 50% -10%, #1c2533, var(--bg));
}
.login-box {
  width: 340px; background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px; display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.login-box h1 { margin: 0; font-size: 20px; }
.login-box label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
input, select, button { font: inherit; }
input[type=text], input[type=password], input[type=number], select, .dial-number {
  background: var(--bg3); border: 1px solid var(--border); color: var(--text);
  padding: 10px 12px; border-radius: 8px; outline: none; width: 100%;
}
input:focus, select:focus { border-color: var(--accent); }
button {
  background: var(--accent); color: #fff; border: 0; border-radius: 8px;
  padding: 10px 16px; cursor: pointer; font-weight: 600;
}
button:hover { background: var(--accent2); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.ghost { background: var(--bg3); color: var(--text); border: 1px solid var(--border); font-weight: 500; }
button.ghost:hover { background: #262c37; }
button.small { padding: 6px 10px; font-size: 12px; }
.login-error { color: var(--red); font-size: 12px; min-height: 16px; }

/* ── app shell ── */
.app { display: grid; grid-template-columns: 220px 1fr; height: 100vh; }
.sidebar {
  background: var(--bg2); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 16px;
}
.brand { font-size: 16px; font-weight: 700; margin-bottom: 18px; display: flex; gap: 8px; align-items: center; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  text-align: left; background: transparent; color: var(--muted); border: 0;
  padding: 10px 12px; border-radius: 8px; cursor: pointer; font-weight: 500;
}
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active { background: var(--bg3); color: var(--text); }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.sip-status { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.online { background: var(--green); box-shadow: 0 0 8px var(--green); }
.dot.offline { background: var(--red); }
.dot.pending { background: var(--amber); }

.content { overflow: auto; padding: 24px; }
.tab { display: none; }
.tab.active { display: block; }
.tab-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.tab-head h2 { margin: 0; font-size: 18px; }

/* ── dialer ── */
.dialer { max-width: 380px; margin: 0 auto; }
.dialer-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.line-pick { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 4px; flex: 1; }
.call-state { font-size: 13px; color: var(--muted); white-space: nowrap; }
.dial-number { text-align: center; font-size: 26px; letter-spacing: 2px; padding: 14px; margin-bottom: 16px; }
.dialpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.dialpad button {
  background: var(--bg3); color: var(--text); border: 1px solid var(--border);
  font-size: 22px; padding: 14px 0; border-radius: 12px; display: flex;
  flex-direction: column; align-items: center; line-height: 1;
}
.dialpad button:hover { background: #262c37; }
.dialpad button i { font-style: normal; font-size: 9px; letter-spacing: 2px; color: var(--muted); margin-top: 3px; }
.dialer-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.call-btn { background: var(--green); }
.call-btn:hover { background: #16a34a; }
.hangup-btn { background: var(--red); }
.hangup-btn:hover { background: #dc2626; }
.incall-actions { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.call-timer { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--muted); }
.answer-bar {
  margin-top: 16px; background: var(--bg3); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px; display: flex; align-items: center; gap: 10px;
}
.answer-bar span { flex: 1; }

/* ── tables / cards ── */
.grid { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: var(--radius); overflow: hidden; }
.grid th, .grid td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
.grid th { color: var(--muted); font-weight: 600; background: var(--bg2); }
.grid tr:last-child td { border-bottom: 0; }
.badge { padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge.reg { background: rgba(34,197,94,.15); color: var(--green); }
.badge.err { background: rgba(239,68,68,.15); color: var(--red); }
.badge.off { background: rgba(138,148,163,.15); color: var(--muted); }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.card h3 { margin: 0 0 12px; font-size: 15px; }
.kv { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.kv:last-child { border-bottom: 0; }
.kv span { color: var(--muted); }
.log { background: var(--bg3); border-radius: 8px; padding: 12px; font-size: 12px; white-space: pre-wrap; max-height: 220px; overflow: auto; margin: 12px 0 0; }

/* ── modal ── */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 50; }
.modal-box { width: 560px; max-width: calc(100vw - 32px); background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
.modal-box h2 { margin: 0 0 16px; font-size: 18px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }
.checks { display: flex; gap: 18px; margin: 16px 0; }
.chk { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 13px; }
.chk input { width: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
