/* ==========================================================================
   FINANCEFLOW — DESIGN SYSTEM "FINTECH SOFISTICADA"
   Estilo Premium (Stripe & Apple Pro inspired)
   Cores harmoniosas, Glassmorphism, Micro-animações e Tipografia Moderna
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700;800&family=Plus+Jakarta+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,400;1,600&display=swap');

:root {
  color-scheme: light;

  /* Superfícies & Fundos (Fintech Light) */
  --bg: #f8fafc;
  --bg-mesh: radial-gradient(at 0% 0%, rgba(37, 99, 235, 0.05) 0px, transparent 50%),
             radial-gradient(at 100% 0%, rgba(16, 185, 129, 0.04) 0px, transparent 40%),
             radial-gradient(at 50% 100%, rgba(99, 102, 241, 0.04) 0px, transparent 50%),
             #f8fafc;
  --sidebar: rgba(255, 255, 255, 0.88);
  --sidebar-border: rgba(226, 232, 240, 0.85);
  --surface: #ffffff;
  --surface-card: rgba(255, 255, 255, 0.95);
  --surface-raised: #f1f5f9;
  --surface-subtle: #f8fafc;
  --border: rgba(226, 232, 240, 0.9);
  --border-subtle: rgba(241, 245, 249, 0.8);
  --border-focus: #2563eb;

  /* Tipografia */
  --text: #0f172a;
  --text-secondary: #475569;
  --muted: #64748b;
  --text-on-accent: #ffffff;

  /* Cores de Marca & Acentos Vivos */
  --blue: #2563eb;
  --blue-hover: #1d4ed8;
  --blue-glow: rgba(37, 99, 235, 0.25);
  --blue-subtle: rgba(37, 99, 235, 0.08);

  --green: #10b981;
  --green-hover: #059669;
  --green-glow: rgba(16, 185, 129, 0.25);
  --green-subtle: rgba(16, 185, 129, 0.09);

  --coral: #f43f5e;
  --coral-hover: #e11d48;
  --coral-glow: rgba(244, 63, 94, 0.25);
  --coral-subtle: rgba(244, 63, 94, 0.08);

  --purple: #8b5cf6;
  --purple-hover: #7c3aed;
  --purple-glow: rgba(139, 92, 246, 0.25);
  --purple-subtle: rgba(139, 92, 246, 0.08);

  --indigo: #6366f1;
  --orange: #f59e0b;
  --orange-subtle: rgba(245, 158, 11, 0.1);

  /* Sombras Elegantes Multicamada */
  --shadow-sm: 0 1px 2px 0 rgba(15, 23, 42, 0.04);
  --shadow: 0 4px 18px -2px rgba(15, 23, 42, 0.05), 0 2px 6px -1px rgba(15, 23, 42, 0.02);
  --shadow-elevated: 0 16px 36px -6px rgba(15, 23, 42, 0.09), 0 6px 14px -3px rgba(15, 23, 42, 0.04);
  --shadow-glow: 0 0 28px -4px rgba(37, 99, 235, 0.18);

  /* Fontes */
  --font-sans: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  --font-display: "Outfit", "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, sans-serif;

  /* Raios de borda */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-pill: 9999px;
}

/* ==========================================================================
   TEMA ESCURO — FINTECH SOFISTICADA (Padrão Stripe & Apple Pro Dark)
   Superfícies em grafite/obsidiana profundo, bordas de precisão e alto contraste
   ========================================================================== */
:root[data-theme="dark"] {
  color-scheme: dark;

  /* Base e Camadas de Elevação (Apple Pro Carbon & Stripe Slate) */
  --bg: #0a0d14;
  --bg-mesh: radial-gradient(ellipse 80% 50% at 50% -15%, rgba(91, 141, 239, 0.09), transparent 60%),
             radial-gradient(ellipse 60% 45% at 100% 0%, rgba(99, 102, 241, 0.05), transparent 50%),
             #0a0d14;
  --sidebar: rgba(12, 16, 24, 0.90);
  --sidebar-border: rgba(255, 255, 255, 0.075);
  --surface: #121722;
  --surface-card: #131926;
  --surface-raised: #1a2233;
  --surface-subtle: #0d121c;
  --border: rgba(255, 255, 255, 0.085);
  --border-subtle: rgba(255, 255, 255, 0.05);
  --border-focus: #5b8def;

  /* Tipografia com Contraste Calibrado (Sem mistura com o fundo) */
  --text: #f8fafc;
  --text-secondary: #cbd5e1;
  --muted: #a3b2c7;
  --text-on-accent: #ffffff;

  /* Acentos Refinados (Elegantes, sem tons neon berrantes) */
  --blue: #5b8def;
  --blue-hover: #7aa4f7;
  --blue-glow: rgba(91, 141, 239, 0.20);
  --blue-subtle: rgba(91, 141, 239, 0.11);

  --green: #34d399;
  --green-hover: #10b981;
  --green-glow: rgba(52, 211, 153, 0.16);
  --green-subtle: rgba(52, 211, 153, 0.10);

  --coral: #f47280;
  --coral-hover: #fb7185;
  --coral-glow: rgba(244, 114, 128, 0.16);
  --coral-subtle: rgba(244, 114, 128, 0.10);

  --purple: #a78bfa;
  --purple-hover: #c4b5fd;
  --purple-glow: rgba(167, 139, 250, 0.18);
  --purple-subtle: rgba(167, 139, 250, 0.11);

  --indigo: #818cf8;
  --orange: #f59e0b;
  --orange-subtle: rgba(245, 158, 11, 0.11);

  /* Sombras Profundas com Luz Especular Superior (Apple Pro Rim Light) */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.45);
  --shadow: 0 8px 24px -4px rgba(0, 0, 0, 0.50), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  --shadow-elevated: 0 20px 44px -8px rgba(0, 0, 0, 0.68), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  --shadow-glow: 0 0 28px -6px rgba(91, 141, 239, 0.22);
}

/* ==========================================================================
   RESET & BASE STYLES
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg-mesh);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.3s ease, color 0.3s ease;
}

button, input, select, textarea {
  font-family: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  cursor: pointer;
  border: 0;
  outline: 0;
  background: transparent;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

button:active {
  transform: scale(0.97);
}

h1, h2, h3, h4, p {
  margin-top: 0;
}

h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 30px;
  letter-spacing: -0.03em;
  margin-bottom: 0;
  line-height: 1.2;
}

h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 24px;
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin: 10px 0 6px;
}

h3 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.015em;
  margin: 0 0 4px;
}

/* ==========================================================================
   SIDEBAR & BRANDING (Glassmorphism & Clean Fintech Navigation)
   ========================================================================== */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  display: flex;
  width: 260px;
  flex-direction: column;
  padding: 30px 18px 24px;
  background: var(--sidebar);
  border-right: 1px solid var(--sidebar-border);
  backdrop-filter: blur(28px) saturate(190%);
  -webkit-backdrop-filter: blur(28px) saturate(190%);
  box-shadow: 4px 0 30px rgba(0, 0, 0, 0.02);
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 8px 36px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 21px;
  letter-spacing: -0.03em;
  color: var(--text);
  user-select: none;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 12px;
  color: #ffffff;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 50%, #4f46e5 100%);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 19px;
  box-shadow: 0 6px 16px -2px rgba(37, 99, 235, 0.45), inset 0 1px 1px rgba(255, 255, 255, 0.4);
  position: relative;
  overflow: hidden;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.brand-mark::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.35) 0%, transparent 60%);
  pointer-events: none;
}

.brand:hover .brand-mark {
  transform: translateY(-1px) rotate(-2deg);
  box-shadow: 0 8px 20px -2px rgba(37, 99, 235, 0.55);
}

