/* Front Desk admin — one stylesheet, light/dark via prefers-color-scheme, responsive to 360 px.
   No inline styles anywhere (CSP style-src 'self'): dynamic widths use .w-0 … .w-100 buckets. */

:root {
  color-scheme: light dark;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --surface-3: #e6e9ee;
  --border: #dde1e7;
  --border-strong: #c3c9d2;
  --text: #161a1f;
  --text-2: #39424d;
  --muted: #5a6470;
  --accent: #2457d6;
  --accent-hover: #1c46b0;
  --accent-soft: #e9efff;
  --accent-text: #1c46b0;
  --on-accent: #ffffff;
  --success: #1a7f37;
  --success-soft: #e5f4e9;
  --success-text: #146a2d;
  --warning: #9a6700;
  --warning-soft: #fff3d1;
  --warning-text: #714c00;
  --danger: #c62828;
  --danger-hover: #a91f1f;
  --danger-soft: #fdeaea;
  --danger-text: #a01b1b;
  --info: #0b6bcb;
  --info-soft: #e5f0fc;
  --info-text: #0957a5;
  --neutral-soft: #edf0f3;
  --neutral-text: #424a54;
  --live: #12a150;
  --on-danger: #ffffff;
  --on-live: #ffffff;
  --focus: #2457d6;
  --bubble-caller: #f1f3f6;
  --bubble-assistant: #e9efff;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .07);
  --shadow-lg: 0 16px 40px rgba(16, 24, 40, .22);
  --radius: 10px;
  --radius-sm: 7px;
  --sidebar-w: 236px;
  --topbar-h: 56px;
  --font: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Noto Sans SC", Roboto, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116;
    --surface: #161a21;
    --surface-2: #1c212a;
    --surface-3: #262c36;
    --border: #2a303b;
    --border-strong: #3b4351;
    --text: #e7eaf0;
    --text-2: #c4cad4;
    --muted: #9aa3b1;
    --accent: #7ea4ff;
    --accent-hover: #9ab8ff;
    --accent-soft: #1b2745;
    --accent-text: #abc3ff;
    --on-accent: #0b1220;
    --success: #4cc46f;
    --success-soft: #142c1d;
    --success-text: #80d99a;
    --warning: #d8ac34;
    --warning-soft: #30270f;
    --warning-text: #ecc767;
    --danger: #ff6d6d;
    --danger-hover: #ff8a8a;
    --danger-soft: #3a191b;
    --danger-text: #ff9d9d;
    --info: #5aa8ff;
    --info-soft: #12283f;
    --info-text: #91c5ff;
    --neutral-soft: #222833;
    --neutral-text: #c4cad4;
    --live: #3ccf74;
    --on-danger: #1c0707;
    --on-live: #04210f;
    --focus: #9ab8ff;
    --bubble-caller: #1f252f;
    --bubble-assistant: #1b2745;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-lg: 0 18px 44px rgba(0, 0, 0, .55);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scrollbar-gutter: stable; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
body.modal-open { overflow: hidden; }
h1, h2, h3, h4, p, ul, ol, dl, dd, figure, pre { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
code, pre, .mono { font-family: var(--mono); font-size: .9em; }
code { background: var(--surface-2); border-radius: 4px; padding: .05em .35em; }
img, svg { display: inline-block; vertical-align: middle; }
.icon { flex: none; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.wrap { white-space: normal; overflow-wrap: anywhere; word-break: break-word; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-variant-numeric: tabular-nums; }
.phone { font-variant-numeric: tabular-nums; white-space: nowrap; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mt { margin-top: 14px; }
.stack { display: flex; flex-direction: column; gap: 2px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.stack-md { display: flex; flex-direction: column; gap: 14px; }
.stack-lg { display: flex; flex-direction: column; gap: 18px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.badges { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.badges-stack { flex-direction: column; align-items: flex-start; }
.meta-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; color: var(--muted); font-size: .9rem; }
.subhead { font-size: .95rem; font-weight: 600; margin-bottom: 8px; }
.note-text, .summary-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.summary-text { font-size: 1.02rem; }
.code-block {
  margin-top: 8px; padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); overflow-x: auto; font-size: .85rem;
}
.code-block code { background: none; padding: 0; }

/* ---------- boot ---------- */
.boot-screen { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.boot-text { color: var(--muted); }
.boot-card { max-width: 420px; width: 100%; }
.noscript { padding: 24px; text-align: center; }

/* ---------- shell ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  grid-template-rows: var(--topbar-h) minmax(0, 1fr);
  grid-template-areas: "side top" "side main";
  min-height: 100vh;
}
.skip-link {
  position: fixed; left: 12px; top: -60px; z-index: 100; padding: 8px 14px; border-radius: var(--radius-sm);
  background: var(--accent); color: var(--on-accent); border: 0; cursor: pointer;
}
.skip-link:focus, .skip-link:focus-visible { top: 10px; }

.sidebar {
  grid-area: side; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--border);
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; height: var(--topbar-h); padding: 0 16px; border-bottom: 1px solid var(--border); flex: none; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; flex: none;
  background: var(--accent); color: var(--on-accent);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-name { font-weight: 700; letter-spacing: .01em; }
.brand-sub { font-size: .78rem; color: var(--muted); }
.icon-btn.nav-close { display: none; margin-left: auto; }
.nav { padding: 10px 10px 16px; flex: 1; }
.nav-group + .nav-group { margin-top: 10px; }
.nav-group-title { font-size: .74rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 8px 10px 4px; }
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500; text-decoration: none; min-height: 40px;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--accent-soft); color: var(--accent-text); }
.nav-link.active .icon { color: var(--accent-text); }
.nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-count {
  min-width: 22px; height: 20px; padding: 0 6px; border-radius: 10px; font-size: .75rem; font-weight: 700;
  display: inline-grid; place-items: center; background: var(--neutral-soft); color: var(--neutral-text);
}
.nav-count-danger { background: var(--danger); color: var(--on-danger); }
.nav-count-warning { background: var(--warning-soft); color: var(--warning-text); }
.nav-count-live { background: var(--live); color: var(--on-live); }
.sidebar-foot { padding: 12px 20px; border-top: 1px solid var(--border); min-height: 44px; }
.nav-backdrop { display: none; }

.topbar {
  grid-area: top; position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: 0 20px; background: color-mix(in srgb, var(--surface) 92%, transparent);
  border-bottom: 1px solid var(--border); backdrop-filter: saturate(1.4) blur(8px); min-width: 0;
}
.icon-btn.menu-btn { display: none; }
.topbar-title { display: flex; align-items: baseline; gap: 12px; min-width: 0; flex: 1; }
.company { font-weight: 650; font-size: 1.02rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.config-ver { font-size: .82rem; color: var(--muted); white-space: nowrap; text-decoration: none; }
.config-ver:hover { color: var(--text); text-decoration: none; }
.config-ver code { font-size: .8rem; }
.topbar-tools { display: flex; align-items: center; gap: 10px; flex: none; }
.health-btn {
  display: inline-flex; align-items: center; padding: 5px 10px; border-radius: 999px; border: 1px solid var(--border);
  color: var(--text-2); font-size: .85rem; text-decoration: none; min-height: 32px;
}
.health-btn:hover { background: var(--surface-2); text-decoration: none; }

.user-menu { position: relative; }
.user-btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 4px 8px 4px 4px; border: 1px solid var(--border);
  border-radius: 999px; background: var(--surface); cursor: pointer; min-height: 36px;
}
.user-btn:hover { background: var(--surface-2); }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .85rem;
  background: var(--accent-soft); color: var(--accent-text);
}
.user-name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 210px; z-index: 50; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.menu-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; background: none;
  border-radius: var(--radius-sm); color: var(--text); cursor: pointer; text-align: left; text-decoration: none; font-size: .93rem;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-2); text-decoration: none; }

.main { grid-area: main; min-width: 0; padding: 22px 24px 48px; }
.main:focus, .main:focus-visible { outline: none; }
.shell-banner { margin-bottom: 16px; }
.page-host { min-width: 0; }

/* ---------- page ---------- */
.page { display: flex; flex-direction: column; gap: 18px; max-width: 1360px; margin: 0 auto; min-width: 0; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
.page-titles { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.page-title { font-size: 1.45rem; font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.page-sub { color: var(--muted); font-size: .92rem; max-width: 72ch; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.back-link { display: inline-flex; align-items: center; gap: 2px; font-size: .88rem; color: var(--muted); width: fit-content; }
.back-link:hover { color: var(--text); }
.page-error { max-width: 760px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; }
.toolbar-note { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- cards & grids ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 14px 18px 0; }
.card-titles { min-width: 0; }
.card-title { font-size: 1.02rem; font-weight: 650; line-height: 1.35; }
.card-sub { color: var(--muted); font-size: .85rem; margin-top: 2px; }
.card-actions { display: flex; gap: 6px; flex: none; }
.card-body { padding: 14px 18px 18px; min-width: 0; }
.card-flush > .card-body { padding: 0; }
.card-flush > .card-head { padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; align-items: start; }
.grid-tight { gap: 14px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 38px; padding: 7px 14px;
  border: 1px solid transparent; border-radius: var(--radius-sm); font-weight: 550; font-size: .92rem; line-height: 1.2;
  cursor: pointer; text-decoration: none; white-space: nowrap; user-select: none;
  transition: background-color .12s ease, border-color .12s ease, color .12s ease;
}
.btn:hover { text-decoration: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: var(--on-danger); }
.btn-danger:hover:not(:disabled) { background: var(--danger-hover); }
.btn-ghost { background: transparent; color: var(--accent-text); }
.btn-ghost:hover:not(:disabled) { background: var(--accent-soft); }
.btn-sm { min-height: 32px; padding: 5px 10px; font-size: .86rem; gap: 5px; }
.btn-block { width: 100%; }
.btn-icon { padding: 7px; width: 38px; }
.btn-sm.btn-icon { width: 32px; padding: 5px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-2); cursor: pointer; flex: none;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.spinner {
  width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent;
  display: inline-block; animation: spin .7s linear infinite; flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- form controls ---------- */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field-label { font-weight: 550; font-size: .9rem; color: var(--text-2); }
.req { color: var(--danger-text); }
.field-help { font-size: .82rem; color: var(--muted); }
.field-error { font-size: .84rem; color: var(--danger-text); display: flex; gap: 4px; align-items: flex-start; }
.field-error .icon { margin-top: 2px; }
.field-inline { flex-direction: row; align-items: center; gap: 10px; }
.field-compact { min-width: 150px; }
.field-grow { flex: 1; }
.input {
  width: 100%; min-height: 38px; padding: 7px 11px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font-size: .95rem; line-height: 1.4; min-width: 0;
}
.input::placeholder { color: var(--muted); opacity: .85; }
.input:hover:not(:disabled) { border-color: var(--muted); }
.input:focus, .input:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus); border-radius: var(--radius-sm); }
.input:disabled { background: var(--surface-2); color: var(--muted); }
.has-error .input, .input[aria-invalid="true"] { border-color: var(--danger); }
.textarea { resize: vertical; min-height: 64px; }
.select {
  appearance: none; -webkit-appearance: none; padding-right: 32px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%; background-size: 5px 5px; background-repeat: no-repeat;
}
.select option { background: var(--surface); color: var(--text); }
input[type="date"].input { min-width: 140px; }
input[type="search"].input::-webkit-search-cancel-button { cursor: pointer; }
.input-sm { min-height: 32px; padding: 4px 9px; font-size: .88rem; }
.input-code { letter-spacing: .3em; font-family: var(--mono); font-size: 1.1rem; }
.input-group { display: flex; align-items: stretch; min-width: 0; }
.input-group .input { flex: 1; }
.input-group .input:not(:last-child) { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-unit {
  display: inline-flex; align-items: center; padding: 0 10px; border: 1px solid var(--border-strong); border-left: 0;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0; background: var(--surface-2); color: var(--muted); font-size: .86rem; white-space: nowrap;
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; min-height: 32px; padding: 4px 11px; border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); font-size: .88rem; cursor: pointer;
}
.chip:hover:not(:disabled) { background: var(--surface-2); }
.chip.on { background: var(--accent-soft); border-color: transparent; color: var(--accent-text); }
.chip:disabled { opacity: .55; cursor: not-allowed; }
.chip-sm { min-height: 28px; padding: 2px 10px; font-size: .84rem; }
.chip-static { cursor: default; }
.chip-x { display: inline-grid; place-items: center; width: 22px; height: 22px; margin-right: -6px; border: 0; border-radius: 50%; background: transparent; color: inherit; cursor: pointer; }
.chip-x:hover { background: var(--surface-3); }
.chip-add { display: inline-flex; align-items: center; gap: 2px; }
.chip-add .input { width: 130px; }
.chips-input { padding: 4px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); min-height: 38px; }
.chips-input .chip { cursor: default; }
.chip-entry { flex: 1; min-width: 110px; border: 0; padding: 4px 6px; }
.chip-entry:focus, .chip-entry:focus-visible { outline: none; }
.chips-input:focus-within { outline: 2px solid var(--focus); border-color: var(--focus); }

.toggle-row, .check-row { display: flex; align-items: flex-start; gap: 12px; }
.toggle-text { display: flex; flex-direction: column; gap: 2px; padding-top: 2px; min-width: 0; }
.toggle-label { font-weight: 550; cursor: pointer; }
.toggle-desc { font-size: .84rem; color: var(--muted); }
.switch {
  appearance: none; -webkit-appearance: none; position: relative; flex: none; width: 42px; height: 24px; margin: 1px 0 0;
  border-radius: 999px; background: var(--border-strong); cursor: pointer; transition: background-color .15s ease;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .3); transition: transform .15s ease;
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(18px); }
.switch:disabled { opacity: .5; cursor: not-allowed; }
.switch:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.checkbox { width: 18px; height: 18px; margin: 3px 0 0; accent-color: var(--accent); flex: none; cursor: pointer; }

.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); max-width: 100%; overflow-x: auto; }
.seg { border: 0; background: transparent; padding: 6px 12px; border-radius: 5px; color: var(--text-2); cursor: pointer; font-size: .9rem; white-space: nowrap; min-height: 32px; }
.seg:hover { color: var(--text); }
.seg.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-weight: 600; }
.segmented-sm .seg { padding: 3px 9px; font-size: .82rem; min-height: 26px; }

/* ---------- badges, lights, banners ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: .78rem; font-weight: 600;
  line-height: 1.5; white-space: nowrap; background: var(--neutral-soft); color: var(--neutral-text);
}
.badge-info { background: var(--info-soft); color: var(--info-text); }
.badge-success { background: var(--success-soft); color: var(--success-text); }
.badge-warning { background: var(--warning-soft); color: var(--warning-text); }
.badge-danger { background: var(--danger-soft); color: var(--danger-text); }
.badge-accent { background: var(--accent-soft); color: var(--accent-text); }
.light { display: inline-flex; align-items: center; gap: 7px; }
.light-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--border-strong); box-shadow: 0 0 0 3px color-mix(in srgb, var(--border-strong) 25%, transparent); }
.light-ok .light-dot { background: var(--success); box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 22%, transparent); }
.light-warn .light-dot { background: var(--warning); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warning) 25%, transparent); }
.light-error .light-dot { background: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 25%, transparent); }
.banner {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: var(--radius); border: 1px solid transparent;
  background: var(--info-soft); color: var(--text);
}
.banner-icon { color: var(--info-text); margin-top: 1px; flex: none; }
.banner-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; overflow-wrap: anywhere; }
.banner-title { font-weight: 650; }
.banner-text { font-size: .92rem; color: var(--text-2); }
.banner-text p + p { margin-top: 4px; }
.banner-actions { display: flex; gap: 6px; flex: none; align-self: center; }
.banner-success { background: var(--success-soft); }
.banner-success .banner-icon { color: var(--success-text); }
.banner-warning { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 30%, transparent); }
.banner-warning .banner-icon { color: var(--warning-text); }
.banner-danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.banner-danger .banner-icon { color: var(--danger-text); }
.config-errors { margin-top: 6px; display: flex; flex-direction: column; gap: 3px; font-size: .88rem; }
/* config warnings banner (config pages, dashboard, system) */
.warning-list { margin: 6px 0 0; padding-left: 18px; list-style: disc; display: flex; flex-direction: column; gap: 4px; font-size: .88rem; }
.warning-file { font-weight: 600; }
.cfg-warnings .warning-more { margin: 6px 0 0 -8px; }
.form-error {
  display: flex; align-items: flex-start; gap: 6px; padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--danger-soft); color: var(--danger-text); font-size: .92rem;
}
.form-error .icon { margin-top: 2px; }

.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 36px 16px; color: var(--muted); }
.empty-compact { padding: 18px 12px; }
.empty-icon { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); margin-bottom: 4px; }
.empty-compact .empty-icon { width: 38px; height: 38px; }
.empty-title { font-weight: 600; color: var(--text-2); }
.empty-msg { font-size: .9rem; max-width: 46ch; }
.empty-action { margin-top: 8px; }
.loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 36px 16px; color: var(--muted); }
.loading-inline { justify-content: flex-start; padding: 6px 0; }

