:root {
  --sidebar-bg: #0b1220;
  --sidebar-fg: #c3ccd8;
  --sidebar-muted: #6f7d90;
  --sidebar-hover: rgba(255, 255, 255, 0.045);
  --sidebar-active: #15213a;

  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #0e1623;
  --text-2: #435064;
  --muted: #8692a4;
  --line: #e2e7ee;
  --line-2: #edf0f4;

  --accent: #0e9c88;
  --accent-strong: #0a7f6f;
  --accent-soft: #e3f5f1;
  --accent-ring: rgba(14, 156, 136, 0.22);

  --ok: #11904a;
  --ok-soft: #e6f6ec;
  --warn: #b36b06;
  --warn-soft: #fcf1de;
  --bad: #cc3a3a;
  --bad-soft: #fceaea;
  --info: #2a66cf;
  --info-soft: #e8effc;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(15, 23, 36, 0.04), 0 2px 6px rgba(15, 23, 36, 0.04);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI Variable Text", "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d131d;
    --surface: #131b27;
    --surface-2: #17202e;
    --text: #e6ebf2;
    --text-2: #a9b4c3;
    --muted: #7b8798;
    --line: #232e3e;
    --line-2: #1c2634;
    --accent-soft: rgba(14, 156, 136, 0.16);
    --ok-soft: rgba(17, 144, 74, 0.16);
    --warn-soft: rgba(179, 107, 6, 0.18);
    --bad-soft: rgba(204, 58, 58, 0.16);
    --info-soft: rgba(42, 102, 207, 0.18);
    --shadow: none;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 14px/1.5 var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-strong); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
