/* Components: buttons, inputs, pills, panels, tables, modals, menus, toasts. */

/* ---------- layout helpers ---------- */
.row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.row.wrap { flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; align-items: start; }
.grid2 > .grow2 { grid-column: span 1; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: var(--ctl); padding: 0 11px;
  border: 1px solid var(--line-2); border-radius: var(--r);
  background: var(--panel); color: var(--ink);
  font-size: var(--fs-sm); font-weight: 550; line-height: 1; white-space: nowrap; text-decoration: none;
  transition: background var(--t), border-color var(--t), color var(--t);
  user-select: none; flex: none;
}
.btn:hover:not(:disabled) { background: var(--raised); border-color: var(--ink-3); }
.btn:active:not(:disabled) { transform: translateY(.5px); }
.btn:disabled { opacity: .45; }
.btn.sm { height: var(--ctl-sm); padding: 0 8px; }
.btn.icon { width: var(--ctl); padding: 0; }
.btn.icon.sm { width: var(--ctl-sm); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover:not(:disabled) { background: var(--raised); border-color: transparent; color: var(--ink); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn.primary:hover:not(:disabled) { background: var(--ink-2); border-color: var(--ink-2); }
.btn.call { background: var(--live); border-color: var(--live); color: var(--on-live); }
.btn.call:hover:not(:disabled) { background: color-mix(in srgb, var(--live) 86%, var(--ink)); border-color: transparent; }
.btn.danger { background: transparent; border-color: color-mix(in srgb, var(--err) 60%, transparent); color: var(--err); }
.btn.danger:hover:not(:disabled) { background: var(--err); border-color: var(--err); color: var(--on-err); }
.btn.lg { height: 38px; padding: 0 16px; font-size: var(--fs); }
.btn.xl { height: 52px; padding: 0 14px; font-size: var(--fs-md); border-radius: 4px; }
.btn.xl.danger { background: var(--err); border-color: var(--err); color: var(--on-err); }
.btn.xl.danger:hover:not(:disabled) { background: color-mix(in srgb, var(--err) 86%, var(--ink)); }
.btn[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn[aria-busy="true"] { position: relative; color: transparent !important; pointer-events: none; }
.btn[aria-busy="true"] > * { visibility: hidden; }
.btn[aria-busy="true"]::after {
  content: ""; position: absolute; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--ink-3); border-top-color: transparent; animation: spin .7s linear infinite;
}
.btn.primary[aria-busy="true"]::after, .btn[aria-pressed="true"][aria-busy="true"]::after { border-color: var(--bg); border-top-color: transparent; }
.btn.call[aria-busy="true"]::after { border-color: var(--on-live); border-top-color: transparent; }
.btn.star[aria-pressed="true"] { background: transparent; border-color: transparent; color: var(--ring); }

.link, button.link { color: var(--ink); text-decoration: underline; text-decoration-color: var(--ink-3); text-underline-offset: 2px; background: none; border: 0; padding: 0; }
.link:hover { text-decoration-color: currentColor; }
.link-strong { font-weight: 600; text-decoration: none; }
.link-strong:hover { text-decoration: underline; text-underline-offset: 2px; }

/* ---------- inputs ---------- */
.input {
  height: var(--ctl); width: 100%; min-width: 0;
  padding: 0 9px;
  border: 1px solid var(--line-2); border-radius: var(--r);
  background: var(--sunken); color: var(--ink);
  font-size: var(--fs);
  transition: border-color var(--t);
}
.input::placeholder { color: var(--ink-3); opacity: 1; }
.input:hover { border-color: var(--ink-3); }
.input:focus-visible { outline-offset: 0; border-color: var(--focus); }
.input:disabled { opacity: .55; }
.input.sm { height: var(--ctl-sm); font-size: var(--fs-sm); width: auto; }
.input.w-s { width: 96px; }
.input.w-m { width: 180px; flex: none; }
.input.grow { flex: 1 1 160px; }
.textarea { height: auto; padding: 7px 9px; line-height: 1.45; resize: vertical; min-height: 56px; }
.textarea.mono { font-size: 12px; line-height: 1.55; tab-size: 2; white-space: pre; overflow: auto; }
.select {
  appearance: none; padding-right: 26px; width: auto; max-width: 100%;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position: calc(100% - 13px) 50%, calc(100% - 9px) 50%;
  background-size: 4px 4px, 4px 4px; background-repeat: no-repeat;
}
.field > .select, .form .select { width: 100%; }
.input.inline { background-color: transparent; border-color: transparent; height: 26px; padding: 0 6px; margin-left: -6px; font-size: var(--fs-sm); }
.input.inline:hover { border-color: var(--line-2); }
.input.inline:focus-visible { background-color: var(--sunken); border-color: var(--focus); }
.select.inline { padding-right: 22px; min-width: 104px; }
input[type="search"]::-webkit-search-cancel-button { filter: grayscale(1); }
input[type="number"] { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field-l { font-size: var(--fs-sm); font-weight: 550; color: var(--ink-2); display: flex; gap: 6px; align-items: baseline; }
.field-opt { font-weight: 400; color: var(--ink-3); font-size: var(--fs-xs); }
.field-h { font-size: var(--fs-xs); color: var(--ink-3); line-height: 1.4; display: block; font-weight: 400; }
.form { display: flex; flex-direction: column; gap: 14px; }
.form-err { color: var(--err); font-size: var(--fs-sm); padding: 7px 9px; border: 1px solid color-mix(in srgb, var(--err) 45%, transparent); border-radius: var(--r); background: color-mix(in srgb, var(--err) 9%, transparent); }
.fieldset { display: flex; flex-direction: column; gap: 8px; }
.fieldset legend { font-size: var(--fs-sm); font-weight: 550; color: var(--ink-2); padding: 0; margin-bottom: 6px; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 6px 14px; padding: 9px 10px; border: 1px solid var(--line); border-radius: var(--r); max-height: 176px; overflow: auto; }

.check { display: flex; align-items: flex-start; gap: 8px; cursor: pointer; font-size: var(--fs); position: relative; min-width: 0; }
.check input { position: absolute; opacity: 0; width: 16px; height: 16px; margin: 0; top: 2px; left: 0; }
.check-box { flex: none; width: 16px; height: 16px; margin-top: 2px; border: 1px solid var(--ink-3); border-radius: 2px; background: var(--sunken); display: grid; place-items: center; color: transparent; transition: background var(--t), border-color var(--t); }
.check input:checked + .check-box { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.check input:focus-visible + .check-box { outline: 2px solid var(--focus); outline-offset: 2px; }
.check input:disabled ~ * { opacity: .5; }
.check-l { display: flex; flex-direction: column; gap: 1px; min-width: 0; }

/* segmented control */
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--r); overflow: hidden; background: var(--sunken); }
.seg-b { display: inline-flex; align-items: center; gap: 5px; height: calc(var(--ctl-sm) - 2px); padding: 0 9px; border: 0; border-right: 1px solid var(--line-2); background: transparent; color: var(--ink-2); font-size: var(--fs-sm); font-weight: 550; white-space: nowrap; transition: background var(--t), color var(--t); }
.seg-b:last-child { border-right: 0; }
.seg-b:hover { color: var(--ink); }
.seg-b[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.seg-b:focus-visible { outline-offset: -2px; }

/* chips (dispositions) */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { height: 28px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: 14px; background: transparent; color: var(--ink-2); font-size: var(--fs-sm); font-weight: 550; display: inline-flex; align-items: center; gap: 4px; transition: background var(--t), color var(--t), border-color var(--t); }
.chip:hover { border-color: var(--ink-3); color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.chip.static { padding-right: 2px; cursor: default; }
.taglist { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- status ---------- */
.pill {
  --s: var(--ink-3);
  display: inline-flex; align-items: center; gap: 5px;
  height: 20px; padding: 0 6px 0 5px;
  border: 1px solid color-mix(in srgb, var(--s) 50%, transparent); border-radius: 2px;
  background: color-mix(in srgb, var(--s) 11%, transparent);
  color: var(--s); font-size: var(--fs-xs); font-weight: 600; white-space: nowrap; line-height: 1;
}
.pill[data-s="ready"] { --s: var(--live); }
.pill[data-s="in_call"] { --s: var(--live); background: var(--live); color: var(--on-live); border-color: var(--live); }
.pill[data-s="ringing"] { --s: var(--ring); }
.pill[data-s="dialing"] { --s: var(--info); }
.pill[data-s="needs_login"] { --s: var(--warn); }
.pill[data-s="error"] { --s: var(--err); }
.pill[data-s="starting"] { --s: var(--ink-2); border-style: dashed; }
.pill[data-s="starting"] .ic { animation: spin 1s linear infinite; }
.pill[data-s="stopped"] { --s: var(--ink-3); background: transparent; }

.presence { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--ink-2); white-space: nowrap; }
.presence[data-p="available"] .ic { color: var(--live); }
.presence[data-p="away"] .ic { color: var(--ring); }
.presence[data-p="dnd"] .ic { color: var(--err); }
.presence[data-p="offline"] { color: var(--ink-3); }

.tag { display: inline-flex; align-items: center; height: 18px; padding: 0 5px; border: 1px solid var(--line-2); border-radius: 2px; font-size: 11px; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.tag[data-k="info"] { color: var(--info); border-color: color-mix(in srgb, var(--info) 45%, transparent); }
.tag[data-k="warn"] { color: var(--ring); border-color: color-mix(in srgb, var(--ring) 45%, transparent); }
.tag[data-k="ok"] { color: var(--live); border-color: color-mix(in srgb, var(--live) 45%, transparent); }
.tag[data-k="mute"] { color: var(--ink-3); }

.sev { display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-sm); font-weight: 600; white-space: nowrap; }
.sev[data-s="info"] { color: var(--info); }
.sev[data-s="warn"] { color: var(--ring); }
.sev[data-s="critical"] { color: var(--err); }

.cstat { font-size: var(--fs-sm); white-space: nowrap; }
.cstat::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: var(--ink-3); vertical-align: 1px; }
.cstat[data-k="ok"]::before { background: var(--live); }
.cstat[data-k="warn"] { color: var(--ring); }
.cstat[data-k="warn"]::before { background: transparent; border: 1.5px solid var(--ring); border-radius: 0; transform: rotate(45deg); }
.cstat[data-k="bad"] { color: var(--err); }
.cstat[data-k="bad"]::before { background: var(--err); border-radius: 0; }
.cstat[data-k="live"]::before { background: var(--live); animation: blink 1.2s steps(2) infinite; }
.cstat[data-k="mute"] { color: var(--ink-3); }

.dir { display: inline-flex; color: var(--ink-3); }
.dir[data-k="in"] { color: var(--c-in); }
.dir[data-k="out"] { color: var(--c-out); }
.dir[data-k="missed"] { color: var(--err); }

/* ---------- panels, page head ---------- */
.panel { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--panel); min-width: 0; }
.panel-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 40px; padding: 5px 8px 5px 14px; border-bottom: 1px solid var(--line); }
.panel-h h2 { display: flex; align-items: baseline; gap: 8px; }
.count { font-weight: 400; color: var(--ink-3); font-size: var(--fs-sm); }
.panel-b { padding: 14px; }
.panel-b.flush { padding: 0; }

.page { padding: 20px 24px 40px; max-width: 1440px; display: flex; flex-direction: column; gap: 16px; }
.page-h { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; min-height: 34px; }
.page-t { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.page-t p { font-size: var(--fs-sm); }
.page-a { flex-wrap: wrap; }

.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.filters .input { width: auto; }
.search { position: relative; display: flex; align-items: center; flex: 1 1 220px; max-width: 340px; }
.search .ic { position: absolute; left: 9px; color: var(--ink-3); pointer-events: none; }
.search .input { width: 100%; padding-left: 28px; }
.daterange { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); }

/* ---------- tables ---------- */
.blocks { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.blocks > .skel, .blocks > .empty { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--panel); max-width: none; }
.list-host { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--panel); min-width: 0; }
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: var(--fs); }
.tbl th { text-align: left; font-size: var(--fs-sm); font-weight: 500; color: var(--ink-3); padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 7px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: color-mix(in srgb, var(--raised) 60%, transparent); }
.tbl th:first-child, .tbl td:first-child { padding-left: 14px; }
.tbl th:last-child, .tbl td:last-child { padding-right: 14px; }
.tbl .r { text-align: right; }
.tbl .tight { width: 1%; white-space: nowrap; padding-left: 6px; padding-right: 6px; }
.tbl .wide { width: 34%; min-width: 150px; }
.tbl .fit { width: 1%; white-space: nowrap; }
.tbl th.clip { display: table-cell; }
.tbl td.clip, .tbl td.wide.clip { max-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: table-cell; }
.tbl td .clip { max-width: 34ch; }
.tbl.dense td { padding-top: 5px; padding-bottom: 5px; }
.tbl tr.dim td { color: var(--ink-3); }
.tbl .actions .row { justify-content: flex-end; }
.who { display: flex; flex-direction: column; gap: 1px; min-width: 0; align-items: flex-start; }
.who .num, .who .muted { font-size: var(--fs-sm); }
.who > strong, .who > .num, .who > a { white-space: nowrap; }
.menu-ph { display: inline-block; width: var(--ctl-sm); }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 14px; border-top: 1px solid var(--line); font-size: var(--fs-sm); }

