/* PGM Server UI – "Control Room" theme (dark) with a light variant */
@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap; src: url("/fonts/InterVariable.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-style: normal; font-weight: 100 800; font-display: swap; src: url("/fonts/JetBrainsMonoVariable.woff2") format("woff2"); }

:root, :root[data-theme="dark"] {
  --bg: #0e1116;
  --bg-header: #0a0d12;
  --surface: #151a21;
  --surface-2: #1b222b;
  --surface-3: #11161d;
  --hover: #1a2029;
  --input-bg: #0f1319;
  --border: #222a35;
  --border-strong: #2b3442;
  --line: #1c232d;
  --text: #e6eaf0;
  --text-strong: #ffffff;
  --text-2: #b8c2cf;
  --muted: #8c97a6;
  --faint: #6b7686;
  --disabled: #3a4452;
  --accent: #4c8dff;
  --accent-ink: #0a0d12;
  --accent-soft: #16233a;
  --accent-border: #2b4470;
  --accent-text: #a9c8ff;
  --link: #7eaeff;
  --row-new: #1a2230;
  --ok: #3fb950; --ok-text: #7ee29a; --ok-soft: #12241a; --ok-border: #1e4a2b;
  --warn: #e3a008; --warn-text: #f5c76b; --warn-soft: #2a1e0b; --warn-border: #5a4114;
  --bad: #f85149; --bad-text: #ff8a80; --bad-soft: #2a1415; --bad-border: #4a2224;
  --seg-off: #2b3442;
  --brand: #f2b227;
  --logo-bg: #1b222b;
  --overlay: rgba(3, 5, 8, .62);
  --shadow: 0 1px 2px rgba(0, 0, 0, .25);
  --shadow-lg: 0 18px 50px rgba(0, 0, 0, .55);
  --radius: 12px;
  --radius-m: 10px;
  --radius-s: 8px;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", "Cascadia Mono", Consolas, "DejaVu Sans Mono", monospace;
  --gap: 20px;
  --pad-x: 28px;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f5f7fa;
  --bg-header: #ffffff;
  --surface: #ffffff;
  --surface-2: #f2f4f7;
  --surface-3: #f2f4f7;
  --hover: #f5f8fc;
  --input-bg: #ffffff;
  --border: #e3e8ef;
  --border-strong: #d0d5dd;
  --line: #eef1f5;
  --text: #101828;
  --text-strong: #0b1220;
  --text-2: #475467;
  --muted: #5b6576;
  --faint: #667085;
  --disabled: #c4cbd5;
  --accent: #1d4ed8;
  --accent-ink: #ffffff;
  --accent-soft: #eef4ff;
  --accent-border: #b2ccff;
  --accent-text: #1d4ed8;
  --link: #1d4ed8;
  --row-new: #f5f8ff;
  --ok: #12b76a; --ok-text: #067647; --ok-soft: #ecfdf3; --ok-border: #abefc6;
  --warn: #f79009; --warn-text: #b54708; --warn-soft: #fffaeb; --warn-border: #fedf89;
  --bad: #f04438; --bad-text: #d92d20; --bad-soft: #fef3f2; --bad-border: #fecdca;
  --seg-off: #d5dce6;
  --logo-bg: #101828;
  --overlay: rgba(16, 24, 40, .45);
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-lg: 0 18px 50px rgba(16, 24, 40, .18);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 var(--sans); -webkit-font-smoothing: antialiased; font-feature-settings: "cv11", "ss01"; }
a { color: var(--link); }
a:hover { text-decoration-thickness: 1px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono, td.mono { font-family: var(--mono); }
code { font-family: var(--mono); font-size: 12.5px; }
.spacer { flex: 1; }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 30; background: var(--bg-header); border-bottom: 1px solid var(--border); }
.topbar-row { display: flex; align-items: center; gap: 4px 20px; padding: 0 var(--pad-x); min-height: 58px; }
.brand { display: flex; align-items: center; gap: 10px; margin-right: 8px; text-decoration: none; color: var(--text); flex: none; }
.brand svg { width: 28px; height: 28px; flex: none; }
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: .03em; white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.nav { display: flex; align-self: stretch; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a { display: flex; align-items: center; gap: 7px; padding: 0 14px; min-height: 58px; color: var(--text-2); text-decoration: none; white-space: nowrap; font-weight: 450; }
.nav a:hover { color: var(--text); }
.nav a[aria-current="page"] { color: var(--text-strong); font-weight: 550; box-shadow: inset 0 -2px 0 var(--accent); }
.nav .count { font-size: 11px; background: var(--accent); color: var(--accent-ink); border-radius: 10px; padding: 0 7px; font-weight: 700; line-height: 18px; }
.nav .flag { width: 7px; height: 7px; border-radius: 50%; background: var(--bad); }
.nav .flag.warn { background: var(--warn); }
.topbar-tools { margin-left: auto; display: flex; align-items: center; gap: 10px; padding: 9px 0; flex: none; }
.pill { display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 12px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; background: var(--surface-3); border: 1px solid var(--border); color: var(--text-2); text-decoration: none; }
.pill .dot, .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; display: inline-block; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); } .dot.info { background: var(--accent); }
.pill.ok { background: var(--ok-soft); border-color: var(--ok-border); color: var(--ok-text); }
.pill.warn { background: var(--warn-soft); border-color: var(--warn-border); color: var(--warn-text); }
.pill.bad { background: var(--bad-soft); border-color: var(--bad-border); color: var(--bad-text); }
a.pill:hover { filter: brightness(1.12); }
.icon-btn { width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; background: transparent; border: 1px solid var(--border-strong); border-radius: var(--radius-s); color: var(--text-2); cursor: pointer; flex: none; }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn.on { color: var(--accent); border-color: var(--accent-border); background: var(--accent-soft); }
.icon-btn.sm { width: 32px; height: 32px; }
.icon-btn.sm svg { width: 15px; height: 15px; }
.account { position: relative; }
.account-btn { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 8px 0 4px; background: transparent; border: 1px solid var(--border-strong); border-radius: 999px; color: var(--text-2); font-size: 13px; cursor: pointer; }
.account-btn:hover { background: var(--hover); color: var(--text); }
.account-btn svg { width: 14px; height: 14px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-text); display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 650; flex: none; }
.menu { position: absolute; right: 0; top: calc(100% + 8px); min-width: 230px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-m); box-shadow: var(--shadow-lg); padding: 6px; z-index: 50; }
.menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu-head strong { display: block; }
.menu-head span { color: var(--muted); font-size: 12px; }
.menu a, .menu button.item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; background: none; color: var(--text); text-decoration: none; border-radius: 6px; cursor: pointer; font-size: 13.5px; text-align: left; }
.menu a:hover, .menu button.item:hover { background: var(--hover); }
.menu svg { width: 16px; height: 16px; color: var(--muted); }
.menu-label { font-size: 11px; color: var(--faint); text-transform: uppercase; letter-spacing: .06em; padding: 10px 10px 6px; }
.theme-switch { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 0 6px 6px; }
.theme-switch button { height: 32px; border: 1px solid var(--border-strong); background: transparent; color: var(--text-2); border-radius: 6px; cursor: pointer; font-size: 12.5px; }
.theme-switch button[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent-border); color: var(--accent-text); font-weight: 600; }

