/* ── VARIÁVEIS ── */
:root {
  --bg:           #f4f7fb;
  --surface:      #ffffff;
  --surface2:     #f8fafc;
  --border:       #e1e7f0;
  --border-hover: #c7d2e4;
  --border-focus: #06b6d4;

  --accent:       #06b6d4;
  --accent-dark:  #0891b2;
  --accent-dim:   rgba(6,182,212,0.08);
  --accent-glow:  rgba(6,182,212,0.2);

  --green:        #10b981;
  --green-dim:    rgba(16,185,129,0.08);
  --green-glow:   rgba(16,185,129,0.2);

  --blue:         #3b82f6;
  --blue-dim:     rgba(59,130,246,0.08);

  --orange:       #f97316;
  --orange-dim:   rgba(249,115,22,0.08);

  --purple:       #8b5cf6;
  --purple-dim:   rgba(139,92,246,0.08);

  --red:          #ef4444;
  --red-dim:      rgba(239,68,68,0.08);

  --text:         #0f172a;
  --muted:        #64748b;
  --muted2:       #94a3b8;

  --shadow-xs:    0 1px 2px rgba(15,23,42,0.05);
  --shadow-sm:    0 1px 4px rgba(15,23,42,0.06), 0 1px 2px rgba(15,23,42,0.04);
  --shadow:       0 4px 16px rgba(15,23,42,0.08), 0 2px 6px rgba(15,23,42,0.04);
  --shadow-lg:    0 16px 48px rgba(15,23,42,0.12), 0 4px 12px rgba(15,23,42,0.06);
}

/* ── TEMA ESCURO ── */
[data-theme="dark"] {
  --bg:           #0b0f1a;
  --surface:      #111827;
  --surface2:     #1a2236;
  --border:       rgba(255,255,255,0.08);
  --border-hover: rgba(255,255,255,0.14);

  --accent-dim:   rgba(6,182,212,0.14);
  --green-dim:    rgba(16,185,129,0.13);
  --blue-dim:     rgba(59,130,246,0.13);
  --orange-dim:   rgba(249,115,22,0.13);
  --purple-dim:   rgba(139,92,246,0.13);
  --red-dim:      rgba(239,68,68,0.13);

  --text:         #e8edf5;
  --muted:        #6b7a99;
  --muted2:       #4a5568;

  --shadow-xs:    0 1px 3px rgba(0,0,0,0.4);
  --shadow-sm:    0 1px 4px rgba(0,0,0,0.5), 0 1px 2px rgba(0,0,0,0.3);
  --shadow:       0 4px 16px rgba(0,0,0,0.5), 0 2px 6px rgba(0,0,0,0.3);
  --shadow-lg:    0 16px 48px rgba(0,0,0,0.6), 0 4px 12px rgba(0,0,0,0.4);
}

[data-theme="dark"] body {
  background: var(--bg);
}

/* Ambient glow no dark mode */
[data-theme="dark"] body::before {
  content: '';
  position: fixed; top: -200px; left: -200px;
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(6,182,212,0.06) 0%, transparent 70%);
  pointer-events: none; z-index: 0;
}
[data-theme="dark"] body::after {
  content: '';
  position: fixed; bottom: -200px; right: -200px;
  width: 700px; height: 700px;
  background: radial-gradient(circle, rgba(16,185,129,0.05) 0%, transparent 70%);
  pointer-events: none; z-index: 0;
}

