/* ============================================================
   Dialix PBX Console — Fluent design system (light/dark + density + accent)
   Restyles the existing SPA markup to the Microsoft-Fluent handoff look:
   mica/acrylic surfaces, layered depth, soft shadows, communication-blue accent.
   Token values mirror the design handoff styles.css.
   ============================================================ */

:root {
  --font-ui: "Inter", "Onest", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-serif: "Tiempos Text", "Georgia", "Times New Roman", ui-serif, serif;
  --font-mono: "JetBrains Mono", ui-monospace, "Cascadia Code", "SF Mono", monospace;
  --r-xs: 5px; --r-sm: 8px; --r-md: 10px; --r-lg: 14px; --r-xl: 18px; --r-2xl: 24px; --r-pill: 999px;
  --ease: cubic-bezier(.33,0,0,1); --ease-out: cubic-bezier(.16,1,.3,1); --dur: .18s;
}

/* density */
[data-density="comfortable"] { --fs:14px; --fs-sm:12.5px; --fs-xs:11.5px; --row-h:52px; --pad-card:22px; --gap:18px; --gap-sm:12px; --ctrl-h:36px; --nav-item-h:40px; }
[data-density="compact"]     { --fs:13px; --fs-sm:12px;   --fs-xs:11px;   --row-h:40px; --pad-card:16px; --gap:12px; --gap-sm:8px;  --ctrl-h:30px; --nav-item-h:34px; }

/* ── Light (Fluent, near-white canvas, blue accent) ── */
[data-theme="light"] {
  --accent:#2563EB; --accent-hover:#1d4ed8; --accent-press:#1e40af; --accent-fg:#fff;
  --accent-soft:rgba(37,99,235,.10); --accent-soft-2:rgba(37,99,235,.16); --accent-ring:rgba(37,99,235,.30);
  --mica-1:#f7f8fa; --mica-2:#f7f8fa; --tint-a:rgba(37,99,235,.04); --tint-b:rgba(37,99,235,.03);
  --bg-content:#f7f8fa; --surface:#ffffff; --surface-2:#f1f3f5;
  --surface-strong:#ffffff; --surface-hover:#f3f4f6;
  --acrylic:rgba(255,255,255,.86); --acrylic-nav:#f3f4f6;
  --text:#111827; --text-2:#6b7280; --text-3:#9ca3af;
  --stroke:#e5e7eb; --stroke-2:#d1d5db; --stroke-top:rgba(255,255,255,.7); --divider:#eef0f2;
  --ok:#16a34a; --ok-soft:rgba(22,163,74,.12); --warn:#d97706; --warn-soft:rgba(217,119,6,.13);
  --danger:#dc2626; --danger-soft:rgba(220,38,38,.12); --busy:#dc2626; --hold:#d97706;
  --purple:#7c3aed; --purple-soft:rgba(124,58,237,.12); --teal:#0891b2; --teal-soft:rgba(8,145,178,.12);
  --shadow-sm:0 1px 2px rgba(16,24,40,.04);
  --shadow-md:0 1px 2px rgba(16,24,40,.05),0 1px 3px rgba(16,24,40,.04);
  --shadow-lg:0 8px 28px rgba(16,24,40,.10),0 2px 6px rgba(16,24,40,.05);
  --shadow-pop:0 12px 40px rgba(16,24,40,.16);
}
/* ── Dark (deep navy/charcoal, blue accent) ── */
[data-theme="dark"] {
  --accent:#3b82f6; --accent-hover:#60a5fa; --accent-press:#2563eb; --accent-fg:#fff;
  --accent-soft:rgba(59,130,246,.16); --accent-soft-2:rgba(59,130,246,.24); --accent-ring:rgba(59,130,246,.38);
  --mica-1:#0f172a; --mica-2:#0b1220; --tint-a:rgba(59,130,246,.06); --tint-b:rgba(59,130,246,.04);
  --bg-content:#0f172a; --surface:#1e293b; --surface-2:#243244;
  --surface-strong:#1e293b; --surface-hover:#243244;
  --acrylic:rgba(15,23,42,.86); --acrylic-nav:#111c30;
  --text:#e5e7eb; --text-2:#94a3b8; --text-3:#64748b;
  --stroke:#1f2a3c; --stroke-2:#2c3a4f; --stroke-top:rgba(255,255,255,.04); --divider:#1b2536;
  --ok:#34d399; --ok-soft:rgba(52,211,153,.16); --warn:#fbbf24; --warn-soft:rgba(251,191,36,.16);
  --danger:#f87171; --danger-soft:rgba(248,113,113,.16); --busy:#f87171; --hold:#fbbf24;
  --purple:#a78bfa; --purple-soft:rgba(167,139,250,.16); --teal:#22d3ee; --teal-soft:rgba(34,211,238,.16);
  --shadow-sm:0 0 #0000;
  --shadow-md:0 0 #0000;
  --shadow-lg:0 10px 34px rgba(0,0,0,.5);
  --shadow-pop:0 16px 52px rgba(0,0,0,.6);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font-ui); font-size: var(--fs); color: var(--text);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; overflow: hidden;
}
::selection { background: var(--accent-soft-2); }
input::placeholder, textarea::placeholder { color: var(--text-3); }
a { color: var(--accent); text-decoration: none; }

/* Claude-style serif for display headings */
.section-head h1, .section-head h2, .section-head h3, .docs-body h2, .modal h3,
.login-card h1, .login-card h2, .login-brand-panel h2, .brand h1 {
  font-family: var(--font-serif); letter-spacing: -.01em; font-weight: 600;
}

/* mica desktop background */
.app {
  /* 100dvh follows the mobile browser's dynamic toolbar so the shell always
     fills the visible viewport (true full-screen); 100vh is the fallback. */
  position: relative; height: 100vh; height: 100dvh; display: grid; grid-template-columns: auto 1fr;
  background:
    radial-gradient(1100px 620px at 100% -8%, var(--tint-a), transparent 60%),
    radial-gradient(900px 540px at -6% 110%, var(--tint-b), transparent 58%),
    linear-gradient(160deg, var(--mica-1), var(--mica-2));
  isolation: isolate;
}