/* ---------- page layout ---------- */
/* every page uses the whole screen width */
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; padding: 18px var(--pad-x) 0; }
.page-head h1, h1.view-title { margin: 0 8px 0 0; font-size: 22px; font-weight: 600; letter-spacing: -.01em; }
.page-head .search { flex: 0 1 420px; }
.page-head .search.narrow { flex-basis: 300px; }
.page-sub { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--text-2); }
.page-sub span { display: inline-flex; align-items: center; gap: 6px; }
.page-body { display: flex; flex-wrap: wrap; gap: var(--gap); padding: 18px var(--pad-x) 32px; align-items: flex-start; }
.page-main { flex: 999 1 640px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.page-side { flex: 1 1 300px; max-width: 360px; min-width: 260px; display: flex; flex-direction: column; gap: 16px; }
.shell { display: flex; flex-wrap: wrap; gap: var(--gap); padding: 18px var(--pad-x) 32px; align-items: flex-start; }
.shell > .main { flex: 999 1 640px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.shell > .side { flex: 1 1 300px; max-width: 360px; display: flex; flex-direction: column; gap: 16px; }
.shell.wide > .main { flex-basis: 100%; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.panel.flush { padding: 0; overflow: hidden; }
.panel-title { margin: 0 0 10px; font-size: 13px; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 8px; }
.panel-title .grow, .panel-title .spacer { flex: 1; }
.panel-title a, .panel-title .aside { margin-left: auto; font-size: 12px; font-weight: 400; color: var(--link); text-decoration: none; }
.panel-title .aside { color: var(--muted); }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-m); padding: 13px 16px; display: flex; flex-direction: column; gap: 3px; min-width: 0; box-shadow: var(--shadow); }
.kpi .k { font-size: 12px; color: var(--muted); }
.kpi .v { font-size: 24px; font-weight: 600; letter-spacing: -.01em; line-height: 1.25; font-variant-numeric: tabular-nums; }
.kpi .s { font-size: 12px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi.warn .v { color: var(--warn-text); } .kpi.bad .v { color: var(--bad-text); } .kpi.ok .v { color: var(--ok-text); }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; gap: 7px; justify-content: center; background: transparent; color: var(--text); border: 1px solid var(--border-strong); border-radius: var(--radius-s); padding: 0 13px; min-height: 36px; cursor: pointer; text-decoration: none; white-space: nowrap; font-size: 13px; font-weight: 500; }
.btn:hover { background: var(--hover); }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn.danger { color: var(--bad-text); border-color: var(--bad-border); }
.btn.danger:hover { background: var(--bad-soft); }
.btn.on { color: var(--accent-text); border-color: var(--accent-border); background: var(--accent-soft); }
.btn.icon { padding: 0; width: 36px; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.small { min-height: 28px; padding: 0 10px; font-size: 12px; }
.btn.small svg { width: 13px; height: 13px; }
.btn.small.icon { width: 28px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.input, select.input, textarea.input { background: var(--input-bg); border: 1px solid var(--border-strong); border-radius: var(--radius-s); color: var(--text); padding: 0 11px; min-height: 36px; width: 100%; font-size: 13.5px; }
select.input { padding-right: 28px; }
textarea.input { padding: 8px 11px; min-height: 90px; font-family: var(--mono); font-size: 13px; resize: vertical; line-height: 1.5; }
.input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.input::placeholder { color: var(--faint); }
.input:read-only { color: var(--text-2); }
.search { position: relative; flex: 1; min-width: 200px; display: flex; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.search .input { padding-left: 34px; background: var(--surface); }
.page-head .search .input { height: 38px; }

.field { display: grid; gap: 6px; margin-bottom: 14px; align-content: start; }
.field > label, .field > .label { font-size: 12.5px; color: var(--text-2); }
.field .help, .help { font-size: 12px; color: var(--muted); }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 12px; }
.check { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 12px; cursor: pointer; }
.check input { margin-top: 2px; accent-color: var(--accent); width: 16px; height: 16px; flex: none; }
.check .help { display: block; font-size: 12px; color: var(--muted); }
.hint { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12px; color: var(--warn-text); margin-top: -2px; }
.hint button { background: var(--warn-soft); border: 1px solid var(--warn-border); color: var(--warn-text); border-radius: 6px; padding: 1px 8px; cursor: pointer; font-size: 12px; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar .spacer { flex: 1; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
/* filter row: search box first, then the filters */
.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filter-bar > .filters { flex: 1 1 auto; }
.filter-bar > .spacer { flex: 1; }
.filter-search { flex: 0 1 480px; min-width: 220px; }
.filter-search .input { height: 34px; min-height: 34px; padding-right: 34px; }
.filter-search .input::-webkit-search-cancel-button { display: none; }
.search-clear { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; }
.search-clear:hover { background: var(--hover); color: var(--text); }
.search .search-clear svg { position: static; transform: none; width: 15px; height: 15px; }
.search-key { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); min-width: 18px; height: 20px; padding: 0 5px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--border-strong); border-radius: 5px; color: var(--faint); font: 600 11px var(--mono); pointer-events: none; }
/* full screen on the Messages page (wall display) */
.kiosk-clock { display: none; }
body.kiosk #topbar, body.kiosk .footer, body.kiosk .banner-wrap { display: none; }
body.kiosk .page-head { padding-top: 10px; }
body.kiosk .kiosk-clock { display: inline; font: 600 22px var(--mono); color: var(--text-strong); letter-spacing: .02em; margin-right: 6px; }
body.kiosk .page-body { padding-bottom: 12px; }
.filters .spacer { flex: 1; }
.filters .count { font-size: 12px; color: var(--muted); }
.select-chip { position: relative; display: inline-flex; align-items: center; height: 32px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-s); color: var(--text-2); font-size: 13px; }
.select-chip.active { background: var(--accent-soft); border-color: var(--accent-border); color: var(--accent-text); }
.select-chip span.k { padding-left: 12px; color: var(--muted); pointer-events: none; white-space: nowrap; }
.select-chip.active span.k { color: inherit; opacity: .8; }
.select-chip select { appearance: none; -webkit-appearance: none; background: transparent; border: 0; color: inherit; height: 30px; padding: 0 28px 0 5px; cursor: pointer; font-size: 13px; max-width: 220px; }
.select-chip svg { position: absolute; right: 9px; width: 14px; height: 14px; pointer-events: none; }
.select-chip select option { background: var(--surface); color: var(--text); }
.segmented { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-s); overflow: hidden; flex: none; }
.segmented button { height: 34px; padding: 0 12px; border: 0; border-right: 1px solid var(--border-strong); background: transparent; color: var(--text-2); cursor: pointer; font-size: 13px; white-space: nowrap; }
.segmented button:last-child { border-right: 0; }
.segmented button[aria-pressed="true"] { background: var(--surface-2); color: var(--text-strong); font-weight: 550; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 4px; height: 32px; padding: 0 6px 0 12px; background: var(--accent-soft); border: 1px solid var(--accent-border); border-radius: var(--radius-s); color: var(--accent-text); font-size: 13px; }
.chip button { background: none; border: 0; color: inherit; cursor: pointer; padding: 4px; border-radius: 4px; display: flex; }
.chip button:hover { background: rgba(127, 127, 127, .18); }
.chip svg { width: 13px; height: 13px; }

/* ---------- alias badge & capcode ---------- */
.icon-dot { width: 26px; height: 26px; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; background: var(--alias-color, var(--disabled)); color: var(--alias-ink, #fff); font-size: 12px; flex: none; }
.icon-dot.sm { width: 22px; height: 22px; border-radius: 6px; font-size: 10.5px; }
.icon-dot.lg { width: 36px; height: 36px; border-radius: 9px; font-size: 16px; }
.icon-dot .letter { display: none; font-weight: 700; font-family: var(--sans); }
.no-fa .icon-dot i, .icon-dot.no-icon i { display: none; }
.no-fa .icon-dot .letter, .icon-dot.no-icon .letter { display: inline; }
.icon-dot.no-icon { background: var(--surface-2); color: var(--muted); box-shadow: inset 0 0 0 1px var(--border-strong); }
.capcode { font-family: var(--mono); font-size: 12.5px; padding: 1px 7px; border-radius: 5px; border: 0; cursor: pointer; background: var(--surface-2); color: var(--text-2); font-weight: 500; }
.capcode.wild::after { content: "*"; opacity: .75; margin-left: 2px; }
mark.hl { background: var(--warn-soft); color: var(--warn-text); border-radius: 3px; padding: 0 2px; cursor: pointer; box-shadow: inset 0 -1px 0 var(--warn-border); }
mark.hit { background: var(--accent-soft, rgba(80, 140, 255, .22)); color: inherit; border-radius: 3px; padding: 0 1px; box-shadow: inset 0 -2px 0 var(--accent); }
abbr.lbl { text-decoration: underline dotted var(--accent); text-underline-offset: 3px; cursor: help; }

/* ---------- messages table ---------- */
.msgs { overflow-x: auto; }
/* Time | Capcode | Freq. | Received by | Agency · Alias | Message; the message takes the rest */
.msg-head, .msg-row { display: grid; grid-template-columns: 124px 92px 78px 152px minmax(150px, 200px) minmax(0, 1fr); gap: 14px; padding: 0 18px; }
.msgs.no-capcode .msg-head, .msgs.no-capcode .msg-row { grid-template-columns: 124px 78px 152px minmax(150px, 200px) minmax(0, 1fr); }
.msgs.no-rx .msg-head, .msgs.no-rx .msg-row { grid-template-columns: 124px 92px 78px minmax(150px, 200px) minmax(0, 1fr); }
.msgs.no-capcode.no-rx .msg-head, .msgs.no-capcode.no-rx .msg-row { grid-template-columns: 124px 78px minmax(150px, 200px) minmax(0, 1fr); }
.msg-row .meta { display: contents; }
.msg-head .h-meta { display: none; }
.msg-head { padding-top: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--border); font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.msg-day { padding: 12px 18px 6px; font-size: 12px; font-weight: 600; color: var(--faint); border-top: 1px solid var(--line); }
.msg-day:first-child { border-top: 0; }
/* wide screens show the date on every row; tablets and phones get day headings instead */
@media (min-width: 1280px) { .msg-day { display: none; } }
.msg-row { padding-top: 12px; padding-bottom: 12px; border-top: 1px solid var(--line); align-items: start; box-shadow: inset 3px 0 0 var(--alias-color, transparent); cursor: pointer; }
.msg-row:hover { background: var(--hover); }
.msg-row.open { background: var(--hover); }
.msg-row.fresh { animation: fresh 3s ease-out 1; }
@keyframes fresh { from { background: var(--row-new); box-shadow: inset 3px 0 0 var(--alias-color, var(--accent)), inset 0 0 0 1px var(--accent-border); } to { background: transparent; } }
.msg-row.selected { background: var(--bad-soft); }
.msg-row .t { font-family: var(--mono); font-size: 13px; color: var(--text); }
.msg-row .t .rel { display: block; font-family: var(--sans); font-size: 11px; color: var(--faint); white-space: nowrap; }
.msg-row .t .t-full { white-space: nowrap; }
.msg-row .t .t-short, .msg-row .t .t-hm { display: none; }
.msg-row .cc, .msg-row .fq { font-family: var(--mono); font-size: 13px; color: var(--text-2); background: none; border: 0; padding: 0; text-align: left; cursor: pointer; justify-self: start; }
.msg-row .fq { color: var(--muted); }
.msg-row .cc:hover, .msg-row .fq:hover, .who button:hover { text-decoration: underline; }
.msg-row .cc.wild::after { content: "*"; color: var(--faint); margin-left: 2px; }
.who { display: flex; gap: 10px; align-items: flex-start; min-width: 0; }
.who .names { display: flex; flex-direction: column; min-width: 0; }
.who button { background: none; border: 0; padding: 0; text-align: left; cursor: pointer; color: inherit; overflow-wrap: break-word; min-width: 0; }
.who .agency { font-weight: 600; color: var(--text); }
.who .alias { font-size: 12px; color: var(--muted); }
.who .unknown { color: var(--muted); font-style: italic; }
.who .add-alias { font-size: 12px; color: var(--link); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: none; }
.msg-row .body { font-family: var(--mono); font-size: 13.5px; line-height: 1.5; color: var(--text); white-space: pre-wrap; overflow-wrap: break-word; min-width: 0; cursor: text; }
.msg-row .flags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.rx { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; padding-top: 1px; }
.rx-site { height: 20px; padding: 0 6px; border: 1px solid var(--border-strong); border-radius: 5px; background: var(--surface-2); color: var(--text-2); font: 600 11px var(--mono); letter-spacing: .02em; cursor: pointer; }
.rx-site:hover { color: var(--text-strong); border-color: var(--accent); }
.rx-more { font: 600 11px var(--mono); color: var(--muted); padding: 0 2px; cursor: default; }
.rx-none { color: var(--faint); font-size: 12px; }
.rx .n { margin-left: 4px; }
.rx .n { font-family: var(--mono); font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.rx .n.low { color: var(--warn-text); }
.rx-detail { grid-column: 1 / -1; margin: 2px 0 2px; padding: 10px 14px; background: var(--surface-3); border: 1px solid var(--border); border-radius: var(--radius-s); cursor: default; }
.rx-detail h3 { font-size: 12px; font-weight: 600; color: var(--muted); margin: 0 0 6px; }
.rx-note { font-size: 13px; color: var(--muted); margin: 4px 0; }
.rx-table { border-collapse: collapse; font-size: 13px; width: 100%; max-width: 680px; }
.rx-table th { text-align: left; font-weight: 500; font-size: 11px; color: var(--faint); padding: 2px 14px 5px 0; text-transform: uppercase; letter-spacing: .05em; }
.rx-table td { padding: 5px 14px 5px 0; border-top: 1px solid var(--line); white-space: nowrap; }
.rx-table td:first-child { white-space: normal; }
.rx-src { color: var(--faint); font-family: var(--mono); font-size: 12px; }
.rx-variant { font-family: var(--mono); font-size: 12px; color: var(--warn-text); white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 2px; }
.alias-notes { background: var(--accent-soft); border-left: 3px solid var(--accent); border-radius: 6px; padding: 7px 10px; margin: 0 0 10px; font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-row input.sel { width: 16px; height: 16px; accent-color: var(--bad); margin: 0 6px 0 0; vertical-align: -3px; }
.sel-bar { position: sticky; bottom: 0; z-index: 4; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px 18px; background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -8px 20px rgba(0, 0, 0, .15); }
.sel-count { margin-right: auto; color: var(--text-2); font-size: 13px; }
.new-pill { display: flex; justify-content: center; padding: 10px; border-bottom: 1px solid var(--line); }
.lost-bar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--bad-soft); color: var(--bad-text); border-bottom: 1px solid var(--bad-border); font-weight: 600; }
.lost-bar[hidden] { display: none; }
.lost-bar svg { width: 18px; height: 18px; flex: none; }
.pager { display: flex; gap: 8px; justify-content: center; align-items: center; padding: 14px; color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.pager select.input { width: auto; min-height: 32px; }
.loading { opacity: .55; transition: opacity .2s; }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty h2 { color: var(--text); font-size: 16px; margin: 0 0 6px; }

/* ---------- side column ---------- */
.side-list { display: flex; flex-direction: column; }
.side-row { display: grid; grid-template-columns: 10px 38px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.side-row:first-child { border-top: 0; }
.side-row .code { font-family: var(--mono); font-weight: 600; font-size: 13px; }
.side-row .nm { display: flex; flex-direction: column; min-width: 0; }
.side-row .nm b { font-weight: 500; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-row .nm small { font-size: 11px; color: var(--faint); font-family: var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-row .st { font-size: 12px; color: var(--muted); white-space: nowrap; }
.side-row .st.warn { color: var(--warn-text); } .side-row .st.bad { color: var(--bad-text); }
.side-row button { background: none; border: 0; padding: 0; color: inherit; cursor: pointer; text-align: left; }
.side-more { display: block; padding-top: 9px; margin-top: 2px; border-top: 1px solid var(--line); font-size: 12px; text-decoration: none; }
.hist { display: flex; align-items: flex-end; gap: 3px; height: 72px; }
.hist span { flex: 1; background: var(--seg-off); border-radius: 2px 2px 0 0; min-height: 2px; }
.hist span.now { background: var(--accent); }
.hist-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--faint); margin-top: 6px; }
.act .panel-title { justify-content: space-between; }
.act .seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-s); overflow: hidden; }
.act .seg button { height: 24px; padding: 0 8px; border: 0; border-right: 1px solid var(--border); background: transparent; color: var(--muted); font: inherit; font-size: 11.5px; font-weight: 500; cursor: pointer; }
.act .seg button:last-child { border-right: 0; }
.act .seg button:hover { color: var(--text); }
.act .seg button.on { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.act-big { display: flex; align-items: baseline; gap: 8px; }
.act-big .v { font-size: 26px; font-weight: 600; letter-spacing: -.01em; font-variant-numeric: tabular-nums; line-height: 1.2; }
.act-big .k { font-size: 12px; color: var(--muted); }
.act-sub { font-size: 12px; color: var(--faint); margin: 1px 0 12px; }
.act-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; }
.act-table-tools { display: flex; align-items: center; gap: 12px; margin: 4px 0 8px; }
.act-table-tools .check { margin: 0; align-items: center; }
.act-table-host .table-wrap { max-height: 60vh; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-s); }
table.act-table th.n, table.act-table td.n { text-align: right; }
table.act-table thead th { position: sticky; top: 0; background: var(--surface); }
table.act-table tfoot td { font-weight: 600; border-top: 1px solid var(--border); position: sticky; bottom: 0; background: var(--surface); }
.ev-list { display: flex; flex-direction: column; }
.ev { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 12.5px; }
.ev:first-child { border-top: 0; }
.ev .dot { margin-top: 5px; }
.ev time { font-family: var(--mono); font-size: 11.5px; color: var(--faint); white-space: nowrap; }
.ev-empty { color: var(--muted); font-size: 13px; }
.top-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.top-list li { display: grid; grid-template-columns: 22px 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.top-list .n { font-family: var(--mono); color: var(--muted); }
.top-list button { background: none; border: 0; padding: 0; color: var(--text); text-align: left; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-list button:hover { text-decoration: underline; }

/* ---------- receivers ---------- */
.site-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.site-card.warn { border-color: var(--warn-border); box-shadow: inset 3px 0 0 var(--warn); }
.site-card.bad { border-color: var(--bad-border); box-shadow: inset 3px 0 0 var(--bad); }
.site-card.maint { box-shadow: inset 3px 0 0 var(--faint); }
.site-head, .host-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; padding: 14px 18px 12px 20px; }
.host-head { padding-top: 10px; border-top: 1px solid var(--line); }
.site-id { display: flex; align-items: center; gap: 12px; min-width: 240px; flex: 1 1 300px; }
.site-code { flex: none; font-family: var(--mono); font-weight: 600; font-size: 13px; background: var(--surface-2); border-radius: 6px; padding: 3px 8px; color: var(--text); text-decoration: none; }
a.site-code:hover { color: var(--accent-text); }
.site-id .names { display: flex; flex-direction: column; min-width: 0; }
.site-id .names b { font-weight: 600; }
.site-id .names b .state { font-weight: 400; font-size: 12.5px; }
.site-id .names small { font-size: 12px; color: var(--muted); }
.state.ok { color: var(--ok-text); } .state.warn { color: var(--warn-text); } .state.bad { color: var(--bad-text); } .state.maint { color: var(--muted); }
.metrics { display: flex; flex-wrap: wrap; align-items: center; gap: 18px; }
.metric { display: flex; flex-direction: column; gap: 3px; min-width: 52px; }
.metric .k { font-size: 11px; color: var(--faint); }
.metric .v { font-family: var(--mono); font-size: 13px; white-space: nowrap; }
.metric.warn .v { color: var(--warn-text); } .metric.bad .v { color: var(--bad-text); }
.metric .bar { height: 3px; width: 56px; border-radius: 2px; background: var(--seg-off); overflow: hidden; }
.metric .bar i { display: block; height: 3px; background: var(--muted); }
.update-chip { font-family: var(--sans); font-size: 11px; font-weight: 600; color: var(--accent-text); background: var(--accent-soft); border: 1px solid var(--accent-border); border-radius: 5px; padding: 0 5px; margin-left: 4px; }
.card-note { display: flex; align-items: center; gap: 8px; margin: 0 18px 10px 20px; padding: 7px 12px; border-radius: var(--radius-s); background: var(--warn-soft); color: var(--warn-text); font-size: 12.5px; }
.card-note.bad { background: var(--bad-soft); color: var(--bad-text); }
.card-note svg { width: 15px; height: 15px; flex: none; }
.site-card { container-type: inline-size; }
.sdr-rows { overflow-x: auto; border-top: 1px solid var(--line); }
.sdr-inner { min-width: 780px; }
.sdr-row .figs { display: contents; }
.sdr-row { display: grid; grid-template-columns: 104px minmax(0, 1fr) 128px 150px 124px 160px var(--sdr-actions, 0px); gap: 14px; align-items: center; padding: 9px 18px 9px 20px; border-top: 1px solid var(--line); font-size: 12.5px; }
.sdr-row:first-child { border-top: 0; }
.sdr-row.dim > :not(.acts) { opacity: .55; }
.sdr-row .fq { font-family: var(--mono); font-size: 12.5px; color: var(--text); text-decoration: none; line-height: 1.5; }
.sdr-row a.fq:hover { color: var(--accent-text); }
.sdr-row .fqs { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.metric a { color: var(--accent-text); text-decoration: none; } .metric a:hover { text-decoration: underline; }
.metric .small-link { font-size: 11px; font-family: var(--font, inherit); }
.sdr-row .nm { display: flex; flex-direction: column; min-width: 0; }
.sdr-row .nm span { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sdr-row .nm small { font-size: 11.5px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sdr-row .stt { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); }
.sdr-row .stt.bad { color: var(--bad-text); } .sdr-row .stt.warn { color: var(--warn-text); } .sdr-row .stt.maint { color: var(--muted); }
.sdr-row .lbl { color: var(--faint); }
.sdr-row .cov { display: flex; align-items: center; gap: 8px; font-family: var(--mono); }
.sdr-row .cov .bar { flex: none; width: 84px; height: 6px; border-radius: 3px; background: var(--seg-off); overflow: hidden; }
.sdr-row .cov .bar i { display: block; height: 6px; background: var(--accent); }
.sdr-row .cov.low .bar i { background: var(--warn); }
.sdr-row .acts { display: flex; gap: 4px; justify-content: flex-end; }
/* a card narrower than the SDR table: frequency, name, state and buttons on one line, the figures under the name */
@container (max-width: 799px) {
  .sdr-inner { min-width: 0; }
  .sdr-row { grid-template-columns: 84px minmax(0, 1fr) auto auto; gap: 4px 12px; padding: 9px 14px 9px 18px; }
  .sdr-row { grid-template-rows: auto 1fr; }
  .sdr-row .fqs { grid-column: 1; grid-row: 1 / span 2; align-self: start; }
  .sdr-row .nm { grid-column: 2; grid-row: 1; }
  .sdr-row .stt { grid-column: 3; grid-row: 1; justify-self: end; }
  .sdr-row .acts { grid-column: 4; grid-row: 1; }
  .sdr-row .figs { grid-column: 2 / -1; grid-row: 2; align-self: start; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 14px; font-size: 12px; }
  .sdr-row .cov .bar { width: 56px; height: 5px; }
  .site-head, .host-head { padding: 12px 14px 10px 18px; gap: 8px 16px; }
  .card-note { margin: 0 14px 10px 18px; }
}
/* phones: the buttons go under the state */
@container (max-width: 439px) {
  .sdr-row { grid-template-columns: 84px minmax(0, 1fr) auto; }
  .sdr-row .acts { grid-column: 3; grid-row: 2; align-self: center; }
  .sdr-row .figs { grid-column: 1 / 3; }
}
.act-picks { display: flex; flex-wrap: wrap; gap: 6px; margin: -2px 0 12px; }
.act-picks .select-chip { height: 28px; font-size: 12.5px; }
.act-picks .select-chip select { height: 26px; font-size: 12.5px; max-width: 170px; }
.drawer-sub { font-size: 14px; font-weight: 600; margin: 0 0 10px; }
.sdr-details { grid-column: 1 / -1; font-size: 12px; }
.sdr-details summary { color: var(--faint); cursor: pointer; }
.sdr-details .kv { margin-top: 6px; }
.order-list { display: flex; flex-wrap: wrap; gap: 6px; }
.order-item { display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 9px 0 5px; background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 7px; font-family: var(--mono); font-size: 12.5px; font-weight: 600; cursor: grab; user-select: none; }
.order-item svg { width: 12px; height: 14px; color: var(--faint); }
.order-item.dragging { opacity: .4; }
.order-item.over { border-color: var(--accent); }
.order-item.ro { cursor: default; }
.kv-list { display: flex; flex-direction: column; }
.kv-list div { display: flex; gap: 12px; padding: 7px 0; border-top: 1px solid var(--line); font-size: 12.5px; }
.kv-list div:first-child { border-top: 0; }
.kv-list dt, .kv-list .k { color: var(--muted); }
.kv-list dd, .kv-list .v { margin: 0 0 0 auto; text-align: right; }
.hist-body canvas { display: block; margin-top: 6px; }
.hist-legend { font-size: 12px; color: var(--muted); }
.hist-legend .sw { display: inline-block; width: 18px; height: 3px; vertical-align: middle; }
.hist-legend .sw.temp { background: var(--warn); }
.hist-legend .sw.cpu { background: var(--seg-off); height: 8px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th { text-align: left; font-weight: 600; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; padding: 10px 10px; white-space: nowrap; border-bottom: 1px solid var(--border); }
table.grid th button { background: none; border: 0; color: inherit; cursor: pointer; padding: 0; font: inherit; letter-spacing: inherit; text-transform: inherit; }
table.grid th button[aria-sort] { color: var(--accent-text); }
table.grid td { padding: 9px 10px; vertical-align: middle; border-top: 1px solid var(--line); }
table.grid tr.clickable td { cursor: pointer; }
table.grid tr.clickable:hover td { background: var(--hover); }
table.grid tr.selected td { background: var(--accent-soft); }
.tag { display: inline-block; font-size: 11px; font-weight: 500; padding: 1px 7px; border-radius: 5px; background: var(--surface-2); color: var(--text-2); margin: 1px 3px 1px 0; white-space: nowrap; }
.tag.warn { background: var(--warn-soft); color: var(--warn-text); }
.tag.bad { background: var(--bad-soft); color: var(--bad-text); }
.tag.ok { background: var(--ok-soft); color: var(--ok-text); }
.tag.info { background: var(--accent-soft); color: var(--accent-text); }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -2px; box-shadow: inset 0 0 0 1px rgba(127, 127, 127, .35); }

/* ---------- drawer / modal ---------- */
.overlay { position: fixed; inset: 0; background: var(--overlay); z-index: 60; display: flex; justify-content: flex-end; }
.overlay.center { justify-content: center; align-items: center; padding: 16px; }
.drawer { width: min(580px, 100%); height: 100%; overflow-y: auto; background: var(--surface); border-left: 1px solid var(--border); padding: 18px 22px 90px; box-shadow: var(--shadow-lg); }
.modal { width: min(560px, 100%); max-height: 90vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow-lg); }
.modal.wide { width: min(780px, 100%); }
.drawer-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.drawer-head h2 { font-size: 17px; font-weight: 600; margin: 0; flex: 1; }
.drawer-foot { position: sticky; bottom: -90px; margin: 18px -22px -90px; padding: 14px 22px 22px; background: var(--surface); border-top: 1px solid var(--border); display: flex; gap: 8px; flex-wrap: wrap; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin: 0 0 16px; }
.tabs button { background: none; border: 0; padding: 8px 12px 10px; color: var(--text-2); cursor: pointer; font-size: 13.5px; }
.tabs button[aria-selected="true"] { color: var(--text-strong); font-weight: 550; box-shadow: inset 0 -2px 0 var(--accent); }
.section { border-top: 1px solid var(--border); margin-top: 16px; padding-top: 14px; }
.section h3 { font-size: 14px; font-weight: 600; margin: 0 0 10px; }
.preview { display: flex; align-items: center; gap: 10px; background: var(--surface-3); border: 1px solid var(--border); border-radius: var(--radius-s); padding: 10px 12px; margin-bottom: 14px; box-shadow: inset 3px 0 0 var(--alias-color, transparent); }
.preview .names { display: flex; flex-direction: column; }
.color-input { display: flex; gap: 6px; }
.pal-row { display: grid; grid-template-columns: 190px minmax(0, 1fr) auto; gap: 6px; margin-bottom: 6px; align-items: center; }
.pal-row.icons { grid-template-columns: 190px minmax(0, 1fr) 130px auto; }
.icon-colour-field { display: flex; align-items: center; gap: 4px; }
.icon-colour { width: 56px; height: 36px; padding: 3px; border: 1px solid var(--border-strong); border-radius: var(--radius-s); background: var(--input-bg); cursor: pointer; }
.icon-colour.unset { opacity: .35; }
.icon-colour-clear { width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; }
.icon-colour-clear:hover { background: var(--hover); color: var(--text); }
.icon-colour-clear svg { width: 15px; height: 15px; }
.pal-head { font-size: 11.5px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.pal-iconfield { display: flex; gap: 8px; align-items: center; }
.pal-icon { display: inline-flex; width: 30px; justify-content: center; flex: none; }
/* dropdown with icons / colour swatches (dropdown.js) */
.dd { position: relative; min-width: 0; }
.dd-btn { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; cursor: pointer; padding-right: 8px; }
.dd-face { display: flex; align-items: center; gap: 9px; min-width: 0; flex: 1; }
.dd-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-text.muted { color: var(--muted); }
.dd-chev { display: inline-flex; color: var(--muted); flex: none; }
.dd-chev svg { width: 16px; height: 16px; }
.dd-btn[aria-expanded="true"] .dd-chev { transform: rotate(180deg); }
.dd-lead { display: inline-flex; width: 18px; justify-content: center; align-items: center; flex: none; color: var(--text-2); }
.dd-lead:empty { display: none; }
.dd-lead svg { width: 15px; height: 15px; }
.dd-swatch { display: inline-block; width: 16px; height: 16px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .2); }
.dd-swatch.none { box-shadow: inset 0 0 0 1.5px var(--border-strong); background: repeating-linear-gradient(135deg, transparent 0 3px, var(--border) 3px 4px); }
.dd-pop { position: fixed; z-index: 1000; overflow-y: auto; padding: 4px; background: var(--surface-2, var(--surface)); border: 1px solid var(--border-strong); border-radius: var(--radius-s); box-shadow: 0 10px 30px rgba(0, 0, 0, .35); }
.dd-opt { display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: 6px; font-size: 13.5px; cursor: pointer; white-space: nowrap; }
.dd-opt.active { background: var(--accent-soft); }
.dd-opt[aria-selected="true"] { font-weight: 600; color: var(--text-strong); }
.dd-opt.divider { border-top: 1px solid var(--line); border-radius: 0 0 6px 6px; margin-top: 4px; padding-top: 9px; color: var(--text-2); }
.dd-hint { width: 9px; height: 9px; border-radius: 50%; margin-left: auto; flex: none; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .2); }
.pick-row { align-items: start; }
.custom-box { margin-top: 8px; }
.conv-table { width: 100%; border-collapse: collapse; font-size: 13px; margin: 6px 0 12px; }
.conv-table td { padding: 5px 6px; border-top: 1px solid var(--line); vertical-align: middle; }
.conv-table td.n { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); width: 60px; }
.conv-swatch { display: inline-block; width: 14px; height: 14px; border-radius: 50%; vertical-align: -2px; margin-right: 6px; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .2); }
.conv-sugg { border: 1px solid var(--warn-border); background: var(--warn-soft); border-radius: var(--radius-s); padding: 8px 12px; margin-bottom: 10px; }
.conv-sugg .check { margin: 0; }
.conv-sugg ul { margin: 6px 0 0 26px; padding: 0; font-size: 12.5px; color: var(--text-2); max-height: 140px; overflow: auto; }
.color-input input[type="color"] { width: 40px; min-height: 36px; padding: 2px; border: 1px solid var(--border-strong); border-radius: var(--radius-s); background: var(--input-bg); }

/* ---------- settings ---------- */
.settings { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: var(--gap); align-items: start; }
.settings > .main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.settings-cols { display: flex; flex-direction: column; gap: 16px; }
.cc-split { display: flex; flex-direction: column; gap: 16px; }
.site-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 400px), 1fr)); gap: 12px; align-items: start; }
.site-grid > .panel { grid-column: 1 / -1; }
/* tablets: Recent alerts and Activity side by side under the cards */
@media (min-width: 761px) and (max-width: 1100px) {
  .rcv-body > .page-side { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
}
@media (min-width: 1800px) {
  :root, :root[data-theme] { --pad-x: 32px; }
  .page-side { max-width: 400px; flex-basis: 340px; }
  /* settings panels in two columns; each panel stays whole */
  .settings-cols { display: block; column-count: 2; column-gap: 16px; }
  .settings-cols > section { break-inside: avoid; margin-bottom: 16px; }
  .cc-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
}
.settings-nav { position: sticky; top: calc(var(--header-h, 58px) + 16px); display: flex; flex-direction: column; gap: 2px; }
.settings-nav a { color: var(--text-2); text-decoration: none; padding: 7px 10px; border-radius: 6px; font-size: 13px; }
.settings-nav a:hover { background: var(--hover); color: var(--text); }
.settings-nav a[aria-current="true"] { color: var(--text-strong); background: var(--surface-2); box-shadow: inset 2px 0 0 var(--accent); }
.save-bar { position: sticky; bottom: 0; z-index: 5; display: flex; gap: 10px; align-items: center; justify-content: flex-end; padding: 12px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0; box-shadow: 0 -8px 24px rgba(0, 0, 0, .18); }
.save-bar .note { margin-right: auto; color: var(--muted); font-size: 13px; }
.save-bar .note.dirty { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; background: var(--warn-soft); border: 1px solid var(--warn-border); color: var(--warn-text); font-weight: 600; }
.save-bar .note.dirty::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
.plugin { position: relative; background: var(--surface-3); border: 1px solid var(--border); border-radius: var(--radius-m); padding: 12px 14px; margin-bottom: 10px; }
.plugin-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.plugin-head .desc { color: var(--muted); font-size: 12px; }
.plugin-body { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.plugin-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 6px; }
.plugin > .plugin-actions { position: absolute; top: 10px; right: 12px; margin: 0; }
.plugin-state { display: flex; flex-direction: column; gap: 2px; margin: 8px 0 0; }
.plugin-state .bad-text { color: var(--bad-text); overflow-wrap: anywhere; }
.test-out { margin: 4px 0 12px; }
.test-verdict { font-weight: 600; margin: 0 0 6px; }
.test-verdict.ok { color: var(--ok-text); }
.test-verdict.bad { color: var(--bad-text); }
.test-log { background: var(--input-bg); border: 1px solid var(--border); border-radius: var(--radius-s); padding: 8px 10px; font-family: var(--mono); font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 260px; overflow-y: auto; margin: 6px 0 0; }
.test-log .lvl-error { color: var(--bad-text); }
.test-log .lvl-warn { color: var(--warn-text); }
.test-log .lvl-debug { color: var(--faint); }
.ok-box { background: var(--ok-soft); border: 1px solid var(--ok-border); color: var(--ok-text); border-radius: var(--radius-s); padding: 9px 12px; margin-bottom: 12px; font-size: 13px; }
.error-box { background: var(--bad-soft); border: 1px solid var(--bad-border); color: var(--bad-text); border-radius: var(--radius-s); padding: 9px 12px; margin-bottom: 12px; font-size: 13px; }
.info-box { display: flex; gap: 10px; align-items: flex-start; background: var(--accent-soft); border: 1px solid var(--accent-border); color: var(--text); border-radius: var(--radius-s); padding: 10px 12px; margin-bottom: 12px; font-size: 13px; }
.info-box svg { width: 17px; height: 17px; flex: none; color: var(--accent-text); margin-top: 1px; }
.switch { position: relative; width: 36px; height: 20px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; position: absolute; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; background: var(--seg-off); border-radius: 999px; transition: background .15s; }
.switch span::after { content: ""; position: absolute; width: 14px; height: 14px; left: 3px; top: 3px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.rule-row { display: grid; grid-template-columns: minmax(0, 1.2fr) 130px minmax(0, 1.2fr) auto; gap: 6px; margin-bottom: 6px; align-items: center; }
.tpl-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) auto auto; gap: 6px; margin-bottom: 6px; align-items: center; }
.key-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) 150px auto; gap: 6px; margin-bottom: 6px; align-items: center; }
.cc-head { font-size: 11px; color: var(--faint); margin-bottom: 2px !important; text-transform: uppercase; letter-spacing: .05em; }
.cc-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.cc-panel-head .panel-title { margin-bottom: 0; }
.cc-filter button { height: 30px; font-size: 12.5px; }
.info-line { display: flex; gap: 7px; align-items: center; color: var(--muted); font-size: 12.5px; margin: -4px 0 10px; }
.info-line svg { width: 15px; height: 15px; flex: none; color: var(--accent-text); }
/* prefix table: compact rows, the delete button next to the row */
.cc-table { max-width: 760px; }
.cc-prefix-row { display: grid; grid-template-columns: 10px 130px 60px 170px minmax(90px, 1fr) minmax(36px, auto); gap: 0 12px; align-items: center; min-height: 40px; padding: 3px 8px; border-bottom: 1px solid var(--line); border-radius: 0; }
.cc-prefix-row:not(.cc-head):hover { background: var(--surface-2); }
.cc-prefix-row.cc-head { min-height: 0; padding-bottom: 6px; }
.cc-prefix-row .input { min-height: 32px; padding: 0 9px; font-size: 13px; }
.cc-prefix-row .cc-n, .cc-prefix-row .cc-last { white-space: nowrap; font-size: 13px; }
.cc-prefix-row .cc-n { font-variant-numeric: tabular-nums; color: var(--text); min-width: 36px; text-align: right; }
.cc-prefix-row .cc-last { color: var(--text-2); }
.cc-act { display: flex; align-items: center; gap: 8px; }
.cc-bar { flex: 1; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.cc-bar-blank { visibility: hidden; }
.cc-bar > span { display: block; height: 100%; border-radius: 3px; background: var(--ok); }
.cc-dot { width: 8px; height: 8px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--border-strong); }
.cc-dot.on { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.cc-prefix-row.idle .input { color: var(--text-2); }
.cc-prefix-row.idle .cc-n, .cc-prefix-row.idle .cc-last { color: var(--faint); }
.cc-del.btn.icon { width: 32px; height: 32px; min-height: 32px; border-color: transparent; background: transparent; color: var(--faint); }
.cc-del.btn.icon:hover, .cc-del.btn.icon:focus-visible { color: var(--bad-text); background: var(--bad-soft); border-color: var(--bad-border); }
.cc-prefix-row.dup .input:nth-child(3) { border-color: var(--warn); background: var(--warn-soft); }
.cc-seen-row .cc-freq { padding-left: 10px; font-size: 13px; }
.cc-unlisted { margin-top: 18px; }
.cc-unlisted h3 { font-size: 13px; margin: 0 0 2px; }
.cc-unlisted .help { color: var(--muted); font-size: 12.5px; margin: 0 0 6px; }
.warn-box { background: var(--warn-soft); border: 1px solid var(--warn-border); color: var(--warn-text); border-radius: var(--radius-s); padding: 8px 12px; margin-bottom: 10px; font-size: 13px; }
.cc-prefix-row .input { font-family: var(--mono); }
.cc-rule-row { display: grid; grid-template-columns: 22px 44px 150px 120px minmax(0, 1.4fr) 150px minmax(0, 1fr) auto; gap: 6px; margin-bottom: 6px; align-items: center; }
.cc-rule-row.off > *:not(.btn-row):not(.cc-on) { opacity: .5; }
.cc-num { color: var(--faint); font-family: var(--mono); font-size: 12px; text-align: right; }
.cc-on { display: flex; justify-content: center; }
.cc-on input { width: 16px; height: 16px; accent-color: var(--accent); }
.cc-digit { display: flex; gap: 6px; align-items: center; }
.cc-digit select { width: 56px; flex: none; }
.cc-example { font-family: var(--mono); font-size: 11px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cc-seen { font-size: 12px; color: var(--faint); margin-left: 6px; }
.cc-test-row { display: grid; grid-template-columns: 150px 160px minmax(0, 1fr) auto; gap: 0 8px; align-items: end; }
.cc-test-row .btn { margin-bottom: 14px; }
.cc-result { color: var(--accent-text); font-size: 15px; font-family: var(--mono); }
.cc-meta { color: var(--muted); font-size: 13px; }
.rep-configure summary { cursor: pointer; font-weight: 600; }
.rep .kv { margin-bottom: 4px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; font-size: 13px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-family: var(--mono); overflow-wrap: anywhere; }
.dupes { display: flex; flex-direction: column; }
.dupe { display: grid; grid-template-columns: minmax(0, 1fr) 32px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 9px 0; border-top: 1px solid var(--line); font-size: 13px; }
.dupe:first-child { border-top: 0; }
.dupe .from { color: var(--warn-text); }
.dupe small { color: var(--faint); }
.dupe svg { width: 16px; height: 16px; color: var(--faint); }
.dupe .kind { font-size: 11px; color: var(--faint); text-transform: uppercase; letter-spacing: .05em; display: block; }

/* ---------- auth ---------- */
.auth-wrap { display: flex; justify-content: center; padding: 72px 16px 40px; }
.auth.panel { padding: 24px 26px; }
.auth { width: min(400px, 100%); }
.auth h1 { font-size: 20px; font-weight: 600; margin: 0 0 16px; }

/* ---------- banner, toast, footer ---------- */
.banner-wrap { padding: 14px var(--pad-x) 0; }
.banner { background: var(--warn-soft); border: 1px solid var(--warn-border); color: var(--text); border-radius: var(--radius-m); padding: 10px 14px; display: flex; gap: 10px 14px; align-items: center; flex-wrap: wrap; font-size: 13px; }
.banner a { color: var(--warn-text); font-weight: 600; }
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 80; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--ok); border-radius: var(--radius-s); padding: 10px 14px; box-shadow: var(--shadow-lg); font-size: 13px; }
.toast.error { border-left-color: var(--bad); }
.footer { text-align: center; color: var(--faint); font-size: 12px; padding: 4px 0 22px; }
.footer a { color: var(--muted); }