.brand-accent {
  background: linear-gradient(135deg, var(--blue) 0%, #6366f1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.6px;
  text-transform: uppercase;
}

.nav-links {
  display: grid;
  gap: 6px;
}

.nav-links a {
  display: flex;
  align-items: center;
  gap: 13px;
  min-height: 44px;
  padding: 0 14px;
  color: var(--text-secondary);
  border-radius: 12px;
  font-size: 16px;
  position: relative;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.nav-links a span {
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.nav-links a:hover {
  color: var(--text);
  background: var(--surface-raised);
  transform: translateX(3px);
}

.nav-links a.active {
  color: #ffffff;
  background: linear-gradient(135deg, var(--blue) 0%, #1d4ed8 100%);
  box-shadow: 0 6px 18px -2px var(--blue-glow), inset 0 1px 1px rgba(255, 255, 255, 0.25);
  font-weight: 600;
}

.nav-links a.active span {
  color: #ffffff;
  font-weight: 700;
}

.sidebar-bottom {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: auto;
  padding: 18px 10px 4px;
  border-top: 1px solid var(--border);
}

.avatar {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 50%;
  color: #ffffff;
  background: linear-gradient(135deg, var(--green) 0%, #059669 100%);
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 4px 12px var(--green-glow), inset 0 1px 1px rgba(255, 255, 255, 0.4);
  position: relative;
}

.avatar::after {
  content: "";
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #10b981;
  border: 2px solid var(--surface);
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
}

.sidebar-bottom strong,
.sidebar-bottom small {
  display: block;
}

.sidebar-bottom strong {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.sidebar-bottom small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

/* ==========================================================================
   MAIN CONTENT AREA & TOPBAR
   ========================================================================== */
.main-content {
  width: min(1500px, calc(100% - 260px));
  margin-left: 260px;
  padding: 34px clamp(24px, 4vw, 56px) 60px;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 26px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.reference-month {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 13px;
}

.reference-month select {
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 650;
  text-transform: capitalize;
}

/* ==========================================================================
   BUTTONS (Fintech Glow, Crisp Borders & Smooth Active States)
   ========================================================================== */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  background: var(--surface);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
}

.button:hover {
  transform: translateY(-1.5px);
  border-color: rgba(37, 99, 235, 0.3);
  box-shadow: var(--shadow);
  color: var(--blue);
}

.button:disabled {
  cursor: wait;
  opacity: 0.6;
  transform: none;
  box-shadow: none;
}

.button-primary {
  color: #ffffff !important;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: linear-gradient(135deg, var(--blue) 0%, #1d4ed8 100%);
  box-shadow: 0 4px 14px -1px var(--blue-glow), inset 0 1px 1px rgba(255, 255, 255, 0.28);
}

.button-primary:hover {
  background: linear-gradient(135deg, #3b82f6 0%, #1e40af 100%);
  box-shadow: 0 8px 22px -2px var(--blue-glow), inset 0 1px 1px rgba(255, 255, 255, 0.35);
  color: #ffffff !important;
}

.button-quiet {
  color: var(--blue);
  background: var(--blue-subtle);
  border: 1px solid rgba(37, 99, 235, 0.18);
}

.button-quiet:hover {
  background: rgba(37, 99, 235, 0.14);
  border-color: rgba(37, 99, 235, 0.35);
}

.button-danger {
  color: var(--coral);
  background: var(--coral-subtle);
  border: 1px solid rgba(244, 63, 94, 0.25);
}

.button-danger:hover {
  background: rgba(244, 63, 94, 0.15);
  border-color: rgba(244, 63, 94, 0.45);
  color: var(--coral-hover);
}

.button-danger-solid {
  color: #ffffff !important;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: linear-gradient(135deg, var(--coral) 0%, #e11d48 100%);
  box-shadow: 0 4px 14px -1px var(--coral-glow);
}

.button-danger-solid:hover {
  background: linear-gradient(135deg, #fb7185 0%, #be123c 100%);
  box-shadow: 0 8px 22px -2px var(--coral-glow);
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  background: var(--surface);
  font-size: 18px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.icon-button:hover {
  color: var(--blue);
  border-color: rgba(37, 99, 235, 0.3);
  transform: translateY(-1.5px);
  box-shadow: var(--shadow);
}

/* ==========================================================================
   CONFIRMATION MODAL (Rich Frosted Backdrop & Spring Modal)
   ========================================================================== */
.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 1300;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(9, 13, 22, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: overlayFadeIn 0.2s ease-out;
}

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

.confirm-dialog {
  width: min(440px, 100%);
  padding: 26px 24px 22px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: var(--shadow-elevated);
  animation: modalPopIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPopIn {
  from { transform: scale(0.94) translateY(8px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

.confirm-dialog h3 {
  margin: 0 0 10px;
  font-size: 18px;
  font-weight: 700;
}

.confirm-dialog p {
  margin: 0 0 20px;
  color: var(--text-secondary);
  font-size: 13.5px;
  line-height: 1.6;
  white-space: pre-line;
}

.confirm-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.confirm-actions .button {
  flex: 1 1 auto;
  min-width: 120px;
}

/* ==========================================================================
   HERO / WELCOME PANEL (Vibrant Mesh Accent Banner)
   ========================================================================== */
.welcome-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 140px;
  margin-bottom: 24px;
  padding: 28px 34px;
  overflow: hidden;
  border: 1px solid rgba(37, 99, 235, 0.18);
  border-radius: var(--radius-lg);
  background: radial-gradient(ellipse at 85% 20%, rgba(37, 99, 235, 0.12), transparent 50%),
              radial-gradient(ellipse at 15% 90%, rgba(16, 185, 129, 0.08), transparent 45%),
              linear-gradient(135deg, var(--surface) 0%, rgba(241, 245, 249, 0.95) 100%);
  box-shadow: var(--shadow);
  position: relative;
  transition: all 0.3s ease;
}

:root[data-theme="dark"] .welcome-panel {
  border-color: rgba(255, 255, 255, 0.09);
  background: radial-gradient(ellipse at 90% 0%, rgba(91, 141, 239, 0.10), transparent 55%),
              linear-gradient(165deg, #151c2b 0%, #111622 100%);
  box-shadow: var(--shadow);
}

.welcome-panel::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--blue), var(--green), transparent);
  opacity: 0.6;
}

.welcome-panel p,
.panel-heading p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.55;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  color: var(--blue);
  background: var(--blue-subtle);
  border: 1px solid rgba(37, 99, 235, 0.15);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.pill-debt {
  color: var(--coral);
  background: var(--coral-subtle);
  border-color: rgba(244, 63, 94, 0.2);
}

.compact-welcome {
  min-height: 110px;
  padding: 22px 30px;
}

/* ==========================================================================
   TONS SUAVES POR CONTEXTO: RECEITAS (Verde Sálvia Suave) & DESPESAS (Rosé/Vermelho Suave)
   ========================================================================== */

/* 1. TELA DE RECEITAS — Tudo relacionado a receitas com tom verde suave (não berrante) */
body[data-page="receitas"] .welcome-panel,
body[data-page="receitas"] .panel.form-panel,
body[data-page="receitas"] .debt-summary-panel,
body[data-page="receitas"] .table-panel {
  border: 1px solid rgba(16, 185, 129, 0.24);
  background: linear-gradient(155deg, #eff8f3 0%, #e7f3ec 52%, #f2f9f5 100%);
  box-shadow: 0 8px 24px -6px rgba(16, 185, 129, 0.09), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

body[data-page="receitas"] .table-panel {
  background: linear-gradient(180deg, #f3faf6 0%, #ffffff 140px);
}

body[data-page="receitas"] .welcome-panel::after,
body[data-page="receitas"] .panel.form-panel::before,
body[data-page="receitas"] .debt-summary-panel::before {
  height: 3px;
  background: linear-gradient(90deg, rgba(5, 150, 105, 0.65), rgba(16, 185, 129, 0.7), rgba(52, 211, 153, 0.55));
  opacity: 0.9;
}

body[data-page="receitas"] .welcome-panel .pill,
body[data-page="receitas"] .debt-summary-panel .pill {
  color: #0f766e;
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.25);
}

body[data-page="receitas"] .debt-main-badge {
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.24);
}

body[data-page="receitas"] .debt-main-badge strong {
  color: #059669;
}

body[data-page="receitas"] .form-panel .field input,
body[data-page="receitas"] .form-panel .field select,
body[data-page="receitas"] .form-panel .field textarea {
  background: #ffffff;
  border-color: rgba(16, 185, 129, 0.24);
}

body[data-page="receitas"] .form-panel .field input:focus,
body[data-page="receitas"] .form-panel .field select:focus {
  border-color: #059669;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.16);
}

body[data-page="receitas"] .add-income-button {
  color: #047857;
  border-color: rgba(16, 185, 129, 0.32);
  background: rgba(16, 185, 129, 0.08);
}

body[data-page="receitas"] .add-income-button:hover {
  background: rgba(16, 185, 129, 0.14);
  border-color: #059669;
}

/* Tema escuro — Receitas: grafite escuro sofisticado com nuance esmeralda discreta */
:root[data-theme="dark"] body[data-page="receitas"] .welcome-panel,
:root[data-theme="dark"] body[data-page="receitas"] .panel.form-panel,
:root[data-theme="dark"] body[data-page="receitas"] .debt-summary-panel,
:root[data-theme="dark"] body[data-page="receitas"] .table-panel {
  border-color: rgba(52, 211, 153, 0.16);
  background: radial-gradient(ellipse at 92% 0%, rgba(52, 211, 153, 0.055), transparent 58%),
              linear-gradient(165deg, #131a26 0%, #111621 100%);
  box-shadow: var(--shadow);
}

:root[data-theme="dark"] body[data-page="receitas"] .welcome-panel .pill,
:root[data-theme="dark"] body[data-page="receitas"] .debt-summary-panel .pill {
  color: #6ee7b7;
  background: rgba(52, 211, 153, 0.11);
  border-color: rgba(52, 211, 153, 0.22);
}

:root[data-theme="dark"] body[data-page="receitas"] .debt-main-badge {
  background: rgba(52, 211, 153, 0.07);
  border-color: rgba(52, 211, 153, 0.20);
}

:root[data-theme="dark"] body[data-page="receitas"] .debt-main-badge strong {
  color: #34d399;
}

:root[data-theme="dark"] body[data-page="receitas"] .add-income-button {
  color: #6ee7b7;
  border-color: rgba(52, 211, 153, 0.24);
  background: rgba(52, 211, 153, 0.07);
}

:root[data-theme="dark"] body[data-page="receitas"] .add-income-button:hover {
  background: rgba(52, 211, 153, 0.13);
  border-color: rgba(52, 211, 153, 0.38);
}

/* 2. TELA DE DESPESAS — Tudo relacionado a despesas com tom vermelho/rosé suave (não berrante) */
body[data-page="despesas"] .welcome-panel,
body[data-page="despesas"] .panel.form-panel,
body[data-page="despesas"] .debt-summary-panel,
body[data-page="despesas"] .table-panel {
  border: 1px solid rgba(225, 29, 72, 0.20);
  background: linear-gradient(155deg, #fbf1f3 0%, #f5e6e9 52%, #faf0f2 100%);
  box-shadow: 0 8px 24px -6px rgba(225, 29, 72, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

body[data-page="despesas"] .table-panel {
  background: linear-gradient(180deg, #fcf4f5 0%, #ffffff 140px);
}

body[data-page="despesas"] .welcome-panel::after,
body[data-page="despesas"] .panel.form-panel::before,
body[data-page="despesas"] .debt-summary-panel::before {
  height: 3px;
  background: linear-gradient(90deg, rgba(190, 18, 60, 0.60), rgba(244, 63, 94, 0.65), rgba(251, 113, 133, 0.50));
  opacity: 0.9;
}

body[data-page="despesas"] .welcome-panel .pill,
body[data-page="despesas"] .panel.form-panel .pill,
body[data-page="despesas"] .debt-summary-panel .pill {
  color: #9f1239;
  background: rgba(225, 29, 72, 0.10);
  border-color: rgba(225, 29, 72, 0.22);
}

body[data-page="despesas"] .form-panel .field input,
body[data-page="despesas"] .form-panel .field select,
body[data-page="despesas"] .form-panel .field textarea {
  background: #ffffff;
  border-color: rgba(225, 29, 72, 0.20);
}

body[data-page="despesas"] .form-panel .field input:focus,
body[data-page="despesas"] .form-panel .field select:focus {
  border-color: #e11d48;
  box-shadow: 0 0 0 3px rgba(225, 29, 72, 0.14);
}

body[data-page="despesas"] .add-income-button {
  color: #be123c;
  border-color: rgba(225, 29, 72, 0.28);
  background: rgba(225, 29, 72, 0.06);
}

body[data-page="despesas"] .add-income-button:hover {
  background: rgba(225, 29, 72, 0.12);
  border-color: #e11d48;
}

/* Tema escuro — Despesas: grafite escuro sofisticado com nuance rosé discreta */
:root[data-theme="dark"] body[data-page="despesas"] .welcome-panel,
:root[data-theme="dark"] body[data-page="despesas"] .panel.form-panel,
:root[data-theme="dark"] body[data-page="despesas"] .debt-summary-panel,
:root[data-theme="dark"] body[data-page="despesas"] .table-panel {
  border-color: rgba(244, 114, 128, 0.16);
  background: radial-gradient(ellipse at 92% 0%, rgba(244, 114, 128, 0.05), transparent 58%),
              linear-gradient(165deg, #151925 0%, #111621 100%);
  box-shadow: var(--shadow);
}

:root[data-theme="dark"] body[data-page="despesas"] .welcome-panel .pill,
:root[data-theme="dark"] body[data-page="despesas"] .panel.form-panel .pill,
:root[data-theme="dark"] body[data-page="despesas"] .debt-summary-panel .pill {
  color: #fda4af;
  background: rgba(244, 114, 128, 0.11);
  border-color: rgba(244, 114, 128, 0.22);
}

:root[data-theme="dark"] body[data-page="despesas"] .add-income-button {
  color: #fda4af;
  border-color: rgba(244, 114, 128, 0.24);
  background: rgba(244, 114, 128, 0.07);
}

:root[data-theme="dark"] body[data-page="despesas"] .add-income-button:hover {
  background: rgba(244, 114, 128, 0.13);
  border-color: rgba(244, 114, 128, 0.38);
}

/* 3. CARDS DE RECEITA E DESPESA NA VISÃO GERAL E ANÁLISE (Tons suaves correspondentes) */
.metric-card:has([data-metric="net-income"]),
.metric-card:has([data-metric="rental-receivable"]),
.analysis-card:has([data-analysis="rental-receivable"]),
.analysis-card:has([data-analysis="rental-recovered"]),
.panel:has(#income-opportunities) {
  border-color: rgba(16, 185, 129, 0.24);
  background: linear-gradient(155deg, #f2faf5 0%, #eaf5ef 100%);
}

.metric-card:has([data-metric="operating-expenses"]),
.metric-card:has([data-metric="monthly-debt"]),
.metric-card:has([data-metric="debt-total"]),
.metric-card:has([data-metric="rental-payable"]),
.analysis-card:has([data-analysis="debt"]),
.analysis-card:has([data-analysis="debt-total"]),
.analysis-card:has([data-analysis="rental-payable"]),
.panel:has(#money-leaks),
.panel:has(#expenses-chart),
.panel:has(#debt-chart) {
  border-color: rgba(225, 29, 72, 0.20);
  background: linear-gradient(155deg, #fcf3f5 0%, #f7ebee 100%);
}

:root[data-theme="dark"] .metric-card:has([data-metric="net-income"]),
:root[data-theme="dark"] .metric-card:has([data-metric="rental-receivable"]),
:root[data-theme="dark"] .analysis-card:has([data-analysis="rental-receivable"]),
:root[data-theme="dark"] .analysis-card:has([data-analysis="rental-recovered"]),
:root[data-theme="dark"] .panel:has(#income-opportunities) {
  border-color: rgba(52, 211, 153, 0.17);
  background: radial-gradient(ellipse at 92% 0%, rgba(52, 211, 153, 0.055), transparent 60%),
              linear-gradient(165deg, #131a26 0%, #111621 100%);
}

:root[data-theme="dark"] .metric-card:has([data-metric="operating-expenses"]),
:root[data-theme="dark"] .metric-card:has([data-metric="monthly-debt"]),
:root[data-theme="dark"] .metric-card:has([data-metric="debt-total"]),
:root[data-theme="dark"] .metric-card:has([data-metric="rental-payable"]),
:root[data-theme="dark"] .analysis-card:has([data-analysis="debt"]),
:root[data-theme="dark"] .analysis-card:has([data-analysis="debt-total"]),
:root[data-theme="dark"] .analysis-card:has([data-analysis="rental-payable"]),
:root[data-theme="dark"] .panel:has(#money-leaks),
:root[data-theme="dark"] .panel:has(#expenses-chart),
:root[data-theme="dark"] .panel:has(#debt-chart) {
  border-color: rgba(244, 114, 128, 0.17);
  background: radial-gradient(ellipse at 92% 0%, rgba(244, 114, 128, 0.05), transparent 60%),
              linear-gradient(165deg, #151925 0%, #111621 100%);
}

/* ==========================================================================
   METRIC CARDS & ANALYSIS SUMMARY (Fintech Deep Cards with Glow Badges)
   ========================================================================== */
.metric-grid,
.analysis-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.metric-card,
.analysis-card,
.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.2s ease;
  position: relative;
  overflow: hidden;
}

.metric-card,
.analysis-card {
  min-height: 140px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.metric-card:hover,
.analysis-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-elevated);
  border-color: rgba(37, 99, 235, 0.25);
}

:root[data-theme="dark"] .metric-card:hover,
:root[data-theme="dark"] .analysis-card:hover {
  border-color: rgba(255, 255, 255, 0.18);
}

.metric-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.metric-card > strong,
.analysis-card > strong {
  display: block;
  margin: 12px 0 4px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 26px;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

/* Valor em destaque: receita em verde, despesas e dívidas em vermelho. */
.metric-card > strong[data-metric="net-income"] {
  color: var(--green);
}

.metric-card > strong[data-metric="operating-expenses"],
.metric-card > strong[data-metric="monthly-debt"] {
  color: var(--coral);
}

.metric-card > small,
.analysis-card > small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.metric-icon {
  display: inline-grid;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: var(--radius-md);
  color: var(--text);
  background: var(--surface-raised);
  font-size: 15px;
  font-weight: 700;
  transition: transform 0.2s ease;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.15);
}

.metric-card:hover .metric-icon {
  transform: scale(1.08);
}

.metric-icon.green {
  color: #ffffff;
  background: linear-gradient(135deg, var(--green) 0%, #059669 100%);
  box-shadow: 0 4px 12px var(--green-glow);
}

.metric-icon.blue {
  color: #ffffff;
  background: linear-gradient(135deg, var(--blue) 0%, #1d4ed8 100%);
  box-shadow: 0 4px 12px var(--blue-glow);
}

.metric-icon.purple {
  color: #ffffff;
  background: linear-gradient(135deg, var(--purple) 0%, #7c3aed 100%);
  box-shadow: 0 4px 12px var(--purple-glow);
}

.metric-icon.coral {
  color: #ffffff;
  background: linear-gradient(135deg, var(--coral) 0%, #e11d48 100%);
  box-shadow: 0 4px 12px var(--coral-glow);
}

/* Card Destaque: Sobra Líquida com Glow Esmeralda */
.metric-card.featured {
  border-color: rgba(16, 185, 129, 0.35);
  background: radial-gradient(ellipse at 90% 10%, rgba(16, 185, 129, 0.12), transparent 60%),
              linear-gradient(135deg, var(--surface) 0%, rgba(16, 185, 129, 0.04) 100%);
  box-shadow: 0 4px 20px -2px var(--green-glow), var(--shadow);
}

.metric-card.featured::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--green), #34d399);
}

.metric-card.featured > strong {
  color: var(--green);
}

/* Card Destaque: Dívida com Glow Coral */
.metric-card.debt-metric {
  border-color: rgba(244, 63, 94, 0.3);
  background: radial-gradient(ellipse at 90% 10%, rgba(244, 63, 94, 0.1), transparent 60%),
              linear-gradient(135deg, var(--surface) 0%, rgba(244, 63, 94, 0.03) 100%);
}

.metric-card.debt-metric::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--coral), #fb7185);
}

.metric-card.debt-metric > strong {
  color: var(--coral);
}

/* ==========================================================================
   LAYOUT GRID & PANELS
   ========================================================================== */
.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(290px, 0.95fr);
  gap: 20px;
  margin-bottom: 24px;
}

.panel {
  padding: 24px 26px;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.panel-heading h3 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}

.panel-heading p {
  font-size: 12.5px;
  margin-top: 2px;
}

.chart-panel {
  min-height: 330px;
}

.chart-wrap {
  position: relative;
  height: 235px;
  width: 100%;
}

.chart-wrap-donut {
  height: 185px;
}

.debt-chart-panel {
  margin-bottom: 24px;
}

.legend-dot {
  color: var(--blue);
  font-size: 16px;
}

.category-legend {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.category-legend span {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 11.5px;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  transition: background 0.15s ease;
}

.category-legend span:hover {
  background: var(--surface-raised);
}

.category-legend i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--legend-color);
  box-shadow: 0 0 8px var(--legend-color);
}

.category-legend strong {
  margin-left: auto;
  color: var(--text);
  font-size: 11.5px;
  font-family: var(--font-display);
}

.table-panel {
  padding-bottom: 12px;
  margin-bottom: 24px;
}

.table-panel .panel-heading {
  align-items: center;
  margin-bottom: 16px;
}

.text-link {
  color: var(--blue);
  font-size: 12.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s ease;
}

.text-link:hover {
  color: var(--blue-hover);
  transform: translateX(2px);
}

.table-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  border-radius: var(--radius-md);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.table-scroll::-webkit-scrollbar {
  height: 0;
  display: none;
}

.floating-table-scroll {
  position: fixed;
  bottom: 14px;
  z-index: 30;
  height: 18px;
  overflow-x: scroll;
  overflow-y: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.16);
  scrollbar-width: thin;
  scrollbar-color: var(--blue) var(--surface-raised);
}

.floating-table-scroll[hidden] {
  display: none;
}

.floating-table-scroll-inner {
  height: 1px;
}

.floating-table-scroll::-webkit-scrollbar {
  height: 12px;
}

.floating-table-scroll::-webkit-scrollbar-thumb {
  background: var(--blue);
  border-radius: 999px;
}

.panel.table-panel {
  overflow: visible;
}

th.wrap-col,
td.wrap-col {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  min-width: 140px;
  max-width: 280px;
}

th[data-sort] {
  cursor: pointer;
  user-select: none;
}

th[data-sort]::after {
  content: "⇅";
  margin-left: 6px;
  font-size: 10px;
  opacity: 0.4;
}

th[data-sort]:hover,
th[data-sort]:focus-visible {
  color: var(--text);
}

th[data-sort]:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: -2px;
}

th[data-sort][aria-sort="ascending"]::after {
  content: "▲";
  opacity: 1;
  color: var(--blue);
}

th[data-sort][aria-sort="descending"]::after {
  content: "▼";
  opacity: 1;
  color: var(--blue);
}

th.wrap-col-wide,
td.wrap-col-wide {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  width: 34%;
  min-width: 180px;
  max-width: 460px;
}

/* ==========================================================================
   TABLES (Fintech Modern Rows, High Contrast & Clean Hierarchy)
   ========================================================================== */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  text-align: left;
  white-space: nowrap;
}

th {
  padding: 12px 16px;
  color: var(--muted);
  background: var(--surface-subtle);
  border-bottom: 1px solid var(--border);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

th:first-child {
  border-top-left-radius: var(--radius-md);
}

th:last-child {
  border-top-right-radius: var(--radius-md);
}

td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text);
  transition: background-color 0.15s ease;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover td {
  background: var(--surface-raised);
}

.align-right {
  text-align: right;
}

.positive {
  color: var(--green);
  font-weight: 700;
  font-family: var(--font-display);
}

.negative {
  color: var(--coral);
  font-weight: 700;
  font-family: var(--font-display);
}

/* Status Badges com Ponto Luminoso */
.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  color: var(--muted);
  background: var(--surface-raised);
  font-size: 11px;
  font-weight: 700;
  text-transform: capitalize;
  letter-spacing: -0.01em;
}

.status::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status-recebido,
.status-receita {
  color: #059669;
  background: var(--green-subtle);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

:root[data-theme="dark"] .status-recebido,
:root[data-theme="dark"] .status-receita {
  color: var(--green);
  border-color: rgba(52, 211, 153, 0.25);
}

.status-atrasado {
  color: var(--coral);
  background: var(--coral-subtle);
  border: 1px solid rgba(244, 63, 94, 0.2);
}

.status-despesa {
  color: var(--blue);
  background: var(--blue-subtle);
  border: 1px solid rgba(37, 99, 235, 0.2);
}

.empty-state {
  padding: 36px 16px;
  color: var(--muted);
  text-align: center;
  white-space: normal;
  font-size: 13.5px;
}

.table-subtext {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

/* ==========================================================================
   CONSOLIDATED DEBT & PROTECTION SUMMARY PANELS
   ========================================================================== */
.debt-summary-panel {
  background: var(--surface-card);
  border: 1px solid rgba(244, 63, 94, 0.25);
  border-radius: var(--radius-lg);
  padding: 26px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.debt-summary-panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--coral), var(--purple), var(--blue));
}

.debt-summary-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 20px;
}

.debt-summary-header h3 {
  font-size: 19px;
  font-weight: 700;
  margin-top: 6px;
}

.debt-main-badge {
  background: linear-gradient(135deg, rgba(244, 63, 94, 0.08) 0%, rgba(37, 99, 235, 0.08) 100%);
  border: 1px solid rgba(244, 63, 94, 0.25);
  border-radius: var(--radius-md);
  padding: 14px 22px;
  text-align: right;
  min-width: 220px;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.2);
}

.debt-badge-label {
  display: block;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.debt-main-badge strong {
  display: block;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 28px;
  color: var(--coral);
  letter-spacing: -0.03em;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

.debt-metrics-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.debt-metric-card {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  transition: all 0.2s ease;
}

.debt-metric-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.debt-metric-card span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.debt-metric-card strong {
  display: block;
  margin: 6px 0 4px;
  color: var(--text);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

/* Proteção de aluguel: repassado ao proprietário em vermelho, valores a receber/recuperados em verde. */
.debt-metric-card strong[data-rental-summary="paid-to-owners"] {
  color: var(--coral);
}

.debt-metric-card strong[data-rental-summary="reimbursable"],
.debt-metric-card strong[data-rental-summary="recovered"] {
  color: var(--green);
}

.debt-metric-card small {
  display: block;
  color: var(--muted);
  font-size: 10.5px;
}

.debt-metric-card.highlight {
  border-color: rgba(37, 99, 235, 0.35);
  background: var(--blue-subtle);
}

.debt-metric-card.highlight strong {
  color: var(--blue);
}

.debt-progress-wrap {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 18px;
}

.debt-progress-labels {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  margin-bottom: 8px;
}

.debt-progress-labels strong {
  color: var(--blue);
  font-size: 12px;
  font-family: var(--font-display);
}

.ios-progress-bar {
  width: 100%;
  height: 10px;
  border-radius: var(--radius-pill);
  background: rgba(148, 163, 184, 0.2);
  overflow: hidden;
  position: relative;
}

.ios-progress-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--blue) 0%, #06b6d4 50%, var(--green) 100%);
  box-shadow: 0 0 12px var(--blue-glow);
  transition: width 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ==========================================================================
/* ==========================================================================
   FORMS & INPUT FIELDS (Fintech Modern Controls — Destaque Azul Claro / Cinza)
   ========================================================================== */
.content-grid.form-content {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.panel.form-panel,
.form-panel {
  padding: 26px;
  background: linear-gradient(145deg, #e7f0fd 0%, #dde7f5 52%, #e4ecf7 100%);
  border: 1.5px solid rgba(37, 99, 235, 0.28);
  box-shadow: 0 10px 26px -6px rgba(37, 99, 235, 0.11), inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

.panel.form-panel::before,
.form-panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--blue), #60a5fa, var(--indigo));
  opacity: 0.85;
}

.panel.form-panel.loan-registration-panel::before {
  background: linear-gradient(90deg, rgba(190, 18, 60, 0.60), rgba(139, 92, 246, 0.60), rgba(37, 99, 235, 0.60));
}

:root[data-theme="dark"] .panel.form-panel,
:root[data-theme="dark"] .form-panel {
  background: radial-gradient(ellipse at 90% 0%, rgba(91, 141, 239, 0.055), transparent 60%),
              linear-gradient(165deg, #141a28 0%, #111622 100%);
  border-color: rgba(255, 255, 255, 0.09);
  box-shadow: var(--shadow);
}

.form-panel .panel-heading {
  align-items: center;
}

.form-panel .field {
  color: #1e293b;
}

:root[data-theme="dark"] .form-panel .field {
  color: #e2e8f0;
}

.form-panel .field input,
.form-panel .field select,
.form-panel .field textarea {
  background: #ffffff;
  border-color: rgba(37, 99, 235, 0.24);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}

:root[data-theme="dark"] .field input,
:root[data-theme="dark"] .field select,
:root[data-theme="dark"] .field textarea,
:root[data-theme="dark"] .form-panel .field input,
:root[data-theme="dark"] .form-panel .field select,
:root[data-theme="dark"] .form-panel .field textarea,
:root[data-theme="dark"] body[data-page="receitas"] .form-panel .field input,
:root[data-theme="dark"] body[data-page="receitas"] .form-panel .field select,
:root[data-theme="dark"] body[data-page="receitas"] .form-panel .field textarea,
:root[data-theme="dark"] body[data-page="despesas"] .form-panel .field input,
:root[data-theme="dark"] body[data-page="despesas"] .form-panel .field select,
:root[data-theme="dark"] body[data-page="despesas"] .form-panel .field textarea {
  background: #0c1018;
  color: #f8fafc;
  border-color: rgba(255, 255, 255, 0.11);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.35);
}

:root[data-theme="dark"] .field input:hover,
:root[data-theme="dark"] .field select:hover,
:root[data-theme="dark"] .field textarea:hover,
:root[data-theme="dark"] body[data-page="receitas"] .form-panel .field input:hover,
:root[data-theme="dark"] body[data-page="receitas"] .form-panel .field select:hover,
:root[data-theme="dark"] body[data-page="despesas"] .form-panel .field input:hover,
:root[data-theme="dark"] body[data-page="despesas"] .form-panel .field select:hover {
  border-color: rgba(255, 255, 255, 0.22);
  background: #0e131d;
}

:root[data-theme="dark"] .field input:focus,
:root[data-theme="dark"] .field select:focus,
:root[data-theme="dark"] .field textarea:focus,
:root[data-theme="dark"] body[data-page="receitas"] .form-panel .field input:focus,
:root[data-theme="dark"] body[data-page="receitas"] .form-panel .field select:focus,
:root[data-theme="dark"] body[data-page="despesas"] .form-panel .field input:focus,
:root[data-theme="dark"] body[data-page="despesas"] .form-panel .field select:focus {
  background: #0f1522;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(91, 141, 239, 0.22);
}

:root[data-theme="dark"] body[data-page="receitas"] .form-panel .field input:focus,
:root[data-theme="dark"] body[data-page="receitas"] .form-panel .field select:focus {
  border-color: #34d399;
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.18);
}

:root[data-theme="dark"] body[data-page="despesas"] .form-panel .field input:focus,
:root[data-theme="dark"] body[data-page="despesas"] .form-panel .field select:focus {
  border-color: #f47280;
  box-shadow: 0 0 0 3px rgba(244, 114, 128, 0.18);
}

.form-panel .field input[readonly] {
  background: rgba(255, 255, 255, 0.68);
  color: var(--text-secondary);
}

:root[data-theme="dark"] .form-panel .field input[readonly],
:root[data-theme="dark"] body[data-page="receitas"] .form-panel .field input[readonly],
:root[data-theme="dark"] body[data-page="despesas"] .form-panel .field input[readonly] {
  background: rgba(15, 21, 34, 0.72);
  color: #94a3b8;
  border-color: rgba(255, 255, 255, 0.07);
}

.field-hint {
  display: block;
  color: #475569;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.35;
  margin-top: -2px;
}

:root[data-theme="dark"] .field-hint {
  color: #94a3b8;
}

.span-2 {
  grid-column: span 2;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.field {
  display: grid;
  align-content: start;
  min-width: 0;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
}

.field > span:first-child {
  display: inline;
  line-height: 1.35;
}

.required {
  display: inline;
  color: var(--coral);
  font-size: 11px;
  font-weight: 700;
  margin-left: 3px;
  white-space: nowrap;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 44px;
  padding: 0 14px;
  outline: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  background: var(--surface);
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.field input:hover,
.field select:hover {
  border-color: rgba(37, 99, 235, 0.35);
}

.field input:focus,
.field select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px var(--blue-glow);
  background: var(--surface);
}

.field input::placeholder {
  color: var(--muted);
  opacity: 0.8;
}

.field select option,
.field select optgroup {
  color: var(--text);
  background: var(--surface);
  font-size: 13px;
}

.field select optgroup {
  font-weight: 700;
  color: var(--muted);
}

.full {
  grid-column: 1 / -1;
}

.calculation {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
}

.calculation span {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.calculation strong {
  color: var(--text);
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
}

.expense-form-panel {
  margin-bottom: 24px;
}

.expense-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.income-entry-stack {
  display: grid;
  gap: 18px;
}

.additional-income-form {
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.income-entry-heading {
  display: flex;
  grid-column: 1 / -1;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.income-entry-heading strong {
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.remove-income-button {
  padding: 6px 12px;
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--coral);
  background: var(--coral-subtle);
  font-size: 11px;
  font-weight: 700;
  transition: all 0.15s ease;
}

.remove-income-button:hover {
  background: rgba(244, 63, 94, 0.15);
  transform: translateY(-1px);
}

/* Botão de edição nas tabelas de lançamentos */
th[data-actions],
td.row-actions {
  position: sticky;
  right: 0;
  z-index: 1;
  background: var(--surface);
  box-shadow: -10px 0 12px -10px rgba(15, 23, 42, 0.25);
}

th[data-actions] {
  background: var(--surface-subtle);
}

tbody tr:hover td.row-actions {
  background: var(--surface-raised);
}

.table-edit-button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border: 1px solid rgba(37, 99, 235, 0.22);
  border-radius: var(--radius-sm);
  color: var(--blue);
  background: var(--blue-subtle);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.table-edit-button:hover {
  background: rgba(37, 99, 235, 0.16);
  border-color: rgba(37, 99, 235, 0.4);
  transform: translateY(-1px);
}

.row-actions-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.table-delete-button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border: 1px solid rgba(244, 63, 94, 0.22);
  border-radius: var(--radius-sm);
  color: var(--coral);
  background: var(--coral-subtle);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.table-delete-button:hover {
  background: rgba(244, 63, 94, 0.16);
  border-color: rgba(244, 63, 94, 0.4);
  transform: translateY(-1px);
}

.edit-mode-banner {
  display: flex;
  flex-wrap: wrap;
  grid-column: 1 / -1;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid rgba(37, 99, 235, 0.28);
  border-radius: var(--radius-sm);
  background: var(--blue-subtle);
  color: var(--blue);
  font-size: 12px;
  font-weight: 600;
}

.edit-type-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}

.edit-type-field select {
  padding: 5px 9px;
  border: 1px solid rgba(37, 99, 235, 0.3);
  border-radius: var(--radius-sm);
  background: var(--surface-card);
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
}

.edit-cancel-button {
  flex-shrink: 0;
  padding: 6px 12px;
  border: 1px solid rgba(37, 99, 235, 0.3);  border-radius: var(--radius-sm);
  color: var(--blue);
  background: var(--surface);
  font-size: 11px;
  font-weight: 700;
  transition: all 0.15s ease;
}

.edit-cancel-button:hover {
  background: rgba(37, 99, 235, 0.12);
}

form.is-editing {
  border-radius: var(--radius-md);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25);
}

.add-income-button {
  width: 100%;
  margin-top: 16px;
  color: var(--blue);
  border: 1px dashed rgba(37, 99, 235, 0.35);
  background: var(--blue-subtle);
  font-weight: 600;
  min-height: 44px;
}

.add-income-button:hover {
  background: rgba(37, 99, 235, 0.14);
  border-color: var(--blue);
}

/* Bloco Detalhado de Empréstimos e Financiamentos */
.loan-fields {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  padding: 20px;
  border: 1px solid rgba(37, 99, 235, 0.25);
  border-radius: var(--radius-lg);
  background: radial-gradient(ellipse at 90% 10%, rgba(37, 99, 235, 0.06), transparent 50%),
              var(--surface-raised);
}

.loan-fields[hidden] {
  display: none;
}

.loan-fields-heading {
  display: grid;
  gap: 4px;
  margin-bottom: 6px;
}

.loan-fields-heading strong {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.loan-fields-heading small {
  color: var(--muted);
  font-size: 11.5px;
}

.loan-calc-preview {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  padding: 16px 20px;
  border: 1px solid rgba(37, 99, 235, 0.28);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.preview-item {
  display: grid;
  gap: 3px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
}

.loan-recalc-button {
  grid-column: 1 / -1;
  justify-self: end;
  min-height: 34px;
  padding: 0 14px;
  font-size: 12px;
}

.preview-item span {
  font-size: 10.5px;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.preview-item strong {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  color: var(--blue);
}

.installment-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  background: var(--blue-subtle);
  color: var(--blue);
  font-size: 11px;
  font-weight: 700;
}

/* Contas a pagar mês a mês: destaca o mês de referência na projeção. */
.payables-panel tr.is-current-month td {
  background: var(--blue-subtle);
  font-weight: 700;
}

/* Uma única tabela de meses: clique no mês para abrir as contas separadas por tipo. */
.section-heading {
  margin: 8px 0 12px;
  padding: 0;
}

.section-heading h3 {
  font-size: 16px;
  margin: 0 0 2px;
}

.section-heading p {
  font-size: 12.5px;
  margin: 0;
  color: var(--text-secondary);
}

.payables-month {
  cursor: pointer;
}

.payables-month:hover td {
  background: var(--blue-subtle);
}

.payables-month.is-open td {
  border-bottom-color: transparent;
}

.payables-chevron {
  display: inline-block;
  width: 14px;
  color: var(--blue);
  font-weight: 800;
}

.payables-months-table {
  width: 100%;
}

.payables-months-table th {
  white-space: normal;
  vertical-align: bottom;
}

.payables-months-table th:first-child,
.payables-months-table td:first-child {
  min-width: 210px;
}

.payables-months-table th,
.payables-months-table td {
  padding: 8px 10px;
  font-size: 12.5px;
}

.payables-month-detail > td {
  padding: 10px;
  background: var(--surface-raised);
  border: 1px solid rgba(15, 23, 42, 0.16);
  border-top: 0;
  white-space: normal;
}

.payables-panel .debt-main-badge .badge-extra {
  display: block;
  margin-top: 6px;
  color: var(--text-secondary);
  font-size: 11px;
}

.payables-panel .debt-main-badge .badge-extra strong {
  color: var(--text);
}

/* Cartões de crédito */
.payables-group--card h4 {
  color: #b45309;
}

:root[data-theme="dark"] .payables-group--card h4 {
  color: #fbbf24;
}

:root[data-theme="dark"] .payables-month-detail > td {
  border-color: rgba(226, 232, 240, 0.22);
}

.payables-groups {
  display: grid;
  gap: 14px;
  padding-top: 6px;
}

.payables-group h4 {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 6px;
  padding-bottom: 4px;
  border-bottom: 1px dashed var(--border);
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.payables-group h4 span {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.payables-group ul {
  list-style: none;
  display: grid;
  gap: 5px;
  margin: 0;
  padding: 0;
}

.payables-group li {
  display: grid;
  grid-template-columns: 100px minmax(0, 1fr) 140px 105px auto;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-card);
  font-size: 12.5px;
  white-space: normal;
}

.payables-due {
  display: grid;
  gap: 2px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}

.payables-name {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.payables-name small {
  color: var(--text-secondary);
  font-size: 11px;
}

.payables-kind {
  display: grid;
  gap: 4px;
  color: var(--text-secondary);
  font-size: 11.5px;
}

.payables-progress {
  position: relative;
  display: block;
  height: 5px;
  border-radius: 999px;
  background: rgba(100, 116, 139, 0.28);
  overflow: hidden;
  box-shadow: inset 0 1px 1px rgba(15, 23, 42, 0.08);
}

.payables-progress-fill {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #2563eb, #22c55e);
  transition: width 0.3s ease;
}

.payables-group--debt .payables-progress-fill {
  background: linear-gradient(90deg, #7c3aed, #22c55e);
}

.payables-progress-label {
  font-size: 10px;
  line-height: 1.2;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.payables-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.payables-row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
}

.late-chip {
  display: inline-block;
  margin-left: 4px;
  padding: 0 5px;
  border-radius: 999px;
  background: rgba(220, 38, 38, 0.12);
  color: #b91c1c;
  font-size: 9.5px;
  font-style: normal;
  font-weight: 800;
  text-transform: uppercase;
}

.payables-empty {
  margin: 6px 0 0;
  color: var(--text-secondary);
  font-size: 12.5px;
}

/* Filtros em pílulas */
.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 14px;
}

/* Pesquisa nas tabelas de receitas e despesas */
.table-search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 12px);
  background: var(--surface-raised);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.table-search:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-subtle);
}

.table-search-icon {
  font-size: 13px;
  line-height: 1;
  opacity: 0.65;
}

.table-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  outline: none;
}

.table-search input::placeholder {
  color: var(--muted);
}

.table-search input::-webkit-search-cancel-button {
  display: none;
}

.table-search-clear {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
}

.table-search-clear:hover {
  color: var(--coral);
}

.table-search small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

/* Em telas estreitas o contador só aparece quando há pesquisa em andamento. */
@media (max-width: 420px) {
  .table-search:not(:has(input[data-searching="1"])) small {
    display: none;
  }
}

.filter-chip {
  padding: 6px 13px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-card);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s ease;
}

.filter-chip:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.filter-chip.is-active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

/* Tipo do lançamento na tabela recolhida */
.type-chip {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  vertical-align: middle;
  background: rgba(100, 116, 139, 0.14);
  color: var(--text-secondary);
}

.type-chip--parcelada {
  background: rgba(37, 99, 235, 0.13);
  color: #1d4ed8;
}

.type-chip--emprestimo {
  background: rgba(124, 58, 237, 0.14);
  color: #6d28d9;
}

.type-chip--fixa {
  background: rgba(15, 118, 110, 0.14);
  color: #0f766e;
}

.type-chip--variavel {
  background: rgba(217, 119, 6, 0.16);
  color: #b45309;
}

/* Registro completo recolhido */
.registry-details {
  margin-top: 10px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}

.registry-details > summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  cursor: pointer;
  list-style: none;
  color: var(--blue);
  font-size: 13.5px;
  font-weight: 700;
}

.registry-details > summary::-webkit-details-marker {
  display: none;
}

.registry-details > summary::before {
  content: "▸";
}

.registry-details[open] > summary::before {
  content: "▾";
}

.registry-details > summary small {
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 500;
}

.registry-details[open] > summary {
  margin-bottom: 12px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 720px) {
  .payables-group li {
    grid-template-columns: 1fr auto;
    gap: 4px 10px;
  }

  .payables-kind,
  .payables-row-actions {
    grid-column: 1 / -1;
  }

  .payables-value {
    text-align: right;
  }

  .payables-row-actions {
    justify-content: flex-start;
  }
}

:root[data-theme="dark"] .type-chip--parcelada { color: #93c5fd; }
:root[data-theme="dark"] .type-chip--emprestimo { color: #c4b5fd; }
:root[data-theme="dark"] .type-chip--fixa { color: #5eead4; }
:root[data-theme="dark"] .type-chip--variavel { color: #fcd34d; }
:root[data-theme="dark"] .late-chip { color: #fca5a5; }

/* Empréstimo, dívida ou parcelamento: os campos fora da opção escolhida ficam ocultos. */
[data-debt-field][hidden],
.field[hidden],
.loan-calc-preview[hidden] {
  display: none !important;
}

.payables-panel .debt-main-badge small {
  display: block;
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--text-secondary);
}

/* ==========================================================================
   ANALYSIS & AI RECOMMENDATIONS
   ========================================================================== */
.analysis-summary {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

/* Resumo de receitas: quatro cartões na mesma linha em telas largas */
.income-summary-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

@media (max-width: 1180px) {
  .income-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .income-summary-grid {
    grid-template-columns: 1fr;
  }
}

.risk-label.risk-high {
  color: var(--coral);
  font-weight: 700;
}

.risk-label.risk-mid {
  color: var(--orange);
  font-weight: 700;
}

.risk-label.risk-low {
  color: var(--green);
  font-weight: 700;
}

.insight-content {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.65;
}

.insight-content p {
  margin: 12px 0 0;
}

.insight-highlight {
  padding: 14px 18px;
  border: 1px solid rgba(37, 99, 235, 0.25);
  border-radius: var(--radius-md);
  color: var(--text);
  background: var(--blue-subtle);
  margin-top: 12px;
}

.insight-highlight strong {
  color: var(--blue);
  font-weight: 700;
}

.snowball-timeline {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.snowball-timeline span {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
}

.snowball-timeline small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.snowball-timeline strong {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}

.suggestion-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.suggestion-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.suggestion-list li small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.suggestion-list li strong {
  color: var(--coral);
  font-family: var(--font-display);
  font-weight: 700;
}

/* Composição das saídas: fatia de cada categoria no total gasto */
.expense-mix {
  display: grid;
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.expense-mix li {
  display: grid;
  gap: 6px;
}

.expense-mix-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.expense-mix-head strong {
  color: var(--text);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.expense-mix-head span {
  color: var(--coral);
  font-family: var(--font-display);
  font-weight: 700;
  white-space: nowrap;
}

.expense-mix-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-raised);
  overflow: hidden;
}

.expense-mix-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--coral), #fb7185);
}

.expense-mix small {
  color: #5c6b7f;
  line-height: 1.45;
}

:root[data-theme="dark"] .expense-mix small {
  color: #aab8cc;
}

/* Dívidas registradas e comprometimento mês a mês na Análise */
.debt-registry,
.debt-schedule {
  display: grid;
  gap: 12px;
  margin: 0 0 16px;
}

.debt-schedule {
  margin-top: 18px;
}

.debt-registry-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.debt-registry-head strong {
  color: var(--text);
  font-family: var(--font-display);
  font-weight: 700;
}

.debt-registry-head span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.debt-schedule .snowball-timeline small:last-child {
  text-transform: none;
  letter-spacing: 0;
  font-size: 10.5px;
  font-weight: 500;
  line-height: 1.45;
}

.ai-panel {
  margin-top: 24px;
  border: 1px solid rgba(139, 92, 246, 0.25);
  background: radial-gradient(ellipse at 90% 10%, rgba(139, 92, 246, 0.08), transparent 60%),
              var(--surface);
  position: relative;
  overflow: hidden;
}

.ai-panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--purple), var(--blue), #06b6d4);
}

.ai-panel > .button {
  margin-bottom: 14px;
}

.ai-result {
  margin-top: 16px;
}

.ai-result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 14px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

/* Ação principal do aplicativo: gerar o plano de ação. */
.cta-panel {
  border: 1px solid rgba(37, 99, 235, 0.32);
  background:
    radial-gradient(ellipse at 88% 0%, rgba(139, 92, 246, 0.16), transparent 62%),
    linear-gradient(160deg, #eff6ff 0%, #f5f3ff 100%);
  box-shadow: 0 18px 38px -20px rgba(37, 99, 235, 0.45);
}

.cta-panel .panel-heading h3 {
  font-size: 19px;
}

.cta-eyebrow {
  display: inline-block;
  margin-bottom: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.12);
  color: var(--blue);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1px;
}

.button.cta-button {
  position: relative;
  overflow: hidden;
  width: 100%;
  min-height: 56px;
  margin-top: 4px;
  border-radius: 14px;
  font-size: clamp(15px, 2.4vw, 16.5px);
  font-weight: 800;
  letter-spacing: 0.01em;
  box-shadow: 0 12px 28px -8px rgba(37, 99, 235, 0.65), inset 0 1px 1px rgba(255, 255, 255, 0.35);
}

/* Reflexo branco: uma passada completa a cada intervalo aleatório de 8s a 15s (agendado no JS). */
.button.cta-button::after {
  content: "";
  position: absolute;
  top: -30%;
  bottom: -30%;
  left: 0;
  width: 34%;
  pointer-events: none;
  background: linear-gradient(100deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.65) 50%, rgba(255, 255, 255, 0) 100%);
  filter: blur(10px);
  transform: translateX(-170%) skewX(-18deg);
}

/* "!important" para o reflexo não virar pisca-pisca quando o sistema pede menos animações. */
.button.cta-button.is-reflecting::after {
  animation: cta-reflex 3s linear !important;
}

/* Percorre o botão inteiro: começa e termina fora da área visível. */
@keyframes cta-reflex {
  0% { transform: translateX(-170%) skewX(-18deg); }
  100% { transform: translateX(330%) skewX(-18deg); }
}

.button.cta-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 34px -8px rgba(37, 99, 235, 0.75), inset 0 1px 1px rgba(255, 255, 255, 0.4);
}

.ai-formatted-body {
  font-size: 14px;
  line-height: 1.75;
  color: var(--text);
}

.ai-heading {
  font-family: var(--font-display);
  color: var(--text);
  margin-top: 26px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.ai-h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--blue);
  letter-spacing: -0.02em;
}

.ai-h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.015em;
}

.ai-h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.ai-p {
  margin: 12px 0;
  line-height: 1.7;
  color: var(--text-secondary);
}

.ai-formatted-body strong,
.ai-p strong,
.ai-list strong,
.ai-ordered-list strong,
.ai-callout strong {
  color: var(--text);
  font-weight: 700;
}

.ai-formatted-body em,
.ai-p em,
.ai-list em,
.ai-ordered-list em,
.ai-callout em {
  color: var(--blue);
  font-style: italic;
}

.ai-callout {
  margin: 18px 0;
  padding: 16px 20px;
  border-left: 4px solid var(--blue);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  background: var(--blue-subtle);
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.65;
}

.ai-callout strong {
  color: var(--blue);
}

.ai-formatted-body .ai-negative,
.ai-formatted-body .ai-negative strong,
.ai-formatted-body .ai-negative em {
  color: var(--coral);
}

.ai-formatted-body blockquote.ai-negative {
  border-left-color: var(--coral);
  background: var(--coral-subtle);
}

.ai-formatted-body blockquote.ai-negative strong {
  color: var(--coral);
}

.ai-list,
.ai-ordered-list {
  margin: 14px 0 18px 22px;
  padding: 0;
  display: grid;
  gap: 10px;
  color: var(--text-secondary);
}

.ai-list li,
.ai-ordered-list li {
  line-height: 1.65;
}

.ai-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  background: var(--blue-subtle);
  color: var(--blue);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.analysis-model {
  color: var(--blue);
  font-size: 11px;
  font-weight: 700;
}

.openai-settings-form {
  margin: 0 0 20px;
}

.settings-status {
  padding: 13px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  background: var(--surface-raised);
  font-size: 12.5px;
  line-height: 1.55;
}

.refresh-models-button {
  align-self: end;
}

.field-hint {
  margin: -2px 0 0;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.55;
  font-weight: 400;
}

.field-hint code {
  color: var(--blue);
  background: var(--blue-subtle);
  padding: 2px 6px;
  border-radius: 4px;
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.ai-divider {
  height: 1px;
  margin: 12px 0 22px;
  background: var(--border);
}

.error-message {
  color: var(--coral);
  border-color: rgba(244, 63, 94, 0.35);
  background: var(--coral-subtle);
}

.result-box {
  display: grid;
  gap: 6px;
  min-height: 64px;
  margin-top: 18px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  background: var(--surface-raised);
  font-size: 12.5px;
  line-height: 1.6;
}

.result-box strong {
  color: var(--blue);
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
}

.export-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.export-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

/* ==========================================================================
   TOASTS (Slide & Spring Notification Region)
   ========================================================================== */
/* Aviso discreto no topo da página, sem cobrir o conteúdo. */
.toast-region {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1400;
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 14px 16px 0;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(620px, 100%);
  padding: 10px 10px 10px 16px;
  border: 1px solid rgba(37, 99, 235, 0.32);
  border-left: 4px solid var(--blue);
  border-radius: 12px;
  color: var(--text);
  text-align: left;
  background: #ffffff;
  box-shadow: 0 16px 34px -18px rgba(15, 23, 42, 0.42), 0 2px 6px -2px rgba(15, 23, 42, 0.08);
  /* Entra rápido e sai devagar. */
  animation: toastSlideDown 0.12s ease-out;
}

@keyframes toastSlideDown {
  from { opacity: 0.4; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.toast-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  color: #ffffff;
  background: var(--blue);
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
}

.toast-text {
  flex: 1 1 auto;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text);
  pointer-events: none;
}

.toast-close {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.06);
  color: var(--muted);
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.toast-close:hover,
.toast-close:focus-visible {
  color: var(--text);
  background: rgba(15, 23, 42, 0.12);
}

/* Receita: tom verde. */
.toast-income {
  border-color: rgba(16, 185, 129, 0.38);
  border-left-color: #10b981;
  background: linear-gradient(100deg, #f0fdf6 0%, #ffffff 60%);
}

.toast-income .toast-icon {
  background: linear-gradient(145deg, #34d399 0%, #059669 100%);
}

/* Despesa (e erros): tom avermelhado. */
.toast-expense,
.toast-error {
  border-color: rgba(244, 63, 94, 0.35);
  border-left-color: var(--coral);
  background: linear-gradient(100deg, #fff4f6 0%, #ffffff 60%);
}

.toast-expense .toast-icon,
.toast-error .toast-icon {
  background: linear-gradient(145deg, #fb7185 0%, #e11d48 100%);
}

.toast-out {
  animation: toastFadeOut 1.1s ease-out forwards;
}

@keyframes toastFadeOut {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-6px); }
}

/* ==========================================================================
   RELATÓRIO DE CONFERÊNCIA OVERLAY
   ========================================================================== */
.report-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
  background: rgba(9, 13, 22, 0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: overlayFadeIn 0.2s ease-out;
}

.report-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-elevated);
  border: 1px solid var(--border);
}

.report-toolbar strong {
  font-size: 15px;
  font-weight: 700;
}

.report-toolbar > div {
  display: flex;
  gap: 10px;
}

.report-frame {
  flex: 1;
  width: 100%;
  border: 0;
  border-radius: var(--radius-md);
  background: #ffffff;
  box-shadow: var(--shadow-elevated);
}

/* ==========================================================================
   AI BUSY INDICATOR (Floating Pill with Pulsing Glow)
   ========================================================================== */
.ai-busy-indicator {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 1100;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: min(92vw, 480px);
  padding: 12px 22px;
  border: 1px solid rgba(139, 92, 246, 0.35);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.25), 0 0 20px var(--purple-glow);
  animation: pulseIndicator 2s infinite ease-in-out;
}

@keyframes pulseIndicator {
  0%, 100% { box-shadow: 0 14px 36px rgba(0, 0, 0, 0.25), 0 0 16px var(--purple-glow); }
  50% { box-shadow: 0 16px 42px rgba(0, 0, 0, 0.35), 0 0 28px var(--purple-glow); }
}

.ai-spinner {
  flex: none;
  width: 18px;
  height: 18px;
  border: 2.5px solid var(--border);
  border-top-color: var(--purple);
  border-radius: 50%;
  animation: ai-spin 0.8s linear infinite;
}

@keyframes ai-spin {
  to { transform: rotate(360deg); }
}

/* ==========================================================================
   RESPONSIVE DESIGN (iPad / Tablets / Mobile Screens)
   ========================================================================== */
@media (max-width: 1180px) {
  .sidebar {
    width: 225px;
  }
  .main-content {
    width: calc(100% - 225px);
    margin-left: 225px;
    padding-right: 28px;
    padding-left: 28px;
  }
  .metric-grid {
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  }
  .debt-metrics-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .content-grid {
    grid-template-columns: 1fr;
  }
  .analysis-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  html, body {
    overflow-x: hidden;
    max-width: 100vw;
  }

  /* Barra de Navegação Nativa Mobile (Frosted Glass Tab Bar) */
  .sidebar {
    position: fixed;
    inset: auto 0 0;
    display: block;
    width: 100%;
    height: calc(64px + env(safe-area-inset-bottom));
    padding: 6px 8px env(safe-area-inset-bottom);
    border: 0;
    border-top: 1px solid var(--border);
    background: var(--sidebar);
    backdrop-filter: blur(28px) saturate(190%);
    -webkit-backdrop-filter: blur(28px) saturate(190%);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.06);
    z-index: 100;
  }

  .brand,
  .sidebar-bottom {
    display: none;
  }

  .nav-links {
    display: flex;
    width: 100%;
    height: 100%;
    align-items: stretch;
    justify-content: space-around;
    gap: 2px;
  }

  .nav-links a {
    display: flex;
    flex: 1 1 0;
    min-width: 0;
    min-height: 52px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 2px;
    border-radius: var(--radius-sm);
    font-size: 16px;
    color: var(--muted);
  }

  .nav-links a span {
    max-width: 100%;
    font-size: 10px;
    line-height: 1.15;
    text-align: center;
    font-weight: 700;
    letter-spacing: -0.2px;
    white-space: nowrap;
  }

  .nav-links a:hover {
    background: transparent;
    transform: none;
  }

  .nav-links a.active {
    color: var(--blue);
    background: transparent;
    box-shadow: none;
    font-weight: 700;
  }

  .nav-links a.active span {
    color: var(--blue);
  }

  .main-content {
    width: 100%;
    max-width: 100%;
    margin-left: 0;
    padding: 20px 16px calc(86px + env(safe-area-inset-bottom));
    overflow-x: hidden;
  }

  .topbar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    margin-bottom: 20px;
  }

  .topbar > div:first-child {
    display: flex;
    flex-direction: column;
    gap: 2px;
  }

  .eyebrow {
    font-size: 11px;
    letter-spacing: 1px;
  }

  h1 {
    font-size: 26px;
    line-height: 1.2;
  }

  .top-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    width: 100%;
  }

  .top-actions .button {
    flex: 1 1 calc(50% - 6px);
    min-height: 40px;
    padding: 0 12px;
    font-size: 12px;
    font-weight: 600;
    border-radius: var(--radius-pill);
    justify-content: center;
    text-align: center;
  }

  .top-actions .icon-button {
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
  }

  .content-grid,
  .content-grid > *,
  .panel,
  .chart-wrap,
  .table-scroll,
  .form-grid {
    min-width: 0;
    max-width: 100%;
  }

  .panel {
    padding: 20px 16px;
    border-radius: var(--radius-md);
  }

  .welcome-panel {
    min-height: auto;
    align-items: flex-start;
    padding: 20px 18px;
    flex-direction: column;
    border-radius: var(--radius-md);
    margin-bottom: 18px;
    gap: 14px;
  }

  .welcome-panel h2 {
    font-size: 20px;
  }

  .welcome-panel > .button {
    align-self: stretch;
    text-align: center;
    justify-content: center;
    min-height: 42px;
  }

  .metric-card {
    padding: 16px;
    border-radius: var(--radius-md);
  }

  .metric-card strong {
    font-size: 24px;
  }

  .debt-summary-header {
    flex-direction: column;
  }

  .debt-main-badge {
    width: 100%;
    text-align: left;
  }

  .debt-metrics-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .loan-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .expense-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .content-grid.form-content {
    grid-template-columns: 1fr;
  }

  .loan-calc-preview {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .chart-panel {
    min-height: 290px;
  }

  .chart-wrap {
    height: 210px;
  }

  .chart-wrap-donut {
    height: 165px;
  }

  .toast-region {
    inset: 0 0 auto;
    padding: 10px 12px 0;
  }

  .toast {
    width: 100%;
    gap: 10px;
    padding: 9px 8px 9px 13px;
  }

  .toast-text {
    font-size: 13px;
  }

  .ai-busy-indicator {
    bottom: calc(78px + env(safe-area-inset-bottom));
  }

  .report-overlay {
    padding: 10px;
  }

  .report-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (max-width: 480px) {
  .metric-grid {
    grid-template-columns: 1fr;
  }
  .debt-metrics-row {
    grid-template-columns: 1fr;
  }
  .analysis-summary {
    grid-template-columns: 1fr;
  }
  .form-grid,
  .expense-grid,
  .loan-fields {
    grid-template-columns: 1fr;
  }
  .field,
  .full,
  .span-2,
  .loan-fields {
    grid-column: 1;
  }
  .field input,
  .field select {
    min-height: 46px;
    font-size: 16px;
  }
  .button {
    min-height: 44px;
    font-size: 13px;
  }
  .loan-calc-preview {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .calculation {
    flex-direction: column;
  }
  .export-panel {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* Card de Investimentos e Reserva para Sanar Dívidas na página de Despesas (tom verde suave de ativo/receita) */
body[data-page="despesas"] #investment-debt-panel {
  background: linear-gradient(180deg, #f3faf6 0%, #edf7f1 100%);
  border-color: #cce5d5;
  box-shadow: 0 6px 20px rgba(22, 101, 52, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

body[data-page="despesas"] #investment-debt-panel > .panel-head {
  background: linear-gradient(135deg, #e0f2e7 0%, #d3ecdd 100%);
  border-bottom: 1px solid #b5dec4;
}

body[data-page="despesas"] #investment-debt-panel > .panel-head h3 {
  color: #14532d;
}

body[data-page="despesas"] #investment-debt-panel > .panel-head p {
  color: #166534;
}

body[data-page="despesas"] #investment-debt-panel .calculation {
  background: linear-gradient(135deg, #e6f5ec 0%, #dbf0e3 100%);
  border-color: #b5dec4;
}

/* Rodapé de todas as páginas */
.app-footer {
  margin-top: 28px;
  padding: 18px 16px 8px;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

/* ==========================================================================
   DARK MODE PREMIUM OVERRIDES — PADRÃO STRIPE & APPLE PRO
   Superfícies coesas, alto contraste tipográfico, badges translúcidos e zero cores berrantes
   ========================================================================== */

/* 1. Navegação Lateral & Botões no Modo Escuro */
:root[data-theme="dark"] .sidebar {
  background: rgba(11, 15, 23, 0.92);
  border-right-color: rgba(255, 255, 255, 0.07);
  box-shadow: 8px 0 32px rgba(0, 0, 0, 0.45);
}

:root[data-theme="dark"] .brand-mark {
  background: linear-gradient(145deg, #3b82f6 0%, #2563eb 55%, #4f46e5 100%);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

:root[data-theme="dark"] .nav-links a {
  color: #94a3b8;
}

:root[data-theme="dark"] .nav-links a:hover {
  color: #f8fafc;
  background: rgba(255, 255, 255, 0.05);
}

:root[data-theme="dark"] .nav-links a.active {
  color: #ffffff;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.22) 0%, rgba(37, 99, 235, 0.14) 100%);
  border: 1px solid rgba(91, 141, 239, 0.34);
  box-shadow: 0 4px 16px -4px rgba(37, 99, 235, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

:root[data-theme="dark"] .nav-links a.active span {
  color: #f8fafc;
}

:root[data-theme="dark"] .avatar {
  background: linear-gradient(135deg, rgba(52, 211, 153, 0.22) 0%, rgba(16, 185, 129, 0.14) 100%);
  color: #6ee7b7;
  border: 1px solid rgba(52, 211, 153, 0.35);
  box-shadow: none;
}

:root[data-theme="dark"] .button {
  background: #161d2b;
  border-color: rgba(255, 255, 255, 0.10);
  color: #e2e8f0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

:root[data-theme="dark"] .button:hover {
  background: #1d2638;
  border-color: rgba(255, 255, 255, 0.18);
  color: #ffffff;
}

:root[data-theme="dark"] .button-primary {
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
  border-color: rgba(255, 255, 255, 0.16);
  color: #ffffff !important;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

:root[data-theme="dark"] .button-primary:hover {
  background: linear-gradient(180deg, #4f8ff7 0%, #2f6ef0 100%);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.32);
}

:root[data-theme="dark"] .button-quiet {
  color: #93c5fd;
  background: rgba(59, 130, 246, 0.10);
  border-color: rgba(91, 141, 239, 0.24);
}

:root[data-theme="dark"] .button-quiet:hover {
  color: #bfdbfe;
  background: rgba(59, 130, 246, 0.16);
  border-color: rgba(91, 141, 239, 0.38);
}

:root[data-theme="dark"] .button-danger {
  color: #fda4af;
  background: rgba(244, 114, 128, 0.10);
  border-color: rgba(244, 114, 128, 0.24);
}

:root[data-theme="dark"] .button-danger:hover {
  color: #ffe4e6;
  background: rgba(244, 114, 128, 0.18);
  border-color: rgba(244, 114, 128, 0.40);
}

:root[data-theme="dark"] .icon-button,
:root[data-theme="dark"] .reference-month {
  background: #141b28;
  border-color: rgba(255, 255, 255, 0.10);
  color: #cbd5e1;
}

/* 2. Ícones de Métricas Estilo Apple Pro (Vidro Translúcido em vez de Blocos Neon) */
:root[data-theme="dark"] .metric-icon {
  background: #1a2233;
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

:root[data-theme="dark"] .metric-icon.green {
  color: #6ee7b7;
  background: rgba(52, 211, 153, 0.12);
  border: 1px solid rgba(52, 211, 153, 0.26);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

:root[data-theme="dark"] .metric-icon.blue {
  color: #93c5fd;
  background: rgba(91, 141, 239, 0.13);
  border: 1px solid rgba(91, 141, 239, 0.28);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

:root[data-theme="dark"] .metric-icon.purple {
  color: #c4b5fd;
  background: rgba(167, 139, 250, 0.13);
  border: 1px solid rgba(167, 139, 250, 0.28);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

:root[data-theme="dark"] .metric-icon.coral {
  color: #fda4af;
  background: rgba(244, 114, 128, 0.12);
  border: 1px solid rgba(244, 114, 128, 0.26);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

/* 3. Cards de Métricas, Destaques e Resumos de Dívida/Investimento no Modo Escuro */
:root[data-theme="dark"] .metric-card,
:root[data-theme="dark"] .analysis-card,
:root[data-theme="dark"] .panel {
  background: linear-gradient(180deg, #141a27 0%, #111622 100%);
  border-color: rgba(255, 255, 255, 0.085);
}

:root[data-theme="dark"] .metric-heading {
  color: #94a3b8;
}

:root[data-theme="dark"] .metric-card > small,
:root[data-theme="dark"] .analysis-card > small {
  color: #8b9bb4;
}

:root[data-theme="dark"] .metric-card.featured {
  border-color: rgba(52, 211, 153, 0.24);
  background: radial-gradient(ellipse at 90% 0%, rgba(52, 211, 153, 0.08), transparent 60%),
              linear-gradient(180deg, #131b26 0%, #111621 100%);
  box-shadow: var(--shadow);
}

:root[data-theme="dark"] .metric-card.featured > strong {
  color: #34d399;
}

:root[data-theme="dark"] .metric-card.debt-metric {
  border-color: rgba(244, 114, 128, 0.22);
  background: radial-gradient(ellipse at 90% 0%, rgba(244, 114, 128, 0.07), transparent 60%),
              linear-gradient(180deg, #161925 0%, #111621 100%);
}

:root[data-theme="dark"] .metric-card.debt-metric > strong {
  color: #f47280;
}

:root[data-theme="dark"] .debt-summary-panel {
  background: linear-gradient(180deg, #141a27 0%, #111622 100%);
  border-color: rgba(255, 255, 255, 0.09);
}

:root[data-theme="dark"] .debt-main-badge {
  background: rgba(244, 114, 128, 0.07);
  border-color: rgba(244, 114, 128, 0.22);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

:root[data-theme="dark"] .debt-main-badge strong {
  color: #fb7185;
}

:root[data-theme="dark"] .debt-metric-card,
:root[data-theme="dark"] .debt-progress-wrap,
:root[data-theme="dark"] .calculation,
:root[data-theme="dark"] .snowball-timeline span,
:root[data-theme="dark"] .result-box,
:root[data-theme="dark"] .settings-status {
  background: #0e131e;
  border-color: rgba(255, 255, 255, 0.075);
}

:root[data-theme="dark"] .debt-metric-card span {
  color: #94a3b8;
}

:root[data-theme="dark"] .debt-metric-card small {
  color: #7c8ba1;
}

:root[data-theme="dark"] .debt-metric-card.highlight {
  background: rgba(91, 141, 239, 0.09);
  border-color: rgba(91, 141, 239, 0.26);
}

:root[data-theme="dark"] .debt-metric-card.highlight strong {
  color: #93c5fd;
}

:root[data-theme="dark"] .loan-calc-preview {
  background: #0d121c;
  border-color: rgba(91, 141, 239, 0.22);
}

:root[data-theme="dark"] .preview-item {
  background: #141b29;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

:root[data-theme="dark"] .preview-item strong {
  color: #93c5fd;
}

:root[data-theme="dark"] .insight-highlight {
  background: rgba(91, 141, 239, 0.09);
  border-color: rgba(91, 141, 239, 0.24);
  color: #e2e8f0;
}

:root[data-theme="dark"] .insight-highlight strong {
  color: #93c5fd;
}

/* 4. Card de Investimentos na Aba Despesas no Modo Escuro (Corrige fundo claro com letra clara) */
:root[data-theme="dark"] body[data-page="despesas"] #investment-debt-panel {
  background: radial-gradient(ellipse at 92% 0%, rgba(52, 211, 153, 0.06), transparent 58%),
              linear-gradient(165deg, #131b26 0%, #111621 100%);
  border-color: rgba(52, 211, 153, 0.20);
  box-shadow: var(--shadow);
}

:root[data-theme="dark"] body[data-page="despesas"] #investment-debt-panel > .panel-head {
  background: rgba(52, 211, 153, 0.07);
  border-bottom: 1px solid rgba(52, 211, 153, 0.16);
}

:root[data-theme="dark"] body[data-page="despesas"] #investment-debt-panel > .panel-head h3 {
  color: #f8fafc;
}

:root[data-theme="dark"] body[data-page="despesas"] #investment-debt-panel > .panel-head p {
  color: #a7f3d0;
}

:root[data-theme="dark"] body[data-page="despesas"] #investment-debt-panel .calculation {
  background: #0d131d;
  border-color: rgba(52, 211, 153, 0.20);
}

:root[data-theme="dark"] body[data-page="despesas"] #investment-debt-panel .debt-main-badge {
  background: rgba(52, 211, 153, 0.08);
  border-color: rgba(52, 211, 153, 0.22);
}

:root[data-theme="dark"] body[data-page="despesas"] #investment-debt-panel .debt-main-badge strong {
  color: #34d399;
}

/* 5. Painel CTA e Diagnóstico Executivo na Aba Análise no Modo Escuro (Corrige fundo branco-lavanda) */
:root[data-theme="dark"] .cta-panel {
  border-color: rgba(99, 102, 241, 0.28);
  background: radial-gradient(ellipse at 88% 0%, rgba(99, 102, 241, 0.14), transparent 60%),
              linear-gradient(165deg, #151c2e 0%, #111623 100%);
  box-shadow: var(--shadow);
}

:root[data-theme="dark"] .cta-eyebrow {
  background: rgba(91, 141, 239, 0.14);
  color: #93c5fd;
  border: 1px solid rgba(91, 141, 239, 0.26);
}

:root[data-theme="dark"] .ai-panel {
  border-color: rgba(167, 139, 250, 0.22);
  background: radial-gradient(ellipse at 90% 0%, rgba(167, 139, 250, 0.07), transparent 60%),
              linear-gradient(180deg, #141a27 0%, #111622 100%);
}

:root[data-theme="dark"] .ai-callout {
  background: rgba(91, 141, 239, 0.09);
  border-left-color: #5b8def;
  color: #e2e8f0;
}

:root[data-theme="dark"] .ai-callout strong {
  color: #93c5fd;
}

:root[data-theme="dark"] .ai-formatted-body blockquote.ai-negative {
  background: rgba(244, 114, 128, 0.09);
  border-left-color: #f47280;
}

/* 6. Tabelas, Cabeçalhos e Coluna Fixa de Ações no Modo Escuro */
:root[data-theme="dark"] th {
  background: #0d121c;
  color: #94a3b8;
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

:root[data-theme="dark"] td {
  color: #e2e8f0;
  border-bottom-color: rgba(255, 255, 255, 0.06);
}

:root[data-theme="dark"] td strong {
  color: #f8fafc;
}

:root[data-theme="dark"] .table-subtext {
  color: #8b9bb4;
}

:root[data-theme="dark"] tbody tr:hover td {
  background: #182030;
}

:root[data-theme="dark"] th[data-actions] {
  background: #0d121c;
}

:root[data-theme="dark"] td.row-actions {
  background: #121722;
  box-shadow: -12px 0 16px -10px rgba(0, 0, 0, 0.65);
}

:root[data-theme="dark"] tbody tr:hover td.row-actions {
  background: #182030;
}

:root[data-theme="dark"] .table-edit-button {
  color: #93c5fd;
  background: rgba(91, 141, 239, 0.11);
  border-color: rgba(91, 141, 239, 0.25);
}

:root[data-theme="dark"] .table-edit-button:hover {
  color: #ffffff;
  background: rgba(91, 141, 239, 0.22);
  border-color: rgba(91, 141, 239, 0.42);
}

:root[data-theme="dark"] .table-delete-button {
  color: #fda4af;
  background: rgba(244, 114, 128, 0.11);
  border-color: rgba(244, 114, 128, 0.25);
}

:root[data-theme="dark"] .table-delete-button:hover {
  color: #ffffff;
  background: rgba(244, 114, 128, 0.22);
  border-color: rgba(244, 114, 128, 0.42);
}

:root[data-theme="dark"] .installment-badge {
  color: #93c5fd;
  background: rgba(91, 141, 239, 0.12);
  border: 1px solid rgba(91, 141, 239, 0.22);
}

/* 7. Notificações Toast no Modo Escuro (Corrige texto branco em fundo branco) */
:root[data-theme="dark"] .toast {
  background: #161e2e;
  border-color: rgba(91, 141, 239, 0.32);
  border-left-color: #5b8def;
  color: #f8fafc;
  box-shadow: 0 18px 38px -10px rgba(0, 0, 0, 0.72), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

:root[data-theme="dark"] .toast-income {
  background: linear-gradient(100deg, #112224 0%, #151d2b 65%);
  border-color: rgba(52, 211, 153, 0.30);
  border-left-color: #34d399;
}

:root[data-theme="dark"] .toast-expense,
:root[data-theme="dark"] .toast-error {
  background: linear-gradient(100deg, #251722 0%, #151d2b 65%);
  border-color: rgba(244, 114, 128, 0.30);
  border-left-color: #f47280;
}

:root[data-theme="dark"] .toast-close {
  background: rgba(255, 255, 255, 0.07);
  color: #94a3b8;
}

:root[data-theme="dark"] .toast-close:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #f8fafc;
}



