:root {
  color-scheme: light;
  --bg: #f4f4f2;
  --surface: #fcfcfb;
  --surface-2: #f0efeb;
  --border: #e1e0d9;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #898781;
  --accent: #2a78d6;
  --accent-hover: #1f66bd;
  --accent-soft: rgba(42, 120, 214, 0.1);
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --good: #0ca30c;
  --good-text: #006300;
  --warning: #fab219;
  --warning-text: #7a5000;
  --critical: #d03b3b;
  --critical-text: #b02a2a;
  --bubble-in: #ffffff;
  --bubble-bot: #e8f1fc;
  --bubble-human: #e7f5e7;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.04);
  --radius: 10px;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --bg: #121211;
    --surface: #1a1a19;
    --surface-2: #242422;
    --border: #2c2c2a;
    --text: #ffffff;
    --text-2: #c3c2b7;
    --muted: #898781;
    --accent: #3987e5;
    --accent-hover: #5a9cec;
    --accent-soft: rgba(57, 135, 229, 0.16);
    --grid: #2c2c2a;
    --baseline: #383835;
    --good-text: #0ca30c;
    --warning-text: #fab219;
    --critical-text: #e66767;
    --bubble-in: #242422;
    --bubble-bot: #1c2a3d;
    --bubble-human: #1c301c;
    --shadow: none;
  }
}
:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #121211;
  --surface: #1a1a19;
  --surface-2: #242422;
  --border: #2c2c2a;
  --text: #ffffff;
  --text-2: #c3c2b7;
  --muted: #898781;
  --accent: #3987e5;
  --accent-hover: #5a9cec;
  --accent-soft: rgba(57, 135, 229, 0.16);
  --grid: #2c2c2a;
  --baseline: #383835;
  --good-text: #0ca30c;
  --warning-text: #fab219;
  --critical-text: #e66767;
  --bubble-in: #242422;
  --bubble-bot: #1c2a3d;
  --bubble-human: #1c301c;
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }
[hidden] { display: none !important; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
.muted { color: var(--text-2); }
.small { font-size: 12px; }
code, pre { font-family: ui-monospace, 'Cascadia Code', Consolas, monospace; font-size: 12px; }
pre { white-space: pre-wrap; background: var(--surface-2); padding: 12px; border-radius: 8px; max-height: 60vh; overflow: auto; margin: 0; }

/* ---------- Formulários ---------- */
label { display: flex; flex-direction: column; gap: 6px; font-weight: 500; color: var(--text-2); font-size: 13px; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 9px 11px; width: 100%;
}
textarea { resize: vertical; min-height: 84px; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
.check input { width: auto; }
.hint { font-weight: 400; color: var(--muted); font-size: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-error { color: var(--critical-text); min-height: 1em; margin: 0; font-size: 13px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }

.btn {
  font: inherit; font-weight: 500; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; white-space: nowrap;
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { color: var(--critical-text); }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn-link { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }

/* ---------- Login ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 28px; display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow);
}
.login-card p { margin: 0; }
.login-alt { display: flex; flex-direction: column; gap: 14px; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.divider::before, .divider::after { content: ''; flex: 1; border-top: 1px solid var(--border); }
.btn-google { gap: 10px; }
.btn-google svg { flex-shrink: 0; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100%; }
.sidebar {
  width: 240px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; padding: 18px 16px; }
.brand-lg { padding: 0; font-size: 18px; }
.brand-mark {
  background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; letter-spacing: 0.04em;
  border-radius: 7px; padding: 6px 6px; line-height: 1;
}
.nav { display: flex; flex-direction: column; padding: 4px 8px; gap: 1px; overflow-y: auto; flex: 1; }
.nav a {
  display: flex; align-items: center; justify-content: space-between; padding: 6px 10px; border-radius: 8px;
  color: var(--text-2); text-decoration: none; font-weight: 500;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding: 12px 10px 2px; }
.nav-badge { background: var(--critical); color: #fff; font-size: 11px; border-radius: 999px; padding: 0 7px; line-height: 18px; }
.sidebar-footer { border-top: 1px solid var(--border); padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; }
.user-line { display: flex; gap: 10px; align-items: center; font-size: 13px; }
.user-line span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-pill { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
.dot.good { background: var(--good); }
.dot.warning { background: var(--warning); }
.dot.critical { background: var(--critical); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 18px 28px 0; }
.menu-btn { display: none; background: none; border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: 16px; padding: 4px 10px; cursor: pointer; }
.view > :empty { display: none; }
.view { padding: 18px 28px 40px; display: flex; flex-direction: column; gap: 18px; max-width: 1280px; width: 100%; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head p { margin: 2px 0 0; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar input, .toolbar select { width: auto; min-width: 180px; }

/* ---------- Banners de status ---------- */
.banner { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); flex-wrap: wrap; }
.banner strong { font-weight: 600; }
.banner .spacer { flex: 1; }
.status-label { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; font-size: 13px; }
.status-label::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.status-label.good { color: var(--good-text); }
.status-label.good::before { background: var(--good); }
.status-label.warning { color: var(--warning-text); }
.status-label.warning::before { background: var(--warning); }
.status-label.critical { color: var(--critical-text); }
.status-label.critical::before { background: var(--critical); }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi-label { color: var(--text-2); font-size: 13px; }
.kpi-value { font-size: 26px; font-weight: 600; margin-top: 4px; letter-spacing: -0.02em; }
.kpi-note { color: var(--muted); font-size: 12px; }

/* ---------- Gráfico ---------- */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .base { stroke: var(--baseline); stroke-width: 1; }
.chart .bar { fill: var(--accent); transition: opacity 0.1s; }
.chart .bar.dim { opacity: 0.75; }
.chart .value-label { fill: var(--text); font-size: 12px; font-weight: 600; }
.chart .hit { fill: transparent; cursor: default; outline: none; }
.chart-tip {
  position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 10px; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12); font-size: 12px; white-space: nowrap;
  transform: translate(-50%, calc(-100% - 8px));
}
.chart-tip strong { display: block; font-size: 14px; color: var(--text); }
.chart-tip span { color: var(--text-2); }

/* ---------- Tabelas ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; font-weight: 600; color: var(--text-2); background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
td select { width: auto; padding: 4px 8px; }
td .toolbar { flex-wrap: nowrap; }
.cell-strong { font-weight: 600; }
.clamp { max-width: 360px; white-space: pre-wrap; }
.empty { text-align: center; color: var(--muted); padding: 32px 12px; }

.tag { display: inline-block; font-size: 12px; font-weight: 500; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.tag.critical { color: var(--critical-text); }
.tag.warning { color: var(--warning-text); }
.tag.good { color: var(--good-text); }
.tag.accent { color: var(--accent); background: var(--accent-soft); border-color: transparent; }

/* ---------- WhatsApp ---------- */
.wa-connect { display: grid; grid-template-columns: 340px 1fr; gap: 24px; align-items: start; }
.qr-box { background: #fff; border-radius: 12px; padding: 10px; border: 1px solid var(--border); width: 100%; max-width: 340px; aspect-ratio: 1; display: grid; place-items: center; }
.qr-box img { width: 100%; height: auto; }
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.pairing-code { font-family: ui-monospace, Consolas, monospace; font-size: 28px; letter-spacing: 0.12em; font-weight: 700; }

/* ---------- Conversas ---------- */
.chat-layout { display: grid; grid-template-columns: 320px 1fr; gap: 0; height: calc(100vh - 150px); min-height: 480px; padding: 0; overflow: hidden; }
.chat-list { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.chat-list-head { padding: 12px; display: flex; flex-direction: column; gap: 8px; border-bottom: 1px solid var(--border); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font: inherit; font-size: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); padding: 3px 10px; border-radius: 999px; cursor: pointer; }
.chip.active { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.chat-items { overflow-y: auto; flex: 1; }
.chat-item { display: block; width: 100%; text-align: left; font: inherit; color: inherit; background: none; border: 0; border-bottom: 1px solid var(--border); padding: 10px 12px; cursor: pointer; }
.chat-item:hover { background: var(--surface-2); }
.chat-item.active { background: var(--accent-soft); }
.chat-item-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.chat-item-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item-time { font-size: 11px; color: var(--muted); flex-shrink: 0; }
.chat-item-last { font-size: 13px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item-tags { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; }
.unread { background: var(--accent); color: #fff; border-radius: 999px; font-size: 11px; padding: 0 7px; line-height: 18px; }
.chat-thread { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.thread-head { padding: 12px 16px; border-bottom: 1px solid var(--border); display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.thread-head .who { flex: 1; min-width: 160px; }
.thread-head .who div:first-child { font-weight: 600; }
.thread-notice { padding: 8px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); font-size: 13px; }
.messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; background: var(--bg); }
.msg { max-width: min(78%, 560px); padding: 8px 12px; border-radius: 12px; white-space: pre-wrap; word-wrap: break-word; border: 1px solid var(--border); }
.msg.in { align-self: flex-start; background: var(--bubble-in); border-bottom-left-radius: 4px; }
.msg.out { align-self: flex-end; border-bottom-right-radius: 4px; }
.msg.bot { background: var(--bubble-bot); }
.msg.human { background: var(--bubble-human); }
.msg-meta { font-size: 11px; color: var(--muted); margin-top: 4px; display: flex; gap: 8px; justify-content: flex-end; }
.composer { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); }
.composer textarea { min-height: 44px; height: 44px; }
.thread-empty { flex: 1; display: grid; place-items: center; color: var(--muted); padding: 24px; text-align: center; }

/* ---------- Playground ---------- */
.playground { display: flex; flex-direction: column; height: calc(100vh - 170px); min-height: 460px; padding: 0; overflow: hidden; }
.playground .messages { border-radius: 0; }

/* ---------- Modal e toast ---------- */
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.4); display: grid; place-items: center; padding: 16px; z-index: 20; }
.modal-card { background: var(--surface); border-radius: 14px; border: 1px solid var(--border); width: 100%; max-width: 640px; max-height: calc(100vh - 32px); overflow: auto; padding: 20px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--surface); padding: 10px 16px; border-radius: 10px; z-index: 30; max-width: calc(100vw - 32px); }

/* ---------- Responsivo ---------- */
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 15; transform: translateX(-100%); transition: transform 0.2s; box-shadow: 0 0 40px rgba(0, 0, 0, 0.2); }
  .sidebar.open { transform: none; }
  .menu-btn { display: inline-block; }
  .topbar { padding: 14px 16px 0; }
  .view { padding: 14px 16px 32px; }
  .wa-connect { grid-template-columns: 1fr; }
  .chat-layout { grid-template-columns: 1fr; height: auto; }
  .chat-list { border-right: 0; max-height: 40vh; }
  .chat-layout.has-thread .chat-list { display: none; }
  .chat-thread { height: calc(100vh - 140px); }
  .form-grid { grid-template-columns: 1fr; }
  .toolbar input, .toolbar select { min-width: 0; flex: 1; }
}

