/* ============================================================================
   IntelliHome Hub — Design System (compartilhado por todas as páginas)
   ========================================================================== */

/* Fontes servidas pelo próprio painel (o CSP não deixa buscar fora).
   Plus Jakarta Sans no texto e JetBrains Mono nos valores. Licença OFL em /fonts. */
@font-face {
  font-family: "Plus Jakarta Sans"; font-style: normal; font-weight: 200 800; font-display: swap;
  src: url("/fonts/plus-jakarta-sans.woff2") format("woff2");
}
@font-face {
  font-family: "JetBrains Mono"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("/fonts/jetbrains-mono-600.woff2") format("woff2");
}

/* ── Tokens ─────────────────────────────────────────────────────────────── */
:root {
  color-scheme: light;

  /* Superfícies */
  --bg: #f4f6fa;
  --bg-grad-1: #f4f6fa;
  --bg-grad-2: #eef1f7;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --surface-3: #eef1f6;

  /* Bordas */
  --border: #e1e5ee;
  --border-strong: #d6dbe6;

  /* Texto */
  --text: #0f1229;
  --text-muted: #545b7a;
  --text-subtle: #8a90ab;

  /* Marca / acentos */
  --brand: #0b7285;
  --brand-strong: #08515f;
  --brand-soft: #e4f7fa;
  --brand-ring: rgba(18, 169, 188, .35);
  --brand-solid: #5fd3e2;       /* fundo de botão principal */
  --brand-solid-hover: #4cc6d6;
  --brand-on: #0f1229;          /* texto sobre o botão principal (turquesa) */
  --on-brand: #ffffff;          /* texto sobre fundos var(--brand) */
  --accent: #6670e0;            /* lilás do logo (gráficos e detalhes) */
  --chart: #6670e0;

  --success: #127a4a;
  --success-soft: #eef9f3;
  --warn: #b87300;
  --warn-soft: #fff8e8;
  --danger: #d92d20;
  --danger-strong: #b42318;
  --danger-soft: #fdecea;

  /* Sombras */
  --shadow-xs: 0 1px 2px rgba(15, 18, 41, .05);
  --shadow-sm: 0 1px 3px rgba(15, 18, 41, .08), 0 1px 2px rgba(15, 18, 41, .04);
  --shadow-md: 0 6px 16px rgba(15, 18, 41, .07), 0 2px 6px rgba(15, 18, 41, .05);
  --shadow-lg: 0 16px 40px rgba(15, 18, 41, .14);
  --hairline: 0 0 #0000;        /* brilho no topo dos cartões (só no escuro) */

  /* Raios */
  --r-xs: 8px;
  --r-sm: 10px;
  --r: 14px;
  --r-lg: 18px;
  --r-xl: 24px;
  --r-pill: 999px;

  --sidebar: 250px;
  --appbar-h: 58px;

  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Aliases legados (mantêm compatibilidade com estilos inline antigos) */
  --card: var(--surface);
  --line: var(--border);
  --ink: var(--text);
  --muted: var(--text-muted);
  --ok: var(--success);
}

/* Tema escuro: segue o sistema (padrão) ou a escolha salva em data-theme. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b0e1f;
    --bg-grad-1: #0d1024;
    --bg-grad-2: #0a0d1c;
    --surface: #131733;
    --surface-2: #0f1229;
    --surface-3: #1c2146;

    --border: #262b4f;
    --border-strong: #333a66;

    --text: #e8ebf7;
    --text-muted: #a3aacb;
    --text-subtle: #767da3;

    --brand: #5fd3e2;
    --brand-strong: #8fe3ee;
    --brand-solid: #5fd3e2;
    --brand-solid-hover: #7adce8;
    --brand-on: #0b0e1f;
    --on-brand: #0b0e1f;
    --chart: #7c86f0;
    --brand-soft: #12303b;
    --brand-ring: rgba(95, 211, 226, .4);
    --accent: #7c86f0;

    --success: #5ee0a0;
    --success-soft: #12291f;
    --warn: #f5c451;
    --warn-soft: #2a2614;
    --danger: #ff7a70;
    --danger-strong: #ff958c;
    --danger-soft: #2e1817;

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, .35);
    --shadow-sm: 0 2px 6px rgba(0, 0, 0, .4);
    --shadow-md: 0 8px 22px rgba(0, 0, 0, .45);
    --shadow-lg: 0 20px 48px rgba(0, 0, 0, .55);
    --hairline: inset 0 1px 0 rgba(255, 255, 255, .035);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0e1f;
  --bg-grad-1: #0d1024;
  --bg-grad-2: #0a0d1c;
  --surface: #131733;
  --surface-2: #0f1229;
  --surface-3: #1c2146;

  --border: #262b4f;
  --border-strong: #333a66;

  --text: #e8ebf7;
  --text-muted: #a3aacb;
  --text-subtle: #767da3;

  --brand: #5fd3e2;
  --brand-strong: #8fe3ee;
  --brand-solid: #5fd3e2;
  --brand-solid-hover: #7adce8;
  --brand-on: #0b0e1f;
  --on-brand: #0b0e1f;
  --chart: #7c86f0;
  --brand-soft: #12303b;
  --brand-ring: rgba(95, 211, 226, .4);
  --accent: #7c86f0;

  --success: #5ee0a0;
  --success-soft: #12291f;
  --warn: #f5c451;
  --warn-soft: #2a2614;
  --danger: #ff7a70;
  --danger-strong: #ff958c;
  --danger-soft: #2e1817;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, .4);
  --shadow-md: 0 8px 22px rgba(0, 0, 0, .45);
  --shadow-lg: 0 20px 48px rgba(0, 0, 0, .55);
  --hairline: inset 0 1px 0 rgba(255, 255, 255, .035);
}

/* ── Reset / base ───────────────────────────────────────────────────────── */
* { box-sizing: border-box; }

