:root {
  --bg: #f5f6f4;
  --surface: #ffffff;
  --surface-2: #f0f2ef;
  --text: #1a1f1c;
  --muted: #5f6b64;
  --line: #e1e5e0;
  --accent: #128c4a;
  --accent-ink: #ffffff;
  --accent-soft: #e3f3e9;
  --ok: #137a3f;
  --ok-soft: #e3f3e9;
  --warn: #8a5a00;
  --warn-soft: #fdf3dc;
  --bad: #b3261e;
  --bad-soft: #fbe9e7;
  --info: #1d5fa8;
  --info-soft: #e5eef9;
  --bubble: #dcf8c6;
  --chat-bg: #efeae2;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 30, 25, .06), 0 2px 8px rgba(20, 30, 25, .04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1311;
    --surface: #171c19;
    --surface-2: #1e2420;
    --text: #e6ebe7;
    --muted: #97a39c;
    --line: #2a322d;
    --accent: #25b565;
    --accent-ink: #06200f;
    --accent-soft: #173524;
    --ok: #4fd08a;
    --ok-soft: #173524;
    --warn: #f0c060;
    --warn-soft: #3a2f14;
    --bad: #ff8a80;
    --bad-soft: #3d1b18;
    --info: #8ab8f0;
    --info-soft: #182a40;
    --bubble: #1f5c3a;
    --chat-bg: #0b1410;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; line-height: 1.2; margin: .15rem 0 .25rem; display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; letter-spacing: -.01em; }
h2 { font-size: 1.02rem; margin: 0; }
p { margin: 0; }
code, .mono, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88em; }
code { background: var(--surface-2); padding: .1em .35em; border-radius: 5px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.strong { font-weight: 600; color: var(--text); }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.inline { display: inline; margin: 0; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-top: 24px; padding-bottom: 64px; }

/* top bar */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 58px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); }
.brand:hover { text-decoration: none; }
.logo { width: 26px; height: 26px; border-radius: 8px; background: var(--accent); position: relative; flex: none; }
.logo::after { content: ""; position: absolute; inset: 7px 6px 7px 8px; border: 2.5px solid var(--accent-ink); border-left: 0; border-bottom: 0; transform: rotate(45deg) translate(-2px, 1px); border-radius: 1px; }
.topbar nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.topbar nav a, .linkbtn { padding: 7px 12px; border-radius: 8px; color: var(--muted); font-weight: 500; }
.topbar nav a:hover, .linkbtn:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.topbar nav a.on { color: var(--text); background: var(--surface-2); }
.linkbtn { background: none; border: 0; font: inherit; cursor: pointer; }