/* responsive: sidebar becomes a slide-over drawer on narrow screens.
   NOTE: these use `.app .sidebar` (specificity 0,2,0) on purpose. A media query
   adds NO specificity, so a plain `.sidebar` here (0,1,0) loses on source order
   to the base `.sidebar { position: relative }` rule declared later in this file
   — which left the drawer in-flow, pushing the whole page down below it instead
   of overlaying. The descendant selector outranks the base rule regardless of
   order, so the drawer reliably goes position:fixed. */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .app .sidebar { position: fixed; top: 0; bottom: 0; left: 0; z-index: 80; width: 248px;
    transform: translateX(-100%); transition: transform var(--dur) var(--ease); box-shadow: var(--shadow-lg); }
  .app .sidebar.open { transform: none; }
  .app .sidebar.collapsed { width: 248px; }
}

/* scrollbars */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--stroke-2); border-radius: 8px; border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: content-box; }

/* ================= SIDEBAR ================= */
.sidebar {
  position: relative; z-index: 5; width: 248px; display: flex; flex-direction: column;
  background: var(--acrylic-nav); -webkit-backdrop-filter: blur(40px) saturate(170%);
  backdrop-filter: blur(40px) saturate(170%); border-right: 1px solid var(--stroke);
  transition: width var(--dur) var(--ease); overflow: hidden;
}
.sidebar.collapsed { width: 60px; }
.brand { display: flex; align-items: center; gap: 11px; height: 56px; padding: 0 16px; flex-shrink: 0; }
.brand .logo-dot, .brand-mark {
  width: 30px; height: 30px; border-radius: 9px; flex-shrink: 0; display: grid; place-items: center; color: #fff;
  background: linear-gradient(150deg, var(--accent), var(--accent-press));
  box-shadow: 0 2px 8px var(--accent-ring), inset 0 1px 0 rgba(255,255,255,.4); font-weight: 800; font-size: 15px;
}
.brand h1 { margin: 0; font-weight: 700; font-size: 16px; letter-spacing: -.01em; white-space: nowrap; color: var(--text); }
.sidebar.collapsed .brand h1 { display: none; }

.nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 6px 10px; display: flex; flex-direction: column; gap: 1px; }
.nav-group { display: flex; flex-direction: column; gap: 1px; }
.nav-group-items { display: flex; flex-direction: column; gap: 1px; }
/* Category header doubles as a collapse toggle (a real <button>). */
.nav-section-label {
  display: flex; align-items: center; justify-content: space-between; gap: 6px; width: 100%;
  border: none; background: transparent; cursor: pointer; font-family: inherit;
  font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-3);
  font-weight: 600; padding: 14px 10px 6px; white-space: nowrap; transition: color var(--dur);
}
.nav-section-label:hover { color: var(--text-2); }
.nav-caret { font-size: 11px; line-height: 1; opacity: .7; transition: transform var(--dur); }
.nav-group.collapsed .nav-caret { transform: rotate(-90deg); }
.nav-group.collapsed .nav-group-items { display: none; }
.sidebar.collapsed .nav-section-label { opacity: 0; height: 8px; padding: 8px 0 0; pointer-events: none; }
.sidebar.collapsed .nav-caret { display: none; }
/* Icon-rail mode ignores per-category collapse so every icon stays reachable. */
.sidebar.collapsed .nav-group.collapsed .nav-group-items { display: flex; }
.nav a {
  position: relative; display: flex; align-items: center; gap: 12px; height: var(--nav-item-h); padding: 0 11px;
  border-radius: var(--r-md); cursor: pointer; color: var(--text-2); white-space: nowrap; user-select: none;
  font-size: var(--fs); font-weight: 500; transition: background var(--dur), color var(--dur);
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--surface-strong); color: var(--text); box-shadow: var(--shadow-sm); }
.nav a.active::before { content: ""; position: absolute; left: -10px; top: 50%; transform: translateY(-50%); width: 3px; height: 18px; border-radius: 3px; background: var(--accent); }
.nav a .ic { width: 20px; text-align: center; flex-shrink: 0; font-size: 15px; opacity: .85; }
.nav a.active .ic { color: var(--accent); opacity: 1; }
.sidebar.collapsed .nav a { padding: 0; justify-content: center; }
.sidebar.collapsed .nav a span:not(.ic), .sidebar.collapsed .nav a { font-size: 0; }
.sidebar.collapsed .nav a .ic { font-size: 16px; }