html, body { height: 100%; overflow-x: clip; max-width: 100%; }

/* Fundo também no html: a cor cobre a página toda, mesmo abaixo da primeira tela. */
html { background: var(--bg-grad-2); }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: linear-gradient(180deg, var(--bg-grad-1), var(--bg-grad-2)) fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  line-height: 1.5;
  overflow-x: clip;
}

a { color: var(--brand); }

input[type=checkbox], input[type=radio] { accent-color: var(--brand-solid); }

/* Texto de apoio (notas abaixo de campos, explicações curtas) */
.hint { font-size: 12.5px; line-height: 1.45; color: var(--text-muted); }

/* Nota recolhível para explicações longas */
details.note { margin: 2px 0 16px; font-size: 12.5px; color: var(--text-muted); line-height: 1.5; }
details.note summary { cursor: pointer; font-weight: 600; color: var(--text-muted); display: inline-flex; align-items: center; gap: 6px; }
details.note summary:hover { color: var(--text); }
details.note summary::before { content: "i"; width: 16px; height: 16px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-size: 10.5px; font-weight: 700; font-style: italic; font-family: Georgia, serif; background: var(--surface-3); color: var(--text-muted); }
details.note p { margin: 8px 0 0; padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-xs); }
details.note p + p { margin-top: 6px; }

::selection { background: var(--brand-ring); }

svg { display: block; }

/* Marca / logo: o símbolo original da IntelliHome (SVG com o degradê da marca) */
.logo-mark { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.logo-mark img { width: 100%; height: 100%; display: block; }

/* "IntelliHome HUB": nome em negrito e o selo HUB em turquesa */
.name b {
  display: inline-block; vertical-align: 2px; margin-left: 3px;
  font-size: .62em; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; line-height: 1;
  color: #0f1229; background: #5fd3e2; border-radius: 5px; padding: 3px 5px;
}

/* Scrollbars discretas */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-subtle); background-clip: padding-box; border: 3px solid transparent; }

/* ── Botões ─────────────────────────────────────────────────────────────── */
.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--text);
  --btn-bd: var(--border-strong);
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  padding: 10px 16px;
  border-radius: var(--r-xs);
  border: 1px solid var(--btn-bd);
  background: var(--btn-bg);
  color: var(--btn-fg);
  cursor: pointer;
  white-space: nowrap;
  transition: transform .08s ease, box-shadow .15s ease, background .15s ease, border-color .15s ease, opacity .15s ease;
}
/* O atributo hidden sempre vence o display das classes (.btn, .mode-chip…). */
[hidden] { display: none !important; }
.btn:hover { box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--brand-ring); }
.btn svg { width: 16px; height: 16px; }
.btn[disabled], .btn.is-loading { opacity: .6; cursor: not-allowed; pointer-events: none; }

.btn-sm { padding: 8px 12px; font-size: 13px; }
.btn-block { width: 100%; }

.btn-primary { --btn-bg: var(--brand-solid); --btn-fg: var(--brand-on); --btn-bd: transparent;
  box-shadow: 0 1px 2px rgba(11, 114, 133, .3); }
.btn-primary:hover { --btn-bg: var(--brand-solid-hover); box-shadow: 0 6px 16px rgba(11, 114, 133, .22); }

.btn-success { --btn-bg: var(--success); --btn-fg: #fff; --btn-bd: transparent; }
.btn-success:hover { filter: brightness(1.05); box-shadow: 0 6px 16px rgba(18, 161, 80, .25); }

.btn-ghost { --btn-bg: var(--surface); --btn-fg: var(--text); --btn-bd: var(--border); }
.btn-ghost:hover { --btn-bg: var(--surface-2); }

.btn-soft { --btn-bg: var(--surface-3); --btn-fg: var(--text); --btn-bd: transparent; }
.btn-soft:hover { --btn-bg: var(--border); }

.btn-danger-ghost { --btn-bg: transparent; --btn-fg: var(--danger); --btn-bd: color-mix(in srgb, var(--danger) 35%, transparent); }
.btn-danger-ghost:hover { --btn-bg: var(--danger-soft); }

/* ── Inputs ─────────────────────────────────────────────────────────────── */
.field {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-xs);
  padding: 11px 13px;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field::placeholder { color: var(--text-subtle); }
.field:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }

/* Campo com prefixo/sufixo de unidade (R$, %, cm…) */
.affix { position: relative; }
.affix > span { position: absolute; top: 50%; transform: translateY(-50%); left: 13px; pointer-events: none;
  font-size: 13px; font-weight: 600; color: var(--text-subtle); }
.affix > .field { padding-left: 40px; }
.affix.usd > .field { padding-left: 50px; }
.affix.suf > span { left: auto; right: 13px; }
.affix.suf > .field { padding-left: 13px; padding-right: 38px; }
input[type=number].field { -moz-appearance: textfield; }
input[type=number].field::-webkit-inner-spin-button, input[type=number].field::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

textarea.field { min-height: 92px; resize: vertical; line-height: 1.55; }

/* ── Login ──────────────────────────────────────────────────────────────── */
#login-overlay {
  position: fixed; inset: 0; z-index: 999;
  display: flex; align-items: flex-start; justify-content: center;
  overflow-y: auto; /* configurar o duplo fator é mais alto que a tela do celular */
  padding: 24px;
  background:
    radial-gradient(900px 500px at 15% -10%, color-mix(in srgb, var(--brand) 20%, transparent), transparent 60%),
    radial-gradient(700px 500px at 110% 110%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 55%),
    linear-gradient(180deg, var(--bg-grad-1), var(--bg-grad-2));
}
#login-overlay.hidden { display: none; }