/* Ajustes específicos do dark mode */
[data-theme="dark"] .stat-card:hover { border-color: rgba(6,182,212,0.4); }
[data-theme="dark"] tr:hover td { background: rgba(255,255,255,0.02); }
[data-theme="dark"] .activity-item:hover { background: rgba(255,255,255,0.02); }
[data-theme="dark"] .user-card:hover { background: rgba(255,255,255,0.04); }
[data-theme="dark"] .card:hover { border-color: rgba(255,255,255,0.12); }
[data-theme="dark"] .nav-item:hover { background: rgba(255,255,255,0.05); border-color: rgba(255,255,255,0.06); }
[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea { color: var(--text); }
[data-theme="dark"] select option { background: #1a2236; }
[data-theme="dark"] .tabs { border-color: rgba(255,255,255,0.08); }
[data-theme="dark"] .tab.active { box-shadow: 0 1px 4px rgba(0,0,0,0.5); }
[data-theme="dark"] .filter-chip { background: var(--surface2); }
[data-theme="dark"] .filter-chip:hover { background: rgba(6,182,212,0.1); }
[data-theme="dark"] .btn-ghost { background: var(--surface2); border-color: rgba(255,255,255,0.1); }
[data-theme="dark"] .btn-ghost:hover { background: rgba(255,255,255,0.06); border-color: var(--accent); }
[data-theme="dark"] .notif { background: var(--surface); border-color: rgba(255,255,255,0.1); }
[data-theme="dark"] .action-btn { background: var(--surface2); border-color: rgba(255,255,255,0.07); }
[data-theme="dark"] .status-badge.aprovado  { background: rgba(16,185,129,0.15);  color: #34d399; }
[data-theme="dark"] .status-badge.aprovado::before  { background: #34d399; }
[data-theme="dark"] .status-badge.pendente  { background: rgba(245,158,11,0.15);  color: #fbbf24; }
[data-theme="dark"] .status-badge.pendente::before  { background: #fbbf24; }
[data-theme="dark"] .status-badge.enviado   { background: rgba(59,130,246,0.15);  color: #60a5fa; }
[data-theme="dark"] .status-badge.enviado::before   { background: #60a5fa; }
[data-theme="dark"] .status-badge.expirado  { background: rgba(245,158,11,0.15);  color: #fbbf24; }
[data-theme="dark"] .status-badge.expirado::before  { background: #fbbf24; }
[data-theme="dark"] .status-badge.rascunho  { background: rgba(100,116,139,0.15); color: #94a3b8; }
[data-theme="dark"] .status-badge.rascunho::before  { background: #94a3b8; }
[data-theme="dark"] .status-badge.em_execucao  { background: rgba(245,158,11,0.15);  color: #fbbf24; }
[data-theme="dark"] .status-badge.em_execucao::before  { background: #fbbf24; }
[data-theme="dark"] .status-badge.aguardando_pagamento  { background: rgba(139,92,246,0.15); color: #a78bfa; }
[data-theme="dark"] .status-badge.aguardando_pagamento::before  { background: #a78bfa; }
[data-theme="dark"] .status-badge.cancelado  { background: rgba(239,68,68,0.15);   color: #f87171; }
[data-theme="dark"] .status-badge.cancelado::before  { background: #f87171; }
[data-theme="dark"] .status-badge.inativo   { background: rgba(107,114,128,0.15); color: #9ca3af; }
[data-theme="dark"] .status-badge.inativo::before   { background: #9ca3af; }
[data-theme="dark"] .total-row { background: rgba(255,255,255,0.03); }
[data-theme="dark"] .modal-footer { background: var(--surface2); }
[data-theme="dark"] .table-filters { background: var(--surface2); }
[data-theme="dark"] th { background: rgba(255,255,255,0.03); }
[data-theme="dark"] .alertas-banner { background: rgba(249,115,22,0.1); border-color: rgba(249,115,22,0.2); }

/* ── Tema escuro via preferência do OS (Firefox, Safari, etc.) ── */
/* Aplica quando o OS está em dark mode e o usuário não forçou light manualmente */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:           #0b0f1a;
    --surface:      #111827;
    --surface2:     #1a2236;
    --border:       rgba(255,255,255,0.08);
    --border-hover: rgba(255,255,255,0.14);
    --accent-dim:   rgba(6,182,212,0.14);
    --green-dim:    rgba(16,185,129,0.13);
    --blue-dim:     rgba(59,130,246,0.13);
    --orange-dim:   rgba(249,115,22,0.13);
    --purple-dim:   rgba(139,92,246,0.13);
    --red-dim:      rgba(239,68,68,0.13);
    --text:         #e8edf5;
    --muted:        #6b7a99;
    --muted2:       #4a5568;
    --shadow-xs:    0 1px 3px rgba(0,0,0,0.4);
    --shadow-sm:    0 1px 4px rgba(0,0,0,0.5), 0 1px 2px rgba(0,0,0,0.3);
    --shadow:       0 4px 16px rgba(0,0,0,0.5), 0 2px 6px rgba(0,0,0,0.3);
    --shadow-lg:    0 16px 48px rgba(0,0,0,0.6), 0 4px 12px rgba(0,0,0,0.4);
  }
  :root:not([data-theme="light"]) body { background: var(--bg); }
  :root:not([data-theme="light"]) .stat-card:hover { border-color: rgba(6,182,212,0.4); }
  :root:not([data-theme="light"]) tr:hover td { background: rgba(255,255,255,0.02); }
  :root:not([data-theme="light"]) .card:hover { border-color: rgba(255,255,255,0.12); }
  :root:not([data-theme="light"]) .nav-item:hover { background: rgba(255,255,255,0.05); border-color: rgba(255,255,255,0.06); }
  :root:not([data-theme="light"]) input,
  :root:not([data-theme="light"]) select,
  :root:not([data-theme="light"]) textarea { color: var(--text); }
  :root:not([data-theme="light"]) select option { background: #1a2236; }
  :root:not([data-theme="light"]) .filter-chip { background: var(--surface2); }
  :root:not([data-theme="light"]) .btn-ghost { background: var(--surface2); border-color: rgba(255,255,255,0.1); }
  :root:not([data-theme="light"]) th { background: rgba(255,255,255,0.03); }
  :root:not([data-theme="light"]) .modal-footer { background: var(--surface2); }
  :root:not([data-theme="light"]) .table-filters { background: var(--surface2); }
  :root:not([data-theme="light"]) .alertas-banner { background: rgba(249,115,22,0.1); border-color: rgba(249,115,22,0.2); }
  :root:not([data-theme="light"]) .status-badge.aprovado  { background: rgba(16,185,129,0.15);  color: #34d399; }
  :root:not([data-theme="light"]) .status-badge.aprovado::before  { background: #34d399; }
  :root:not([data-theme="light"]) .status-badge.pendente  { background: rgba(245,158,11,0.15);  color: #fbbf24; }
  :root:not([data-theme="light"]) .status-badge.pendente::before  { background: #fbbf24; }
  :root:not([data-theme="light"]) .status-badge.enviado   { background: rgba(59,130,246,0.15);  color: #60a5fa; }
  :root:not([data-theme="light"]) .status-badge.enviado::before  { background: #60a5fa; }
  :root:not([data-theme="light"]) .status-badge.expirado  { background: rgba(245,158,11,0.15);  color: #fbbf24; }
  :root:not([data-theme="light"]) .status-badge.expirado::before  { background: #fbbf24; }
  :root:not([data-theme="light"]) .status-badge.rascunho  { background: rgba(100,116,139,0.15); color: #94a3b8; }
  :root:not([data-theme="light"]) .status-badge.rascunho::before  { background: #94a3b8; }
  :root:not([data-theme="light"]) .status-badge.em_execucao  { background: rgba(245,158,11,0.15);  color: #fbbf24; }
  :root:not([data-theme="light"]) .status-badge.em_execucao::before  { background: #fbbf24; }
  :root:not([data-theme="light"]) .status-badge.aguardando_pagamento  { background: rgba(139,92,246,0.15); color: #a78bfa; }
  :root:not([data-theme="light"]) .status-badge.aguardando_pagamento::before  { background: #a78bfa; }
  :root:not([data-theme="light"]) .status-badge.cancelado  { background: rgba(239,68,68,0.15);   color: #f87171; }
  :root:not([data-theme="light"]) .status-badge.cancelado::before  { background: #f87171; }
  :root:not([data-theme="light"]) .status-badge.inativo   { background: rgba(107,114,128,0.15); color: #9ca3af; }
  :root:not([data-theme="light"]) .status-badge.inativo::before  { background: #9ca3af; }
}

/* Botão de tema (fica no rodapé da sidebar, acima do user-card) */
.btn-tema {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 6px 10px; margin-bottom: 4px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; cursor: pointer; font-size: 12px; font-weight: 500;
  color: var(--muted); transition: all 0.15s;
}
.btn-tema::after { content: attr(data-label); }
.btn-tema:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }

/* ── RESET ── */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── SIDEBAR ── */
.sidebar {
  position: fixed; top: 0; left: 0;
  width: 232px; height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 100;
  transition: left 0.3s ease;
}

.logo {
  padding: 18px 18px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: flex-start;
}
.logo-mark {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 19px; font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
  line-height: 1;
}
.logo-mark span { color: var(--accent); }
.logo-sub { font-size: 11px; color: var(--muted2); margin-top: 3px; letter-spacing: 0.02em; }

.nav {
  flex: 1; padding: 10px 10px;
  display: flex; flex-direction: column; gap: 1px;
  overflow-y: auto;
}
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 11px; border-radius: 8px;
  font-size: 13.5px; font-weight: 500;
  color: var(--muted); cursor: pointer;
  transition: all 0.15s; border: 1px solid transparent;
  text-decoration: none; line-height: 1;
}
.nav-item:hover { color: var(--text); background: var(--bg); border-color: var(--border); }
.nav-item.active {
  color: var(--accent); background: var(--accent-dim);
  border-color: rgba(6,182,212,0.18); font-weight: 600;
}
.nav-icon {
  width: 17px; height: 17px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; opacity: 0.65;
}
.nav-item.active .nav-icon,
.nav-item:hover .nav-icon { opacity: 1; }
.nav-badge {
  margin-left: auto; background: var(--accent); color: #fff;
  font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 20px;
}
.nav-divider { height: 1px; background: var(--border); margin: 5px 4px; }

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

/* ── User card ── */
.user-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: 8px;
  transition: background 0.15s;
  cursor: default;
}
.user-card:hover { background: var(--bg); }
.user-avatar {
  width: 30px; height: 30px; border-radius: 7px;
  background: linear-gradient(135deg, var(--accent), #3b82f6);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 11px; color: #fff; flex-shrink: 0;
}
.user-text { min-width: 0; flex: 1; }
.user-name { font-size: 13px; font-weight: 600; color: var(--text); line-height: 1.3; }
.user-card-sub {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}
.user-plan {
  font-size: 11px;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-upgrade-link {
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--accent-dim);
  border: 1px solid rgba(6,182,212,0.25);
  white-space: nowrap;
  flex-shrink: 0;
  line-height: 1.7;
  transition: background 0.15s, color 0.15s;
}
.sidebar-upgrade-link:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ── Sidebar: Plan Card ── */
.sidebar-plan-card {
  margin: 0 10px 6px;
  padding: 8px 10px;
  background: var(--surface2);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.sidebar-plan-card .spc-row {
  margin-bottom: 6px;
}

.sidebar-plan-card .spc-row:last-child {
  margin-bottom: 0;
}

.sidebar-plan-card .spc-label {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 3px;
}

.sidebar-plan-card .spc-bar {
  height: 4px;
  background: var(--bg);
  border-radius: 2px;
  overflow: hidden;
}

.sidebar-plan-card .spc-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.4s;
}

.sidebar-plan-card .spc-bar-fill.accent { background: var(--accent); }
.sidebar-plan-card .spc-bar-fill.blue { background: var(--blue); }

.sidebar-plan-card .spc-validade {
  font-size: 10px;
  color: var(--muted);
  text-align: center;
  padding-top: 3px;
  border-top: 1px solid var(--border);
  margin-top: 3px;
}

/* ── Sidebar: Broadcast ── */
.sidebar-broadcast {
  margin: 0 10px 6px;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid rgba(6,182,212,0.2);
  background: var(--accent-dim);
  font-size: 11px;
  color: var(--text);
  line-height: 1.35;
}

.sidebar-broadcast.warning {
  background: rgba(245,158,11,0.08);
  border-color: rgba(245,158,11,0.2);
}

.sidebar-broadcast.urgent {
  background: rgba(239,68,68,0.06);
  border-color: rgba(239,68,68,0.2);
}

.sidebar-broadcast .sb-msg {
  margin: 0;
  font-size: 12px;
  line-height: 1.4;
}

.sidebar-broadcast .sb-dismiss {
  font-size: 10px;
  color: var(--muted);
  cursor: pointer;
  margin-top: 4px;
  display: inline-block;
}

.sidebar-broadcast .sb-dismiss:hover {
  color: var(--text);
}

/* ── Sidebar: Back to Admin ── */
.nav-item.nav-admin-back {
  color: #f97316;
}

.nav-item.nav-admin-back:hover {
  background: rgba(249,115,22,0.08);
  border-color: rgba(249,115,22,0.2);
}

.nav-item.nav-admin-link {
  color: #f97316;
}

.nav-item.nav-admin-link:hover {
  background: rgba(249,115,22,0.08);
  border-color: rgba(249,115,22,0.2);
}

.nav-item.nav-planos-link {
  color: var(--blue);
}

.nav-item.nav-planos-link:hover {
  background: rgba(59,130,246,0.08);
  border-color: rgba(59,130,246,0.2);
}

.nav-item.nav-config-admin-link {
  color: #fbbf24;
}

.nav-item.nav-config-admin-link:hover {
  background: rgba(251,191,36,0.08);
  border-color: rgba(251,191,36,0.2);
}

.nav-item.nav-comercial-link {
  color: var(--accent);
}

.nav-item.nav-comercial-link:hover {
  background: var(--accent-dim);
  border-color: rgba(6,182,212,0.2);
}

.nav-item.nav-ia-link {
  color: #8b5cf6;
}

.nav-item.nav-ia-link:hover {
  background: rgba(139,92,246,0.08);
  border-color: rgba(139,92,246,0.2);
}

/* ── MAIN ── */
.main {
  margin-left: 232px;
  padding: 26px 32px 40px;
  position: relative;
  min-height: 100vh;
}

/* ── TOPBAR ── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 26px; flex-wrap: wrap; gap: 12px;
}
.topbar-title-wrap { flex: 1; min-width: 0; }
.page-title {
  font-family: 'Outfit', sans-serif;
  font-size: 22px; font-weight: 700; color: var(--text); line-height: 1.2;
}
.page-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

#topbar-notificacoes { display: inline-flex; align-items: center; flex: 0 0 auto; }
#topbar-notificacoes .topbar-notification-btn { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; min-width: 36px; border: none; border-radius: 10px; background: var(--surface2); color: var(--text); cursor: pointer; font-size: 16px; padding: 0; }
#topbar-notificacoes .topbar-notification-btn.is-empty { color: var(--muted); }
#topbar-notificacoes .topbar-notification-badge { position: absolute; top: 2px; right: 2px; background: #ef4444; color: #fff; font-size: 10px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; display: flex; align-items: center; justify-content: center; line-height: 1; }

@media (max-width: 768px) {
  #topbar-notificacoes { align-self: flex-start; width: auto !important; }
  #topbar-notificacoes .topbar-notification-btn { width: 36px !important; max-width: 36px !important; display: inline-flex !important; margin: 0 !important; text-align: center !important; white-space: nowrap !important; }
}

/* ── BOTÕES ── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px; border-radius: 8px;
  font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all 0.15s;
  border: none; font-family: 'DM Sans', sans-serif; white-space: nowrap;
}
.btn-primary {
  background: var(--accent); color: #fff;
  box-shadow: 0 1px 3px rgba(6,182,212,0.25);
}
.btn-primary:hover {
  background: var(--accent-dark);
  box-shadow: 0 4px 14px rgba(6,182,212,0.35);
  transform: translateY(-1px);
}
.btn-ghost {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); box-shadow: var(--shadow-xs);
}
.btn-ghost:hover { background: var(--bg); border-color: var(--accent); color: var(--accent); }
.btn-danger { background: var(--red-dim); color: var(--red); border: 1px solid rgba(239,68,68,0.18); }
.btn-danger:hover { background: rgba(239,68,68,0.14); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

/* ── STAT CARDS ── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 14px; margin-bottom: 22px;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 20px;
  position: relative; overflow: hidden; cursor: pointer;
  transition: box-shadow 0.2s, transform 0.2s, border-color 0.2s;
  box-shadow: var(--shadow-sm);
}
.stat-card:hover {
  box-shadow: var(--shadow); transform: translateY(-2px);
  border-color: var(--border-focus);
}
.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0;
  height: 3px; border-radius: 14px 14px 0 0;
}
.stat-card.green::before  { background: linear-gradient(90deg, #10b981, rgba(16,185,129,0.05)); }
.stat-card.blue::before   { background: linear-gradient(90deg, #3b82f6, rgba(59,130,246,0.05)); }
.stat-card.orange::before { background: linear-gradient(90deg, #f97316, rgba(249,115,22,0.05)); }
.stat-card.purple::before { background: linear-gradient(90deg, #8b5cf6, rgba(139,92,246,0.05)); }
.stat-card.cyan::before   { background: linear-gradient(90deg, #06b6d4, rgba(6,182,212,0.05)); }

.stat-icon {
  width: 38px; height: 38px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; margin-bottom: 14px; flex-shrink: 0;
}
.stat-icon.green  { background: var(--green-dim);  color: #059669; }
.stat-icon.blue   { background: var(--blue-dim);   color: var(--blue); }
.stat-icon.orange { background: var(--orange-dim); color: var(--orange); }
.stat-icon.purple { background: var(--purple-dim); color: var(--purple); }
.stat-icon.cyan   { background: var(--accent-dim); color: var(--accent); }

.stat-value {
  font-family: 'Outfit', sans-serif; font-size: 23px; font-weight: 700;
  line-height: 1; color: var(--text); letter-spacing: -0.3px;
}
.stat-label { font-size: 12px; color: var(--muted); margin-top: 5px; font-weight: 400; }
.stat-delta, .stat-trend {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 500; margin-top: 9px;
  padding: 3px 8px; border-radius: 20px;
}
.stat-delta.up, .stat-trend.up   { color: #059669; background: var(--green-dim); }
.stat-delta.down, .stat-trend.down { color: var(--orange); background: var(--orange-dim); }

/* ── CHARTS ── */
.charts-grid {
  display: grid; grid-template-columns: 1fr 280px;
  gap: 14px; margin-bottom: 22px;
}
.chart-container { padding: 4px 8px 12px; position: relative; height: 196px; }

/* ── CARD ── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; overflow: hidden; box-shadow: var(--shadow-sm);
}
.card:hover { border-color: var(--border-hover); }
.card-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-title {
  font-family: 'Outfit', sans-serif; font-size: 14px; font-weight: 600; color: var(--text);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.card-action {
  font-size: 12px; color: var(--accent); cursor: pointer;
  text-decoration: none; font-weight: 500; transition: color 0.15s;
}
.card-action:hover { color: var(--accent-dark); }

/* ── CONTENT GRID ── */
.content-grid { display: grid; grid-template-columns: 1fr 320px; gap: 14px; }
.right-panel { display: flex; flex-direction: column; gap: 14px; }

@media (max-width: 1024px) {
    .right-panel {
        display: none !important;
        position: fixed;
        bottom: 85px;
        right: 20px;
        left: 20px;
        z-index: 1000;
        background: var(--surface);
        box-shadow: 0 8px 32px rgba(0,0,0,0.4);
        border: 1px solid var(--border);
        border-radius: 16px;
        padding: 16px;
        max-height: 70vh;
        overflow-y: auto;
    }
    .content-grid {
        grid-template-columns: 1fr !important;
    }
}

/* ── TABLE ── */
.table-filters {
  padding: 12px 20px; display: flex; gap: 6px;
  border-bottom: 1px solid var(--border); background: var(--surface2); flex-wrap: wrap;
}
.filter-chip {
  padding: 5px 14px; border-radius: 20px;
  font-size: 12px; cursor: pointer; border: 1px solid var(--border);
  background: var(--surface); color: var(--muted);
  transition: all 0.15s; font-family: inherit; font-weight: 500;
}
.filter-chip:hover { border-color: var(--accent); color: var(--accent); }
.filter-chip.active {
  background: var(--accent-dim); color: var(--accent);
  border-color: rgba(6,182,212,0.3); font-weight: 600;
}
.filter-chip-vencendo { color: #ea580c; border-color: rgba(249,115,22,0.3); }
.filter-chip-vencendo:hover { border-color: #ea580c; color: #ea580c; background: rgba(249,115,22,0.07); }
.filter-chip-vencendo.active { background: rgba(249,115,22,0.1); color: #ea580c; border-color: rgba(249,115,22,0.4); }
.filter-chip-execucao { color: #d97706; border-color: rgba(217,119,6,0.3); }
.filter-chip-execucao:hover { border-color: #d97706; color: #d97706; background: rgba(217,119,6,0.07); }
.filter-chip-execucao.active { background: rgba(217,119,6,0.1); color: #d97706; border-color: rgba(217,119,6,0.4); }
.filter-chip-aguardando { color: #7c3aed; border-color: rgba(124,58,237,0.3); }
.filter-chip-aguardando:hover { border-color: #7c3aed; color: #7c3aed; background: rgba(124,58,237,0.07); }
.filter-chip-aguardando.active { background: rgba(124,58,237,0.1); color: #7c3aed; border-color: rgba(124,58,237,0.4); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 600px; }
th {
  padding: 10px 20px; text-align: left; font-size: 11px; font-weight: 600;
  color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em;
  background: var(--surface2); border-bottom: 1px solid var(--border);
}
td {
  padding: 13px 20px; font-size: 13px;
  border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text);
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg); }

/* Linhas de orçamento clicáveis (dashboard + listagem) */
.orc-row-clickable td {
  cursor: pointer;
  transition: background 0.12s ease;
}

.client-cell { display: flex; align-items: center; gap: 10px; }
.client-avatar {
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.client-name { font-weight: 500; font-size: 13px; color: var(--text); }
.client-service { font-size: 11px; color: var(--muted); margin-top: 1px; }
.value-cell { font-family: 'Outfit', sans-serif; font-weight: 600; font-size: 13px; }

/* ── STATUS BADGES ── */
.status-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
  text-transform: uppercase; letter-spacing: 0.03em;
}
.status-badge::before { content: ''; width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0; }
.status-badge.aprovado  { background: rgba(16,185,129,0.1);  color: #059669; }
.status-badge.aprovado::before  { background: #059669; }
.status-badge.pendente  { background: rgba(245,158,11,0.1);  color: #d97706; }
.status-badge.pendente::before  { background: #d97706; }
.status-badge.enviado   { background: rgba(59,130,246,0.1);  color: var(--blue); }
.status-badge.enviado::before   { background: var(--blue); }
.status-badge.expirado  { background: rgba(245,158,11,0.1);   color: #d97706; }
.status-badge.expirado::before  { background: #d97706; }
.status-badge.rascunho  { background: rgba(100,116,139,0.1); color: var(--muted); }
.status-badge.rascunho::before  { background: var(--muted); }
.status-badge.em_execucao  { background: rgba(245,158,11,0.1);  color: #d97706; }
.status-badge.em_execucao::before  { background: #d97706; }
.status-badge.aguardando_pagamento  { background: rgba(139,92,246,0.1); color: #7c3aed; }
.status-badge.aguardando_pagamento::before  { background: #7c3aed; }
.status-badge.cancelado  { background: rgba(239,68,68,0.1);   color: #dc2626; }
.status-badge.cancelado::before  { background: #dc2626; }
.status-badge.inativo   { background: rgba(107,114,128,0.1); color: #6b7280; }
.status-badge.inativo::before   { background: #6b7280; }

/* ── ACTION BUTTONS ── */
.action-btn {
  background: var(--bg); border: 1px solid var(--border);
  color: var(--muted); padding: 5px 9px; border-radius: 7px;
  font-size: 12px; cursor: pointer; transition: all 0.15s; font-family: inherit;
}
.action-btn:hover      { color: var(--accent); border-color: rgba(6,182,212,0.3); background: var(--accent-dim); }
.action-btn.send:hover { color: var(--green);  border-color: rgba(16,185,129,0.3); background: var(--green-dim); }
.action-btn.edit:hover { color: var(--blue);   border-color: rgba(59,130,246,0.3); background: var(--blue-dim); }
.action-btn.pdf:hover  { color: var(--orange); border-color: rgba(249,115,22,0.3); background: var(--orange-dim); }
.action-btns { display: flex; gap: 4px; flex-wrap: nowrap; }

/* ── MODAL PDF ── */
.modal-pdf { width: min(880px, 95vw); max-height: 95vh; overflow: hidden; }
.modal-pdf .modal-body { padding: 0; height: 78vh; background: #525659; border-radius: 0 0 20px 20px; }
.modal-pdf iframe { width: 100%; height: 100%; border: none; border-radius: 0 0 20px 20px; }

/* ── FORMS ── */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }
label { font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
input, select, textarea {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; padding: 9px 12px;
  color: var(--text); font-size: 13.5px; font-family: 'DM Sans', sans-serif;
  outline: none; transition: border-color 0.15s, box-shadow 0.15s; width: 100%;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(6,182,212,0.1);
}
textarea { resize: vertical; min-height: 80px; }
select option { background: var(--surface); color: var(--text); }
.input-error { border-color: rgba(239,68,68,0.5) !important; }
.error-msg { font-size: 11px; color: var(--red); margin-top: 4px; }

/* ── MODAL ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,23,42,0.5); backdrop-filter: blur(4px);
  z-index: 200; display: none; align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from{opacity:0} to{opacity:1} }
.modal,
.modal-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; width: 560px; max-height: 90vh; overflow-y: auto;
  animation: slideUp 0.25s ease; box-shadow: var(--shadow-lg);
  font-family: 'DM Sans', sans-serif;
}
@keyframes slideUp { from{transform:translateY(16px);opacity:0} to{transform:none;opacity:1} }
.modal-header {
  padding: 22px 26px 18px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; background: var(--surface); z-index: 1;
}
.modal-title { font-family: 'Outfit', sans-serif; font-size: 17px; font-weight: 700; color: var(--text); }
.modal-close {
  width: 30px; height: 30px; border-radius: 7px;
  background: var(--bg); border: 1px solid var(--border);
  color: var(--muted); cursor: pointer; font-size: 14px;
  display: flex; align-items: center; justify-content: center; transition: all 0.15s;
}
.modal-close:hover { color: var(--text); border-color: var(--accent); }
/* Exceção: forçar botão X visível em mobile (usado em modais compactos) */
.modal-close.modal-close--force { display: flex !important; }
.modal-body { padding: 22px 26px; display: flex; flex-direction: column; gap: 16px; font-family: 'DM Sans', sans-serif; }
.modal-footer {
  padding: 16px 26px; display: flex; justify-content: flex-end; gap: 12px;
  border-top: 1px solid var(--border);
}
.modal-drag-handle { display: none; }

/* Herdam do .modal (.modal-title etc. continuam com font-family próprio). */
.modal input,
.modal select,
.modal textarea,
.modal button {
  font-family: inherit;
}

/* ── WHATSAPP ── */
.wpp-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow-sm); }
.wpp-header { background: #0a4a3a; padding: 13px 16px; display: flex; align-items: center; gap: 11px; }
.wpp-avatar-circle {
  width: 34px; height: 34px; border-radius: 50%;
  background: rgba(255,255,255,0.12);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.wpp-dot { width: 7px; height: 7px; border-radius: 50%; background: #25d366; box-shadow: 0 0 8px rgba(37,211,102,0.6); }
.wpp-title { font-size: 13px; font-weight: 600; color: #fff; }
.wpp-sub { font-size: 11px; color: rgba(255,255,255,0.5); margin-top: 1px; }
.wpp-body {
  padding: 12px 12px; background: #0d1f1a;
  display: flex; flex-direction: column; gap: 7px;
  min-height: 190px; max-height: 250px; overflow-y: auto;
}
.wpp-body::-webkit-scrollbar { width: 4px; }
.wpp-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 4px; }
.msg {
  max-width: 82%; padding: 8px 11px; border-radius: 10px;
  font-size: 12.5px; line-height: 1.5; position: relative;
}
.msg-time { font-size: 10px; color: rgba(255,255,255,0.3); margin-top: 3px; text-align: right; }
.msg.received { background: #1a332b; align-self: flex-start; border-bottom-left-radius: 3px; color: #d0ede2; }
.msg.sent { background: #005c4b; align-self: flex-end; border-bottom-right-radius: 3px; color: #dcf8c6; }
.msg-typing {
  display: flex; gap: 4px; align-items: center;
  background: #1a332b; padding: 10px 14px;
  border-radius: 10px; align-self: flex-start; width: 56px; border-bottom-left-radius: 3px;
}
.dot-anim {
  width: 5px; height: 5px; border-radius: 50%;
  background: rgba(255,255,255,0.35); animation: bounce 1.2s infinite;
}
.dot-anim:nth-child(2) { animation-delay: 0.2s; }
.dot-anim:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce { 0%,60%,100%{transform:translateY(0)} 30%{transform:translateY(-5px)} }
.wpp-chips {
  display: flex; flex-wrap: wrap; gap: 5px;
  padding: 8px 12px; background: #0d1a15;
  border-top: 1px solid rgba(255,255,255,0.05);
}
.chip-btn {
  background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 14px; padding: 5px 10px;
  font-size: 11px; color: rgba(255,255,255,0.5);
  cursor: pointer; font-family: inherit; transition: all 0.15s;
}
.chip-btn:hover { border-color: #25d366; color: #25d366; background: rgba(37,211,102,0.08); }
.wpp-input {
  padding: 10px 12px; background: #0d1a15;
  border-top: 1px solid rgba(255,255,255,0.05);
  display: flex; gap: 7px; align-items: center;
}
.wpp-input input {
  flex: 1; background: #1a2e26; border: 1px solid rgba(255,255,255,0.08);
  border-radius: 20px; padding: 7px 13px;
  color: #d0ede2; font-size: 12px; font-family: inherit; outline: none;
}
.wpp-input input:focus { border-color: rgba(37,211,102,0.35); box-shadow: none; }
.wpp-input input::placeholder { color: rgba(255,255,255,0.2); }
.mic-btn, .send-btn {
  width: 32px; height: 32px; border-radius: 50%; border: none;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 14px; transition: all 0.15s;
}
.mic-btn { background: rgba(255,255,255,0.07); color: rgba(255,255,255,0.4); }
.mic-btn:hover { background: rgba(249,115,22,0.2); color: var(--orange); }
.mic-btn.listening { background: rgba(239,68,68,0.25); color: #f87171; animation: mic-pulse 1s ease-in-out infinite; }
@keyframes mic-pulse { 0%,100%{box-shadow:0 0 0 0 rgba(239,68,68,0.4)} 50%{box-shadow:0 0 0 8px rgba(239,68,68,0)} }
.send-btn { background: #25d366; color: #fff; }
.send-btn:hover { background: #1ea855; transform: scale(1.06); }

/* ── ACTIVITY ── */
.activity-list { display: flex; flex-direction: column; }
.activity-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 18px; border-bottom: 1px solid var(--border); transition: background 0.15s;
}
.activity-item:last-child { border-bottom: none; }
.activity-item:hover { background: var(--bg); }
.activity-dot { width: 7px; height: 7px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.activity-text { font-size: 12.5px; line-height: 1.5; color: var(--text); }
.activity-text strong { font-weight: 600; }
.activity-time { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ── LEMBRETE ENVIADO (feedback na listagem) ── */
.lembrete-enviado-badge {
  font-size: 11px; color: #b45309; margin-top: 4px;
  display: inline-flex; align-items: center; gap: 4px;
}
[data-theme="dark"] .lembrete-enviado-badge { color: #fbbf24; }

/* ── CATÁLOGO ── */
.catalogo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }

/* ── NOTIFICAÇÃO ── */
.notif {
  position: fixed; bottom: 20px; right: 20px; z-index: 9999;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px 18px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: var(--shadow-lg);
  transform: translateX(calc(100% + 30px));
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-width: 320px;
}
.notif.show { transform: translateX(0); }
.notif-icon { font-size: 20px; flex-shrink: 0; }
.notif-title { font-size: 13px; font-weight: 600; overflow-wrap: break-word; word-break: break-word; color: var(--text); }
.notif-sub { font-size: 12px; color: var(--muted); margin-top: 2px; overflow-wrap: break-word; word-break: break-word; white-space: pre-line; }
body.quick-quote-open .notif {
  bottom: 12px;
  right: 12px;
  padding: 8px 12px;
  max-width: 240px;
  border-radius: 8px;
  gap: 8px;
}
body.quick-quote-open .notif-icon { font-size: 16px; }
body.quick-quote-open .notif-title { font-size: 12px; }
body.quick-quote-open .notif-sub { font-size: 11px; margin-top: 0; }

/* ── TABS ── */
.tabs {
  display: flex; gap: 2px; padding: 3px;
  background: var(--bg); border-radius: 10px;
  border: 1px solid var(--border); margin-bottom: 20px;
}
.tab {
  flex: 1; padding: 7px 14px; border-radius: 7px;
  font-size: 13px; font-weight: 500; cursor: pointer;
  text-align: center; transition: all 0.15s;
  background: transparent; border: none; color: var(--muted); font-family: 'DM Sans', sans-serif;
}
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); font-weight: 600; }

/* ── NAVEGAÇÃO ENTRE PÁGINAS DE RELATÓRIOS ── */
.nav-relatorios {
  display: flex;
  gap: 10px;
  padding: 4px;
  border-bottom: none;
}
.nav-relatorios .tab-button {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 18px;
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  border-bottom: none;
  box-shadow: var(--shadow-xs);
  text-decoration: none !important;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.nav-relatorios .tab-button:hover {
  background: var(--surface);
  border-color: var(--border-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.nav-relatorios .tab-button.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 4px 14px var(--accent-glow);
}
.nav-relatorios .tab-button.active svg {
  stroke: #fff;
}
@media (max-width: 768px) {
  .nav-relatorios {
    gap: 6px;
    padding: 4px;
  }
  .nav-relatorios .tab-button {
    padding: 8px 12px;
    font-size: 12px;
    flex: 1 1 auto;
    min-width: 140px;
    justify-content: center;
  }
}

/* ── ITEMS DO ORÇAMENTO ── */
.items-section { display: flex; flex-direction: column; gap: 8px; }
.item-row { display: grid; grid-template-columns: 1fr 100px 56px 100px 32px; gap: 8px; align-items: center; min-width: 0; }
.orc-item-cor-wrap { min-width: 0; }
.orc-item-cor-select,
.orc-item-cor-text { width: 100%; font-size: 12px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); box-sizing: border-box; }
.remove-btn {
  width: 32px; height: 32px; border-radius: 7px;
  background: var(--red-dim); border: 1px solid rgba(239,68,68,0.2);
  color: var(--red); cursor: pointer; font-size: 16px;
  display: flex; align-items: center; justify-content: center; transition: all 0.15s;
}
.remove-btn:hover { background: rgba(239,68,68,0.15); }
.add-item-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px;
  background: var(--accent-dim); border: 1px dashed rgba(6,182,212,0.3);
  color: var(--accent); font-size: 13px; cursor: pointer;
  transition: all 0.15s; font-family: inherit; width: 100%; justify-content: center;
}
.add-item-btn:hover { background: rgba(6,182,212,0.14); border-color: var(--accent); }
.total-row {
  display: flex; flex-direction: column; gap: 5px;
  padding: 14px 16px; background: var(--bg);
  border: 1px solid var(--border); border-radius: 10px; font-size: 14px;
}
.total-value { color: var(--green); font-family: 'Outfit', sans-serif; font-size: 22px; font-weight: 700; }
#subtotal-row, #desconto-row { font-size: 13px; font-weight: 500; }

/* ── AUTOCOMPLETE ── */
.cliente-autocomplete { position: relative; }
.cliente-sugestoes-list {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; z-index: 9999; max-height: 220px; overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.sugestao-item {
  padding: 9px 14px; cursor: pointer; font-size: 13px; color: var(--text);
  display: flex; align-items: center; gap: 8px; transition: background 0.1s;
  border-bottom: 1px solid var(--border);
}
.sugestao-item:last-child { border-bottom: none; }
.sugestao-item:hover { background: var(--bg); }
.sugestao-item.novo { color: var(--accent); font-weight: 600; border-top: 1px solid var(--border); }

/* ── LOADING ── */
.loading { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 40px; color: var(--muted); font-size: 14px; }
.spinner { width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── EMPTY STATE ── */
.empty-state { text-align: center; padding: 48px; color: var(--muted); }
.empty-state .icon { font-size: 38px; margin-bottom: 14px; }
.empty-state .title { font-family: 'Outfit', sans-serif; font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.empty-state .desc { font-size: 13px; }

/* ── ALERT ── */
.alert { padding: 12px 16px; border-radius: 10px; font-size: 13px; margin-bottom: 16px; }
.alert-error   { background: var(--red-dim);   border: 1px solid rgba(239,68,68,0.2);   color: var(--red);   }
.alert-success { background: var(--green-dim); border: 1px solid rgba(16,185,129,0.2); color: var(--green); }

/* ── ANIMATIONS ── */
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.4} }
.pulse { animation: pulse 2s infinite; }

/* ── ALERTAS VENCIMENTO ── */

/* ── MOBILE / RESPONSIVE ── */
.btn-hamburger {
  display: none; align-items: center; justify-content: center;
  width: 36px; height: 36px; flex-shrink: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 18px;
  cursor: pointer; line-height: 1; box-shadow: var(--shadow-xs);
}
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(15,23,42,0.4); z-index: 99; }
.sidebar-overlay.open { display: block; }

@media (max-width: 1024px) {
  .sidebar { left: -260px; z-index: 300; width: 232px; }
  .sidebar.open { left: 0; box-shadow: 8px 0 40px rgba(15,23,42,0.15); }
  .main { margin-left: 0; padding: 18px 16px 32px; }
  .topbar { margin-bottom: 18px; gap: 8px 12px; align-items: flex-start; }
  .topbar .topbar-title-wrap { flex: 1 1 auto; min-width: 0; }
  .topbar .topbar-actions { flex-basis: 100%; margin-top: 4px; padding-top: 10px; border-top: 1px solid var(--border); flex-wrap: wrap; gap: 8px; }
  .page-title { font-size: 18px; }
  .page-sub { font-size: 12px; }
  .btn-hamburger { display: flex; }
  .stats-row { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
  .stat-card { padding: 15px; }
  .stat-value { font-size: 19px; }
  .stat-icon { width: 32px; height: 32px; font-size: 14px; margin-bottom: 10px; }
  .charts-grid { grid-template-columns: 1fr; }
  .content-grid { grid-template-columns: 1fr; }
  th { padding: 10px 12px; font-size: 11px; }
  td { padding: 11px 12px; font-size: 13px; }
  .table-filters { padding: 10px 12px; }
  /* Modal: mantém centralizado em tablets (641-1024px) — sheet só em <= 640px */
  .modal-body { padding: 16px 18px; gap: 12px; }
  .modal-header { padding: 22px 22px 16px; }
  .modal-footer { padding: 12px 22px; }
  .modal-title { font-size: 15px; }
  .form-row { grid-template-columns: 1fr; }
  .item-row { grid-template-columns: 1fr 80px 48px 80px 32px; gap: 6px; min-width: 0; }
  .item-row > * { min-width: 0; }
  .orc-item-cor-select, .orc-item-cor-text { font-size: 11px; }
  .notif { bottom: 10px; right: 10px; max-width: calc(100% - 20px); }
  .modal-pdf { width: 98vw; max-height: 96vh; }
  .modal-pdf .modal-body { height: 72vh; }
  .catalogo-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .catalogo-grid .catalogo-card-img { height: 88px !important; }
  .catalogo-grid .catalogo-card-img img { max-height: 88px !important; }
  .catalogo-grid .catalogo-card-img--empty { height: 64px !important; }
  .catalogo-grid .catalogo-card-content { padding: 10px !important; gap: 6px !important; }
  .catalogo-grid .catalogo-card-nome { font-size: 13px !important; }
  .catalogo-grid .catalogo-card-desc { display: none; }
  .catalogo-grid .catalogo-card-preco { font-size: 14px; }
  .catalogo-grid .catalogo-card-preco span:first-child { font-size: 15px !important; }
}

/* Preço menor em tablets (481-768px) */
@media (max-width: 768px) and (min-width: 481px) {
  .catalogo-grid .catalogo-card-preco span:first-child {
    font-size: 16px !important;
  }
  .catalogo-grid .catalogo-card-actions { gap: 4px !important; }
  .catalogo-grid .catalogo-card-btn { padding: 5px 6px !important; font-size: 11px !important; }
}

/* ── BREAKPOINT INTERMEDIÁRIO: colapsa grids de 2 colunas em tablets estreitos ── */
@media (max-width: 600px) {
  .charts-grid { grid-template-columns: 1fr; }
  .content-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .stats-row { grid-template-columns: 1fr 1fr; }
  .main { padding: 16px 16px 28px; }
  .topbar { margin-bottom: 14px; }
  .topbar-actions .btn { padding: 8px 12px; font-size: 12px; }
  .page-title { font-size: 16px; }
  /* Touch targets: ≥44px de área clicável */
  .btn, .tab, .filter-chip, .action-btn, .mobile-card-actions-btn {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .filter-chip { padding: 0 16px; }
  .tab { padding: 0 16px; }
  .action-btn { width: 44px; height: 44px; padding: 0; }
  .mobile-card-actions-btn { width: 44px; height: 44px; font-size: 20px; }
  /* Modal compacto em mobile pequeno */
  .modal-body { padding: 14px 14px; gap: 10px; }
  .modal-header { padding: 24px 14px 12px; } /* Ajustado para drag handle */
  .modal-footer { padding: 10px 14px; }

  /* Modais Clientes: garante empilhamento e evita overflow horizontal */
  .modal .form-row { gap: 10px; }
  .modal .form-row > .form-group {
    min-width: 0 !important;
    flex: 1 1 100%;
    width: 100%;
  }
  /* Inputs full width por padrão no modal */
  .modal .form-group input,
  .modal .form-group select,
  .modal .form-group textarea { width: 100%; box-sizing: border-box; }
  /* Botões de busca CNPJ/CEP: um pouco menores */
  #btn-buscar-cnpj, #btn-buscar-cep { width: 36px !important; height: 36px !important; font-size: 14px !important; }
  /* Toggle PF/PJ: fonte menor e sem quebra */
  #btn-pf, #btn-pj { font-size: 12px !important; padding: 8px 4px !important; }
  /* Footer do modal: botões ocupam largura total */
  .modal-footer .btn { flex: 1 1 100%; justify-content: center; }
  /* Footer preview: 3 botões ghost em grid, CTA em linha cheia */
  .modal-footer--preview { gap: 8px !important; }
  .modal-footer-preview-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    width: 100%;
  }
  .modal-footer-preview-actions .btn {
    flex: none;
    padding: 8px 6px;
    font-size: 12px;
    gap: 4px;
    min-width: 0;
  }
  /* Em telas pequenas, os 3 botões ghost do footer do preview ficam
     muito estreitos (causando corte do texto). Empilha em 1 coluna. */
  @media (max-width: 461px) {
    .modal-footer-preview-actions {
      grid-template-columns: 1fr;
    }
    .modal-footer-preview-actions .btn {
      padding: 10px 12px;
      font-size: 13px;
      justify-content: center;
    }
  }
  /* Textarea com altura limitada */
  .modal textarea { max-height: 180px; }

  /* Item row de orçamento: esconde cor, 4 colunas */
  .item-row { 
    grid-template-columns: 1fr 48px 68px 38px; 
    gap: 4px;
    min-width: 0;
    width: 100%;
    max-width: 100%;
  }
  .item-row > * {
    min-width: 0;
    overflow: hidden;
  }
  .item-row input,
  .item-row select {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }
  .item-row .orc-item-cor-wrap {
    display: none;
  }
  .item-row input[type="number"],
  .item-row .orc-item-valor {
    min-width: 0;
    width: 100%;
  }
  .remove-btn { 
    width: 44px; 
    height: 44px; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    font-size: 18px; 
  }
  /* Nav badge legível */
  .nav-badge { font-size: 11px; padding: 2px 6px; }
  /* Catálogo: 1 coluna em telas muito estreitas */
  .catalogo-grid { grid-template-columns: 1fr; gap: 8px; }
  .catalogo-grid .catalogo-card-img { height: 72px !important; }
  .catalogo-grid .catalogo-card-img img { max-height: 72px !important; }
  .catalogo-grid .catalogo-card-img--empty { height: 52px !important; }
  .catalogo-grid .catalogo-card-content { padding: 8px !important; }
  .catalogo-grid .catalogo-card-nome { font-size: 12px !important; }
  .catalogo-grid .catalogo-card-preco span:first-child { font-size: 14px !important; }
}

/* ── Mobile: tabela de orçamentos — 3 colunas ── */
.mobile-meta { display: none; }
.action-row  { display: none; }

/* Desktop: último tr visível é o action-row (hidden), então o último data-row
   fica com border-bottom indesejada — removemos via nth-last-child */
tr.orc-row-clickable:nth-last-child(2) td { border-bottom: none; }
tr.doc-row:nth-last-child(2) td { border-bottom: none; }

@media (max-width: 640px) {
  /* Modal vira sheet (bottom drawer) apenas em mobile real */
  .modal-overlay {
    align-items: flex-start;
    padding: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .modal, .modal-box {
    width: 100vw; max-width: 100vw;
    min-height: 100vh;
    border-radius: 0;
    animation: slideUpSheet 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    margin: 0;
    transform: translateY(0);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    max-height: none;
  }
  @keyframes slideUpSheet { from { transform: translateY(100%); } to { transform: translateY(0); } }
  .modal.closing { transform: translateY(100%); }
  .modal-close { display: none !important; }
  .modal-drag-handle {
    width: 100%; height: 30px; display: flex; align-items: center; justify-content: center;
    position: absolute; top: 0; left: 0; z-index: 10; touch-action: none;
  }
  .modal-drag-handle::after { content: ''; width: 48px; height: 5px; background: var(--muted2); border-radius: 10px; opacity: 0.5; }
  .modal-body { padding: 16px 18px; gap: 12px; }
  .modal-header { padding: 24px 18px 14px; }
  .modal-footer { padding: 12px 18px; padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
  .modal-overlay { padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px); }
  .modal-title { font-size: 15px; }
  .item-row {
    grid-template-columns: 1fr 72px 44px 72px 40px;
    gap: 5px;
    min-width: 0;
    width: 100%;
    max-width: 100%;
  }
  .item-row > * {
    min-width: 0;
    overflow: hidden;
  }
  .item-row input,
  .item-row select {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }
  .item-row .orc-item-desc {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .item-row input[type="number"],
  .item-row .orc-item-valor {
    min-width: 0;
    width: 100%;
  }
  .item-row .orc-item-cor-wrap {
    min-width: 0;
    overflow: hidden;
  }
  .item-row .orc-item-cor-select,
  .item-row .orc-item-cor-text {
    min-width: 0;
    width: 100%;
  }

  .col-hide-mobile { display: none !important; }

  /* Linha de valor: status + data compactos */
  .mobile-meta {
    display: flex; flex-direction: column; gap: 3px; margin-top: 5px;
  }
  .mobile-meta .status-badge {
    font-size: 10px; padding: 2px 7px; align-self: flex-start;
  }
  .mobile-meta .mobile-date {
    font-size: 11px; color: var(--muted);
  }

  /* Linha de ações abaixo dos dados */
  .action-row { display: table-row; }
  .action-row td {
    padding: 0 12px 10px;
    border-top: none;
  }
  /* Cancela o hover de fundo no action-row */
  .action-row:hover td { background: transparent !important; }

  /* Botões maiores para toque */
  .action-btn {
    font-size: 16px;
    min-width: 36px; min-height: 36px;
    padding: 6px 8px;
    display: inline-flex; align-items: center; justify-content: center;
  }
  .action-btns { flex-wrap: wrap; gap: 6px; }

  /* ── MODAL COMPACTO (exceção ao sheet full-screen) ── */
  .modal--compact {
    width: 92vw; max-width: 480px;
    min-height: auto; max-height: 85vh;
    border-radius: 16px;
    margin: auto;
    transform: none;
    animation: slideUp 0.25s ease;
  }
  .modal--compact .modal-header { padding: 18px 20px 14px; }
  .modal--compact .modal-body   { padding: 18px 20px; }
  .modal--compact .modal-footer { padding: 14px 20px; padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
  .modal--compact .modal-drag-handle { display: none; }
}

/* ── LANDSCAPE MOBILE: modal não escapa da tela com teclado aberto ── */
@media (max-height: 600px) {
  .modal { max-height: 96vh; }
}

/* ── LOGIN PAGE ── */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}
.login-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; padding: 40px; width: 400px;
  box-shadow: var(--shadow-lg); position: relative; z-index: 1;
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .logo-mark { justify-content: center; font-size: 26px; }
.login-logo .logo-sub { text-align: center; margin-top: 6px; }
.login-title { font-family: 'Outfit', sans-serif; font-size: 19px; font-weight: 700; margin-bottom: 22px; color: var(--text); }
.login-footer { text-align: center; margin-top: 18px; font-size: 13px; color: var(--muted); }
.login-footer a { color: var(--accent); cursor: pointer; text-decoration: none; }
.login-footer a:hover { text-decoration: underline; }
.divider { display: flex; align-items: center; gap: 12px; margin: 18px 0; color: var(--muted); font-size: 12px; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ── MODAL SELEÇÃO DE PLANOS ── */
.modal-planos-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-planos-container {
  background: var(--surface);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  max-width: 1100px;
  width: 100%;
  padding: 40px 32px;
  animation: slideUp 0.4s ease;
  position: relative;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-planos-header {
  text-align: center;
  margin-bottom: 36px;
}

.modal-planos-header h2 {
  font-family: 'Outfit', sans-serif;
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 800;
  color: var(--text);
  margin-bottom: 12px;
  line-height: 1.2;
}

.modal-planos-header p {
  font-size: 15px;
  color: var(--muted);
  max-width: 600px;
  margin: 0 auto;
  line-height: 1.6;
}

.modal-planos-icon-wrap {
  display: flex; align-items: center; justify-content: center;
  width: 56px; height: 56px;
  background: var(--accent-dim);
  border: 1.5px solid rgba(6, 182, 212, 0.3);
  border-radius: 16px;
  margin: 0 auto 20px;
  color: var(--accent);
}

.modal-planos-subtitle-top {
  font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 1.2px;
  color: var(--accent);
  margin-bottom: 8px;
}

.modal-planos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.plano-card {
  background: var(--surface2);
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}

.plano-card:hover {
  border-color: var(--accent);
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.plano-card.plano-destaque {
  border-color: var(--accent);
  background: linear-gradient(135deg, var(--accent-dim) 0%, var(--surface2) 100%);
  box-shadow: 0 8px 24px rgba(6, 182, 212, 0.15);
  transform: translateY(-6px);
}

.plano-card.plano-destaque:hover {
  transform: translateY(-10px);
  box-shadow: 0 16px 40px rgba(6, 182, 212, 0.3);
}

.plano-destaque .plano-nome { color: var(--accent); }
.plano-destaque .feature-item::before { color: var(--accent); }

.plano-badge {
  display: inline-block;
  background: linear-gradient(90deg, var(--accent), var(--accent-dark));
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 4px 14px;
  border-radius: 20px;
  margin-bottom: 10px;
  box-shadow: 0 2px 10px var(--accent-glow);
}

.plano-header {
  margin-bottom: 24px;
}

.plano-nome {
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin-bottom: 8px;
}

.plano-preco {
  display: flex;
  align-items: baseline;
  gap: 4px;
  margin-bottom: 12px;
}

.preco-valor {
  font-family: 'Outfit', sans-serif;
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}

.plano-destaque .preco-valor {
  color: var(--accent);
}

.preco-periodo {
  font-size: 15px;
  color: var(--muted);
  font-weight: 500;
}

.plano-desc {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

.plano-features {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
}

.feature-item {
  font-size: 14px;
  color: var(--text);
  display: flex;
  align-items: flex-start;
  gap: 8px;
  line-height: 1.5;
}

.feature-item::before {
  content: '✓';
  color: var(--green);
  font-weight: 700;
  flex-shrink: 0;
}

.plano-btn {
  display: block;
  width: 100%;
  padding: 14px 20px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  font-family: 'Outfit', sans-serif;
  letter-spacing: 0.2px;
  text-align: center;
  text-decoration: none;
  transition: all 0.2s ease;
  cursor: pointer;
}

.plano-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  transform: translateY(-2px);
}

.plano-btn-destaque {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  border-color: transparent;
  color: #ffffff;
  font-family: 'Outfit', sans-serif;
  letter-spacing: 0.3px;
  box-shadow: 0 4px 16px rgba(6, 182, 212, 0.25);
}

.plano-btn-destaque:hover {
  background: linear-gradient(135deg, var(--accent-dark), var(--accent));
  color: #ffffff;
  box-shadow: 0 6px 20px rgba(6, 182, 212, 0.35);
}

.modal-planos-footer {
  text-align: center;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.footer-trust {
  display: flex; align-items: center; justify-content: center;
  flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--muted);
}
.trust-item { display: flex; align-items: center; gap: 5px; }
.trust-item svg { width: 13px; height: 13px; color: var(--green); flex-shrink: 0; }
.trust-sep { color: var(--border); }

@media (max-width: 768px) {
  .modal-planos-container {
    padding: 28px 20px;
  }
  
  .modal-planos-grid {
    grid-template-columns: 1fr;
  }
  
  .plano-card {
    padding: 24px 20px;
  }
  
  .modal-planos-header h2 {
    font-size: 1.3rem;
  }

  .plano-card.plano-destaque {
    transform: none;
    margin-top: 20px;
  }
}

/* ══════════════════════════════════════════════════════════════════════════
   MELHORIAS DE UX — Cards Mobile, Dropdown Ações, Paginação, Erros
   ══════════════════════════════════════════════════════════════════════════ */

/* ── CARDS MOBILE (alternativa à tabela) ── */
.mobile-cards-list {
  display: none;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
}

.mobile-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.mobile-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-sm);
}

.mobile-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.mobile-card-client {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.mobile-card-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.mobile-card-info {
  flex: 1;
  min-width: 0;
}

.mobile-card-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mobile-card-numero {
  font-size: 11px;
  color: var(--muted);
  margin-top: 1px;
  font-family: ui-monospace, 'SF Mono', Consolas, monospace;
}

.mobile-card-actions-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
  line-height: 1;
}
.mobile-card-actions-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

.mobile-card-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.mobile-card-valor {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 18px;
  color: var(--green);
}

.mobile-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mobile-card-data {
  font-size: 12px;
  color: var(--muted);
}

/* ── DROPDOWN DE AÇÕES MOBILE ── */
.actions-dropdown {
  position: fixed;
  z-index: 9999;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  min-width: 200px;
  padding: 6px;
  display: none;
  flex-direction: column;
  gap: 2px;
}
.actions-dropdown.open {
  display: flex;
}

.actions-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  border: none;
  background: transparent;
  font-family: inherit;
  width: 100%;
  text-align: left;
  transition: background 0.1s;
}
.actions-dropdown-item:hover {
  background: var(--bg);
}
.actions-dropdown-item.danger {
  color: var(--red);
}
.actions-dropdown-item.danger:hover {
  background: var(--red-dim);
}

.actions-dropdown-item .action-icon {
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.actions-dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* ── STICKY FOOTER NO MODAL ── */
.modal-footer-sticky {
  position: sticky;
  bottom: 0;
  z-index: 2;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 14px 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 -4px 12px rgba(15, 23, 42, 0.06);
}

/* Modal de orçamento — Soft Structuralism: corpo rolável, rodapé fixo, polish premium */
#modal-novo-orcamento.modal-overlay--orcamento {
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

#modal-novo-orcamento.modal-overlay--orcamento.open {
  animation: orcOverlayIn 0.45s cubic-bezier(0.32, 0.72, 0, 1);
}

@keyframes orcOverlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

#modal-novo-orcamento .modal.modal--orcamento {
  display: flex;
  flex-direction: column;
  max-height: min(90vh, 800px);
  overflow: hidden;
  width: min(660px, calc(100vw - 32px));
  border: none;
  border-radius: 24px;
  background: transparent;
  box-shadow:
    0 0 0 1px rgba(15, 23, 42, 0.06),
    0 24px 48px -12px rgba(15, 23, 42, 0.14),
    0 48px 96px -24px rgba(6, 182, 212, 0.08);
  animation: orcModalIn 0.55s cubic-bezier(0.32, 0.72, 0, 1);
}

@keyframes orcModalIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

#modal-novo-orcamento .modal.modal--orcamento::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 24px;
  padding: 1px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.65), rgba(15, 23, 42, 0.06));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

#modal-novo-orcamento .modal.modal--orcamento {
  position: relative;
  background: var(--surface);
}

#modal-novo-orcamento .modal-header {
  flex-shrink: 0;
  border-bottom-color: rgba(15, 23, 42, 0.06);
}

#modal-novo-orcamento .modal-header--orcamento {
  position: relative;
  justify-content: center;
  padding: 14px 20px 12px;
  background: linear-gradient(180deg, var(--surface) 0%, rgba(248, 250, 252, 0.6) 100%);
}

[data-theme="dark"] #modal-novo-orcamento .modal-header--orcamento {
  background: linear-gradient(180deg, var(--surface) 0%, rgba(15, 23, 42, 0.4) 100%);
}

#modal-novo-orcamento .orc-modal-header-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: 1;
  padding: 0 40px;
}

#modal-novo-orcamento .orc-modal-eyebrow {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid rgba(6, 182, 212, 0.18);
}

#modal-novo-orcamento .modal-header--orcamento .modal-title {
  font-family: 'Outfit', sans-serif;
  font-size: 17px;
  font-weight: 700;
  text-align: center;
  letter-spacing: -0.02em;
}

#modal-novo-orcamento .orc-modal-close {
  position: absolute;
  right: 16px;
  top: 50%;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(248, 250, 252, 0.9);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
  transform: translateY(-50%);
  transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1),
    border-color 0.35s cubic-bezier(0.32, 0.72, 0, 1),
    background 0.35s cubic-bezier(0.32, 0.72, 0, 1);
}

#modal-novo-orcamento .orc-modal-close:hover {
  border-color: rgba(6, 182, 212, 0.35);
  background: var(--accent-dim);
  transform: translateY(-50%) scale(1.04);
}

#modal-novo-orcamento .orc-modal-close:active {
  transform: translateY(-50%) scale(0.96);
}

#modal-novo-orcamento .orc-modal-tabs {
  margin-bottom: 14px;
  padding: 4px;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.04);
  border: 1px solid rgba(15, 23, 42, 0.06);
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04);
}

#modal-novo-orcamento .orc-modal-tabs .tab {
  border-radius: 10px;
  transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1),
    background 0.4s cubic-bezier(0.32, 0.72, 0, 1),
    color 0.4s cubic-bezier(0.32, 0.72, 0, 1),
    box-shadow 0.4s cubic-bezier(0.32, 0.72, 0, 1);
}

#modal-novo-orcamento .orc-modal-tabs .tab.active {
  border-radius: 10px;
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.06),
    0 4px 12px rgba(15, 23, 42, 0.06);
}

#modal-novo-orcamento .modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 20px 18px;
  gap: 12px;
}

#modal-novo-orcamento .orc-modal-tab-manual {
  gap: 14px;
}

#modal-novo-orcamento .orc-modal-tab-manual > .form-group {
  animation: orcFieldReveal 0.65s cubic-bezier(0.32, 0.72, 0, 1) both;
}

#modal-novo-orcamento .orc-modal-tab-manual > .form-group:nth-child(1) { animation-delay: 0.05s; }
#modal-novo-orcamento .orc-modal-tab-manual > .form-group:nth-child(2) { animation-delay: 0.1s; }
#modal-novo-orcamento .orc-modal-tab-manual > .form-group:nth-child(3) { animation-delay: 0.15s; }
#modal-novo-orcamento .orc-modal-tab-manual > .items-section { animation-delay: 0.2s; }

#modal-novo-orcamento .orc-modal-tab-manual > .items-section {
  animation: orcFieldReveal 0.65s cubic-bezier(0.32, 0.72, 0, 1) both;
}

@keyframes orcFieldReveal {
  from {
    opacity: 0;
    transform: translateY(12px);
    filter: blur(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

#modal-novo-orcamento .modal-body input,
#modal-novo-orcamento .modal-body select,
#modal-novo-orcamento .modal-body textarea {
  border-radius: 12px;
  border-color: rgba(15, 23, 42, 0.1);
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: border-color 0.35s cubic-bezier(0.32, 0.72, 0, 1),
    box-shadow 0.35s cubic-bezier(0.32, 0.72, 0, 1);
}

#modal-novo-orcamento .modal-body input:focus,
#modal-novo-orcamento .modal-body select:focus,
#modal-novo-orcamento .modal-body textarea:focus {
  border-color: rgba(6, 182, 212, 0.45);
  box-shadow:
    inset 0 1px 2px rgba(15, 23, 42, 0.04),
    0 0 0 3px rgba(6, 182, 212, 0.12);
}

#modal-novo-orcamento #orc-obs {
  min-height: 48px;
}

#modal-novo-orcamento .add-item-btn {
  border-radius: 12px;
  transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1),
    background 0.35s cubic-bezier(0.32, 0.72, 0, 1),
    border-color 0.35s cubic-bezier(0.32, 0.72, 0, 1);
}

#modal-novo-orcamento .add-item-btn:active {
  transform: scale(0.98);
}

#modal-novo-orcamento .orc-modal-footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  gap: 12px;
  flex-wrap: wrap;
}

#modal-novo-orcamento .orc-modal-total-shell {
  padding: 3px;
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.04);
  border: 1px solid rgba(15, 23, 42, 0.06);
  flex-shrink: 0;
}

#modal-novo-orcamento .orc-modal-total-core {
  padding: 8px 14px;
  border-radius: calc(16px - 3px);
  background: var(--surface);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
  text-align: left;
  line-height: 1.2;
  min-width: 148px;
}

[data-theme="dark"] #modal-novo-orcamento .orc-modal-total-core {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

#modal-novo-orcamento .orc-footer-breakdown {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 2px;
}

#modal-novo-orcamento .orc-footer-breakdown--desconto {
  color: var(--red);
}

#modal-novo-orcamento .orc-footer-total-label {
  font-size: 9px;
  color: var(--muted);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.12em;
}

#modal-novo-orcamento .orc-footer-total-valor {
  font-family: 'Outfit', sans-serif;
  font-size: 20px;
  font-weight: 800;
  color: var(--green);
  letter-spacing: -0.03em;
  transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1);
}

#modal-novo-orcamento .orc-footer-total-valor.is-updating {
  transform: scale(1.03);
}

#modal-novo-orcamento .orc-modal-footer-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

#modal-novo-orcamento .orc-modal-footer-actions .btn {
  border-radius: 999px;
  padding: 10px 18px;
  transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1),
    box-shadow 0.35s cubic-bezier(0.32, 0.72, 0, 1),
    background 0.35s cubic-bezier(0.32, 0.72, 0, 1);
}

#modal-novo-orcamento .orc-modal-footer-actions .btn-primary {
  box-shadow:
    0 1px 2px rgba(6, 182, 212, 0.2),
    0 8px 20px -6px rgba(6, 182, 212, 0.45);
}

#modal-novo-orcamento .orc-modal-footer-actions .btn-primary:hover {
  transform: translateY(-1px) scale(1.02);
}

#modal-novo-orcamento .orc-modal-footer-actions .btn:active {
  transform: scale(0.98);
}

#modal-novo-orcamento #modal-orc-success-screen {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

#modal-novo-orcamento .orc-modal-footer {
  display: flex;
  flex-shrink: 0;
  position: sticky;
  bottom: 0;
  z-index: 3;
  padding: 14px 18px;
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.4) 0%, var(--surface) 28%);
  border-top: 1px solid rgba(15, 23, 42, 0.06);
  box-shadow: 0 -12px 32px -8px rgba(15, 23, 42, 0.08);
}

[data-theme="dark"] #modal-novo-orcamento .orc-modal-footer {
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.5) 0%, var(--surface) 35%);
  box-shadow: 0 -12px 32px -8px rgba(0, 0, 0, 0.35);
}

@media (max-width: 640px) {
  #modal-novo-orcamento.modal-overlay--orcamento {
    align-items: flex-end;
    padding: 0;
  }

  #modal-novo-orcamento .modal.modal--orcamento {
    width: 100vw;
    max-width: 100vw;
    max-height: 92dvh;
    border-radius: 24px 24px 0 0;
    margin: 0;
    animation: slideUpSheet 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  }

  #modal-novo-orcamento .modal.modal--orcamento::before {
    border-radius: 24px 24px 0 0;
  }

  #modal-novo-orcamento .orc-modal-footer {
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
  }

  #modal-novo-orcamento .orc-modal-footer-inner {
    flex-direction: column;
    align-items: stretch;
  }

  #modal-novo-orcamento .orc-modal-total-shell {
    width: 100%;
  }

  #modal-novo-orcamento .orc-modal-total-core {
    width: 100%;
  }

  #modal-novo-orcamento .orc-modal-footer-actions {
    width: 100%;
    justify-content: stretch;
  }

  #modal-novo-orcamento .orc-modal-footer-actions .btn {
    flex: 1;
    justify-content: center;
  }
}

/* Footer do modal de orçamento: empilha em telas intermediárias */
@media (max-width: 768px) and (min-width: 641px) {
  #modal-novo-orcamento .orc-modal-footer-inner {
    flex-direction: column;
    align-items: stretch;
  }
  #modal-novo-orcamento .orc-modal-total-shell {
    width: 100%;
  }
  #modal-novo-orcamento .orc-modal-total-core {
    width: 100%;
  }
  #modal-novo-orcamento .orc-modal-footer-actions {
    width: 100%;
    justify-content: stretch;
  }
  #modal-novo-orcamento .orc-modal-footer-actions .btn {
    flex: 1;
    justify-content: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  #modal-novo-orcamento.modal-overlay--orcamento.open,
  #modal-novo-orcamento .modal.modal--orcamento,
  #modal-novo-orcamento .orc-modal-tab-manual > .form-group,
  #modal-novo-orcamento .orc-modal-tab-manual > .items-section,
  #modal-novo-orcamento .orc-modal-tab-ia > * {
    animation: none;
  }

  #modal-novo-orcamento .orc-modal-close,
  #modal-novo-orcamento .orc-modal-tabs .tab,
  #modal-novo-orcamento .orc-modal-footer-actions .btn,
  #modal-novo-orcamento .orc-footer-total-valor,
  #modal-novo-orcamento .orc-ia-cta,
  #modal-novo-orcamento .orc-ia-chip {
    transition: none;
  }

  /* Modais genéricos: remove animações para usuários sensíveis a movimento */
  .modal-overlay.open,
  .modal,
  .modal-box,
  .modal-close,
  .modal-drag-handle,
  .modal-footer .btn {
    animation: none !important;
    transition: none !important;
  }
}

/* ── PRINT: ao imprimir o preview de cliente, mostra apenas o conteúdo do modal ── */
@media print {
  body * { visibility: hidden; }
  #modal-preview-cliente,
  #modal-preview-cliente * { visibility: visible; }
  #modal-preview-cliente {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    background: white;
    border: none;
    box-shadow: none;
    border-radius: 0;
    max-width: none;
    max-height: none;
  }
  #modal-preview-cliente .modal-overlay { display: block !important; background: white !important; backdrop-filter: none !important; position: static !important; }
  #modal-preview-cliente .modal { width: 100% !important; max-width: none !important; max-height: none !important; box-shadow: none !important; border-radius: 0 !important; }
  #modal-preview-cliente .modal-header,
  #modal-preview-cliente .modal-footer,
  #modal-preview-cliente .modal-drag-handle { display: none !important; }
  #modal-preview-cliente .modal-body { padding: 20px !important; overflow: visible !important; }
}

/* ── Modal orçamento: aba Via IA (composer premium) ── */
#modal-novo-orcamento .orc-modal-tab-ia {
  display: none;
  flex-direction: column;
  gap: 16px;
}

