:root {
  --bg: #000;
  --ink: #f5f5f7;
  --muted: #8a8a93;
  --surface: #0b0b0d;
  --surface-2: #131316;
  --panel: #08080a;
  --line: #1c1c21;
  --line-strong: #2a2a31;
  --lcd: #07100a;
  --lcd-ink: #7dffa8;
  --green: #30d158;
  --red: #ff453a;
  --accent: #ffffff;
  --glow: #ffffff0d;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  font: 15px/1.5 "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  background: radial-gradient(ellipse 80% 40% at 50% -10%, var(--glow) 0, transparent 70%), var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; transition: background 0.15s, border-color 0.15s, transform 0.1s, opacity 0.15s; }
::selection { background: #ffffff33; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 24px 20px; max-width: 1180px; margin: 0 auto; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 14px; }
.logo { font-size: 28px; width: 48px; height: 48px; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 14px; }
.brand h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.03em; }
.brand p { margin: 0; color: var(--muted); font-size: 13px; }
.stats { font: 11.5px ui-monospace, "SF Mono", Menlo, monospace; color: var(--muted); letter-spacing: 0.02em; border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; background: var(--panel); }
.stats:empty { display: none; }

main { max-width: 1180px; margin: 0 auto; padding: 0 16px 24px; display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { main.signed-in { grid-template-columns: 380px minmax(0, 1fr); align-items: start; } }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 20px 22px; box-shadow: inset 0 1px 0 #ffffff08; }
.panel h2 { margin: 0 0 8px; font-size: 17px; font-weight: 650; letter-spacing: -0.02em; display: flex; align-items: center; gap: 8px; }
.panel h3 { margin: 18px 0 6px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); }
.muted { color: var(--muted); font-size: 13.5px; margin: 0 0 12px; }
.err { color: var(--red); min-height: 1.4em; margin: 8px 0 0; font-size: 14px; }

.welcome { max-width: 520px; margin: 10px auto 0; width: 100%; padding: 28px; }
.welcome h2 { font-size: 24px; letter-spacing: -0.03em; }
.tabs { display: flex; gap: 4px; margin: 14px 0 16px; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.tabs button { flex: 1; border: 0; background: transparent; border-radius: 9px; padding: 8px; color: var(--muted); font-weight: 500; }
.tabs button[aria-selected="true"] { background: var(--surface-2); color: var(--ink); box-shadow: 0 0 0 1px var(--line-strong); font-weight: 600; }
.form { display: grid; gap: 12px; }
.form label { display: grid; gap: 5px; font-size: 13px; color: var(--muted); }
.form input, .form textarea, .form select { width: 100%; border: 1px solid var(--line-strong); background: #000; border-radius: 12px; padding: 10px 13px; color: var(--ink); }
.form input::placeholder, .form textarea::placeholder { color: #55555d; }
.form input:focus, .form textarea:focus, .form select:focus { outline: none; border-color: #fff; box-shadow: 0 0 0 3px #ffffff1f; }
.form.compact { margin-top: 12px; }
.form .row { display: flex; gap: 10px; flex-wrap: wrap; }
.form .row label { flex: 1; min-width: 130px; }
.form button, .ghost { border: 1px solid var(--line-strong); background: var(--surface-2); border-radius: 12px; padding: 10px 14px; font-weight: 600; }
.form button:hover, .ghost:hover { background: #1b1b20; border-color: #3a3a42; }
.big { font-size: 15px; padding: 13px 18px !important; background: #fff !important; border-color: #fff !important; color: #000 !important; border-radius: 12px; border: 1px solid; font-weight: 650; letter-spacing: -0.01em; }
.big:hover { background: #e6e6e6 !important; }
.ghost { background: transparent; color: var(--muted); font-weight: 500; width: 100%; }
.emojis { border: 0; padding: 0; margin: 0; }
.emojis legend { font-size: 13px; color: var(--muted); margin-bottom: 6px; padding: 0; }
#emojiPick { display: flex; flex-wrap: wrap; gap: 6px; }
#emojiPick button { font-size: 20px; width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); padding: 0; }
#emojiPick button:hover { border-color: var(--line-strong); }
#emojiPick button[aria-pressed="true"] { border-color: #fff; background: var(--surface-2); box-shadow: 0 0 0 3px #ffffff1a; }
.whois { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 4px; }

/* ── the phone ── */
.phone-wrap { position: sticky; top: 12px; }
.phone {
  position: relative;
  background: linear-gradient(180deg, #17171b 0%, #0a0a0c 55%, #060607 100%);
  border-radius: 34px;
  padding: 58px 18px 18px;
  border: 1px solid var(--line-strong);
  box-shadow: inset 0 1px 0 #ffffff14, inset 0 -1px 0 #000, 0 30px 60px -20px #000, 0 0 0 1px #000, 0 0 80px -30px #ffffff22;
}
.handset {
  position: absolute; left: 24px; right: 24px; top: 14px; height: 32px;
  background: linear-gradient(180deg, #26262c, #0e0e11);
  border-radius: 20px; border: 1px solid #2f2f37; box-shadow: inset 0 1px 0 #ffffff14, 0 4px 10px #000;
  transition: transform 0.25s;
}
.phone.offhook .handset { transform: translateY(-8px) rotate(-3deg); }
.phone.ringing .handset { animation: ring 0.12s infinite alternate; }
.phone.ringing { box-shadow: inset 0 1px 0 #ffffff14, 0 30px 60px -20px #000, 0 0 0 1px #000, 0 0 80px -10px #30d15866; }
@keyframes ring { from { transform: rotate(-2deg) translateY(-2px); } to { transform: rotate(2deg) translateY(-4px); } }
@media (prefers-reduced-motion: reduce) { .phone.ringing .handset { animation: none; } button { transition: none; } }
.lcd { background: var(--lcd); color: var(--lcd-ink); border-radius: 16px; padding: 12px 14px; font-family: ui-monospace, "SF Mono", Menlo, monospace; border: 1px solid #16261b; box-shadow: inset 0 0 30px #0008, 0 0 24px -8px #30d15855; min-height: 112px; }
.lcd-top { display: flex; justify-content: space-between; font-size: 11px; opacity: 0.6; gap: 8px; }
.lcd-main { font-size: 26px; font-weight: 700; letter-spacing: 0.06em; margin: 6px 0 2px; word-break: break-all; min-height: 1.3em; text-shadow: 0 0 12px #7dffa866; }
.lcd-sub { font-size: 12.5px; min-height: 2.6em; opacity: 0.85; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 16px 0 14px; }
.keypad button {
  height: 56px; border-radius: 50px; border: 1px solid var(--line-strong);
  background: linear-gradient(180deg, #1a1a1f, #101013); color: #f5f5f7;
  font-size: 22px; font-weight: 600; display: grid; place-items: center; line-height: 1; padding: 0;
  box-shadow: inset 0 1px 0 #ffffff0f;
}
.keypad button:hover { background: linear-gradient(180deg, #212127, #141418); border-color: #3a3a42; }
.keypad button small { display: block; font-size: 8.5px; letter-spacing: 0.18em; color: var(--muted); font-weight: 600; margin-top: 2px; }
.keypad button:active { transform: scale(0.96); background: #26262d; }
.callbar { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.callbar button { height: 52px; border-radius: 50px; border: 0; font-weight: 650; color: #fff; font-size: 15px; }
.call { background: var(--green); color: #000 !important; }
.call:hover:not(:disabled) { filter: brightness(1.1); }
.hang { background: var(--red); }
.hang:hover:not(:disabled) { filter: brightness(1.1); }
.callbar button:disabled { opacity: 0.3; cursor: default; }
.incall { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 12px; }
.incall button { border: 1px solid var(--line-strong); background: var(--surface); border-radius: 12px; padding: 8px 2px; font-size: 12px; color: var(--ink); }
.incall button:hover:not(:disabled) { background: var(--surface-2); }
.incall button[aria-pressed="true"] { background: #fff; color: #000; border-color: #fff; }
.incall button:disabled { opacity: 0.35; cursor: default; }
.sticker { text-align: center; font-size: 10.5px; color: #55555d; margin: 14px 0 0; letter-spacing: 0.04em; }

/* ── lists ── */
.side { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1200px) { .side { grid-template-columns: 1fr 1fr; align-items: start; } }
.dir, .list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.dir li, .list li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; }
.dir li:hover, .list li:hover { background: var(--surface); }
.dir .em { font-size: 20px; width: 32px; height: 32px; display: grid; place-items: center; background: var(--surface-2); border-radius: 10px; flex: none; }
.dir .who { flex: 1; min-width: 0; }
.dir .who b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.dir .who span { font-size: 12px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: #3a3a42; }
.dot.online { background: var(--green); box-shadow: 0 0 10px #30d158aa; }
.dot.busy { background: var(--red); box-shadow: 0 0 10px #ff453a88; }
.dot.dnd { background: #bf5af2; }
.mini { border: 1px solid var(--line-strong); background: var(--surface-2); border-radius: 999px; padding: 4px 12px; font-size: 13px; flex: none; }
.mini:hover { background: #fff; color: #000; border-color: #fff; }
.dir.small li { padding: 5px 6px; }
.list .grow { flex: 1; min-width: 0; }
.list .grow b { font-weight: 600; }
.list .grow span { display: block; font-size: 12px; color: var(--muted); }
.list .empty, .dir .empty { color: var(--muted); font-size: 13.5px; }
.list .empty:hover, .dir .empty:hover { background: transparent; }
.badge { background: var(--red); color: #fff; font-size: 11px; font-weight: 600; border-radius: 999px; padding: 1px 8px; }
.badge:empty { display: none; }
.admin summary { cursor: pointer; font-weight: 650; font-size: 16px; }

/* ── SIP panel ── */
.sip-details { display: grid; gap: 10px; }
.sip-row { display: grid; grid-template-columns: 110px 1fr; gap: 12px; align-items: center; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.sip-row label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 600; }
.sip-row code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 14px; background: #000; border: 1px solid var(--line-strong); border-radius: 8px; padding: 6px 10px; word-break: break-all; }
.sip-row .copy { width: 32px; height: 32px; border: 1px solid var(--line-strong); background: var(--surface-2); border-radius: 8px; font-size: 14px; display: grid; place-items: center; justify-self: start; }
.sip-row .copy:hover { background: #fff; color: #000; border-color: #fff; }
.sip-row .copy.copied { background: var(--green); color: #000; border-color: var(--green); }
.sip-warning { font-size: 12px; color: var(--muted); padding: 8px 0 0; border-top: 1px solid var(--line); margin-top: 4px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: #111114; border: 1px solid var(--line-strong); color: var(--ink); padding: 11px 18px; border-radius: 14px; opacity: 0; transition: 0.25s; pointer-events: none; max-width: calc(100vw - 32px); font-size: 14px; z-index: 10; box-shadow: 0 20px 40px -10px #000; }
.toast.show { opacity: 1; transform: translateX(-50%); }
.overlay { position: fixed; inset: 0; background: #000d; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); display: grid; place-content: center; text-align: center; color: var(--ink); gap: 12px; z-index: 20; padding: 16px; }
.overlay p { color: var(--muted); margin: 0; }
.overlay[hidden] { display: none; }
footer { text-align: center; color: #5f5f68; font-size: 12px; padding: 14px 16px 36px; max-width: 760px; margin: 0 auto; }