.login-box {
  width: 100%; max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 34px 30px 30px;
  box-shadow: var(--shadow-lg);
  animation: pop .35s cubic-bezier(.2, .8, .2, 1);
  margin: auto 0; /* centraliza quando cabe, rola quando não cabe */
}
.login-brand { display: flex; align-items: center; gap: 11px; justify-content: center; margin-bottom: 22px; }
.login-brand .logo-mark { width: 40px; height: 40px; border-radius: 11px; }
.login-brand .name { font-size: 19px; font-weight: 700; letter-spacing: -.01em; }
.login-box .subtitle { text-align: center; color: var(--text-muted); font-size: 13.5px; margin: -14px 0 24px; }
.login-box label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-muted); margin: 0 0 6px; }
.login-box .form-group { margin-bottom: 16px; }
.login-box .btn { margin-top: 4px; }
.login-error { color: var(--danger); font-size: 13px; text-align: center; margin-top: 12px; min-height: 18px; }
/* Duplo fator: segundo passo do login */
.login-2fa-hint { color: var(--text-muted); font-size: 13.5px; line-height: 1.5; margin: 0 0 16px; text-align: center; }
.login-box .login-code { font-family: var(--font-mono); font-size: 22px; letter-spacing: 6px; text-align: center; }
.login-2fa-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 16px; margin-top: 14px; }
.link-btn { background: none; border: 0; padding: 4px 0; color: var(--brand); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
/* Duplo fator: configurar (primeiro login e Configurações) */
.tf-options { display: grid; gap: 8px; margin-bottom: 14px; }
.tf-opt { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--r-sm); cursor: pointer; }
.tf-opt:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.tf-opt.disabled { opacity: .55; cursor: not-allowed; }
.tf-opt input { margin-top: 3px; accent-color: var(--brand); }
.tf-opt b { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.tf-opt b .tag { font-size: 10.5px; }
.tf-opt small { display: block; margin-top: 3px; color: var(--text-muted); font-size: 12.5px; line-height: 1.45; }
.tf-steps { margin: 0 0 10px; padding-left: 20px; font-size: 13.5px; line-height: 1.6; }
.tf-qr { width: 200px; height: 200px; margin: 6px auto 10px; padding: 8px; background: #fff; border: 1px solid var(--border); border-radius: var(--r-sm); }
.tf-qr svg { display: block; width: 100%; height: 100%; }
.tf-secret { font-size: 12.5px; color: var(--text-muted); margin-bottom: 12px; text-align: center; }
.tf-secret summary { cursor: pointer; }
.tf-secret code { display: block; margin-top: 6px; font-family: var(--font-mono); font-size: 14px; color: var(--text); word-break: break-all; user-select: all; }
.tf-code { font-family: var(--font-mono); font-size: 20px; letter-spacing: 5px; text-align: center; }
.tf-p { font-size: 13.5px; line-height: 1.5; color: var(--text-muted); margin: 0 0 12px; }
.tf-p b { color: var(--text); }
.tf-codes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; padding: 14px 16px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--r-sm); font-family: var(--font-mono); font-size: 15px; text-align: center; user-select: all; }
.tf-code-actions { display: flex; gap: 8px; justify-content: center; margin-top: 10px; }
.login-box .tf-opt { display: flex; margin: 0; font-size: inherit; font-weight: 400; color: var(--text); }
.login-box .tf-options { margin-bottom: 16px; }
.login-box .tf-qr { width: 180px; height: 180px; }
.login-box .tf-steps { color: var(--text); }
.tf-codes-done { margin-top: 14px; }