.kv { display: grid; grid-template-columns: minmax(110px, max-content) minmax(0, 1fr); gap: 0; }
.kv-row { display: contents; }
.kv dt, .kv dd { padding: 7px 0; border-bottom: 1px solid var(--border); }
.kv dt { color: var(--muted); font-size: .88rem; padding-right: 16px; }
.kv dd { overflow-wrap: anywhere; min-width: 0; }
.kv-row:last-child dt, .kv-row:last-child dd { border-bottom: 0; }
.kv-compact { margin-top: 12px; }
.kv-compact dt, .kv-compact dd { padding: 4px 0; font-size: .86rem; }

/* width buckets (bars) */
.w-0 { width: 0; } .w-5 { width: 5%; } .w-10 { width: 10%; } .w-15 { width: 15%; } .w-20 { width: 20%; }
.w-25 { width: 25%; } .w-30 { width: 30%; } .w-35 { width: 35%; } .w-40 { width: 40%; } .w-45 { width: 45%; }
.w-50 { width: 50%; } .w-55 { width: 55%; } .w-60 { width: 60%; } .w-65 { width: 65%; } .w-70 { width: 70%; }
.w-75 { width: 75%; } .w-80 { width: 80%; } .w-85 { width: 85%; } .w-90 { width: 90%; } .w-95 { width: 95%; } .w-100 { width: 100%; }

