:root {
  --primary: #9a2167;
  --primary-dark: #5c225c;
  --danger: #dc2626;
  --success: #16a34a;
  --bg: #f8f3fa;
  --card: #ffffff;
  --text: #2a2b58;
  --muted: #646997;
  --border: #e2d6ee;
  --emerald: #d7a6f4;
  --emerald-dark: #a86ad6;
  --ink: #140f2e;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.hidden { display: none !important; }

/* ---------- Auth screens ---------- */
.auth-wrapper {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
}

/* Painel de marca (esquerda) */
.auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  background: radial-gradient(circle at 20% 20%, #5c225c 0%, var(--ink) 58%, #0b081b 100%);
  color: #e5e7eb;
}

.auth-brand-inner { max-width: 420px; }

.auth-brand-logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
  color: var(--emerald);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 36px;
}

/* Tipografia "jumbo" no espírito do hero do template App Launch (W3.CSS) */
.jumbo {
  font-size: 46px;
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: -0.01em;
  margin: 0;
  color: #fff;
}

.jumbo .accent { color: var(--emerald); }

hr.fade {
  border: none;
  border-top: 1px solid rgba(255,255,255,0.15);
  margin: 22px 0;
}

.lead {
  color: #9ca3af;
  font-size: 15px;
  line-height: 1.6;
  margin: 0 0 32px;
}

/* Grade de recursos, no espírito da seção "Features" do App Launch */
.auth-features {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 32px;
}

.auth-features .feature {
  text-align: center;
  color: #d1d5db;
}

.auth-features .feature i {
  font-size: 22px;
  color: var(--emerald);
  margin-bottom: 6px;
  display: block;
}

.auth-features .feature p {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
}

.auth-trust {
  font-size: 12px;
  color: #9ca3af;
  line-height: 1.9;
}

.auth-trust i { color: var(--emerald); margin-right: 4px; }
.auth-trust .dot { margin: 0 8px; color: #4b5563; }

/* Painel do formulário (direita) */
.auth-forms {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}

.auth-card {
  background: var(--card);
  padding: 36px 32px;
  border-radius: 20px;
  box-shadow: 0 20px 45px rgba(92, 34, 92, 0.15), 0 2px 8px rgba(0,0,0,0.06);
  width: 100%;
  max-width: 400px;
}

.auth-card-logo {
  display: none;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--emerald-dark);
  margin-bottom: 16px;
}

.auth-card h1 {
  font-size: 26px;
  font-weight: 800;
  margin-bottom: 4px;
}

.auth-card p.subtitle {
  color: var(--muted);
  margin-top: 0;
  margin-bottom: 24px;
  font-size: 14px;
}

@media (max-width: 860px) {
  .auth-wrapper { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .auth-card-logo { display: inline-flex; }
}

@media (max-width: 480px) {
  .jumbo { font-size: 34px; }
  .auth-features { grid-template-columns: repeat(4, 1fr); gap: 4px; }
}

.field {
  margin-bottom: 14px;
  position: relative;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
}

.field input, .field select, .field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
}

.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(154, 33, 103, 0.15);
}

/* Inputs com ícone (Font Awesome), estilo app bancário */
.field-icon .field-icon-glyph {
  position: absolute;
  left: 12px;
  bottom: 12px;
  color: var(--muted);
  font-size: 14px;
  pointer-events: none;
}

.field-icon input { padding-left: 34px; }

button.primary {
  width: 100%;
  padding: 13px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  letter-spacing: 0.01em;
  cursor: pointer;
  margin-top: 10px;
  transition: background 0.15s ease, transform 0.05s ease;
}

button.primary i { margin-right: 6px; }

button.primary:hover { background: var(--primary-dark); }
button.primary:active { transform: scale(0.99); }

button.secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}

/* Botão em formato de link de texto, usado para ações secundárias dentro
   de um card (ex.: "Informar número da transação manualmente" quando a
   leitura automática do comprovante falha). */