/* ---------- updates (settings) ---------- */
.help.warn-text { color: var(--warn-text); }
.help-text { color: var(--muted); font-size: 13px; margin: 0 0 12px; line-height: 1.5; }
.muted { color: var(--muted); }
span.bad-text, p.bad-text { color: var(--bad-text); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; align-items: center; flex-wrap: nowrap; }
.upd-kv { margin-bottom: 12px; }
.upd-kv dd { font-family: var(--sans, inherit); }
.upd-kv .tag { margin-left: 4px; }
.upd-available { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--accent-soft); border: 1px solid var(--accent-border); border-radius: var(--radius-s); padding: 10px 12px; font-size: 13px; }
.upd-available > svg { width: 17px; height: 17px; color: var(--accent-text); flex: none; }
.upd-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.upd-head h3 { margin: 0; }
.upd-lib { border-radius: var(--radius-s); transition: background .15s; }
.upd-lib.drop { background: var(--accent-soft); outline: 2px dashed var(--accent-border); outline-offset: 4px; }
.upd-table { margin-bottom: 10px; }
.upd-table td:first-child { min-width: 200px; }
.upd-table td:last-child { width: 1%; white-space: nowrap; }
.upd-name { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.upd-file { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.upd-table .small, .muted.small { font-size: 11.5px; }
.upd-progress { display: flex; align-items: center; gap: 10px; font-size: 12.5px; margin: 6px 0 12px; }
.upd-progress .bar { flex: 1; height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.upd-progress .bar i { display: block; height: 100%; background: var(--accent); transition: width .2s; }
.upd-drop { border: 1px dashed var(--border); border-radius: var(--radius-s); padding: 18px; text-align: center; font-size: 13px; }
.upd-checked { font-size: 13px; color: var(--text-2); margin: 12px 0 10px; }
.upd-result { margin-top: 12px; }
.upd-result .ok-box { display: flex; gap: 8px; align-items: flex-start; }
.upd-result .ok-box svg { width: 16px; height: 16px; flex: none; margin-top: 1px; }
.upd-endpoints { margin-top: 4px; font-size: 12.5px; }
.upd-wait { text-align: center; width: min(440px, 100%); }
.upd-wait h2 { font-size: 16px; margin: 12px 0 6px; }
.upd-wait p { color: var(--text-2); margin: 0 0 6px; }
.upd-wait.ok p { color: var(--ok-text); }
.upd-wait.bad p { color: var(--bad-text); text-align: left; }
.upd-wait .btn-row { justify-content: center; margin-top: 14px; }
.upd-spin { width: 28px; height: 28px; margin: 4px auto 0; border-radius: 50%; border: 3px solid var(--surface-2); border-top-color: var(--accent); animation: upd-spin .9s linear infinite; }
@keyframes upd-spin { to { transform: rotate(360deg); } }
@media (max-width: 760px) {
  .upd-table.lib th:nth-child(3), .upd-table.lib td:nth-child(3), .upd-table.lib th:nth-child(4), .upd-table.lib td:nth-child(4),
  .upd-table.remote th:nth-child(3), .upd-table.remote td:nth-child(3) { display: none; }
  .upd-table td:first-child { min-width: 0; }
  .upd-file { overflow-wrap: anywhere; }
}
@media (prefers-reduced-motion: reduce) { .upd-spin { animation-duration: 3s; } }

/* ---------- release notes ---------- */
.rel-list { max-width: 860px; }
.release { padding: 18px 22px 8px; scroll-margin-top: calc(var(--header-h, 58px) + 14px); }
.rel-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.rel-head h2 { margin: 0; font-family: var(--mono); font-size: 18px; font-weight: 600; letter-spacing: -.01em; }
.rel-date { color: var(--muted); font-size: 12.5px; }
.rel-head .tag { align-self: center; }
.rel-sec { margin: 12px 0 10px; }
.rel-sec h3 { margin: 0 0 6px; display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 500; }
.rel-sec h3 .tag { font-size: 11.5px; padding: 2px 8px; }
.rel-aud { color: var(--faint); font-size: 11.5px; }
.rel-sec ul { margin: 0; padding-left: 18px; color: var(--text-2); line-height: 1.55; }
.rel-sec li { margin: 3px 0; }
.rel-sec li::marker { color: var(--faint); }
.rel-sec strong { color: var(--text); font-weight: 600; }
.whats-new h2 { margin: 0 0 6px; font-size: 17px; }
.whats-new .rel-ver { margin: 14px 0 0; font-family: var(--mono); font-size: 13px; color: var(--muted); font-weight: 500; }
.whats-new .btn-row { margin-top: 16px; }
.whats-new .btn-row a { font-size: 13px; color: var(--link); text-decoration: none; }

/* ---------- responsive ---------- */
/* tablets: four columns, Time | Capcode, frequency and sites stacked | Agency · Alias | Message */
@media (min-width: 761px) and (max-width: 1279px) {
  .msg-head, .msg-row,
  .msgs.no-capcode .msg-head, .msgs.no-capcode .msg-row,
  .msgs.no-rx .msg-head, .msgs.no-rx .msg-row,
  .msgs.no-capcode.no-rx .msg-head, .msgs.no-capcode.no-rx .msg-row { grid-template-columns: 66px 112px clamp(110px, 18vw, 200px) minmax(0, 1fr); gap: 12px; padding: 0 16px; }
  .msg-head .h-cc, .msg-head .h-fq, .msg-head .h-rx { display: none; }
  .msg-head .h-meta { display: block; }
  .msg-head { padding-top: 10px; padding-bottom: 10px; }
  .msg-row { padding-top: 11px; padding-bottom: 11px; }
  .msg-row .meta { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; min-width: 0; }
  .msg-row .meta .fq { font-size: 12px; }
  .msg-row .meta .rx { margin-top: 2px; }
  .msg-row .t .t-full { display: none; }
  .msg-row .t .t-hm { display: inline; }
  .msg-day { padding: 12px 16px 6px; }
}
@media (max-width: 1100px) {
  .page-side, .shell > .side { max-width: none; flex-basis: 100%; }
}
@media (max-width: 860px) {
  .settings { grid-template-columns: minmax(0, 1fr); }
  .settings-nav { position: static; flex-direction: row; flex-wrap: wrap; }
  .rule-row, .tpl-row, .key-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .pal-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
  .pal-row.icons { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) auto auto; }
  .pal-row.icons .icon-colour { width: 40px; }
  .pal-row.icons .pal-icon { display: none; }
  .pal-head.icons { display: none; }
  .cc-rule-row { grid-template-columns: 22px 30px minmax(0, 1fr) minmax(0, 1fr); padding-bottom: 8px; border-bottom: 1px solid var(--line); }
  .cc-rule-row.cc-head { display: none; }
  .cc-rule-row > :nth-child(5) { grid-column: 1 / -1; }
  .cc-rule-row > :nth-child(6) { grid-column: 1 / 4; }
  .cc-rule-row > :nth-child(7) { grid-column: 4; }
  .cc-rule-row > :nth-child(8) { grid-column: 1 / -1; justify-content: flex-end; }
  .cc-prefix-row { grid-template-columns: 8px minmax(0, 1fr) 52px minmax(0, 1fr) minmax(32px, auto); gap: 0 8px; padding: 3px 2px; }
  .cc-prefix-row > :nth-child(5) { display: none; }
  .cc-del.btn.icon { color: var(--bad-text); }
  .cc-test-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
@media (max-width: 760px) {
  :root, :root[data-theme] { --pad-x: 16px; --gap: 14px; }
  body { font-size: 14.5px; }
  .topbar-row { gap: 0 10px; min-height: 0; padding-top: 10px; flex-wrap: wrap; }
  .brand { margin-right: 0; }
  .brand-name { font-size: 16px; max-width: 150px; }
  .topbar-tools { padding: 0; gap: 8px; }
  .topbar-tools .pill .txt { display: none; }
  .topbar-tools .pill { padding: 0 9px; }
  .account-btn .uname, .account-btn > svg { display: none; }
  .account-btn { padding: 0 3px; }
  .nav { order: 3; flex-basis: calc(100% + 2 * var(--pad-x)); margin: 6px calc(-1 * var(--pad-x)) 0; padding: 0 8px; }
  .nav a { min-height: 42px; padding: 0 10px; }
  .page-head { padding-top: 14px; }
  .page-head .search, .page-head .search.narrow { flex: 1 1 100%; }
  .page-head h1 { font-size: 19px; }
  .kpis { display: flex; overflow-x: auto; margin: 0 calc(-1 * var(--pad-x)); padding: 0 var(--pad-x); scrollbar-width: none; gap: 8px; }
  .kpis::-webkit-scrollbar { display: none; }
  .kpi { flex: none; min-width: 120px; padding: 10px 12px; }
  .kpi .v { font-size: 20px; }
  .kpi .s { display: none; }
  .panel { padding: 14px; }
  .drawer { padding: 16px 16px 90px; border-left: 0; }
  .drawer-foot { margin: 18px -16px -90px; padding: 12px 16px 18px; }
  /* message list as stacked blocks */
  .msg-head { display: none; }
  .msg-row, .msgs.no-capcode .msg-row, .msgs.no-rx .msg-row, .msgs.no-capcode.no-rx .msg-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 10px; padding: 12px 14px 12px 16px; }
  .msg-row .t { grid-column: 1; grid-row: 1; display: flex; gap: 8px; align-items: baseline; }
  .msg-row .t .rel { display: inline; }
  .msg-row .t .t-full { display: none; }
  .msg-row .t .t-short { display: inline; }
  .msg-row .rx { display: none; }
  .msg-row .fq { grid-column: 2; grid-row: 1; font-size: 12px; }
  .msg-row .who { grid-column: 1 / -1; grid-row: 2; }
  .msg-row .who .names { flex-direction: row; flex-wrap: wrap; gap: 0 8px; align-items: baseline; }
  .msg-row .body { grid-column: 1 / -1; grid-row: 3; font-size: 14px; }
  .msg-row .rx { grid-column: 1; grid-row: 4; }
  .msg-row .cc { grid-column: 2; grid-row: 4; font-size: 12px; color: var(--faint); align-self: center; }
  .msg-day { padding: 8px 14px 5px; }
  .rx-detail { overflow-x: auto; }
  .site-head, .host-head { padding: 12px 14px; }
  .card-note { margin: 0 14px 10px; }
  .toasts { left: 16px; right: 16px; max-width: none; }
  .filter-search { flex-basis: 100%; }
  .search-key { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .msg-row.fresh { animation: none; background: var(--row-new); }
  * { transition: none !important; }
}
.panel[id] { scroll-margin-top: calc(var(--header-h, 58px) + 14px); }

/* Log */
.log-help { margin: 0 0 12px; font-size: 13px; color: var(--muted); }
.log-follow { margin: 0; align-items: center; white-space: nowrap; }
.log-lines { font-family: var(--mono, 'JetBrains Mono', monospace); font-size: 12px; max-height: calc(100vh - 290px); min-height: 240px; overflow: auto; }
.log-line { display: grid; grid-template-columns: 150px 52px 44px 1fr; gap: 10px; padding: 3px 14px; border-top: 1px solid var(--line); align-items: baseline; }
.log-line:first-child { border-top: 0; }
.log-line .lt { color: var(--faint); white-space: nowrap; }
.log-line .ls { color: var(--muted); }
.log-line .lx { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text-2); }
.log-line .ll { font-weight: 600; text-transform: uppercase; font-size: 10.5px; color: var(--faint); }
.log-line .ll.warn { color: var(--warn); }
.log-line .ll.error { color: var(--bad); }
.log-line.error { background: color-mix(in srgb, var(--bad) 7%, transparent); }
.log-line.error .lx { color: var(--text); }
.log-empty { padding: 18px; color: var(--muted); margin: 0; }
.log-table td.log-what { overflow-wrap: anywhere; width: 100%; }
.log-table th { white-space: nowrap; }
.log-table td.nowrap, .log-table td.mono.nowrap { white-space: nowrap; }
.log-more { margin-top: 12px; justify-content: center; }
@media (max-width: 760px) {
  .log-line { grid-template-columns: 1fr auto; gap: 2px 8px; padding: 6px 12px; }
  .log-line .lt { grid-column: 1; }
  .log-line .ls { display: none; }
  .log-line .lx { grid-column: 1 / -1; }
  .log-table thead { display: none; }
  .log-table, .log-table tbody { display: block; }
  .log-table tr { display: grid; grid-template-columns: auto auto 1fr; align-items: center; gap: 4px 10px; padding: 10px 14px; border-top: 1px solid var(--line); }
  .log-table tr:first-child { border-top: 0; }
  table.grid.log-table td { border: 0; padding: 0; }
  .log-table td:nth-child(3) { justify-self: end; }
  .log-table td.log-what { grid-column: 1 / -1; }
  .log-table td:nth-child(5) { display: none; }
}

/* Users */
.user-dot { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--border); font-size: 11px; font-weight: 600; color: var(--text-2); }
.user-dot.admin { background: var(--warn-soft); border-color: var(--warn-border); color: var(--warn-text); }
@media (max-width: 760px) {
  .users-table th:nth-child(3), .users-table td:nth-child(3), .users-table th:nth-child(4), .users-table td:nth-child(4), .users-table th:nth-child(7), .users-table td:nth-child(7) { display: none; }
}

/* ---------- pop-up action menu ---------- */
.pop-menu { position: fixed; right: auto; top: 0; z-index: 80; min-width: 200px; }
.menu .menu-sep { height: 1px; background: var(--line); margin: 5px 4px; }
.menu button.item.danger, .menu button.item.danger svg { color: var(--bad-text); }
.menu button.item:disabled { opacity: .45; cursor: default; background: none; }
.btn.ghost { border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); border-color: var(--border-strong); }