/* ---------- table ---------- */
.table-wrap { width: 100%; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th {
  text-align: left; font-weight: 600; font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em;
  padding: 10px 11px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap;
}
.table th.num { text-align: right; }
.table td { padding: 10px 11px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tr.clickable { cursor: pointer; }
.table tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
.table tr.row-urgent td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.row-link { font-weight: 600; white-space: nowrap; }
.col-summary { min-width: 200px; max-width: 560px; }
.caller-line { font-weight: 500; }
.caller-line strong { font-weight: 600; }
.summary-line { color: var(--text-2); }
.col-actions { white-space: nowrap; }
.col-detail { max-width: 360px; }
.lang-tag {
  display: inline-block; font-size: .7rem; font-weight: 700; padding: 0 5px; border-radius: 4px; border: 1px solid var(--border-strong);
  color: var(--muted); text-decoration: none; line-height: 1.5; vertical-align: 1px;
}
.urgent-mark { color: var(--danger-text); display: inline-flex; vertical-align: -2px; }

.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.pager-info { color: var(--muted); font-size: .88rem; }
.pager-btns { display: flex; gap: 8px; }

/* ---------- tabs ---------- */
.tablist { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: thin; }
.tab {
  border: 0; background: none; padding: 10px 14px; color: var(--muted); font-weight: 550; cursor: pointer; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px; display: inline-flex; align-items: center; gap: 6px; min-height: 42px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent-text); border-bottom-color: var(--accent); }
.tab-badge { font-size: .72rem; padding: 0 6px; border-radius: 999px; background: var(--neutral-soft); color: var(--neutral-text); }
.tabpanel { padding-top: 16px; }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: rgba(10, 14, 20, .55); animation: fade .12s ease;
}
.modal {
  width: 100%; max-height: calc(100vh - 32px); display: flex; flex-direction: column; background: var(--surface);
  border-radius: 14px; box-shadow: var(--shadow-lg); border: 1px solid var(--border); animation: pop .14s ease;
}
.modal-sm { max-width: 440px; }
.modal-md { max-width: 620px; }
.modal-lg { max-width: 920px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 18px 6px; }
.modal-title { font-size: 1.1rem; font-weight: 650; }
.modal-body { padding: 8px 18px 16px; overflow-y: auto; }
.modal-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 12px 18px 16px; border-top: 1px solid var(--border); }
.confirm-msg { color: var(--text-2); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.985); } }