#modal-novo-orcamento .orc-modal-tab-ia > * {
  animation: orcFieldReveal 0.65s cubic-bezier(0.32, 0.72, 0, 1) both;
}

#modal-novo-orcamento .orc-modal-tab-ia > *:nth-child(1) { animation-delay: 0.04s; }
#modal-novo-orcamento .orc-modal-tab-ia > *:nth-child(2) { animation-delay: 0.1s; }
#modal-novo-orcamento .orc-modal-tab-ia > *:nth-child(3) { animation-delay: 0.16s; }
#modal-novo-orcamento .orc-modal-tab-ia > *:nth-child(4) { animation-delay: 0.22s; }

#modal-novo-orcamento .orc-ia-intro-shell {
  padding: 3px;
  border-radius: 16px;
  background: rgba(6, 182, 212, 0.08);
  border: 1px solid rgba(6, 182, 212, 0.14);
}

#modal-novo-orcamento .orc-ia-intro-core {
  padding: 12px 14px;
  border-radius: calc(16px - 3px);
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.06) 0%, var(--surface) 68%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

[data-theme="dark"] #modal-novo-orcamento .orc-ia-intro-core {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

#modal-novo-orcamento .orc-ia-intro-eyebrow {
  display: inline-flex;
  margin-bottom: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid rgba(6, 182, 212, 0.2);
}

