/* Plain, dense admin styling: neutral greys, one accent, 1px borders, no shadows or gradients. */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f2f5;
  --border: #e1e4e9;
  --border-strong: #cdd1d8;
  --text: #1b1f27;
  --muted: #667085;
  --accent: #2c4fd6;
  --accent-hover: #2340b4;
  --accent-soft: #eaeefc;
  --accent-text: #ffffff;
  --ok: #17794a;
  --warn: #9a5b06;
  --bad: #b3261e;
  --chart-1: var(--accent);
  --chart-2: #a3abb8;
  --bubble-in: #f1f2f5;
  --bubble-out: #e6ebfb;
  --radius: 6px;
  --radius-lg: 8px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101317;
    --surface: #171b21;
    --surface-2: #1e232b;
    --border: #2a303a;
    --border-strong: #3a424f;
    --text: #e5e8ed;
    --muted: #8b95a5;
    --accent: #8aa0ff;
    --accent-hover: #a9b9ff;
    --accent-soft: #1f2748;
    --accent-text: #0d1330;
    --ok: #4cc38a;
    --warn: #e0a83a;
    --bad: #f07a72;
    --chart-2: #596273;
    --bubble-in: #1e232b;
    --bubble-out: #222c52;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 13.5px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}

h1, h2, h3 { margin: 0; line-height: 1.3; font-weight: 600; }
h1 { font-size: 20px; letter-spacing: -0.01em; }
h2 { font-size: 14px; }
h3 { font-size: 14px; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--bad); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 208px minmax(0, 1fr); min-height: 100vh; }
.content { min-width: 0; display: flex; flex-direction: column; }

.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--surface); border-right: 1px solid var(--border); padding: 12px 8px;
}
.sidebar-brand { font-weight: 600; font-size: 14px; padding: 6px 10px 16px; }
#nav { display: flex; flex-direction: column; gap: 1px; }
#nav a {
  display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 10px; border-radius: var(--radius);
  color: var(--muted); font-weight: 500; text-decoration: none;
}
#nav a svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
#nav a:hover { background: var(--surface-2); color: var(--text); }
#nav a.active { background: var(--surface-2); color: var(--text); font-weight: 600; }
.nav-count { margin-left: auto; font-size: 12px; font-weight: 600; color: var(--warn); }

.topbar {
  position: sticky; top: 0; z-index: 20; height: 48px; padding: 0 24px;
  display: flex; align-items: center; gap: 18px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.search-box {
  display: flex; align-items: center; gap: 8px; width: min(340px, 40vw); height: 30px; padding: 0 10px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); color: var(--muted);
}
.search-box svg { width: 14px; height: 14px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; }
.search-box input { border: 0; padding: 0; height: 100%; background: transparent; outline: none; font-size: 13px; }
.search-box:focus-within { border-color: var(--accent); }
.topbar-link { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.topbar-link:hover { color: var(--text); text-decoration: none; }
.topbar-link.attn { color: var(--warn); font-weight: 500; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--border-strong); display: inline-block; flex: none; }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--bad); }