svg.i { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ── Layout ─────────────────────────────────────────────── */

.app { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 4px;
  padding: 18px 12px 14px;
  background: var(--sidebar-bg); color: var(--sidebar-fg);
}
.brand { display: flex; align-items: center; gap: 11px; padding: 2px 10px 20px; color: #fff; }
.brand-mark { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; width: 24px; height: 24px; }
.brand-mark i { display: block; border-radius: 3px; background: var(--accent); }
.brand-mark i:nth-child(2) { opacity: 0.55; }
.brand-mark i:nth-child(3) { opacity: 0.3; }
.brand-mark i:nth-child(4) { opacity: 0.8; }
.brand-name { font-weight: 650; letter-spacing: -0.01em; line-height: 1.15; }
.brand-name span { display: block; font-size: 11.5px; font-weight: 500; color: var(--sidebar-muted); letter-spacing: 0; }
.nav-label { padding: 14px 10px 6px; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--sidebar-muted); }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 8px;
  color: var(--sidebar-fg); font-weight: 500; text-decoration: none;
}
.nav a:hover { background: var(--sidebar-hover); color: #fff; }
.nav a.active { background: var(--sidebar-active); color: #fff; box-shadow: inset 2px 0 0 var(--accent); }
.nav a .count { margin-left: auto; min-width: 22px; padding: 0 7px; border-radius: 999px; background: rgba(255, 255, 255, 0.08); font-size: 11.5px; text-align: center; }
.nav a .count.hot { background: var(--accent); color: #fff; }
.sidebar-foot { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid rgba(255, 255, 255, 0.06); font-size: 12.5px; color: var(--sidebar-muted); }
.sidebar-foot .mode { display: flex; align-items: center; gap: 8px; color: var(--sidebar-fg); margin-bottom: 8px; }
.sidebar-foot a { color: var(--sidebar-muted); display: inline-flex; align-items: center; gap: 6px; }
.sidebar-foot a:hover { color: #fff; text-decoration: none; }

.main { min-width: 0; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; padding: 28px 36px 20px; flex-wrap: wrap; }
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.crumbs a { color: var(--muted); }
.page-title { margin: 0; font-size: 22px; font-weight: 650; letter-spacing: -0.015em; line-height: 1.25; }
.page-sub { margin-top: 3px; color: var(--text-2); }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.content { padding: 0 36px 56px; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px; }
  .brand { padding: 4px 8px; }
  .nav-label, .sidebar-foot { display: none; }
  .nav { display: flex; flex-wrap: wrap; gap: 2px; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
}

/* ── Surfaces ───────────────────────────────────────────── */

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line-2); }
.card-title { margin: 0; font-size: 14px; font-weight: 600; }
.card-body { padding: 16px 18px; }
.card-body.flush { padding: 0; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.side { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
@media (max-width: 1100px) { .grid.cols-2, .grid.side { grid-template-columns: 1fr; } }
.stack > * + * { margin-top: 16px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); color: inherit; }
a.kpi:hover { border-color: var(--accent); text-decoration: none; }
.kpi-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.kpi-value { margin-top: 4px; font-size: 24px; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi-note { margin-top: 2px; font-size: 12px; color: var(--text-2); }

/* ── Tables ─────────────────────────────────────────────── */

.table { width: 100%; border-collapse: collapse; }
.table th { padding: 9px 14px; text-align: left; font-size: 11.5px; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--line); }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .r { text-align: right; }
.table .w1 { width: 1%; white-space: nowrap; }
.row-link { color: var(--text); font-weight: 500; }
.row-link:hover { color: var(--accent-strong); }
.sub { margin-top: 2px; font-size: 12.5px; color: var(--muted); }
.scroll-x { overflow-x: auto; }

/* ── Chips and status ───────────────────────────────────── */

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; line-height: 18px; white-space: nowrap; background: var(--line-2); color: var(--text-2); }
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.85; }
.chip.plain::before { display: none; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.info { background: var(--info-soft); color: var(--info); }
.chip.accent { background: var(--accent-soft); color: var(--accent-strong); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.ok { background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18); }
.dot.warn { background: #f59e0b; box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.18); }
.dot.off { background: #64748b; }
.tag { display: inline-block; padding: 0 6px; border: 1px solid var(--line); border-radius: 5px; font-size: 11.5px; color: var(--text-2); }

/* ── Forms and buttons ──────────────────────────────────── */

label.f { display: block; margin: 14px 0 6px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
label.f:first-child { margin-top: 0; }
.hint { margin-top: 5px; font-size: 12px; color: var(--muted); }
input[type=text], input[type=number], input[type=search], select, textarea {
  width: 100%; padding: 8px 11px;
  font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  transition: border-color 0.12s, box-shadow 0.12s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
textarea { min-height: 96px; resize: vertical; line-height: 1.55; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-top: 14px; }
.check { display: flex; align-items: flex-start; gap: 9px; margin-top: 12px; cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 14px;
  font: inherit; font-weight: 550; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.btn:hover { border-color: #c9d1dc; background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--line-2); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-soft); border-color: transparent; }
.btn.ghost.danger { color: var(--muted); }
.btn.ghost.danger:hover { color: var(--bad); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn.icon { width: 30px; height: 30px; padding: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 16px; }
.actions .spacer { flex: 1; }
form.inline { display: inline; margin: 0; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.toolbar .search { position: relative; flex: 1 1 280px; }
.toolbar .search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.toolbar .search input { padding-left: 32px; }
.toolbar select { width: auto; min-width: 150px; }

.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--line-2); border-radius: 9px; }
.segmented a { padding: 5px 12px; border-radius: 7px; color: var(--text-2); font-weight: 550; font-size: 13px; text-decoration: none; }
.segmented a:hover { color: var(--text); }
.segmented a.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.segmented .n { margin-left: 4px; color: var(--muted); font-weight: 500; }

.flash { display: flex; align-items: center; gap: 10px; margin: 0 0 16px; padding: 10px 14px; border-radius: var(--radius); background: var(--accent-soft); color: var(--accent-strong); font-weight: 550; }
.flash.warn { background: var(--warn-soft); color: var(--warn); }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--line-2); font-size: 12.5px; color: var(--muted); }
.pager .btns { display: flex; gap: 6px; }

.empty { padding: 44px 20px; text-align: center; color: var(--muted); }
.empty svg.i { width: 28px; height: 28px; margin-bottom: 8px; color: var(--line); stroke-width: 1.6; }
.empty b { display: block; color: var(--text-2); margin-bottom: 2px; }

/* ── Content blocks ─────────────────────────────────────── */

.prose { white-space: pre-wrap; word-break: break-word; }
.quote { padding: 11px 14px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line-2); white-space: pre-wrap; word-break: break-word; }
.quote.accent { background: var(--accent-soft); border-color: transparent; }
.quote.bad { background: var(--bad-soft); border-color: transparent; }
.kv { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 8px 14px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; color: var(--text-2); font-size: 12.5px; }
.meta .sep { width: 3px; height: 3px; border-radius: 50%; background: var(--muted); }
.links { display: flex; flex-wrap: wrap; gap: 6px; }
.links a { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border: 1px solid var(--line); border-radius: 999px; font-size: 12.5px; color: var(--text-2); }
.links a:hover { border-color: var(--accent); color: var(--accent-strong); text-decoration: none; }
.diff { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 900px) { .diff { grid-template-columns: 1fr; } }
.diff h4 { margin: 0 0 6px; font-size: 11.5px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }

.timeline { position: relative; margin: 0; padding: 0; list-style: none; }
.timeline > li { position: relative; padding: 0 0 20px 34px; }
.timeline > li::before { content: ""; position: absolute; left: 11px; top: 26px; bottom: 0; width: 1px; background: var(--line); }
.timeline > li:last-child { padding-bottom: 0; }
.timeline > li:last-child::before { display: none; }
.timeline .node { position: absolute; left: 0; top: 0; display: grid; place-items: center; width: 23px; height: 23px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--line); color: var(--text-2); }
.timeline .node svg.i { width: 13px; height: 13px; }
.timeline .node.accent { background: var(--accent-soft); border-color: transparent; color: var(--accent-strong); }
.timeline .node.bad { background: var(--bad-soft); border-color: transparent; color: var(--bad); }
.timeline .node.ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.timeline h4 { margin: 2px 0 8px; font-size: 13px; font-weight: 600; }
.timeline h4 .muted { font-weight: 400; }

.chart { width: 100%; height: auto; display: block; }
.chart .bar-suggest { fill: var(--accent); }
.chart .bar-auto { fill: #34c3a6; }
.chart .bar-escalate { fill: #f0a948; }
.chart .bar-handoff { fill: #a7b3c4; }
.chart .axis { fill: var(--muted); font-size: 10px; font-family: var(--font); }
.chart .grid-line { stroke: var(--line-2); stroke-width: 1; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--text-2); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

.queue-type { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 8px; background: var(--line-2); color: var(--text-2); }
.queue-type.P { background: var(--accent-soft); color: var(--accent-strong); }
.queue-type.U { background: var(--info-soft); color: var(--info); }
.queue-type.C { background: var(--warn-soft); color: var(--warn); }
.queue-type.G { background: var(--line-2); color: var(--text-2); }
.count-pill { display: inline-block; min-width: 26px; padding: 1px 8px; border-radius: 999px; background: var(--line-2); text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; font-size: 12.5px; }
.count-pill.hot { background: var(--warn-soft); color: var(--warn); }

.mode-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; }
.mode-card { position: relative; display: block; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; }
.mode-card input { position: absolute; opacity: 0; }
.mode-card b { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.mode-card span { font-size: 12.5px; color: var(--text-2); }
.mode-card:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }

/* ── Tickets ────────────────────────────────────────────── */

.avatar {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  font-size: 12.5px; font-weight: 650; letter-spacing: 0.02em;
  background: hsl(var(--h, 170) 40% 92%); color: hsl(var(--h, 170) 45% 32%);
}
@media (prefers-color-scheme: dark) { .avatar { background: hsl(var(--h, 170) 30% 22%); color: hsl(var(--h, 170) 55% 78%); } }
.ticket-row { cursor: pointer; }
.ticket-row .name { font-weight: 600; color: var(--text); }
.wait-hot { color: var(--bad); font-weight: 600; }
.wait { color: var(--warn); font-weight: 550; }
.wait svg.i, .wait-hot svg.i, .sub svg.i { width: 13px; height: 13px; vertical-align: -2px; }

.desk { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
@media (max-width: 1100px) { .desk { grid-template-columns: 1fr; } }
.chat { display: flex; flex-direction: column; overflow: hidden; }
.messages {
  height: calc(100vh - 360px); min-height: 380px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px;
  padding: 18px 20px; background: var(--surface-2);
}
.msg { display: flex; flex-direction: column; gap: 3px; max-width: 74%; }
.msg.in { align-self: flex-start; }
.msg.out, .msg.bot { align-self: flex-end; align-items: flex-end; }
.msg.note { align-self: stretch; max-width: none; }
.bubble {
  padding: 8px 12px; border-radius: 14px; background: var(--surface);
  border: 1px solid var(--line); box-shadow: var(--shadow); word-break: break-word;
}
.msg.in .bubble { border-top-left-radius: 5px; }
.msg.out .bubble { background: var(--accent-soft); border-color: transparent; border-top-right-radius: 5px; }
.msg.bot .bubble { background: var(--info-soft); border-color: transparent; border-top-right-radius: 5px; }
.msg.note .bubble { background: var(--warn-soft); border: 1px dashed rgba(179, 107, 6, 0.35); box-shadow: none; }
.msg.deleted .bubble { opacity: 0.55; text-decoration: line-through; }
.msg .prose { white-space: pre-wrap; }
.msg-meta { padding: 0 4px; font-size: 11.5px; color: var(--muted); }
.msg.event { align-self: center; max-width: 90%; text-align: center; font-size: 12px; color: var(--muted); }
.bubble img { display: block; max-width: 300px; max-height: 300px; border-radius: 9px; }
.bubble img.sticker { max-width: 140px; max-height: 140px; }
.bubble video { display: block; max-width: 320px; max-height: 300px; border-radius: 9px; }
.bubble audio { display: block; width: 260px; }
.bubble img + .prose, .bubble video + .prose, .bubble audio + .prose, .bubble .attachment + .prose { margin-top: 6px; }
.attachment { display: inline-flex; align-items: center; gap: 7px; font-weight: 550; }
.day-divider { display: flex; align-items: center; gap: 10px; margin: 6px 0; font-size: 11.5px; font-weight: 600; color: var(--muted); }
.day-divider::before, .day-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.suggestion { margin: 0; padding: 12px 18px; border-top: 1px solid var(--line-2); background: var(--accent-soft); }
.suggestion-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; color: var(--accent-strong); }
.suggestion .prose { white-space: pre-wrap; color: var(--text); }
.suggestion .actions { margin-top: 10px; }
.warn-text { color: var(--warn); }

.composer { padding: 12px 14px; border-top: 1px solid var(--line); background: var(--surface); }
.composer textarea { min-height: 76px; border-color: transparent; background: var(--surface-2); }
.composer textarea:focus { background: var(--surface); }
.composer-bar { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.composer-bar .spacer { flex: 1; }
.composer-bar select { width: auto; max-width: 220px; height: 30px; padding: 0 8px; font-size: 13px; }
.file-label { cursor: pointer; }
.file-label.has-file { color: var(--accent-strong); }

.sound-toggle { display: flex; align-items: center; gap: 6px; padding: 0; margin: 0 0 8px; border: 0; background: none; color: var(--sidebar-muted); font: inherit; font-size: 12.5px; text-align: left; cursor: pointer; }
.sound-toggle:hover { color: #fff; }
.sound-toggle.off { opacity: 0.6; }

/* ── Ticket list extras ─────────────────────────────────── */

.kpis.compact { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.kpis.compact .kpi { padding: 12px 14px; }
.kpis.compact .kpi-value { font-size: 21px; }
.kpi.hot { border-color: rgba(204, 58, 58, 0.35); }
.kpi.hot .kpi-value { color: var(--bad); }
.board-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.board-bar .segmented a { white-space: nowrap; }
@media (max-width: 640px) {
  .kpis.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpis.compact .kpi { padding: 10px 12px; }
  .kpis.compact .kpi-value { font-size: 18px; }
  .kpis.compact .kpi-note { display: none; }
  .board-bar .segmented { max-width: 100%; overflow-x: auto; }
  .hint-keys { display: none; }
  .ticket-row > td:nth-child(3) { display: none; }
}
.segmented a svg.i { width: 14px; height: 14px; margin-right: 5px; vertical-align: -2px; }
.ticket-row.selected td { background: var(--accent-soft); }
.ticket-row.selected td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.presence-chip { background: var(--info-soft); color: var(--info); }
.presence-chip.typing { background: var(--warn-soft); color: var(--warn); }
.presence-chip svg.i { width: 13px; height: 13px; margin-right: 1px; }
.hint-keys { margin-top: 10px; font-size: 12px; color: var(--muted); }
kbd { display: inline-block; min-width: 18px; padding: 0 5px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; background: var(--surface); font: 11px/16px var(--mono); color: var(--text-2); text-align: center; }

/* ── Conversation extras ────────────────────────────────── */

.wait-chip { background: var(--warn-soft); color: var(--warn); }
.wait-chip.hot { background: var(--bad-soft); color: var(--bad); }
.wait-chip svg.i { width: 13px; height: 13px; margin-right: 1px; }
.btn .count-pill { min-width: 20px; padding: 0 6px; font-size: 11.5px; }
.chat { position: relative; }
.thread { position: relative; }
.jump { position: absolute; right: 18px; bottom: 14px; display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--text-2); font: inherit; font-size: 12.5px; font-weight: 550; box-shadow: 0 4px 14px rgba(15, 23, 36, 0.12); cursor: pointer; }
.jump.has-new { background: var(--accent); border-color: var(--accent); color: #fff; }
.jump svg.i { width: 14px; height: 14px; }
.msg-tools { display: inline-flex; gap: 2px; margin-left: 4px; vertical-align: middle; opacity: 0; transition: opacity 0.12s; }
.msg:hover .msg-tools, .msg:focus-within .msg-tools { opacity: 1; }
@media (hover: none) { .msg-tools { opacity: 1; } }
.msg-tools button { display: inline-grid; place-items: center; width: 22px; height: 20px; padding: 0; border: 0; border-radius: 5px; background: none; color: var(--muted); cursor: pointer; }
.msg-tools button:hover { background: var(--line-2); color: var(--text); }
.msg-tools svg.i { width: 13px; height: 13px; }
.quote-ref { display: block; max-width: 420px; margin: 0 0 6px; padding: 3px 8px; border-left: 3px solid var(--accent); border-radius: 4px; background: rgba(15, 23, 36, 0.04); color: var(--text-2); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quote-ref b { margin-right: 6px; color: var(--accent-strong); font-weight: 600; }
.quote-ref:hover { text-decoration: none; background: rgba(15, 23, 36, 0.07); }
.msg.flash-msg .bubble { box-shadow: 0 0 0 3px var(--accent-ring); }
.bubble a[data-lightbox] img { cursor: zoom-in; }
.presence-bar { display: flex; align-items: center; gap: 8px; padding: 8px 18px; border-top: 1px solid var(--line-2); background: var(--info-soft); color: var(--info); font-size: 12.5px; font-weight: 550; }
.presence-bar.typing { background: var(--warn-soft); color: var(--warn); }
.presence-bar svg.i { width: 15px; height: 15px; }
.composer-ref { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; padding: 6px 6px 6px 10px; border-left: 3px solid var(--accent); border-radius: 6px; background: var(--surface-2); color: var(--text-2); font-size: 12.5px; }
.composer-ref > svg.i { width: 14px; height: 14px; color: var(--accent-strong); }
.composer-ref .ref-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.composer-ref .thumb { display: grid; place-items: center; flex: none; width: 40px; height: 40px; overflow: hidden; border-radius: 6px; background: var(--line-2); color: var(--text-2); }
.composer-ref .thumb img { width: 100%; height: 100%; object-fit: cover; }
.composer-field { position: relative; }
.qr-pop { position: absolute; left: 0; right: 0; bottom: calc(100% + 6px); z-index: 20; display: flex; flex-direction: column; max-height: 320px; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(15, 23, 36, 0.14); }
.qr-pop input[type=search] { border: 0; border-bottom: 1px solid var(--line-2); border-radius: 0; box-shadow: none; }
.qr-pop ul { margin: 0; padding: 4px; list-style: none; overflow-y: auto; }
.qr-pop li { display: flex; flex-direction: column; gap: 1px; padding: 7px 10px; border-radius: 7px; cursor: pointer; }
.qr-pop li b { font-size: 12.5px; color: var(--accent-strong); }
.qr-pop li span { overflow: hidden; color: var(--text-2); font-size: 12.5px; text-overflow: ellipsis; white-space: nowrap; }
.qr-pop li.on, .qr-pop li:hover { background: var(--accent-soft); }
.qr-pop li.none { color: var(--muted); background: none; cursor: default; }
.split { position: relative; display: inline-flex; }
.split > .btn.primary:first-child { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.split > .caret { width: 32px; padding: 0; border-top-left-radius: 0; border-bottom-left-radius: 0; border-left-color: rgba(255, 255, 255, 0.35); }
.split .btn:disabled { opacity: 0.6; cursor: progress; }
.menu { position: absolute; right: 0; bottom: calc(100% + 6px); z-index: 30; min-width: 360px; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(15, 23, 36, 0.16); }
.menu button { display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 10px; border: 0; border-radius: 7px; background: none; color: var(--text); font: inherit; font-size: 13px; text-align: left; white-space: nowrap; cursor: pointer; }
.menu button:hover { background: var(--surface-2); }
.menu kbd { margin-left: auto; }
@media (max-width: 640px) {
  .menu { min-width: 0; width: min(360px, calc(100vw - 48px)); }
  .menu kbd { display: none; }
}
.composer.busy textarea { opacity: 0.7; }
.drop-zone { display: none; position: absolute; inset: 0; z-index: 40; place-items: center; align-content: center; gap: 8px; border: 2px dashed var(--accent); border-radius: var(--radius); background: rgba(227, 245, 241, 0.92); color: var(--accent-strong); font-weight: 600; }
.chat.dragging .drop-zone { display: grid; }
.drop-zone svg.i { width: 26px; height: 26px; }
#account.loading { opacity: 0.6; transition: opacity 0.15s; }
@media (prefers-color-scheme: dark) {
  .drop-zone { background: rgba(19, 27, 39, 0.92); }
  .quote-ref { background: rgba(255, 255, 255, 0.05); }
}

.lightbox { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 24px; background: rgba(8, 12, 20, 0.86); cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: calc(100vh - 48px); border-radius: 8px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45); }
.lightbox-close { position: absolute; top: 16px; right: 18px; color: #fff; opacity: 0.8; }
.lightbox-close svg.i { width: 22px; height: 22px; }
.toast { position: fixed; left: 50%; bottom: 26px; z-index: 200; padding: 8px 16px; border-radius: 999px; background: #0e1623; color: #fff; font-size: 13px; font-weight: 550; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2); opacity: 0; transform: translate(-50%, 12px); transition: opacity 0.16s, transform 0.16s; pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ── Client card ────────────────────────────────────────── */

.kv.tight { grid-template-columns: 96px minmax(0, 1fr); gap: 6px 12px; }
.kv.tight dd { overflow-wrap: anywhere; }
.alert { display: flex; align-items: flex-start; gap: 8px; padding: 8px 10px; border-radius: var(--radius-sm); font-size: 12.5px; background: var(--line-2); color: var(--text-2); }
.alert svg.i { flex: none; width: 15px; height: 15px; margin-top: 1px; }
.alert.bad { background: var(--bad-soft); color: var(--bad); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alerts { display: grid; gap: 6px; margin-bottom: 12px; }
.card-head .head-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn { display: inline-grid; place-items: center; width: 26px; height: 26px; padding: 0; border: 0; border-radius: 7px; background: none; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--line-2); color: var(--text); text-decoration: none; }
.icon-btn svg.i { width: 14px; height: 14px; }
.sub-item { padding: 14px 18px; border-bottom: 1px solid var(--line-2); }
.sub-item:last-child { border-bottom: 0; }
.sub-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sub-top b { min-width: 0; }
.sub-dates { margin: 2px 0 10px; }
.meter { height: 6px; margin: 4px 0 3px; border-radius: 999px; background: var(--line-2); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.meter.warn i { background: var(--warn); }
.meter.bad i { background: var(--bad); }
.sub-item .kv { margin-top: 10px; }
.sub-item .links { margin-top: 10px; }
.devices { margin-top: 10px; font-size: 13px; }
.devices summary, .pay-more summary { cursor: pointer; color: var(--text-2); font-weight: 550; font-size: 12.5px; }
.devices summary:hover, .pay-more summary:hover { color: var(--accent-strong); }
.devices ul { margin: 8px 0 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.devices li { padding: 8px 10px; border-radius: var(--radius-sm); background: var(--surface-2); }
.pay-list { margin: 0; padding: 0; list-style: none; }
.pay-list li { padding: 10px 18px; border-bottom: 1px solid var(--line-2); }
.pay-list li:last-child { border-bottom: 0; }
.pay-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.pay-more { border-top: 1px solid var(--line-2); }
.pay-more summary { padding: 10px 18px; }
.inline-search { display: flex; gap: 6px; margin-top: 10px; }
.inline-search input { height: 30px; font-size: 13px; }
.account-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.account-grid > .card { margin: 0; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--sidebar-bg); }
.login .card { width: 100%; max-width: 400px; padding: 28px; }
.login .brand { color: var(--text); padding: 0 0 18px; }
.login .brand-name span { color: var(--muted); }