.userbox { padding: 10px 12px 14px; border-top: 1px solid var(--divider); flex-shrink: 0; }
.uname { font-weight: 650; font-size: var(--fs-sm); color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.urole { font-size: var(--fs-xs); color: var(--text-3); text-transform: capitalize; margin-bottom: 6px; }
.sidebar.collapsed .userbox { display: none; }
.qr-login {
  display: flex; align-items: center; gap: 10px; width: 100%; height: 36px; margin-top: 8px; padding: 0 11px;
  border-radius: var(--r-md); border: 1px solid var(--stroke); background: var(--surface-2); color: var(--text-2);
  font: inherit; font-size: var(--fs-sm); font-weight: 600; cursor: pointer; transition: all var(--dur);
}
.qr-login:hover { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

/* ================= COMMAND BAR ================= */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; z-index: 1; }
.topbar {
  height: 56px; flex-shrink: 0; display: flex; align-items: center; gap: 14px; padding: 0 18px 0 12px;
  background: var(--acrylic); -webkit-backdrop-filter: blur(36px) saturate(160%); backdrop-filter: blur(36px) saturate(160%);
  border-bottom: 1px solid var(--stroke);
}
.icon-btn {
  width: 34px; height: 34px; border-radius: var(--r-md); border: none; background: transparent; color: var(--text-2);
  cursor: pointer; display: grid; place-items: center; flex-shrink: 0; font-size: 16px; transition: background var(--dur), color var(--dur);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.on { background: var(--accent-soft); color: var(--accent); }
.topbar .title { font-size: 16px; font-weight: 650; letter-spacing: -.01em; white-space: nowrap; color: var(--text); }
.topbar .flex { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.status-pill {
  display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 10px; border-radius: var(--r-pill);
  background: var(--surface-2); border: 1px solid var(--stroke); color: var(--text-2); font-size: var(--fs-sm); font-weight: 600;
}
.status-pill select { font: inherit; font-weight: 600; }

/* accent swatch menu */
.accent-menu { display: inline-flex; gap: 6px; align-items: center; }
.accent-swatch { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--stroke); cursor: pointer; }
.accent-swatch.on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px currentColor; }

/* ================= CONTENT ================= */
.content { flex: 1; overflow-y: auto; overflow-x: hidden; min-height: 0; padding: var(--gap) 22px 40px; }
[data-density="compact"] .content { padding: var(--gap) 16px 32px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: var(--gap); flex-wrap: wrap; }
.section-head h2, .section-head h3 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.section-head .muted { font-size: var(--fs-sm); }

@media (prefers-reduced-motion: no-preference) {
  .content > * { animation: fadeUp .45s var(--ease-out) both; }
  @keyframes fadeUp { from { transform: translateY(7px); } to { transform: none; } }
}

/* ---- Card ---- */
.card {
  background: var(--surface); border: 1px solid var(--stroke); border-radius: var(--r-lg);
  box-shadow: var(--shadow-md); position: relative; padding: var(--pad-card); margin-bottom: var(--gap);
}
.card::before { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; border-top: 1px solid var(--stroke-top); -webkit-mask: linear-gradient(#000, transparent 40%); mask: linear-gradient(#000, transparent 40%); }
.card h3, .card h4 { margin: 0 0 12px; font-size: var(--fs); font-weight: 650; letter-spacing: -.005em; }

/* ---- grid ---- */
.grid { display: grid; gap: var(--gap); }
.cols-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
@media (max-width: 1100px) { .cols-3, .cols-4 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 720px) { .cols-2, .cols-3, .cols-4 { grid-template-columns: 1fr; } }

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: var(--ctrl-h); padding: 0 14px;
  border-radius: var(--r-md); font: inherit; font-size: var(--fs-sm); font-weight: 600; cursor: pointer;
  border: 1px solid var(--stroke-2); background: var(--surface-strong); color: var(--text); white-space: nowrap;
  box-shadow: var(--shadow-sm); transition: background var(--dur), border var(--dur), box-shadow var(--dur), transform .06s;
}
.btn:hover { background: var(--surface-hover); }
.btn:active { transform: translateY(.5px); }
.btn-sm { height: 28px; padding: 0 10px; font-size: var(--fs-xs); }
.btn-block { width: 100%; }
.btn-primary { background: linear-gradient(180deg, var(--accent-hover), var(--accent)); color: var(--accent-fg); border: 1px solid var(--accent-press); box-shadow: 0 1px 2px var(--accent-ring), inset 0 1px 0 rgba(255,255,255,.25); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { color: var(--danger); border-color: var(--danger-soft); }
.btn-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-call { background: var(--ok); color: #fff; border-color: transparent; }
.btn-call:hover { filter: brightness(1.07); }
.btn-hang { background: var(--danger); color: #fff; border-color: transparent; }
.btn-hang:hover { filter: brightness(1.07); }

/* ---- badges + status colors ---- */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 600; white-space: nowrap; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--stroke); }
.badge.green, .badge.available, .badge.success { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.red, .badge.busy, .badge.error, .badge.dnd { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge.amber, .badge.warn, .badge.wrap_up, .badge.break, .badge.hold { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.blue, .badge.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge.purple { background: var(--purple-soft); color: var(--purple); border-color: transparent; }

.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex-shrink: 0; background: var(--text-3); }
.dot.green, .dot.available, .dot.online { background: var(--ok); }
.dot.red, .dot.busy, .dot.dnd { background: var(--danger); }
.dot.amber, .dot.wrap_up, .dot.break, .dot.hold { background: var(--warn); }
.dot.blue { background: var(--accent); }
.dot.offline { background: var(--text-3); }

.status { font-size: var(--fs-xs); font-weight: 600; color: var(--text-2); }

/* ---- tables ---- */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: var(--fs-xs); font-weight: 600; color: var(--text-3); padding: 9px 12px; border-bottom: 1px solid var(--divider); white-space: nowrap; letter-spacing: .01em; }
td { padding: 10px 12px; border-bottom: 1px solid var(--divider); font-size: var(--fs-sm); vertical-align: middle; }
tbody tr { transition: background var(--dur); }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }
.mono, .num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ---- forms ---- */
.field { margin-bottom: 12px; display: flex; flex-direction: column; gap: 5px; }
.field > label, .label { font-size: var(--fs-xs); font-weight: 600; color: var(--text-2); }
.field .value, .value { font-size: var(--fs-sm); color: var(--text); }
input, select, textarea {
  width: 100%; height: var(--ctrl-h); padding: 0 10px; border-radius: var(--r-sm); border: 1px solid var(--stroke);
  background: var(--surface-2); color: var(--text); font: inherit; font-size: var(--fs-sm); outline: none;
  transition: border var(--dur), box-shadow var(--dur), background var(--dur);
}
textarea { height: auto; min-height: 70px; padding: 8px 10px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--surface-strong); }
select { -webkit-appearance: none; appearance: none; padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2385878e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center; }
input[type="checkbox"], input[type="radio"] { width: auto; height: auto; accent-color: var(--accent); }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: var(--gap-sm); }
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr; } }