button.link-btn {
  display: block;
  background: none;
  border: none;
  padding: 0;
  margin: 0 auto;
  color: var(--primary);
  font-size: 12px;
  text-decoration: underline;
  cursor: pointer;
}
button.link-btn:hover { color: var(--primary-dark); }

.switch-link {
  text-align: center;
  margin-top: 16px;
  font-size: 13px;
  color: var(--muted);
}

.switch-link a { color: var(--primary); cursor: pointer; text-decoration: none; }

.error-box {
  background: #fee2e2;
  color: #991b1b;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 14px;
}

.success-box {
  background: #dcfce7;
  color: #166534;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 14px;
}

/* ---------- App shell ---------- */
.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, #1a1338 0%, #140f2e 55%, #0b081b 100%);
  color: #e5e7eb;
  padding: 20px 14px;
}

.sidebar h2 {
  font-size: 16px;
  margin: 0 0 2px;
}

.sidebar .tenant-plan {
  font-size: 12px;
  color: #c4bbdf;
  margin-bottom: 20px;
}

.nav-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: #e5e7eb;
  font-size: 14px;
  cursor: pointer;
  margin-bottom: 4px;
}

.nav-item:hover { background: rgba(215, 166, 244, 0.14); }
.nav-item.active { background: var(--primary); color: white; }
.nav-sub-item {
  font-size: 13px;
  padding: 8px 12px 8px 22px;
}

.sidebar-menu-label {
  margin: 14px 0 4px;
  padding: 0 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #d7c9ec;
}

.sidebar-footer {
  margin-top: 24px;
  padding-top: 14px;
  border-top: 1px solid rgba(215, 166, 244, 0.28);
  font-size: 12px;
  color: #c4bbdf;
}

.main {
  padding: 28px 36px;
}

.main h1 {
  margin-top: 0;
  font-size: 22px;
}