/* ---------- Canal de conexão ---------- */
.stack { display: flex; flex-direction: column; gap: 18px; }

.questionnaire-editor { border-top: 1px solid var(--border); padding-top: 18px; display: flex; flex-direction: column; gap: 12px; }
.questionnaire-heading, .questionnaire-row-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.questionnaire-row { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 8px; background: var(--surface-2); }
.questionnaire-row-fields { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.questionnaire-row-fields select { width: auto; }
.questionnaire-row [data-question-options] { margin: 0; }
.questionnaire-row [data-question-options][hidden] { display: none; }
.btn-link.danger { color: var(--critical-text); }
@media (max-width: 640px) { .questionnaire-heading { flex-direction: column; } }
.sep { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }
.channel-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.channel {
  flex-direction: row; align-items: flex-start; gap: 10px; padding: 14px; border: 1px solid var(--border);
  border-radius: var(--radius); cursor: pointer; color: var(--text); font-weight: 400;
}
.channel input { width: auto; margin-top: 3px; }
.channel > span { display: flex; flex-direction: column; gap: 4px; }
.channel:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
@media (max-width: 900px) { .channel-options { grid-template-columns: 1fr; } }

/* ---------- Fluxo inicial ---------- */
.flow-layout { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.label-text { font-weight: 500; color: var(--text-2); font-size: 13px; }
.flow-options-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.flow-options { display: flex; flex-direction: column; gap: 10px; }
.flow-option { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); }
.flow-num { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 13px; margin-top: 6px; }
.flow-fields { display: flex; flex-direction: column; gap: 6px; }
.flow-fields textarea { min-height: 76px; }
.flow-actions { display: flex; flex-direction: column; gap: 4px; }
.wa-preview { background: #e5ddd5; border-radius: 12px; padding: 16px; position: sticky; top: 16px; }
.wa-bubble { background: #fff; color: #111; border-radius: 10px 10px 10px 2px; padding: 10px 12px; white-space: pre-wrap; font-size: 14px; line-height: 1.45; box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1); max-width: 360px; }
.wa-bubble.muted { color: #555; }
:root[data-theme='dark'] .wa-preview { background: #0b141a; }
:root[data-theme='dark'] .wa-bubble { background: #202c33; color: #e9edef; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .wa-preview { background: #0b141a; }
  :root:not([data-theme='light']) .wa-bubble { background: #202c33; color: #e9edef; }
}
@media (max-width: 900px) { .flow-layout { grid-template-columns: 1fr; } .wa-preview { position: static; } }

/* ---------- Escala sequencial (mapa de calor) ---------- */
:root {
  --s0: var(--surface-2);
  --s1: #dbe9fb; --s2: #b7d3f6; --s3: #8dbaf0; --s4: #5f9de8; --s5: #3a84dc; --s6: #2a6dc0; --s7: #1d5299;
}
:root[data-theme='dark'] {
  --s1: #1c2d45; --s2: #1f3d63; --s3: #245086; --s4: #2a65aa; --s5: #3a7fd0; --s6: #6aa2e6; --s7: #a5c8f2;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --s1: #1c2d45; --s2: #1f3d63; --s3: #245086; --s4: #2a65aa; --s5: #3a7fd0; --s6: #6aa2e6; --s7: #a5c8f2;
  }
}

/* ---------- Utilitários ---------- */
.center { text-align: center; }
.spacer { flex: 1; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; margin: 6px 0 -8px; }
.big-number { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; }
a.kpi { color: inherit; text-decoration: none; transition: border-color 0.1s; }
a.kpi:hover { border-color: var(--accent); }
label.inline { flex-direction: row; align-items: center; gap: 6px; font-weight: 400; }
label.inline input { width: auto; }
.nav-badge.calm { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
table.compact th, table.compact td { padding: 6px 8px; font-size: 12px; }
tr.row-link { cursor: pointer; }
tr.row-link:hover td { background: var(--surface-2); }
.chip-sep { width: 1px; background: var(--border); margin: 0 4px; align-self: stretch; }
.chip-check { flex-direction: row; font-weight: 400; border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px; }
.chip-check:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; flex-wrap: wrap; }
.segmented button { font: inherit; font-size: 13px; background: var(--surface); color: var(--text-2); border: 0; border-right: 1px solid var(--border); padding: 6px 12px; cursor: pointer; }
.segmented button:last-child { border-right: 0; }
.segmented button:hover { background: var(--surface-2); }
.segmented button.active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }

/* ---------- Cadastro público ---------- */
.signup { min-height: 100%; padding: 32px 16px 48px; }
.signup-inner { max-width: 880px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.signup-inner h1 { font-size: 26px; letter-spacing: -0.02em; }
.signup-inner > p { margin: 0; }
.hp { position: absolute !important; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.plan-card {
  font: inherit; text-align: left; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 8px; box-shadow: var(--shadow);
}
button.plan-card { cursor: pointer; }
.plan-card.selected, .plan-card.current { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.plan-name { font-weight: 600; }
.plan-price { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; }
.plan-price small { font-size: 13px; font-weight: 400; color: var(--text-2); }
.plan-features { margin: 0; padding-left: 18px; color: var(--text-2); display: flex; flex-direction: column; gap: 4px; flex: 1; }
.plan-card .btn, .plan-card .status-label { align-self: flex-start; }

/* ---------- Estrutura do painel ---------- */
.tenant-switch { padding: 0 16px 10px; }
.tenant-switch select { padding: 6px 8px; }
.support-banner { background: var(--warning); color: #231900; padding: 8px 28px; font-size: 13px; }
.support-banner .btn-link { color: #231900; text-decoration: underline; font-weight: 600; }
.tenant-chip { display: inline-flex; align-items: center; gap: 10px; }
.tenant-chip a { text-decoration: none; }

/* ---------- Primeiros passos ---------- */
.checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.checklist li { display: flex; align-items: center; gap: 10px; }
.checklist li.done { color: var(--muted); text-decoration: line-through; }
.check-dot { width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--border); display: grid; place-items: center; font-size: 12px; font-weight: 600; flex-shrink: 0; color: var(--text-2); }
.checklist li.done .check-dot { background: var(--good); border-color: var(--good); color: #fff; }

/* ---------- Fila de atendimento ---------- */
.queue-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.queue-title { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.queue-card { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; }
.queue-card.late { border-color: var(--critical); }
.queue-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.queue-card p { margin: 0; }
.last-msg { color: var(--text-2); overflow-wrap: anywhere; }

/* ---------- Funil (kanban) ---------- */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; align-items: start; }
.kanban-col { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 160px; }
.kanban-col header { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; padding: 2px 4px; }
.kanban-col.over { border-color: var(--accent); background: var(--accent-soft); }
.kanban-cards { display: flex; flex-direction: column; gap: 8px; }
.kanban-card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px; display: flex; flex-direction: column; gap: 4px; cursor: grab; box-shadow: var(--shadow); }
.kanban-card.dragging { opacity: 0.5; }
.kanban-meta { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; font-variant-numeric: tabular-nums; }
.kanban-move { padding: 3px 6px; font-size: 12px; margin-top: 4px; }
.empty-col { text-align: center; padding: 12px 0; margin: 0; }

/* ---------- Ficha, histórico e tarefas ---------- */
.profile { align-items: start; }
.timeline { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.timeline li { padding: 8px 10px; border-left: 2px solid var(--border); display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
.timeline li input { width: auto; }
.timeline li.done { color: var(--muted); }
.task-group { margin: 16px 0 8px; display: flex; gap: 8px; align-items: baseline; }
.task-group:first-child { margin-top: 0; }
.task-group.late { color: var(--critical-text); }
.tasks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.tasks li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 10px 4px; border-bottom: 1px solid var(--border); }
.tasks li:last-child { border-bottom: 0; }
.tasks li input { width: auto; margin-top: 4px; }
.tasks li.done strong { text-decoration: line-through; color: var(--muted); }

/* ---------- Relatórios ---------- */
.report-filter { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.export-menu { position: relative; }
.export-menu summary { list-style: none; }
.export-menu summary::-webkit-details-marker { display: none; }
.export-list { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12); padding: 6px; display: flex; flex-direction: column; min-width: 230px; z-index: 5; }
.export-list a { padding: 8px 10px; border-radius: 6px; text-decoration: none; color: var(--text); }
.export-list a:hover { background: var(--surface-2); }

.heatmap { display: grid; grid-template-columns: 36px repeat(24, minmax(0, 1fr)); gap: 2px; }
.hm-hour { font-size: 10px; color: var(--muted); text-align: left; }
.hm-day { font-size: 12px; color: var(--text-2); align-self: center; }
.hm-cell { aspect-ratio: 1; min-height: 12px; border-radius: 3px; background: var(--s0); outline: none; }
.heatmap .hm-cell:focus-visible { outline: 2px solid var(--text); outline-offset: 1px; }
.hm-cell.s1 { background: var(--s1); }
.hm-cell.s2 { background: var(--s2); }
.hm-cell.s3 { background: var(--s3); }
.hm-cell.s4 { background: var(--s4); }
.hm-cell.s5 { background: var(--s5); }
.hm-cell.s6 { background: var(--s6); }
.hm-cell.s7 { background: var(--s7); }
.hm-legend { display: flex; align-items: center; gap: 3px; margin-top: 10px; font-size: 11px; color: var(--muted); justify-content: flex-end; }
.hm-legend i { width: 14px; min-height: 14px; display: inline-block; }
.hm-legend span { margin: 0 4px; }

.hbars { display: flex; flex-direction: column; gap: 10px; }
.hbar-row { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.hbar-label { font-size: 13px; color: var(--text); overflow: hidden; text-overflow: ellipsis; }
.hbar-track { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.hbar-fill { height: 100%; background: var(--accent); border-radius: 999px; }
.hbar-value { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 13px; text-align: right; }

.meter { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.meter-fill { height: 100%; background: var(--good); border-radius: 999px; }
.meter.warning .meter-fill { background: var(--warning); }
.meter.critical .meter-fill { background: var(--critical); }
.meter-text { margin-top: 8px; font-size: 13px; color: var(--text-2); }
.meter-text strong { color: var(--text); font-size: 16px; }

/* ---------- Horários ---------- */
.hours-grid { display: flex; flex-direction: column; gap: 6px; }
.hours-row { display: grid; grid-template-columns: 120px 1fr auto 1fr; gap: 8px; align-items: center; }
.hours-row input[type='time'] { padding: 6px 8px; }
.hours-row:has(input[data-f='open']:not(:checked)) input[type='time'] { opacity: 0.45; }

@media (max-width: 900px) {
  .grid-2, .queue-cols { grid-template-columns: 1fr; }
  .support-banner { padding: 8px 16px; }
  .topbar { flex-wrap: wrap; }
  .tenant-chip { width: 100%; }
  .hbar-row { grid-template-columns: minmax(0, 1fr) auto; }
  .hbar-track { grid-column: 1 / -1; grid-row: 2; }
  .hours-row { grid-template-columns: 1fr 1fr auto 1fr; }
  .hours-row label { grid-column: 1 / -1; }
  .heatmap { grid-template-columns: 28px repeat(24, minmax(0, 1fr)); gap: 1px; }
  .hm-hour { font-size: 8px; }
  .report-filter .spacer { display: none; }
  .export-list { left: 0; right: auto; }
}

/* ---------- Telas públicas: login, nova senha, convite ---------- */
.login-card h2 { font-size: 18px; }
.label-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.label-row a { font-weight: 400; }
.stack-sm { display: flex; flex-direction: column; gap: 12px; }

/* ---------- Cadastro com checkout ---------- */
.signup-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.step-title { display: flex; align-items: center; gap: 10px; font-size: 16px; margin-bottom: 12px; }
.step-num { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 13px; font-weight: 600; flex-shrink: 0; }
.plan-card { position: relative; }
.plan-card.featured { background: linear-gradient(180deg, var(--accent-soft), transparent 70%), var(--surface); }
.plan-badge { position: absolute; top: -10px; right: 12px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 600; padding: 2px 10px; border-radius: 999px; }
.signup-summary { display: flex; flex-direction: column; gap: 10px; position: sticky; bottom: 12px; z-index: 2; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12); }
.signup-summary .btn { align-self: flex-end; }
.summary-line { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 16px; }
.summary-line strong small, .plan-price small { font-size: 13px; font-weight: 400; color: var(--text-2); }

/* ---------- Aviso de pagamento ---------- */
.pay-banner { display: flex; align-items: center; gap: 12px; padding: 10px 28px; font-size: 13px; flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.pay-banner > span { flex: 1; min-width: 240px; }
.pay-banner.warning { background: color-mix(in srgb, var(--warning) 18%, var(--surface)); }
.pay-banner.critical { background: color-mix(in srgb, var(--critical) 14%, var(--surface)); }

/* ---------- Checkout ---------- */
.checkout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.checkout h2 { margin-bottom: 12px; }
.checkout-pay { display: flex; flex-direction: column; gap: 12px; align-items: stretch; }
.pix-qr { align-self: center; width: 220px; height: 220px; border-radius: 12px; background: #fff; padding: 8px; border: 1px solid var(--border); image-rendering: pixelated; }
.checkout-pay textarea { min-height: 72px; font-family: ui-monospace, Consolas, monospace; font-size: 12px; word-break: break-all; }
.waiting-line { display: flex; align-items: center; gap: 10px; color: var(--text-2); font-size: 13px; margin: 4px 0 0; }
.pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--warning); flex-shrink: 0; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.35; transform: scale(0.8); } }
@media (prefers-reduced-motion: reduce) { .pulse { animation: none; } }
.checkout-done { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 40px 18px; }
.done-mark { width: 56px; height: 56px; border-radius: 50%; background: var(--good); color: #fff; display: grid; place-items: center; font-size: 28px; font-weight: 700; }
.center-row { justify-content: center; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; min-width: 0; }

/* ---------- Barra inferior no celular ---------- */
.tabbar { display: none; }
@media (max-width: 900px) {
  .pay-banner { padding: 10px 16px; }
  .checkout { grid-template-columns: 1fr; }
  .checkout-pay { order: -1; }
  .tabbar {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; left: 0; right: 0; bottom: 0; z-index: 12;
    background: var(--surface); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar a, .tabbar button {
    position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px 7px;
    font: inherit; font-size: 11px; color: var(--text-2); text-decoration: none; background: none; border: 0; cursor: pointer; min-height: 56px; justify-content: center;
  }
  .tabbar a.active { color: var(--accent); }
  .tab-icon { font-size: 18px; line-height: 1; }
  .tab-badge { position: absolute; top: 5px; left: calc(50% + 6px); background: var(--critical); color: #fff; font-size: 10px; border-radius: 999px; padding: 0 5px; line-height: 16px; min-width: 16px; text-align: center; }
  .view { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
  .chat-thread { height: calc(100vh - 196px); }
  .playground { height: calc(100vh - 226px); }
  .toast { bottom: calc(72px + env(safe-area-inset-bottom)); }
  .signup-summary .btn { align-self: stretch; }
}
.login-redesign { min-height:100vh; grid-template-columns:1fr 1fr; padding:0; background:#f7f9ff; color:#182752; font-family:'Trebuchet MS','Segoe UI',sans-serif; }
.login-story { align-self:stretch; min-height:100vh; padding:48px 9%; background:#2548ed; color:white; display:flex; flex-direction:column; position:relative; overflow:hidden; }
.login-wordmark { display:flex; align-items:center; gap:12px; color:white; font-size:30px; font-weight:700; letter-spacing:-1px; text-decoration:none; }
.login-wordmark img { border:1px solid #8299ff; border-radius:13px; }
.login-story-copy { margin-top:clamp(55px,9vh,100px); position:relative; z-index:1; }
.login-story-copy>p:first-child { color:#dce5ff; font-size:13px; margin-bottom:24px; }
.login-story-copy h1 { font-size:clamp(34px,3.7vw,57px); line-height:1.08; letter-spacing:-2px; margin:0 0 24px; color:white; }
.login-story-copy>p:last-child { color:#e1e7ff; max-width:360px; line-height:1.7; font-size:15px; }
.login-illustration { margin:35px 0 55px; padding:22px 25px; background:#ffc5ab; color:#182752; border-radius:16px; transform:rotate(-3deg); max-width:350px; align-self:center; }
.login-illustration>span { font-size:11px; font-weight:bold; }
.login-illustration>p { font-size:18px; line-height:1.45; margin:10px 0 16px; }
.login-illustration>div { background:white; padding:18px; border-radius:12px; margin-right:-40px; transform:rotate(5deg); font-size:15px; }
.login-story-footer { margin-top:auto; font-size:11px; color:#dce5ff; }
.login-access { width:100%; min-height:100vh; padding:48px clamp(28px,6vw,90px) 28px; display:flex; flex-direction:column; align-items:center; }
.login-back { align-self:flex-end; font-size:12px; color:#56627c; text-decoration:none; }
.login-redesign .login-card { width:100%; max-width:420px; margin:auto 0; padding:55px 0; background:transparent; border:0; box-shadow:none; gap:23px; border-radius:0; }
.login-welcome h2 { font-size:32px; line-height:1.15; letter-spacing:-1.1px; margin:0 0 15px; color:#182752; }
.login-welcome p { font-size:14px; line-height:1.7; color:#56627c; max-width:360px; }
.login-welcome { margin-bottom:12px; }
.login-redesign label { color:#182752; font-size:13px; gap:9px; }
.login-redesign input { border:1px solid #cdd7eb; border-radius:9px; background:white; min-height:52px; padding:13px 15px; color:#182752; }
.login-redesign input:focus { outline:3px solid #2548ed26; border-color:#2548ed; }
.login-redesign .btn-primary { background:#2548ed; border-color:#2548ed; min-height:52px; border-radius:9px; font-size:14px; }
.login-redesign .btn-primary:hover { background:#1838cd; }
.login-redesign .label-row a,.login-redesign #signup-link a { color:#2548ed; font-weight:600; }
.login-redesign #signup-link { padding-top:8px; font-size:13px; line-height:1.7; }
.login-redesign #login-error:empty { display:none; }
.login-access-footer { color:#56627c; font-size:11px; text-align:center; }
.login-mobile-brand { display:none; }
.login-redesign a:focus-visible { outline:3px solid #d76435; outline-offset:5px; }
@media(max-width:760px){.login-redesign{grid-template-columns:1fr}.login-story{display:none}.login-access{padding:25px 25px 20px}.login-redesign .login-card{padding:40px 0;gap:23px}.login-mobile-brand{display:block;color:#2548ed;font-size:30px;font-weight:bold;letter-spacing:-1px;margin-bottom:12px}.login-welcome h2{font-size:30px}.login-access-footer{max-width:260px}}
.dashboard-home { display:flex; flex-direction:column; gap:24px; font-family:'Trebuchet MS','Segoe UI',sans-serif; }
.dashboard-welcome { display:flex; align-items:center; justify-content:space-between; gap:24px; padding:10px 0 6px; }
.dashboard-welcome h2 { font-size:clamp(26px,3vw,38px); line-height:1.15; letter-spacing:-1.2px; margin:7px 0 12px; }
.dashboard-welcome p { margin:0; color:var(--muted); font-size:14px; }
.dashboard-welcome .dashboard-eyebrow { color:var(--accent-text,var(--accent)); font-size:12px; }
.dashboard-welcome .btn-primary { background:#2548ed; border-color:#2548ed; color:white; padding:13px 20px; border-radius:9px; white-space:nowrap; }
.dashboard-home .kpis { grid-template-columns:repeat(3,minmax(0,1fr)); gap:16px; }
.dashboard-home .kpi { position:relative; padding:22px 24px; border-radius:14px; box-shadow:none; border:1px solid var(--border); background:var(--surface); text-decoration:none; transition:border-color .18s; }
.dashboard-home .kpi:hover { border-color:#8299ff; }
.dashboard-home .kpi:first-child { background:#2548ed; color:white; border-color:#2548ed; }
.dashboard-home .kpi:first-child .kpi-label,.dashboard-home .kpi:first-child .kpi-note { color:#e1e7ff; }
.dashboard-home .kpi:after { content:'↗'; position:absolute; right:22px; top:22px; opacity:.65; }
.dashboard-home .kpi-value { font-size:39px; line-height:1.2; font-weight:700; letter-spacing:-1.5px; padding:12px 0 8px; }
.dashboard-home .kpi-label { font-size:13px; padding-right:25px; }
.dashboard-home .kpi-note { font-size:12px; }
.dashboard-columns { display:grid; grid-template-columns:minmax(0,2fr) minmax(240px,1fr); gap:24px; }
.dashboard-home .card { border-radius:14px; box-shadow:none; padding:25px; }
.dashboard-home .card-head h2 { font-size:17px; letter-spacing:-.3px; }
.dashboard-chart { min-width:0; }
.dashboard-home .chart { min-height:240px; }
.dashboard-shortcuts { background:#e9eeff; color:#182752; padding:27px; border-radius:14px; display:flex; flex-direction:column; }
.dashboard-shortcuts h2 { font-size:21px; margin:0 0 8px; letter-spacing:-.5px; }
.dashboard-shortcuts p { color:#56627c; font-size:13px; margin:0 0 20px; }
.dashboard-shortcuts a { display:flex; align-items:center; justify-content:space-between; gap:15px; padding:15px 0; border-bottom:1px solid #ccd6f3; text-decoration:none; color:#182752; font-size:14px; }
.dashboard-shortcuts a:hover { color:#2548ed; }
.dashboard-shortcuts-note { font-size:11px; color:#56627c; margin-top:auto; padding-top:24px; }
.dashboard-home .banner { border-radius:10px; padding:15px 18px; font-size:13px; }
.dashboard-home #dash-alerts:empty,.dashboard-home #dash-onboarding:empty { display:none; }
.dashboard-home .checklist { display:grid; grid-template-columns:1fr 1fr; gap:10px 24px; }
@media(max-width:1050px){.dashboard-columns{grid-template-columns:1fr}.dashboard-shortcuts{display:grid;grid-template-columns:1fr 1fr;gap:0 25px}.dashboard-shortcuts h2,.dashboard-shortcuts p{grid-column:1/-1}}
@media(max-width:640px){.dashboard-welcome{align-items:flex-start;flex-direction:column;gap:18px}.dashboard-home{gap:18px}.dashboard-home .kpis{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}.dashboard-home .kpi{padding:18px 14px}.dashboard-home .kpi:after{right:12px;top:17px}.dashboard-home .kpi-value{font-size:32px}.dashboard-home .kpi-label{font-size:12px}.dashboard-home .card{padding:18px}.dashboard-shortcuts{display:flex;padding:22px}.dashboard-home .checklist{grid-template-columns:1fr}.dashboard-home .kpi-note{font-size:11px}}
@media(prefers-reduced-motion:reduce){.dashboard-home .kpi{transition:none}}