/* ── Shell / layout ─────────────────────────────────────────────────────── */
.sidebar {
  position: fixed; top: 0; left: 0; z-index: 120;
  width: var(--sidebar); height: 100vh; height: 100dvh;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  transition: transform .28s cubic-bezier(.4, 0, .2, 1);
}
.sidebar-brand {
  display: flex; align-items: center; gap: 11px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.sidebar-brand .logo-mark { width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0; }
.sidebar-brand .name { font-size: 16px; font-weight: 700; letter-spacing: -.01em; }

.sidebar-nav { flex: 1; padding: 14px 12px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
/* Primeiro nível: Visão geral e os títulos dos grupos (ícone + negrito) */
.sidebar-nav .nav-top, .nav-group-head {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 9px 12px; border-radius: var(--r-xs); border: 0; background: none; cursor: pointer;
  font: inherit; font-size: 14px; font-weight: 700; color: var(--text); text-align: left;
  text-decoration: none; transition: background .14s ease, color .14s ease;
}
.sidebar-nav .nav-top svg, .nav-group-head > svg:first-child { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-nav .nav-top:hover, .nav-group-head:hover { background: var(--surface-2); }
.nav-group-head:focus-visible, .sidebar-nav a:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--brand-ring); }
.sidebar-nav .nav-top.active { background: var(--brand-soft); color: var(--brand-strong); }
.nav-group { margin-top: 6px; }
.nav-group-label { flex: 1; }
.nav-chevron { width: 15px; height: 15px; color: var(--text-subtle); transition: transform .18s ease; }
.nav-group.closed .nav-chevron { transform: rotate(-90deg); }
.nav-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warn); }
.nav-group:not(.closed) .nav-dot { display: none; }
/* Segundo nível: recuado, com linha guia, letra menor e cinza */
.nav-sub { margin: 2px 0 2px 20px; padding-left: 12px; border-left: 1px solid var(--border); display: flex; flex-direction: column; gap: 1px; }
.nav-group.closed .nav-sub { display: none; }
.nav-sub a {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: 7px; position: relative;
  font-size: 13px; font-weight: 500; color: var(--text-muted); text-decoration: none;
  transition: background .14s ease, color .14s ease;
}
.nav-sub a:hover { background: var(--surface-2); color: var(--text); }
.nav-sub a.active { background: var(--brand-soft); color: var(--brand-strong); font-weight: 650; }
.nav-sub a.active::before { content: ""; position: absolute; left: -13px; top: 6px; bottom: 6px; width: 2px; border-radius: 2px; background: var(--brand); }
.nav-sub a.active.danger { background: var(--danger-soft); color: var(--danger); }
.nav-sub a.active.danger::before { background: var(--danger); }
.sidebar-nav a .badge {
  margin-left: auto;
  min-width: 20px; height: 20px; padding: 0 6px;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 11px; font-weight: 600; line-height: 1;
  color: var(--brand-on); background: var(--brand-solid); border-radius: var(--r-pill);
}
.sidebar-nav a .badge.danger { color: #fff; background: var(--danger); }
.sidebar-nav a .badge.hidden { display: none; }

.sidebar-footer { padding: 14px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }

/* Seletor de tema (automático / claro / escuro) */
.theme-switch { display: flex; background: var(--surface-3); border-radius: var(--r-xs); padding: 3px; gap: 2px; }
.theme-switch button {
  flex: 1; appearance: none; border: 0; background: transparent; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-size: 12px; font-weight: 600; color: var(--text-muted);
  padding: 7px 4px; border-radius: 7px; transition: background .15s ease, color .15s ease;
}
.theme-switch button svg { width: 15px; height: 15px; }
.theme-switch button:hover { color: var(--text); }
.theme-switch button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs); }
.theme-switch button:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--brand-ring); }
.sidebar-footer .who { display: flex; align-items: center; gap: 10px; padding: 4px 4px 2px; color: var(--text); text-decoration: none; border-radius: var(--r-xs); }
.sidebar-footer .who:hover .who-txt b { color: var(--brand); }
.who-av { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--brand-soft, var(--surface-3)); color: var(--brand); font-weight: 700; font-size: 13px; }
.who-txt { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.who-txt b { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-txt small { font-size: 11.5px; color: var(--text-muted); }
.sidebar-footer .btn { justify-content: flex-start; color: var(--text-muted); }
.sidebar-footer .btn:hover { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); background: var(--danger-soft); }

/* Backdrop (drawer no mobile) */
.backdrop {
  position: fixed; inset: 0; z-index: 110;
  background: rgba(16, 24, 40, .5);
  opacity: 0; visibility: hidden;
  transition: opacity .28s ease, visibility .28s ease;
  backdrop-filter: blur(2px);
}
body.nav-open .backdrop { opacity: 1; visibility: visible; }

/* App bar (só no mobile) */
.appbar {
  display: none;
  position: sticky; top: 0; z-index: 90;
  align-items: center; gap: 12px;
  height: var(--appbar-h); padding: 0 14px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.appbar .logo-mark { width: 30px; height: 30px; border-radius: 8px; }
.appbar .name { font-size: 15px; font-weight: 700; }
.hamburger {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: var(--r-xs);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer; flex-shrink: 0;
}
.hamburger:hover { background: var(--surface-2); }
.hamburger svg { width: 20px; height: 20px; }

.content { margin-left: var(--sidebar); min-height: 100vh; }

/* Barra de página (listas) */
.topbar {
  position: sticky; top: 0; z-index: 60;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 16px 24px;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 18px; font-weight: 700; letter-spacing: -.01em; margin: 0; }
.topbar-sub { font-size: 13px; color: var(--text-muted); }
.count-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 600; color: var(--text-muted);
  background: var(--surface-3); padding: 4px 10px; border-radius: var(--r-pill);
}
.count-chip.empty { display: none; }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.toolbar .field { width: auto; }
/* Barra em duas linhas: título + ações em cima, busca + filtros embaixo. */
.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.toolbar.toolbar-row { flex: 1 1 100%; margin-left: 0; }
.toolbar-row .search-box { flex: 1 1 260px; max-width: 480px; }

main { max-width: 1040px; margin: 0 auto; padding: 26px 24px 60px; }

.page-head { margin: 4px 0 20px; }
.page-head h2 { font-size: 12px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--text-subtle); margin: 0; }

/* ── Dashboard: stat cards ──────────────────────────────────────────────── */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

.stat-card {
  position: relative; overflow: hidden; min-width: 0;
  display: flex; flex-direction: column; gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 24px;
  text-decoration: none; color: var(--text);
  box-shadow: var(--shadow-xs);
  transition: transform .16s ease, box-shadow .18s ease, border-color .18s ease;
}
.stat-card::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 4px;
  background: var(--brand);
}
.stat-card.claims::before { background: var(--danger); }
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }

.stat-top { display: flex; align-items: center; gap: 12px; }
.stat-icon {
  width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--brand-soft); color: var(--brand);
}
.stat-card.claims .stat-icon { background: var(--danger-soft); color: var(--danger); }
.stat-icon svg { width: 22px; height: 22px; }
.stat-label { font-size: 14px; font-weight: 600; color: var(--text); }
.stat-sublabel { font-size: 12.5px; color: var(--text-muted); }

.stat-num { font-family: var(--font-mono); font-size: 48px; font-weight: 600; line-height: 1; letter-spacing: -.03em; }
.stat-num.zero { color: var(--text-subtle); }
.stat-num.has { color: var(--text); }

.stat-foot { display: flex; align-items: center; justify-content: space-between; margin-top: auto; }
.stat-link { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 600; color: var(--brand); }
.stat-card.claims .stat-link { color: var(--danger); }
.stat-link svg { width: 15px; height: 15px; transition: transform .15s ease; }
.stat-card:hover .stat-link svg { transform: translateX(3px); }