#modal-novo-orcamento .orc-ia-intro-text {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
}

#modal-novo-orcamento .orc-ia-composer-shell {
  padding: 4px;
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.04);
  border: 1px solid rgba(15, 23, 42, 0.07);
}

#modal-novo-orcamento .orc-ia-composer-core {
  border-radius: calc(18px - 4px);
  background: var(--surface);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
  overflow: hidden;
  transition: box-shadow 0.4s cubic-bezier(0.32, 0.72, 0, 1);
}

#modal-novo-orcamento .orc-ia-composer-core:focus-within {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.75),
    0 0 0 3px rgba(6, 182, 212, 0.14);
}

#modal-novo-orcamento .orc-ia-label {
  display: block;
  padding: 12px 14px 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

#modal-novo-orcamento .orc-ia-textarea {
  width: 100%;
  min-height: 112px;
  max-height: 220px;
  margin: 0;
  padding: 10px 14px 8px;
  border: none;
  border-radius: 0;
  background: transparent;
  resize: none;
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  box-shadow: none;
}

#modal-novo-orcamento .orc-ia-textarea:focus {
  outline: none;
  box-shadow: none;
}

#modal-novo-orcamento .orc-ia-textarea::placeholder {
  color: rgba(100, 116, 139, 0.75);
  font-size: 14px;
}