/* ---------- toasts ---------- */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 90; display: flex; flex-direction: column; gap: 8px; width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.toast-region { display: flex; flex-direction: column; gap: 8px; }
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; padding: 11px 10px 11px 14px; border-radius: var(--radius);
  background: var(--text); color: var(--bg); box-shadow: var(--shadow-lg); animation: pop .16s ease; font-size: .92rem;
}
.toast .icon-btn { color: inherit; width: 28px; height: 28px; opacity: .8; }
.toast .icon-btn:hover { background: rgba(127, 127, 127, .25); opacity: 1; }
.toast > .icon { margin-top: 2px; }
.toast-msg { flex: 1; overflow-wrap: anywhere; }
.toast-success > .icon { color: var(--success-soft); }
.toast-error { background: var(--danger); color: var(--on-danger); }
.toast-warning > .icon { color: var(--warning-soft); }

/* ---------- audio ---------- */
.audio { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.audio audio { width: 100%; max-width: 420px; height: 40px; }
.audio-failed { display: inline-flex; gap: 6px; align-items: center; }

/* ---------- date range, editors ---------- */
.daterange { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 14px; min-width: 0; }
.daterange-inputs { display: flex; flex-wrap: wrap; gap: 10px; }
.daterange-presets { display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 3px; }
.kv-editor, .list-editor { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.kv-editor-row { display: grid; grid-template-columns: minmax(120px, 1fr) minmax(0, 2fr) auto; gap: 8px; align-items: end; width: 100%; }
.kv-remove { margin-bottom: 0; }
.list-item { display: flex; gap: 8px; width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.list-item-body { flex: 1; min-width: 0; }
.list-item-tools { display: flex; gap: 2px; align-items: flex-start; flex: none; }
.svg-image { width: 220px; height: 220px; max-width: 100%; background: #fff; padding: 8px; border-radius: var(--radius-sm); border: 1px solid var(--border); }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background:
  radial-gradient(1200px 500px at 50% -10%, var(--accent-soft), transparent 70%), var(--bg); }
.login-card {
  width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 18px; padding: 28px 26px 22px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg);
}
.login-card:focus { outline: none; }
.login-brand { display: flex; align-items: center; gap: 12px; }
.login-brand .brand-mark { width: 42px; height: 42px; border-radius: 12px; }
.login-brand .brand-name { font-size: 1.1rem; }
.login-title { font-size: 1.35rem; font-weight: 700; }
.login-note { text-align: center; }
.login-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding-top: 4px; border-top: 1px solid var(--border); padding-top: 14px; }

/* ---------- dashboard ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.kpi {
  display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: var(--radius); background: var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow); color: var(--text); text-decoration: none; min-width: 0;
}
.kpi:hover { border-color: var(--border-strong); text-decoration: none; }
.kpi-icon { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); flex: none; }
.kpi-text { display: flex; flex-direction: column; min-width: 0; }
.kpi-value { font-size: 1.6rem; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi-label { color: var(--muted); font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi-hint { font-size: .78rem; color: var(--muted); }
.kpi-live .kpi-icon { background: color-mix(in srgb, var(--live) 18%, transparent); color: var(--live); }
.kpi-warning .kpi-icon { background: var(--warning-soft); color: var(--warning-text); }
.kpi-danger .kpi-icon { background: var(--danger-soft); color: var(--danger-text); }
.kpi-danger .kpi-value { color: var(--danger-text); }
.usage-row + .usage-row { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.usage-title { font-size: .85rem; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.usage-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.usage-stats dt { font-size: .8rem; color: var(--muted); }
.usage-stats dd { font-size: 1.3rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: minmax(80px, 128px) minmax(0, 1fr) 40px; gap: 10px; align-items: center; }
.bar-label { color: var(--text-2); font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { height: 10px; border-radius: 5px; background: var(--surface-2); overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 5px; background: var(--accent); }
.bar-outcome { background: var(--success); }
.bar-value { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; font-size: .9rem; }
.mini-list { display: flex; flex-direction: column; }
.mini-list li + li { border-top: 1px solid var(--border); }
.mini-item { display: flex; align-items: center; gap: 10px; padding: 9px 4px; color: var(--text); text-decoration: none; min-width: 0; }
.mini-item:hover { background: var(--surface-2); text-decoration: none; border-radius: var(--radius-sm); }
.mini-time { color: var(--muted); font-size: .84rem; flex: none; min-width: 74px; }
.mini-main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.mini-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-sub { color: var(--muted); font-size: .84rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-side { display: flex; align-items: center; gap: 6px; flex: none; }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--live); flex: none; display: inline-block; animation: pulse 1.6s ease-in-out infinite; }
.live-dot.off { background: var(--border-strong); animation: none; }
@keyframes pulse { 50% { opacity: .35; } }

.health-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 18px; }
.health-item { display: flex; align-items: flex-start; gap: 10px; min-width: 0; }
.health-item .light { margin-top: 6px; }
.health-text { display: flex; flex-direction: column; min-width: 0; }
.health-label { font-weight: 550; font-size: .92rem; }
.health-detail { font-size: .82rem; color: var(--muted); overflow-wrap: anywhere; }
.secret-list { display: flex; flex-direction: column; gap: 6px; }
.secret-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--border); }

/* ---------- calls ---------- */
.filters { padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.filters-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 12px; }
.search-box { position: relative; flex: 1 1 260px; min-width: 0; display: flex; }
.search-box .field { flex: 1; }
.search-box .input { padding-left: 36px; }
.search-icon { position: absolute; left: 11px; top: 10px; color: var(--muted); pointer-events: none; z-index: 1; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 380px); gap: 18px; align-items: start; }
.detail-main, .detail-side { display: flex; flex-direction: column; gap: 18px; min-width: 0; }