/* ---------- Files ---------- */
.notice { display: flex; align-items: center; gap: 10px; background: var(--accent-soft); border: 1px solid var(--accent-border); color: var(--accent-text); border-radius: var(--radius-s); padding: 9px 12px; font-size: 13px; }
.notice svg { width: 16px; height: 16px; flex: none; }
.notice .spacer { flex: 1; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 14px; min-width: 0; }
.crumbs .crumb { color: var(--link); text-decoration: none; padding: 3px 6px; border-radius: 6px; border: 1px dashed transparent; }
.crumbs a.crumb:hover { background: var(--hover); }
.crumbs .crumb.current { color: var(--text-strong); font-weight: 600; }
.crumbs .crumb-sep { color: var(--faint); }
.crumbs .crumb.drop-target { border-color: var(--accent); background: var(--accent-soft); }
.files-panel { position: relative; }
.files-panel.drop::after { content: attr(data-drop-label); position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--accent-soft) 88%, transparent); border: 2px dashed var(--accent); border-radius: var(--radius); color: var(--accent-text); font-weight: 600; font-size: 15px; pointer-events: none; min-height: 120px; }
.files-table td { padding-top: 7px; padding-bottom: 7px; }
.files-table .files-name { display: flex; align-items: center; gap: 10px; min-width: 0; }
.files-table th:first-child { width: 100%; }
.file-icon { width: 30px; height: 30px; flex: none; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; background: var(--surface-2); color: var(--text-2); }
.file-icon svg { width: 17px; height: 17px; }
.file-icon.folder { background: color-mix(in srgb, var(--brand) 18%, transparent); color: var(--brand); }
.file-icon.sheet { background: var(--ok-soft); color: var(--ok-text); }
.fn { display: flex; flex-direction: column; min-width: 0; }
.fn-name { font-weight: 550; color: var(--text-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fn-where { font-size: 12px; color: var(--muted); }
.files-table tr.unavailable .fn-name { color: var(--muted); }
.files-table tr.drop-target td { background: var(--accent-soft); box-shadow: inset 0 1px 0 var(--accent), inset 0 -1px 0 var(--accent); }
.files-table .files-more { width: 1%; }
.files-empty svg { width: 34px; height: 34px; color: var(--faint); margin-bottom: 8px; }
.files-empty p { margin: 0; }
td.n, th.n { text-align: right; }
td.nowrap, .nowrap { white-space: nowrap; }
.muted { color: var(--muted); }
.files-uploads { display: flex; flex-direction: column; gap: 6px; }
.files-uploads:empty { display: none; }
.upload-row { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-s); padding: 7px 10px; font-size: 13px; }
.upload-row .fn-name { flex: 0 1 auto; font-weight: 500; }
.upload-row.bad { border-color: var(--bad-border); color: var(--bad-text); }
.upload-bar { flex: 1; height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; min-width: 60px; }
.upload-bar i { display: block; height: 100%; background: var(--accent); transition: width .2s; }
.modal.file-preview { width: min(1100px, 100%); height: min(88vh, 1000px); max-height: none; display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.preview-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px 10px 16px; border-bottom: 1px solid var(--border); }
.preview-head .spacer { flex: 1; }
.preview-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.preview-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-body { flex: 1; min-height: 0; overflow: auto; background: var(--surface-3); }
.preview-frame { width: 100%; height: 100%; border: 0; display: block; background: #fff; }
.preview-img { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 16px; }
.preview-img img { max-width: 100%; max-height: 100%; object-fit: contain; box-shadow: var(--shadow-lg); }
.preview-text { margin: 0; padding: 16px 18px; font: 12.5px/1.55 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text); }
.versions-table td { vertical-align: top; }
.btn-row.stack { flex-direction: column; align-items: stretch; }
@media (max-width: 760px) {
  .hide-s { display: none; }
  .modal.file-preview { height: 92vh; }
}

/* ---------- Backup and restore ---------- */
.restore .section:first-child, .restore .rs-job + .section { border-top: 0; margin-top: 0; padding-top: 0; }
.rs-job { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rs-job .bar { flex: 1 1 120px; height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.rs-job .bar i { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.rs-as .check { margin-bottom: 8px; }
.rs-as .check strong { display: block; font-weight: 550; }
.spinner { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Spreadsheet editor ---------- */
.sheet-head { padding-bottom: 4px; align-items: flex-end; }
.sheet-name { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.sheet-crumbs { font-size: 12.5px; }
.sheet-crumbs .crumb { padding: 0 2px; }
.sheet-name-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.sheet-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-dirty { font-size: 12px; color: var(--warn-text); background: var(--warn-soft); border: 1px solid var(--warn-border); border-radius: 999px; padding: 1px 9px; white-space: nowrap; }
.sheet-ver { font-family: var(--mono); font-size: 12px; color: var(--muted); padding-bottom: 6px; }
.sheet-wrap { padding: 8px var(--pad-x) 0; display: flex; flex-direction: column; gap: 8px; }
.sheet-banner:empty { display: none; }
.sheet-toolbar { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-s); padding: 5px 6px; }
.sheet-toolbar .tb { position: relative; }
.sheet-toolbar .tb.on { background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent-border); }
.sheet-toolbar .btn.small { border-color: transparent; }
.sheet-toolbar .btn.small:hover { border-color: var(--border-strong); }
.sheet-toolbar .btn.small.on { border-color: var(--accent-border); }
.sheet-toolbar .tb[style*="--swatch"]::after { content: ""; position: absolute; left: 6px; right: 6px; bottom: 3px; height: 3px; border-radius: 2px; background: var(--swatch); }
.tb-sep { width: 1px; height: 20px; background: var(--border-strong); margin: 0 4px; }
.sheet-fx { display: flex; align-items: stretch; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-s); overflow: hidden; }
.fx-ref { min-width: 92px; padding: 0 10px; display: flex; align-items: center; border-right: 1px solid var(--border); font-size: 12.5px; color: var(--text-2); }
.fx-label { padding: 0 8px; display: flex; align-items: center; color: var(--faint); font-style: italic; font-size: 12px; border-right: 1px solid var(--line); }
.fx-input { flex: 1; border: 0; background: transparent; color: var(--text); padding: 0 10px; min-height: 32px; font-size: 13px; outline: none; }
.fx-input:focus { background: var(--input-bg); box-shadow: inset 0 0 0 2px var(--accent-soft); }
.sg-host { position: relative; }
.sg-scroll { overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-s); outline: none; height: 60vh; position: relative; }
.sg-scroll:focus-visible { border-color: var(--accent); }
table.sg { border-collapse: separate; border-spacing: 0; table-layout: fixed; font-size: 13px; }
table.sg th, table.sg td { height: 26px; padding: 0 6px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; box-sizing: border-box; }
table.sg thead th { position: sticky; top: 0; z-index: 3; background: var(--surface-2); color: var(--muted); font-weight: 500; font-size: 11.5px; text-align: center; user-select: none; }
table.sg thead tr.sg-frozen td, table.sg thead tr.sg-frozen th { position: sticky; top: 26px; z-index: 2; background: var(--surface); border-bottom: 2px solid var(--border-strong); }
table.sg thead tr.sg-frozen th.sg-rh { z-index: 4; background: var(--surface-2); }
table.sg th.sg-rh { position: sticky; left: 0; z-index: 1; background: var(--surface-2); color: var(--muted); font-weight: 500; font-size: 11.5px; text-align: center; user-select: none; cursor: e-resize; }
table.sg th.sg-ch { cursor: s-resize; position: sticky; }
table.sg th.sg-corner { position: sticky; left: 0; top: 0; z-index: 5; background: var(--surface-2); cursor: pointer; }
table.sg th.on { background: var(--accent-soft); color: var(--accent-text); }
table.sg td { color: var(--text); cursor: cell; background: var(--surface); }
table.sg td.num { font-variant-numeric: tabular-nums; }
table.sg td.err { color: var(--bad-text); }
table.sg td.b { font-weight: 700; }
table.sg td.i { font-style: italic; }
table.sg td.a-left { text-align: left; }
table.sg td.a-center { text-align: center; }
table.sg td.a-right { text-align: right; }
table.sg td.filled { color: #101828; }
table.sg td.sel { box-shadow: inset 0 0 0 9999px color-mix(in srgb, var(--accent) 14%, transparent); }
table.sg td.cur { outline: 2px solid var(--accent); outline-offset: -2px; }
table.sg tr.sg-spacer td { padding: 0; border: 0; background: transparent; }
.sg-resize { position: absolute; top: 0; right: -3px; width: 7px; height: 100%; cursor: col-resize; z-index: 2; }
.sg-resize:hover { background: var(--accent); opacity: .5; }
.sg-grow { padding: 8px 10px 10px 52px; }
.sg-editor { position: absolute; z-index: 10; box-sizing: border-box; padding: 0 5px; border: 2px solid var(--accent); background: var(--input-bg); color: var(--text); font: 13px var(--sans); outline: none; box-shadow: var(--shadow-lg); }
.sheet-foot { display: flex; align-items: center; gap: 10px; padding-bottom: 12px; flex-wrap: wrap; }
.sheet-foot .spacer { flex: 1; }
.sheet-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.sheet-tab { height: 30px; padding: 0 14px; border: 1px solid var(--border); border-top: 0; border-radius: 0 0 8px 8px; background: var(--surface-2); color: var(--text-2); cursor: pointer; font-size: 13px; }
.sheet-tab.on { background: var(--surface); color: var(--text-strong); font-weight: 600; box-shadow: inset 0 2px 0 var(--accent); }
.sheet-tab.add { padding: 0 10px; display: inline-flex; align-items: center; }
.sheet-tab.add svg { width: 15px; height: 15px; }
.sheet-status { font-size: 12px; color: var(--muted); }
.color-pop { padding: 10px; min-width: 0; }
.swatches { display: grid; grid-template-columns: repeat(6, 26px); gap: 6px; }
.swatch { width: 26px; height: 26px; border-radius: 6px; border: 1px solid var(--border-strong); cursor: pointer; }
.swatch:hover { outline: 2px solid var(--accent); outline-offset: 1px; }
.color-row { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.color-row input[type="color"] { width: 40px; height: 28px; border: 1px solid var(--border-strong); border-radius: 6px; background: none; padding: 1px; }
.sheet-toolbar.disabled { opacity: .55; }
@media (max-width: 760px) {
  .sheet-wrap { padding-left: 10px; padding-right: 10px; }
  .fx-ref { min-width: 64px; }
}

/* Settings → Alias types: update the aliases too */
.type-update-list { display: flex; flex-direction: column; gap: 6px; margin: 12px 0 16px; max-height: 50vh; overflow: auto; }
.check.type-update { align-items: center; gap: 12px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; margin: 0; }
.check.type-update > span:last-child { display: flex; flex-direction: column; }
.type-update-icons { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }

/* Backup and restore → Import and merge a database */
.db-import .check strong { display: block; font-weight: 550; }
.db-import .check > span { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.db-import .warn-text { color: var(--warn-text); font-size: 12px; }
.im-options { display: flex; flex-direction: column; gap: 4px; margin: 8px 0; }
.im-differ { margin-top: 8px; }
.im-differ .check { margin-bottom: 6px; }
.im-sub { margin: 4px 0 8px; font-size: 13px; }
.im-sub-option { margin-left: 26px; }
.im-differ details { margin-top: 4px; }
.im-differ summary { cursor: pointer; color: var(--accent); font-size: 13px; margin-bottom: 8px; }
.im-differ .table-wrap { max-height: 320px; overflow: auto; }
.im-alias { display: inline-flex; align-items: center; gap: 8px; }
.im-alias > span:last-child { display: flex; flex-direction: column; }
.help.bad-text { color: var(--bad-text); }
