:root {
  --brand: #159447;
  --brand-bright: #22c55e;
  --brand-hover: #127a3a;
  --brand-soft: #eef8f2;
  --brand-ink: #14532d;
  --ink: #14181f;
  --muted: #6b7280;
  --line: #e7e9ee;
  --field: #f4f5f7;
  --paper: #f5f6f8;
  --card: #ffffff;
  --side: #0e131b;
  --side-ink: #f4f6f8;
  --side-muted: #9aa3b2;
  --shadow: 0 1px 2px rgba(16, 20, 28, 0.04);
  --ok: #15803d;
  --ok-bg: #ecfdf5;
  --wait: #b45309;
  --wait-bg: #fffbeb;
  --bad: #dc2626;
  --bad-bg: #fef2f2;
  --radius: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
  letter-spacing: -0.011em;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
::selection { background: #d1fae5; color: #052e16; }
.hidden { display: none !important; }
.boot {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: var(--paper);
}
h1, h2, p { margin: 0; }
h1 { font-size: 1.45rem; font-weight: 750; letter-spacing: -0.04em; line-height: 1.15; }
h2 { font-size: 0.95rem; font-weight: 700; letter-spacing: -0.02em; }
.kicker {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.01em;
}
.muted { color: var(--muted); font-size: 0.84rem; line-height: 1.45; }
.field-hint { margin: 6px 0 0; color: var(--muted); font-size: 0.8rem; line-height: 1.45; }
.field-hint b { color: var(--brand-ink); font-weight: 700; }
.mono { font-variant-numeric: tabular-nums; letter-spacing: 0; color: #334155; }

.login-wrap {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 28px 20px;
  background: #0e1218;
}
.login-stage {
  width: min(920px, 100%);
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  min-height: 520px;
  border-radius: 24px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
}
.login-hero {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 28px;
  padding: 36px;
  color: #e7eef8;
  background: #141a24;
}
.login-hero .brand-mark { width: 52px; height: 52px; border-radius: 16px; }
.login-hero-copy { display: grid; gap: 12px; }
.login-hero .kicker { color: #86efac; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 750; }
.login-hero h2 {
  font-size: 1.85rem;
  line-height: 1.15;
  letter-spacing: -0.04em;
  font-weight: 750;
  max-width: 14ch;
}
.login-hero p:last-child { max-width: 32ch; color: #b7c3d6; font-size: 0.96rem; line-height: 1.55; }
.login-card {
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: #fff;
  padding: 40px 36px 32px;
}
.login-brand { display: flex; align-items: center; gap: 14px; }
.login-brand h1 { margin: 2px 0 0; font-size: 1.7rem; }
.login-lead { margin: 8px 0 22px; color: var(--muted); font-size: 0.95rem; }
.login-card .field { display: grid; gap: 8px; }
.login-card .field + .field { margin-top: 14px; }
.login-card label { margin: 0; font-size: 0.8rem; font-weight: 650; color: #374151; }
.login-card input[type="text"],
.login-card input[type="password"] {
  appearance: none;
  width: 100%;
  height: 48px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--field);
  padding: 0 14px;
  outline: none;
}
.login-card input::placeholder { color: #9ca3af; }
.login-card input:focus { border-color: #86efac; background: #fff; box-shadow: 0 0 0 3px rgba(21, 148, 71, 0.12); }
.login-card input:-webkit-autofill {
  -webkit-text-fill-color: var(--ink);
  box-shadow: 0 0 0 1000px #fff inset;
}
.login-card .btn.block { width: 100%; height: 48px; margin-top: 22px; border-radius: 12px; }
.login-card .alert { margin-top: 14px; }

dialog:not([open]) { display: none !important; }
dialog {
  width: min(440px, calc(100% - 32px));
  margin: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 24px 50px rgba(16, 20, 28, 0.16);
  padding: 22px;
}
dialog::backdrop { background: rgba(16, 20, 28, 0.45); }
dialog[open] { animation: rise 0.16s ease; }
@keyframes rise {
  from { transform: translateY(8px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
#nameDialog { width: min(420px, calc(100% - 32px)); }
#nameForm { display: grid; gap: 0; }
#nameForm h2 { font-size: 1.15rem; }
#nameForm input { margin-top: 16px; }
#nameForm .row-actions { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 8px; margin-top: 18px; }
#nameForm .row-actions .btn { width: 100%; height: 42px; }
#newChatDialog { width: min(440px, calc(100% - 32px)); padding: 24px; }
#newChatForm { display: grid; gap: 0; }
#newChatForm h2 { font-size: 1.15rem; }
#newChatForm .muted { margin-top: 6px; }
#newChatForm label { margin: 16px 0 6px; }
#newChatForm .row-actions { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 8px; margin-top: 18px; }
#newChatForm .row-actions .btn { width: 100%; height: 42px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px;
  display: block;
  object-fit: cover;
}
.brand-mark.sm { width: 34px; height: 34px; border-radius: 10px; }
label { display: block; margin: 14px 0 6px; font-size: 0.78rem; font-weight: 650; color: #374151; }
.block label:first-of-type { margin-top: 0; }
input[type="text"], input[type="password"], input[type="number"], input[type="search"], textarea, select {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 0 12px;
  outline: none;
}
textarea { height: auto; min-height: 108px; padding: 12px; line-height: 1.5; resize: vertical; }
textarea.tall { min-height: 260px; }
.bulk-save {
  display: grid;
  grid-template-columns: minmax(180px, 260px) minmax(0, 1fr);
  gap: 12px;
  align-items: end;
  margin-top: 14px;
}
.bulk-save label { margin-top: 0; }
.bulk-save .btn { width: 100%; height: 40px; }
select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%236b7280' d='M1.2 1.4 6 6.2 10.8 1.4'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
input:focus, textarea:focus, select:focus {
  border-color: #86efac;
  box-shadow: 0 0 0 3px rgba(21, 148, 71, 0.12);
}
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: 0;
  background: var(--brand);
  color: #fff; text-decoration: none;
  height: 38px; border-radius: 10px; padding: 0 14px; font-weight: 650;
  white-space: nowrap; flex: 0 0 auto;
}
.btn:hover { background: var(--brand-hover); }
.btn:active { transform: translateY(1px); }
.btn.block { width: 100%; margin-top: 16px; height: 42px; }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.ghost:hover { background: var(--field); }
.btn.small { height: 32px; padding: 0 10px; border-radius: 8px; font-size: 0.8rem; }
.btn.danger { background: #fff; color: var(--bad); border: 1px solid #fecaca; }
.btn.danger:hover { background: var(--bad-bg); }
.text-btn { border: 0; background: transparent; color: var(--brand-hover); font-size: 0.78rem; font-weight: 650; padding: 0; }
.text-btn.danger { color: var(--bad); }
.text-btn + .text-btn { margin-left: 12px; }
.alert { background: var(--bad-bg); color: var(--bad); border-radius: 10px; padding: 10px 12px; font-size: 0.84rem; }
.stack { display: grid; gap: 0; align-content: start; }
.block { display: grid; gap: 8px; padding: 14px 0; }
.block + .block { border-top: 1px solid var(--line); }
.card > .block:first-child { padding-top: 0; }
.card > .block:last-child { padding-bottom: 0; }
.row-actions, .toolbar, .form-row { display: flex; gap: 8px; align-items: center; }
.form-row { align-items: end; margin-top: 4px; }
.form-row > div { flex: 1; min-width: 0; }
.form-row label { margin-top: 0; }
.toolbar { justify-content: space-between; flex-wrap: wrap; }
.toolbar input, .toolbar select { width: auto; flex: 1; }
.count {
  min-width: 28px; height: 22px; padding: 0 8px; border-radius: 999px;
  display: inline-grid; place-items: center;
  background: var(--brand-soft); color: var(--brand-ink); font-size: 0.72rem; font-weight: 700;
}

.app {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: grid;
  grid-template-columns: 228px minmax(0, 1fr);
}
.side {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
  padding: 16px 12px 12px;
  color: var(--side-ink);
  background: var(--side);
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 8px 14px;
  text-decoration: none;
  color: #fff;
}
.logo-copy { display: grid; line-height: 1.1; }
.logo-copy strong { font-size: 0.95rem; font-weight: 750; letter-spacing: -0.03em; }
.logo-copy small { margin-top: 3px; color: var(--side-muted); font-size: 0.7rem; font-weight: 550; }
.nav-label {
  margin: 6px 10px 2px;
  color: #6b7280;
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.nav { display: flex; flex-direction: column; gap: 2px; padding: 2px; }
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 38px;
  padding: 0 10px;
  border-radius: 10px;
  color: var(--side-muted);
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
}
.nav svg {
  width: 18px; height: 18px; flex: 0 0 auto;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}
.nav a:hover { background: rgba(255, 255, 255, 0.05); color: #fff; }
.nav a.on { background: rgba(21, 148, 71, 0.18); color: #fff; }
.nav a.on svg { color: #4ade80; }
.nav-badge {
  margin-left: auto;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px;
  display: inline-grid; place-items: center;
  background: var(--brand-bright); color: #052e16;
  font-size: 0.66rem; font-weight: 800; line-height: 1;
}
.side-foot { margin-top: auto; padding: 12px 4px 0; border-top: 1px solid rgba(255, 255, 255, 0.08); }
.side .btn { width: 100%; }
.side .btn.ghost {
  background: transparent;
  color: #c5ceda;
  border-color: rgba(255, 255, 255, 0.1);
}
.side .btn.ghost:hover { background: rgba(255, 255, 255, 0.06); }
.main { min-width: 0; min-height: 0; overflow: auto; padding: 28px 32px 40px; }
.main.inbox { display: flex; flex-direction: column; overflow: hidden; padding: 12px; }
.page { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.page:not(.page-fill) { width: 100%; }
#page-contactAdd { align-items: flex-start; }
#page-contactAdd .page-head,
#page-contactAdd .card { width: min(760px, 100%); }
.page-fill { flex: 1; min-height: 0; width: 100%; height: 100%; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-width: 0; }
.page-head > div { min-width: 0; }
.page-head p { margin-top: 4px; max-width: 58ch; }
.page-head .btn { flex: 0 0 auto; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.stat {
  display: grid;
  gap: 6px;
  align-content: start;
  padding: 18px 20px 16px;
  border-right: 1px solid var(--line);
}
.stat .kicker { letter-spacing: 0.06em; text-transform: uppercase; font-size: 0.68rem; }
.stat:last-child { border-right: 0; }
.stat-btn {
  border: 0; background: transparent; text-align: left; font: inherit; color: inherit;
  cursor: pointer; width: 100%;
}
.stat-btn:hover { background: #f3faf6; }
.stat-btn strong { color: var(--brand-ink); }
#sentDialog { width: min(640px, calc(100% - 32px)); }
.sent-scroll { max-height: min(60vh, 440px); overflow: auto; margin-top: 12px; }
.sent-filters { display: flex; gap: 8px; align-items: center; margin-top: 12px; }
.sent-table { table-layout: auto; }
.sent-table th:nth-child(3), .sent-table td:nth-child(3) { width: 110px; }
.stat strong { font-size: 1.75rem; font-weight: 750; letter-spacing: -0.045em; line-height: 1; }
.dash-card { display: grid; gap: 2px; padding: 6px; }
.dash-card .toolbar { padding: 8px 10px 4px; }
#dashManage {
  color: var(--brand-hover);
  font-size: 0.82rem;
  font-weight: 650;
  text-decoration: none;
}
#dashManage:hover { text-decoration: underline; }
.dash-list { display: grid; }
.dash-row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border-radius: 10px;
}
.dash-row:hover { background: var(--field); }
.dash-copy { min-width: 0; display: grid; gap: 2px; }
.dash-copy b { font-size: 0.9rem; }
.dash-copy span { color: var(--muted); font-size: 0.78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-alert {
  width: calc(100% - 8px);
  margin: 4px;
  padding: 10px 12px;
  border: 0;
  border-radius: 10px;
  background: #fff7ed;
  color: #9a3412;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
  font-weight: 650;
}
.dash-alert b { min-width: 0; }
.dash-alert span { flex: 0 0 auto; font-size: 0.78rem; font-weight: 650; white-space: nowrap; }

.board {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.session-list { display: grid; }
.session {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border-top: 1px solid #f0f1f4;
  background: #fff;
}
.session-list .session:first-child { border-top: 0; }
.session:hover { background: #fafbfc; }
.session-copy { min-width: 0; display: grid; gap: 3px; }
.session-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.session-title strong { font-size: 0.95rem; letter-spacing: -0.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-copy .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-actions { display: flex; align-items: center; gap: 6px; }
.more { position: relative; }
.more summary {
  list-style: none;
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #6b7280;
}
.more summary::-webkit-details-marker { display: none; }
.more summary:hover, .more[open] summary { background: var(--field); border-color: var(--line); color: var(--ink); }
.more-menu {
  position: absolute;
  right: 0; top: calc(100% + 4px);
  z-index: 6;
  min-width: 160px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(16, 20, 28, 0.1);
  display: grid;
}
.menu-item {
  border: 0; background: transparent; text-align: left;
  height: 34px; border-radius: 8px; padding: 0 10px; font-weight: 600; font-size: 0.86rem;
}
.menu-item:hover { background: var(--field); }
.menu-item.danger { color: var(--bad); }
#qrDialog { width: min(420px, calc(100% - 32px)); }
.qr-popup { display: grid; justify-items: center; gap: 14px; text-align: center; }
.qr-popup-head { width: 100%; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; text-align: left; }
.pair-code {
  min-height: 52px; margin: 8px 0 0; padding: 10px 12px;
  border-radius: 12px; background: var(--field);
  font-size: 1.7rem; font-weight: 750; letter-spacing: 0.16em; text-align: center;
}
#qrImage {
  width: min(300px, 70vw); height: auto; aspect-ratio: 1; object-fit: contain;
  background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 12px;
}
.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px;
  border-radius: 999px; font-size: 0.7rem; font-weight: 650;
  background: var(--field); color: var(--muted); white-space: nowrap;
}
.pill.open::before, .pill.qr::before, .pill.connecting::before, .pill.close::before, .pill.warn::before {
  content: ""; width: 6px; height: 6px; border-radius: 99px; background: currentColor;
}
.session-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.pill.open { background: var(--ok-bg); color: var(--ok); }
.pill.qr, .pill.connecting { background: var(--wait-bg); color: var(--wait); }
.pill.close { background: var(--bad-bg); color: var(--bad); }
.pill.warn { background: #fff7ed; color: #c2410c; }
.lock-note { color: #c2410c; font-size: 0.84rem; font-weight: 650; }

.chat-layout {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  padding: 0;
  overflow: hidden;
  border-radius: 16px;
}
.chats, .thread { min-height: 0; min-width: 0; display: flex; flex-direction: column; }
.chats { border-right: 1px solid var(--line); background: #fff; }
.pane-head {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 8px;
  flex: 0 0 auto;
  background: #fff;
}
.pane-search { display: flex; gap: 8px; align-items: center; min-width: 0; }
.pane-search input { flex: 1; min-width: 0; background: var(--field); border-color: transparent; }
.pane-search input:focus { background: #fff; border-color: #86efac; }
.pane-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.pane-row select { width: 100%; height: 34px; background-color: #fff; }
.chat-filters {
  display: flex;
  width: 100%;
  gap: 2px;
  padding: 2px;
  border-radius: 10px;
  background: var(--field);
}
.chat-filters .chip { flex: 1; }
.chip {
  height: 30px;
  border: 0;
  background: transparent;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 650;
  color: #4b5563;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 10px;
  white-space: nowrap;
}
.chip.on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(16, 20, 28, 0.06); }
.filter-row { display: flex; gap: 4px; padding: 10px 12px; border-bottom: 1px solid var(--line); background: #fff; }
.filter-row .chip.on { background: var(--brand-soft); color: var(--brand-ink); }
.chip-count {
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px;
  background: var(--brand); color: #fff; font-size: 0.64rem; font-weight: 800;
  display: inline-grid; place-items: center;
}
.thread-title { display: flex; align-items: center; gap: 10px; min-height: 58px; font-weight: 650; }
.thread-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread { position: relative; background: #f7f8f7; }
.thread-empty {
  flex: 1;
  min-width: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 6px;
  text-align: center;
  padding: 32px 24px;
}
.thread-empty strong, .thread-empty p { max-width: 36ch; }
.thread-empty strong { font-size: 1rem; letter-spacing: -0.02em; }
.thread-empty p { max-width: 34ch; }
.thread.is-idle #messages,
.thread.is-idle .composer,
.thread.is-idle .disconnect-note { display: none; }
.composer.is-off { opacity: 0.45; pointer-events: none; }
.chat-scroll, .msg-scroll, .pick-list, .table-wrap, .log, .history { overflow: auto; }
.chat-scroll, .msg-scroll { flex: 1; min-height: 0; }
.chat-scroll::-webkit-scrollbar,
.msg-scroll::-webkit-scrollbar,
.table-wrap::-webkit-scrollbar,
.log::-webkit-scrollbar,
.history::-webkit-scrollbar { width: 8px; height: 8px; }
.chat-scroll::-webkit-scrollbar-thumb,
.msg-scroll::-webkit-scrollbar-thumb,
.table-wrap::-webkit-scrollbar-thumb,
.log::-webkit-scrollbar-thumb,
.history::-webkit-scrollbar-thumb { background: #d5d8de; border-radius: 99px; }
.chat-item {
  text-align: left; border: 0; background: transparent;
  margin: 0; width: 100%;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
}
.chat-item .avatar { margin-top: 1px; width: 36px; height: 36px; border-radius: 12px; }
.chat-side { display: grid; justify-items: end; gap: 6px; padding-top: 2px; }
.chat-side .time { font-size: 0.7rem; white-space: nowrap; }
.chat-item.on { background: #e8f6ee; }
.chat-item:hover { background: #f6f7f8; }
.chat-item.on:hover { background: #dff3e7; }
.chat-copy { min-width: 0; display: grid; gap: 1px; }
.chat-name { display: flex; align-items: center; min-width: 0; }
.chat-name b, .chat-copy b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.9rem; }
.chat-copy .wa-badge { max-width: 100%; justify-self: start; }
.thread-title .wa-badge { max-width: 180px; }
.wa-badge {
  display: inline-block; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  height: 18px; padding: 0 6px; border-radius: 999px; line-height: 18px;
  background: var(--field); color: #4b5563; font-size: 0.66rem; font-weight: 650;
}
.chat-copy .wa-badge { background: transparent; padding: 0; color: #9ca3af; font-weight: 600; }
.disconnect-note {
  margin: 0 12px 8px; padding: 10px 12px; border-radius: 10px;
  background: #fef2f2; color: #b91c1c; font-size: 0.82rem; font-weight: 600;
}
.chat-copy span, .time { color: var(--muted); font-size: 0.78rem; font-weight: 500; }
.chat-copy span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center;
  background: #e8f6ee; color: var(--brand-ink);
  font-size: 0.75rem; font-weight: 750;
}
.avatar.sm { width: 32px; height: 32px; border-radius: 10px; font-size: 0.68rem; }
.badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  display: inline-grid; place-items: center;
  background: var(--brand); color: #fff; font-size: 0.68rem; font-weight: 750;
}
.msg-scroll { padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; background: #f7f8f7; }
.bubble {
  max-width: min(68%, 520px);
  padding: 9px 12px 7px;
  border-radius: 16px 16px 16px 6px;
  background: #fff;
  align-self: flex-start;
  box-shadow: 0 1px 1px rgba(16, 20, 28, 0.04);
}
.bubble.me {
  align-self: flex-end;
  background: #d7f5e3;
  border-radius: 16px 16px 6px 16px;
  box-shadow: none;
}
.bubble.me .time, .bubble.me .text-btn { color: #3f6b52; }
.bubble img, .bubble video { max-width: 220px; border-radius: 10px; display: block; margin-bottom: 6px; }
.bubble audio { width: 210px; }
.bubble a { color: inherit; }
.bubble-text { white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; line-height: 1.45; }
.bubble-foot { display: flex; justify-content: flex-end; gap: 10px; align-items: center; margin-top: 2px; }
.composer {
  position: relative;
  flex: 0 0 auto;
  border-top: 1px solid var(--line);
  padding: 8px 10px 10px;
  display: grid;
  gap: 8px;
  background: #fff;
}
.reply-bar, .file-bar {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  background: var(--field); border-left: 3px solid var(--brand); border-radius: 8px; padding: 8px 10px; font-size: 0.82rem;
}
.compose-row { display: flex; gap: 4px; align-items: flex-end; }
.compose-row .btn { height: 40px; border-radius: 10px; }
.compose-row textarea {
  flex: 1; min-height: 40px; max-height: 110px; border-radius: 12px;
  background: var(--field); border-color: transparent;
}
.compose-row textarea:focus { background: #fff; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px; flex: 0 0 auto;
  border: 0; background: transparent; color: #4b5563;
  display: inline-grid; place-items: center;
}
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:hover { background: var(--field); }
.hash-btn { font-weight: 700; font-size: 1.05rem; letter-spacing: 0; }
.hash-field {
  display: flex; align-items: stretch; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff;
}
.hash-field span {
  display: grid; place-items: center; min-width: 36px; background: var(--field); color: var(--muted); font-weight: 700;
}
.hash-field input { border: 0; border-radius: 0; box-shadow: none; }
.emoji-pop {
  position: absolute; left: 10px; right: 10px; bottom: 64px; z-index: 5;
  display: flex; flex-wrap: wrap; gap: 2px; max-height: 180px; overflow: auto;
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 6px;
  box-shadow: 0 12px 28px rgba(16, 20, 28, 0.1);
}
.emoji-pop button { border: 0; background: transparent; font-size: 1.1rem; width: 32px; height: 32px; border-radius: 8px; }
.emoji-pop button:hover { background: var(--field); }
.shortcut-pop {
  position: absolute; left: 10px; right: 10px; bottom: 64px; z-index: 6;
  display: grid; gap: 2px; max-height: 220px; overflow: auto;
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 6px;
  box-shadow: 0 12px 28px rgba(16, 20, 28, 0.1);
}
.shortcut-item {
  border: 0; background: transparent; text-align: left;
  border-radius: 8px; padding: 8px 10px; display: grid; gap: 2px;
}
.shortcut-item b { font-size: 0.82rem; }
.shortcut-item span {
  color: var(--muted); font-size: 0.78rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.shortcut-item.on, .shortcut-item:hover { background: var(--field); }
.shortcut-pop .muted { padding: 8px 10px; }
.shortcut-tools { display: flex; gap: 6px; align-items: center; padding: 2px 2px 6px; }
.shortcut-tools input { flex: 1; height: 34px; }
.shortcut-draft { display: grid; gap: 6px; padding: 2px; }
.shortcut-draft.hidden { display: none; }
.shortcut-draft textarea { min-height: 76px; resize: vertical; }
.shortcut-pop { max-height: 320px; }

.split { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.blast-split { grid-template-columns: minmax(0, 1fr); }
#page-blast { width: 100%; }
.blast-form { display: grid; gap: 0; padding: 6px 20px 20px; }
.blast-fields {
  display: grid;
  grid-template-columns: minmax(220px, 1.35fr) minmax(180px, 1fr) minmax(170px, 0.75fr) minmax(190px, 0.85fr);
  gap: 16px 18px;
  align-items: start;
  padding: 14px 0 16px;
  border-bottom: 1px solid var(--line);
}
.blast-fields .block { padding: 0; border: 0; }
.blast-fields .block + .block { border-top: 0; }
.blast-fields label { margin-top: 0; }
.blast-message { padding: 16px 0 0; }
.blast-message label { margin-top: 14px; }
.contact-split { grid-template-columns: 320px minmax(0, 1fr); }
.table-card { max-height: calc(100dvh - 168px); overflow: hidden; }
.blast-split.is-live { grid-template-columns: minmax(0, 1fr); }
.blast-split.is-live .blast-queue { width: 100%; }
.blast-queue { position: sticky; top: 0; }
#blastForm, .blast-queue { min-width: 0; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; }
.section-title label { margin: 0; }
.count { white-space: nowrap; height: auto; min-height: 22px; flex: 0 0 auto; }
#blastForm .block { min-width: 0; }
#blastForm .btn.block { margin-top: 8px; }
.seg { display: flex; gap: 2px; padding: 2px; border-radius: 10px; background: var(--field); }
.file-pick {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  height: 40px;
  margin: 0;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  font-weight: 650;
}
.file-pick:hover { border-color: #bbf7d0; }
.file-pick input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.file-pick span:first-of-type { flex: 0 0 auto; color: var(--brand-ink); font-size: 0.78rem; }
#blastFileName {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--muted); font-weight: 500; font-size: 0.8rem;
}
.blast-queue .log { min-height: 120px; max-height: calc(100dvh - 360px); }
.blast-split.is-live .blast-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.blast-split.is-live .blast-metrics > span {
  display: grid;
  gap: 2px;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--field);
}
.blast-split.is-live .blast-metrics b { display: block; font-size: 1.45rem; letter-spacing: -0.04em; margin: 0 0 2px; }
.blast-bar { height: 8px; border-radius: 99px; background: #e8eaee; overflow: hidden; }
.blast-bar > span { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--brand); }
.blast-progress { display: grid; gap: 12px; margin-top: 14px; }
.blast-metrics { display: flex; flex-wrap: wrap; gap: 8px 12px; color: var(--muted); font-size: 0.78rem; }
.blast-metrics b { color: var(--ink); font-weight: 750; }
#blastLive, #blastPast { min-width: 0; }
.history { display: grid; gap: 4px; align-content: start; max-height: 420px; }
.history-item {
  width: 100%; text-align: left; border: 0; background: transparent;
  border-radius: 8px; padding: 8px 8px; display: grid; gap: 2px;
}
.history-item:hover { background: var(--field); }
.history-item.on { background: var(--brand-soft); }
.history-item b { font-size: 0.84rem; }
.history-item span { color: var(--muted); font-size: 0.74rem; }
.blast-ack { display: flex; gap: 8px; align-items: flex-start; margin-top: 14px; text-align: left; font-size: 0.9rem; font-weight: 650; }
.blast-ack input { margin-top: 3px; }
.blast-sample {
  margin: 10px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--field);
  text-align: left; white-space: pre-wrap; font-size: 0.86rem; line-height: 1.45; color: #374151;
}
.toasts {
  position: fixed; top: 16px; right: 16px; z-index: 50;
  display: grid; gap: 8px; width: min(320px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  pointer-events: auto; text-align: left; width: 100%;
  display: grid; gap: 2px; padding: 12px 14px; border: 0; border-radius: 12px;
  background: #14181f; color: #f8fafc;
  box-shadow: 0 12px 28px rgba(16, 20, 28, 0.22);
}
.toast b { font-size: 0.88rem; }
.toast span { color: #cbd5e1; font-size: 0.78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast small { color: #86efac; font-size: 0.72rem; font-weight: 650; }
.table-card {
  min-height: 280px; min-width: 0;
  display: flex; flex-direction: column; gap: 0; padding: 0;
}
.table-card .toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  width: 100%;
  padding: 12px;
  gap: 10px;
  border-bottom: 1px solid var(--line);
}
.table-card .toolbar input { width: 100%; min-width: 0; flex: none; background: var(--field); border-color: transparent; }
.table-card .toolbar input:focus { background: #fff; }
.tool-end { display: flex; align-items: center; justify-content: flex-end; gap: 8px; min-width: 0; flex-wrap: wrap; }
#contactCount { color: var(--muted); font-size: 0.8rem; font-weight: 600; white-space: nowrap; }
.table-wrap { flex: 1; min-height: 240px; max-height: calc(100dvh - 248px); overflow: auto; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
table.no-groups .group-col { display: none; }
#contactTable { table-layout: auto; }
#contactTable .check-col { width: 52px; }
#contactTable .name-col { width: auto; }
#contactTable .phone-col { width: 200px; white-space: nowrap; }
#contactTable .group-col { width: 160px; }
#contactTable .act-col { width: 128px; text-align: right; white-space: nowrap; }
#contactTable.no-groups .name-col { width: auto; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid #eef0f3; vertical-align: middle; }
th {
  font-size: 0.68rem; color: var(--muted); font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; position: sticky; top: 0; z-index: 1; background: #f8f9fb;
}
tbody tr:hover td { background: #fafbfc; }
td:last-child, th:last-child { width: 132px; text-align: right; }
td.empty-cell, th.empty-cell { width: auto; text-align: center; color: var(--muted); padding: 56px 16px; }
tr:last-child td { border-bottom: 0; }
.person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.person span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 650; }
.checks { display: grid; gap: 6px; }
.check {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 10px; background: #fff; width: 100%; margin: 0;
  font-weight: 600; font-size: 0.88rem;
}
.check:hover { border-color: #d1d5db; }
.check.is-locked {
  background: #fff7ed; border-color: #fed7aa; color: #9a3412;
  cursor: not-allowed; pointer-events: none;
}
.check.is-locked span { color: #c2410c; font-size: 0.76rem; font-weight: 600; }
.check input {
  appearance: none; width: 16px; height: 16px; margin: 0; flex: 0 0 auto;
  border: 1.5px solid #d1d5db; border-radius: 4px; background: #fff;
  display: grid; place-items: center;
}
.check input:checked { background: var(--brand); border-color: var(--brand); }
.check input:checked::after {
  content: ""; width: 4px; height: 7px;
  border: solid #fff; border-width: 0 2px 2px 0;
  transform: rotate(45deg) translate(-1px, -1px);
}
.pick-list {
  min-height: 140px; max-height: 240px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
  display: grid; align-content: start;
}
.pick-list .check, .pick { width: 100%; border: 0; border-radius: 0; background: transparent; padding: 8px 10px; }
.pick { display: grid; grid-template-columns: 16px 32px minmax(0, 1fr); gap: 10px; }
.pick-copy { min-width: 0; display: grid; }
.pick-copy span { color: var(--muted); font-size: 0.78rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick:hover { background: var(--field); }
.log { display: grid; align-content: start; }
.log div {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 9px 0; border-bottom: 1px solid #f3f4f6; font-size: 0.82rem;
}
.log div:last-child { border-bottom: 0; }
.ok { color: var(--ok); font-weight: 650; }
.bad { color: var(--bad); font-weight: 650; }
.empty { padding: 36px 16px; text-align: center; }
.row-actions select { flex: 1; min-width: 0; }
th.check-col, td.check-col { width: 44px; text-align: center; }
.tick {
  appearance: none; width: 16px; height: 16px; margin: 0;
  border: 1.5px solid #d1d5db; border-radius: 4px; background: #fff;
  display: inline-grid; place-items: center; vertical-align: middle;
}
.tick:checked { background: var(--brand); border-color: var(--brand); }
.tick:checked::after {
  content: ""; width: 4px; height: 7px;
  border: solid #fff; border-width: 0 2px 2px 0;
  transform: rotate(45deg) translate(-1px, -1px);
}
.swal2-popup { font-family: "Plus Jakarta Sans", system-ui, sans-serif !important; border-radius: 16px !important; }
.swal2-html-container { font-size: 0.95rem !important; color: #374151 !important; }
.swal2-confirm { border-radius: 10px !important; background: #159447 !important; box-shadow: none !important; }

@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stat:nth-child(3) { border-right: 0; }
  .stat:nth-child(n + 4) { border-top: 1px solid var(--line); }
  .blast-fields { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
  .login-stage { grid-template-columns: 1fr; min-height: 0; }
  .login-hero { padding: 28px 24px 8px; gap: 16px; }
  .login-hero h2 { font-size: 1.45rem; max-width: none; }
  .login-card { padding: 24px 22px 22px; }
}
@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; height: auto; min-height: 100dvh; overflow: visible; }
  .side {
    position: sticky; top: 0; z-index: 20;
    flex-direction: row; align-items: center; gap: 8px;
    padding: 8px 10px;
  }
  .logo { padding: 0 4px 0 0; }
  .logo-copy small, .nav-label { display: none; }
  .nav { flex: 1; flex-direction: row; overflow: auto; gap: 2px; }
  .nav a { white-space: nowrap; height: 36px; }
  .side-foot { margin: 0; padding: 0; border: 0; }
  .side .btn { width: auto; }
  .main { overflow: visible; padding: 16px 12px 24px; }
  .main.inbox { overflow: visible; height: auto; }
  .page:not(.page-fill), .page-fill { width: 100%; height: auto; }
  .page-head { align-items: flex-start; flex-wrap: wrap; }
  .stats, .split, .contact-split, .chat-layout, .blast-split, .blast-fields { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { border-right: 1px solid var(--line); }
  .stat:nth-child(2n) { border-right: 0; }
  .stat:nth-child(n + 3) { border-top: 1px solid var(--line); }
  .blast-queue { position: static; }
  .table-card .toolbar { grid-template-columns: 1fr; }
  .tool-end { justify-content: flex-start; }
  .bulk-save, .form-row { grid-template-columns: 1fr; display: grid; }
  .session { grid-template-columns: 40px minmax(0, 1fr); }
  .session-actions { grid-column: 2; justify-content: flex-start; }
  .table-card { max-height: none; }
  .chat-layout { min-height: 78vh; height: 78vh; }
  .chats { border-right: 0; border-bottom: 1px solid var(--line); max-height: 280px; }
  .pane-row { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