.pill-status { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600; color: var(--text-muted); }
.ping { width: 9px; height: 9px; border-radius: 50%; background: var(--border-strong); display: inline-block; flex-shrink: 0; position: relative; }
.ping.has { background: var(--warn); }
.ping.has::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: var(--warn); animation: ping 1.4s cubic-bezier(0, 0, .2, 1) infinite;
}
.stat-card.claims .ping.has, .stat-card.claims .ping.has::after { background: var(--danger); }

/* ── Modo de resposta (toggle) ──────────────────────────────────────────── */
.mode-card {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  padding: 18px 20px; box-shadow: var(--shadow-xs);
}
.mode-card.auto { border-color: color-mix(in srgb, var(--warn) 45%, var(--border)); }
.mode-info { flex: 1; min-width: 220px; }
.mode-title { display: flex; align-items: center; gap: 9px; font-size: 15px; font-weight: 700; }
.mode-desc { font-size: 12.5px; color: var(--text-muted); margin-top: 4px; }
.mode-desc.warn { color: var(--warn); }

/* Etiqueta curta que leva à configuração (Perguntas, Anúncios, Vendas) */
.mode-chip {
  display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 13px; font-weight: 600; color: var(--text-muted); text-decoration: none;
  padding: 7px 12px; border: 1px solid var(--border); border-radius: var(--r-xs); background: var(--surface);
}
.mode-chip:hover { border-color: var(--brand); }
.mode-chip .mode-chip-go { color: var(--brand); }

.segment { display: inline-flex; background: var(--surface-3); border-radius: var(--r-xs); padding: 3px; gap: 2px; }
.segment button {
  appearance: none; border: none; background: transparent; cursor: pointer;
  font: inherit; font-size: 13.5px; font-weight: 600; color: var(--text-muted);
  padding: 8px 16px; border-radius: 8px; display: inline-flex; align-items: center; gap: 7px;
  transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}
.segment button svg { width: 15px; height: 15px; }
.segment button:hover { color: var(--text); }
.segment button.active { background: var(--surface); color: var(--brand); box-shadow: var(--shadow-xs); }
.segment button.active.warn { color: var(--warn); }
.segment.busy { opacity: .6; pointer-events: none; }

/* ── Abas ───────────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 18px 0 20px; }
.tabs .tab {
  appearance: none; border: none; background: transparent; cursor: pointer;
  font: inherit; font-size: 14px; font-weight: 600; color: var(--text-muted);
  padding: 10px 4px; margin-bottom: -1px; border-bottom: 2px solid transparent;
  display: inline-flex; align-items: center; gap: 8px;
  transition: color .15s ease, border-color .15s ease;
}
.tabs .tab + .tab { margin-left: 18px; }
.tabs .tab:hover { color: var(--text); }
.tabs .tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.tabs .tab-count {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--r-pill);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11.5px; font-weight: 700; background: var(--surface-3); color: var(--text-muted);
}
.tabs .tab.active .tab-count { background: var(--brand-soft); color: var(--brand); }
.tabs .tab-count.hidden { display: none; }

/* ── Histórico (respostas automáticas) ──────────────────────────────────── */
.hist-card { position: relative; }
.hist-card .answer {
  background: var(--success-soft); border: 1px solid transparent; border-radius: var(--r-xs);
  padding: 11px 13px; margin-top: 10px; font-size: 14px; line-height: 1.55;
}
.hist-card .answer .answer-label {
  display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em; color: var(--success); margin-bottom: 6px;
}
.hist-card .answer .answer-label svg { width: 13px; height: 13px; }
.hist-time { font-size: 12px; color: var(--text-subtle); margin-top: 10px; display: flex; align-items: center; gap: 6px; }
.hist-time svg { width: 13px; height: 13px; }

/* ── KPIs de vendas ─────────────────────────────────────────────────────── */
.section { margin-bottom: 30px; }
.section-head { display: flex; align-items: center; gap: 12px; margin: 4px 0 16px; }
.section-head h2 { font-size: 12px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--text-subtle); margin: 0; }
.section-head .spacer { flex: 1; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  padding: 18px 18px 16px; box-shadow: var(--shadow-xs), var(--hairline);
  display: flex; flex-direction: column; gap: 8px;
  min-width: 0; /* impede que um número grande estique a coluna do grid */
}
.kpi .kpi-value { overflow-wrap: break-word; } /* quebra no espaço de "R$ 1.234", não no meio do número */
.kpi .kpi-label { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-muted); font-weight: 500; }
.kpi .kpi-label svg { width: 16px; height: 16px; opacity: .8; }
.kpi .kpi-icon { width: 30px; height: 30px; border-radius: 9px; display: flex; align-items: center; justify-content: center;
  background: var(--brand-soft); color: var(--brand); flex-shrink: 0; }
.kpi .kpi-icon svg { width: 17px; height: 17px; }
/* Valores em fonte mono: os números alinham e se leem de relance. */
.kpi .kpi-value { font-family: var(--font-mono); font-size: 24px; font-weight: 600; letter-spacing: -.02em; line-height: 1.1; }
.kpi .kpi-sub { font-size: 12px; color: var(--text-subtle); }

.delta { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 700;
  padding: 2px 7px; border-radius: var(--r-pill); }
.delta svg { width: 12px; height: 12px; }
.delta.up { color: var(--success); background: var(--success-soft); }
.delta.down { color: var(--danger); background: var(--danger-soft); }
.delta.flat { color: var(--text-muted); background: var(--surface-3); }

