/* WA Connect — sistema de diseño (sin dependencias externas). */

:root {
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-2: #f0f3f4;
  --surface-3: #e7ecee;
  --border: #dfe5e8;
  --border-strong: #c7d1d6;
  --text: #0f1b20;
  --text-muted: #5a6b73;
  --text-subtle: #83939a;
  --brand: #0f7b6c;
  --brand-hover: #0b6559;
  --brand-soft: #e2f3f0;
  --brand-contrast: #ffffff;
  --accent: #25d366;
  --fb: #1877f2;
  --fb-hover: #1464cf;
  --success: #117a3e;
  --success-soft: #e3f4ea;
  --warning: #9a5b00;
  --warning-soft: #fff3dc;
  --danger: #b42318;
  --danger-soft: #fdeceb;
  --info: #1d5bb6;
  --info-soft: #e7effb;
  --focus: rgba(15, 123, 108, 0.35);
  --shadow-sm: 0 1px 2px rgba(15, 27, 32, 0.06);
  --shadow: 0 1px 3px rgba(15, 27, 32, 0.08), 0 4px 14px rgba(15, 27, 32, 0.05);
  --shadow-lg: 0 20px 50px rgba(15, 27, 32, 0.18);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --chat-bg: #efeae2;
  --bubble: #ffffff;
  --bubble-text: #111b21;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1114;
    --surface: #121a1f;
    --surface-2: #172127;
    --surface-3: #1e2a31;
    --border: #243239;
    --border-strong: #33444c;
    --text: #e6eef1;
    --text-muted: #9aabb2;
    --text-subtle: #6f8189;
    --brand: #2bb39f;
    --brand-hover: #3cc6b1;
    --brand-soft: #123a35;
    --brand-contrast: #06221e;
    --success: #4cc97e;
    --success-soft: #133322;
    --warning: #f0b34a;
    --warning-soft: #3a2c10;
    --danger: #f2877e;
    --danger-soft: #3d1a17;
    --info: #7aa7ef;
    --info-soft: #172a47;
    --focus: rgba(43, 179, 159, 0.45);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.45), 0 6px 18px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.55);
    --chat-bg: #0b141a;
    --bubble: #202c33;
    --bubble-text: #e9edef;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0b1114;
  --surface: #121a1f;
  --surface-2: #172127;
  --surface-3: #1e2a31;
  --border: #243239;
  --border-strong: #33444c;
  --text: #e6eef1;
  --text-muted: #9aabb2;
  --text-subtle: #6f8189;
  --brand: #2bb39f;
  --brand-hover: #3cc6b1;
  --brand-soft: #123a35;
  --brand-contrast: #06221e;
  --success: #4cc97e;
  --success-soft: #133322;
  --warning: #f0b34a;
  --warning-soft: #3a2c10;
  --danger: #f2877e;
  --danger-soft: #3d1a17;
  --info: #7aa7ef;
  --info-soft: #172a47;
  --focus: rgba(43, 179, 159, 0.45);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.45), 0 6px 18px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.55);
  --chat-bg: #0b141a;
  --bubble: #202c33;
  --bubble-text: #e9edef;
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.15rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: 0.86em; }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }
img { max-width: 100%; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; }
.muted { color: var(--text-muted); }
.subtle { color: var(--text-subtle); }
.small { font-size: 0.85rem; }
.break { word-break: break-all; }
.hidden { display: none !important; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------- Layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner { display: flex; align-items: center; gap: 12px; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; font-size: 1rem; }
.brand:hover { text-decoration: none; }
.brand img { width: 30px; height: 30px; border-radius: 8px; }
.brand small { display: block; font-weight: 500; color: var(--text-muted); font-size: 0.75rem; line-height: 1.1; }
.nav { display: flex; gap: 4px; margin-left: 12px; }
.nav a { color: var(--text-muted); padding: 7px 12px; border-radius: 8px; font-weight: 550; font-size: 0.9rem; }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--brand-soft); color: var(--brand); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.user-chip { font-size: 0.85rem; color: var(--text-muted); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.container { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 24px; }
.container-narrow { max-width: 860px; }
.page { padding-top: 28px; padding-bottom: 64px; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-header p { margin-top: 6px; }
.eyebrow { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-subtle); font-weight: 650; margin-bottom: 4px; }
.breadcrumbs { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 6px; }
.breadcrumbs a { color: var(--text-muted); }

@media (max-width: 720px) {
  .container { padding: 0 16px; }
  .brand > span { display: none; }
  .nav { margin-left: 4px; }
  .nav a { padding: 6px 9px; font-size: 0.85rem; }
  .user-chip { display: none; }
  .topbar-actions form .btn span { display: none; }
  h1 { font-size: 1.35rem; }
  .page { padding-top: 20px; }
}

/* ---------- Buttons ---------- */
.btn {
  --btn-bg: var(--surface); --btn-fg: var(--text); --btn-border: var(--border-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px;
  font: inherit; font-size: 0.92rem; font-weight: 600; line-height: 1;
  color: var(--btn-fg); background: var(--btn-bg);
  border: 1px solid var(--btn-border); border-radius: 10px;
  cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
}
.btn:hover { text-decoration: none; background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn-primary { --btn-bg: var(--brand); --btn-fg: var(--brand-contrast); --btn-border: var(--brand); }
.btn-primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn-fb { --btn-bg: var(--fb); --btn-fg: #fff; --btn-border: var(--fb); }
.btn-fb:hover { background: var(--fb-hover); border-color: var(--fb-hover); }
.btn-secondary { --btn-bg: var(--surface); }
.btn-ghost { --btn-bg: transparent; --btn-border: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); }
.btn-danger { --btn-bg: var(--danger-soft); --btn-fg: var(--danger); --btn-border: transparent; }
.btn-sm { min-height: 32px; padding: 0 12px; font-size: 0.84rem; border-radius: 8px; }
.btn-icon { width: 36px; min-height: 36px; padding: 0; border-radius: 9px; }
.btn-block { width: 100%; }
.btn .spinner { display: none; }
.btn.is-loading .spinner { display: inline-block; }
.btn.is-loading { pointer-events: none; opacity: 0.85; }
.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin 0.7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } * { transition: none !important; } }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); padding: 20px;
}
.card + .card { margin-top: 16px; }
.card-title { margin-bottom: 12px; }
.subhead { margin: 18px 0 8px; font-size: 0.95rem; }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
@media (max-width: 520px) {
  .stats { gap: 8px; }
  .stat { padding: 10px 12px; }
  .stat-label { font-size: 0.72rem; }
  .stat-value { font-size: 1.2rem; }
}
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat-label { font-size: 0.8rem; color: var(--text-muted); font-weight: 550; }
.stat-value { font-size: 1.5rem; font-weight: 700; margin-top: 2px; }

