/* whats.zoxo — painel do WhatsApp API */
:root {
  --bg: #f4f3ee;
  --surface: #ffffff;
  --ink: #18201b;
  --ink-2: #4b554e;
  --muted: #7a837d;
  --line: #e3e1d8;
  --line-2: #eeede6;
  --side: #13261c;
  --side-ink: #d9e6dd;
  --side-muted: #86a090;
  --accent: #1d6b45;
  --accent-ink: #ffffff;
  --accent-soft: #e3f0e8;
  --ok: #1d7a4c;
  --ok-soft: #e2f2e8;
  --warn: #9a6200;
  --warn-soft: #fbf0d9;
  --bad: #b3361f;
  --bad-soft: #fbe6e1;
  --live: #1f5fa8;
  --live-soft: #e3edf9;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(24, 32, 27, 0.05), 0 4px 16px rgba(24, 32, 27, 0.04);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 14px/1.5 var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 24px; }
h2 { font-size: 15px; }
h3 { font-size: 14px; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); font-size: 13px; }
.right { text-align: right; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ── Marca ─────────────────────────────────────────────────────────── */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; letter-spacing: -0.02em; }
.brand-dot { color: #5fc58f; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 7px; flex: none;
  background: var(--accent) url("/favicon.svg") center / cover no-repeat;
}
.brand-lg { font-size: 22px; }