/* ── Painéis / gráfico ──────────────────────────────────────────────────── */
.panel-grid { display: grid; grid-template-columns: 1.7fr 1fr; gap: 16px; align-items: start; }
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  padding: 18px; box-shadow: var(--shadow-xs), var(--hairline);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.panel-head h3 { font-size: 14.5px; font-weight: 700; margin: 0; }
.panel-head .hint { font-size: 12px; color: var(--text-subtle); }
.chart-wrap { width: 100%; }

.chart-tip {
  position: absolute; transform: translate(-50%, -100%);
  background: var(--text); color: var(--surface);
  font-size: 12px; line-height: 1.4; font-weight: 500;
  padding: 6px 9px; border-radius: 8px; box-shadow: var(--shadow-md);
  pointer-events: none; white-space: nowrap; z-index: 5;
}
.chart-tip b { font-weight: 700; }

/* Lista de barras (top produtos) */
.bar-list { display: flex; flex-direction: column; gap: 14px; }
.bar-row { display: flex; flex-direction: column; gap: 6px; }
.bar-row .bar-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.bar-row .bar-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .bar-val { font-size: 12.5px; font-weight: 700; color: var(--text-muted); flex-shrink: 0; }
.bar-row .bar-track { height: 8px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; }
.bar-row .bar-fill { height: 100%; border-radius: var(--r-pill); background: var(--brand); min-width: 4px; }
.bar-row .bar-sub { font-size: 11.5px; color: var(--text-subtle); }

/* ── Anúncios ───────────────────────────────────────────────────────────── */
.item-head { display: flex; align-items: flex-start; gap: 14px; }
.item-thumb {
  width: 60px; height: 60px; border-radius: var(--r-xs); flex-shrink: 0;
  object-fit: cover; background: var(--surface-2); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; color: var(--text-subtle);
}
.item-thumb svg { width: 24px; height: 24px; }
.item-main { flex: 1; min-width: 0; }
.item-title { font-size: 14.5px; font-weight: 600; line-height: 1.35; margin: 0 0 6px;
  display: flex; align-items: center; gap: 8px; }
.item-title .id { font-size: 11.5px; font-weight: 600; color: var(--text-subtle); font-variant-numeric: tabular-nums; }
.item-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; font-size: 12.5px; color: var(--text-muted); }
.item-meta b { color: var(--text); font-weight: 700; }
.item-meta a { color: var(--brand); text-decoration: none; font-weight: 600; }
.item-meta a:hover { text-decoration: underline; }
.item-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; flex-shrink: 0; }

.badge-status { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 700;
  padding: 4px 10px; border-radius: var(--r-pill); }
.badge-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-status.active { background: var(--success-soft); color: var(--success); }
.badge-status.paused { background: var(--warn-soft); color: var(--warn); }
.badge-status.closed { background: var(--surface-3); color: var(--text-muted); }
.badge-status.under_review { background: var(--brand-soft); color: var(--brand); }

/* Formulário de edição do anúncio */
.item-edit { margin-top: 16px; padding-top: 16px; border-top: 1px dashed var(--border); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; margin-bottom: 12px; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.form-field { display: flex; flex-direction: column; gap: 5px; }
.form-field.full { grid-column: 1 / -1; }
.form-field label { font-size: 12px; font-weight: 600; color: var(--text-muted); display: flex; justify-content: space-between; }
.form-field label .counter { font-weight: 500; color: var(--text-subtle); }
.form-field label .counter.over { color: var(--danger); }
.form-field .field-note { font-size: 11.5px; color: var(--text-subtle); line-height: 1.4; }
.field:disabled { opacity: .6; cursor: not-allowed; }
select.field { appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; }

.gen-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px;
  background: var(--brand-soft); border: 1px solid color-mix(in srgb, var(--brand) 20%, transparent);
  border-radius: var(--r-xs); padding: 10px 12px; }
.gen-bar .gen-hint { font-size: 12px; color: var(--brand); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.gen-bar .gen-hint svg { width: 15px; height: 15px; }
.gen-bar input.field { flex: 1; min-width: 160px; }

/* ── Tabela de vendas ───────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); box-shadow: var(--shadow-xs); }
.sales-table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 620px; }
.sales-table th {
  text-align: left; font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  color: var(--text-subtle); padding: 12px 16px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface); white-space: nowrap;
}
.sales-table td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.sales-table tr:last-child td { border-bottom: none; }
.sales-table tbody tr { transition: background .12s ease; }
.sales-table tbody tr:hover { background: var(--surface-2); }
.sales-table .t-prod { max-width: 320px; }
.sales-table .t-prod .t-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sales-table .t-prod .t-extra { font-size: 11.5px; color: var(--text-subtle); }
.sales-table .t-num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.sales-table .t-amount { text-align: right; font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.sales-table .t-id { font-variant-numeric: tabular-nums; color: var(--text-muted); font-size: 12.5px; }
.status-dot { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; }
.status-dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--success); }
.status-dot.paid::before { background: var(--success); }
.status-dot.other::before { background: var(--warn); }

/* Seletor de mês */
input.month-picker { width: auto; padding: 8px 12px; font-size: 13px; }

/* ── Footer dashboard ───────────────────────────────────────────────────── */
.dash-footer {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px;
  margin-top: 28px; padding: 16px 20px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
}
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none;
  font-size: 13.5px; color: var(--text-muted); }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 40px; height: 23px; border-radius: var(--r-pill); background: var(--border-strong);
  position: relative; transition: background .18s ease; flex-shrink: 0; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 19px; height: 19px;
  border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .18s ease; }
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { transform: translateX(17px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px var(--brand-ring); }
.last-update { font-size: 12.5px; color: var(--text-subtle); }

/* ── Cards de item (perguntas / reclamações) ────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-xs), var(--hairline);
  transition: opacity .2s ease, box-shadow .18s ease;
  animation: rise .3s ease both;
}
.card:hover { box-shadow: var(--shadow-sm), var(--hairline); }
.card.busy { opacity: .5; pointer-events: none; }

.card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin-bottom: 12px; }
.prod { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-muted);
  margin-bottom: 10px; }
.prod svg { width: 15px; height: 15px; flex-shrink: 0; opacity: .8; }
.prod a { color: var(--brand); text-decoration: none; font-weight: 600; white-space: nowrap; flex-shrink: 0; }
.prod a:hover { text-decoration: underline; }

.q { font-size: 15.5px; font-weight: 600; line-height: 1.45; margin: 0 0 12px; }
.buyer { display: flex; align-items: center; gap: 8px; font-size: 14.5px; font-weight: 700; margin-bottom: 6px; }
.buyer .avatar { width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--brand-soft); color: var(--brand); font-size: 12px; font-weight: 700; }

.reason { display: flex; align-items: flex-start; gap: 7px; font-size: 12.5px; color: var(--text-muted);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-xs);
  padding: 8px 11px; margin: 0 0 12px; }
.reason svg { width: 14px; height: 14px; flex-shrink: 0; margin-top: 2px; color: var(--warn); }

/* Tags */
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 600; line-height: 1;
  padding: 5px 9px; border-radius: var(--r-pill);
  background: var(--brand-soft); color: var(--brand);
}
.tag.hold { background: var(--warn-soft); color: var(--warn); }
.tag.auto { background: var(--success-soft); color: var(--success); }
.tag.claim { background: var(--danger-soft); color: var(--danger); }
.tag.neutral { background: var(--surface-3); color: var(--text-muted); }