/* ---------- Accounts ---------- */
.accounts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 520px), 1fr)); gap: 16px; }
.account-card { display: flex; flex-direction: column; gap: 16px; padding: 18px 20px; }
.account-head { display: flex; gap: 14px; align-items: flex-start; }
.avatar {
  flex: none; width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center; font-weight: 700; font-size: 1rem;
  background: var(--brand-soft); color: var(--brand);
}
.account-title { min-width: 0; flex: 1; }
.account-title h2 { font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-phone { color: var(--text-muted); font-size: 0.92rem; margin-top: 2px; }
.account-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
@media (max-width: 520px) { .meta-grid { grid-template-columns: 1fr; } }
.meta-label { font-size: 0.75rem; color: var(--text-subtle); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.copy { display: flex; align-items: center; gap: 6px; min-width: 0; }
.copy .mono { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.copy-btn {
  flex: none; border: 0; background: transparent; color: var(--text-subtle); cursor: pointer;
  width: 26px; height: 26px; border-radius: 6px; display: grid; place-items: center;
}
.copy-btn:hover { background: var(--surface-2); color: var(--text); }
.account-actions { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 14px; border-top: 1px solid var(--border); }
.account-notice { border-radius: var(--radius-sm); padding: 10px 12px; font-size: 0.88rem; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 0.74rem; font-weight: 650; line-height: 1; padding: 5px 9px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-muted); white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.85; }
.badge-plain::before { display: none; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-brand { background: var(--brand-soft); color: var(--brand); }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field + .field { margin-top: 14px; }
.label { font-size: 0.86rem; font-weight: 600; }
.label .opt { color: var(--text-subtle); font-weight: 500; }
.input, .select, .textarea {
  width: 100%; min-height: 40px; padding: 9px 12px;
  font: inherit; font-size: 0.93rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--focus); }
.input[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--danger); }
.input.mono { font-size: 0.86rem; }
.help { font-size: 0.8rem; color: var(--text-muted); }
.field-error { font-size: 0.8rem; color: var(--danger); }
.field-warning { font-size: 0.8rem; color: var(--warning); }
.input-group { display: flex; gap: 8px; }
.input-group .input { flex: 1; min-width: 0; }
.checkbox { display: flex; gap: 10px; align-items: flex-start; font-size: 0.9rem; cursor: pointer; }
.checkbox input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--brand); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .field + .field { margin-top: 0; }
@media (max-width: 620px) { .form-grid { grid-template-columns: 1fr; } }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-form .input { flex: 1; min-width: 200px; }
.counter { font-size: 0.75rem; color: var(--text-subtle); text-align: right; }
.counter.over { color: var(--danger); }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.section-title { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-subtle); font-weight: 700; margin-bottom: 12px; }