.transcript { display: flex; flex-direction: column; gap: 10px; }
.bubble-row { display: flex; }
.bubble { max-width: min(78%, 640px); padding: 9px 13px; border-radius: 14px; background: var(--bubble-caller); }
.bubble-caller .bubble { border-bottom-left-radius: 4px; }
.bubble-assistant { justify-content: flex-end; }
.bubble-assistant .bubble { background: var(--bubble-assistant); border-bottom-right-radius: 4px; }
.bubble-system { justify-content: center; }
.bubble-system .bubble { background: transparent; border: 1px dashed var(--border-strong); max-width: 90%; font-size: .86rem; color: var(--muted); }
.bubble-meta { display: flex; gap: 8px; align-items: baseline; font-size: .75rem; color: var(--muted); margin-bottom: 2px; }
.bubble-who { font-weight: 650; }
.bubble-time { font-family: var(--mono); }
.bubble-text { white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- notifications ---------- */
.notif-list { display: flex; flex-direction: column; gap: 12px; }
.notif {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 8px; min-width: 0;
}
.notif-unacked { border-left: 3px solid var(--warning); }
.notif-urgent { border-left-color: var(--danger); }
.notif-list-compact .notif { box-shadow: none; padding: 12px; }
.notif-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.notif-kind { display: inline-flex; align-items: center; gap: 5px; font-size: .84rem; font-weight: 600; color: var(--text-2); }
.notif-time { margin-left: auto; font-size: .84rem; }
.notif-title { font-size: 1rem; font-weight: 650; overflow-wrap: anywhere; }
.notif-body { color: var(--text-2); white-space: pre-wrap; overflow-wrap: anywhere; font-size: .93rem; }
.notif-recipients { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.notif-deliveries summary { cursor: pointer; font-size: .88rem; color: var(--accent-text); font-weight: 550; padding: 2px 0; width: fit-content; }
.notif-deliveries[open] summary { margin-bottom: 8px; }
.notif-actions { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 4px; }
.timeline { position: relative; display: flex; flex-direction: column; gap: 10px; padding-left: 4px; }
.tl-item { position: relative; display: flex; gap: 10px; }
.tl-item:not(:last-child)::before { content: ""; position: absolute; left: 12px; top: 26px; bottom: -12px; width: 2px; background: var(--border); }
.tl-dot { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--neutral-soft); color: var(--neutral-text); position: relative; }
.tl-success .tl-dot { background: var(--success-soft); color: var(--success-text); }
.tl-info .tl-dot { background: var(--info-soft); color: var(--info-text); }
.tl-warning .tl-dot { background: var(--warning-soft); color: var(--warning-text); }
.tl-danger .tl-dot { background: var(--danger-soft); color: var(--danger-text); }
.tl-body { min-width: 0; padding-top: 2px; }
.tl-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: .9rem; }
.tl-meta { font-size: .8rem; color: var(--muted); overflow-wrap: anywhere; }