/* ── Estrutura ─────────────────────────────────────────────────────── */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side {
  background: var(--side); color: var(--side-ink);
  padding: 22px 14px; display: flex; flex-direction: column; gap: 18px;
  position: sticky; top: 0; height: 100vh;
}
.side .brand { padding: 0 8px; color: #fff; }
.conn {
  display: flex; align-items: center; gap: 8px; margin: 0 8px;
  padding: 7px 10px; border-radius: 999px; font-size: 12.5px;
  background: rgba(255, 255, 255, 0.06);
}
.conn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--side-muted); flex: none; }
.conn-ok .dot { background: #4cd38a; box-shadow: 0 0 0 3px rgba(76, 211, 138, 0.18); }
.conn-warn .dot { background: #f2b54a; }
.conn-bad .dot { background: #f2735a; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  color: var(--side-ink); text-decoration: none; padding: 9px 10px; border-radius: var(--radius-sm);
  font-weight: 500; opacity: 0.82;
}
.nav a:hover { background: rgba(255, 255, 255, 0.06); opacity: 1; }
.nav a.active { background: rgba(255, 255, 255, 0.1); opacity: 1; color: #fff; }
.side-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 8px 0; border-top: 1px solid rgba(255, 255, 255, 0.08); }
.me { color: var(--side-ink); text-decoration: none; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me.active, .me:hover { color: #fff; }
.side .link-btn { color: var(--side-muted); }
.side .link-btn:hover { color: #fff; }

.main { padding: 32px 40px 60px; max-width: 1180px; width: 100%; }
.view { display: flex; flex-direction: column; gap: 20px; }
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.view-head h1 + p { margin-top: 4px; }

/* ── Cartões ───────────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card.narrow { max-width: 440px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.big { font-size: 22px; font-weight: 650; letter-spacing: -0.02em; }
.split { display: grid; grid-template-columns: 300px 1fr; gap: 16px; align-items: start; }
.split-wide { grid-template-columns: 1fr 340px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.empty { color: var(--muted); padding: 8px 0; }

.facts { margin: 4px 0 0; display: flex; flex-direction: column; gap: 10px; }
.facts dt { color: var(--muted); font-size: 12px; }
.facts dd { margin: 2px 0 0; font-weight: 600; }

/* Herói do estado */
.hero {
  display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow); border-left: 5px solid var(--muted);
}
.hero-ok { border-left-color: var(--ok); }
.hero-warn { border-left-color: #e0a12f; }
.hero-bad { border-left-color: var(--bad); }
.hero-state { display: flex; align-items: center; gap: 14px; }
.hero-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--muted); flex: none; }
.hero-ok .hero-dot { background: var(--ok); box-shadow: 0 0 0 6px var(--ok-soft); }
.hero-warn .hero-dot { background: #e0a12f; box-shadow: 0 0 0 6px var(--warn-soft); }
.hero-bad .hero-dot { background: var(--bad); box-shadow: 0 0 0 6px var(--bad-soft); }
.hero-title { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
.hero-facts { display: flex; gap: 32px; margin: 0; flex-wrap: wrap; }
.hero-facts dt { color: var(--muted); font-size: 12px; }
.hero-facts dd { margin: 2px 0 0; font-weight: 600; font-variant-numeric: tabular-nums; }

.qr-box { display: flex; align-items: center; gap: 24px; background: var(--warn-soft); border: 1px solid #efd9a6; border-radius: var(--radius); padding: 20px; }
.qr-box img { width: 220px; height: 220px; background: #fff; border-radius: var(--radius-sm); padding: 8px; }
.qr-box p { margin-top: 6px; }

.banner { padding: 12px 16px; border-radius: var(--radius-sm); }
.banner-warn { background: var(--warn-soft); color: #6d4600; border: 1px solid #efd9a6; }

/* ── Botões ────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; font-weight: 550; white-space: nowrap;
  transition: background 0.12s, border-color 0.12s;
}
.btn:hover { border-color: #cfcdc2; background: #fafaf7; }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #175a3a; border-color: #175a3a; }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-danger:hover { background: #962c18; border-color: #962c18; }
.btn-danger-ghost { color: var(--bad); }
.btn-danger-ghost:hover { background: var(--bad-soft); border-color: #efc2b8; }
.btn-block { width: 100%; padding: 11px; }
.link-btn { background: none; border: 0; padding: 0; cursor: pointer; color: var(--accent); font-weight: 550; }
.link-btn:hover { text-decoration: underline; }
.link-danger { color: var(--bad); }
.icon-btn { background: none; border: 0; font-size: 26px; line-height: 1; cursor: pointer; color: var(--muted); padding: 0 4px; }
.icon-btn:hover { color: var(--ink); }

/* ── Formulários ───────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
input[type="email"], input[type="password"], input[type="tel"], input[type="number"], input[type="search"], textarea, select {
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 9px 11px; background: #fff; width: 100%;
  outline: none; transition: border-color 0.12s, box-shadow 0.12s;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; }
.form-foot { display: flex; align-items: center; justify-content: flex-end; gap: 14px; }
.form-msg { margin-right: auto; font-size: 13px; color: var(--muted); }
.form-msg-ok { color: var(--ok); }
.form-msg-warn { color: var(--warn); }
.form-msg-err { color: var(--bad); }
.form-error { color: var(--bad); background: var(--bad-soft); padding: 9px 12px; border-radius: var(--radius-sm); font-size: 13px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); white-space: nowrap; }

.settings { gap: 0; padding: 4px 20px; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 18px 0; border-bottom: 1px solid var(--line-2); }
.settings-row h2 + p { margin-top: 2px; }
.settings-col { flex-direction: column; align-items: stretch; gap: 12px; }
.settings .form-foot { padding: 16px 0; }
.range-inputs { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.range-inputs input { width: 76px; text-align: center; }
.inline-add { display: flex; gap: 8px; max-width: 380px; }

.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 5px 6px 5px 12px; border-radius: 999px;
  background: var(--accent-soft); color: #134a30; font-family: var(--mono); font-size: 13px;
}
.chip button { border: 0; background: none; cursor: pointer; color: #3f6f55; font-size: 16px; line-height: 1; padding: 0 6px; border-radius: 50%; }
.chip button:hover { color: var(--bad); }

/* Interruptor */
.switch { position: relative; display: inline-block; flex: none; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { display: block; width: 46px; height: 26px; border-radius: 999px; background: #cfd3cf; transition: background 0.15s; position: relative; }
.switch-thumb { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2); transition: transform 0.15s; }
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(20px); }
.switch input:focus-visible + .switch-track { box-shadow: 0 0 0 3px var(--accent-soft); }

/* ── Tabelas e listas ──────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; margin: 0 -20px; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 8px 20px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 11px 20px; border-bottom: 1px solid var(--line-2); vertical-align: top; white-space: nowrap; }
.table th.num, .table td.num { text-align: right; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fbfbf8; }
.clip { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-bad { background: var(--bad-soft); color: var(--bad); }
.pill-live { background: var(--live-soft); color: var(--live); }
.pill-muted { background: #efeee8; color: var(--ink-2); }
.tag { font-family: var(--font); font-size: 11px; background: #efeee8; border-radius: 4px; padding: 1px 6px; margin-left: 4px; }

.list-card { padding: 8px; }
.pick-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.pick-list button {
  width: 100%; text-align: left; background: none; border: 0; padding: 10px 12px; border-radius: var(--radius-sm);
  cursor: pointer; display: flex; flex-direction: column; gap: 2px;
}
.pick-list button:hover { background: #f6f5f0; }
.pick-list button.active { background: var(--accent-soft); }

.memories { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.memories li { padding: 14px 0; border-top: 1px solid var(--line-2); display: flex; flex-direction: column; gap: 6px; }
.mem-meta { display: flex; align-items: center; gap: 14px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.mem-meta .link-btn { font-size: 12.5px; }
.mem-meta .link-btn:first-of-type { margin-left: auto; }
.mem-title { font-weight: 600; }
.memories p { color: var(--ink-2); max-width: 70ch; }

.plain-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.plain-list li { display: flex; justify-content: space-between; gap: 12px; }

.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat-n { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.stat-l { color: var(--muted); font-size: 12.5px; }
.stat-bad .stat-n { color: var(--bad); }

/* ── Logs ──────────────────────────────────────────────────────────── */
.view-logs { height: calc(100vh - 92px); }
.log-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.log-tools input[type="search"] { width: 200px; }
.log-tools select { width: auto; }
.terminal {
  flex: 1; min-height: 320px; overflow: auto; background: #0f1712; color: #cfdcd3; border-radius: var(--radius);
  padding: 14px 16px; font: 12.5px/1.55 var(--mono);
}
.log { display: grid; grid-template-columns: 70px 52px 1fr; gap: 10px; padding: 1px 0; }
.log-t { color: #6f8578; }
.log-l { font-weight: 700; color: #7fb595; }
.log-m { white-space: pre-wrap; word-break: break-word; }
.log-ctx { color: #7f9688; }
.log-warn .log-l { color: #f0b94e; }
.log-error .log-l, .log-fatal .log-l { color: #ff7d66; }
.log-error .log-m, .log-fatal .log-m { color: #ffc2b7; }
.log-debug .log-l { color: #6f8578; }
.log-raw .log-m { color: #8ba596; }
.log-d { grid-column: 3; margin: 2px 0 6px; color: #8ba596; white-space: pre-wrap; word-break: break-word; font: inherit; }

/* ── Conversa (gaveta) ─────────────────────────────────────────────── */
dialog { border: 0; padding: 0; color: var(--ink); }
dialog::backdrop { background: rgba(14, 22, 17, 0.45); }
.drawer {
  margin: 0 0 0 auto; height: 100vh; max-height: 100vh; width: min(560px, 100vw);
  display: flex; flex-direction: column; background: var(--bg); box-shadow: -8px 0 32px rgba(0, 0, 0, 0.15);
}
.drawer:not([open]) { display: none; }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 22px 24px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.drawer-body { padding: 20px 24px 40px; overflow-y: auto; display: flex; flex-direction: column; gap: 18px; }
.summary { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.summary p { margin-top: 6px; color: var(--ink-2); }
.transcript { display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 86%; padding: 10px 13px; border-radius: 14px; }
.msg-ai { background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; align-self: flex-start; }
.msg-user { background: var(--accent-soft); border-bottom-right-radius: 4px; align-self: flex-end; }
.msg-who { font-size: 11.5px; color: var(--muted); font-weight: 600; margin-bottom: 2px; }
.msg-text { white-space: pre-wrap; word-break: break-word; }

.confirm { border-radius: var(--radius); width: min(420px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25); }
.confirm form { padding: 22px; display: flex; flex-direction: column; gap: 10px; }
.confirm h2 { font-size: 17px; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 50;
  padding: 11px 18px; border-radius: 999px; background: var(--ink); color: #fff; font-weight: 550;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}
.toast-err { background: var(--bad); }

/* ── Login ─────────────────────────────────────────────────────────── */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--side); }
.login-card {
  width: min(380px, 100%); background: var(--surface); border-radius: 16px; padding: 32px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.35); display: flex; flex-direction: column; gap: 6px;
}
.login-card .brand-dot { color: var(--accent); }
.login-sub { color: var(--muted); margin-bottom: 18px; }
.login-card form { display: flex; flex-direction: column; gap: 14px; }

/* ── Telas menores ─────────────────────────────────────────────────── */
@media (max-width: 1000px) {
  .grid-3 { grid-template-columns: 1fr; }
  .split, .split-wide { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; padding: 14px; gap: 12px; min-width: 0; }
  .nav { flex-direction: row; overflow-x: auto; }
  .nav a { white-space: nowrap; }
  .side-foot { margin-top: 0; }
  .main { padding: 20px 16px 48px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .settings-row { flex-direction: column; align-items: flex-start; }
  .view-logs { height: auto; }
  .terminal { height: 70vh; }
  .log { grid-template-columns: 62px 1fr; }
  .log-l { display: none; }
  .log-d { grid-column: 2; }
  .qr-box { flex-direction: column; align-items: flex-start; }
}