#modal-novo-orcamento .orc-ia-composer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px 10px;
  border-top: 1px solid rgba(15, 23, 42, 0.06);
  background: rgba(248, 250, 252, 0.85);
}

[data-theme="dark"] #modal-novo-orcamento .orc-ia-composer-bar {
  background: rgba(15, 23, 42, 0.35);
}

#modal-novo-orcamento .orc-ia-hint {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
}

#modal-novo-orcamento .orc-ia-hint-kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.4em;
  padding: 1px 5px;
  border-radius: 5px;
  border: 1px solid rgba(15, 23, 42, 0.1);
  background: var(--surface);
  font-size: 10px;
  font-weight: 600;
  color: var(--text);
}

#modal-novo-orcamento .orc-ia-char-count {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
  white-space: nowrap;
}

#modal-novo-orcamento .orc-ia-char-count--active {
  color: var(--accent);
}

#modal-novo-orcamento .orc-ia-examples {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#modal-novo-orcamento .orc-ia-examples-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

#modal-novo-orcamento .orc-ia-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

#modal-novo-orcamento .orc-ia-chip {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(248, 250, 252, 0.95);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1),
    border-color 0.35s cubic-bezier(0.32, 0.72, 0, 1),
    background 0.35s cubic-bezier(0.32, 0.72, 0, 1),
    color 0.35s cubic-bezier(0.32, 0.72, 0, 1);
}