.empty { padding: 36px 20px; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; max-width: 46ch; }
.empty-t { font-weight: 600; display: flex; align-items: center; gap: 6px; }
.empty-d { color: var(--ink-3); font-size: var(--fs-sm); }
.empty .btn { margin-top: 8px; }
.empty.is-error .empty-t { color: var(--err); }

.skel { padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.skel-row { height: 12px; width: var(--w, 70%); border-radius: 2px; background: var(--raised); animation: blink 1.4s ease-in-out infinite; }

.kv { display: grid; grid-template-columns: minmax(110px, max-content) 1fr; gap: 7px 18px; font-size: var(--fs); align-items: baseline; }
.kv dt { color: var(--ink-3); font-size: var(--fs-sm); padding-top: 1px; }
.kv dd { min-width: 0; }

.banner { display: flex; align-items: flex-start; gap: 10px; padding: 9px 12px; border: 1px solid var(--line-2); border-left-width: 3px; border-radius: var(--r); background: var(--panel); font-size: var(--fs-sm); line-height: 1.45; }
.banner > .ic { margin-top: 1px; }
.banner-b { flex: 1; min-width: 0; }
.banner[data-kind="warn"] { border-left-color: var(--ring); }
.banner[data-kind="warn"] > .ic { color: var(--ring); }
.banner[data-kind="error"] { border-left-color: var(--err); }
.banner[data-kind="error"] > .ic { color: var(--err); }
.banner[data-kind="info"] { border-left-color: var(--info); }
.banner[data-kind="info"] > .ic { color: var(--info); }

/* ---------- modal / drawer ---------- */
.modal-layer { position: fixed; inset: 0; z-index: 100; display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; padding: 24px; background: var(--scrim); animation: fade var(--t) ease-out; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
@keyframes slide { from { transform: translateX(24px); opacity: 0; } }
.modal { width: 100%; min-width: 0; max-height: calc(100dvh - 48px); display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line-2); border-radius: 6px; box-shadow: var(--shadow); animation: rise 130ms ease-out; }
.modal.sz-sm { max-width: 420px; }
.modal.sz-md { max-width: 540px; }
.modal.sz-lg { max-width: 720px; }
.modal.sz-xl { max-width: 1120px; }
.modal-h { display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 18px; border-bottom: 1px solid var(--line); }
.modal-h h2 { font-size: var(--fs-md); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-b { padding: 16px 18px; overflow: auto; display: flex; flex-direction: column; gap: 14px; min-height: 0; }
.modal-b > *, .form > * { min-width: 0; }
.form > div:empty { display: none; }
.modal-f { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }
.modal-msg { font-size: var(--fs); line-height: 1.5; }
.modal-layer[data-kind="drawer"] { place-items: stretch end; padding: 0; }
.modal-layer[data-kind="drawer"] .modal { max-width: 680px; max-height: none; height: 100dvh; border-radius: 0; border-width: 0 0 0 1px; animation: slide 140ms ease-out; }

/* ---------- menu ---------- */
.menu { position: fixed; z-index: 200; min-width: 184px; max-width: 280px; max-height: 70vh; overflow: auto; padding: 4px; background: var(--raised); border: 1px solid var(--line-2); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.menu-i { display: flex; align-items: center; gap: 8px; width: 100%; height: 30px; padding: 0 9px; border: 0; border-radius: 2px; background: transparent; font-size: var(--fs-sm); font-weight: 500; text-align: left; white-space: nowrap; }
.menu-i:hover:not(:disabled), .menu-i:focus-visible { background: var(--line); outline: none; }
.menu-i:disabled { color: var(--ink-3); opacity: .6; }
.menu-i.danger { color: var(--err); }
.menu-i .ic { color: var(--ink-3); }
.menu-i.danger .ic { color: inherit; }
.menu-gap { width: 14px; }
.menu-sep { height: 1px; background: var(--line-2); margin: 4px 0; }
.menu-sep:first-child, .menu-sep:last-child, .menu-sep + .menu-sep { display: none; }

/* ---------- toasts ---------- */
.toasts { position: fixed; z-index: 300; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: flex-start; gap: 9px; padding: 9px 8px 9px 11px; background: var(--raised); border: 1px solid var(--line-2); border-left: 3px solid var(--ink-3); border-radius: var(--r); box-shadow: var(--shadow); font-size: var(--fs-sm); line-height: 1.45; animation: rise 130ms ease-out; }
.toast.leaving { opacity: 0; transition: opacity 120ms; }
.toast-ic { margin-top: 1px; color: var(--ink-3); }
.toast-body { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow-wrap: anywhere; }
.toast[data-kind="ok"] { border-left-color: var(--live); }
.toast[data-kind="ok"] .toast-ic { color: var(--live); }
.toast[data-kind="error"] { border-left-color: var(--err); }
.toast[data-kind="error"] .toast-ic { color: var(--err); }
.toast[data-kind="warn"] { border-left-color: var(--ring); }
.toast[data-kind="warn"] .toast-ic { color: var(--ring); }
.toast[data-kind="info"] { border-left-color: var(--info); }
.toast[data-kind="info"] .toast-ic { color: var(--info); }

/* ---------- misc ---------- */
.reveal { display: flex; flex-direction: column; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--sunken); max-height: 260px; overflow: auto; }
.reveal-r { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.reveal-r:last-child { border-bottom: 0; }
.reveal-p { font: 500 15px var(--mono); letter-spacing: .04em; flex: 1; user-select: all; overflow-wrap: anywhere; }
.plain { display: flex; flex-direction: column; gap: 4px; font-size: var(--fs-sm); }
.steps { list-style: decimal; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font-size: var(--fs-sm); color: var(--ink-2); line-height: 1.5; }
.steps li::marker { font-family: var(--mono); color: var(--ink-3); }
.pre { margin: 0; padding: 10px 12px; background: var(--sunken); border: 1px solid var(--line); border-radius: var(--r); font: 12px/1.55 var(--mono); overflow: auto; max-height: 280px; white-space: pre-wrap; word-break: break-word; }
.support { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r); font-size: var(--fs-sm); }
.side-label { font-size: var(--fs-xs); color: var(--ink-3); }

.log { background: var(--sunken); border: 1px solid var(--line); border-radius: var(--r); font: 12px/1.6 var(--mono); max-height: 300px; overflow: auto; padding: 6px 0; }
.log.tall { max-height: 460px; }
.log-l { display: flex; gap: 10px; padding: 0 10px; white-space: pre-wrap; word-break: break-word; }
.log-l:hover { background: var(--panel); }
.log-t { color: var(--ink-3); flex: none; }
.log-lv { flex: none; width: 5ch; color: var(--ink-3); }
.log-a { flex: none; color: var(--info); }
.log-m { flex: 1; min-width: 0; }
.log-l[data-lv="warn"] .log-lv, .log-l[data-lv="warn"] .log-m { color: var(--ring); }
.log-l[data-lv="error"] .log-lv, .log-l[data-lv="error"] .log-m { color: var(--err); }
.log-l[data-lv="debug"] .log-m { color: var(--ink-3); }

.passfail { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-sm); font-weight: 600; }
.passfail[data-ok="1"] { color: var(--live); }
.passfail[data-ok="0"] { color: var(--err); }
.passfail[data-ok="n"] { color: var(--ink-2); font-weight: 500; }
.sel-sum { display: flex; align-items: center; gap: 6px; font-size: var(--fs-sm); font-weight: 600; margin-bottom: 8px; }
.sel-sum.ok { color: var(--live); }
.sel-sum.bad { color: var(--err); }

/* ---------- charts ---------- */
.chart { position: relative; }
.chart-plot svg { display: block; overflow: visible; }
.ax-grid { stroke: var(--line); stroke-width: 1; shape-rendering: crispEdges; }
.ax-base { stroke: var(--line-2); stroke-width: 1; shape-rendering: crispEdges; }
.ax-t { fill: var(--ink-3); font: 11px var(--sans); font-variant-numeric: tabular-nums; }
.seg.c-out { fill: var(--c-out); }
.seg.c-in { fill: var(--c-in); }
.c-missed-bg { fill: var(--c-missed); }
.c-hatch { stroke: var(--panel); opacity: .5; }
.hit { fill: transparent; outline: none; cursor: default; }
.col:hover .hit, .hit:focus-visible { fill: color-mix(in srgb, var(--ink) 7%, transparent); }
.chart-tip { position: absolute; z-index: 5; pointer-events: none; min-width: 132px; padding: 7px 9px; background: var(--raised); border: 1px solid var(--line-2); border-radius: var(--r); box-shadow: var(--shadow); font-size: var(--fs-sm); display: flex; flex-direction: column; gap: 3px; white-space: nowrap; }
.tip-r { display: flex; align-items: center; gap: 6px; color: var(--ink-2); }
.tip-r b { margin-left: auto; padding-left: 14px; color: var(--ink); font-weight: 500; }
.sw { display: inline-block; width: 9px; height: 9px; border-radius: 2px; flex: none; }
.sw.c-out { background: var(--c-out); }
.sw.c-in { background: var(--c-in); }
.sw.c-missed { background: repeating-linear-gradient(45deg, var(--c-missed) 0 2px, color-mix(in srgb, var(--c-missed) 55%, var(--panel)) 2px 4px); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: var(--fs-sm); color: var(--ink-2); margin-bottom: 8px; }
.legend-i { display: inline-flex; align-items: center; gap: 6px; }
.hours-cells { display: grid; grid-template-columns: repeat(24, 1fr); gap: 2px; }
.hour { height: 44px; border-radius: 2px; background: var(--sunken); display: grid; place-items: center; }
.hour[data-l="1"] { background: color-mix(in srgb, var(--c-out) 22%, var(--panel)); }
.hour[data-l="2"] { background: color-mix(in srgb, var(--c-out) 40%, var(--panel)); }
.hour[data-l="3"] { background: color-mix(in srgb, var(--c-out) 58%, var(--panel)); }
.hour[data-l="4"] { background: color-mix(in srgb, var(--c-out) 78%, var(--panel)); }
.hour[data-l="5"] { background: var(--c-out); }
.hour-v { font-size: 11px; color: var(--on-live); font-weight: 600; }
.hours-axis { display: grid; grid-template-columns: repeat(24, 1fr); gap: 2px; margin-top: 5px; font-size: 11px; color: var(--ink-3); }
.barcell { position: relative; display: flex; align-items: center; height: 20px; min-width: 90px; }
.barcell-b { position: absolute; left: 0; top: 4px; bottom: 4px; background: color-mix(in srgb, var(--c-out) 32%, transparent); border-radius: 0 2px 2px 0; border-left: 2px solid var(--c-out); }
.barcell .num { position: relative; padding-left: 8px; }

/* ---------- narrow screens ---------- */
@media (max-width: 720px) {
  .grid2 { grid-template-columns: 1fr; }
  .page { padding: 14px 14px 28px; gap: 12px; }
  .modal-layer { padding: 0; place-items: end stretch; }
  .modal, .modal.sz-sm, .modal.sz-md, .modal.sz-lg, .modal.sz-xl { max-width: none; max-height: 94dvh; border-radius: 10px 10px 0 0; border-width: 1px 0 0; }
  .modal-layer[data-kind="drawer"] .modal { height: 94dvh; border-width: 1px 0 0; border-radius: 10px 10px 0 0; animation: rise 130ms ease-out; }
  .modal-f { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .modal-f .btn { flex: 1; }
  .toasts { left: 12px; right: 12px; bottom: auto; top: 56px; width: auto; }
  .search { max-width: none; flex-basis: 100%; }
  .filters .select, .filters .daterange { flex: 1 1 140px; }
  .filters .daterange .input { flex: 1; }

  /* stack table rows into labelled blocks */
  .stackable .tbl thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .stackable .tbl, .stackable .tbl tbody { display: block; }
  .stackable .tbl tr { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); align-items: center; }
  .stackable .tbl tbody tr:last-child { border-bottom: 0; }
  .stackable .tbl td { display: flex; align-items: center; gap: 10px; padding: 0 !important; border: 0; width: auto !important; min-width: 0; max-width: none; grid-column: 1 / -1; text-align: left !important; }
  .stackable .tbl td[data-label]:not([data-label=""])::before { content: attr(data-label); flex: none; width: 84px; font-size: var(--fs-xs); color: var(--ink-3); }
  .stackable .tbl td.tight { grid-column: auto; }
  .stackable .tbl td.tight:first-child { order: 0; grid-column: 2; grid-row: 1; justify-self: end; }
  .stackable .tbl td.actions { grid-column: 1 / -1; justify-content: flex-end; }
  .stackable .tbl td:empty { display: none; }
  .stackable .tbl td.clip, .stackable .tbl td.wide.clip { display: flex; white-space: normal; max-width: none; overflow: visible; overflow-wrap: anywhere; }
  .stackable .tbl td.clip:empty, .stackable .tbl td.wide.clip:empty { display: none; }
  .tbl td .clip { max-width: none; white-space: normal; }
  .stackable .tbl td.lead::before { display: none !important; }
  .stackable .tbl td.lead { font-size: var(--fs-md); grid-column: 1; grid-row: 1; }
  .stackable .tbl td.lead + td.tight { grid-column: 2; }

  /* call history: a compact three-line row instead of one line per field */
  .stackable .tbl.calls tr { grid-template-columns: 18px repeat(4, minmax(0, 1fr)) 36px; gap: 3px 8px; }
  .stackable .tbl.calls td::before { display: none !important; }
  .stackable .tbl.calls td { grid-column: auto; }
  .stackable .tbl.calls .k-dir { grid-column: 1; grid-row: 1; }
  .stackable .tbl.calls .k-who { grid-column: 2 / 4; grid-row: 1; }
  .stackable .tbl.calls .k-when { grid-column: 4 / 6; grid-row: 1; justify-content: flex-end; font-size: var(--fs-sm); color: var(--ink-3); }
  .stackable .tbl.calls .k-call { grid-column: 6; grid-row: 1; justify-self: end; }
  .stackable .tbl.calls .k-line { grid-column: 2 / 3; grid-row: 2; font-size: var(--fs-sm); color: var(--ink-2); white-space: nowrap; }
  .stackable .tbl.calls .k-agent { grid-column: 3 / 4; grid-row: 2; font-size: var(--fs-sm); color: var(--ink-2); white-space: nowrap; overflow: hidden; }
  .stackable .tbl.calls .k-status { grid-column: 4 / 6; grid-row: 2; justify-content: flex-end; }
  .stackable .tbl.calls .k-len { grid-column: 6; grid-row: 2; justify-content: flex-end; font-size: var(--fs-sm); }
  .stackable .tbl.calls .k-out { grid-column: 2 / 4; grid-row: 3; }
  .stackable .tbl.calls .k-out .select { width: 100%; min-width: 0; }
  .stackable .tbl.calls .k-notes { grid-column: 4 / 7; grid-row: 3; }
  .input.inline { border-color: var(--line); margin-left: 0; flex: 1; }
}

/* ---------- switch (role="switch": on / off / unknown) ---------- */
.switch { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: start; column-gap: 10px; width: 100%; padding: 7px 0; border: 0; background: none; text-align: left; color: var(--ink); }
.switch + .switch { border-top: 1px solid var(--line); }
.switch:disabled { cursor: not-allowed; }
.switch:disabled .switch-n, .switch:disabled .switch-v { color: var(--ink-3); }
.switch:focus-visible { outline-offset: 2px; }
.switch-t { position: relative; width: 30px; height: 16px; margin-top: 2px; border: 1px solid var(--ink-3); border-radius: 9px; background: var(--sunken); transition: background var(--t), border-color var(--t); flex: none; }
.switch-k { position: absolute; top: 2px; left: 2px; width: 10px; height: 10px; border-radius: 50%; background: var(--ink-3); transition: transform var(--t), background var(--t); }
.switch[aria-checked="true"] .switch-t { background: var(--ink); border-color: var(--ink); }
.switch[aria-checked="true"] .switch-k { transform: translateX(14px); background: var(--bg); }
.switch[aria-checked="mixed"] .switch-t { border-style: dashed; }
.switch[aria-checked="mixed"] .switch-k { transform: translateX(7px); background: transparent; border: 1.5px solid var(--ink-3); }
.switch:disabled .switch-t { opacity: .55; }
.switch-l { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.switch-n { font-size: var(--fs); font-weight: 550; line-height: 1.35; }
.switch-v { font-size: var(--fs-xs); font-weight: 600; color: var(--ink-2); min-width: 54px; text-align: right; padding-top: 2px; white-space: nowrap; }
.switch[aria-checked="mixed"] .switch-v { color: var(--ring); }
.switch[aria-busy="true"] .switch-k { animation: blink 1s steps(2) infinite; }
.gv { display: flex; flex-direction: column; }
.gv-note { margin-top: 6px; min-height: 16px; }
.gv-note:empty { display: none; }

.badge[data-k="callbacks"] { background: var(--ring); color: #1a1202; }
:root[data-theme="light"] .badge[data-k="callbacks"] { color: #fff; }