/* ---------- Alerts ---------- */
.alert { border-radius: var(--radius); padding: 12px 14px; font-size: 0.9rem; border: 1px solid transparent; margin-bottom: 14px; }
.alert-success { background: var(--success-soft); color: var(--success); }
.alert-warning { background: var(--warning-soft); color: var(--warning); }
.alert-danger { background: var(--danger-soft); color: var(--danger); }
.alert-info { background: var(--info-soft); color: var(--info); }
.alert strong { font-weight: 700; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table th { text-align: left; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-subtle); font-weight: 650; padding: 11px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
@media (max-width: 640px) {
  .table-responsive thead { display: none; }
  .table-responsive tr { display: block; padding: 10px 14px; border-bottom: 1px solid var(--border); }
  .table-responsive td { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border: 0; }
  .table-responsive td::before { content: attr(data-label); color: var(--text-subtle); font-size: 0.78rem; font-weight: 600; }
}

/* ---------- Empty state ---------- */
.empty {
  text-align: center; padding: 48px 20px; border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg); background: var(--surface);
}
.empty-icon { width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 16px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.empty h2 { margin-bottom: 6px; }
.empty p { max-width: 460px; margin: 0 auto 18px; color: var(--text-muted); }

/* ---------- Dialog ---------- */
dialog.modal {
  width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 32px);
  padding: 0; border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
dialog.modal-sm { width: min(440px, calc(100vw - 24px)); }
dialog.modal::backdrop { background: rgba(8, 14, 17, 0.55); backdrop-filter: blur(2px); }
.modal-inner { display: flex; flex-direction: column; max-height: calc(100vh - 34px); }
.modal-inner > section[hidden] { display: none; }
.modal-inner > section:not([hidden]) { display: flex; flex-direction: column; min-height: 0; max-height: calc(100vh - 34px); }
.modal-header { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px 12px; }
.modal-header h2 { font-size: 1.1rem; }
.modal-header p { margin-top: 4px; color: var(--text-muted); font-size: 0.9rem; }
.modal-header .btn-icon { margin-left: auto; flex: none; }
.modal-body { padding: 6px 20px 18px; overflow-y: auto; flex: 1 1 auto; min-height: 0; }
.modal-header, .modal-footer { flex: none; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--border); flex-wrap: wrap; }