/* ---- tabs ---- */
.tabs { display: inline-flex; background: var(--surface-2); border: 1px solid var(--stroke); border-radius: var(--r-md); padding: 2px; gap: 2px; margin-bottom: var(--gap); flex-wrap: wrap; }
.tab { height: 30px; padding: 0 14px; border: none; background: transparent; color: var(--text-2); font: inherit; font-size: var(--fs-sm); font-weight: 600; border-radius: var(--r-sm); cursor: pointer; transition: all var(--dur); }
.tab:hover { color: var(--text); }
.tab.active { background: var(--surface-strong); color: var(--text); box-shadow: var(--shadow-sm); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---- settings: header + left-sidebar category layout ---- */
.set-head { margin-bottom: var(--gap); }
.set-head h2 { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.set-head .muted { margin-top: 2px; font-size: var(--fs-sm); }
.set-layout { display: grid; grid-template-columns: 236px minmax(0, 1fr); gap: var(--gap); align-items: start; }
.set-nav { position: sticky; top: 12px; display: flex; flex-direction: column; gap: 2px; background: var(--surface); border: 1px solid var(--stroke); border-radius: var(--r-lg); padding: 8px; box-shadow: var(--shadow-sm); }
.set-navitem { display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 12px; border-radius: var(--r-sm); color: var(--text-2); font-size: var(--fs-sm); font-weight: 600; cursor: pointer; transition: all var(--dur); white-space: nowrap; }
.set-navitem .ic { width: 18px; text-align: center; opacity: .75; font-size: 14px; }
.set-navitem:hover { background: var(--surface-2); color: var(--text); }
.set-navitem.active { background: var(--accent-soft); color: var(--accent); }
.set-navitem.active .ic { opacity: 1; }
.set-body { min-width: 0; }
@media (max-width: 860px) {
  .set-layout { grid-template-columns: 1fr; }
  .set-nav { position: static; flex-direction: row; flex-wrap: wrap; }
}

/* ---- toggle switch (preferences) ---- */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--divider); cursor: pointer; }
.switch-row:last-child { border-bottom: none; }
.switch-row .sr-txt b { font-weight: 650; }
.switch-row .sr-txt div { color: var(--text-2); font-size: var(--fs-xs); margin-top: 2px; }
.switch { position: relative; flex-shrink: 0; width: 40px; height: 23px; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .track { position: absolute; inset: 0; background: var(--stroke-2); border-radius: 999px; transition: background var(--dur); }
.switch .track::before { content: ""; position: absolute; left: 2px; top: 2px; width: 19px; height: 19px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform var(--dur); }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::before { transform: translateX(17px); }

/* ---- stat / kpi ---- */
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat .value, .stat-value { font-size: 32px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1; }
.stat .label { font-size: var(--fs-sm); color: var(--text-2); font-weight: 500; }

/* ---- avatar ---- */
.avatar { width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center; color: #fff; font-weight: 600; font-size: 14px; background: linear-gradient(150deg, var(--purple), var(--accent)); box-shadow: inset 0 1px 0 rgba(255,255,255,.3); object-fit: cover; }
img.avatar { background: var(--surface-2); }

/* ---- user cards ---- */
.user-card { padding: var(--pad-card); }
.uc-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.uc-id { flex: 1; min-width: 0; }
.uc-name { font-weight: 650; }
.uc-email { font-size: var(--fs-sm); color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uc-rows { display: flex; flex-direction: column; gap: 8px; }
.uc-row { display: flex; justify-content: space-between; gap: 8px; font-size: var(--fs-sm); }
.uc-k { color: var(--text-3); }
.uc-v { text-align: right; color: var(--text); }
.uc-actions { display: flex; gap: 8px; justify-content: flex-end; border-top: 1px solid var(--divider); padding-top: 12px; margin-top: 12px; flex-wrap: wrap; }

/* ---- helpers ---- */
.muted { color: var(--text-3); }
.flex { display: flex; align-items: center; gap: var(--gap-sm); }
.right { margin-left: auto; }
.spacer { flex: 1; }
.hidden { display: none !important; }
.green { color: var(--ok); } .red { color: var(--danger); } .amber { color: var(--warn); } .blue { color: var(--accent); }
.empty { display: grid; place-items: center; gap: 10px; padding: 50px; color: var(--text-3); text-align: center; }
.qr-box { display: inline-block; padding: 14px; border-radius: var(--r-md); background: #fff; border: 1px solid var(--stroke); box-shadow: var(--shadow-sm); }

/* ---- modal ---- */
.modal-backdrop { position: fixed; inset: 0; z-index: 100; display: none; place-items: center; padding: 24px; background: rgba(10,12,18,.42); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.modal-backdrop.open { display: grid; }
.modal { position: relative; width: 520px; max-width: 100%; max-height: 86vh; overflow-y: auto; padding: 24px; border-radius: var(--r-xl); background: var(--acrylic); -webkit-backdrop-filter: blur(40px) saturate(180%); backdrop-filter: blur(40px) saturate(180%); border: 1px solid var(--stroke-2); box-shadow: var(--shadow-pop); }
.modal h3 { margin: 0 0 14px; font-size: 18px; font-weight: 700; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }

/* ---- toasts ---- */
.toast-wrap { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast { padding: 11px 16px; border-radius: var(--r-md); background: var(--surface-strong); border: 1px solid var(--stroke); box-shadow: var(--shadow-lg); font-size: var(--fs-sm); font-weight: 500; max-width: 340px; }
.toast.success { border-left: 3px solid var(--ok); }
.toast.error { border-left: 3px solid var(--danger); }

/* ================= CALL FLOW DESIGNER ================= */
.tint-accent { background: var(--accent-soft); color: var(--accent); }
.tint-ok { background: var(--ok-soft); color: var(--ok); }
.tint-warn { background: var(--warn-soft); color: var(--warn); }
.tint-danger { background: var(--danger-soft); color: var(--danger); }
.tint-purple { background: var(--purple-soft); color: var(--purple); }
.tint-teal { background: var(--teal-soft); color: var(--teal); }

.flow-grid { display: grid; grid-template-columns: 184px minmax(0,1fr) 300px; gap: var(--gap); align-items: start; }
@media (max-width: 1100px) { .flow-grid { grid-template-columns: 1fr; } }
.flow-palette { padding: 14px; }
.palette-group-label { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-3); font-weight: 600; margin-bottom: 8px; }
.palette-node { display: flex; align-items: center; gap: 10px; padding: 9px 10px; margin-bottom: 8px; border-radius: var(--r-md); border: 1px solid var(--stroke); background: var(--surface-2); cursor: grab; transition: all var(--dur); }
.palette-node:hover { background: var(--surface-strong); border-color: var(--accent); box-shadow: var(--shadow-sm); }
.palette-node:active { cursor: grabbing; transform: scale(.98); }
.pn-ic, .fn-ic { width: 28px; height: 28px; border-radius: var(--r-md); display: grid; place-items: center; font-size: 15px; flex-shrink: 0; }
.pn-label { font-weight: 600; font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.flow-canvas { overflow: auto; max-height: 70vh; }
.flow-surface { position: relative; width: 1600px; height: 900px; background-image: radial-gradient(var(--stroke) 1px, transparent 1px); background-size: 20px 20px; }
.flow-surface.drop { outline: 2px dashed var(--accent); outline-offset: -10px; }
.flow-edges { position: absolute; inset: 0; pointer-events: none; }
.flow-node { position: absolute; width: 172px; min-height: 58px; display: flex; align-items: center; gap: 9px; padding: 9px 11px; border-radius: var(--r-md); background: var(--surface-strong); border: 1.5px solid var(--stroke-2); box-shadow: var(--shadow-sm); cursor: grab; touch-action: none; user-select: none; }
.flow-node.sel { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-md); }
.fn-title { font-size: 12.5px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fn-sub { font-size: 10.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 110px; }
.port { position: absolute; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--stroke-2); top: 50%; transform: translateY(-50%); cursor: crosshair; }
.port-in { left: -7px; }
.port-out { right: -7px; }
.flow-node.sel .port { border-color: var(--accent); }
.port-out:hover { background: var(--accent); border-color: var(--accent); }
.flow-props { padding: 16px; position: sticky; top: 0; }
.prop-label { font-size: var(--fs-xs); font-weight: 600; color: var(--text-2); margin-bottom: 6px; }

/* ================= DOCS ================= */
.docs-grid { display: grid; grid-template-columns: 220px minmax(0,1fr); gap: var(--gap); align-items: start; }
@media (max-width: 900px) { .docs-grid { grid-template-columns: 1fr; } }
.docs-nav { padding: 8px; position: sticky; top: 0; display: flex; flex-direction: column; gap: 2px; }
.docs-link { display: block; padding: 9px 11px; border-radius: var(--r-md); color: var(--text-2); cursor: pointer; font-size: var(--fs-sm); font-weight: 500; }
.docs-link:hover { background: var(--surface-2); color: var(--text); }
.docs-link.active { background: var(--surface-strong); color: var(--text); box-shadow: var(--shadow-sm); }
.docs-link.active::before { content: ""; }
.docs-body { padding: 26px 30px; max-height: 78vh; overflow-y: auto; line-height: 1.6; }
.docs-body h2 { margin: 0 0 14px; font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
.docs-body h3 { margin: 22px 0 8px; font-size: 16px; font-weight: 650; }
.docs-body p { margin: 0 0 12px; color: var(--text); }
.docs-body ul { margin: 0 0 12px; padding-left: 20px; color: var(--text); }
.docs-body li { margin-bottom: 5px; }
.docs-body code { font-family: var(--font-mono); font-size: .86em; background: var(--surface-2); border: 1px solid var(--stroke); border-radius: var(--r-xs); padding: 1px 5px; }
.docs-body table { margin: 8px 0 14px; }
.docs-tip { background: var(--accent-soft); border-left: 3px solid var(--accent); border-radius: var(--r-sm); padding: 10px 12px !important; font-size: var(--fs-sm); }

/* ================= DIRECTORY ================= */
.dir-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.dir-card { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.dir-card .avatar { width: 40px; height: 40px; }
.dir-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dir-sub { font-size: var(--fs-xs); color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fav-star { cursor: pointer; color: var(--text-3); font-size: 16px; }
.fav-star.on { color: var(--warn); }

/* ================= SOFTPHONE ================= */
.softphone { position: fixed; right: 18px; bottom: 18px; z-index: 90; width: 300px; border-radius: var(--r-xl); background: var(--acrylic); -webkit-backdrop-filter: blur(40px) saturate(170%); backdrop-filter: blur(40px) saturate(170%); border: 1px solid var(--stroke-2); box-shadow: var(--shadow-pop); overflow: hidden; }
.sp-head { display: flex; align-items: center; justify-content: space-between; padding: 13px 16px; border-bottom: 1px solid var(--divider); font-weight: 650; }
.sp-body { padding: 16px; }
.sp-status { font-size: var(--fs-xs); color: var(--text-3); margin-bottom: 10px; }
.sp-dial { font-family: var(--font-mono); font-size: 18px; text-align: center; height: 42px; margin-bottom: 12px; }
.dialpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.dialpad button { height: 46px; border-radius: var(--r-md); border: 1px solid var(--stroke); background: var(--surface-2); color: var(--text); font-family: var(--font-mono); font-size: 18px; font-weight: 600; cursor: pointer; transition: all var(--dur); }
.dialpad button:hover { background: var(--surface-strong); border-color: var(--accent); }
.sp-actions { display: flex; gap: 8px; }
.sp-actions .btn { flex: 1; }

/* internal P2P phone widget */
.intphone { position: fixed; right: 18px; bottom: 18px; z-index: 95; width: 290px; padding: 16px; border-radius: var(--r-xl); background: var(--acrylic); -webkit-backdrop-filter: blur(40px) saturate(170%); backdrop-filter: blur(40px) saturate(170%); border: 1px solid var(--stroke-2); box-shadow: var(--shadow-pop); }
.ip-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.ip-name { font-size: 18px; font-weight: 700; margin-bottom: 14px; }
.ip-actions { display: flex; gap: 8px; }
.ip-actions .btn { flex: 1; }

/* ================= LOGIN ================= */
.login-stage, .login-body {
  height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(1100px 620px at 100% -8%, var(--tint-a), transparent 60%),
    radial-gradient(900px 540px at -6% 110%, var(--tint-b), transparent 58%),
    linear-gradient(160deg, var(--mica-1), var(--mica-2));
}
.login-card { width: 100%; max-width: 388px; padding: 32px; background: var(--surface); border: 1px solid var(--stroke); border-radius: var(--r-xl); box-shadow: var(--shadow-lg); -webkit-backdrop-filter: blur(30px) saturate(160%); backdrop-filter: blur(30px) saturate(160%); }
.login-card .brand, .login-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 6px; }
.login-card h1, .login-card h2 { margin: 0 0 4px; font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
.login-sub { color: var(--text-2); font-size: var(--fs-sm); margin-bottom: 22px; }
.login-error { color: var(--danger); font-size: var(--fs-sm); margin-top: 10px; }

/* ============================================================
   Re-skin: sidebar brand, footer, topbar search, dashboard KPIs,
   call-volume chart, live queues, trunk utilisation, recent calls.
   ============================================================ */

/* --- Sidebar brand block --- */
.brand-text { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.brand-sub { font-size: 9.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--text-3); font-weight: 600; margin-top: 2px; }
.sidebar.collapsed .brand-text { display: none; }

/* --- Sidebar footer (avatar + signout + mobile login) --- */
.userbox-row { display: flex; align-items: center; gap: 10px; }
.user-avatar {
  width: 32px; height: 32px; border-radius: 9px; flex-shrink: 0; display: grid; place-items: center;
  color: var(--accent-fg); font-weight: 700; font-size: 14px;
  background: linear-gradient(150deg, var(--accent), var(--accent-press));
}
.userbox-info { min-width: 0; flex: 1; }
.userbox-info .urole { margin-bottom: 0; }
.user-signout {
  width: 30px; height: 30px; border-radius: var(--r-md); display: grid; place-items: center; flex-shrink: 0;
  color: var(--text-3); text-decoration: none; font-size: 15px; transition: background var(--dur), color var(--dur);
}
.user-signout:hover { background: var(--danger-soft); color: var(--danger); }
.mobile-login-row {
  display: flex; align-items: center; gap: 12px; height: 36px; margin-top: 10px; padding: 0 11px;
  border-radius: var(--r-md); border: 1px solid var(--stroke); background: var(--surface-2);
  color: var(--text-2); font-size: var(--fs-sm); font-weight: 600; cursor: pointer; text-decoration: none;
  transition: background var(--dur), color var(--dur), border-color var(--dur);
}
.mobile-login-row .ic { width: 20px; text-align: center; }
.mobile-login-row:hover { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.sidebar.collapsed .mobile-login-row span:not(.ic) { display: none; }

/* --- Topbar title + search pill + bell --- */
.title-block { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.page-subtitle { font-size: var(--fs-xs); color: var(--text-3); font-weight: 500; }
.search-pill {
  display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 8px 0 11px; border-radius: var(--r-pill);
  background: var(--surface-2); border: 1px solid var(--stroke); color: var(--text-3); cursor: pointer;
  font: inherit; font-size: var(--fs-sm); transition: border-color var(--dur), background var(--dur);
}
.search-pill:hover { border-color: var(--accent-ring); }
.search-pill .search-ph { color: var(--text-3); }
.search-pill .kbd {
  font-size: 10px; font-weight: 600; color: var(--text-3); background: var(--surface);
  border: 1px solid var(--stroke); border-radius: var(--r-xs); padding: 1px 5px;
}
@media (max-width: 860px) { .search-pill .search-ph, .search-pill .kbd { display: none; } }

/* --- Command palette --- */
.palette-input { width: 100%; height: 38px; margin: 6px 0 10px; }
.palette-list { display: flex; flex-direction: column; gap: 2px; max-height: 320px; overflow-y: auto; }
.palette-item {
  display: block; padding: 9px 11px; border-radius: var(--r-md); color: var(--text-2);
  text-decoration: none; font-size: var(--fs); font-weight: 500;
}
.palette-item:hover { background: var(--accent-soft); color: var(--accent); }

/* --- Dashboard header --- */
.dash-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: var(--gap); flex-wrap: wrap; }
.dash-head h2 { font-family: var(--font-ui); font-size: 20px; font-weight: 700; letter-spacing: -.02em; margin: 0 0 2px; }
.dash-head .muted { font-size: var(--fs-sm); }

/* --- KPI cards --- */
.kpi-grid { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: var(--gap); }
@media (max-width: 1100px) { .kpi-grid { grid-template-columns: repeat(3, minmax(0,1fr)); } }
@media (max-width: 720px)  { .kpi-grid { grid-template-columns: repeat(2, minmax(0,1fr)); } }
.kpi {
  position: relative; background: var(--surface); border: 1px solid var(--stroke); border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm); padding: 16px;
}
.kpi-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.kpi-chip { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; font-size: 17px; }
.kpi-num { font-size: 26px; font-weight: 700; letter-spacing: -.02em; color: var(--text); font-variant-numeric: tabular-nums; }
.kpi-label { font-size: var(--fs-sm); font-weight: 600; color: var(--text); margin-top: 2px; }
.kpi-sub { font-size: var(--fs-xs); color: var(--text-3); margin-top: 3px; }
.kpi-badge { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 8px; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 600; }
.kpi-badge.live { background: var(--danger-soft); color: var(--danger); }
.kpi-badge.live .dot { width: 7px; height: 7px; background: var(--danger); animation: dxpulse 1.4s infinite; }
.kpi-badge.pos { background: var(--ok-soft); color: var(--ok); }
.kpi-badge.neg { background: var(--warn-soft); color: var(--warn); }
@keyframes dxpulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
/* tones drive the icon-chip tint */
.tone-primary   .kpi-chip { background: var(--accent-soft); color: var(--accent); }
.tone-positive  .kpi-chip { background: var(--ok-soft); color: var(--ok); }
.tone-attention .kpi-chip { background: var(--danger-soft); color: var(--danger); }
.tone-time      .kpi-chip { background: var(--warn-soft); color: var(--warn); }
.tone-neutral   .kpi-chip { background: var(--surface-2); color: var(--text-2); }
.tone-purple    .kpi-chip { background: var(--purple-soft); color: var(--purple); }

/* --- Card head (title + controls) --- */
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h3 { margin: 0; }

/* --- Segmented range toggle --- */
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--stroke); border-radius: var(--r-md); padding: 2px; gap: 2px; }
.seg button { border: none; background: transparent; color: var(--text-2); font: inherit; font-size: var(--fs-xs); font-weight: 600; padding: 4px 10px; border-radius: var(--r-sm); cursor: pointer; }
.seg button.active { background: var(--accent); color: var(--accent-fg); }

/* --- Call-volume chart --- */
.chart-stats { display: flex; gap: 22px; margin-bottom: 16px; flex-wrap: wrap; }
.cs { display: flex; flex-direction: column; }
.cs-num { font-size: 18px; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.cs-num.pos { color: var(--ok); }
.cs-num.neg { color: var(--danger); }
.cs-lbl { font-size: var(--fs-xs); color: var(--text-3); }
.chart { display: flex; align-items: flex-end; gap: 6px; height: 160px; }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; min-width: 0; }
.chart-bar { width: 100%; max-width: 28px; border-radius: 5px 5px 2px 2px; background: var(--accent-soft-2); transition: height var(--dur) var(--ease), background var(--dur); }
.chart-col:hover .chart-bar { background: var(--accent-ring); }
.chart-bar.active { background: var(--accent); }
.chart-x { font-size: 9.5px; color: var(--text-3); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* --- Progress bar (queues, trunk utilisation) --- */
.bar { height: 6px; border-radius: var(--r-pill); background: var(--surface-2); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width var(--dur) var(--ease); }

/* --- Live queues --- */
.queue-list { display: flex; flex-direction: column; gap: 14px; }
.queue-row { display: flex; align-items: center; gap: 12px; }
.queue-ring { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; }
.queue-ring.idle { background: var(--surface-2); color: var(--text-3); box-shadow: inset 0 0 0 2px var(--stroke); }
.queue-ring.busy { background: var(--warn-soft); color: var(--warn); box-shadow: inset 0 0 0 2px var(--warn); }
.queue-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.queue-name { font-size: var(--fs-sm); font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* --- Trunk utilisation rows --- */
.util-row { margin-bottom: 14px; }
.util-row:last-child { margin-bottom: 0; }
.util-head { display: flex; justify-content: space-between; font-size: var(--fs-sm); font-weight: 600; margin-bottom: 7px; }
.util-head .muted { font-weight: 500; font-size: var(--fs-xs); }

/* --- Recent calls --- */
.recent-list { display: flex; flex-direction: column; }
.recent-row { display: flex; align-items: center; gap: 11px; padding: 9px 0; border-bottom: 1px solid var(--divider); }
.recent-row:last-child { border-bottom: none; }
.dir-ic { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; flex-shrink: 0; font-size: 14px; font-weight: 700; }
.dir-ic.in { background: var(--accent-soft); color: var(--accent); }
.dir-ic.out { background: var(--purple-soft); color: var(--purple); }
.recent-meta { flex: 1; min-width: 0; }
.recent-name { font-size: var(--fs-sm); font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-sub { font-size: var(--fs-xs); color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-time { font-size: var(--fs-xs); color: var(--text-3); white-space: nowrap; flex-shrink: 0; }

/* --- Agent status counts --- */
.agent-list { display: flex; flex-direction: column; }
.agent-stat { display: flex; align-items: center; gap: 9px; padding: 9px 0; border-bottom: 1px solid var(--divider); font-size: var(--fs-sm); color: var(--text-2); }
.agent-stat b { color: var(--text); font-variant-numeric: tabular-nums; font-size: var(--fs); }
.agent-stat.total { border-bottom: none; font-weight: 600; color: var(--text); }

/* ============================================================
   Live Call Monitor + Call Queues & Ring Groups (page restyles)
   ============================================================ */

/* shared page header + section labels */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: var(--gap); flex-wrap: wrap; }
.page-head-titles h2 { font-family: var(--font-ui); font-size: 20px; font-weight: 700; letter-spacing: -.02em; margin: 0 0 2px; }
.page-head-titles .muted { font-size: var(--fs-sm); max-width: 60ch; }
.sect-label { font-size: 11px; letter-spacing: .09em; text-transform: uppercase; color: var(--text-3); font-weight: 700; margin: 0 0 12px 2px; }
.divider { height: 1px; background: var(--divider); margin: 16px 0; border: 0; }
.dot-pulse .dot { animation: dxpulse 1.4s infinite; }

/* small status pill with a colored dot */
.spill { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 600; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.spill.green { background: var(--ok-soft); color: var(--ok); }
.spill.blue { background: var(--accent-soft); color: var(--accent); }
.spill.amber { background: var(--warn-soft); color: var(--warn); }

/* round icon button (row actions / "···") */
.iconbtn { width: 30px; height: 30px; border-radius: var(--r-md); border: 1px solid var(--stroke); background: var(--surface); color: var(--text-2); cursor: pointer; font-size: 14px; display: inline-grid; place-items: center; transition: all var(--dur); }
.iconbtn:hover { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

/* ---- Live Call Monitor ---- */
.live-pill { letter-spacing: .04em; }
.live-grid { display: grid; grid-template-columns: minmax(0,1fr) 340px; gap: var(--gap); align-items: start; }
@media (max-width: 1080px) { .live-grid { grid-template-columns: 1fr; } }
.live-left { display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }
.ls-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.ls-head h3 { margin: 0; }
.ls-counts { font-size: var(--fs-xs); margin-top: 2px; }
.live-table { width: 100%; }
.live-row { cursor: pointer; transition: background var(--dur); }
.live-row:hover { background: var(--surface-2); }
.live-row.sel { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.party { display: flex; align-items: center; gap: 9px; }
.party-name { font-weight: 600; color: var(--text); white-space: nowrap; }
.party-sub { font-size: var(--fs-xs); color: var(--text-3); text-transform: capitalize; }
.row-acts { display: inline-flex; gap: 6px; justify-content: flex-end; }
.live-empty { padding: 44px; }
.empty-ic, .ctl-empty-ic { font-size: 30px; opacity: .5; }

/* Call Control panel */
.ctl-card { position: sticky; top: 12px; }
.ctl-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.ctl-label { font-size: 11px; letter-spacing: .09em; text-transform: uppercase; color: var(--text-3); font-weight: 700; }
.ctl-id { text-align: center; padding: 6px 0 14px; }
.ctl-avatar { width: 60px; height: 60px; border-radius: 50%; margin: 0 auto 10px; display: grid; place-items: center; font-weight: 700; font-size: 20px; color: var(--accent-fg); background: linear-gradient(150deg, var(--accent), var(--accent-press)); }
.ctl-name { font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.ctl-num { font-size: var(--fs-xs); margin-top: 2px; }
.ctl-timer { font-family: var(--font-mono); font-size: 26px; font-weight: 600; margin: 10px 0 4px; font-variant-numeric: tabular-nums; }
.ctl-route { font-size: var(--fs-sm); }
.ctl-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.ctl-tile { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 4px; border: 1px solid var(--stroke); border-radius: var(--r-md); background: var(--surface); color: var(--text-2); font: inherit; font-size: var(--fs-xs); font-weight: 600; cursor: pointer; transition: all var(--dur); }
.ctl-tile:hover:not([disabled]) { border-color: var(--accent-ring); background: var(--accent-soft); color: var(--accent); }
.ctl-tile[disabled] { opacity: .45; cursor: not-allowed; }
.ctl-ic { font-size: 18px; color: var(--accent); }
.ctl-end { width: 100%; justify-content: center; }
.ctl-secondary { display: flex; gap: 8px; margin-top: 10px; }
.ctl-secondary .btn { flex: 1; }
.ctl-empty { text-align: center; padding: 40px 10px; display: flex; flex-direction: column; gap: 8px; align-items: center; color: var(--text-3); }
.kv { display: flex; flex-direction: column; gap: 10px; }
.kv-row { display: flex; align-items: center; justify-content: space-between; font-size: var(--fs-sm); }
.kv-k { color: var(--text-3); }
.kv-v { font-weight: 600; color: var(--text); }

/* avatar stacks */
.avstack { display: inline-flex; align-items: center; }
.av-sm { width: 26px; height: 26px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 10px; font-weight: 700; color: var(--accent-fg); background: linear-gradient(150deg, var(--accent), var(--accent-press)); border: 2px solid var(--surface); margin-left: -8px; }
.av-sm:first-child { margin-left: 0; }
.av-sm.more { background: var(--surface-2); color: var(--text-2); }

/* ---- Call Queues & Ring Groups ---- */
.qgrid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: var(--gap); }
@media (max-width: 1100px) { .qgrid { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 720px) { .qgrid { grid-template-columns: 1fr; } }
.qcard { margin-bottom: 0; }
.qc-head { display: flex; align-items: flex-start; gap: 11px; margin-bottom: 16px; }
.qc-id { flex: 1; min-width: 0; }
.qc-name { font-weight: 700; font-size: 15px; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qc-sub { font-size: var(--fs-xs); margin-top: 2px; }
.qc-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.qc-stat { text-align: left; }
.qc-num { font-size: 22px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.qc-num.warn { color: var(--warn); }
.qc-lbl { font-size: var(--fs-xs); color: var(--text-3); }
.qc-sla { margin-bottom: 14px; }
.qc-sla-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 7px; font-size: var(--fs-xs); }
.qc-sla-pct { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.qc-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 14px; border-top: 1px solid var(--divider); }
.qc-members { display: flex; align-items: center; gap: 8px; min-width: 0; }
.qc-free { font-size: var(--fs-xs); white-space: nowrap; }
.qc-manage { font-size: var(--fs-sm); font-weight: 600; color: var(--accent); white-space: nowrap; }
.qc-manage:hover { text-decoration: underline; }

/* ring groups table */
.rg-card { overflow-x: auto; }
.rg-group { display: flex; align-items: center; gap: 10px; }
.rg-mem { display: flex; align-items: center; gap: 8px; }
.kpi-chip.sm { width: 28px; height: 28px; border-radius: 8px; font-size: 13px; }
.rg-dots { font-weight: 700; letter-spacing: 1px; }

/* Collapsible "Advanced options" blocks (SIP trunk, etc.) */
.adv-block { border: 1px solid var(--stroke); border-radius: var(--r-md); padding: 0 12px; background: var(--surface-2); }
.adv-block > summary { cursor: pointer; padding: 11px 0; font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); list-style: none; }
.adv-block > summary::-webkit-details-marker { display: none; }
.adv-block > summary::before { content: "▸ "; color: var(--text-3); }
.adv-block[open] > summary::before { content: "▾ "; }
.adv-block[open] { padding-bottom: 12px; }

/* ================= PEOPLE (Directory + Customers + Users merged) ================= */
/* Full-width segmented tab bar; scrolls horizontally instead of wrapping on phones. */
.people-tabs { display: flex; flex-wrap: nowrap; width: 100%; gap: 2px; margin-bottom: var(--gap); overflow-x: auto; scrollbar-width: none; }
.people-tabs::-webkit-scrollbar { display: none; }
.people-tabs .tab { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 7px; height: 34px; }
.people-tabs .ptab-ic { font-size: 14px; opacity: .9; }
.people-hint { font-size: var(--fs-sm); margin: -2px 0 14px; }
.people-toolbar { margin-top: 2px; }
.people-body { min-width: 0; }

/* ================= MOBILE / RESPONSIVE POLISH ================= */
/* Dim scrim behind the slide-over sidebar drawer (tap to close). */
.scrim { display: none; position: fixed; inset: 0; z-index: 70; background: rgba(10,12,18,.44);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); opacity: 0; transition: opacity var(--dur) var(--ease); }
.scrim.open { display: block; opacity: 1; }

@media (max-width: 860px) {
  /* Full-screen safe areas: when launched from the home screen the shell runs
     edge-to-edge, so keep the topbar clear of the notch and content clear of
     the home indicator (env() is 0 on devices without insets). */
  .content { padding: var(--gap) calc(14px + env(safe-area-inset-right)) calc(40px + env(safe-area-inset-bottom)) calc(14px + env(safe-area-inset-left)); }
  [data-density="compact"] .content { padding: var(--gap) calc(12px + env(safe-area-inset-right)) calc(32px + env(safe-area-inset-bottom)) calc(12px + env(safe-area-inset-left)); }

  /* Topbar: keep the essentials, drop the noise so controls never overflow. */
  .topbar { height: auto; min-height: 56px; gap: 8px;
    padding: env(safe-area-inset-top) calc(12px + env(safe-area-inset-right)) 0 calc(8px + env(safe-area-inset-left)); }
  .sidebar { padding-top: env(safe-area-inset-top); }
  .topbar .flex { gap: 6px; }
  .page-subtitle { display: none; }
  .topbar .title { font-size: 15px; overflow: hidden; text-overflow: ellipsis; }
  #accent-menu, #density-toggle, #ws-state { display: none; }
  .status-pill { padding: 0 6px; }
  .status-pill select { max-width: 96px; }
  /* Bigger, thumb-friendly hit targets for the icon buttons. */
  .icon-btn { width: 38px; height: 38px; font-size: 17px; }
  #nav-collapse { margin-right: 2px; }

  /* Section headers stack their toolbars under the title. */
  .section-head { gap: 10px; }
  .section-head .flex, .section-head .form-row { width: 100%; }
  .section-head .btn, .people-toolbar .btn { flex: 1; }

  /* Wide tables scroll horizontally within their card instead of clipping. */
  .card > table, .card > .rg-card > table, #cust-tbl > table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: nowrap; }

  /* Comfortable tap size for controls and buttons in forms/modals. */
  .btn { min-height: 38px; }
  input, select, textarea { min-height: 40px; }
  .modal { padding: 20px; border-radius: var(--r-lg); }
  .modal-actions .btn { flex: 1; }

  /* Softphone widget becomes a bottom sheet rather than a floating card. */
  .softphone { left: calc(10px + env(safe-area-inset-left)); right: calc(10px + env(safe-area-inset-right));
    bottom: calc(10px + env(safe-area-inset-bottom)); width: auto; max-width: none; }
}

@media (max-width: 520px) {
  /* Free up room so the page title isn't crushed to an ellipsis by the
     right-side controls. Bell + softphone toggle are reachable elsewhere. */
  #notif-bell, #sp-toggle { display: none; }
  .status-pill select { max-width: 84px; }

  /* Single-column people/directory cards; buttons wrap gracefully. */
  .dir-grid { grid-template-columns: 1fr; }
  .uc-actions { justify-content: stretch; }
  .uc-actions .btn { flex: 1; }
  .people-tabs .tab { flex: 1 0 auto; justify-content: center; }
}