/* ---------- live ---------- */
.live-layout { display: grid; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); gap: 18px; align-items: start; }
.live-list { display: flex; flex-direction: column; }
.live-list li + li { border-top: 1px solid var(--border); }
.live-item { display: flex; align-items: center; gap: 10px; padding: 12px 16px; color: var(--text); text-decoration: none; }
.live-item:hover { background: var(--surface-2); text-decoration: none; }
.live-item.active { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.live-item.ended { opacity: .7; }
.live-item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.live-item-top { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.live-item-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: .84rem; }
.live-item-time { font-size: .9rem; color: var(--text-2); }
.live-detail { min-height: 420px; display: flex; flex-direction: column; }
.live-detail > .empty { flex: 1; justify-content: center; }
.live-detail-inner { display: flex; flex-direction: column; flex: 1; min-height: 0; position: relative; }
.live-detail-head { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px 14px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.live-back { display: none; }
.live-detail-title { flex: 1 1 240px; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.live-detail-title .card-title { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.live-detail-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.live-transcript { flex: 1; overflow-y: auto; padding: 16px 18px; max-height: calc(100vh - 260px); min-height: 300px; }
.jump-latest { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); }
.conn-state { font-size: .88rem; color: var(--muted); padding: 6px 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); }

/* ---------- voicemail ---------- */
.vm-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
.vm-card { padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.vm-new { border-left: 3px solid var(--warning); }
.vm-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 10px; }
.vm-title { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.vm-note { display: flex; flex-direction: column; gap: 8px; }

/* ---------- numbers ---------- */
.number-list { display: flex; flex-direction: column; }
.number-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.number-list li:last-child { border-bottom: 0; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-grid { grid-template-columns: minmax(0, 1fr) minmax(280px, 340px); }
}

@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-areas: "top" "main"; }
  .sidebar {
    position: fixed; z-index: 70; left: 0; top: 0; bottom: 0; width: min(290px, 86vw); height: auto;
    transform: translateX(-102%); transition: transform .2s ease; box-shadow: var(--shadow-lg); visibility: hidden;
  }
  .nav-open .sidebar { transform: none; visibility: visible; }
  .nav-open .nav-backdrop { display: block; position: fixed; inset: 0; z-index: 60; background: rgba(10, 14, 20, .5); }
  .icon-btn.nav-close { display: inline-grid; }
  .icon-btn.menu-btn { display: inline-grid; margin-left: -8px; }
  .topbar { padding: 0 16px; gap: 8px; }
  .main { padding: 18px 16px 40px; }
  .grid-2, .grid-3, .detail-grid { grid-template-columns: minmax(0, 1fr); }
  .vm-list { grid-template-columns: minmax(0, 1fr); }
  .live-layout { grid-template-columns: minmax(0, 1fr); }
  .page-live.has-selection .live-list-card { display: none; }
  .page-live:not(.has-selection) .live-detail { display: none; }
  .live-back { display: inline-flex; width: 100%; justify-content: flex-start; margin: -4px 0 0 -8px; }
  .live-transcript { max-height: none; min-height: 50vh; }
  .health-btn-text, .config-ver-label { display: none; }
  .health-btn { padding: 5px 9px; }
}

@media (max-width: 640px) {
  body { font-size: 14.5px; }
  .page { gap: 14px; }
  .page-title { font-size: 1.25rem; }
  .page-head { align-items: flex-start; }
  .user-name { display: none; }
  .user-btn { padding: 4px; }
  .user-btn > .icon { display: none; }
  .topbar-title { flex-direction: column; gap: 0; align-items: flex-start; }
  .company { font-size: .95rem; max-width: 100%; }
  .config-ver { font-size: .74rem; line-height: 1.2; }
  .kpi-grid { gap: 10px; }
  .kpi { padding: 12px; gap: 10px; flex-direction: column; align-items: flex-start; }
  .kpi-icon { width: 34px; height: 34px; }
  .kpi-value { font-size: 1.35rem; }
  .card-head { padding: 12px 14px 0; }
  .card-body { padding: 12px 14px 14px; }
  .health-grid { grid-template-columns: minmax(0, 1fr); }
  .usage-stats dd { font-size: 1.1rem; }
  .filters { padding: 12px; }
  .field-compact { min-width: 0; flex: 1 1 140px; }
  .daterange, .daterange-inputs { width: 100%; }
  .daterange-inputs .field { flex: 1 1 130px; }
  .kv { grid-template-columns: minmax(0, 1fr); }
  .kv dt { border-bottom: 0; padding-bottom: 0; }
  .kv dd { padding-top: 2px; }
  .bubble { max-width: 90%; }
  .modal-backdrop { padding: 10px; align-items: flex-end; }
  .modal { max-height: calc(100vh - 20px); }
  .modal-foot .btn { flex: 1; }
  .kv-editor-row { grid-template-columns: minmax(0, 1fr) auto; }
  .kv-editor-row .kv-key { grid-column: 1 / -1; }
  .login-card { padding: 22px 18px 18px; }
  .banner { flex-wrap: wrap; }
  .banner-body { flex: 1 1 calc(100% - 64px); }
  .banner-actions { margin-left: 28px; align-self: flex-start; }

  /* tables become cards */
  .table-wrap { overflow: visible; }
  .rt thead { display: none; }
  .rt, .rt tbody, .rt tr, .rt td { display: block; width: 100%; }
  .rt tr { padding: 10px 14px; border-bottom: 1px solid var(--border); }
  .rt tbody tr:last-child { border-bottom: 0; }
  .rt td { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 4px 0; border: 0; text-align: right; }
  .rt td::before { content: attr(data-label); color: var(--muted); font-size: .8rem; font-weight: 600; text-align: left; flex: none; max-width: 45%; padding-top: 1px; }
  .rt td[data-label=""]::before { display: none; }
  .rt td.td-primary { font-size: 1rem; padding-bottom: 6px; }
  .rt td > .td-v { min-width: 0; overflow-wrap: anywhere; }
  .rt td.td-empty { display: none; }
  .rt tbody tr:hover td { background: none; }
  .rt tr.row-urgent { box-shadow: inset 3px 0 0 var(--danger); }
  .rt tr.row-urgent td:first-child { box-shadow: none; }
  .col-summary { max-width: none; min-width: 0; }
  .rt td.col-summary { text-align: left; flex-direction: column; gap: 2px; }
  .rt td.col-summary::before { max-width: none; }
  .rt .row-actions { justify-content: flex-end; }
  .rt .badges-stack { flex-direction: row; justify-content: flex-end; }
  .rt .stack { align-items: flex-end; }
  .rt .caller-cell { align-items: flex-start; text-align: left; }
  .rt td.num { text-align: right; }
}

@media (max-width: 400px) {
  .topbar-tools { gap: 6px; }
  .segmented-sm .seg { padding: 3px 7px; }
  .bar-row { grid-template-columns: minmax(64px, 96px) minmax(0, 1fr) 32px; gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

@media print {
  .sidebar, .topbar, .toasts, .page-actions, .filters { display: none !important; }
  .app { display: block; }
  .card { box-shadow: none; }
}

/* =====================================================================================
   F2 — configuration editor, config history, account / admin users
   ===================================================================================== */

/* ---------- shared bits ---------- */
.mb { margin-bottom: 10px; }
.mr-auto { margin-right: auto; }
.span-2 { grid-column: 1 / -1; }
.text-success { color: var(--success-text); }
.text-warning { color: var(--warning-text); }
.text-danger { color: var(--danger-text); }
.hint-warn, .hint-info { display: flex; align-items: flex-start; gap: 6px; }
.hint-warn { color: var(--warning-text); }
.hint-info { color: var(--info-text); }
.hint-warn .icon, .hint-info .icon { margin-top: 3px; }
.plain-fieldset { border: 0; padding: 0; margin: 0; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.plain-fieldset > legend { padding: 0; margin-bottom: 4px; }
.inline-add { display: flex; align-items: flex-start; gap: 8px; flex-wrap: wrap; }
.inline-add > .field { flex: 1 1 180px; }
.inline-add > .btn { margin-top: 26px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; align-items: start; }
.subsection-title { font-size: .98rem; font-weight: 650; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.field-date { flex: 0 1 210px; }
.field-time .input { max-width: 170px; }
.check-list { display: flex; flex-direction: column; gap: 10px; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 170px), 1fr)); gap: 8px 16px; }
.mono-area { font-family: var(--mono); font-size: .86rem; line-height: 1.55; tab-size: 2; }
.file-btn { display: inline-flex; }

/* radio group with descriptions (ui.js RadioGroup) */
.radio-group { border: 0; padding: 0; margin: 0; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.radio-group > legend { padding: 0; margin-bottom: 4px; }
.radio-row { display: flex; align-items: flex-start; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.radio-row.on { border-color: color-mix(in srgb, var(--accent) 55%, transparent); background: var(--accent-soft); }
.radio { width: 18px; height: 18px; margin: 3px 0 0; accent-color: var(--accent); flex: none; cursor: pointer; }
.radio:disabled { cursor: not-allowed; }
.radio-group.has-error .radio-row { border-color: var(--danger); }

/* ---------- config page frame ---------- */
.tablist { overflow-y: hidden; }
.tablist .tab { margin-bottom: 0; }
.cfg-tab-select { display: none; }
.cfg-frame { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.cfg-intro-row { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px; }
.cfg-intro { color: var(--text-2); font-size: .93rem; max-width: 82ch; flex: 1 1 320px; display: flex; flex-direction: column; gap: 4px; }
.cfg-toolbar { display: flex; flex-wrap: wrap; gap: 8px; flex: none; }
.cfg-body { min-width: 0; }
.error-summary:focus { outline: none; }
.error-summary:focus-visible .banner { outline: 2px solid var(--focus); outline-offset: 2px; }
.error-list { margin: 4px 0 0; padding-left: 18px; list-style: disc; display: flex; flex-direction: column; gap: 2px; }

.save-bar {
  position: sticky; bottom: 12px; z-index: 15; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 10px 16px; padding: 10px 12px 10px 16px; border: 1px solid var(--border); border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: saturate(1.3) blur(8px);
  box-shadow: 0 6px 24px rgba(16, 24, 40, .14);
}
.save-bar.is-dirty { border-color: color-mix(in srgb, var(--accent) 60%, transparent); }
.save-bar-status { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; min-width: 0; }
.save-state { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: .92rem; }
.save-state-dirty { color: var(--accent-text); }
.save-state-ok { color: var(--success-text); }
.save-state-warn { color: var(--warning-text); }
.dirty-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); display: inline-block; }
.save-bar-actions { display: flex; gap: 8px; margin-left: auto; }

/* ---------- company ---------- */
.hours-grid { display: flex; flex-direction: column; gap: 4px; container-type: inline-size; }
.hours-row { display: grid; grid-template-columns: 48px minmax(90px, auto) minmax(0, 1fr); align-items: center; gap: 6px 12px; padding: 6px 8px; border-radius: var(--radius-sm); }
.hours-row:nth-child(odd) { background: var(--surface-2); }
.hours-row.has-error { box-shadow: inset 3px 0 0 var(--danger); }
.hours-day { font-weight: 600; }
.hours-row.is-closed .hours-day { color: var(--muted); }
.hours-row .toggle-row { align-items: center; gap: 8px; }
.hours-row .toggle-text { padding-top: 0; }
.hours-times { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.hours-times .input { width: 128px; max-width: 100%; }
.hours-err { grid-column: 1 / -1; }
@container (max-width: 470px) {
  .hours-row { grid-template-columns: 44px minmax(0, 1fr); }
  .hours-times, .hours-closed { grid-column: 2; }
  .hours-times .input { width: 118px; }
}
.date-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.date-chips .chip { gap: 6px; }
.chip-past { opacity: .62; }
.chip-error { border: 1px solid var(--danger); }

/* ---------- greeting & phrases ---------- */
.greeting-grid { display: flex; flex-direction: column; gap: 18px; }
.greeting-card .card-body { container-type: inline-size; }
.greeting-card .list-editor { width: 100%; }
.segment { display: grid; grid-template-columns: minmax(120px, 160px) minmax(0, 1fr); gap: 10px; align-items: start; }
@container (max-width: 520px) {
  .segment { grid-template-columns: minmax(0, 1fr); }
  .greeting-card .list-item { flex-direction: column; gap: 4px; }
  .greeting-card .list-item-tools { order: -1; justify-content: flex-end; margin: -4px -4px 0 0; }
}
.greeting-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.greeting-card .hint-info { margin-bottom: 10px; }
.segment-menu { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 4px; }
.segment-menu.is-off .toggle-desc { color: var(--warning-text); }
.phone-line { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.sound-ctl { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.sound-note { display: inline-block; padding: 4px 0; }
.phrase-list { display: flex; flex-direction: column; }
.phrase { padding: 16px 0; border-bottom: 1px solid var(--border); }
.phrase:first-child { padding-top: 0; }
.phrase:last-child { border-bottom: 0; padding-bottom: 0; }
.phrase-head { display: flex; flex-direction: column; gap: 2px; margin-bottom: 10px; }
.phrase-title { font-size: .98rem; font-weight: 650; display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
.phrase-key { font-size: .74rem; color: var(--muted); font-weight: 500; }
.phrase-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 16px; }
.phrase-cell { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.phrase-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }

/* ---------- staff ---------- */
.staff-name { font-weight: 600; }
.contact { gap: 3px; }
.contact-line { display: inline-flex; align-items: center; gap: 6px; min-width: 0; color: var(--text-2); }
.contact-line .icon { color: var(--muted); }
.table tr.row-inactive td { color: var(--muted); }
.table tr.row-error td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.staff-form .toggle-row { padding: 2px 0; }
.dialog-section { border-top: 1px solid var(--border); padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.field-pin { flex: 0 1 190px !important; }
.input-pin { max-width: 190px; letter-spacing: .4em; }
.test-list { display: flex; flex-direction: column; gap: 8px; }
.test-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.test-row > span { display: inline-flex; align-items: center; gap: 4px; }
.reveal { align-items: stretch; }
.secret-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.pin-reveal {
  font-family: var(--mono); font-size: 2.4rem; font-weight: 700; letter-spacing: .32em; padding: 8px 10px 8px 22px;
  background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: var(--radius); user-select: all;
}
.secret-value {
  font-family: var(--mono); font-size: 1rem; padding: 6px 10px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); overflow-wrap: anywhere; word-break: break-all; user-select: all; display: inline-block; max-width: 100%;
}
.secret-block { display: flex; flex-direction: column; gap: 6px; }
.qr-row { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 16px; }
.qr-side { flex: 1 1 200px; min-width: 0; }

/* ---------- call categories ---------- */
.cat-list { display: flex; flex-direction: column; gap: 12px; }
.cat-card.cat-error { border-color: var(--danger); }
.cat-card.is-other { border-style: dashed; }
.cat-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 8px 10px 8px 6px; }
.cat-toggle {
  flex: 1 1 240px; min-width: 0; display: flex; align-items: flex-start; gap: 8px; padding: 6px 8px; border: 0; background: none;
  color: var(--text); text-align: left; cursor: pointer; border-radius: var(--radius-sm);
}
.cat-toggle:hover { background: var(--surface-2); }
.cat-toggle > .icon { margin-top: 3px; color: var(--muted); }
.cat-titles { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cat-title { font-weight: 650; font-size: 1rem; overflow-wrap: anywhere; }
.cat-key { font-size: .76rem; color: var(--muted); font-weight: 500; }
.cat-desc { color: var(--muted); font-size: .88rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cat-badges { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.cat-tools { display: flex; gap: 2px; margin-left: auto; }
.cat-summary { display: flex; flex-wrap: wrap; gap: 8px 22px; padding: 0 16px 12px 42px; }
.cat-sum-item { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.cat-body { display: flex; flex-direction: column; gap: 16px; padding: 16px 18px 18px; border-top: 1px solid var(--border); }

/* ---------- plain forms ---------- */
.feature-list { display: flex; flex-direction: column; }
.feature-item { display: flex; flex-direction: column; gap: 6px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.feature-item:first-child { padding-top: 0; }
.feature-item:last-child { border-bottom: 0; padding-bottom: 0; }
.feature-item > p { margin-left: 54px; }

/* ---------- AI rules ---------- */
.prompt-layout { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.prompt-preview-card { position: sticky; top: calc(var(--topbar-h) + 12px); }
.prompt-preview { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 64vh; overflow-y: auto; font-size: .82rem; line-height: 1.5; }
.placeholder-help { display: flex; flex-direction: column; gap: 6px; }
.placeholder-list { display: flex; flex-direction: column; gap: 4px; }
.placeholder-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.placeholder-list .chip code { background: none; padding: 0; }

/* ---------- raw editor ---------- */
.raw-editor { display: flex; flex-direction: column; gap: 10px; padding: 14px 18px 16px; }
.raw-area { white-space: pre; overflow-wrap: normal; overflow-x: auto; min-height: 52vh; }
.raw-status { text-align: right; font-variant-numeric: tabular-nums; }
.raw-err-lines { padding: 6px 10px; border-radius: var(--radius-sm); background: var(--danger-soft); color: var(--danger-text); }
.raw-diff { display: flex; flex-direction: column; gap: 8px; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); max-height: 46vh; overflow-y: auto; }

/* ---------- diff viewer ---------- */
.diff-wrap { width: 100%; overflow-x: auto; }
.diff-wrap:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.diff { width: 100%; border-collapse: collapse; table-layout: fixed; font-family: var(--mono); font-size: .8rem; line-height: 1.5; }
.diff col.diff-col-ln { width: 3.4em; }
.diff col.diff-col-sign { width: 1.6em; }
.diff td { padding: 0; vertical-align: top; }
.diff td.diff-ln { text-align: right; padding: 0 6px; color: var(--muted); user-select: none; border-right: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.diff td.diff-sign { text-align: center; user-select: none; font-weight: 700; }
.diff td.diff-text { white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; padding: 0 10px 0 2px; }
.diff-add { background: var(--success-soft); }
.diff-add .diff-sign, .diff-add .diff-text { color: var(--success-text); }
.diff-del { background: var(--danger-soft); }
.diff-del .diff-sign, .diff-del .diff-text { color: var(--danger-text); }
.diff tr.diff-hunk td { padding: 3px 10px; background: var(--info-soft); color: var(--info-text); }
.diff tr.diff-file td { padding: 3px 10px; background: var(--surface-2); font-weight: 600; }
.diff tr.diff-meta td { padding: 2px 10px; color: var(--muted); font-style: italic; }
.diff-stat { font-family: var(--mono); font-size: .85rem; white-space: nowrap; }
.diff-stat-add { color: var(--success-text); font-weight: 600; }
.diff-stat-del { color: var(--danger-text); font-weight: 600; }
.row-link-btn { padding-left: 0; padding-right: 0; justify-content: flex-start; font-weight: 600; }

/* ---------- account ---------- */
.field > .segmented { align-self: flex-start; }
.checklist { display: flex; flex-direction: column; gap: 4px; color: var(--muted); }
.checklist li { display: flex; align-items: center; gap: 6px; }
.checklist li.ok { color: var(--success-text); }
.device { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.device .icon { color: var(--muted); }

/* ---------- server settings (system page) ---------- */
.srv-group { border: 0; border-top: 1px solid var(--border); padding: 14px 0 0; margin: 0; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.srv-group:first-of-type { border-top: 0; padding-top: 0; }
.srv-group > legend { padding: 0; float: left; width: 100%; margin-bottom: 12px; }
.srv-group > legend + * { clear: both; }
.srv-intro { margin-bottom: 14px; max-width: 82ch; }
.srv-label { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.srv-secret { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.srv-progress { display: flex; align-items: center; gap: 8px; }
.srv-progress .spinner { flex: none; }

/* greeting tab: dialplan prompts (fallback / busy / voicemail-prompt) */
.stable-list { display: flex; flex-direction: column; }
.stable-item { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.stable-item:last-child { border-bottom: 0; }
.stable-text { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; min-width: 0; }
.stable-title { font-weight: 600; }

/* toasts must not cover the sticky save bar (its Save / Discard buttons) */
body:has(.save-bar) .toasts { bottom: 84px; }

@media (max-width: 1100px) {
  .phrase-grid { grid-template-columns: minmax(0, 1fr); }
  .prompt-layout { grid-template-columns: minmax(0, 1fr); }
  .prompt-preview-card { position: static; }
}

@media (max-width: 640px) {
  .cfg-tab-select { display: block; }
  .cfg-tabs .tablist { display: none; }
  .cfg-tabs .tabpanel { padding-top: 0; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .segment { grid-template-columns: minmax(0, 1fr); }
  .cat-summary { padding-left: 16px; }
  .cat-body { padding: 14px; }
  .cat-tools { margin-left: 0; }
  .save-bar { bottom: 8px; padding: 8px 10px; }
  .save-hint { display: none; }
  .save-bar-actions { flex: 1 1 auto; justify-content: flex-end; }
  .raw-editor { padding: 12px; }
  .raw-area { white-space: pre-wrap; overflow-wrap: anywhere; }
  .diff { font-size: .76rem; }
  .diff col.diff-col-ln { width: 2.7em; }
  .pin-reveal { font-size: 2rem; }
  .feature-item > p { margin-left: 0; }
  .rt tr.row-error { box-shadow: inset 3px 0 0 var(--danger); }
  .rt tr.row-error td:first-child { box-shadow: none; }
  .rt .contact { align-items: flex-end; }
  .rt .badges-stack { flex-wrap: wrap; }
  .modal-foot .btn.mr-auto { flex-basis: 100%; }
}

@media (max-width: 420px) {
  /* keep the save bar on one line: the discard button shows its icon only (label stays for screen readers) */
  .save-bar-actions .btn-ghost > span {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
  }
  .save-bar-actions .btn-ghost { width: 38px; padding: 7px; }
}
