:root {
  --bg: #0f1419;
  --bg2: #171d25;
  --panel: #1c2430;
  --border: #2a3544;
  --text: #e8eef6;
  --muted: #93a0b4;
  --primary: #3b82f6;
  --primary-2: #2563eb;
  --danger: #ef4444;
  --warn: #f59e0b;
  --ok: #22c55e;
  --radius: 12px;
  --shadow: 0 8px 24px rgba(0,0,0,.35);
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: radial-gradient(1200px 600px at 10% -10%, #1a2740 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
}
a { color: #93c5fd; text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: #0b1220; padding: .1rem .35rem; border-radius: 6px; font-size: .9em; }

.app-shell { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, #141b24, #10161e);
  border-right: 1px solid var(--border);
  padding: 1.25rem 1rem;
  display: flex; flex-direction: column; gap: 1.25rem;
}
.brand { display: flex; gap: .75rem; align-items: center; }
.brand-center { justify-content: center; margin-bottom: 1rem; }
.brand strong { display: block; font-size: .95rem; }
.brand span { color: var(--muted); font-size: .8rem; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(135deg, #3b82f6, #06b6d4);
  display: grid; place-items: center; font-weight: 800; color: #fff;
  box-shadow: 0 0 0 3px rgba(59,130,246,.2);
}
.nav { display: flex; flex-direction: column; gap: .35rem; flex: 1; }
.nav a {
  color: var(--muted); padding: .7rem .85rem; border-radius: 10px;
  text-decoration: none; font-weight: 600;
}
.nav a:hover { background: rgba(255,255,255,.04); color: var(--text); }
.nav a.active { background: rgba(59,130,246,.15); color: #fff; border: 1px solid rgba(59,130,246,.35); }
.sidebar-foot { margin-top: auto; display: grid; gap: .5rem; }
.user-chip { font-size: .85rem; color: var(--muted); padding: .25rem .4rem; }

.main { padding: 1.25rem 1.5rem 2rem; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.topbar h1 { margin: 0; font-size: 1.45rem; font-weight: 700; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem 1.2rem;
  margin-bottom: 1rem;
}
.panel.narrow { max-width: 720px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .85rem; }
.panel-head h2, .panel h3 { margin: 0; font-size: 1.05rem; }

.grid { display: grid; gap: 1rem; }
.stats-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.two-col { grid-template-columns: 1.4fr 1fr; }
.stat-card {
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem; display: grid; gap: .35rem;
}
.stat-card.stat-danger { border-color: rgba(239,68,68,.4); }
.stat-label { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 1.8rem; font-weight: 800; }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: .65rem .55rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; }
.actions { white-space: nowrap; }
.inline { display: inline; }
.inline-form { display: flex; gap: .5rem; align-items: end; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  border: 1px solid var(--border); background: #243041; color: var(--text);
  border-radius: 10px; padding: .55rem .9rem; font-weight: 600; cursor: pointer;
  text-decoration: none; font-size: .9rem;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); border-color: transparent; color: #fff; }
.btn-danger { background: rgba(239,68,68,.15); border-color: rgba(239,68,68,.4); color: #fecaca; }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; }
.btn-sm { padding: .35rem .6rem; font-size: .8rem; }

.alert { padding: .75rem 1rem; border-radius: 10px; margin-bottom: 1rem; border: 1px solid var(--border); }
.alert-success { background: rgba(34,197,94,.12); border-color: rgba(34,197,94,.35); }
.alert-error { background: rgba(239,68,68,.12); border-color: rgba(239,68,68,.35); }
.alert-warn { background: rgba(245,158,11,.12); border-color: rgba(245,158,11,.35); }

.badge, .pill, .tag {
  display: inline-block; padding: .15rem .5rem; border-radius: 999px;
  font-size: .75rem; font-weight: 700; background: #243041; border: 1px solid var(--border);
}
.badge-warn { background: rgba(245,158,11,.15); color: #fcd34d; border-color: rgba(245,158,11,.35); }
.badge-ok { background: rgba(34,197,94,.15); color: #86efac; border-color: rgba(34,197,94,.35); }
.pill-missed { background: rgba(239,68,68,.15); color: #fecaca; }
.pill-received { background: rgba(34,197,94,.15); color: #bbf7d0; }
.pill-dialed { background: rgba(59,130,246,.15); color: #bfdbfe; }
.tag { margin-right: .25rem; color: var(--muted); font-weight: 600; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.toolbar { display: flex; gap: .5rem; margin-bottom: .85rem; }
.toolbar input[type="search"], .toolbar input[type="date"] { flex: 1; }

input, textarea, select {
  width: 100%; margin-top: .35rem; background: #0f1620; color: var(--text);
  border: 1px solid var(--border); border-radius: 10px; padding: .65rem .75rem; font: inherit;
}
label { display: block; font-size: .88rem; color: var(--muted); margin-bottom: .75rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem 1rem; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: .5rem; align-items: center; }
.check { display: flex; align-items: center; gap: .5rem; color: var(--text); }
.check input { width: auto; margin: 0; }

.tabs { display: flex; gap: .35rem; margin-bottom: 1rem; flex-wrap: wrap; }
.tab {
  padding: .45rem .85rem; border-radius: 999px; border: 1px solid var(--border);
  color: var(--muted); font-weight: 600; text-decoration: none;
}
.tab.active, .tab:hover { background: rgba(59,130,246,.15); color: #fff; border-color: rgba(59,130,246,.4); text-decoration: none; }

.activity-list { list-style: none; margin: 0; padding: 0; }
.activity-list li { padding: .65rem 0; border-bottom: 1px solid var(--border); display: grid; gap: .15rem; }
.activity-list time { color: var(--muted); font-size: .8rem; }

.auth-body { display: grid; place-items: center; min-height: 100vh; padding: 1rem; }
.auth-card {
  width: min(420px, 100%); background: var(--panel); border: 1px solid var(--border);
  border-radius: 16px; padding: 1.5rem; box-shadow: var(--shadow);
}
.auth-form h1 { margin: 0 0 .25rem; }
.auth-form form { display: grid; gap: .75rem; margin-top: 1rem; }

.softphone-grid { display: grid; grid-template-columns: 380px 1fr; gap: 1rem; }
.dial-display input { font-size: 1.4rem; letter-spacing: .05em; text-align: center; }
.dial-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin: 1rem 0; }
.dial-key {
  aspect-ratio: 1; border-radius: 50%; border: 1px solid var(--border);
  background: #121925; color: #fff; font-size: 1.25rem; font-weight: 700; cursor: pointer;
}
.dial-key:hover { background: #1b2636; }
.dial-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.softphone-status { margin-top: .85rem; color: var(--muted); font-size: .9rem; }
.contact-dial-list { list-style: none; margin: 0; padding: 0; }
.contact-dial-list li {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: .65rem 0; border-bottom: 1px solid var(--border);
}
.contact-dial-list span { display: block; font-size: .8rem; }
.doc-box { margin-top: 1rem; padding: .85rem; background: #121925; border-radius: 10px; border: 1px solid var(--border); }
.ami-out { background: #0b1220; padding: .75rem; border-radius: 8px; min-height: 2.5rem; white-space: pre-wrap; font-size: .8rem; color: #93a0b4; }
.settings-form h3.full { margin: .5rem 0 0; padding-top: .75rem; border-top: 1px solid var(--border); color: #fff; }
.empty-state { text-align: center; padding: 3rem 1rem; }
audio { max-width: 260px; height: 32px; }

@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .two-col, .softphone-grid { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 10; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .form-grid { grid-template-columns: 1fr; }
}

.dial-label { display:block; margin:0 0 .35rem; color:#93a0b4; font-size:.85rem; }
.dial-display input {
  width:100%; box-sizing:border-box; padding:.75rem .9rem; border-radius:10px;
  border:1px solid var(--border); background:#0b1220; color:#fff;
  font-size:1.35rem; letter-spacing:.04em; text-align:center;
}
.dial-display input:focus { outline:2px solid #3b82f6; border-color:#3b82f6; }