.card {
  background: var(--card);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  margin-bottom: 20px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th, td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.badge.free { background: #f1e9f8; color: #4a3d70; }
.badge.premium { background: #eadcf7; color: #6f2e93; }
.badge.mp { background: #efe6ff; color: #5b3b99; }

.sync-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  margin: -12px 0 20px;
  color: #9ca3af;
}

.sync-status .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.sync-status.synced .dot { background: #22c55e; }
.sync-status.pending .dot { background: #f59e0b; }
.sync-status.local .dot { background: #6b7280; }
.sync-status.error .dot { background: #ef4444; }

/* Badge/indicador global do Mercado Pago na sidebar (resumo do que
   orcamento_agent/mp_expenses.py + mp_reconcile.py já geraram/confirmaram —
   distinto do selo "Mercado Pago" por linha na tabela de despesas). */
.mp-status {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 11px;
  margin: -12px 0 20px;
  color: #9ca3af;
}

.mp-status .badge.mp { flex-shrink: 0; transition: opacity 0.15s ease; }

.mp-status.idle .badge.mp { opacity: 0.45; }

.mp-status.connected .badge.mp { opacity: 1; }

.mp-status.connected #mp-status-label { color: var(--success); }

/* Botão de atualizar (refresh) ao lado do badge do Mercado Pago -- só
   reconsulta Api.getMercadoPagoStatus() em js/dashboard.js. */
.mp-refresh-btn {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 6px;
  flex-shrink: 0;
  opacity: 0.7;
  transition: opacity 0.15s ease, background 0.15s ease;
}

.mp-refresh-btn:hover { opacity: 1; background: rgba(255, 255, 255, 0.08); }

.mp-refresh-btn.spinning { animation: mp-spin 0.7s linear infinite; }

.mp-customer-profile {
  flex-basis: 100%;
  line-height: 1.35;
}

.mp-rejection-reasons {
  flex-basis: 100%;
  line-height: 1.35;
  white-space: pre-line;
  color: #fca5a5;
}

@keyframes mp-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.plan-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  text-align: center;
}

.plan-card.current { border-color: var(--primary); background: #f3e7fa; }

.plan-card h3 { margin: 0 0 6px; }
.plan-price { font-size: 24px; font-weight: 700; margin: 8px 0; }
.plan-price span { font-size: 13px; font-weight: 400; color: var(--muted); }

.alert-ok {
  background: #dcfce7; color: #166534; padding: 14px; border-radius: 8px;
}
.alert-warn {
  background: #fee2e2; color: #991b1b; padding: 14px; border-radius: 8px;
}

.kpi-status {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.kpi-status-green {
  background: #dcfce7;
  color: #166534;
}
.kpi-status-yellow {
  background: #fef3c7;
  color: #92400e;
}
.kpi-status-red {
  background: #fee2e2;
  color: #991b1b;
}
.kpi-status-gray {
  background: #e5e7eb;
  color: #374151;
}

/* ---------- Fluxo "Orçamento & Despesas" (paginação) ---------- */
.flow-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.flow-pager-dots {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.flow-page-dot {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.flow-page-dot:hover { border-color: var(--primary); color: var(--text); }
.flow-page-dot.active { background: var(--primary); color: #fff; border-color: var(--primary); }

#view-budget-flow .flow-pager-dots,
#view-budget-flow #budget-submenu-budget,
#view-budget-flow #budget-submenu-expenses {
  justify-content: center;
}

.badge.sem-orcamento { background: #e5e7eb; color: #374151; }
.badge.estourado { background: #fee2e2; color: #991b1b; }
.badge.dentro { background: #dcfce7; color: #166534; }

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.small-muted { color: var(--muted); font-size: 12px; }

.budget-upload-area {
  border: 1px dashed #9ca3af;
  border-radius: 12px;
  padding: 18px 14px;
  text-align: center;
  background: #faf5ff;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
  cursor: pointer;
}

.budget-upload-area:hover,
.budget-upload-area:focus {
  border-color: var(--primary);
  background: #f5e9fa;
  outline: none;
  box-shadow: 0 0 0 3px rgba(154, 33, 103, 0.15);
}

.budget-upload-area.drag-over {
  border-color: var(--primary);
  background: #f1defa;
}

.budget-upload-title {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

/* ---------- Modal (pagamento Pix) ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal-box {
  background: var(--card);
  border-radius: 12px;
  padding: 24px;
  max-width: 370px;
  width: 100%;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  text-align: center;
}

/* Modal do criador de layout de leitura — 15px menor que o padrão */
#budget-layout-modal .modal-box {
  max-width: 355px;
}

.qr-wrap {
  background: #fff;
  padding: 12px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 166px;
  height: 166px;
  box-sizing: border-box;
  margin: 0 auto 16px;
  border: 1px solid var(--border);
}

.qr-wrap img {
  width: 100%;
  height: 100%;
  display: block;
}

.pix-code-box {
  font-size: 11px;
  word-break: break-all;
  background: #f8f1fc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 10px;
  color: var(--muted);
  text-align: left;
}

/* ---------- Utility classes (migradas de estilos inline) ---------- */
.d-flex { display: flex; }
.d-block { display: block; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }
.gap-6 { gap: 6px; }
.gap-10 { gap: 10px; }
.gap-16 { gap: 16px; }
.text-center { text-align: center; }
.text-left { text-align: left; }
.w-100 { width: 100%; }
.min-w-160 { min-width: 160px; }
.min-h-1rem { min-height: 1rem; }
.m-0 { margin: 0; }
.mt-0 { margin-top: 0; }
.mt-4 { margin-top: 4px; }
.mt-6 { margin-top: 6px; }
.mt-8 { margin-top: 8px; }
.mt-10 { margin-top: 10px; }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: 2px; }
.mb-4 { margin-bottom: 4px; }
.mb-6 { margin-bottom: 6px; }
.mb-12 { margin-bottom: 12px; }
.mb-14 { margin-bottom: 14px; }
.mb-16 { margin-bottom: 16px; }
.mb-18 { margin-bottom: 18px; }
.text-danger { color: var(--danger); }
.btn-outline-danger { border-color: var(--danger); color: var(--danger); }
.fs-18 { font-size: 18px; }
.fs-20 { font-size: 20px; }
.fs-26 { font-size: 26px; }
.fw-400 { font-weight: 400; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.line-height-1 { line-height: 1; }
.no-bg { background: none; }
.no-border { border: none; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.hidden-frame { display: none; visibility: hidden; }

/* Classes compostas para padrões repetidos */
.row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.row-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
}

.radio-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 400;
}

.button-row {
  display: flex;
  gap: 10px;
}

.button-row-wrap {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

.google-ai-chat-messages {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 10px;
  max-height: 300px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.google-ai-msg {
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.4;
  white-space: pre-wrap;
}

.google-ai-msg.user {
  background: rgba(154, 33, 103, 0.12);
  align-self: flex-end;
}

.google-ai-msg.bot {
  background: rgba(215, 166, 244, 0.22);
  align-self: flex-start;
}

/* ---------- Sidebar: seção "Conta" (Segurança/Privacidade/Configurações) ---------- */
.sidebar-section-label {
  margin: 18px 0 6px;
  padding: 0 12px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #c4bbdf;
}

/* ---------- Segurança: lista de controles implementados / direitos LGPD ---------- */
.security-control-list {
  margin: 0;
  padding-left: 20px;
  font-size: 13px;
  line-height: 1.9;
  color: var(--text);
}

.security-control-list li { margin-bottom: 4px; }

.monthly-check-item-done { color: var(--success); }
.monthly-check-item-open { color: #92400e; }

/* ---------- CIA Triad ---------- */
.cia-card { text-align: center; padding: 18px 14px; }

.cia-letter {
  width: 40px;
  height: 40px;
  margin: 0 auto 10px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Normas ISO (referência) ---------- */
.iso-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.iso-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
}

/* ---------- Configurações: dados institucionais (empresa) ---------- */
.company-profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px 20px;
  font-size: 13px;
}

.company-profile-grid .company-profile-full { grid-column: 1 / -1; }

/* ---------- Certificação: barra de prontidão (autoavaliação) ---------- */
.readiness-bar {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}

.readiness-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 999px;
}

/* ---------- Privacidade: toggle de consentimento de cookies ---------- */
.consent-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  cursor: pointer;
}

.consent-toggle input { width: 18px; height: 18px; cursor: pointer; }

@media (max-width: 1024px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 40;
    padding: 14px 12px;
  }
  .sidebar h2 { margin-bottom: 6px; }
  .tenant-plan, .sync-status, .mp-status, .sidebar-section-label, .sidebar-footer {
    margin-bottom: 10px;
  }
  .main { padding: 20px; }
  .flow-pager { justify-content: center; }
}

@media (max-width: 860px) {
  .auth-wrapper { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .auth-card-logo { display: inline-flex; }
  #cia-triad-grid, .iso-grid, .company-profile-grid, .grid-2, .grid-cols-2, .grid-cols-3 {
    grid-template-columns: 1fr;
  }
  .top-bar { flex-direction: column; align-items: flex-start; gap: 8px; }
  .flow-pager { flex-direction: column; align-items: stretch; }
  .flow-pager .secondary { width: 100%; }
  .flow-pager-dots { justify-content: flex-start; }
  #view-budget-flow .flow-pager-dots { justify-content: center; }
  .flow-page-dot { width: 100%; text-align: center; }
}

@media (max-width: 640px) {
  .main { padding: 16px; }
  .card { padding: 16px; }
  .auth-forms { padding: 14px; }
  .auth-card { padding: 22px 16px; border-radius: 14px; }
  .flow-page-dot { font-size: 11px; padding: 6px 10px; }
  .button-row, .button-row-wrap, .row, .row-between { flex-direction: column; }
  .button-row > *, .button-row-wrap > * { width: 100%; }
  th, td { white-space: nowrap; }
  table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .modal-box { padding: 18px; }
  .qr-wrap { width: 142px; height: 142px; }
}