/* layout */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.grid-2 > .stack { gap: 20px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
@media (max-width: 820px) { .grid-2 { grid-template-columns: 1fr; } }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 20px; }
.stack > .card, .grid-2 .card { margin-bottom: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card.empty { text-align: center; padding: 48px 20px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
details.card summary { cursor: pointer; }
.msg { white-space: pre-wrap; margin: 12px 0 0; background: var(--surface-2); padding: 12px; border-radius: 8px; font-family: inherit; font-size: .95rem; }

/* forms */
label { display: flex; flex-direction: column; gap: 6px; font-weight: 500; font-size: .92rem; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line);
  border-radius: 9px; padding: 10px 12px; width: 100%; font-weight: 400;
}
textarea { resize: vertical; min-height: 90px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.hint { font-weight: 400; font-size: .82rem; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 10px; }
label.check input { width: 18px; height: 18px; accent-color: var(--accent); }
details summary { cursor: pointer; font-weight: 500; font-size: .92rem; margin-bottom: 8px; }

.drop { border: 1.5px dashed var(--line); border-radius: 10px; padding: 22px 16px; text-align: center; cursor: pointer; background: var(--surface-2); position: relative; align-items: center; }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop-title { font-weight: 600; color: var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { font: 500 .82rem ui-monospace, Menlo, Consolas, monospace; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); padding: 4px 9px; border-radius: 999px; cursor: pointer; }
.chip:hover { border-color: var(--accent); color: var(--accent); }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-family: inherit; font-weight: 600; font-size: .9rem; line-height: 1; padding: 10px 16px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.big { padding: 14px 18px; font-size: 1rem; }
.btn.small { padding: 6px 10px; font-size: .82rem; }
.btn.danger-ghost { color: var(--bad); }
.btn.danger-ghost:hover { background: var(--bad-soft); }
.btn:disabled { opacity: .6; cursor: default; }

/* alerts */
.alert { padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; font-size: .92rem; border: 1px solid transparent; }
.card .alert { margin-bottom: 0; }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.err { background: var(--bad-soft); color: var(--bad); }

/* stats */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
@media (max-width: 720px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; color: var(--text); box-shadow: var(--shadow); }
a.stat:hover { border-color: var(--accent); text-decoration: none; }
.stat.on { border-color: var(--accent); outline: 1px solid var(--accent); }
.stat-label { font-size: .82rem; color: var(--muted); font-weight: 500; }
.stat-num { font-size: 1.7rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat-num.ok { color: var(--ok); }
.stat-num.bad { color: var(--bad); }
.stat-sub { font-size: .8rem; color: var(--muted); min-height: 1.2em; }

/* progress */
.bar { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; min-width: 80px; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .4s; }
.bar.big { height: 10px; margin: 10px 0 8px; }
.progress-card { padding: 16px 20px; }

/* tables */
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.table td { padding: 11px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table.compact th, .table.compact td { padding: 8px 10px; }
.card .table.compact { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
tr.rowlink { cursor: pointer; }
tr.rowlink:hover td { background: var(--surface-2); }
.w-prog { width: 150px; }
.err-text { color: var(--bad); font-weight: 600; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .8rem; }

.table-tools { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs a { padding: 6px 11px; border-radius: 8px; color: var(--muted); font-size: .88rem; font-weight: 500; }
.tabs a:hover { background: var(--surface-2); text-decoration: none; }
.tabs a.on { background: var(--accent-soft); color: var(--accent); }
.search input { padding: 7px 11px; width: 220px; max-width: 100%; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-top: 1px solid var(--line); gap: 8px; flex-wrap: wrap; }
.pager .btn { margin-left: 6px; }

/* badges */
.badge { display: inline-block; font-size: .75rem; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; letter-spacing: 0; vertical-align: middle; }
.b-delivered, .b-read, .b-completed { background: var(--ok-soft); color: var(--ok); }
.b-accepted, .b-sent, .b-queued, .b-running, .b-sending { background: var(--info-soft); color: var(--info); }
.b-failed { background: var(--bad-soft); color: var(--bad); }
.b-paused { background: var(--warn-soft); color: var(--warn); }

/* whatsapp preview */
.phone-preview { background: var(--chat-bg); border-radius: 10px; padding: 18px 14px; min-height: 110px; }
.bubble { background: var(--bubble); color: var(--text); padding: 8px 12px 10px; border-radius: 10px 10px 10px 2px; max-width: 90%; white-space: pre-wrap; word-wrap: break-word; box-shadow: 0 1px 1px rgba(0,0,0,.08); font-size: .95rem; }

/* code */
pre.code { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: 0; white-space: pre-wrap; word-break: break-all; }
.copyable { cursor: copy; position: relative; }
.copyable::after { content: "Click to copy"; position: absolute; top: 6px; right: 8px; font: 500 .7rem system-ui, sans-serif; color: var(--muted); opacity: 0; transition: opacity .15s; }
.copyable:hover::after { opacity: 1; }
.copyable.copied::after { content: "Copied"; opacity: 1; color: var(--ok); }

/* auth */
.auth { min-height: 80vh; display: grid; place-items: center; }
.auth .card { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 14px; }
.auth-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
