:root {
  --bg: #0e1116;
  --card: #161b22;
  --card2: #1c232c;
  --border: #2a3340;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #2f81f7;
  --green: #3fb950;
  --red: #f85149;
  --orange: #d29922;
  --purple: #a371f7;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button {
  background: var(--accent);
  color: white;
  border: none;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}
button:hover { filter: brightness(1.1); }
button.link, button.danger {
  background: transparent;
  color: var(--accent);
  padding: 4px 8px;
}
button.danger { color: var(--red); }

input, select, textarea {
  background: var(--card2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 1px solid var(--accent); }

label { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; font-size: 13px; color: var(--muted); }

.muted { color: var(--muted); }
.center { text-align: center; }

.error { color: var(--red); margin-top: 8px; font-size: 13px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
}

/* Login */
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-card { width: 100%; max-width: 360px; }
.login-card h1 { margin: 0 0 4px; }
.login-card button { width: 100%; margin-top: 8px; }

/* Topbar */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 24px; border-bottom: 1px solid var(--border);
  background: var(--card);
  position: sticky; top: 0; z-index: 5;
}
.topbar .brand { font-weight: 600; }
.topbar nav { display: flex; gap: 16px; align-items: center; }

main { padding: 16px 24px 32px; max-width: 1400px; margin: 0 auto; }

/* Filters */
.filters {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  margin-bottom: 16px;
}
.filters input[type=search] { flex: 1 1 240px; max-width: 320px; }
.filter-pills { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.pill {
  background: var(--card2);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: opacity 0.15s, border-color 0.15s, color 0.15s;
}
.pill:hover { border-color: var(--accent); }
.pill b { color: var(--text); font-weight: 600; }
.pill.inactive { opacity: 0.4; }
.pill.inactive b { color: var(--muted); }

/* Status dots */
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.dot-online { background: var(--green); }
.dot-busy { background: var(--orange); }
.dot-ringing { background: var(--purple); animation: pulse 1.2s ease-in-out infinite; }
.dot-offline { background: var(--red); }
.dot-unknown { background: var(--muted); }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

/* Grid of extensions */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}
.ext {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color 0.15s, transform 0.15s;
}
.ext.online { border-color: rgba(63,185,80,0.4); }
.ext.busy   { border-color: rgba(210,153,34,0.6); }
.ext.ringing { border-color: rgba(163,113,247,0.6); }
.ext.offline { opacity: 0.6; }

.ext-num { font-size: 18px; font-weight: 600; }
.ext-status { display: flex; align-items: center; gap: 6px; font-size: 12px; }

/* Admin */
.admin .card { margin-bottom: 18px; }
.admin h2 { margin-top: 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.right { justify-content: flex-end; }

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
}
th, td {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
td .small { color: var(--muted); font-size: 12px; }

/* Modal */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: grid; place-items: center;
  z-index: 100;
  padding: 16px;
}
.modal[hidden] { display: none; }
.modal-content { width: 100%; max-width: 540px; }
.modal-content textarea { width: 100%; font-family: ui-monospace, monospace; }
