/* MewBot dashboard. Dark by default; light via system preference or the toggle. */
:root {
  --bg: #0b0d12; --surface: #12151c; --surface-2: #191d27; --surface-3: #212633; --border: #262b37; --border-strong: #343a49;
  --text: #e7e9ee; --text-muted: #8b93a6; --text-faint: #868e9c;
  --accent: #818cf8; --accent-strong: #a5b4fc; --on-accent: #0b0d12;
  --staff: #2bb3a3; --danger: #f87171; --warn: #fbbf24; --ok: #34d399; --info: #38bdf8;
  --series-customer: #8a96a8; --series-bot: var(--accent); --series-staff: var(--staff);
  --bot-weak: rgba(129, 140, 248, .12); --staff-weak: rgba(43, 179, 163, .12); --danger-weak: rgba(248, 113, 113, .12);
  --warn-weak: rgba(251, 191, 36, .12); --ok-weak: rgba(52, 211, 153, .12); --info-weak: rgba(56, 189, 248, .12);
  --shadow: 0 12px 32px rgba(0, 0, 0, .45), 0 2px 6px rgba(0, 0, 0, .3);
  --font: ui-sans-serif, system-ui, "Segoe UI", Roboto, Inter, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", monospace;
  --radius: 6px; --row: 40px; --top: 48px; --side-w: 220px; --tabbar: 56px;
  --ease: 120ms ease;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f6f7f9; --surface: #ffffff; --surface-2: #f0f2f5; --surface-3: #e6e9ee; --border: #e2e5ea; --border-strong: #cfd4dc;
    --text: #12151b; --text-muted: #5a6374; --text-faint: #636b78;
    --accent: #4f46e5; --accent-strong: #4338ca; --on-accent: #ffffff;
    --staff: #115e59; --danger: #b91c1c; --warn: #92400e; --ok: #047857; --info: #0369a1;
    --series-customer: #6b7787;
    --bot-weak: rgba(79, 70, 229, .10); --staff-weak: rgba(18, 135, 122, .10); --danger-weak: rgba(220, 38, 38, .10);
    --warn-weak: rgba(180, 83, 9, .10); --ok-weak: rgba(5, 150, 105, .10); --info-weak: rgba(2, 132, 199, .10);
    --shadow: 0 12px 32px rgba(18, 21, 27, .14), 0 2px 6px rgba(18, 21, 27, .08);
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #f6f7f9; --surface: #ffffff; --surface-2: #f0f2f5; --surface-3: #e6e9ee; --border: #e2e5ea; --border-strong: #cfd4dc;
  --text: #12151b; --text-muted: #5a6374; --text-faint: #636b78;
  --accent: #4f46e5; --accent-strong: #4338ca; --on-accent: #ffffff;
  --staff: #115e59; --danger: #b91c1c; --warn: #92400e; --ok: #047857; --info: #0369a1;
  --series-customer: #6b7787;
  --bot-weak: rgba(79, 70, 229, .10); --staff-weak: rgba(18, 135, 122, .10); --danger-weak: rgba(220, 38, 38, .10);
  --warn-weak: rgba(180, 83, 9, .10); --ok-weak: rgba(5, 150, 105, .10); --info-weak: rgba(2, 132, 199, .10);
  --shadow: 0 12px 32px rgba(18, 21, 27, .14), 0 2px 6px rgba(18, 21, 27, .08);
  color-scheme: light;
}
:root[data-compact="1"] { --row: 32px; }

/* ------------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; }
input, select { font: inherit; color: var(--text); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
kbd { font: 500 11px/1 var(--mono); color: var(--text-faint); border: 1px solid var(--border); border-radius: 4px; padding: 3px 5px; background: var(--surface-2); }
.mono, .id { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.num, .tnum { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.i { fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; flex: none; display: block; }
.i path { vector-effect: non-scaling-stroke; }
.boot { position: fixed; inset: 0; background: var(--bg); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.t-staff-txt { color: var(--staff); font-weight: 500; }
.flash-hl .bubble { animation: hl 2.4s ease; }
@keyframes hl { 0%, 40% { box-shadow: 0 0 0 2px var(--accent); } 100% { box-shadow: 0 0 0 0 transparent; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }

/* ------------------------------------------------------------------ buttons, fields */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: var(--radius);
  border: 1px solid var(--border-strong); background: var(--surface); font-weight: 500; font-size: 13px; cursor: pointer; white-space: nowrap; transition: background var(--ease), border-color var(--ease); text-decoration: none; color: var(--text); }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn-block { width: 100%; height: 40px; }
.btn[disabled] { opacity: .6; cursor: default; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border: 0; border-radius: var(--radius); background: transparent; color: var(--text-muted); cursor: pointer; transition: background var(--ease), color var(--ease); }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.link-btn { display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; padding: 2px 4px; color: var(--text-muted); font-size: 12px; cursor: pointer; border-radius: 4px; }
.link-btn:hover { color: var(--text); background: var(--surface-2); }
.link-btn[aria-pressed="true"], .link-btn.on { color: var(--text); background: var(--surface-3); }
.field { display: grid; gap: 6px; }
.field-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.input, .field input, select.input { height: 36px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface-2); width: 100%; min-width: 0; }
.input:focus, .field input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.seg { display: inline-flex; padding: 2px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); gap: 2px; }
.seg button { border: 0; background: none; height: 26px; padding: 0 10px; border-radius: 4px; font-size: 12px; font-weight: 500; color: var(--text-muted); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--border); }

