/* ==========================================================================
   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: #94a3b8;
  --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 (Dark Mode Cinematográfico / Obsidian Slate)
   ========================================================================== */
:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #090d16;
  --bg-mesh: radial-gradient(at 0% 0%, rgba(37, 99, 235, 0.12) 0px, transparent 50%),
             radial-gradient(at 100% 10%, rgba(16, 185, 129, 0.08) 0px, transparent 40%),
             radial-gradient(at 50% 100%, rgba(139, 92, 246, 0.08) 0px, transparent 50%),
             #090d16;
  --sidebar: rgba(13, 19, 32, 0.88);
  --sidebar-border: rgba(255, 255, 255, 0.08);
  --surface: rgba(18, 26, 43, 0.85);
  --surface-card: rgba(18, 26, 43, 0.9);
  --surface-raised: #1c263c;
  --surface-subtle: #131d2e;
  --border: rgba(255, 255, 255, 0.08);
  --border-subtle: rgba(255, 255, 255, 0.04);
  --border-focus: #3b82f6;

  --text: #f8fafc;
  --text-secondary: #cbd5e1;
  --muted: #64748b;
  --text-on-accent: #ffffff;

  --blue: #3b82f6;
  --blue-hover: #60a5fa;
  --blue-glow: rgba(59, 130, 246, 0.35);
  --blue-subtle: rgba(59, 130, 246, 0.12);

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

  --coral: #fb7185;
  --coral-hover: #f43f5e;
  --coral-glow: rgba(251, 113, 133, 0.35);
  --coral-subtle: rgba(251, 113, 133, 0.12);

  --purple: #a78bfa;
  --purple-hover: #8b5cf6;
  --purple-glow: rgba(167, 139, 250, 0.35);
  --purple-subtle: rgba(167, 139, 250, 0.12);

  --indigo: #818cf8;
  --orange: #fbbf24;
  --orange-subtle: rgba(251, 191, 36, 0.12);

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow: 0 6px 24px -2px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  --shadow-elevated: 0 20px 48px -6px rgba(0, 0, 0, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  --shadow-glow: 0 0 35px -4px rgba(59, 130, 246, 0.28);
}

/* ==========================================================================
   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;
}

/* ==========================================================================
   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(59, 130, 246, 0.25);
  background: radial-gradient(ellipse at 85% 20%, rgba(59, 130, 246, 0.18), transparent 50%),
              radial-gradient(ellipse at 15% 90%, rgba(52, 211, 153, 0.1), transparent 45%),
              linear-gradient(135deg, rgba(20, 30, 50, 0.95) 0%, rgba(13, 19, 32, 0.95) 100%);
  box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.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;
}

/* ==========================================================================
   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;
}

.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%;
  overflow-x: auto;
  border-radius: var(--radius-md);
  -webkit-overflow-scrolling: touch;
}

/* ==========================================================================
   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 {
  color: #059669;
  background: var(--green-subtle);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

:root[data-theme="dark"] .status-recebido {
  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;
}

.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)
   ========================================================================== */
.form-panel {
  padding: 26px;
}

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

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

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

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

.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 */
.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);
}

.edit-mode-banner {
  display: flex;
  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-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: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 14px 18px;
  border: 1px solid rgba(37, 99, 235, 0.25);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.preview-item {
  display: grid;
  gap: 3px;
}

.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;
}

/* ==========================================================================
   ANALYSIS & AI RECOMMENDATIONS
   ========================================================================== */
.analysis-summary {
  grid-template-columns: repeat(4, minmax(0, 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;
}

.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);
}

.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)
   ========================================================================== */
.toast-region {
  position: fixed;
  z-index: 1000;
  right: 24px;
  bottom: 24px;
  display: grid;
  gap: 10px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  max-width: min(390px, calc(100vw - 32px));
  padding: 14px 20px;
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: var(--radius-md);
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow-elevated);
  font-size: 13px;
  font-weight: 600;
  animation: toastSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.toast-error {
  border-color: rgba(244, 63, 94, 0.45);
  background: var(--surface);
}

/* ==========================================================================
   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));
  }

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

  .chart-wrap {
    height: 210px;
  }

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

  .toast-region {
    left: 14px;
    right: 14px;
    bottom: calc(76px + env(safe-area-inset-bottom));
    justify-items: center;
  }

  .toast {
    max-width: 100%;
    width: 100%;
    text-align: center;
    justify-content: center;
  }

  .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,
  .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 {
    flex-direction: column;
    align-items: flex-start;
    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;
  }
}
