/* CERC Phone — design system
   Brand colours: CERC amber #eca327, navy #3b3a5e, warm neutrals. UI type: Plus Jakarta Sans. */
:root {
  --brand: #eca327; --brand-strong: #c27a0e; --brand-soft: #fdf3e0; --on-brand: #27273e;
  --navy: #3b3a5e; --navy-dk: #27273e; --navy-xdk: #1c1c30;
  --coral: #e85b15; --coral-soft: #fde9df;
  --green: #2f8f63; --green-soft: #e3f4ec;
  --blue: #2f7f99; --blue-soft: #e2f1f6;
  --purple: #a24f96;
  --bg: #f6f6f4; --surface: #ffffff; --surface-2: #f3f1ea; --surface-3: #ebe8de;
  --border: #e3e3e7; --border-strong: #cfcfd8;
  --text: #2a2940; --text-2: #4d4c63; --muted: #6b6a80;
  --st-available: #2f8f63; --st-oncall: #e85b15; --st-wrapup: #c27a0e; --st-away: #8a89a0; --st-offline: #c3c3cc;
  --chart-bar: #c27a0e; --chart-grid: #ececf0;
  --shadow-1: 0 1px 2px rgba(39,39,62,.06), 0 1px 3px rgba(39,39,62,.06);
  --shadow-2: 0 6px 24px rgba(39,39,62,.10);
  --shadow-3: 0 18px 50px rgba(39,39,62,.22);
  --radius: 14px; --radius-sm: 10px; --radius-lg: 20px;
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --sidebar-w: 248px; --phone-w: 360px; --topbar-h: 64px; --tabbar-h: 64px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --brand-soft: #3a3020; --on-brand: #1c1c30;
  --coral-soft: #3d2620; --green-soft: #1d3a2f; --blue-soft: #1c3440;
  --bg: #15152a; --surface: #1f1f38; --surface-2: #26264a; --surface-3: #30305a;
  --border: #33335a; --border-strong: #45456e;
  --text: #ededf5; --text-2: #c9c9dc; --muted: #9c9cb8;
  --st-offline: #55557a; --chart-grid: #2c2c50;
  --shadow-1: 0 1px 2px rgba(0,0,0,.3); --shadow-2: 0 8px 28px rgba(0,0,0,.35); --shadow-3: 0 18px 50px rgba(0,0,0,.5);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand-soft: #3a3020; --on-brand: #1c1c30;
    --coral-soft: #3d2620; --green-soft: #1d3a2f; --blue-soft: #1c3440;
    --bg: #15152a; --surface: #1f1f38; --surface-2: #26264a; --surface-3: #30305a;
    --border: #33335a; --border-strong: #45456e;
    --text: #ededf5; --text-2: #c9c9dc; --muted: #9c9cb8;
    --st-offline: #55557a; --chart-grid: #2c2c50;
    --shadow-1: 0 1px 2px rgba(0,0,0,.3); --shadow-2: 0 8px 28px rgba(0,0,0,.35); --shadow-3: 0 18px 50px rgba(0,0,0,.5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 400 14.5px/1.5 var(--font); -webkit-font-smoothing: antialiased; letter-spacing: -.005em; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: var(--brand-strong); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg.i { width: 20px; height: 20px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
svg.i.sm { width: 16px; height: 16px; }
svg.i.lg { width: 24px; height: 24px; }
.tnum { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }

/* ---------- buttons & inputs ---------- */
.btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 10px; font-weight: 600; white-space: nowrap; transition: background .15s, box-shadow .15s, transform .05s; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: var(--on-brand); }
.btn-primary:hover { background: #f0b043; }
.btn-navy { background: var(--navy); color: #fff; }
.btn-navy:hover { background: var(--navy-dk); }
.btn-ghost { background: var(--surface-2); color: var(--text); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-outline { border: 1px solid var(--border-strong); background: var(--surface); }
.btn-outline:hover { background: var(--surface-2); }
.btn-danger { background: var(--coral); color: #fff; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 14px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.icon-btn { width: 36px; height: 36px; border-radius: 10px; display: inline-grid; place-items: center; color: var(--text-2); }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--text-2); }
.input, select.input, textarea.input { width: 100%; height: 42px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); outline: none; transition: border-color .15s, box-shadow .15s; }
textarea.input { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 25%, transparent); }
.input-icon { position: relative; }
.input-icon > svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-icon > .input { padding-left: 38px; }
.switch { position: relative; width: 42px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--border-strong); border-radius: 12px; transition: background .2s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: var(--shadow-1); }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(18px); }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 15px; background: var(--surface-2); color: var(--text-2); font-size: 13px; font-weight: 600; border: 1px solid transparent; }
.chip:hover { background: var(--surface-3); }
.chip.on { background: var(--navy); color: #fff; }
:root[data-theme="dark"] .chip.on { background: var(--brand); color: var(--on-brand); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--coral); color: #fff; font-size: 11px; font-weight: 700; }
.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--text-2); }
.tag.brand { background: var(--brand-soft); color: var(--brand-strong); }
.tag.green { background: var(--green-soft); color: var(--green); }
.tag.coral { background: var(--coral-soft); color: var(--coral); }
.tag.blue { background: var(--blue-soft); color: var(--blue); }