/* Thread de mensagens */
.thread {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 12px 14px; margin-bottom: 14px; max-height: 260px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 12px;
}
.msg { display: flex; flex-direction: column; gap: 3px; }
.msg-author { font-size: 11.5px; font-weight: 700; display: inline-flex; align-items: center; gap: 6px; }
.msg-author::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.msg-author.complainant { color: var(--danger); }
.msg-author.respondent { color: var(--success); }
.msg-author.mediator { color: var(--text-muted); }
.msg-text { font-size: 13.5px; line-height: 1.55; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xs);
  padding: 8px 11px; align-self: flex-start; max-width: 100%; }
.msg-author.respondent + .msg-text { background: var(--success-soft); border-color: transparent; }
.no-msgs { font-size: 12.5px; color: var(--text-subtle); font-style: italic; }

.card .row { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

/* ── Estados vazio / carregando ─────────────────────────────────────────── */
.empty { text-align: center; color: var(--text-muted); padding: 64px 20px; }
.empty .empty-icon {
  width: 64px; height: 64px; margin: 0 auto 16px; border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
}
.empty .empty-icon svg { width: 30px; height: 30px; color: var(--success); }
.empty h3 { font-size: 16px; font-weight: 700; color: var(--text); margin: 0 0 4px; }
.empty p { font-size: 13.5px; margin: 0; }

.loading { display: flex; align-items: center; justify-content: center; gap: 10px;
  color: var(--text-muted); font-size: 14px; padding: 64px 20px; }
.spinner { width: 20px; height: 20px; border-radius: 50%;
  border: 2.5px solid var(--border-strong); border-top-color: var(--brand);
  animation: spin .7s linear infinite; }

/* ── Toasts ─────────────────────────────────────────────────────────────── */
.toast-host {
  position: fixed; z-index: 1000; right: 18px; bottom: 18px;
  display: flex; flex-direction: column; gap: 10px; align-items: flex-end;
  max-width: min(380px, calc(100vw - 32px)); pointer-events: none;
}
.toast {
  pointer-events: auto; cursor: pointer;
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-left: 3px solid var(--text-subtle);
  border-radius: var(--r-sm); padding: 12px 14px;
  box-shadow: var(--shadow-lg); font-size: 13.5px; line-height: 1.45;
  transform: translateY(12px); opacity: 0;
  transition: transform .25s cubic-bezier(.2, .8, .2, 1), opacity .25s ease;
}
.toast.show { transform: none; opacity: 1; }
.toast .toast-icon { flex-shrink: 0; width: 18px; height: 18px; margin-top: 1px; }
.toast .toast-icon svg { width: 18px; height: 18px; }
.toast.success { border-left-color: var(--success); }
.toast.success .toast-icon { color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.error .toast-icon { color: var(--danger); }
.toast.info { border-left-color: var(--brand); }
.toast.info .toast-icon { color: var(--brand); }
@media (max-width: 640px) {
  .toast-host { right: 12px; left: 12px; bottom: 12px; max-width: none; align-items: stretch; }
}

/* ── Animações ──────────────────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes ping { 75%, 100% { transform: scale(2.4); opacity: 0; } }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes rise { from { transform: translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* Busca única (topo do menu) */
.gsearch { position: relative; margin: 12px 12px 0; }
.gsearch > svg { position: absolute; left: 11px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: var(--text-subtle); pointer-events: none; }
.gsearch input { width: 100%; height: 38px; padding: 0 10px 0 34px; border: 1px solid var(--border); border-radius: var(--r-xs);
  background: var(--surface-2); color: var(--text); font: inherit; font-size: 13px; }
.gsearch input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); background: var(--surface); }
.gsearch-res { position: absolute; top: calc(100% + 6px); left: 0; width: max(100%, 360px); max-width: calc(100vw - 24px); z-index: 200;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm, 10px); box-shadow: var(--shadow-lg);
  max-height: 70vh; overflow-y: auto; padding: 4px; }