/* ------------------------------------------------------------------ chips, pills, dots */
.chip { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 6px; border-radius: 4px; font-size: 12px; font-weight: 500; line-height: 1; background: var(--surface-2); color: var(--text-muted); white-space: nowrap; flex: none; }
.chip-danger { background: var(--danger-weak); color: var(--danger); }
.chip-warn { background: var(--warn-weak); color: var(--warn); }
.chip-ok { background: var(--ok-weak); color: var(--ok); }
.chip-info { background: var(--info-weak); color: var(--info); }
.chip-bot { background: var(--bot-weak); color: var(--accent); }
.chip-staff { background: var(--staff-weak); color: var(--staff); }
.chip-game { background: var(--surface-2); color: var(--text); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); flex: none; display: inline-block; }
.dot-ok { background: var(--ok); } .dot-warn { background: var(--warn); } .dot-danger { background: var(--danger); }
.badge { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: #dc2626; color: #fff; font-size: 11px; font-weight: 600; line-height: 18px; text-align: center; font-variant-numeric: tabular-nums; }
.t-warn { color: var(--warn); } .t-danger { color: var(--danger); } .t-ok { color: var(--ok); }

/* ------------------------------------------------------------------ login */
.login { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); padding: 16px; z-index: 100; }
.login-card { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 28px 24px 24px; display: grid; gap: 16px; }
.login-brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 16px; }
.login-title { margin: 0; font-size: 20px; font-weight: 600; }
.login-err { margin: 0; color: var(--danger); font-size: 13px; }
.brand-mark { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; background: var(--accent); color: var(--on-accent); flex: none; }

/* ------------------------------------------------------------------ shell */
.shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); grid-template-rows: var(--top) auto; grid-template-areas: "side top" "side main"; min-height: 100vh; }
.shell[data-side="collapsed"] { --side-w: 56px; }
.sidebar { grid-area: side; position: sticky; top: 0; height: 100vh; border-right: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; overflow: hidden; z-index: 20; }
.side-brand { height: var(--top); display: flex; align-items: center; gap: 10px; padding: 0 10px 0 14px; font-weight: 600; border-bottom: 1px solid var(--border); }
.side-brand .side-label { flex: 1; }
.side-nav { display: grid; gap: 2px; padding: 8px; }
.side-nav a { display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px; border-radius: var(--radius); color: var(--text-muted); font-weight: 500; text-decoration: none; transition: background var(--ease), color var(--ease); white-space: nowrap; }
.side-nav a:hover { background: var(--surface-2); color: var(--text); }
.side-nav a[aria-current="page"] { background: var(--surface-2); color: var(--text); }
.side-nav a[aria-current="page"] .i { color: var(--accent); }
.side-nav .badge { margin-left: auto; }
.shell[data-side="collapsed"] .side-label { display: none; }
.shell[data-side="collapsed"] .side-brand { padding: 0; justify-content: center; flex-direction: column; gap: 0; }
.shell[data-side="collapsed"] .side-brand .brand-mark { display: none; }
.shell[data-side="collapsed"] .side-collapse .i { transform: rotate(180deg); }
.shell[data-side="collapsed"] .side-nav a { justify-content: center; padding: 0; position: relative; }
.shell[data-side="collapsed"] .side-nav .badge { position: absolute; top: 2px; right: 2px; min-width: 16px; height: 16px; line-height: 16px; font-size: 10px; padding: 0 4px; }

.topbar { grid-area: top; position: sticky; top: 0; z-index: 30; height: var(--top); display: flex; align-items: center; gap: 12px; padding: 0 12px 0 20px; background: var(--bg); border-bottom: 1px solid var(--border); min-width: 0; }
.top-title { font-weight: 600; font-size: 14px; white-space: nowrap; display: none; }
.search-trigger { display: flex; align-items: center; gap: 8px; height: 32px; width: 320px; max-width: 34vw; min-width: 0; padding: 0 8px 0 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text-faint); cursor: pointer; }
.search-trigger:hover { border-color: var(--border-strong); }
.search-ph { flex: 1; text-align: left; font-size: 13px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.strip { display: flex; align-items: center; gap: 6px; margin-left: auto; min-width: 0; overflow: hidden; }
.pill { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border: 1px solid var(--border); border-radius: 14px; font-size: 12px; color: var(--text-muted); white-space: nowrap; text-decoration: none; background: var(--surface); }
.pill:hover { text-decoration: none; color: var(--text); border-color: var(--border-strong); }
.pill b { font-weight: 500; color: var(--text); }
.pill-warn { border-color: transparent; background: var(--warn-weak); color: var(--warn); }
.pill-warn b, .pill-danger b { color: inherit; }
.pill-danger { border-color: transparent; background: var(--danger-weak); color: var(--danger); }
.pill-plain { border-color: transparent; background: none; padding: 0 4px; }
.status-dot-btn { display: none; min-width: 40px; height: 40px; padding: 0 8px; border: 0; background: none; align-items: center; justify-content: center; cursor: pointer; border-radius: var(--radius); }
.top-actions { display: flex; align-items: center; gap: 2px; }

.main { grid-area: main; min-width: 0; padding: 20px 24px 40px; }
.main:focus { outline: none; }
.tabbar { display: none; }

/* ------------------------------------------------------------------ layout helpers */
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; min-width: 0; }
.page-title { margin: 0; font-size: 20px; font-weight: 600; }
.page-sub { color: var(--text-muted); font-size: 13px; }
.page-head .spacer { flex: 1; }
.stack { display: grid; gap: 12px; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; min-width: 0; }
.panel-flush { padding: 0; overflow: hidden; }
.panel-head { display: flex; align-items: center; gap: 8px; min-height: 28px; margin-bottom: 12px; flex-wrap: wrap; }
.panel-flush > .panel-head { padding: 12px 16px 0; margin-bottom: 8px; }
.panel-title { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-muted); display: flex; align-items: center; gap: 8px; }
.panel-title .count { font-family: var(--mono); color: var(--text-faint); font-weight: 500; letter-spacing: 0; }
.panel-head .spacer { flex: 1; }
.panel-note { font-size: 12px; color: var(--text-faint); margin: 10px 0 0; }
.section-gap { margin-top: 12px; }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 12px; font-size: 13px; margin: 0; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.not-learned { color: var(--text-faint); font-style: italic; }