.main { padding: 24px 28px 56px; width: 100%; max-width: 1480px; outline: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head p { margin-top: 2px; max-width: 72ch; }
.notice { border: 1px solid var(--border-strong); border-left: 3px solid var(--warn); border-radius: var(--radius); background: var(--surface); padding: 8px 12px; margin-bottom: 16px; }

/* ---------- surfaces ---------- */
.card, .panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.card-pad { padding: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--border); min-height: 46px; }
.panel { padding: 14px 16px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.panel-title { font-size: 13.5px; font-weight: 600; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }

/* ---------- overview: analytics layout (scoped to .ov so the other pages stay plain) ---------- */
.ov { --ov-blue: #2a6df4; --ov-green: #4fd16c; --ov-shadow: 0 1px 2px rgba(20, 35, 58, .04), 0 6px 20px rgba(20, 35, 58, .05); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ov { --ov-blue: #5b8cff; --ov-green: #4ade80; --ov-shadow: none; } }
.ov-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.ov-head h1 { font-size: 24px; }
.ov-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.ov-grid.no-inbox { grid-template-columns: minmax(0, 1fr); }
.ov-main { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.ov-row { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 18px; }
.ov-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--ov-shadow); padding: 20px 22px; min-width: 0; }
.ov-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.ov-title { font-size: 18px; font-weight: 650; }
.ov-sub { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; font-size: 14px; }
.ov-select {
  appearance: none; width: auto; height: 36px; padding: 0 34px 0 14px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%236b7a93' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 12px center;
}
.ov-select.sm { height: 30px; padding: 0 30px 0 10px; font-size: 12.5px; background-position: right 10px center; }

.ov-conv { display: grid; grid-template-columns: minmax(0, 1fr) 200px; gap: 18px; align-items: stretch; }
.ov-legend { display: flex; gap: 16px; align-items: center; color: var(--muted); font-size: 13px; }
.ov-legend i { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.ov-legend .a i { background: var(--ov-blue); }
.ov-legend .b i { background: var(--ov-green); }
.ov-metrics { display: flex; flex-direction: column; gap: 12px; }
.ov-metric { flex: 1; background: var(--surface-2); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; justify-content: center; }
.ov-metric .meter { height: 8px; border-radius: 6px; background: var(--accent-soft); margin-bottom: 10px; overflow: hidden; }
.ov-metric .meter i { display: block; height: 100%; background: var(--ov-blue); border-radius: 6px; }
.ov-metric small { color: var(--muted); font-size: 12.5px; }
.ov-metric b { display: block; font-size: 26px; line-height: 1.15; font-weight: 650; letter-spacing: -0.01em; }

/* shared chart basics (the SVGs are drawn at their real pixel width, so 1 unit = 1 px) */
.ov svg.chart { width: 100%; height: auto; display: block; overflow: visible; }
.ov svg.chart text { font-size: 11.5px; fill: var(--muted); font-family: inherit; }
.ov svg.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.ov svg.chart .hover { fill: transparent; }
.ov svg.chart .hover:hover { fill: var(--surface-2); }
.ov svg.chart .bar-in { fill: var(--ov-blue); }
.ov svg.chart .bar-out { fill: var(--ov-green); }
.ov svg.chart .line-in { fill: none; stroke: var(--ov-blue); stroke-width: 2.4; stroke-linecap: round; }
.ov svg.chart .line-out { fill: none; stroke: var(--ov-green); stroke-width: 2.4; stroke-linecap: round; }
.ov svg.chart .pt-in { fill: var(--surface); stroke: var(--ov-blue); stroke-width: 2.2; }
.ov svg.chart .pt-out { fill: var(--surface); stroke: var(--ov-green); stroke-width: 2.2; }

.ov-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ov-tile { border-radius: 14px; padding: 18px 10px; min-height: 104px; text-align: center; color: #0d2b3b; display: flex; flex-direction: column; justify-content: center; text-decoration: none; }
a.ov-tile:hover { filter: brightness(.97); text-decoration: none; }
.ov-tile b { font-size: 30px; line-height: 1.1; font-weight: 700; letter-spacing: -0.01em; }
.ov-tile span { margin-top: 5px; font-size: 13.5px; }
.ov-tile.cyan { background: linear-gradient(135deg, #8be9ff, #5fd3f6); }
.ov-tile.green { background: linear-gradient(135deg, #a5f3b8, #7de39a); }
.ov-tile.blue { background: linear-gradient(135deg, #a9cdff, #86b6fb); }
.ov-tile.yellow { background: linear-gradient(135deg, #ffe9b3, #ffd98a); }

.ov-inbox { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--ov-shadow); overflow: hidden; position: sticky; top: 64px; max-height: calc(100vh - 84px); display: flex; flex-direction: column; }
.ov-inbox-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.ov-inbox-head h2 { font-size: 18px; font-weight: 650; flex: 1; }
.ov-inbox-icon { width: 34px; height: 34px; border-radius: 9px; background: #25c168; color: #fff; display: grid; place-items: center; flex: none; }
.ov-inbox-icon svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ov-inbox-band { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 16px; background: var(--surface-2); font-size: 13.5px; }
.ov-inbox-scroll { overflow-y: auto; flex: 1; }
.ov-inbox-empty { padding: 22px 16px; color: var(--muted); }
.ov-row-item { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--border); cursor: pointer; }
.ov-row-item:hover { background: var(--surface-2); }
.ov-avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 13px; flex: none; }
.ov-who { min-width: 0; flex: 1; }
.ov-who b { display: block; font-weight: 600; }
.ov-who span { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; }
.ov-who em { font-style: normal; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ov-when { color: var(--muted); font-size: 12px; white-space: nowrap; align-self: flex-start; padding-top: 2px; }
.ov-actions { display: flex; gap: 4px; }
.sdot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--border-strong); }
.sdot.active { background: var(--ok); }
.sdot.pending { background: var(--warn); }
.sdot.muted { background: var(--bad); }

/* ---------- controls ---------- */
.btn {
  appearance: none; display: inline-flex; align-items: center; justify-content: center; height: 30px; padding: 0 12px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  border-radius: var(--radius); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.sm { height: 24px; padding: 0 8px; font-size: 12px; }
.btn.block { width: 100%; height: 34px; }

.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: 12px; font-weight: 500; color: var(--muted); }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius); height: 30px; padding: 0 9px; width: 100%;
}
input[type="checkbox"] { width: auto; height: auto; }
textarea { height: auto; padding: 8px 10px; resize: vertical; min-height: 110px; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
select { width: auto; padding-right: 4px; }
.select, .select-sm { width: auto; }
.search { max-width: 260px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.toolbar input[type="search"] { width: 240px; }
.toolbar input[type="date"] { width: 136px; }
.toolbar .inline { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; }

/* status: a dot and a word, no pill */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500; color: var(--muted); white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.pill.ok { color: var(--ok); }
.pill.warn { color: var(--warn); }
.pill.bad { color: var(--bad); }
.tag { display: inline-block; border: 1px solid var(--border); border-radius: 4px; padding: 0 6px; font-size: 12px; color: var(--muted); line-height: 18px; }

.switch-row { flex-wrap: nowrap; gap: 16px; cursor: pointer; }
.switch-row > span:first-child { min-width: 0; }
.switch { position: relative; width: 32px; height: 18px; flex: none; }
.switch input { opacity: 0; position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch i { position: absolute; inset: 0; background: var(--border-strong); border-radius: 999px; transition: background .12s; }
.switch i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .12s; }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(14px); }
.switch input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.tabs button { appearance: none; border: 0; background: none; padding: 7px 10px; font: inherit; font-weight: 500; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.card-head .tabs { border: 0; margin: 0; align-self: stretch; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); padding: 7px 12px; border-bottom: 1px solid var(--border-strong); white-space: nowrap; }
td { padding: 7px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; white-space: nowrap; }
th.num, td.num { text-align: right; }
tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr:hover { background: var(--surface-2); }
td.snippet { max-width: 340px; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
td.trunc { max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
td.wrap { white-space: normal; }
td.actions { text-align: right; }
.table-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 14px; border-top: 1px solid var(--border); }
.empty { padding: 32px 16px; text-align: center; color: var(--muted); }

/* ---------- conversation ---------- */
.chat { display: flex; flex-direction: column; gap: 6px; max-height: 52vh; overflow-y: auto; padding: 2px; }
.bubble { max-width: 82%; padding: 7px 11px; border-radius: 8px; background: var(--bubble-in); white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble.out { align-self: flex-end; background: var(--bubble-out); }
.bubble .meta { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
.bubble.manual { outline: 1px dashed var(--accent); }
.composer { display: flex; gap: 8px; margin-top: 10px; align-items: flex-end; }
.composer textarea { min-height: 30px; height: 30px; padding: 5px 9px; }

/* ---------- drawer / dialog / toast ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(10, 14, 20, .35); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(540px, 100vw); z-index: 50;
  background: var(--surface); border-left: 1px solid var(--border-strong); display: flex; flex-direction: column;
}
.drawer-head { padding: 14px 18px 12px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.drawer-body { padding: 14px 18px 24px; overflow-y: auto; flex: 1; }
.dialog { border: 1px solid var(--border-strong); border-radius: var(--radius-lg); background: var(--surface); color: var(--text); padding: 18px; max-width: 400px; width: calc(100vw - 32px); }
.dialog::backdrop { background: rgba(10, 14, 20, .4); }
.dialog h3 { margin-bottom: 4px; font-size: 15px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.toasts { position: fixed; bottom: 16px; right: 16px; display: flex; flex-direction: column; gap: 6px; z-index: 80; }
.toast { background: var(--text); color: var(--bg); padding: 8px 12px; border-radius: var(--radius); max-width: 360px; }
.toast.error { background: var(--bad); color: #fff; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(340px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 24px; display: flex; flex-direction: column; gap: 14px; }

/* ---------- misc ---------- */
.pairing-code { font: 600 30px/1 ui-monospace, Menlo, Consolas, monospace; letter-spacing: .12em; padding: 14px 16px; border: 1px solid var(--border-strong); border-radius: var(--radius); text-align: center; user-select: all; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 14px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.playground-chat { min-height: 240px; max-height: 50vh; }
.flags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
details.debug { margin-top: 6px; }
details.debug pre { white-space: pre-wrap; background: var(--surface); border: 1px solid var(--border); padding: 8px; border-radius: var(--radius); max-height: 240px; overflow: auto; font-size: 12px; }
.danger-zone { border-color: var(--bad); }

@media (max-width: 1180px) {
  .ov-grid { grid-template-columns: minmax(0, 1fr); }
  .ov-inbox { position: static; max-height: none; }
  .ov-inbox-scroll { max-height: 420px; }
}

@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; padding: 6px 8px; border-right: 0; border-bottom: 1px solid var(--border); }
  .sidebar-brand { display: none; }
  #nav { flex-direction: row; overflow-x: auto; }
  #nav a { flex: none; }
  .topbar { padding: 0 12px; gap: 10px; }
  .search-box { flex: 1; width: auto; }
  .main { padding: 16px 12px 40px; }
  .ov-conv, .ov-row { grid-template-columns: 1fr; }
  .ov-metrics { flex-direction: row; }
  .grid.two { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: 0; }
  .kv dd { margin-bottom: 8px; }
}
@media (max-width: 520px) {
  .topbar-link span#tb-wa-text, .topbar-link .txt { display: none; }
}

/* ---------- chats: messenger layout (scoped to .wa) ---------- */
.wa {
  --wa-panel: #ffffff; --wa-head: #f0f2f5; --wa-line: #e9edef; --wa-chat: #efeae2; --wa-dots: rgba(17, 27, 33, .045);
  --wa-in: #ffffff; --wa-out: #d9fdd3; --wa-text: #111b21; --wa-muted: #667781; --wa-green: #00a884; --wa-badge: #25d366;
  --wa-hover: #f5f6f6; --wa-selected: #f0f2f5; --wa-system: #fff5c4; --wa-link: #027eb5; --wa-chip-on: #d9fdd3; --wa-chip-on-text: #0a6b55;
  --wa-ai: #7c4ddb; --wa-you: #008069; --wa-shadow: 0 1px .5px rgba(11, 20, 26, .13);
  display: grid; grid-template-columns: 380px minmax(0, 1fr); height: calc(100vh - 100px); min-height: 480px;
  background: var(--wa-panel); color: var(--wa-text); border: 1px solid var(--wa-line); border-radius: 12px; overflow: hidden;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .wa {
    --wa-panel: #111b21; --wa-head: #202c33; --wa-line: #222d34; --wa-chat: #0b141a; --wa-dots: rgba(255, 255, 255, .035);
    --wa-in: #202c33; --wa-out: #005c4b; --wa-text: #e9edef; --wa-muted: #8696a0; --wa-hover: #182229; --wa-selected: #2a3942;
    --wa-system: #2f3b27; --wa-link: #53bdeb; --wa-chip-on: #0a332c; --wa-chip-on-text: #00d9a5; --wa-ai: #b79cff; --wa-you: #5fe0c0;
    --wa-shadow: none; --wa-input: #2a3942;
  }
}

.wa-list { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--wa-panel); border-right: 1px solid var(--wa-line); }
.wa-list-head { padding: 14px 16px 6px; }
.wa-list-head h2 { font-size: 20px; font-weight: 650; }
.wa-search { display: flex; align-items: center; gap: 10px; margin: 6px 12px 8px; height: 36px; padding: 0 12px; background: var(--wa-head); border-radius: 8px; color: var(--wa-muted); }
.wa-search svg { width: 17px; height: 17px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.wa-search input { border: 0; background: transparent; height: 100%; padding: 0; outline: none; box-shadow: none; color: var(--wa-text); font-size: 14px; }
.wa-search input:focus { box-shadow: none; }
.wa-chips { display: flex; gap: 6px; padding: 0 12px 10px; flex-wrap: wrap; }
.wa-chips button { border: 0; background: var(--wa-head); color: var(--wa-muted); font: inherit; font-size: 13px; padding: 4px 12px; border-radius: 999px; cursor: pointer; }
.wa-chips button:hover { filter: brightness(.97); }
.wa-chips button[aria-pressed="true"] { background: var(--wa-chip-on); color: var(--wa-chip-on-text); font-weight: 600; }
.wa-rows { overflow-y: auto; flex: 1; }
.wa-row { display: flex; gap: 12px; padding: 10px 14px; cursor: pointer; }
.wa-row:hover { background: var(--wa-hover); }
.wa-row.selected { background: var(--wa-selected); }
.wa-row .ov-avatar { width: 46px; height: 46px; font-size: 14px; }
.wa-row-main { min-width: 0; flex: 1; border-bottom: 1px solid var(--wa-line); padding-bottom: 10px; margin-bottom: -10px; display: flex; flex-direction: column; gap: 2px; }
.wa-row-top, .wa-row-bottom { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.wa-row-top b { font-weight: 600; font-size: 14.5px; }
.wa-time { font-size: 12px; color: var(--wa-muted); white-space: nowrap; }
.wa-time.unread { color: var(--wa-badge); font-weight: 600; }
.wa-preview { color: var(--wa-muted); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.wa-badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--wa-badge); color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center; flex: none; }
.wa-flag { font-size: 11px; font-weight: 650; padding: 0 5px; border-radius: 4px; margin-right: 6px; }
.wa-flag.warn { background: var(--warn-soft, #fef3c7); color: var(--warn); }
.wa-flag.bad { background: rgba(179, 38, 30, .12); color: var(--bad); }
.wa-empty-list { padding: 28px 16px; text-align: center; color: var(--wa-muted); }

.wa-thread { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--wa-chat); }
.wa-thread-head { display: flex; align-items: center; gap: 12px; padding: 9px 16px; background: var(--wa-head); border-bottom: 1px solid var(--wa-line); }
.wa-thread-head .ov-avatar { width: 40px; height: 40px; font-size: 13px; }
.wa-title { min-width: 0; flex: 1; display: flex; flex-direction: column; line-height: 1.3; }
.wa-title b { font-size: 15.5px; font-weight: 600; }
.wa-title span { font-size: 12.5px; color: var(--wa-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-head-actions { display: flex; align-items: center; gap: 8px; }
.wa-icon-btn { width: 38px; height: 38px; border: 0; border-radius: 50%; background: transparent; color: var(--wa-muted); display: grid; place-items: center; cursor: pointer; flex: none; }
.wa-icon-btn:hover { background: rgba(120, 130, 140, .16); color: var(--wa-text); }
.wa-icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.wa-back { display: none; }

.wa-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 8px 16px; background: var(--wa-system); color: var(--wa-text); font-size: 13px; border-bottom: 1px solid var(--wa-line); }
.wa-banner-actions { display: flex; gap: 6px; }

.wa-messages { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 6% 16px; display: flex; flex-direction: column; background-image: radial-gradient(var(--wa-dots) 1.2px, transparent 1.2px); background-size: 20px 20px; }
.wa-day { display: flex; justify-content: center; margin: 12px 0 8px; position: sticky; top: 0; z-index: 1; }
.wa-day span { background: var(--wa-in); color: var(--wa-muted); font-size: 12.5px; padding: 5px 12px; border-radius: 8px; box-shadow: var(--wa-shadow); }
.wa-system { align-self: center; background: var(--wa-system); color: var(--wa-text); font-size: 13px; padding: 6px 12px; border-radius: 8px; margin: 20px 0; }
.wa-msg { display: flex; margin-top: 2px; }
.wa-msg.out { justify-content: flex-end; }
.wa-msg.tail { margin-top: 9px; }
.wa-bubble { position: relative; max-width: min(68%, 580px); padding: 6px 9px 7px; border-radius: 8px; box-shadow: var(--wa-shadow); font-size: 14.2px; line-height: 1.38; overflow-wrap: anywhere; white-space: pre-wrap; }
.wa-msg.in .wa-bubble { background: var(--wa-in); }
.wa-msg.out .wa-bubble { background: var(--wa-out); }
.wa-msg.tail .wa-bubble::before { content: ""; position: absolute; top: 0; width: 9px; height: 13px; }
.wa-msg.in.tail .wa-bubble { border-top-left-radius: 0; }
.wa-msg.in.tail .wa-bubble::before { left: -8px; background: var(--wa-in); clip-path: polygon(100% 0, 100% 100%, 0 0); }
.wa-msg.out.tail .wa-bubble { border-top-right-radius: 0; }
.wa-msg.out.tail .wa-bubble::before { right: -8px; background: var(--wa-out); clip-path: polygon(0 0, 100% 0, 0 100%); }
.wa-who { display: block; font-size: 12px; font-weight: 650; margin-bottom: 1px; }
.wa-who.bot { color: var(--wa-ai); }
.wa-who.you { color: var(--wa-you); }
.wa-text a { color: var(--wa-link); }
.wa-note { font-style: italic; color: var(--wa-muted); }
.wa-file { display: inline-flex; align-items: center; gap: 8px; padding: 8px 10px; background: rgba(120, 130, 140, .14); border-radius: 6px; min-width: 160px; }
.wa-file svg { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; }
.wa-meta { float: right; margin: 7px 0 -4px 12px; font-size: 11px; line-height: 1; color: var(--wa-muted); display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; user-select: none; }
.wa-tick { display: inline-flex; }
.wa-tick svg { width: 14px; height: 10px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.wa-composer { display: flex; align-items: flex-end; gap: 8px; padding: 10px 14px; background: var(--wa-head); }
.wa-composer textarea { flex: 1; min-height: 42px; max-height: 120px; height: 42px; padding: 10px 14px; border: 0; border-radius: 8px; background: var(--wa-input, var(--wa-in)); color: var(--wa-text); font-size: 15px; line-height: 1.35; resize: none; outline: none; box-shadow: none; }
.wa-composer textarea:focus { box-shadow: none; }
.wa-send { width: 42px; height: 42px; border: 0; border-radius: 50%; background: var(--wa-green); color: #fff; display: grid; place-items: center; cursor: pointer; flex: none; }
.wa-send:hover { filter: brightness(1.08); }
.wa-send:disabled { opacity: .5; cursor: not-allowed; }
.wa-send svg { width: 21px; height: 21px; fill: currentColor; stroke: none; }

.wa-placeholder { margin: auto; padding: 24px; text-align: center; color: var(--wa-muted); max-width: 380px; }
.wa-placeholder svg { width: 76px; height: 76px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; opacity: .55; margin-bottom: 14px; }
.wa-placeholder h3 { font-size: 21px; font-weight: 400; color: var(--wa-text); margin-bottom: 6px; }

.nav-count.unread { color: #fff; background: #25d366; border-radius: 999px; padding: 0 6px; min-width: 18px; text-align: center; }

@media (max-width: 1100px) {
  .wa { grid-template-columns: 320px minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .wa { grid-template-columns: minmax(0, 1fr); height: calc(100vh - 150px); border-radius: 8px; }
  .wa .wa-thread { display: none; }
  .wa.show-thread .wa-list { display: none; }
  .wa.show-thread .wa-thread { display: flex; }
  .wa-back { display: grid; }
  .wa-messages { padding-inline: 12px; }
  .wa-bubble { max-width: 84%; }
}

/* new chat picker */
.wa-list-view, .wa-new-view { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.wa-list-head { display: flex; align-items: center; justify-content: space-between; }
.wa-new-head { display: flex; align-items: center; gap: 8px; padding: 12px 12px 6px; }
.wa-new-head h2 { font-size: 18px; font-weight: 650; }
.wa-newnum { margin: 6px 12px 4px; padding: 12px; border: 1px solid var(--wa-border, rgba(127,127,127,.25)); border-radius: 10px; display: flex; flex-direction: column; gap: 8px; }
.wa-newnum label { display: flex; flex-direction: column; gap: 2px; }
.wa-newnum label span { font-size: 12px; color: var(--wa-muted); }
.wa-newnum-row { display: flex; gap: 8px; }
.wa-newnum-row input { flex: 1; min-width: 0; height: 36px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--wa-border, rgba(127,127,127,.3)); background: transparent; color: inherit; font: inherit; }
.wa-new-results { overflow-y: auto; flex: 1; padding-bottom: 12px; }
.wa-section { padding: 12px 16px 4px; font-size: 12.5px; font-weight: 600; color: var(--wa-muted); }
.wa-opt { display: flex; align-items: center; gap: 12px; padding: 9px 14px; cursor: pointer; }
.wa-opt:hover:not(.disabled) { background: var(--wa-hover); }
.wa-opt.disabled { opacity: .5; cursor: default; }
.wa-opt .ov-avatar { width: 42px; height: 42px; font-size: 13px; }
.wa-opt.plus .ov-avatar { font-size: 24px; font-weight: 400; }
.wa-opt-main { min-width: 0; }
.wa-opt-main b { display: block; font-weight: 600; font-size: 14.5px; }
.wa-opt-main span { display: block; color: var(--wa-muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-hint { padding: 8px 16px; color: var(--wa-muted); font-size: 13px; }
.wa-hint.error { color: var(--bad); }
.wa-check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; }
.wa-check input { width: auto; height: auto; }
.wa-new-btn { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; }
.wa-new-btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.wa-start .ov-avatar { background: var(--wa-green); font-size: 24px; font-weight: 400; }