.gsearch-res a { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: var(--r-xs); color: var(--text); text-decoration: none; }
.gsearch-res a:hover, .gsearch-res a.sel { background: var(--brand-soft); }
.gs-type { flex-shrink: 0; min-width: 56px; font-size: 10.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--text-subtle); padding-top: 2px; }
.gs-main { min-width: 0; display: flex; flex-direction: column; }
.gs-main b { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gs-main small { font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gs-note { padding: 10px; font-size: 12.5px; color: var(--text-muted); }
.appbar-search { margin-left: auto; width: 38px; height: 38px; display: grid; place-items: center; border: 0; border-radius: var(--r-xs);
  background: none; color: var(--text); cursor: pointer; }
.appbar-search:hover { background: var(--surface-2); }
.appbar-search svg { width: 20px; height: 20px; }

/* ── Responsivo ─────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .appbar { display: flex; }
  .content { margin-left: 0; }
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: translateX(0); }
  .topbar { top: var(--appbar-h); }
  main { padding: 20px 16px 56px; }
  .toolbar { width: 100%; margin-left: 0; }
  .toolbar .field, .toolbar .btn { flex: 1 1 auto; }
}

@media (max-width: 900px) {
  .panel-grid { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .stats { grid-template-columns: 1fr; gap: 14px; }
  .stat-num { font-size: 46px; }
  .topbar { padding: 12px 16px; }
  main { padding: 16px 14px 48px; }
  .card { padding: 16px; }
  .card .row .btn { flex: 1 1 auto; }
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .kpi .kpi-value { font-size: 22px; }
  /* Segmentos ocupam a largura toda com botões iguais, sem vazar da tela. */
  .segment { display: flex; flex: 1 1 0; min-width: 0; }
  .segment button { flex: 1 1 auto; justify-content: center; padding: 8px 7px; font-size: 12.5px; min-width: 0; }
  /* Botão só com ícone no celular (ex.: Atualizar ao lado dos filtros). */
  .toolbar .btn.btn-icon-m { flex: 0 0 auto; }
  .btn-icon-m .btn-label { display: none; }
  .hide-m { display: none; }
  .topbar-actions .btn { padding-left: 12px; padding-right: 12px; }
  /* Cartão de anúncio: status e Editar descem para uma linha própria. */
  .item-head { flex-wrap: wrap; gap: 12px; }
  .item-thumb { width: 48px; height: 48px; }
  .item-main { flex: 1 1 calc(100% - 60px); }
  .item-actions { flex-direction: row; flex-wrap: wrap; justify-content: flex-start; align-items: center; width: 100%; }
  .mode-card { padding: 16px; }
  .mode-card .segment { flex-basis: 100%; }
  .mode-info { min-width: 0; }
  /* Valores em R$ cabem nos KPIs de duas colunas sem quebrar o número. */
  .kpi { padding: 14px; }
  .kpi .kpi-value { font-size: clamp(17px, 5.2vw, 22px); }
}

@media (min-width: 901px) {
  .appbar, .backdrop { display: none !important; }
  .sidebar { transform: none !important; }
}

/* Página sem acesso (menu não liberado para o usuário, ver app.js guardPage) */
.no-access { padding: 24px; }
.no-access .empty .btn { margin-top: 16px; text-decoration: none; }

/* Dados fiscais (public/fiscal.js) */
.fiscal-grid { margin-bottom: 0; }
.fiscal-grid .form-field .field { width: 100%; box-sizing: border-box; flex: none; }
.fiscal-ok { color: var(--success); font-weight: 600; }
.fiscal-no { color: var(--warn); font-weight: 600; }
.fiscal-src { font-size: 12.5px; color: var(--text-muted); margin: 0 0 10px; }

/* Promoções do anúncio (public/promocoes.js) */
.promos .pr-listing + .pr-listing { margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--border); }
.promos .pr-head { font-size: 13px; margin-bottom: 8px; }
.promos .pos { color: var(--success); }
.promos .neg { color: var(--danger); }
.pr-card { border: 1px solid var(--border); border-radius: var(--r-xs); background: var(--surface); padding: 10px 12px; margin-top: 8px; font-size: 13px; }
.pr-card.on { border-color: color-mix(in srgb, var(--success) 45%, var(--border)); }
.pr-top { display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.pr-st { margin-left: auto; font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-muted); }
.pr-st.on { background: var(--success-soft); color: var(--success); }
.pr-st.can { background: var(--brand-soft); color: var(--brand); }
.pr-nums { display: flex; flex-wrap: wrap; gap: 2px 16px; margin-top: 4px; }
.pr-calc { display: flex; flex-wrap: wrap; gap: 2px 12px; margin-top: 4px; }
.pr-profit { font-weight: 700; }
.pr-muted { color: var(--text-muted); font-size: 12px; }
.pr-form { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin-top: 8px; }
.pr-form label { display: flex; gap: 6px; align-items: center; font-size: 12.5px; }
.pr-form .field { width: 120px; padding: 6px 8px; font-size: 13px; flex: none; }
.pr-form input[type=date].field { width: 150px; }
.pr-twin { width: 100%; }
@media (max-width: 640px) { .pr-form .btn { width: 100%; } }
.edit-tabs { margin: 0 0 14px; overflow-x: auto; }
.edit-tabs .tab { font-size: 13.5px; padding: 8px 2px; white-space: nowrap; }

/* iPhone/iPad: o Safari dá zoom na página ao focar um campo com fonte menor que
   16px (acontecia ao abrir o painel, com o foco automático no campo de senha).
   Só nos aparelhos da Apple (-webkit-touch-callout), para o resto continuar igual. */
@supports (-webkit-touch-callout: none) {
  input:not([type=checkbox]):not([type=radio]):not([type=range]), select, textarea { font-size: 16px !important; }
}
