/* Debug panel — design tokens (dark only) + shared components. dialers.css uses the same tokens. */
:root {
  --bg: #121212; --surface: #1e1e1e; --surface2: #262626; --border: #333; --text: #e0e0e0; --dim: #8f8f8f;
  --green: #4caf50; --orange: #ff9800; --red: #f44336; --blue: #1e88e5; --accent: #90caf9;
  --mono: 'Consolas', 'Menlo', 'DejaVu Sans Mono', monospace; --sans: 'Segoe UI', system-ui, sans-serif;
  --dock-w: 360px;
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
/* The app is a fixed viewport: header on top, then main and the dock, each scrolling on its own. */
html, body { height: 100%; background: var(--bg); color: var(--text); font: 13px/1.45 var(--sans); font-variant-numeric: tabular-nums; }
body { height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
a { color: var(--accent); }
.mono { font-family: var(--mono); }
.muted { color: var(--dim); }
.err { color: var(--red); font-size: 12px; }
.err:empty { display: none; }
h2 { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--dim); white-space: nowrap; }
h3 { font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
p { overflow-wrap: anywhere; }

input, select, textarea {
  background: var(--surface2); color: var(--text); border: 1px solid var(--border); border-radius: 6px;
  padding: 4px 8px; font: inherit; min-width: 0; max-width: 100%; height: 28px;
}
textarea { font-family: var(--mono); font-size: 12px; width: 100%; resize: vertical; height: auto; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); height: auto; }
input[type=range] { padding: 0; border: 0; background: none; height: auto; accent-color: var(--accent); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: #6b6b6b; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #3a3a3a; border-radius: 5px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: #4a4a4a; }
::-webkit-scrollbar-corner { background: transparent; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px; height: 28px;
  background: var(--surface2); color: var(--text); border: 1px solid var(--border); border-radius: 6px;
  padding: 0 12px; font: inherit; cursor: pointer; white-space: nowrap; flex: none;
}
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover:not(:disabled) { border-color: #fff6; }
.btn.danger { color: var(--red); }
.btn.danger:hover:not(:disabled) { border-color: var(--red); }
.btn.primary.danger { background: #c62828; border-color: #c62828; color: #fff; }
.btn.small { height: 23px; padding: 0 8px; font-size: 12px; }
.btn.icon { width: 23px; padding: 0; }
.btn.on { border-color: var(--accent); color: var(--accent); }

.pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 0 8px; height: 19px; border-radius: 999px;
  border: 1px solid var(--border); font-size: 11px; font-weight: 600; white-space: nowrap; color: var(--text); flex: none;
}
.pill.ok { color: var(--green); border-color: color-mix(in srgb, var(--green) 45%, var(--border)); }
.pill.warn { color: var(--orange); border-color: color-mix(in srgb, var(--orange) 45%, var(--border)); }
.pill.bad { color: var(--red); border-color: color-mix(in srgb, var(--red) 45%, var(--border)); }
.pill.dim { color: var(--dim); }
.pill.info { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; min-width: 0; }
.card > header { display: flex; align-items: center; gap: 8px; padding: 0 12px; min-height: 42px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card > header > h2 { padding: 12px 0 11px; }
.card > header .sp { flex: 1; }
.card > .body, .card.body { padding: 10px 12px; }
.body:empty { display: none; }
.grid { display: grid; gap: 12px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.sp { flex: 1; }
.empty { padding: 20px 16px; text-align: center; color: var(--dim); }
.note { color: var(--dim); font-size: 12px; max-width: 72ch; }
.count { color: var(--dim); font-family: var(--mono); font-size: 12px; white-space: nowrap; min-width: 8ch; text-align: right; }
.id { font-family: var(--mono); white-space: nowrap; }
[data-copy] { cursor: copy; }
[data-copy]:hover { text-decoration: underline dotted; text-underline-offset: 3px; }

table.data { width: 100%; border-collapse: collapse; }
table.data th { text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--dim);
  padding: 6px 8px; border-bottom: 1px solid var(--border); background: var(--surface2); position: sticky; top: 0; z-index: 1; white-space: nowrap; }
table.data td { padding: 5px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data .num { text-align: right; }
table.data .nw { white-space: nowrap; }
table.data tr.click { cursor: pointer; }
table.data tr.click:hover td, table.data tr.sel td { background: var(--surface2); }
table.data tr.sel td:first-child { box-shadow: inset 2px 0 var(--accent); }
.scrollx { overflow-x: auto; max-width: 100%; }

details.json > summary { cursor: pointer; color: var(--dim); font-size: 12px; user-select: none; padding: 2px 0; }
details.json > summary:hover { color: var(--text); }
details.json pre, pre.json { font-size: 12px; white-space: pre-wrap; word-break: break-all; background: var(--bg);
  border: 1px solid var(--border); border-radius: 6px; padding: 8px; margin-top: 4px; max-height: 420px; overflow: auto; cursor: text; }

/* ── shell ── */
.top { display: flex; align-items: center; gap: 10px; padding: 8px 16px; background: var(--surface); border-bottom: 1px solid var(--border); flex-wrap: wrap; flex: none; }
.top .brand { font-weight: 600; color: var(--accent); font-size: 15px; white-space: nowrap; }
.top .sp { flex: 1; }
#docktoggle.on { border-color: var(--accent); color: var(--accent); }
body:has(#dialers[data-ringing]) #docktoggle { border-color: var(--orange); color: var(--orange); animation: ring 1.2s ease-in-out infinite; }
@keyframes ring { 50% { background: color-mix(in srgb, var(--orange) 25%, var(--surface2)); } }
.banner { padding: 6px 16px; background: color-mix(in srgb, var(--orange) 18%, var(--bg)); color: var(--orange); border-bottom: 1px solid var(--orange); flex: none; }
.banner.bad { background: color-mix(in srgb, var(--red) 15%, var(--bg)); color: #ff8a80; border-bottom-color: var(--red); }
.banner:empty { display: none; }
nav.tabs { display: flex; gap: 2px; padding: 0 12px; background: var(--surface); border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; flex: none; }
nav.tabs a { padding: 8px 12px; color: var(--dim); text-decoration: none; border-bottom: 2px solid transparent; white-space: nowrap; }
nav.tabs a:hover { color: var(--text); }
nav.tabs a.on { color: var(--text); border-bottom-color: var(--accent); }
nav.tabs a:not([data-n=""])[data-n]::after { content: attr(data-n); margin-left: 6px; padding: 0 6px; border-radius: 999px; font-size: 11px; font-weight: 700; background: var(--orange); color: #000; }
.shell { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto auto; }
/* Views lay out against their own width (container queries), so the dock's width never breaks them. */
main#view { padding: 12px 16px 24px; min-width: 0; min-height: 0; overflow: auto; scrollbar-gutter: stable; container: view / inline-size; transition: opacity .2s; }
body:is([data-conn=down], [data-conn=connecting], [data-conn=unauthorized]) main#view { opacity: .55; }
aside#dialers { width: var(--dock-w); min-width: 0; min-height: 0; overflow-y: auto; overflow-x: hidden; scrollbar-gutter: stable; background: var(--bg); }
aside#dialers.hidden { display: none; }
.grip { width: 5px; cursor: col-resize; border-left: 1px solid var(--border); touch-action: none; }
.grip:hover, .grip.drag, .grip:focus-visible { outline: none; border-left: 2px solid var(--accent); }
.grip:has(+ aside.hidden) { display: none; }
.dockerr { padding: 12px; color: var(--red); white-space: pre-wrap; font-family: var(--mono); font-size: 12px; overflow-wrap: anywhere; }
/* Narrow: the dock replaces the view instead of squeezing it; the Dialers button switches. */
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .grip { display: none; }
  aside#dialers { width: auto; }
  .shell:has(> aside#dialers:not(.hidden)) > main { display: none; }
  main#view { padding: 10px 10px 24px; }
  .top { padding: 8px 10px; gap: 8px; }
  nav.tabs { mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent); }
}
/* Sign-in (app.js login): signed out, the card is all the page shows. */
body[data-auth=out] > :not(.login, .toasts) { display: none !important; }
body:not([data-auth=out]) > .login { display: none; }
.login { flex: 1; display: grid; place-items: center; padding: 24px 16px; overflow: auto;
  background: radial-gradient(ellipse 80% 60% at 50% 0%, color-mix(in srgb, var(--blue) 14%, var(--bg)), var(--bg)); }
.login-card { width: min(360px, 100%); display: flex; flex-direction: column; gap: 8px; padding: 32px 28px 28px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 16px 48px #0009; }
.login-mark { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; margin-bottom: 8px;
  color: var(--accent); background: color-mix(in srgb, var(--blue) 20%, transparent); }
.login h1 { font-size: 19px; font-weight: 600; }
.login-sub { color: var(--dim); margin-bottom: 14px; }
.login label { font-size: 12px; font-weight: 600; color: var(--dim); }
.login input { height: 40px; padding: 0 12px; font-size: 14px; }
.login-err { min-height: 18px; color: var(--red); font-size: 12px; }
.login .btn { height: 40px; font-size: 14px; font-weight: 600; }

/* ── popover menu, modal, toast ── */
.menu { position: fixed; z-index: 50; display: none; min-width: 200px; max-width: min(420px, 94vw); max-height: 70vh; overflow: auto; background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 4px; box-shadow: 0 10px 30px rgba(0, 0, 0, .5); }
.menu.open { display: block; }
.menu .mh { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--dim); padding: 6px 10px 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu .sep { height: 1px; background: var(--border); margin: 4px; }
.menu button { display: flex; width: 100%; gap: 16px; align-items: center; padding: 6px 10px; border: 0; background: none;
  color: var(--text); font: inherit; text-align: left; border-radius: 6px; cursor: pointer; white-space: nowrap; }
.menu button:hover:not(:disabled), .menu button:focus-visible { background: var(--surface2); outline: none; }
.menu button.danger { color: var(--red); }
.menu button:disabled { opacity: .4; cursor: default; }
.menu .hint { margin-left: auto; font-family: var(--mono); font-size: 11px; color: var(--dim); }
.backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, .55); display: grid; place-items: center; padding: 16px; }
.modal { width: min(460px, 100%); max-height: 90vh; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; box-shadow: 0 16px 40px rgba(0, 0, 0, .6); }
.modal .field { display: flex; flex-direction: column; gap: 3px; }
.modal .field > span, .modal .row > span { font-size: 12px; color: var(--dim); }
.modal .acts { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.toasts { position: fixed; bottom: 16px; left: 16px; z-index: 70; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; pointer-events: none; max-width: min(520px, calc(100vw - 32px)); }
.toast { background: var(--surface2); border: 1px solid var(--border); border-left: 3px solid var(--accent); padding: 7px 14px; border-radius: 6px;
  overflow-wrap: anywhere; box-shadow: 0 6px 20px rgba(0, 0, 0, .5); transition: opacity .3s; }
.toast.ok { border-left-color: var(--green); }
.toast.warn { border-left-color: var(--orange); }
.toast.bad { border-left-color: var(--red); }

/* ── board ── */
.board { display: grid; gap: 12px; align-items: start; grid-template-columns: minmax(0, 1fr); grid-template-areas: "ep" "calls" "insp"; }
.board > .eps { grid-area: ep; } .board > .calls { grid-area: calls; } .board > .insp { grid-area: insp; }
.board > .eps > .list { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
@container view (min-width: 720px) {
  .board { grid-template-columns: minmax(0, 1fr) 300px; grid-template-rows: auto 1fr; grid-template-areas: "ep insp" "calls insp"; }
}
@container view (min-width: 1200px) {
  .board { grid-template-columns: 250px minmax(0, 1fr) 340px; grid-template-rows: auto; grid-template-areas: "ep calls insp"; }
  .board > .eps > .list { display: block; }
}
@container view (min-width: 720px) { .board > .insp { position: sticky; top: 0; max-height: calc(100dvh - 130px); overflow: auto; } }
.eprow { display: flex; align-items: center; gap: 8px; padding: 5px 8px 5px 12px; min-width: 0; }
.eprow:hover { background: var(--surface2); }
.eprow .nm { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.eprow .nm > b { font-weight: 500; font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.eprow .nm > span { display: flex; gap: 4px; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--dim); }
.dot.avail { background: var(--green); } .dot.oncall { background: var(--orange); } .dot.away { background: transparent; box-shadow: inset 0 0 0 2px var(--green); }
.dot.gone { background: transparent; box-shadow: inset 0 0 0 2px var(--dim); }
.tag { font-family: var(--mono); font-size: 10.5px; line-height: 16px; padding: 0 5px; border-radius: 4px; background: var(--surface2); color: var(--dim); white-space: nowrap; }
.tag.warn { color: var(--orange); } .tag.info { color: var(--accent); }
.call { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 10px; overflow: hidden; border-left: 3px solid var(--hue, var(--dim)); }
.call:last-child { margin-bottom: 0; }
.call > .ch { display: flex; align-items: center; gap: 8px; padding: 5px 8px 5px 10px; background: var(--surface2); flex-wrap: wrap; min-height: 34px; }
.brg { margin: 6px 8px; border: 1px dashed var(--border); border-radius: 6px; }
.brg > .bh { display: flex; align-items: center; gap: 6px; padding: 4px 8px; font-size: 12px; color: var(--dim); flex-wrap: wrap; cursor: pointer; min-height: 30px; }
.brg > .empty { padding: 8px; }
/* A leg: what (state, direction, who) | where (id, transport, endpoint, flags) | when + actions. */
.leg { display: flex; align-items: center; gap: 4px 10px; padding: 4px 8px 4px 10px; cursor: pointer; flex-wrap: wrap; min-height: 32px; }
.leg:hover { background: var(--surface2); }
.leg.sel, .brg.sel { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.leg > .what { display: flex; align-items: center; gap: 8px; flex: 1 1 180px; min-width: 0; }
.leg .who { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leg > .where { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.leg > .acts { display: flex; align-items: center; gap: 6px; justify-content: flex-end; margin-left: auto; }
/* Wide enough: reserve the actions column so ended and live legs line up. */
.board > .calls { container: calls / inline-size; }
@container calls (min-width: 640px) { .leg > .acts { min-width: 140px; } }
.st { display: inline-block; width: 68px; text-align: center; flex: none; font-size: 10.5px; font-weight: 700; text-transform: uppercase; padding: 1px 0; border-radius: 999px; background: var(--bg); color: var(--dim); }
.st.incoming { color: var(--accent); } .st.ringing, .st.dialing { color: var(--orange); } .st.up { color: var(--green); } .st.ended { color: var(--dim); opacity: .7; }
.dur { font-family: var(--mono); color: var(--dim); min-width: 5ch; text-align: right; }
.insp dl { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 3px 12px; margin: 8px 0; }
.insp dt { color: var(--dim); font-size: 11px; text-transform: uppercase; line-height: 19px; }
.insp dd { overflow-wrap: anywhere; }
.insp .acts { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }

/* ── timeline ── */
.tl { margin-bottom: 12px; }
.tl .clock { font-family: var(--mono); color: var(--dim); white-space: nowrap; }
.tl .zoom { font-family: var(--mono); color: var(--dim); min-width: 7ch; text-align: center; }
.tlbody { overflow: auto; max-height: min(34vh, 320px); padding: 8px 0 4px; cursor: crosshair; }
.tlinner { position: relative; }
.lane { display: flex; align-items: center; height: 20px; }
.lane.sel { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.lname { width: 170px; flex: none; position: sticky; left: 0; z-index: 3; background: var(--surface); padding: 0 8px 0 12px;
  font-size: 11px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; cursor: pointer; }
.lane.sel .lname { background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
.track { position: relative; height: 12px; flex: none; }
.seg { position: absolute; top: 0; bottom: 0; border-radius: 3px; }
.seg.incoming { opacity: .5; }
.seg.ringing, .seg.dialing { opacity: .85; background-image: repeating-linear-gradient(90deg, transparent 0 3px, rgba(255, 255, 255, .28) 3px 5px); }
.seg.ended { opacity: .25; }
.playline { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--text); z-index: 2; pointer-events: none; }
.future { position: absolute; top: 0; bottom: 0; background: rgba(18, 18, 18, .6); z-index: 1; pointer-events: none; border-left: 1px dashed var(--dim); }
.tick { position: absolute; top: 4px; width: 5px; height: 5px; border-radius: 50%; transform: translateX(-50%); }
.axis { display: flex; height: 14px; position: sticky; bottom: -4px; background: var(--surface); }

/* ── events ── */
.card.sticky > header { position: sticky; top: 0; z-index: 2; background: var(--surface); border-radius: 8px 8px 0 0; }
.evrow { display: grid; grid-template-columns: 70px 64px 150px minmax(0, 1fr); gap: 8px; padding: 3px 12px; font-family: var(--mono); font-size: 12px;
  border-bottom: 1px solid var(--surface2); cursor: pointer; align-items: baseline; }
.evrow:hover { background: var(--surface2); }
.evrow > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.evrow.open { background: var(--surface2); }
.evrow.open .sum { white-space: normal; overflow-wrap: anywhere; }
.evrow > pre { grid-column: 1 / -1; }
.evrow.au { grid-template-columns: 62px 84px minmax(0, 1fr); padding: 3px 4px; }
.k-out { color: var(--accent); } .k-reply { color: #64b5f6; } .k-snap { color: var(--dim); } .k-sys { color: var(--orange); } .k-ev { color: var(--green); }
@container view (max-width: 640px) { .evrow { grid-template-columns: 62px 56px minmax(0, 1fr); } .evrow .ty { display: none; } }
.evfilters { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; padding: 8px 0; }
.evfilters input { width: 130px; }

/* ── split list/detail (history, console, trunks) ── */
.split { display: grid; gap: 12px; align-items: start; grid-template-columns: minmax(0, 1fr); }
@container view (min-width: 960px) {
  .split { grid-template-columns: minmax(0, 1fr) minmax(320px, 36%); }
  .split.narrow { grid-template-columns: 250px minmax(0, 1fr); }
  .split.even { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .split > .detail { position: sticky; top: 0; max-height: calc(100dvh - 130px); overflow: auto; }
  /* The list scrolls inside its card so the table header stays in view. */
  .split .rows { max-height: calc(100dvh - 330px); overflow: auto; }
}
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.filters label { display: flex; flex-direction: column; gap: 2px; font-size: 11px; color: var(--dim); }
.subtabs { display: flex; gap: 4px; margin: 8px 0; }
.cmdlist { max-height: calc(100dvh - 190px); overflow: auto; padding: 4px; }
.cmdlist button { display: block; width: 100%; text-align: left; padding: 3px 8px; background: none; border: 0; color: var(--text); font: 12px/1.6 var(--mono); cursor: pointer; border-radius: 4px; }
.cmdlist button:hover { background: var(--surface2); }
.cmdlist button.on { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); }
.form { display: flex; flex-direction: column; gap: 10px; }
.form label { display: flex; flex-direction: column; gap: 3px; }
.form label > span { font-family: var(--mono); font-size: 12px; }
.form label > small { color: var(--dim); font-size: 11px; }
.form input:not([type=checkbox]), .form select { width: 100%; }
.offer { padding: 10px 12px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; }
.offer:last-child { border-bottom: 0; }
.countdown { font-family: var(--mono); font-weight: 700; white-space: nowrap; }
.countdown.low { color: var(--red); }

/* ── diag ── */
.diag .chart header > span:first-child { font-weight: 600; }
/* Fixed columns: live numbers changing length must not reflow the table every 500 ms. */
.diag table.data { table-layout: fixed; min-width: 760px; }
.diag table.data th:first-child { width: 110px; } .diag table.data th:nth-child(2) { width: 140px; }
.diag .canvas-wrap { position: relative; height: 160px; }
.diag canvas { display: block; width: 100%; height: 100%; }
.diag .val.bad, .diag .bad { color: var(--red); }
.diag .warn { color: var(--orange); }
.diag .good { color: var(--green); }
.diag .stat { display: inline-flex; gap: 6px; color: var(--dim); white-space: nowrap; }
.diag .stat > span { color: var(--text); min-width: 6ch; }