.options { display: grid; gap: 12px; }
.option-card {
  display: flex; gap: 14px; align-items: flex-start; text-align: left; width: 100%;
  padding: 16px; border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font: inherit; cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.option-card:hover { border-color: var(--brand); box-shadow: 0 0 0 3px var(--focus); }
.option-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.option-title { font-size: 1rem; font-weight: 650; }
.option-desc { color: var(--text-muted); font-size: 0.88rem; }
.option-icon { flex: none; width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.option-chevron { margin-left: auto; color: var(--text-subtle); align-self: center; }

.checklist { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.checklist li { display: flex; gap: 10px; align-items: flex-start; font-size: 0.9rem; }
.check-icon { flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 0.75rem; font-weight: 800; background: var(--brand-soft); color: var(--brand); }
.checklist li.is-warn .check-icon { background: var(--warning-soft); color: var(--warning); }
.checklist li.is-ok .check-icon { background: var(--success-soft); color: var(--success); }
.plain-list { margin: 0; padding-left: 18px; }
.plain-list li + li { margin-top: 4px; }
.details { margin-top: 14px; border: 1px solid var(--border); border-radius: var(--radius); padding: 0 14px; }
.details summary { cursor: pointer; padding: 12px 0; font-weight: 600; font-size: 0.9rem; }
.details[open] summary { border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.details > div { padding-bottom: 14px; }

.progress-steps { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 12px; }
.progress-steps li { display: flex; gap: 12px; align-items: center; color: var(--text-subtle); font-weight: 550; }
.progress-steps .dot { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--border-strong); display: grid; place-items: center; flex: none; font-size: 0.72rem; }
.progress-steps li.is-active { color: var(--text); }
.progress-steps li.is-active .dot { border-color: var(--brand); border-right-color: transparent; animation: spin 0.8s linear infinite; }
.progress-steps li.is-done { color: var(--text); }
.progress-steps li.is-done .dot { background: var(--brand); border-color: var(--brand); color: var(--brand-contrast); }

.result-icon { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; margin-bottom: 12px; font-size: 1.4rem; font-weight: 800; }
.result-icon.ok { background: var(--success-soft); color: var(--success); }
.result-icon.warn { background: var(--warning-soft); color: var(--warning); }
.result-icon.err { background: var(--danger-soft); color: var(--danger); }
.pin-display { font-family: var(--mono); font-size: 1.6rem; letter-spacing: 0.3em; font-weight: 700; padding: 10px 14px; background: var(--surface-2); border-radius: var(--radius-sm); display: inline-block; }

.code { font-family: var(--mono); font-size: 0.8rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; white-space: pre-wrap; word-break: break-all; margin: 8px 0 0; }
.migration + .migration { margin-top: 14px; }
.migration-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 0.9rem; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 100; display: grid; gap: 8px; width: min(380px, calc(100vw - 32px)); }
.toast {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px;
  border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg); font-size: 0.9rem; animation: toast-in 0.18s ease-out;
}
.toast::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; background: var(--brand); }
.toast.toast-error::before { background: var(--danger); }
.toast.toast-warning::before { background: var(--warning); }
.toast.toast-success::before { background: var(--success); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Auth ---------- */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(1200px 500px at 50% -10%, var(--brand-soft), transparent 70%), var(--bg); }
.auth-card { width: min(400px, 100%); }
.auth-card .card { padding: 28px; box-shadow: var(--shadow); }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 20px; text-align: center; }
.auth-brand img { width: 52px; height: 52px; border-radius: 14px; }
.auth-footer { text-align: center; margin-top: 16px; font-size: 0.8rem; color: var(--text-subtle); }
.auth-footer a { color: var(--text-muted); }

/* ---------- Templates / editor ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .input { max-width: 320px; }
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
.editor-preview { position: sticky; top: 84px; }
@media (max-width: 960px) { .editor { grid-template-columns: 1fr; } .editor-preview { position: static; } }
.button-row { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; background: var(--surface-2); }
.button-row + .button-row { margin-top: 10px; }
.button-row-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; font-weight: 600; font-size: 0.88rem; }
.variables { display: grid; gap: 10px; margin-top: 10px; }

.phone { border-radius: 28px; border: 1px solid var(--border-strong); background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
.phone-top { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: #075e54; color: #fff; }
:root[data-theme="dark"] .phone-top { background: #1f2c33; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .phone-top { background: #1f2c33; } }
.phone-top .avatar { width: 32px; height: 32px; border-radius: 50%; background: rgba(255, 255, 255, 0.2); color: #fff; font-size: 0.8rem; }
.phone-top strong { font-size: 0.9rem; display: block; }
.phone-top small { opacity: 0.8; font-size: 0.72rem; }
.phone-chat { background: var(--chat-bg); padding: 16px 12px 22px; min-height: 360px; }
.bubble { background: var(--bubble); color: var(--bubble-text); border-radius: 0 10px 10px 10px; padding: 7px 9px 5px; max-width: 92%; box-shadow: 0 1px 1px rgba(0, 0, 0, 0.12); font-size: 0.88rem; line-height: 1.4; }
.bubble-header { font-weight: 700; margin-bottom: 4px; }
.bubble-media { height: 120px; border-radius: 8px; background: var(--surface-3); display: grid; place-items: center; color: var(--text-subtle); font-size: 0.8rem; margin-bottom: 6px; }
.bubble-body { white-space: pre-wrap; word-wrap: break-word; }
.bubble-footer { color: #8696a0; font-size: 0.78rem; margin-top: 4px; }
.bubble-time { text-align: right; color: #8696a0; font-size: 0.68rem; margin-top: 2px; }
.bubble-buttons { max-width: 92%; display: grid; gap: 2px; margin-top: 2px; }
.bubble-button { background: var(--bubble); color: #0b8fd1; text-align: center; padding: 8px; font-size: 0.86rem; font-weight: 550; border-radius: 8px; box-shadow: 0 1px 1px rgba(0, 0, 0, 0.12); }
.preview-empty { color: var(--text-subtle); font-style: italic; }