#modal-novo-orcamento .orc-ia-chip:hover {
  border-color: rgba(6, 182, 212, 0.35);
  background: var(--accent-dim);
  color: var(--accent-dark);
  transform: translateY(-1px);
}

#modal-novo-orcamento .orc-ia-chip:active,
#modal-novo-orcamento .orc-ia-chip.is-selected {
  transform: scale(0.97);
  border-color: rgba(6, 182, 212, 0.45);
  background: rgba(6, 182, 212, 0.12);
}

#modal-novo-orcamento .orc-ia-cta {
  width: 100%;
  justify-content: space-between;
  padding: 12px 12px 12px 18px;
  border-radius: 999px;
  gap: 10px;
  box-shadow:
    0 1px 2px rgba(6, 182, 212, 0.2),
    0 10px 28px -8px rgba(6, 182, 212, 0.45);
  transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1),
    box-shadow 0.35s cubic-bezier(0.32, 0.72, 0, 1);
}

#modal-novo-orcamento .orc-ia-cta:hover {
  transform: translateY(-1px) scale(1.01);
}

#modal-novo-orcamento .orc-ia-cta:active {
  transform: scale(0.98);
}

#modal-novo-orcamento .orc-ia-cta.is-loading {
  opacity: 0.85;
  pointer-events: none;
}

#modal-novo-orcamento .orc-ia-cta.is-loading .orc-ia-cta-icon-wrap {
  animation: orcIaSpin 0.8s cubic-bezier(0.32, 0.72, 0, 1) infinite;
}

@keyframes orcIaSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

#modal-novo-orcamento .orc-ia-cta-text {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

#modal-novo-orcamento .orc-ia-cta-icon-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.22);
  flex-shrink: 0;
  transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
}

#modal-novo-orcamento .orc-ia-cta:hover .orc-ia-cta-icon-wrap {
  transform: translate(2px, -1px) scale(1.05);
}

#modal-novo-orcamento .orc-ia-cta-icon {
  font-size: 15px;
  line-height: 1;
}

#modal-novo-orcamento.orc-modal--ia-tab .orc-modal-total-shell,
#modal-novo-orcamento.orc-modal--ia-tab #btn-criar-orc {
  display: none !important;
}

#modal-novo-orcamento.orc-modal--ia-tab .orc-modal-footer-inner {
  justify-content: flex-end;
}

@media (max-width: 640px) {
  #modal-novo-orcamento .orc-ia-textarea {
    font-size: 16px;
    max-height: 160px;
  }

  #modal-novo-orcamento .orc-ia-composer-bar {
    flex-direction: column;
    align-items: flex-start;
  }

  #modal-novo-orcamento .orc-ia-chips {
    gap: 6px;
  }

  #modal-novo-orcamento .orc-ia-chip {
    flex: 1 1 calc(50% - 6px);
    min-width: 0;
    text-align: center;
    padding: 10px 8px;
  }

  #modal-novo-orcamento .orc-ia-cta {
    position: sticky;
    bottom: 0;
    z-index: 2;
  }
}

[data-theme="dark"] .modal-footer-sticky {
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.3);
}

.modal-footer-sticky .total-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.modal-footer-sticky .total-valor {
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 22px;
  color: var(--green);
}

/* ── PAGINAÇÃO MELHORADA ── */
.pagination-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.pagination-info {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pagination-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.pagination-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}
.pagination-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.pagination-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.pagination-ellipsis {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted2);
  font-size: 13px;
}

.pagination-per-page {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}
.pagination-per-page select {
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  font-family: inherit;
  outline: none;
  cursor: pointer;
}

/* ── FILTROS COM CONTAGEM ── */
.filter-chip-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  font-size: 10px;
  font-weight: 700;
  margin-left: 5px;
  background: var(--border);
  color: var(--muted);
  transition: all 0.15s;
}
.filter-chip.active .filter-chip-count {
  background: var(--accent);
  color: #fff;
}

/* ── ESTADOS DE ERRO DESCritivos ── */
.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 24px;
  gap: 12px;
}

.error-state-icon {
  font-size: 48px;
  margin-bottom: 4px;
}