/* ------------------------------------------------------------------ tiles */
.tiles { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 4px; min-width: 0; text-decoration: none; color: var(--text); }
a.tile:hover { border-color: var(--border-strong); text-decoration: none; }
.tile-top { display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 12px; font-weight: 500; }
.tile-num { font-size: 24px; font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; }
.tile-sub { font-size: 12px; color: var(--text-faint); min-height: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-danger { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }
.tile-danger .tile-num, .tile-danger .tile-top { color: var(--danger); }
.tile-warn .tile-num { color: var(--warn); }
.tile .spark { margin-top: 6px; }
.kpis { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }

/* ------------------------------------------------------------------ lists (queue + tickets) */
.list { display: grid; }
.row { display: grid; grid-template-columns: 52px minmax(80px, 150px) auto minmax(0, 1fr) auto 58px 32px; align-items: center; gap: 10px; min-height: var(--row); padding: 0 8px 0 16px; border-top: 1px solid var(--border); cursor: pointer; color: var(--text); text-decoration: none; transition: background var(--ease); }
.row:first-child { border-top: 0; }
.row:hover { background: var(--surface-2); text-decoration: none; }
.row .user { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; font-size: 13px; }
.row .preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-muted); font-size: 13px; }
.row .chips { display: flex; gap: 4px; justify-content: flex-end; }
.row .when { font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); color: var(--text-muted); }
.row .id { font-size: 13px; color: var(--text-muted); }
.row-ext { color: var(--text-faint); }
.row-wrap { border-top: 1px solid var(--border); }
.row-wrap:first-child { border-top: 0; }
.row-wrap > .row { border-top: 0; }
.esc-detail { padding: 0 16px 12px 78px; font-size: 13px; display: grid; gap: 6px; }
.esc-detail .label { color: var(--text-faint); font-size: 12px; }
.queue-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: start; }
.queue-col { display: grid; gap: 12px; min-width: 0; }
.queue-cols .row { grid-template-columns: 48px minmax(60px, 120px) minmax(0, 1fr) auto 54px 28px; }
.queue-cols .row .type-chip { display: none; }
.flash-card { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }
.q-collapsed [data-list], .q-collapsed .q-note, .q-collapsed [data-foot] { display: none; }
.q-collapsed > .panel-head { margin-bottom: 12px; }
.q-note { margin: 0 16px 8px; }
.list-toggle { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 8px 12px 10px; border-top: 1px solid var(--border); font-size: 12px; }
.dot-lbl { font-size: 12px; font-weight: 500; color: var(--text-muted); margin-left: 6px; white-space: nowrap; }