/* ---------- avatar & presence ---------- */
.avatar { position: relative; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 14px; color: #fff; background: var(--navy); flex-shrink: 0; letter-spacing: .3px; }
.avatar.sm { width: 32px; height: 32px; font-size: 12px; }
.avatar.lg { width: 72px; height: 72px; font-size: 24px; }
.avatar.xl { width: 96px; height: 96px; font-size: 32px; }
.avatar.ext { background: var(--surface-3); color: var(--text-2); }
.avatar .dot { position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--surface); background: var(--st-offline); }
.dot.available { background: var(--st-available) !important; }
.dot.oncall { background: var(--st-oncall) !important; }
.dot.wrapup { background: var(--st-wrapup) !important; }
.dot.away { background: var(--st-away) !important; }
.dot.offline { background: var(--st-offline) !important; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.status-pill .dot { position: static; width: 9px; height: 9px; border: 0; border-radius: 50%; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(420px, 1.05fr) 1fr; background: var(--surface); }
.login-brand { position: relative; overflow: hidden; background: radial-gradient(1200px 600px at -10% 110%, #4b4a78 0%, transparent 60%), var(--navy-dk); color: #fff; padding: 48px 56px; display: flex; flex-direction: column; }
.login-brand::after { content: ""; position: absolute; right: -120px; top: -120px; width: 420px; height: 420px; border-radius: 50%; border: 60px solid rgba(236,163,39,.12); }
.login-logo { display: flex; align-items: center; gap: 14px; position: relative; z-index: 1; }
.login-logo img { width: 52px; height: 52px; background: #fff; border-radius: 14px; padding: 6px; }
.login-logo b { display: block; font-size: 20px; letter-spacing: .4px; }
.login-logo small { color: #c8c8de; font-size: 13px; }
.login-hero { margin: auto 0; position: relative; z-index: 1; max-width: 520px; }
.login-hero .kicker { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; letter-spacing: 1.4px; text-transform: uppercase; color: var(--brand); background: rgba(236,163,39,.12); padding: 6px 12px; border-radius: 20px; }
.login-hero h1 { font-size: clamp(30px, 3vw, 44px); line-height: 1.12; margin: 18px 0 16px; font-weight: 800; letter-spacing: -.02em; }
.login-hero p { color: #d3d3e6; font-size: 17px; margin: 0 0 28px; }
.login-features { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 22px; padding: 0; margin: 0; list-style: none; }
.login-features li { display: flex; gap: 10px; align-items: flex-start; color: #e7e7f3; font-size: 15px; }
.login-features svg { color: var(--brand); margin-top: 1px; }
.login-foot { position: relative; z-index: 1; color: #a9a9c6; font-size: 13px; }
.login-main { display: flex; flex-direction: column; padding: 28px 32px; }
.login-top { display: flex; justify-content: flex-end; gap: 8px; }
.login-card { width: 100%; max-width: 400px; margin: auto; }
.login-card .mobile-logo { display: none; }
.login-card h2 { font-size: 28px; margin: 0 0 6px; font-weight: 800; letter-spacing: -.02em; }
.login-card p.sub { color: var(--muted); margin: 0 0 28px; }
.login-card form { display: grid; gap: 16px; }
.login-card .pw { position: relative; }
.login-card .pw .input { padding-right: 44px; }
.login-card .pw button { position: absolute; right: 4px; top: 3px; }
.login-row { display: flex; align-items: center; justify-content: space-between; font-size: 14px; }
.login-row label { display: flex; gap: 8px; align-items: center; color: var(--text-2); }
.login-error { display: flex; gap: 8px; align-items: center; background: var(--coral-soft); color: var(--coral); border-radius: 10px; padding: 10px 12px; font-size: 14px; font-weight: 600; }
.login-help { margin-top: 22px; text-align: center; font-size: 14px; color: var(--muted); }
.login-btn { height: 48px; font-size: 16px; }

/* ---------- app shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--phone-w); height: 100vh; height: 100dvh; }
.sidebar { background: var(--navy-dk); color: #d9d9ea; display: flex; flex-direction: column; padding: 18px 14px; gap: 6px; min-height: 0; }
:root[data-theme="dark"] .sidebar { background: var(--navy-xdk); }
.brandmark { display: flex; align-items: center; gap: 12px; padding: 4px 8px 18px; color: #fff; text-decoration: none; }
.brandmark img { width: 38px; height: 38px; background: #fff; border-radius: 11px; padding: 4px; }
.brandmark b { display: block; font-size: 17px; letter-spacing: .3px; line-height: 1.1; }
.brandmark small { color: #a9a9c6; font-size: 12px; }
.nav { display: grid; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 12px; height: 42px; padding: 0 12px; border-radius: 10px; color: #c9c9de; text-decoration: none; font-weight: 600; position: relative; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: rgba(236,163,39,.16); color: #fff; }
.nav a.active::before { content: ""; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 4px; border-radius: 0 4px 4px 0; background: var(--brand); }
.nav a .badge { margin-left: auto; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px; color: #8686a8; padding: 14px 12px 6px; font-weight: 700; }
.sidebar .spacer { flex: 1; }
.me-card { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; background: rgba(255,255,255,.05); }
.me-card .avatar .dot { border-color: var(--navy-dk); }
.me-card .who { min-width: 0; flex: 1; }
.me-card .who b { display: block; color: #fff; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-card select { background: transparent; border: 0; color: #c9c9de; font-size: 12px; padding: 0; cursor: pointer; }
.me-card select option { color: #000; }
.me-card .icon-btn { color: #c9c9de; }
.me-card .icon-btn:hover { background: rgba(255,255,255,.08); color: #fff; }

.main { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.topbar { height: var(--topbar-h); display: flex; align-items: center; gap: 12px; padding: 0 24px; border-bottom: 1px solid var(--border); background: var(--surface); flex-shrink: 0; }
.topbar h1 { font-size: 20px; margin: 0; font-weight: 700; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .mobile-only { display: none; }
.view { flex: 1; overflow: auto; padding: 24px; min-height: 0; container-type: inline-size; container-name: view; }
.view.flush { padding: 0; overflow: hidden; display: flex; }
.conn-banner { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--brand-soft); color: var(--brand-strong); font-weight: 600; font-size: 14px; border-bottom: 1px solid var(--border); }
.conn-banner.error { background: var(--coral-soft); color: var(--coral); }
.conn-banner button { margin-left: auto; }

/* ---------- cards & widgets ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-1); }
.card-h { display: flex; align-items: center; gap: 10px; padding: 16px 18px 10px; }
.card-h h3 { margin: 0; font-size: 16px; font-weight: 700; flex: 1; }
.card-h .sub { font-size: 13px; color: var(--muted); }
.card-b { padding: 6px 18px 18px; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; font-size: 14px; }
.empty svg { width: 34px; height: 34px; color: var(--border-strong); display: block; margin: 0 auto 8px; }
.greeting { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.greeting h2 { margin: 0; font-size: 26px; }
.greeting h2 { letter-spacing: -.02em; font-weight: 800; }
.greeting h2 em { font-style: normal; color: var(--brand-strong); }
.greeting p { margin: 2px 0 0; color: var(--muted); }
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { padding: 16px 18px; display: grid; gap: 4px; }
.kpi .label { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.kpi .label svg { width: 28px; height: 28px; padding: 6px; border-radius: 8px; background: var(--surface-2); color: var(--text-2); }
.kpi .value { font-size: 28px; font-weight: 800; line-height: 1.1; letter-spacing: -.02em; }
.kpi .hint { font-size: 12px; color: var(--muted); }
.kpi.alert .label svg { background: var(--coral-soft); color: var(--coral); }
.kpi.good .label svg { background: var(--green-soft); color: var(--green); }
.kpi.brand .label svg { background: var(--brand-soft); color: var(--brand-strong); }
.kpi.blue .label svg { background: var(--blue-soft); color: var(--blue); }
.widgets { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 18px; }
.w-8 { grid-column: span 8; } .w-6 { grid-column: span 6; } .w-4 { grid-column: span 4; } .w-12 { grid-column: span 12; }

/* rows used in lists & widgets */
.rows { display: grid; }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); min-width: 0; }
.rows .row:first-child { border-top: 0; }
.row .main-col { flex: 1; min-width: 0; }
.row .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; gap: 8px; align-items: center; }
.row .s { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .meta { font-size: 12px; color: var(--muted); text-align: right; flex-shrink: 0; }
.row .acts { display: flex; gap: 4px; flex-shrink: 0; }
.dir-ic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; background: var(--surface-2); color: var(--text-2); }
.dir-ic.in { background: var(--green-soft); color: var(--green); }
.dir-ic.out { background: var(--blue-soft); color: var(--blue); }
.dir-ic.missed { background: var(--coral-soft); color: var(--coral); }
.dir-ic.vm { background: var(--brand-soft); color: var(--brand-strong); }
.missed-t { color: var(--coral); }

/* queue widget */
.queue-stat { display: flex; gap: 14px; margin-bottom: 8px; }
.queue-stat div { flex: 1; background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.queue-stat b { display: block; font-size: 24px; }
.queue-stat span { font-size: 12px; color: var(--muted); font-weight: 600; }
.waiting-row .wait { font-weight: 700; color: var(--coral); }

/* chart */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: 220px; overflow: visible; }
.chart .bar { fill: var(--chart-bar); }
.chart .bar.dim { opacity: .45; }
.chart .grid { stroke: var(--chart-grid); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 12px; font-family: var(--font); }
.chart .val { fill: var(--text-2); font-size: 12px; font-weight: 600; font-family: var(--font); }
.chart .hit { fill: transparent; cursor: default; }
.tooltip { position: absolute; pointer-events: none; background: var(--navy-dk); color: #fff; border-radius: 10px; padding: 8px 10px; font-size: 13px; box-shadow: var(--shadow-2); white-space: nowrap; transform: translate(-50%, -100%); z-index: 5; }
.tooltip b { display: block; margin-bottom: 2px; }

/* ---------- phone panel ---------- */
.phone { background: var(--surface); border-left: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; position: relative; }
.phone-h { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.phone-h .num b { display: block; font-size: 15px; }
.phone-h .num span { font-size: 12px; color: var(--muted); }
.phone-h .reg { margin-left: auto; flex-shrink: 0; }
.phone-h .num { min-width: 0; flex: 1; }
.line-select { display: block; max-width: 100%; border: 0; background: transparent; font-weight: 700; font-size: 14px; padding: 0; cursor: pointer; color: var(--text); text-overflow: ellipsis; }
.line-chooser { display: grid; gap: 8px; }
.lc-label { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .8px; }
.lc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.lc { display: grid; gap: 1px; text-align: left; padding: 8px 10px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--surface); min-width: 0; }
.lc b { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lc span { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lc:hover { border-color: var(--border-strong); }
.lc.on { border-color: var(--brand); background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand); }
.lines-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.line-card .tags { display: flex; gap: 6px; flex-wrap: wrap; min-height: 22px; }
.line-card { border: 1px solid var(--border); border-radius: 12px; padding: 12px; display: grid; gap: 10px; background: var(--surface); }
.line-card.sel { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.line-card .lh { display: flex; gap: 10px; align-items: center; }
.line-card .lh b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.line-card .ls { display: flex; gap: 14px; font-size: 13px; color: var(--text-2); }
.line-card .la { display: flex; gap: 6px; flex-wrap: wrap; }
.from-line { font-size: 12px; color: var(--muted); font-weight: 600; display: flex; gap: 6px; align-items: center; }
.from-line select { border: 1px solid var(--border); border-radius: 6px; background: var(--surface); padding: 2px 6px; font-size: 12px; max-width: 220px; }
.tag svg.i.sm { width: 12px; height: 12px; margin-right: 3px; }
.dialer { padding: 16px 22px; display: flex; flex-direction: column; gap: 12px; flex-shrink: 0; }
.dial-display { position: relative; }
.dial-display input { width: 100%; border: 0; border-bottom: 2px solid var(--border); background: transparent; font-size: 28px; font-weight: 600; text-align: center; padding: 8px 36px; outline: none; letter-spacing: .5px; }
.dial-display input:focus { border-color: var(--brand); }
.dial-display .clear { position: absolute; right: 0; top: 10px; }
.dial-match { min-height: 20px; text-align: center; font-size: 13px; color: var(--muted); }
.suggest { position: absolute; left: 0; right: 0; top: 100%; z-index: 4; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-2); padding: 6px; margin-top: 6px; max-height: 260px; overflow: auto; }
.suggest button { display: flex; gap: 10px; align-items: center; width: 100%; padding: 8px; border-radius: 8px; text-align: left; }
.suggest button:hover, .suggest button.hl { background: var(--surface-2); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.key { height: 58px; border-radius: 14px; background: var(--surface-2); display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 24px; font-weight: 600; line-height: 1; user-select: none; transition: background .1s; }
.key small { font-size: 10px; letter-spacing: 2px; color: var(--muted); font-weight: 600; margin-top: 3px; }
.key:hover { background: var(--surface-3); }
.key:active { background: var(--border-strong); }
.dial-actions { display: grid; grid-template-columns: 1fr 72px 1fr; align-items: center; justify-items: center; }
.call-btn { width: 64px; height: 64px; border-radius: 50%; background: var(--green); color: #fff; display: grid; place-items: center; box-shadow: 0 6px 18px rgba(47,143,99,.35); }
.call-btn:hover { filter: brightness(1.06); }
.call-btn svg { width: 26px; height: 26px; }
.round-sm { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); }
.round-sm:hover { background: var(--surface-3); }
.phone-recents { border-top: 1px solid var(--border); padding: 12px 18px 16px; flex: 1; min-height: 0; overflow: auto; }
@media (max-height: 820px) and (min-width: 761px) { .key { height: 50px; } .dial-display input { font-size: 24px; padding-top: 4px; padding-bottom: 4px; } }
.phone-recents h4 { margin: 0 0 4px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.phone-close { display: none; }

/* in-call screen (Spoke-style) */
.incall { position: absolute; inset: 0; z-index: 20; background: linear-gradient(180deg, #2c2b4a 0%, var(--navy-xdk) 100%); color: #fff; display: flex; flex-direction: column; padding: 22px 22px 18px; }
.incall-top { display: flex; align-items: center; justify-content: space-between; font-size: 13px; color: #c8c8de; }
.incall-top .rec-ind { display: inline-flex; align-items: center; gap: 6px; color: #ff8a65; font-weight: 700; }
.incall-top .rec-ind::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #ff5a36; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.incall-id { text-align: center; margin: 18px 0 8px; }
.incall-id .avatar { margin: 0 auto 14px; background: rgba(255,255,255,.12); }
.incall-id .ctx { font-size: 13px; color: var(--brand); font-weight: 700; letter-spacing: .3px; text-transform: uppercase; }
.incall-id h2 { margin: 6px 0 2px; font-size: 26px; font-weight: 700; word-break: break-word; }
.incall-id .num { color: #c8c8de; font-size: 14px; }
.incall-id .state { margin-top: 8px; font-size: 18px; font-variant-numeric: tabular-nums; color: #fff; }
.incall-card { background: rgba(255,255,255,.07); border-radius: 12px; padding: 10px 12px; font-size: 13px; color: #d8d8ea; margin: 6px 0 10px; display: flex; gap: 8px; align-items: flex-start; }
.incall-card svg { color: var(--brand); margin-top: 1px; }
.incall-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 8px; margin: auto 0 18px; }
.ic-btn { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12.5px; color: #e4e4f0; font-weight: 600; }
.ic-btn .c { width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.12); transition: background .15s; }
.ic-btn:hover .c { background: rgba(255,255,255,.2); }
.ic-btn.on .c { background: var(--brand); color: var(--on-brand); }
.ic-btn.rec.on .c { background: #ff5a36; color: #fff; }
.ic-btn[disabled] { opacity: .4; pointer-events: none; }
.incall-end { display: flex; justify-content: center; gap: 40px; }
.end-btn { width: 68px; height: 68px; border-radius: 50%; background: #e2421b; color: #fff; display: grid; place-items: center; box-shadow: 0 8px 22px rgba(226,66,27,.45); }
.end-btn svg { transform: rotate(135deg); width: 28px; height: 28px; }
.accept-btn { width: 68px; height: 68px; border-radius: 50%; background: var(--green); color: #fff; display: grid; place-items: center; box-shadow: 0 8px 22px rgba(47,143,99,.45); animation: ring 1.4s infinite; }
.accept-btn svg { width: 28px; height: 28px; }
@keyframes ring { 0%,100% { transform: rotate(0); } 10% { transform: rotate(-12deg); } 20% { transform: rotate(12deg); } 30% { transform: rotate(-8deg); } 40% { transform: rotate(0); } }
.end-label { text-align: center; font-size: 12px; color: #c8c8de; margin-top: 6px; }
.incall-keypad .key { background: rgba(255,255,255,.1); color: #fff; height: 52px; }
.incall-keypad .key small { color: #b9b9d3; }
.incall .digits { text-align: center; font-size: 22px; min-height: 30px; letter-spacing: 2px; }

/* ---------- sheets, modals, toasts ---------- */
.scrim { position: fixed; inset: 0; background: rgba(20,20,40,.45); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 16px; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-3); width: 100%; max-width: 480px; max-height: calc(100dvh - 32px); display: flex; flex-direction: column; animation: pop .18s; }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }
.modal-h { display: flex; align-items: center; gap: 10px; padding: 18px 20px 8px; }
.modal-h h3 { margin: 0; font-size: 18px; flex: 1; }
.modal-b { padding: 8px 20px 12px; overflow: auto; display: grid; gap: 14px; }
.modal-f { padding: 12px 20px 18px; display: flex; gap: 10px; justify-content: flex-end; border-top: 1px solid var(--border); }
.seg { display: inline-flex; background: var(--surface-2); padding: 3px; border-radius: 10px; gap: 2px; }
.seg button { height: 32px; padding: 0 14px; border-radius: 8px; font-weight: 600; font-size: 14px; color: var(--text-2); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
.pick-list { display: grid; gap: 2px; max-height: 320px; overflow: auto; }
.pick-list button { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 10px; text-align: left; width: 100%; }
.pick-list button:hover { background: var(--surface-2); }
.pick-list button[disabled] { opacity: .5; }
.toasts { position: fixed; top: 16px; right: 16px; z-index: 80; display: grid; gap: 10px; width: min(380px, calc(100vw - 32px)); }
.toast { background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-2); border-radius: 12px; padding: 12px 14px; display: flex; gap: 10px; align-items: flex-start; animation: pop .2s; font-size: 14px; }
.toast.error { border-left: 4px solid var(--coral); }
.toast.ok { border-left: 4px solid var(--green); }
.toast.info { border-left: 4px solid var(--brand); }
.toast b { display: block; }

/* ---------- calls view ---------- */
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .grow { flex: 1; min-width: 200px; }
.table-card .row { padding: 12px 18px; }
.call-row { cursor: pointer; }
.call-row:hover { background: var(--surface-2); }
.call-row .who { width: 30%; min-width: 0; }
.call-row .agent { width: 18%; font-size: 13px; color: var(--text-2); }
.call-row .tags { display: flex; gap: 4px; flex-wrap: wrap; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100vw); background: var(--surface); box-shadow: var(--shadow-3); z-index: 70; display: flex; flex-direction: column; animation: slide .2s; }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
.drawer-h { display: flex; align-items: center; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.drawer-b { padding: 18px 20px; overflow: auto; display: grid; gap: 18px; align-content: start; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 8px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; }
audio { width: 100%; height: 36px; }

/* ---------- messages view ---------- */
.msg-layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); flex: 1; min-height: 0; min-width: 0; }
.msg-layout > * { min-width: 0; }
.conv-pane { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; background: var(--surface); }
.conv-pane .pane-h { padding: 14px 16px; display: grid; gap: 10px; border-bottom: 1px solid var(--border); }
.conv-list { overflow: auto; flex: 1; }
.conv { display: flex; gap: 12px; padding: 12px 16px; cursor: pointer; border-bottom: 1px solid var(--border); }
.conv:hover { background: var(--surface-2); }
.conv.sel { background: var(--brand-soft); }
.conv .main-col { flex: 1; min-width: 0; }
.conv .t { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; }
.conv .t span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv .t time { font-size: 12px; color: var(--muted); font-weight: 400; flex-shrink: 0; }
.conv .s { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; gap: 6px; align-items: center; }
.conv.unread .s { color: var(--text); font-weight: 600; }
.thread-pane { display: flex; flex-direction: column; min-height: 0; background: var(--bg); }
.thread-h { display: flex; align-items: center; gap: 12px; padding: 12px 18px; background: var(--surface); border-bottom: 1px solid var(--border); }
.thread-h .who { flex: 1; min-width: 0; }
.thread-h .who b { display: block; }
.thread-h .who span { font-size: 13px; color: var(--muted); }
.thread { flex: 1; overflow: auto; padding: 20px; display: flex; flex-direction: column; gap: 6px; }
.day-sep { align-self: center; font-size: 12px; color: var(--muted); background: var(--surface-2); padding: 3px 10px; border-radius: 10px; margin: 10px 0; }
.bubble { max-width: min(560px, 78%); padding: 10px 14px; border-radius: 18px; line-height: 1.4; white-space: pre-wrap; word-break: break-word; box-shadow: var(--shadow-1); }
.bubble.inbound { align-self: flex-start; background: var(--surface); border-bottom-left-radius: 6px; }
.bubble.outbound { align-self: flex-end; background: var(--navy); color: #fff; border-bottom-right-radius: 6px; }
.bubble.failed { background: var(--coral); color: #fff; }
.bubble.web { border: 1px dashed var(--brand); }
.bubble .meta { display: block; font-size: 11px; opacity: .75; margin-top: 4px; text-align: right; }
.bubble img { max-width: 100%; border-radius: 10px; display: block; margin-top: 6px; }
.composer { display: flex; gap: 10px; align-items: flex-end; padding: 12px 18px; background: var(--surface); border-top: 1px solid var(--border); }
.composer textarea { flex: 1; resize: none; min-height: 44px; max-height: 160px; border: 1px solid var(--border-strong); background: var(--surface); border-radius: 12px; padding: 11px 14px; outline: none; }
.composer textarea:focus { border-color: var(--brand); }
.composer .count { font-size: 11px; color: var(--muted); text-align: right; }
.thread-empty { flex: 1; display: grid; place-items: center; color: var(--muted); text-align: center; padding: 20px; }
.thread-empty img { width: 72px; opacity: .9; margin-bottom: 8px; }

/* ---------- team & wallboard ---------- */
.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.member { padding: 16px; display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); min-width: 0; }
.member .top { display: flex; gap: 12px; align-items: center; }
.member .top .main-col { flex: 1; min-width: 0; }
.member .top b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member .stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; text-align: center; background: var(--surface-2); border-radius: 10px; padding: 8px 4px; }
.member .stats b { display: block; font-size: 17px; }
.member .stats span { font-size: 11px; color: var(--muted); }
.member .acts { display: flex; gap: 6px; }
.wallboard { display: grid; gap: 18px; }
.wb-big { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.wb-tile { padding: 22px; text-align: center; }
.wb-tile .v { font-size: clamp(40px, 5vw, 72px); font-weight: 700; line-height: 1; }
.wb-tile .l { margin-top: 8px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; font-size: 13px; }
.wb-tile.hot .v { color: var(--coral); }
.wb-tile.good .v { color: var(--green); }
.wb-agents { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.wb-agents div { padding: 14px; text-align: center; }
.wb-agents b { display: block; font-size: 32px; }

/* ---------- settings ---------- */
.settings { display: grid; gap: 18px; max-width: 860px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-top: 1px solid var(--border); }
.set-row:first-child { border-top: 0; }
.set-row .l b { display: block; }
.set-row .l span { font-size: 13px; color: var(--muted); }
.hours { display: grid; gap: 8px; }
.hours .d { display: grid; grid-template-columns: 120px 44px 1fr 1fr; gap: 10px; align-items: center; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; background: var(--navy-xdk); color: #e7e7f3; border-radius: 10px; padding: 12px 14px; white-space: pre-wrap; word-break: break-all; }

/* ---------- mobile tab bar ---------- */
.tabbar { display: none; }
.fab-phone { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 1280px) {
  :root { --sidebar-w: 76px; --phone-w: 340px; }
  .brandmark div, .nav a span, .nav-label, .me-card .who, .me-card .icon-btn { display: none; }
  .brandmark { justify-content: center; padding: 4px 0 18px; }
  .nav a { justify-content: center; padding: 0; }
  .nav a .badge { position: absolute; top: 4px; right: 6px; margin: 0; min-width: 18px; height: 18px; }
  .me-card { justify-content: center; background: none; }
}
@media (max-width: 1024px) {
  .app { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .phone { position: fixed; right: 0; top: 0; bottom: 0; width: min(380px, 100vw); z-index: 50; box-shadow: var(--shadow-3); transform: translateX(105%); transition: transform .22s ease; }
  .app.phone-open .phone { transform: none; }
  .phone-close { display: inline-grid; }
  .fab-phone { display: grid; place-items: center; position: fixed; right: 20px; bottom: 20px; width: 60px; height: 60px; border-radius: 50%; background: var(--green); color: #fff; z-index: 45; box-shadow: 0 8px 22px rgba(47,143,99,.4); }
  .fab-phone svg { width: 26px; height: 26px; }
  .msg-layout { grid-template-columns: 300px minmax(0, 1fr); }
  .wb-big { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .login { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .login-main { padding: 20px 16px; }
  .login-card .mobile-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
  .login-card .mobile-logo img { width: 48px; height: 48px; }
  .login-card .mobile-logo b { display: block; font-size: 18px; }
  .login-card .mobile-logo small { color: var(--muted); }
  .app { grid-template-columns: minmax(0, 1fr); padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
  .sidebar { display: none; }
  .topbar { padding: 0 16px; height: 56px; }
  .topbar .mobile-only { display: inline-grid; }
  .view { padding: 16px; }
  .fab-phone { display: none; }
  .phone { position: fixed; inset: 0 0 calc(var(--tabbar-h) + env(safe-area-inset-bottom)) 0; width: auto; transform: none; display: none; box-shadow: none; border: 0; z-index: 30; }
  .app.phone-open .phone { display: flex; }
  .phone .incall { position: fixed; inset: 0; z-index: 90; padding-top: max(22px, env(safe-area-inset-top)); padding-bottom: max(18px, env(safe-area-inset-bottom)); }
  .phone-close { display: none; }
  .dialer { padding: 16px; justify-content: center; flex: 1; overflow: auto; }
  .key { height: 62px; }
  .phone-recents { display: none; }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--surface); border-top: 1px solid var(--border); z-index: 40; }
  .tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; font-weight: 600; color: var(--muted); text-decoration: none; position: relative; }
  .tabbar a.active { color: var(--brand-strong); }
  .tabbar a .badge { position: absolute; top: 6px; left: calc(50% + 6px); min-width: 18px; height: 18px; font-size: 10px; }
  .tabbar a.keypad-tab .kc { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--green); color: #fff; margin-top: -18px; box-shadow: 0 6px 16px rgba(47,143,99,.4); }
  .kpi { padding: 12px 14px; }
  .kpi .value { font-size: 24px; }
  .widgets { gap: 12px; }
  .new-label { display: none; }
  .app.has-call .tabbar { display: none; }
  .app.has-call .phone { z-index: 95; inset: 0; }
  .greeting h2 { font-size: 22px; }
  .msg-layout { grid-template-columns: 1fr; }
  .msg-layout.thread-open .conv-pane { display: none; }
  .msg-layout:not(.thread-open) .thread-pane { display: none; }
  .call-row .agent, .call-row .tags { display: none; }
  .call-row .who { width: auto; flex: 1; }
  .table-card .row { padding: 12px 14px; }
  .wb-agents { grid-template-columns: repeat(3, 1fr); }
  .hours .d { grid-template-columns: 1fr 44px; }
  .hours .d input[type=time] { grid-column: span 1; }
  .kv { grid-template-columns: 110px 1fr; }
  .toasts { top: auto; bottom: calc(var(--tabbar-h) + 12px); right: 16px; }
}
/* Dashboard adapts to the space actually available (sidebar + phone panel vary) */
@container view (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .w-8 { grid-column: span 12; }
  .w-4 { grid-column: span 6; }
}
@container view (max-width: 640px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .w-4, .w-6 { grid-column: span 12; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