.error-state-title {
  font-family: 'Outfit', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.error-state-desc {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  max-width: 360px;
}

.error-state-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.error-state-sugestao {
  font-size: 12px;
  color: var(--muted2);
  font-style: italic;
  margin-top: 4px;
}

/* ── RESPONSIVE: melhorar layout para telas médias (481-640px) ── */
@media (min-width: 481px) and (max-width: 640px) {
  /* Ajustes específicos para telas médias */
  .action-btn, .mobile-card-actions-btn {
    min-width: 44px;
    min-height: 44px;
    padding: 10px;
  }
  .modal-footer .btn {
    min-height: 44px;
    padding: 10px 16px;
  }
  .novo-usuario-form {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
  }
  .novo-usuario-form .form-group {
    width: 100% !important;
  }
  .novo-usuario-form .btn {
    width: 100% !important;
  }
  .modal-footer {
    padding: 16px 20px;
  }
  .mobile-card-actions-btn {
    padding: 10px;
    min-width: 44px;
    min-height: 44px;
  }
}

/* ── RESPONSIVE: mostrar cards mobile, esconder tabela ── */
@media (max-width: 640px) {
  .table-wrap { display: none !important; }
  .mobile-cards-list { display: flex !important; }

  /* Paginação compacta no mobile */
  .pagination-wrapper {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .pagination-controls {
    justify-content: center;
  }
  .pagination-per-page {
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .mobile-card { padding: 12px 14px; }
  .mobile-card-valor { font-size: 16px; }
}

/* ── Search inputs: esconder botão de limpar ── */
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-decoration {
  -webkit-appearance: none;
  display: none;
}
input[type="search"] {
  -moz-appearance: none;
  appearance: none;
}

/* ══════════════════════════════════════════════════════════════════════════
   COMPONENTES MODERNOS — Design System v2
   ══════════════════════════════════════════════════════════════════════════ */

/* ── LEAD DETAIL PANEL (CRM Drawer/Modal) ── */
.lead-panel {
  background: var(--surface);
  border-radius: 16px;
  overflow: hidden;
}

.lead-panel-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 24px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 2;
}

.lead-panel-avatar {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), #3b82f6);
}

.lead-panel-avatar.green { background: linear-gradient(135deg, #10b981, #059669); }
.lead-panel-avatar.amber { background: linear-gradient(135deg, #f59e0b, #d97706); }
.lead-panel-avatar.red { background: linear-gradient(135deg, #ef4444, #dc2626); }
.lead-panel-avatar.purple { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }

.lead-panel-title {
  font-family: 'Outfit', sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.lead-panel-sub {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}

.lead-panel-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
}

.lead-panel-body {
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.lead-panel-section {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px 22px;
  transition: box-shadow 0.2s;
}

.lead-panel-section:hover {
  box-shadow: var(--shadow-xs);
}

.lead-panel-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--accent);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.lead-field {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.lead-field:last-child { border-bottom: none; }

.lead-field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  min-width: 100px;
  flex-shrink: 0;
}

.lead-field-value {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  text-align: right;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
}

.lead-field-value.empty {
  color: var(--muted2);
  font-style: italic;
  font-weight: 400;
}

.lead-field-action {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  transition: all 0.15s;
}

.lead-field-action:hover {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

/* Lead stats row */
.lead-stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 10px;
}

.lead-stat-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 12px;
  text-align: center;
  transition: all 0.2s;
}

.lead-stat-box:hover {
  border-color: var(--border-hover);
  transform: translateY(-1px);
}

.lead-stat-value {
  font-family: 'Outfit', sans-serif;
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}

.lead-stat-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

/* Quick status changer */
.lead-status-quick {
  display: inline-flex;
  gap: 4px;
  background: var(--surface);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.lead-status-quick-btn {
  border: none;
  background: transparent;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  color: var(--muted);
  white-space: nowrap;
}

.lead-status-quick-btn:hover {
  background: var(--bg);
  color: var(--text);
}

.lead-status-quick-btn.active {
  color: #fff;
  box-shadow: var(--shadow-xs);
}

/* Timeline moderna */
.lead-timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
  position: relative;
}

.lead-timeline::before {
  content: '';
  position: absolute;
  left: 15px;
  top: 24px;
  bottom: 24px;
  width: 2px;
  background: var(--border);
  border-radius: 2px;
}

.lead-tl-item {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: 14px;
  padding: 10px 0;
  align-items: start;
  position: relative;
}

.lead-tl-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
  border: 2px solid var(--surface);
}

.lead-tl-dot.obs { background: var(--accent-dim); }
.lead-tl-dot.whats { background: var(--green-dim); }
.lead-tl-dot.email { background: var(--orange-dim); }
.lead-tl-dot.status { background: var(--purple-dim); }
.lead-tl-dot.lemb { background: rgba(236,72,153,0.1); }

.lead-tl-content {
  min-width: 0;
}

.lead-tl-text {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
  word-break: break-word;
}

.lead-tl-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.lead-tl-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.lead-tl-tag.system { background: var(--bg); color: var(--muted); }
.lead-tl-tag.user { background: var(--accent-dim); color: var(--accent); }

.lead-tl-time {
  font-size: 11px;
  color: var(--muted2);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Composer de observação moderno */
.lead-note-composer {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  transition: border-color 0.2s;
}

.lead-note-composer:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.lead-note-composer textarea {
  flex: 1;
  border: none;
  background: transparent;
  resize: none;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  outline: none;
  min-height: 40px;
  padding: 4px 0;
}

.lead-note-composer textarea::placeholder {
  color: var(--muted2);
}

/* ── COMPANY BADGE (vindo do sistema) ── */
.empresa-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: all 0.15s;
}

.empresa-badge:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-xs);
}

.empresa-badge-avatar {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.empresa-badge-info {
  min-width: 0;
}

.empresa-badge-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.empresa-badge-meta {
  font-size: 11px;
  color: var(--muted);
}

/* ── SCORE SELECTOR MODERNO ── */
.score-picker {
  display: inline-flex;
  gap: 3px;
  background: var(--surface2);
  padding: 3px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.score-pick {
  border: none;
  background: transparent;
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  color: var(--muted);
  text-transform: capitalize;
}

.score-pick:hover { background: var(--surface); color: var(--text); }
.score-pick.active.quente { background: #dc2626; color: #fff; }
.score-pick.active.morno { background: #d97706; color: #fff; }
.score-pick.active.frio { background: #3b82f6; color: #fff; }

/* ── PAGE HEADER PADRONIZADO ── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.page-header-title {
  font-family: 'Outfit', sans-serif;
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  letter-spacing: -0.3px;
}

.page-header-desc {
  font-size: 14px;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.4;
}

.page-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ── SECTION CARD PADRONIZADO ── */
.section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s;
}

.section-card:hover {
  box-shadow: var(--shadow);
}

.section-card-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-card-title {
  font-family: 'Outfit', sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.section-card-body {
  padding: 22px;
}

/* ── PILL / BADGE MODERNO ── */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.pill.green  { background: var(--green-dim);  color: #059669; }
.pill.red    { background: var(--red-dim);    color: var(--red); }
.pill.blue   { background: var(--blue-dim);   color: var(--blue); }
.pill.amber  { background: var(--orange-dim); color: var(--orange); }
.pill.purple { background: var(--purple-dim); color: var(--purple); }
.pill.accent { background: var(--accent-dim); color: var(--accent); }
.pill.muted  { background: var(--bg); color: var(--muted); border: 1px solid var(--border); }

.pill::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  flex-shrink: 0;
}

.pill.green::before  { background: #059669; }
.pill.red::before    { background: var(--red); }
.pill.blue::before   { background: var(--blue); }
.pill.amber::before  { background: var(--orange); }
.pill.purple::before { background: var(--purple); }
.pill.accent::before { background: var(--accent); }

/* ── MODAL WIDE / DETAIL ── */
.modal.wide {
  max-width: 780px;
}

@media (max-width: 820px) {
  .modal.wide {
    max-width: 95vw;
  }
  .lead-panel-header {
    padding: 16px 18px;
  }
  .lead-panel-body {
    padding: 16px 18px;
    gap: 14px;
  }
  .lead-panel-section {
    padding: 14px 16px;
  }
  .lead-stats-row {
    grid-template-columns: repeat(2, 1fr);
  }
  .lead-field {
    flex-direction: column;
    gap: 4px;
  }
  .lead-field-value {
    text-align: left;
    justify-content: flex-start;
  }
}

@media (max-width: 480px) {
  .lead-panel-title {
    font-size: 17px;
  }
  .lead-stats-row {
    grid-template-columns: 1fr 1fr;
  }
  .lead-panel-actions {
    width: 100%;
    justify-content: flex-end;
  }
  .lead-status-quick {
    flex-wrap: wrap;
  }
}

/* ── TAB SYSTEM MODERNO (padrão para todas as páginas admin) ── */
.admin-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 2px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  margin-bottom: 24px;
}

.admin-tabs::-webkit-scrollbar { display: none; }

.admin-tab {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 14px 20px;
  border: none;
  background: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s ease;
  white-space: nowrap;
  font-family: inherit;
}

.admin-tab:hover {
  color: var(--text);
  background: rgba(6,182,212,0.03);
}

.admin-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.admin-tab-icon {
  font-size: 16px;
}

/* ── EMPTY STATE MODERNO ── */
.state-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 24px;
  gap: 8px;
}

.state-empty-icon {
  font-size: 40px;
  margin-bottom: 8px;
  opacity: 0.8;
}

.state-empty-title {
  font-family: 'Outfit', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.state-empty-desc {
  font-size: 13px;
  color: var(--muted);
  max-width: 300px;
  line-height: 1.5;
}

/* ── GRID UTILITIES ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

@media (max-width: 768px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
  .grid-4 { grid-template-columns: 1fr; }
}

/* ── DANGER ZONE ── */
.danger-zone {
  border: 1px solid rgba(239,68,68,0.25);
  border-radius: 12px;
  padding: 16px 18px;
  background: rgba(239,68,68,0.03);
}

.danger-zone-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--red);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.danger-zone-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── SCROLL SMOOTH ── */
.lead-detail-scroll {
  max-height: 75vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.lead-detail-scroll::-webkit-scrollbar { width: 5px; }
.lead-detail-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 5px; }
.lead-detail-scroll::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 768px) {
  .lead-detail-scroll {
    max-height: none;
  }
}

/* ── LEAD BADGE (status pipeline inline) ── */
.lead-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.lead-badge.status-novo { background: #f1f5f9; color: #64748b; }
.lead-badge.status-contato_iniciado { background: #dbeafe; color: #2563eb; }
.lead-badge.status-proposta_enviada { background: #fef3c7; color: #b45309; }
.lead-badge.status-negociacao { background: #e0f2fe; color: #0369a1; }
.lead-badge.status-em_analise { background: #ede9fe; color: #6d28d9; }
.lead-badge.status-fechado_ganho { background: #dcfce7; color: #166534; }
.lead-badge.status-fechado_perdido { background: #fee2e2; color: #b91c1c; }

[data-theme="dark"] .lead-badge.status-novo { background: rgba(100,116,139,0.15); color: #94a3b8; }
[data-theme="dark"] .lead-badge.status-contato_iniciado { background: rgba(37,99,235,0.15); color: #60a5fa; }
[data-theme="dark"] .lead-badge.status-proposta_enviada { background: rgba(180,83,9,0.15); color: #fbbf24; }
[data-theme="dark"] .lead-badge.status-negociacao { background: rgba(3,105,161,0.15); color: #38bdf8; }
[data-theme="dark"] .lead-badge.status-fechado_ganho { background: rgba(22,101,52,0.15); color: #4ade80; }
[data-theme="dark"] .lead-badge.status-fechado_perdido { background: rgba(185,28,28,0.15); color: #f87171; }

/* ── Tool Use v2: trace de ferramentas e card de confirmação ──────────── */
.tool-trace { margin-top: 4px; font-size: 10px; color: var(--muted, #6b7280); display: flex; flex-wrap: wrap; gap: 4px; }
.tool-trace-item { display: inline-flex; align-items: center; gap: 3px; padding: 1px 6px; border-radius: 999px; background: rgba(99,102,241,0.07); color: #6366f1; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; opacity: 0.8; }
[data-theme="dark"] .tool-trace-item { background: rgba(129,140,248,0.15); color: #a5b4fc; }

.pending-action-card { margin-top: 12px; padding: 14px 16px; background: #fff7ed; border: 1px solid #fed7aa; border-left: 4px solid #f97316; border-radius: 10px; box-shadow: 0 2px 8px rgba(249,115,22,0.08); }
[data-theme="dark"] .pending-action-card { background: rgba(249,115,22,0.08); border-color: rgba(249,115,22,0.35); }
.pending-action-header { font-weight: 600; color: #c2410c; margin-bottom: 6px; font-size: 14px; }
[data-theme="dark"] .pending-action-header { color: #fdba74; }
.pending-action-tool { font-size: 15px; margin-bottom: 4px; }
.pending-action-desc { font-size: 13px; color: var(--muted, #6b7280); margin-bottom: 10px; }
.pending-action-summary { background: rgba(255,255,255,0.6); border: 1px solid rgba(251,146,60,0.25); border-radius: 8px; padding: 10px 12px; font-size: 13px; margin-bottom: 12px; }
[data-theme="dark"] .pending-action-summary { background: rgba(0,0,0,0.25); border-color: rgba(251,146,60,0.3); }
.pending-action-summary .pa-row { display: flex; gap: 6px; padding: 2px 0; line-height: 1.45; }
.pending-action-summary .pa-label { color: var(--muted, #6b7280); min-width: 90px; font-weight: 500; }
.pending-action-summary .pa-value { color: var(--text, #111827); word-break: break-word; }
[data-theme="dark"] .pending-action-summary .pa-value { color: #e5e7eb; }
.pending-action-summary .pa-empty { color: var(--muted, #6b7280); font-style: italic; }
.pending-action-guidance { margin: -2px 0 12px; font-size: 12px; color: var(--muted, #6b7280); }
.pending-action-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.pending-action-buttons button:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }
.pending-action-buttons button[disabled] { opacity: 0.55; cursor: not-allowed; }
.btn-confirm-alt { background: #0d9488; color: #fff; border: none; border-radius: 6px; padding: 8px 14px; font-size: 13px; cursor: pointer; font-weight: 500; }
.btn-confirm-alt:hover { background: #0f766e; }
.btn-confirm-alt:focus-visible { outline: 2px solid #0d9488; outline-offset: 2px; }
@media (max-width: 480px) { .pending-action-buttons { flex-direction: column; } .btn-confirm-alt { width: 100%; } }
.pending-action-status { margin-top: 10px; font-size: 13px; color: #1d4ed8; }
.pending-action-cancelled { padding: 10px 14px; font-size: 13px; color: #6b7280; font-style: italic; }

/* ── Badges utilitários (NF-e, templates, dashboard) ───────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  line-height: 1.2;
}
.badge-success { background: var(--green-dim); color: #059669; border: 1px solid rgba(16, 185, 129, 0.22); }
.badge-warning { background: var(--orange-dim); color: #c2410c; border: 1px solid rgba(249, 115, 22, 0.25); }
.badge-info { background: var(--blue-dim); color: var(--blue); border: 1px solid rgba(59, 130, 246, 0.22); }
.badge-secondary { background: rgba(100, 116, 139, 0.12); color: var(--muted); border: 1px solid var(--border); }
.badge-danger { background: var(--red-dim); color: var(--red); border: 1px solid rgba(239, 68, 68, 0.22); }
[data-theme="dark"] .badge-success { color: #34d399; border-color: rgba(52, 211, 153, 0.25); }
[data-theme="dark"] .badge-warning { color: #fdba74; border-color: rgba(251, 146, 60, 0.3); }
[data-theme="dark"] .badge-info { color: #93c5fd; border-color: rgba(147, 197, 253, 0.25); }
[data-theme="dark"] .badge-secondary { color: #94a3b8; background: rgba(148, 163, 184, 0.12); }
[data-theme="dark"] .badge-danger { color: #f87171; border-color: rgba(248, 113, 113, 0.28); }

.text-danger { color: var(--red); font-size: 0.875rem; line-height: 1.45; }
[data-theme="dark"] .text-danger { color: #f87171; }

.btn-sm {
  padding: 8px 12px;
  font-size: 12px;
  min-height: 40px;
  border-radius: 8px;
}
.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}
.btn-warning {
  background: var(--orange-dim);
  color: #c2410c;
  border: 1px solid rgba(249, 115, 22, 0.35);
}
.btn-warning:hover {
  background: rgba(249, 115, 22, 0.22);
  border-color: var(--orange);
}
[data-theme="dark"] .btn-warning { color: #fdba74; border-color: rgba(251, 146, 60, 0.35); }

a.btn-sm { text-decoration: none; }

.btn:focus-visible,
a.btn:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

/* ── Notas fiscais: listagem (modo definido por .nf-list--table / .nf-list--cards) ─ */
.nf-list {
  width: 100%;
}

.nf-filtros-card {
  margin-bottom: 20px;
  padding: 16px 20px;
}
.nf-filtros-bar {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
}
.nf-filtros-bar .nf-filtro-grupo {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.nf-filtros-bar .nf-filtro-grupo--grow {
  flex: 1;
  min-width: 200px;
}
.nf-filtro-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.nf-filtros-bar input,
.nf-filtros-bar select {
  font-family: inherit;
  width: 100%;
}
.nf-search-field {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.nf-search-field:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.12);
}
.nf-search-field svg {
  flex-shrink: 0;
  color: var(--muted2);
}
.nf-search-field input {
  border: none;
  background: transparent;
  padding: 10px 0;
  min-width: 0;
  flex: 1;
  outline: none;
  font-size: 14px;
  color: var(--text);
}

.nf-pagination-outer {
  margin-top: 24px;
}
.nf-pagination-outer .pagination-wrapper {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.nf-empty {
  padding: 40px;
  text-align: center;
}
.nf-empty-icon {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
  color: var(--muted2);
}
.nf-empty .empty-state .title,
.nf-empty h3 {
  margin: 0 0 8px;
  font-family: 'Outfit', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

.nf-card {
  overflow: visible;
}
.nf-card__header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}
.nf-card__header-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}
.nf-card__numero {
  margin-left: auto;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  letter-spacing: -0.02em;
}
.nf-card__tipo {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.nf-card__numero .nf-card__numero-muted {
  font-weight: 400;
  font-size: 0.85rem;
  color: var(--muted);
}

.nf-card__body {
  padding: 14px 18px 16px;
}
.nf-meta-grid {
  display: grid;
  grid-template-columns: minmax(100px, 120px) 1fr;
  gap: 8px 14px;
  font-size: 14px;
  line-height: 1.45;
}
@media (max-width: 480px) {
  .nf-meta-grid {
    grid-template-columns: 1fr;
    gap: 2px 0;
  }
  .nf-meta-grid .nf-meta-label {
    margin-top: 8px;
  }
  .nf-meta-grid .nf-meta-label:first-child {
    margin-top: 0;
  }
}
.nf-meta-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.nf-meta-value {
  color: var(--text);
  word-break: break-word;
}
.nf-meta-value a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}
.nf-meta-value a:hover {
  text-decoration: underline;
}
.nf-meta-hint {
  grid-column: 1 / -1;
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.4;
}

.nf-card__alert {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-left-width: 4px;
  border-left-color: var(--red);
  background: var(--red-dim);
}
.nf-card__alert .nf-card__alert-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--red);
  margin-bottom: 4px;
}
.nf-card__alert .nf-card__alert-msg {
  font-size: 13px;
  color: var(--text);
  line-height: 1.45;
}

.nf-card__footer {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 18px;
  border-top: 1px dashed var(--border);
  background: rgba(248, 250, 252, 0.5);
}
[data-theme="dark"] .nf-card__footer {
  background: rgba(0, 0, 0, 0.15);
}
.nf-card__links,
.nf-card__ops {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.nf-card__links .btn,
.nf-card__links .btn-sm,
.nf-card__ops .btn,
.nf-card__ops .btn-sm {
  cursor: pointer;
}
.nf-card__links .btn-sm {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--accent);
  font-weight: 600;
}
.nf-card__links .btn-sm:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.topbar-actions .btn-ghost.nf-config-fiscal svg {
  flex-shrink: 0;
}

.nf-pagination-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
}
/* Botões de texto Anterior/Próxima (largura padrão da paginação é fixa 34px só para números) */
.nf-pagination-outer .nf-pagination-nav > .pagination-btn {
  width: auto;
  min-width: 40px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 500;
}
@media (max-width: 640px) {
  .nf-pagination-outer .pagination-wrapper {
    flex-direction: column;
    align-items: stretch;
  }
  .nf-pagination-nav {
    justify-content: center;
  }
}
@media (max-width: 600px) {
  .nf-filtros-bar {
    gap: 10px;
  }
}

/* ── Notas fiscais: tabela, grupos de erro, menu ações, toggle visualização ─ */
.nf-view-seg {
  display: inline-flex;
  border-radius: 10px;
  border: 1px solid var(--border);
  overflow: hidden;
  background: var(--surface2);
}
.nf-view-seg__btn {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.nf-view-seg__btn:hover {
  color: var(--text);
  background: rgba(6, 182, 212, 0.06);
}
.nf-view-seg__btn.is-active {
  background: var(--accent-dim);
  color: var(--accent-dark);
}
[data-theme="dark"] .nf-view-seg__btn.is-active {
  color: #22d3ee;
}

.nf-list.nf-list--table {
  display: block;
  width: 100%;
}
.nf-list.nf-list--cards {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
@media (min-width: 1200px) {
  .nf-list.nf-list--cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
    align-items: start;
  }
}

.nf-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  -webkit-overflow-scrolling: touch;
}
.nf-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  font-size: 13px;
}
.nf-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  text-align: left;
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.nf-table tbody tr.nf-row td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
}
.nf-table tbody tr.nf-row:hover td {
  background: rgba(6, 182, 212, 0.04);
}
[data-theme="dark"] .nf-table tbody tr.nf-row:hover td {
  background: rgba(255, 255, 255, 0.03);
}
.nf-table .nf-col-numero {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 600;
  white-space: nowrap;
}
.nf-table .nf-col-natureza {
  max-width: 140px;
  width: 12%;
}
.nf-table .nf-truncate {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nf-table .nf-col-data {
  max-width: 118px;
  white-space: nowrap;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.nf-table .nf-col-orc {
  max-width: 96px;
  overflow: hidden;
}
.nf-table .nf-col-orc a {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}
.nf-table .nf-col-orc a:hover {
  text-decoration: underline;
}

.nf-grupo {
  border-bottom: 2px solid var(--border);
}
.nf-grupo__summary td {
  padding: 0;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}
.nf-grupo__toggle {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s;
}
.nf-grupo__toggle:hover {
  background: rgba(6, 182, 212, 0.06);
}
.nf-grupo__chev {
  flex-shrink: 0;
  width: 1.25rem;
  display: inline-flex;
  justify-content: center;
  color: var(--accent);
  font-size: 11px;
  transition: transform 0.2s;
}
.nf-grupo[data-expanded="1"] .nf-grupo__chev {
  transform: rotate(90deg);
}
.nf-grupo__meta {
  flex: 1;
  min-width: 0;
  line-height: 1.45;
}
.nf-grupo__tit {
  font-weight: 700;
  margin-bottom: 4px;
}
.nf-grupo__erro-resumo {
  font-size: 12px;
  color: var(--muted);
  word-break: break-word;
}
.nf-grupo__detail td {
  padding: 8px 12px 8px 36px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  font-size: 12px;
}
.nf-grupo__detail td.nf-col-acoes {
  padding-left: 10px;
  vertical-align: middle;
}
.nf-grupo__detail:hover td {
  background: rgba(239, 68, 68, 0.04);
}

/* Ações em linha na tabela de notas fiscais */
.nf-col-acoes {
  white-space: normal;
  vertical-align: middle;
  text-align: right;
  min-width: 120px;
}
.nf-row-acoes {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  max-width: min(100%, 520px);
  margin-left: auto;
}
.nf-row-acoes .nf-icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
}
.nf-row-acoes .nf-icon-btn .nf-ico {
  width: 16px;
  height: 16px;
}
@media (max-width: 900px) {
  .nf-row-acoes {
    justify-content: flex-start;
    margin-left: 0;
    max-width: none;
  }
  .nf-col-acoes {
    text-align: left;
  }
}
/* Botões só-ícone (cartões e barra de atalhos) */
.nf-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  flex-shrink: 0;
  cursor: pointer;
  font: inherit;
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s, color 0.15s, opacity 0.2s;
}
.nf-icon-btn:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent-dark);
}
.nf-icon-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.nf-icon-btn--link {
  color: var(--accent);
}
.nf-icon-btn--link:hover {
  color: var(--accent-dark);
}
.nf-icon-btn--danger {
  border-color: rgba(239, 68, 68, 0.35);
  color: var(--red);
}
.nf-icon-btn--danger:hover {
  background: var(--red-dim);
  border-color: rgba(239, 68, 68, 0.55);
  color: var(--red);
}
.nf-icon-btn--warning {
  border-color: rgba(245, 158, 11, 0.45);
  color: #b45309;
  background: rgba(245, 158, 11, 0.08);
}
.nf-icon-btn--warning:hover {
  background: rgba(245, 158, 11, 0.16);
  border-color: rgba(217, 119, 6, 0.6);
  color: #92400e;
}
[data-theme="dark"] .nf-icon-btn--warning {
  color: #fbbf24;
}
[data-theme="dark"] .nf-icon-btn--warning:hover {
  color: #fde68a;
}
.nf-icon-btn--whatsapp {
  border-color: rgba(37, 211, 102, 0.35);
  color: #128c7e;
}
.nf-icon-btn--whatsapp:hover {
  background: rgba(37, 211, 102, 0.12);
  border-color: rgba(37, 211, 102, 0.55);
  color: #075e54;
}
.nf-icon-btn--mail {
  border-color: rgba(14, 165, 233, 0.35);
  color: #0369a1;
}
.nf-icon-btn--mail:hover {
  background: rgba(14, 165, 233, 0.1);
  border-color: rgba(14, 165, 233, 0.55);
  color: #0c4a6e;
}
.nf-icon-btn--loading {
  opacity: 0.55;
  pointer-events: none;
}
.nf-card__links.nf-card__icon-row,
.nf-card__ops.nf-card__icon-row {
  gap: 6px;
}
.nf-grupo__detail-erro {
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.45;
  word-break: break-word;
  color: var(--text);
}
.nf-grupo__detail-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
  font-size: 12px;
}
.nf-muted {
  color: var(--muted);
  font-size: 13px;
}

/* ── Prova Social — card flutuante do operador ─────────────────────────────── */
.prova-social-card {
  position: fixed; bottom: 20px; right: 20px; width: 380px; max-width: calc(100vw - 32px);
  background: var(--surface, #fff); border: 1px solid var(--border, #e5e7eb);
  border-radius: 14px; box-shadow: var(--shadow-lg, 0 10px 30px rgba(0,0,0,.15));
  z-index: 9997; overflow: hidden;
}
.prova-social-card.hidden { display: none; }
.prova-social-card .ps-head {
  background: var(--accent, #4f46e5); color: #fff; padding: 12px 14px;
  display: flex; justify-content: space-between; align-items: center;
}
.prova-social-card .ps-body { padding: 16px; max-height: 70vh; overflow-y: auto; }
.prova-social-star { cursor: pointer; transition: transform .1s; }
.prova-social-star:hover { transform: scale(1.1); }
.prova-social-chip {
  background: #f3f4f6; border: 1px solid #d1d5db; color: #374151;
  padding: 6px 12px; border-radius: 16px; font-size: 13px; cursor: pointer; margin: 2px;
  transition: all .2s;
}
.prova-social-chip:hover { background: #e0f2fe; border-color: #0284c7; color: #0369a1; }
@media (max-width: 768px) { .prova-social-card { bottom: 88px; right: 16px; } }
body.quick-quote-open .prova-social-card { transform: translateX(120%); }

/* ══════════════════════════════════════════════════════════════
   MOBILE GLOBAL — Correções transversais de responsividade
   ══════════════════════════════════════════════════════════════ */

/* Touch targets mínimos (44x44px) em todas as telas */
@media (max-width: 768px) {
  .btn, .tab, .filter-chip, .action-btn, .admin-tab,
  .nav-item, .mobile-card-actions-btn, a[href],
  button:not([type="hidden"]), .fin-tab, .fin-chip {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .sidebar .nav-item {
    justify-content: flex-start;
  }

  .sidebar .sidebar-upgrade-link {
    min-height: 28px;
  }
}

/* Prevenir zoom automático em inputs no iOS (font-size < 16px) */
@media (max-width: 768px) {
  input:not([type="hidden"]):not([type="color"]):not([type="range"]),
  select, textarea {
    font-size: 16px !important;
  }
}

/* Imagens sempre responsivas */
img { max-width: 100%; height: auto; }

/* Texto com word-break adequado */
@media (max-width: 768px) {
  .card, .stat-card, .modal-body, .cfg-card-body {
    word-break: break-word;
    overflow-wrap: break-word;
  }
}