/* ------------------------------------------------------------------ tickets split view */
.tk { display: grid; grid-template-columns: 380px minmax(0, 1fr); margin: -20px -24px -40px; min-height: calc(100vh - var(--top)); }
.tk.has-sel { grid-template-columns: 380px minmax(0, 1fr) 320px; }
.tk-list { position: sticky; top: var(--top); height: calc(100vh - var(--top)); overflow-y: auto; overscroll-behavior: contain; border-right: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; min-width: 0; }
.tk-list-head { position: sticky; top: 0; z-index: 2; background: var(--surface); padding: 12px 12px 8px; border-bottom: 1px solid var(--border); display: grid; gap: 8px; }
.tk-search { display: flex; gap: 6px; }
.views { display: flex; flex-wrap: wrap; gap: 4px; }
.side-title.section-gap { margin-top: 16px; }
.tbl td.r, .tbl th.r { white-space: nowrap; }
.tcard-l1 .mc .i { width: 12px; height: 12px; }
.views::-webkit-scrollbar { display: none; }
.views button { flex: none; height: 28px; padding: 0 10px; border: 1px solid var(--border); border-radius: 14px; background: none; font-size: 12px; font-weight: 500; color: var(--text-muted); cursor: pointer; }
.views button[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.filters-pop { display: grid; gap: 10px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.filters-pop .frow { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.tcard { display: grid; gap: 4px; padding: 10px 12px; border-bottom: 1px solid var(--border); cursor: pointer; color: var(--text); text-decoration: none; min-width: 0; }
.tcard:hover { background: var(--surface-2); text-decoration: none; }
.tcard[aria-current="true"] { background: var(--surface-2); box-shadow: inset 3px 0 0 var(--accent); }
.tcard.kbd-focus { box-shadow: inset 3px 0 0 var(--text-faint); }
.tcard-l1 { display: flex; align-items: center; gap: 8px; font-size: 13px; min-width: 0; }
.tcard-l1 .id { color: var(--text); font-weight: 500; }
.tcard-l1 .when { margin-left: auto; color: var(--text-muted); font-size: 12px; font-family: var(--mono); }
.tcard-l1 .mc { color: var(--text-faint); font-size: 12px; display: inline-flex; gap: 3px; align-items: center; }
.tcard-l2 { display: flex; align-items: center; gap: 6px; font-size: 13px; min-width: 0; }
.tcard-l2 .user { font-weight: 500; flex: none; max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tcard-l2 .preview { color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.list-foot { padding: 12px; text-align: center; color: var(--text-faint); font-size: 12px; }
.st { text-transform: capitalize; }

.tk-main { min-width: 0; padding: 0 24px 80px; position: relative; }
.tk-placeholder { display: grid; place-items: center; height: 60vh; color: var(--text-faint); text-align: center; gap: 8px; align-content: center; }
.tk-head { position: sticky; top: var(--top); z-index: 5; background: var(--bg); margin: 0 -24px; padding: 12px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; min-width: 0; }
.tk-head .count-txt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.tk-head .btn { flex: none; }
.tk-head .title { font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 8px; flex: none; }
.tk-head .spacer { flex: 1; }
.tk-head .back { display: none; }
.tk-tabs { display: none; }
.tk-side { position: sticky; top: var(--top); height: calc(100vh - var(--top)); overflow-y: auto; overscroll-behavior: contain; border-left: 1px solid var(--border); background: var(--surface); padding: 16px; display: grid; gap: 16px; align-content: start; min-width: 0; }
.tk-side .side-toggle { display: none; }
.tk:not(.has-sel) .tk-side { display: none; }
.side-sec { display: grid; gap: 8px; min-width: 0; }
.side-sec + .side-sec { border-top: 1px solid var(--border); padding-top: 16px; }
.side-title { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-muted); margin: 0; }
.esc-card { border: 1px solid color-mix(in srgb, var(--warn) 35%, var(--border)); background: var(--warn-weak); border-radius: var(--radius); padding: 10px 12px; display: grid; gap: 6px; font-size: 13px; }
.esc-card .esc-meta { color: var(--warn); font-size: 12px; font-weight: 500; }
.esc-card .esc-tried { color: var(--text-muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.mini-list { display: grid; gap: 2px; font-size: 13px; }
.mini-list a, .mini-list .mini { display: flex; align-items: center; gap: 8px; padding: 6px 8px; margin: 0 -8px; border-radius: var(--radius); color: var(--text); text-decoration: none; min-width: 0; }
.mini-list a:hover { background: var(--surface-2); text-decoration: none; }
.mini-list .r { margin-left: auto; color: var(--text-muted); font-size: 12px; }
.games { display: flex; flex-wrap: wrap; gap: 4px; }
.note-card { background: var(--surface-2); border-radius: var(--radius); padding: 8px 10px; font-size: 13px; overflow-wrap: anywhere; }
.ai-counts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.ai-counts div { background: var(--surface-2); border-radius: var(--radius); padding: 6px 8px; font-size: 12px; color: var(--text-muted); display: flex; justify-content: space-between; gap: 6px; }
.ai-counts b { color: var(--text); font-variant-numeric: tabular-nums; font-weight: 600; }
.ai-counts .bad b { color: var(--warn); }

/* transcript */
.transcript { display: grid; gap: 2px; padding-top: 12px; min-width: 0; }
.day { display: flex; align-items: center; gap: 12px; margin: 16px 0 8px; color: var(--text-faint); font-size: 12px; font-weight: 500; }
.day::before, .day::after { content: ""; height: 1px; flex: 1; background: var(--border); }
.msg { display: grid; gap: 2px; max-width: min(720px, 100%); min-width: 0; margin-top: 10px; }
.msg.cont { margin-top: 2px; }
.msg-head { display: flex; align-items: center; gap: 8px; font-size: 12px; position: relative; min-height: 22px; }
.msg-head .author { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-head .time { color: var(--text-faint); font-family: var(--mono); }
.msg-menu { display: flex; gap: 2px; opacity: 0; transition: opacity var(--ease); }
.msg:hover .msg-menu, .msg:focus-within .msg-menu { opacity: 1; }
.msg-menu .icon-btn { width: 26px; height: 26px; }
.bubble { padding: 8px 12px; border-radius: var(--radius); background: var(--surface-2); overflow-wrap: anywhere; word-break: break-word; min-width: 0; }
.msg-bot .bubble { background: var(--bot-weak); }
.msg-staff .bubble { background: var(--surface); border-left: 3px solid var(--staff); border-radius: 2px var(--radius) var(--radius) 2px; box-shadow: inset 0 0 0 1px var(--border); }
.msg-staff .author { color: var(--staff); }
.msg-bot .author { color: var(--accent); }
.tag { font-size: 10px; font-weight: 600; letter-spacing: .06em; padding: 2px 5px; border-radius: 3px; line-height: 1; }
.tag-bot { background: var(--bot-weak); color: var(--accent); }
.tag-staff { background: var(--staff-weak); color: var(--staff); }
.bubble a { overflow-wrap: anywhere; }
.bubble .md-pre { margin: 6px 0; padding: 8px 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 4px; overflow-x: auto; font: 12px/1.5 var(--mono); white-space: pre; max-width: 100%; }
.bubble .md-code { font: 12px var(--mono); background: var(--bg); padding: 1px 4px; border-radius: 3px; border: 1px solid var(--border); overflow-wrap: anywhere; }
.bubble .md-quote { margin: 4px 0; padding: 0 0 0 10px; border-left: 3px solid var(--border-strong); color: var(--text-muted); }
.bubble .md-ul { margin: 4px 0; padding-left: 20px; }
.bubble .md-h { font-weight: 600; margin: 6px 0 2px; }
.mention { background: var(--bot-weak); color: var(--accent); border-radius: 3px; padding: 0 3px; font-weight: 500; }
.emoji-name { color: var(--text-muted); }
.spoiler { background: var(--text-faint); color: transparent; border-radius: 3px; cursor: pointer; filter: blur(3px); transition: filter var(--ease), background var(--ease), color var(--ease); }
.spoiler.shown { background: var(--surface-3); color: inherit; filter: none; }
.atts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.att-img { display: block; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--bg); cursor: zoom-in; max-width: 240px; }
.att-img img { display: block; max-width: 240px; max-height: 240px; width: auto; height: auto; }
.att-video { max-width: min(360px, 100%); border-radius: var(--radius); border: 1px solid var(--border); background: #000; display: block; }
.att-file, .att-expired { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); font-size: 13px; color: var(--text); max-width: 100%; min-width: 0; text-decoration: none; }
.att-file span.n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-expired { color: var(--text-muted); border-style: dashed; cursor: pointer; }
.marker { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 12px 0; font-size: 12px; color: var(--text-muted); text-align: center; }
.marker::before, .marker::after { content: ""; height: 1px; flex: 1 1 24px; background: var(--border); min-width: 16px; }
.marker .mk { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 12px; background: var(--surface-2); max-width: 80%; }
.marker-warn .mk { background: var(--warn-weak); color: var(--warn); }
.marker-danger .mk { background: var(--danger-weak); color: var(--danger); }
.marker-staff .mk { background: var(--staff-weak); color: var(--staff); }
.marker .mk .faint { color: inherit; }
.marker-group { margin: 12px 0; }
.marker-group > .marker { margin: 0; }
.marker-sub { display: grid; justify-items: center; gap: 6px; margin-top: 4px; }
.marker-tried { width: 100%; max-width: 640px; color: var(--text-muted); font-size: 12px; text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 10px; }
/* "What the bot tried": clamped to 6 lines with a Show all toggle */
.tried { white-space: pre-wrap; overflow-wrap: anywhere; }
.tried.clamp { display: -webkit-box; -webkit-line-clamp: 6; line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
.tried-more { margin-top: 4px; padding-left: 0; }
.new-pill { position: fixed; left: 50%; transform: translateX(-50%); bottom: 24px; z-index: 40; display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 14px; border-radius: 16px; border: 0; background: var(--accent); color: var(--on-accent); font-weight: 500; font-size: 13px; cursor: pointer; box-shadow: var(--shadow); }
.tk-bottombar { display: none; }

/* ------------------------------------------------------------------ tables */
.tbl-wrap { overflow-x: auto; min-width: 0; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-size: 12px; font-weight: 500; color: var(--text-muted); padding: 8px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl td { padding: 0 12px; height: var(--row); border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .r, .tbl th.r { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tbody tr.click { cursor: pointer; }
.tbl tbody tr.click:hover { background: var(--surface-2); }
.tbl th button { border: 0; background: none; padding: 0; font: inherit; color: inherit; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.tbl th button[aria-sort] { color: var(--text); }
.tbl-compact td { height: 30px; padding: 0 8px; }
.tbl-compact th { padding: 6px 8px; }
.tbl .wrap { white-space: normal; overflow-wrap: anywhere; padding-top: 8px; padding-bottom: 8px; }
.cell-user { display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 500; }
.cell-user .u { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }

/* ------------------------------------------------------------------ charts */
.chart { margin: 0; display: grid; gap: 6px; min-width: 0; }
.chart-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chart-toggle { margin-left: auto; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--text-muted); }
.lg { display: inline-flex; align-items: center; gap: 6px; }
.chart-plot { position: relative; height: 140px; border-bottom: 1px solid var(--border); }
.chart-plot .bars { width: 100%; height: 100%; display: block; }
.chart-max { position: absolute; top: -2px; left: 0; font-size: 11px; color: var(--text-faint); font-variant-numeric: tabular-nums; pointer-events: none; }
.chart-x { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-faint); font-variant-numeric: tabular-nums; gap: 8px; }
.chart-x span { white-space: nowrap; }
.chart-data { max-height: 240px; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.hit { fill: transparent; }
.hit:hover { fill: color-mix(in srgb, var(--text) 8%, transparent); }
.s-cust { fill: var(--series-customer); } .s-bot { fill: var(--series-bot); } .s-staff { fill: var(--series-staff); }
.s-support { fill: var(--series-customer); } .s-purchase { fill: var(--info); } .s-flash { fill: var(--warn); }
.s-ok { fill: var(--ok); } .s-fallback { fill: var(--warn); } .s-silent { fill: var(--danger); } .s-pending { fill: var(--text-faint); }
.fill-accent { fill: var(--accent); } .fill-muted { fill: var(--series-customer); } .fill-warn { fill: var(--warn); } .fill-danger { fill: var(--danger); } .fill-staff { fill: var(--staff); }
.hbar { display: block; width: 100%; height: 8px; border-radius: 4px; overflow: hidden; }
.hbar-lg { height: 12px; border-radius: 4px; }
.hbar-bg { fill: var(--surface-3); }
.spark { display: block; width: 100%; height: 28px; overflow: visible; }
.spark-line { fill: none; stroke: var(--accent); stroke-width: 1.5; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-linecap: round; }
.spark-area { fill: var(--bot-weak); stroke: none; }
.spark-warn .spark-line { stroke: var(--warn); } .spark-warn .spark-area { fill: var(--warn-weak); }
.spark-staff .spark-line { stroke: var(--staff); } .spark-staff .spark-area { fill: var(--staff-weak); }
.spark-muted .spark-line { stroke: var(--series-customer); } .spark-muted .spark-area { fill: color-mix(in srgb, var(--series-customer) 12%, transparent); }
.spark-empty { font-size: 12px; color: var(--text-faint); height: 28px; display: flex; align-items: flex-end; margin-top: 6px; }
.meter { display: inline-flex; align-items: center; gap: 6px; }
.meter-n { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; font-family: var(--mono); }
.m-on { fill: var(--accent); } .m-off { fill: var(--surface-3); }
.cov { display: grid; grid-template-columns: 130px minmax(0, 1fr) 76px; align-items: center; gap: 6px 12px; font-size: 13px; }
.cov .v { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-muted); font-size: 12px; font-family: var(--mono); }
.bars-list { display: grid; grid-template-columns: max-content minmax(0, 1fr) 40px; gap: 8px 12px; align-items: center; font-size: 13px; }
.bars-list .v { text-align: right; font-variant-numeric: tabular-nums; }
.outcome-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--text-muted); margin-top: 8px; }
.outcome-legend b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.big-rates { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.big-rate { background: var(--surface-2); border-radius: var(--radius); padding: 10px 12px; }
.big-rate .tile-num { font-size: 20px; }
.big-rate .lbl { font-size: 12px; color: var(--text-muted); }

/* ------------------------------------------------------------------ system */
.svc { display: grid; gap: 6px; }
.svc-name { display: flex; align-items: center; gap: 8px; font-weight: 600; font-family: var(--mono); font-size: 13px; }
.feed { display: grid; }
.feed-row { display: grid; grid-template-columns: 56px minmax(0, 1fr) 48px 44px; gap: 10px; align-items: start; padding: 8px 0; border-top: 1px solid var(--border); font-size: 13px; }
.feed-row:first-child { border-top: 0; }
.feed-row .tpl { font-family: var(--mono); font-size: 12px; overflow-wrap: anywhere; }
.feed-row .tks { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.feed-row .r { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-muted); font-size: 12px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); font-size: 13px; }
.toggle-row:first-of-type { border-top: 0; }
.switch { position: relative; width: 36px; height: 20px; flex: none; appearance: none; -webkit-appearance: none; background: var(--surface-3); border-radius: 10px; cursor: pointer; transition: background var(--ease); margin: 0; border: 1px solid var(--border-strong); }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--text-muted); transition: transform var(--ease), background var(--ease); }
.switch:checked { background: var(--accent); border-color: var(--accent); }
.switch:checked::after { transform: translateX(16px); background: var(--on-accent); }

/* ------------------------------------------------------------------ states */
.empty { color: var(--text-faint); font-size: 13px; padding: 14px 16px; }
.panel .empty { padding: 8px 0; }
.panel-flush .empty { padding: 4px 16px 16px; }
.err-card { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border-radius: var(--radius); background: var(--danger-weak); color: var(--danger); font-size: 13px; margin: 8px 0; }
.err-card .btn { margin-left: auto; color: var(--text); }
.skel { display: block; border-radius: 4px; background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.skel-list { display: grid; gap: 0; }
.skel-row { display: grid; gap: 6px; padding: 10px 16px; border-top: 1px solid var(--border); }
.skel-row:first-child { border-top: 0; }
.skel-a { height: 12px; width: 40%; } .skel-b { height: 10px; width: 75%; }
.tile-skel { min-height: 82px; }
.skel-num { height: 22px; width: 48px; } .skel-lbl { height: 10px; width: 70%; }
.loading-wait .skel-list, .loading-wait .tiles { visibility: hidden; }

/* ------------------------------------------------------------------ overlays */
.sheet-wrap, .palette-wrap { position: fixed; inset: 0; z-index: 60; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(5, 7, 10, .55); }
.sheet { position: absolute; right: 0; top: 0; bottom: 0; width: min(420px, 100%); background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow); display: flex; flex-direction: column; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 8px 16px; border-bottom: 1px solid var(--border); min-height: 48px; }
.sheet-title { font-weight: 600; }
.sheet-body { overflow-y: auto; padding: 16px; display: grid; gap: 16px; align-content: start; flex: 1; }
.sheet-nav { display: grid; gap: 2px; }
.sheet-nav a, .sheet-nav button { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: var(--radius); border: 0; background: none; color: var(--text); font-weight: 500; text-decoration: none; text-align: left; cursor: pointer; width: 100%; }
.sheet-nav a:hover, .sheet-nav button:hover { background: var(--surface-2); text-decoration: none; }
.strip-sheet { display: grid; gap: 8px; }
.strip-sheet .pill { height: 44px; border-radius: var(--radius); justify-content: flex-start; font-size: 13px; }
.palette { position: absolute; left: 50%; top: 12vh; transform: translateX(-50%); width: min(640px, calc(100% - 32px)); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; max-height: 70vh; }
.palette-input { display: flex; align-items: center; gap: 10px; padding: 0 14px; border-bottom: 1px solid var(--border); color: var(--text-faint); }
.palette-input input { flex: 1; height: 48px; border: 0; background: none; outline: none; font-size: 15px; min-width: 0; }
.palette-input input::-webkit-search-cancel-button { display: none; }
.palette-results { overflow-y: auto; padding: 6px; }
.pal-group { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-faint); padding: 10px 10px 4px; }
.pal-item { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 6px 10px; border-radius: var(--radius); color: var(--text); text-decoration: none; font-size: 13px; cursor: pointer; min-width: 0; }
.pal-item:hover, .pal-item[aria-selected="true"] { background: var(--surface-2); text-decoration: none; }
.pal-item .main-t { flex: none; font-weight: 500; }
.pal-item .sub { color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.pal-item .sub mark { background: var(--warn-weak); color: var(--text); border-radius: 2px; }
.pal-hint { padding: 16px 12px; font-size: 13px; color: var(--text-faint); }
.lightbox { position: fixed; inset: 0; z-index: 80; background: rgba(5, 7, 10, .92); display: grid; place-items: center; padding: 48px 56px; }
.lightbox img { max-width: 100%; max-height: calc(100vh - 120px); object-fit: contain; border-radius: 4px; box-shadow: var(--shadow); }
.lightbox .icon-btn { position: absolute; color: #e7e9ee; width: 44px; height: 44px; background: rgba(255, 255, 255, .08); }
.lb-close { top: 12px; right: 12px; } .lb-prev { left: 8px; top: 50%; transform: translateY(-50%); } .lb-next { right: 8px; top: 50%; transform: translateY(-50%); }
.lb-cap { position: absolute; bottom: 14px; left: 0; right: 0; text-align: center; color: #b7bdc9; font-size: 12px; padding: 0 16px; overflow-wrap: anywhere; }
.tip { position: fixed; z-index: 90; pointer-events: none; background: var(--text); color: var(--bg); font-size: 12px; padding: 5px 8px; border-radius: 4px; max-width: 280px; box-shadow: var(--shadow); font-variant-numeric: tabular-nums; }
.toast { position: fixed; z-index: 90; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); font-size: 13px; padding: 8px 14px; border-radius: var(--radius); box-shadow: var(--shadow); }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1440px) { .search-trigger { width: 240px; } }
@media (max-width: 1279px) {
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .queue-cols { grid-template-columns: minmax(0, 1fr); }
  .tk.has-sel { grid-template-columns: 340px minmax(0, 1fr); }
  .tk { grid-template-columns: 340px minmax(0, 1fr); }
  .tk-tabs { display: inline-flex; }
  .tk-list { grid-row: 1 / span 2; }
  .tk.has-sel .tk-main { grid-column: 2; grid-row: 1; }
  .tk.has-sel .tk-side { grid-column: 2; grid-row: 2; position: static; height: auto; border-left: 0; padding: 16px 24px 80px; background: none; display: none; }
  .tk[data-tab="details"] .tk-side { display: grid; }
  .tk[data-tab="details"] .tk-main > :not(.tk-head) { display: none; }
  .tk[data-tab="details"] .tk-main { padding-bottom: 0; }
  .search-ph { display: none; }
  .search-trigger { width: auto; }
  .search-trigger kbd { display: none; }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1023px) {
  .tk, .tk.has-sel { grid-template-columns: minmax(0, 1fr); margin: -20px -24px -40px; }
  .tk-list { position: static; height: auto; border-right: 0; overflow: visible; background: none; grid-row: auto; }
  .tk.has-sel .tk-main { grid-column: 1; }
  .tk-list-head { top: var(--top); background: var(--bg); }
  .tk.has-sel .tk-list { display: none; }
  .tk:not(.has-sel) .tk-main { display: none; }
  .tk-head .back { display: inline-flex; }
  .tk-tabs { display: none; }
  /* head, then collapsible details, then transcript */
  .tk.has-sel .tk-main { display: contents; }
  .tk { align-content: start; }
  .tk.has-sel .tk-main > .tk-state { order: 2; align-self: start; margin: 12px 16px; }
  .tk.has-sel .tk-head { order: 1; margin: 0; }
  .tk.has-sel .tk-side, .tk[data-tab="details"] .tk-side { order: 2; grid-column: 1; grid-row: auto; display: grid; position: static; height: auto; border: 0; border-bottom: 1px solid var(--border); padding: 0 24px; background: var(--surface); gap: 0; }
  .tk.has-sel .transcript { order: 3; padding: 4px 24px 80px; }
  .tk[data-tab="details"] .tk-main > .transcript { display: grid; }
  .tk-side .side-toggle { display: flex; align-items: center; gap: 8px; height: 44px; border: 0; background: none; width: 100%; padding: 0; font-weight: 600; font-size: 13px; color: var(--text-muted); cursor: pointer; }
  .tk-side .side-toggle .i { transition: transform var(--ease); }
  .tk-side.side-open .side-toggle .i { transform: rotate(180deg); }
  .tk-side:not(.side-open) .side-sec { display: none; }
  .tk-side.side-open { padding-bottom: 16px; gap: 16px; }
  .tk-side .side-sec + .side-sec { padding-top: 12px; }
  .tcard { padding: 12px 24px; background: var(--surface); }
  .tk-list-head { padding: 12px 24px 8px; }
  .views { margin: 0; padding: 0; }
  .row { grid-template-columns: 48px minmax(60px, 120px) minmax(0, 1fr) auto 54px 28px; }
  .row .type-chip { display: none; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .esc-detail { padding-left: 16px; }
}
@media (max-width: 767px) {
  :root { --top: 52px; }
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-areas: "top" "main"; }
  .sidebar { display: none; }
  .topbar { padding: 0 8px 0 16px; gap: 4px; }
  .top-title { display: block; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; font-size: 16px; }
  .search-trigger, .strip { display: none; }
  .status-dot-btn { display: inline-flex; }
  .icon-btn { width: 44px; height: 44px; }
  .hide-phone { display: none !important; }
  .top-actions [data-action="theme"] { display: none; }
  .main { padding: 16px 16px calc(var(--tabbar) + env(safe-area-inset-bottom) + 24px); }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; height: calc(var(--tabbar) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--surface); border-top: 1px solid var(--border); }
  .tabbar a, .tabbar button { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 0; background: none; color: var(--text-muted); font-size: 11px; font-weight: 500; text-decoration: none; cursor: pointer; min-height: 44px; }
  .tabbar [aria-current="page"] { color: var(--accent); }
  .tabbar .badge { position: absolute; top: 4px; left: calc(50% + 6px); min-width: 16px; height: 16px; line-height: 16px; font-size: 10px; padding: 0 4px; }
  .page-title { font-size: 20px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .tile { padding: 12px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panel { padding: 14px; }
  .panel-flush { padding: 0; }
  .panel-flush > .panel-head { padding: 12px 14px 0; }
  /* lists become two-line cards */
  .row, .queue-cols .row { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "id user when" "pv pv pv" "chips chips chips"; gap: 2px 8px; padding: 10px 14px; min-height: 56px; }
  .row .id { grid-area: id; } .row .user { grid-area: user; } .row .when { grid-area: when; }
  .row .preview { grid-area: pv; } .row .chips { grid-area: chips; justify-content: flex-start; } .row .chips:empty { display: none; }
  .row .type-chip, .row .row-ext { display: none; }
  .esc-detail { padding: 0 14px 12px; }
  .tk, .tk.has-sel { margin: -16px -16px calc(-1 * (var(--tabbar) + 24px)); }
  .tk-list-head { padding: 12px 16px 8px; }
  .views { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
  .views::-webkit-scrollbar { display: none; }
  .tcard { padding: 12px 16px; min-height: 64px; }
  .tk-main { padding: 0 16px 24px; }
  .tk-head, .tk.has-sel .tk-head { margin: 0; padding: 8px 16px; gap: 4px; }
  .tk.has-sel .transcript { padding: 4px 16px 24px; }
  .tk-head .hide-sm { display: none; }
  .tk-head .title { font-size: 15px; }
  .tk.has-sel .tk-side { display: none !important; }
  body.ticket-open .tabbar { display: none; }
  body.ticket-open .main { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .tk-bottombar { display: flex; gap: 8px; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--border); }
  .tk-bottombar .btn { flex: 1; height: 44px; font-size: 14px; }
  .new-pill { bottom: calc(76px + env(safe-area-inset-bottom)); }
  .msg { max-width: 100%; }
  .msg-menu { opacity: 1; }
  .att-img, .att-img img { max-width: min(240px, 100%); }
  .cov { grid-template-columns: 96px minmax(0, 1fr) 64px; }
  .big-rates { grid-template-columns: minmax(0, 1fr); }
  .feed-row { grid-template-columns: 52px minmax(0, 1fr) 40px; }
  .feed-row .last { display: none; }
  .hide-sm { display: none; }
  .tbl th, .tbl td { padding-left: 8px; padding-right: 8px; }
  .chart-plot { height: 120px; }
  .sheet { top: auto; left: 0; width: 100%; max-height: 85vh; border-left: 0; border-top: 1px solid var(--border); border-radius: 12px 12px 0 0; padding-bottom: env(safe-area-inset-bottom); }
  .palette { top: 8px; width: calc(100% - 16px); max-height: calc(100vh - 16px); }
  .lightbox { padding: 56px 8px; }
  .seg button { height: 32px; }
  .views button { height: 32px; }
  .btn { height: 36px; }
  .btn-sm { height: 32px; }
  .toast { bottom: calc(var(--tabbar) + 16px); }
  /* the top bar already names the page */
  .page-title.dup { display: none; }
  .page-head:has(> .page-title.dup):not(:has(> :not(.page-title):not(:empty))) { display: none; }
  /* KPI explanations wrap instead of being cut mid-phrase */
  .tile-sub { white-space: normal; overflow: visible; text-overflow: clip; }
  /* touch targets: at least 32px tall */
  .link-btn, .chart-toggle { min-height: 32px; padding: 4px 8px; }
  .mini-list a, .mini-list .mini { min-height: 40px; }
  .tbl a.mono, .feed-row .tks .chip, a.chip { display: inline-flex; align-items: center; min-height: 32px; padding: 0 8px; }
  .cell-user .u { display: inline-flex; align-items: center; min-height: 32px; }
  .tbl th button { min-height: 32px; }
  .switch { width: 44px; height: 26px; border-radius: 13px; }
  .switch::after { width: 20px; height: 20px; }
  .switch:checked::after { transform: translateX(18px); }
}
