/* ==========================================================================
   CONTROLA CONTA — FINTECH DESIGN SYSTEM (LIGHT & DARK)
   Paleta neutra com destaque esmeralda e cores semânticas restritas a alertas
   ========================================================================== */

:root {
  color-scheme: light;
  /* Superfícies Neutras — Light Mode */
  --bg-canvas: #f8fafc;
  --bg-primary: #f8fafc;
  --bg-secondary: #f1f5f9;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-subtle: #f1f5f9;
  --bg-input: #f8fafc;

  /* Bordas & Sombras Sutis (1px) */
  --border-color: #e2e8f0;
  --border-strong: #cbd5e1;
  --border-highlight: rgba(13, 148, 136, 0.35);
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 2px 8px -2px rgba(15, 23, 42, 0.05), 0 1px 2px rgba(15, 23, 42, 0.03);
  --shadow-md: 0 10px 28px -6px rgba(15, 23, 42, 0.09), 0 4px 10px -2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 20px 44px -12px rgba(15, 23, 42, 0.18);

  /* Cor de Destaque Única — Esmeralda / Teal */
  --brand-primary: #0d9488;
  --brand-primary-dark: #0f766e;
  --brand-primary-light: #14b8a6;
  --brand-soft: rgba(13, 148, 136, 0.10);
  --brand-glow: rgba(13, 148, 136, 0.20);

  /* Tipografia */
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #64748b;
  --text-on-brand: #ffffff;

  /* Cores Semânticas */
  --accent-green: #059669;
  --accent-green-soft: rgba(5, 150, 105, 0.11);

  --accent-red: #dc2626;
  --accent-red-soft: rgba(220, 38, 38, 0.10);

  --accent-coral: #e11d48;
  --accent-coral-soft: rgba(225, 29, 72, 0.08);
  --accent-coral-border: rgba(225, 29, 72, 0.24);

  --accent-yellow: #d97706;
  --accent-yellow-soft: rgba(217, 119, 6, 0.12);

  --accent-blue: #0284c7;
  --accent-blue-soft: rgba(2, 132, 199, 0.10);

  /* Glass & Overlays */
  --header-bg: rgba(255, 255, 255, 0.88);
  --nav-bg: rgba(255, 255, 255, 0.94);
  --overlay-bg: rgba(15, 23, 42, 0.50);

  /* Escala de Espaçamentos (4px base) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;

  /* Raios & Transições */
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-pill: 999px;
  --transition: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg-canvas: #0b1120;
  --bg-primary: #0b1120;
  --bg-secondary: #111827;
  --bg-card: #131c2e;
  --bg-card-hover: #1a253b;
  --bg-subtle: #0f172a;
  --bg-input: #0f172a;

  --border-color: #1f2b40;
  --border-strong: #334155;
  --border-highlight: rgba(20, 184, 166, 0.40);
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.28);
  --shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.28);
  --shadow-md: 0 12px 30px rgba(0, 0, 0, 0.42);
  --shadow-lg: 0 24px 52px rgba(0, 0, 0, 0.62);

  --brand-primary: #14b8a6;
  --brand-primary-dark: #0d9488;
  --brand-primary-light: #2dd4bf;
  --brand-soft: rgba(20, 184, 166, 0.14);
  --brand-glow: rgba(20, 184, 166, 0.22);

  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --text-on-brand: #ffffff;

  --accent-green: #10b981;
  --accent-green-soft: rgba(16, 185, 129, 0.15);

  --accent-red: #f87171;
  --accent-red-soft: rgba(248, 113, 113, 0.15);

  --accent-coral: #fb7185;
  --accent-coral-soft: rgba(251, 113, 133, 0.13);
  --accent-coral-border: rgba(251, 113, 133, 0.30);

  --accent-yellow: #fbbf24;
  --accent-yellow-soft: rgba(251, 191, 36, 0.15);

  --accent-blue: #38bdf8;
  --accent-blue-soft: rgba(56, 189, 248, 0.14);

  --header-bg: rgba(15, 23, 42, 0.88);
  --nav-bg: rgba(15, 23, 42, 0.94);
  --overlay-bg: rgba(2, 6, 23, 0.74);
}

/* ==========================================================================
   BASE & RESET
   ========================================================================== */
[hidden] {
  display: none !important;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  overflow-x: clip;
  width: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-canvas);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
  width: 100%;
  padding-bottom: env(safe-area-inset-bottom);
  transition: background-color 0.2s ease, color 0.2s ease;
}

h1, h2, h3, h4, h5, .balance-card-val, .score-number, .sheet-col-footer {
  font-family: 'Plus Jakarta Sans', 'Inter', sans-serif;
}

img, svg, canvas {
  max-width: 100%;
}

.tabular-nums {
  font-variant-numeric: tabular-nums;
}

.sr-hidden-select {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}

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

.val-positive { color: var(--accent-green) !important; }
.val-danger { color: var(--accent-red) !important; }
.val-warning { color: var(--accent-yellow) !important; }
.val-reserve-highlight { color: var(--accent-blue) !important; }

::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

.container {
  max-width: 1320px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-6) var(--space-8);
}

/* ==========================================================================
   HEADER SUPERIOR
   ========================================================================== */
header.header {
  background: var(--header-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 200;
  padding: 12px var(--space-6);
}

.header-content {
  max-width: 1320px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4);
}

.brand-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.brand-group {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.brand-logo {
  width: 38px;
  height: 38px;
  background: var(--brand-primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  flex-shrink: 0;
  box-shadow: var(--shadow-xs);
}

.brand-title-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.brand-info h1 {
  font-size: 1.08rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-main);
  line-height: 1.2;
}

.brand-subtitle {
  display: block;
  font-size: 0.75rem;
  color: var(--text-dim);
  font-weight: 500;
}

.app-version-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  background: var(--bg-subtle);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-pill);
  font-size: 0.68rem;
  font-weight: 600;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  line-height: 1.3;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.header-primary-ctas {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

/* Seletor de Mês */
.month-picker-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.month-calendar-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  height: 36px;
  padding: 0 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: var(--shadow-xs);
}

.month-calendar-btn:hover,
.month-picker-wrapper.is-open .month-calendar-btn {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

.month-cal-svg {
  color: var(--text-dim);
  flex-shrink: 0;
}

.month-cal-text {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.month-cal-arrow {
  color: var(--text-dim);
  transition: transform var(--transition);
}

.month-picker-wrapper.is-open .month-cal-arrow {
  transform: rotate(180deg);
}

/* Dropdowns de Header */
.dropdown-wrapper {
  position: relative;
  display: inline-flex;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 224px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 400;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: all var(--transition);
}

.dropdown-menu.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background var(--transition), color var(--transition);
}

.dropdown-item:hover {
  background: var(--bg-subtle);
}

.dropdown-item-danger {
  color: var(--accent-red);
}

.dropdown-item-danger:hover {
  background: var(--accent-red-soft);
}

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

/* Tema & Perfil */
.theme-toggle-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: var(--shadow-xs);
}

.theme-toggle-btn:hover {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

.user-profile-widget {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  height: 36px;
  padding: 0 10px 0 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition);
  box-shadow: var(--shadow-xs);
}

.user-profile-widget:hover {
  border-color: var(--border-strong);
  background: var(--bg-card-hover);
}

.user-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--brand-primary);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.74rem;
  flex-shrink: 0;
}

.user-avatar-lg {
  width: 42px;
  height: 42px;
  font-size: 1rem;
}

.user-email {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-header-tools {
  display: none;
}

/* ==========================================================================
   BOTÕES PADRONIZADOS
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  border: 1px solid transparent;
  outline: none;
  text-decoration: none;
  white-space: nowrap;
}

.btn:focus-visible {
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--brand-primary);
  color: var(--text-on-brand);
  box-shadow: var(--shadow-xs);
}

.btn-primary:hover:not(:disabled) {
  background: var(--brand-primary-dark);
}

.btn-secondary {
  background: var(--bg-card);
  border-color: var(--border-color);
  color: var(--text-main);
  box-shadow: var(--shadow-xs);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-subtle);
  border-color: var(--border-strong);
}

.btn-outline {
  background: transparent;
  border-color: var(--border-color);
  color: var(--text-muted);
}

.btn-outline:hover:not(:disabled) {
  background: var(--bg-subtle);
  border-color: var(--border-strong);
  color: var(--text-main);
}

.btn-danger {
  background: var(--accent-red);
  color: #ffffff;
}

.btn-danger:hover:not(:disabled) {
  filter: brightness(0.92);
}

.btn-danger-soft {
  background: transparent;
  border-color: rgba(220, 38, 38, 0.25);
  color: var(--accent-red);
}

.btn-danger-soft:hover:not(:disabled) {
  background: var(--accent-red-soft);
  border-color: var(--accent-red);
}

.btn-sm {
  height: 32px;
  padding: 0 11px;
  font-size: 0.78rem;
}

.btn-full {
  width: 100%;
  height: 40px;
}

.btn-spacer-top {
  margin-top: var(--space-2);
}

.btn-justify-start {
  justify-content: flex-start;
  padding-left: var(--space-4);
}

.btn-icon {
  width: 30px;
  height: 30px;
  min-width: 30px;
  min-height: 30px;
  padding: 0;
  border-radius: var(--radius-xs);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.btn-icon::after {
  content: "";
  position: absolute;
  inset: -6px;
}

.btn-text-clear {
  background: none;
  border: none;
  color: var(--brand-primary);
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 4px;
}

.btn-text-clear:hover {
  text-decoration: underline;
}

.btn-inline-link {
  background: none;
  border: none;
  color: var(--brand-primary);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-inline-link:hover {
  text-decoration: underline;
}

/* ==========================================================================
   NAVEGAÇÃO POR ABAS (VISÕES PRINCIPAIS)
   ========================================================================== */
.workspace-nav-bar {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 4px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-5);
}

.workspace-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.workspace-tab:hover {
  color: var(--text-main);
}

.workspace-tab.active {
  background: var(--bg-card);
  color: var(--text-main);
  box-shadow: var(--shadow-xs);
}

.workspace-tab.active svg {
  color: var(--brand-primary);
}

.tab-score-pill {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  background: var(--brand-soft);
  color: var(--brand-primary);
  font-variant-numeric: tabular-nums;
}

.tab-score-pill.neutral {
  background: var(--bg-subtle);
  color: var(--text-dim);
}

.tab-panel {
  animation: fadeSlideIn 0.16s ease-out;
}

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

/* ==========================================================================
   TOPO EXECUTIVO — 5 CARDS KPI & FAIXA DE FLUXO
   ========================================================================== */
.balance-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: var(--space-4);
}

.balance-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-4) 18px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.balance-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.balance-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px var(--space-2);
  margin-bottom: var(--space-3);
}

.balance-card-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  font-weight: 700;
}

.balance-card-val {
  font-size: clamp(1.22rem, 1.48vw, 1.48rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--text-main);
  line-height: 1.15;
  margin-bottom: var(--space-2);
}

.balance-card-sub {
  font-size: 0.78rem;
  color: var(--text-dim);
  font-weight: 500;
  line-height: 1.35;
}

.kpi-delta-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.kpi-delta-pill.neutral {
  background: var(--bg-subtle);
  color: var(--text-dim);
}

.kpi-delta-pill.good {
  background: var(--accent-green-soft);
  color: var(--accent-green);
}

.kpi-delta-pill.warn {
  background: var(--accent-yellow-soft);
  color: var(--accent-yellow);
}

.kpi-delta-pill.bad {
  background: var(--accent-red-soft);
  color: var(--accent-red);
}

.kpi-inline-action {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.kpi-inline-action:hover {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

.kpi-limit-track {
  width: 100%;
  height: 6px;
  background: var(--bg-subtle);
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin-bottom: var(--space-2);
}

.kpi-limit-fill {
  height: 100%;
  width: 0%;
  background: var(--brand-primary);
  border-radius: var(--radius-pill);
  transition: width 0.35s ease, background-color 0.25s ease;
}

/* Faixa Compacta de Fluxo Orçamentário */
.cashflow-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px var(--space-5);
  margin-bottom: var(--space-5);
  box-shadow: var(--shadow-xs);
  flex-wrap: wrap;
}

.cashflow-strip-items {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  flex-wrap: wrap;
}

.cashflow-metric {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
}

.cashflow-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-income { background: var(--accent-green); }
.dot-free { background: var(--brand-primary); }
.dot-reserve { background: var(--accent-blue); }

.cashflow-label {
  color: var(--text-dim);
  font-weight: 500;
}

.cashflow-value {
  color: var(--text-main);
  font-weight: 700;
}

.cashflow-divider {
  width: 1px;
  height: 16px;
  background: var(--border-color);
}

.cashflow-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--brand-primary);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.cashflow-link-btn:hover {
  text-decoration: underline;
}

/* ==========================================================================
   SURFACE CARDS & MEIO (GRÁFICOS)
   ========================================================================== */
.surface-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
  min-width: 0;
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.015em;
  line-height: 1.3;
}

.card-subtitle {
  font-size: 0.81rem;
  color: var(--text-dim);
  margin-top: 2px;
}

.analytics-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.12fr);
  gap: var(--space-5);
  margin-bottom: var(--space-5);
}

.chart-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}

.chart-header-meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.chart-total-pill {
  padding: 4px 10px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-main);
}

.category-chart-layout {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: var(--space-5);
  align-items: center;
}

.donut-canvas-wrap {
  position: relative;
  height: 210px;
  width: 200px;
  margin: 0 auto;
}

.category-legend-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 230px;
  overflow-y: auto;
  padding-right: 4px;
}

.cat-legend-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: 7px 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: all var(--transition);
}

.cat-legend-item:hover {
  background: var(--bg-subtle);
  border-color: var(--border-color);
}

.cat-legend-item.active-filter {
  background: var(--brand-soft);
  border-color: var(--border-highlight);
}

.cat-legend-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.cat-legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.cat-legend-name {
  font-size: 0.81rem;
  font-weight: 600;
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cat-legend-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.cat-legend-pct {
  font-size: 0.74rem;
  color: var(--text-dim);
  font-weight: 600;
}

.cat-legend-val {
  font-size: 0.81rem;
  font-weight: 700;
  color: var(--text-main);
}

/* Segmented Control (Evolução vs Top Locais) */
.segmented-control {
  display: inline-flex;
  padding: 3px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

.segmented-btn {
  padding: 5px 11px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.segmented-btn.active {
  background: var(--bg-card);
  color: var(--text-main);
  box-shadow: var(--shadow-xs);
}

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

.top-merchants-list {
  max-height: 235px;
  overflow-y: auto;
}

#topMerchantsContainer {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.merchant-rank-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  padding: 10px 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

.merchant-rank-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.merchant-rank-badge {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand-primary);
  font-size: 0.73rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.merchant-rank-title {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.merchant-rank-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.merchant-rank-count {
  font-size: 0.74rem;
  color: var(--text-dim);
}

.merchant-rank-total {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--text-main);
}

/* ==========================================================================
   BASE: TABELA DE TRANSAÇÕES & FILTROS
   ========================================================================== */
.transactions-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}

.transactions-title-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.month-context-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  background: var(--brand-soft);
  color: var(--brand-primary);
  font-size: 0.74rem;
  font-weight: 700;
}

.transactions-header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.tx-filters-bar {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.tx-search-box {
  position: relative;
  width: 100%;
}

.tx-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  pointer-events: none;
}

.tx-search-input {
  width: 100%;
  height: 38px;
  padding: 0 36px 0 38px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.85rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.tx-search-input::placeholder {
  color: var(--text-dim);
  font-size: 0.84rem;
}

.tx-search-input:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.tx-search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: var(--bg-subtle);
  color: var(--text-dim);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color var(--transition), color var(--transition);
}

.tx-search-clear:hover {
  background: var(--border-color);
  color: var(--text-main);
}

.tx-filter-controls {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.tx-mobile-filters-toggle {
  display: none;
}

.tx-filter-panel {
  display: contents;
}

.tx-filter-field {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 34px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition), background-color var(--transition), box-shadow var(--transition);
}

.tx-filter-field:hover {
  border-color: var(--border-strong);
}

.tx-filter-field:focus-within {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.tx-filter-field.is-active {
  border-color: var(--border-highlight);
  background: var(--brand-soft);
}

.tx-filter-field.is-active .tx-filter-label,
.tx-filter-field.is-active .tx-filter-chevron {
  color: var(--brand-primary);
}

.tx-filter-field-sort {
  order: 5;
}

.tx-reset-filters-btn {
  order: 6;
  gap: 5px;
}

.tx-filter-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding-left: 10px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-dim);
  white-space: nowrap;
  pointer-events: none;
  user-select: none;
}

.tx-filter-label::after {
  content: ":";
}

.tx-sort-mobile-icon {
  display: none;
  flex-shrink: 0;
}

.tx-filter-select {
  height: 100%;
  padding: 0 26px 0 6px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.81rem;
  font-weight: 600;
  outline: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  min-width: 0;
  max-width: 190px;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.tx-filter-select option {
  background-color: var(--bg-card);
  color: var(--text-main);
}

.tx-filter-chevron {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  pointer-events: none;
  transition: color var(--transition);
}

.table-scroll-container {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

table.styled-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  background: var(--bg-card);
}

table.styled-table thead th {
  background: var(--bg-subtle);
  padding: 12px 16px;
  font-size: 0.73rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

table.styled-table thead th.sortable-th {
  cursor: pointer;
  user-select: none;
}

table.styled-table thead th.sortable-th:hover {
  color: var(--text-main);
}

.sort-indicator {
  font-size: 0.65rem;
  margin-left: 3px;
  color: var(--brand-primary);
}

.th-actions {
  width: 96px;
}

table.styled-table td {
  padding: 14px 16px;
  font-size: 0.86rem;
  color: var(--text-main);
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

table.styled-table tbody tr:last-child td {
  border-bottom: none;
}

table.styled-table tbody tr:hover td {
  background: var(--bg-card-hover);
}

.tx-date-cell {
  color: var(--text-dim);
  font-size: 0.82rem;
  white-space: nowrap;
}

.tx-sub-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 3px;
}

.tx-note-sub {
  font-size: 0.72rem;
  color: var(--text-dim);
}

.payment-method-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  font-size: 0.69rem;
  font-weight: 600;
  line-height: 1.25;
  border: 1px solid var(--border-color);
  background: var(--bg-subtle);
  color: var(--text-muted);
  white-space: nowrap;
}

.payment-method-badge svg {
  flex-shrink: 0;
}

.payment-method-badge.pm-credit {
  background: var(--accent-coral-soft);
  border-color: var(--accent-coral-border);
  color: var(--accent-coral);
}

.payment-method-badge.pm-pix {
  background: var(--brand-soft);
  border-color: var(--border-highlight);
  color: var(--brand-primary);
}

.payment-method-badge.pm-debit,
.payment-method-badge.pm-transfer {
  background: var(--accent-blue-soft);
  border-color: rgba(2, 132, 199, 0.22);
  color: var(--accent-blue);
}

.payment-method-badge.pm-boleto {
  background: var(--accent-yellow-soft);
  border-color: rgba(217, 119, 6, 0.24);
  color: var(--accent-yellow);
}

.payment-method-badge.pm-cash {
  background: var(--accent-green-soft);
  border-color: rgba(16, 185, 129, 0.24);
  color: var(--accent-green);
}

.tx-title-main {
  font-weight: 600;
  color: var(--text-main);
}

.tx-amount-cell {
  font-weight: 700;
  color: var(--text-main);
  cursor: pointer;
  white-space: nowrap;
}

.tx-amount-cell:hover {
  color: var(--brand-primary);
}

.tx-actions-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

/* Highlight de item recém-criado (sem roxo, usando esmeralda) */
.row-highlight-new td {
  background: var(--brand-soft) !important;
  animation: pulseNewRow 2.6s ease-out forwards;
}

@keyframes pulseNewRow {
  0% { background: rgba(13, 148, 136, 0.22); }
  100% { background: transparent; }
}

/* Badges Padronizadas de Categoria & Status */
.category-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 600;
  white-space: nowrap;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  font-size: 0.73rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.status-badge.status-single {
  background: var(--bg-subtle);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

.status-badge.status-installment {
  background: var(--accent-blue-soft);
  color: var(--accent-blue);
  border: 1px solid rgba(2, 132, 199, 0.22);
}

.status-badge.status-recurring {
  background: var(--brand-soft);
  color: var(--brand-primary);
  border: 1px solid var(--border-highlight);
}

.status-badge.status-pending {
  background: var(--accent-yellow-soft);
  color: var(--accent-yellow);
  border: 1px solid rgba(217, 119, 6, 0.26);
}

.fixed-item-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  font-size: 0.69rem;
  font-weight: 700;
  background: var(--brand-soft);
  color: var(--brand-primary);
  border: 1px solid var(--border-highlight);
  margin-left: 6px;
}

.card-invoice-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  font-size: 0.69rem;
  font-weight: 700;
  background: var(--accent-coral);
  color: #ffffff;
  margin-left: 4px;
}

/* Lista Mobile de Transações (oculta no desktop) */
.tx-mobile-list {
  display: none;
  flex-direction: column;
  gap: var(--space-2);
}

.tx-mobile-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tx-mobile-card.row-highlight-new {
  background: var(--brand-soft);
  border-color: var(--brand-primary);
}

.tx-mobile-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-3);
}

.tx-mobile-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-main);
  line-height: 1.3;
  word-break: break-word;
}

.tx-mobile-amount {
  font-weight: 800;
  font-size: 0.94rem;
  color: var(--text-main);
  white-space: nowrap;
  flex-shrink: 0;
}

.tx-mobile-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.tx-mobile-date {
  font-size: 0.76rem;
  color: var(--text-dim);
  margin-right: 4px;
}

.tx-mobile-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--border-color);
}

.tx-empty-box {
  text-align: center;
  padding: 36px var(--space-4);
  color: var(--text-dim);
  font-size: 0.86rem;
}

/* ==========================================================================
   ABA 2: ORÇAMENTO 60/30/10 & CADERNO 3 COLUNAS
   ========================================================================== */
.rule-banner {
  margin-bottom: var(--space-5);
}

.rule-banner-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}

.rule-banner-subtitle {
  display: block;
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-top: 2px;
}

.rule-cards-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-4);
}

.rule-item-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}

.rule-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-3);
}

.rule-item-label {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--text-main);
}

.rule-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
}

.badge-essential { background: var(--accent-green-soft); color: var(--accent-green); }
.badge-personal { background: var(--accent-coral-soft); color: var(--accent-coral); }
.badge-reserve { background: var(--accent-blue-soft); color: var(--accent-blue); }

.rule-progress-track {
  width: 100%;
  height: 7px;
  background: var(--border-color);
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin-bottom: var(--space-3);
}

.rule-progress-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  width: 0%;
  transition: width 0.35s ease, background-color 0.25s ease;
}

.fill-essential { background: var(--accent-green); }
.fill-personal { background: var(--accent-coral); }
.fill-reserve { background: var(--accent-blue); }

.rule-values-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.83rem;
  margin-bottom: 6px;
  color: var(--text-muted);
}

.rule-values-row strong {
  color: var(--text-main);
}

.rule-values-row.rule-pct-row {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-bottom: 2px;
}

.rule-values-row.rule-pct-row strong {
  font-weight: 600;
  color: var(--text-muted);
}

.rule-balance-tag {
  font-size: 0.83rem;
  font-weight: 700;
  padding-top: var(--space-2);
  margin-top: var(--space-2);
  border-top: 1px dashed var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.rule-balance-caption {
  color: var(--text-dim);
  font-weight: 600;
}

.rule-balance-muted {
  color: var(--text-dim);
  font-weight: 500;
}

.sheet-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-5);
}

.sheet-col-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
}

.sheet-col-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-color);
}

.sheet-col-header h4 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

/* Flag de preferência: Supermercado do cartão em Gastos Essenciais */
.essential-flag-card {
  margin-bottom: var(--space-3);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  transition: background-color var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.essential-flag-card:hover {
  border-color: var(--border-strong);
}

.essential-flag-card.is-active {
  background: var(--accent-green-soft);
  border-color: var(--border-highlight);
}

.essential-flag-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  cursor: pointer;
  user-select: none;
}

.essential-flag-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.essential-flag-title {
  font-size: 0.79rem;
  font-weight: 600;
  line-height: 1.38;
  color: var(--text-main);
}

.essential-flag-meta {
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.essential-flag-card.is-active .essential-flag-meta {
  color: var(--accent-green);
  font-weight: 600;
}

/* Switch acessível baseado em input[type="checkbox"] */
.toggle-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  width: 40px;
  height: 22px;
}

.toggle-switch-input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
  z-index: 2;
}

.toggle-switch-track {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  border-radius: var(--radius-pill);
  background: var(--border-strong);
  transition: background-color var(--transition), box-shadow var(--transition);
}

.toggle-switch-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.25);
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.toggle-switch-input:checked + .toggle-switch-track {
  background: var(--brand-primary);
}

.toggle-switch-input:checked + .toggle-switch-track::after {
  transform: translateX(18px);
}

.toggle-switch-input:focus-visible + .toggle-switch-track {
  box-shadow: 0 0 0 3px var(--brand-glow);
}

.toggle-switch-input:disabled + .toggle-switch-track {
  opacity: 0.6;
  cursor: not-allowed;
}

.sheet-items-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  flex: 1;
  min-height: 90px;
}

.sheet-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-6) var(--space-3);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 0.82rem;
  gap: 4px;
  margin: auto 0;
}

.sheet-row-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  gap: var(--space-2);
  transition: border-color var(--transition);
}

.sheet-row-item:hover {
  border-color: var(--border-strong);
}

.sheet-row-item.card-invoice-highlight {
  background: var(--accent-coral-soft);
  border-color: var(--accent-coral-border);
}

.sheet-row-item.essential-supermarket-highlight {
  background: var(--accent-green-soft);
  border-color: var(--border-highlight);
}

.sheet-row-item.direct-expense-highlight {
  background: var(--accent-blue-soft);
  border-color: rgba(2, 132, 199, 0.22);
}

.direct-expense-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  font-size: 0.69rem;
  font-weight: 700;
  background: var(--accent-blue);
  color: #ffffff;
  margin-left: 4px;
}

.sheet-row-name-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.sheet-row-name {
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--text-main);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  min-width: 0;
}

.sheet-row-subnote {
  font-size: 0.72rem;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
}

.essential-auto-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  font-size: 0.69rem;
  font-weight: 700;
  background: var(--accent-green);
  color: #ffffff;
  margin-left: 4px;
}

.sheet-row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.sheet-row-val {
  font-size: 0.89rem;
  font-weight: 700;
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.sheet-row-val.val-income { color: var(--accent-green); }
.sheet-row-val.val-card { color: var(--accent-coral); }
.sheet-row-val.val-essential-auto { color: var(--accent-green); }
.sheet-row-val:hover { text-decoration: underline; }
.sheet-row-item.card-invoice-highlight .sheet-row-val,
.sheet-row-item.essential-supermarket-highlight .sheet-row-val,
.sheet-row-item.direct-expense-highlight .sheet-row-val {
  cursor: default;
}
.sheet-row-item.card-invoice-highlight .sheet-row-val:hover,
.sheet-row-item.essential-supermarket-highlight .sheet-row-val:hover,
.sheet-row-item.direct-expense-highlight .sheet-row-val:hover {
  text-decoration: none;
}

.sheet-col-footer {
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 800;
  font-size: 0.94rem;
}

/* ==========================================================================
   ABA 3: CONSULTORIA IA (GEMINI)
   ========================================================================== */
.gemini-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
}

.gemini-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.gemini-header-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.gemini-icon-badge {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: var(--brand-soft);
  color: var(--brand-primary);
  border: 1px solid var(--border-highlight);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.gemini-title {
  font-size: 1.08rem;
  font-weight: 800;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.ai-badge {
  font-size: 0.69rem;
  font-weight: 700;
  background: var(--brand-soft);
  color: var(--brand-primary);
  border: 1px solid var(--border-highlight);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.gemini-subtitle {
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-top: 2px;
}

.gemini-summary-card {
  display: grid;
  grid-template-columns: 168px 1fr;
  gap: var(--space-5);
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  margin-bottom: var(--space-5);
  align-items: center;
}

.gemini-score-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  border-right: 1px solid var(--border-color);
  padding-right: var(--space-4);
}

.score-circle {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  border: 3px solid var(--accent-green);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-2);
  background: var(--accent-green-soft);
}

.score-circle.excellent { border-color: var(--accent-green); background: var(--accent-green-soft); color: var(--accent-green); }
.score-circle.good { border-color: var(--accent-blue); background: var(--accent-blue-soft); color: var(--accent-blue); }
.score-circle.balanced { border-color: var(--accent-yellow); background: var(--accent-yellow-soft); color: var(--accent-yellow); }
.score-circle.warning { border-color: var(--accent-red); background: var(--accent-red-soft); color: var(--accent-red); }
.score-circle.neutral { border-color: var(--border-strong); background: var(--bg-subtle); color: var(--text-dim); }

.score-number {
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1;
}

.score-label-text {
  font-size: 0.62rem;
  color: var(--text-dim);
  text-transform: uppercase;
  font-weight: 700;
  margin-top: 2px;
}

.score-info {
  text-align: center;
}

.score-badge {
  font-size: 0.76rem;
  font-weight: 700;
  display: inline-block;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
}

.score-caption {
  display: block;
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 3px;
}

.gemini-summary-text-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.summary-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--brand-primary);
}

.summary-paragraph {
  font-size: 0.9rem;
  color: var(--text-main);
  line-height: 1.55;
}

.summary-advice {
  background: var(--brand-soft);
  border-left: 3px solid var(--brand-primary);
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
  padding: 8px 12px;
  font-size: 0.82rem;
  color: var(--text-main);
}

.gemini-hints-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--space-3);
}

.gemini-hint-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-left: 3px solid var(--accent-blue);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--space-3);
}

.gemini-hint-card.warning,
.gemini-hint-card.danger { border-left-color: var(--accent-yellow); }
.gemini-hint-card.saving,
.gemini-hint-card.success { border-left-color: var(--accent-green); }
.gemini-hint-card.praise { border-left-color: var(--brand-primary); }

.hint-badge {
  font-size: 0.69rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  text-transform: uppercase;
}

.hint-badge.warning,
.hint-badge.danger { background: var(--accent-yellow-soft); color: var(--accent-yellow); }
.hint-badge.saving,
.hint-badge.success { background: var(--accent-green-soft); color: var(--accent-green); }
.hint-badge.tip { background: var(--accent-blue-soft); color: var(--accent-blue); }
.hint-badge.praise { background: var(--brand-soft); color: var(--brand-primary); }

.hint-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-main);
  margin-top: 8px;
}

.hint-description {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.hint-action-box {
  background: var(--bg-card);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-xs);
  padding: 8px 10px;
  font-size: 0.79rem;
  color: var(--text-muted);
  display: flex;
  gap: 6px;
}

.hint-action-box strong {
  color: var(--brand-primary);
  white-space: nowrap;
}

.gemini-loading-skeleton {
  text-align: center;
  padding: var(--space-8) var(--space-4);
  color: var(--text-dim);
}

.gemini-loading-spinner {
  display: inline-block;
  width: 28px;
  height: 28px;
  border: 3px solid var(--brand-soft);
  border-top-color: var(--brand-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: var(--space-2);
}

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

.gemini-chat-card {
  margin-top: var(--space-5);
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
}

.gemini-chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
  gap: var(--space-2);
}

.gemini-chat-header-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.chat-header-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: var(--brand-soft);
  color: var(--brand-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.chat-card-title {
  font-size: 0.94rem;
  font-weight: 700;
  color: var(--text-main);
}

.chat-card-sub {
  font-size: 0.78rem;
  color: var(--text-dim);
}

.accent-month-tag {
  color: var(--brand-primary);
}

.chat-suggestions-container {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  padding: var(--space-3) 0 var(--space-2);
}

.chat-chip {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.77rem;
  font-weight: 500;
  padding: 6px 12px;
  white-space: nowrap;
  cursor: pointer;
  transition: all var(--transition);
}

.chat-chip:hover {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

.gemini-chat-messages {
  min-height: 190px;
  max-height: 340px;
  overflow-y: auto;
  padding: var(--space-3) 4px;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.chat-msg-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.chat-msg-row.user {
  flex-direction: row-reverse;
}

.chat-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
  flex-shrink: 0;
}

.chat-msg-row.user .chat-avatar {
  background: var(--accent-blue-soft);
  color: var(--accent-blue);
}

.chat-msg-row.assistant .chat-avatar {
  background: var(--brand-primary);
  color: #ffffff;
}

.chat-msg-bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.86rem;
  line-height: 1.5;
}

.chat-msg-row.user .chat-msg-bubble {
  background: var(--brand-primary);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.chat-msg-row.assistant .chat-msg-bubble {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-bottom-left-radius: 4px;
}

.chat-msg-bubble p { margin-bottom: 6px; }
.chat-msg-bubble p:last-child { margin-bottom: 0; }
.chat-msg-bubble ul, .chat-msg-bubble ol { margin: 6px 0 8px 18px; }

.chat-typing {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 6px;
}

.chat-typing-dot {
  width: 6px;
  height: 6px;
  background: var(--brand-primary);
  border-radius: 50%;
  animation: typingBounce 1.2s infinite ease-in-out;
}
.chat-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.chat-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

.gemini-chat-input-form {
  display: flex;
  gap: var(--space-2);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 4px 6px 4px 12px;
  align-items: center;
}

.gemini-chat-input-form:focus-within {
  border-color: var(--brand-primary);
}

.gemini-chat-input-form input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  padding: 8px 4px;
  font-size: 0.88rem;
  color: var(--text-main);
  font-family: inherit;
}

/* ==========================================================================
   MODAIS & DRAWERS (GAVETAS LATERAIS NO DESKTOP, BOTTOM SHEET NO MOBILE)
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-bg);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  padding: var(--space-5);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-card-sm {
  max-width: 430px;
}

/* Gavetas Laterais (Drawers) no Desktop */
.modal-drawer-overlay {
  justify-content: flex-end;
  align-items: stretch;
  padding: 0;
}

.modal-drawer {
  max-width: 500px;
  height: 100%;
  max-height: 100vh;
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
  border-right: none;
  display: flex;
  flex-direction: column;
  transform: translateX(28px);
  transition: transform 0.24s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-drawer-lg {
  max-width: 720px;
}

.modal-overlay.active .modal-drawer {
  transform: translateX(0);
}

.modal-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-3);
  flex-shrink: 0;
}

.modal-header h3 {
  font-size: 1.02rem;
  font-weight: 800;
  color: var(--text-main);
}

.modal-header-subtitle {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-top: 2px;
}

.modal-title-danger {
  color: var(--accent-red) !important;
}

.modal-close {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: var(--text-muted);
  font-size: 1.15rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--transition);
}

.modal-close:hover {
  background: var(--accent-red-soft);
  color: var(--accent-red);
  border-color: var(--accent-red);
}

.modal-body {
  padding: var(--space-5);
  overflow-y: auto;
  flex: 1;
}

.modal-lead {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: var(--space-4);
}

.modal-actions-row {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

.stack-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* Formulários */
.form-group {
  margin-bottom: var(--space-4);
}

.form-group-last {
  margin-bottom: 0;
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

.form-group label {
  display: block;
  font-size: 0.81rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.label-split {
  display: flex !important;
  justify-content: space-between;
  align-items: center;
}

.form-group input,
.form-group select {
  width: 100%;
  height: 40px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  color: var(--text-main);
  font-size: 0.89rem;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.form-group input.money-atm-input {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.field-helper {
  display: block;
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 5px;
}

.field-helper-brand {
  color: var(--brand-primary);
  font-weight: 500;
}

.form-helper-gap {
  margin-bottom: var(--space-4);
}

.inline-field-group {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.compact-num-input {
  max-width: 88px;
}

.field-hint-inline {
  font-size: 0.8rem;
  color: var(--text-dim);
}

/* Parcelamento e Recorrência */
.installment-panel {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  margin-bottom: var(--space-4);
}

.radio-pill-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
}

.radio-pill-option {
  display: flex !important;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.8rem !important;
  font-weight: 500 !important;
  color: var(--text-main) !important;
  cursor: pointer;
  margin-bottom: 0 !important;
}

.radio-pill-option input {
  width: auto !important;
  height: auto !important;
  accent-color: var(--brand-primary);
}

.installment-preview-box {
  font-size: 0.78rem;
  color: var(--brand-primary);
  font-weight: 500;
  padding-top: var(--space-2);
  border-top: 1px dashed var(--border-color);
}

.fixed-expense-toggle-card {
  margin: var(--space-3) 0 var(--space-4);
  padding: 11px 13px;
  background: var(--brand-soft);
  border: 1px solid var(--border-highlight);
  border-radius: var(--radius-md);
}

.fixed-expense-toggle-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.fixed-expense-checkbox {
  width: 17px !important;
  height: 17px !important;
  margin-top: 2px;
  accent-color: var(--brand-primary);
  cursor: pointer;
  flex-shrink: 0;
}

.toggle-card-title {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-main);
}

.toggle-card-desc {
  display: block;
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 2px;
}

.drawer-footer-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-color);
}

.targets-box {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
}

.targets-box-desc {
  display: block;
  font-size: 0.81rem;
  color: var(--text-muted);
  margin-bottom: var(--space-3);
}

.info-callout {
  background: var(--brand-soft);
  border: 1px solid var(--border-highlight);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  font-size: 0.81rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.info-callout strong {
  display: block;
  color: var(--brand-primary-dark);
  margin-bottom: 2px;
}

[data-theme="dark"] .info-callout strong {
  color: var(--brand-primary-light);
}

.danger-callout {
  background: var(--accent-red-soft);
  border: 1px solid rgba(220, 38, 38, 0.25);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  font-size: 0.81rem;
  color: var(--accent-red);
  line-height: 1.45;
  margin-bottom: var(--space-4);
}

/* ==========================================================================
   IMPORTAÇÃO CSV EM 2 ETAPAS (DRAG & DROP + PRÉ-VISUALIZAÇÃO)
   ========================================================================== */
.csv-stepper {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.csv-step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-dim);
}

.csv-step.active {
  color: var(--text-main);
}

.csv-step.done {
  color: var(--accent-green);
}

.csv-step-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.74rem;
  font-weight: 700;
}

.csv-step.active .csv-step-num {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: #ffffff;
}

.csv-step.done .csv-step-num {
  background: var(--accent-green);
  border-color: var(--accent-green);
  color: #ffffff;
}

.csv-step-line {
  flex: 1;
  height: 1px;
  background: var(--border-color);
}

.modal-context-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 13px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: var(--space-4);
}

.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 36px var(--space-5);
  text-align: center;
  background: var(--bg-subtle);
  cursor: pointer;
  transition: all var(--transition);
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--brand-primary);
  background: var(--brand-soft);
}

.dropzone-icon-wrap {
  width: 52px;
  height: 52px;
  margin: 0 auto var(--space-3);
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--brand-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.dropzone-title {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text-main);
  margin-bottom: 4px;
}

.dropzone-hint {
  font-size: 0.79rem;
  color: var(--text-dim);
}

.csv-info-box {
  margin-top: var(--space-4);
}

.csv-file-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.csv-file-name-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.86rem;
  color: var(--text-main);
  min-width: 0;
}

.csv-file-name-wrap strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.csv-summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.csv-stat-pill {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}

.csv-stat-pill span {
  display: block;
  font-size: 0.7rem;
  color: var(--text-dim);
  font-weight: 600;
}

.csv-stat-pill strong {
  font-size: 1.05rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.csv-preview-table-wrap {
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
}

.csv-preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.81rem;
  text-align: left;
}

.csv-preview-table thead th {
  position: sticky;
  top: 0;
  background: var(--bg-subtle);
  padding: 9px 10px;
  font-size: 0.71rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border-color);
  z-index: 2;
}

.csv-preview-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.csv-preview-table tr.csv-row-error {
  background: var(--accent-red-soft);
  opacity: 0.85;
}

.csv-preview-table tr.csv-row-duplicate {
  opacity: 0.65;
}

.csv-col-check {
  width: 34px;
  text-align: center;
}

.csv-cat-select {
  height: 28px;
  padding: 0 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-main);
  font-size: 0.76rem;
  max-width: 155px;
}

.csv-status-tag {
  display: inline-flex;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  font-size: 0.7rem;
  font-weight: 700;
  white-space: nowrap;
}

.csv-status-tag.new { background: var(--accent-green-soft); color: var(--accent-green); }
.csv-status-tag.update { background: var(--accent-blue-soft); color: var(--accent-blue); }
.csv-status-tag.duplicate { background: var(--accent-yellow-soft); color: var(--accent-yellow); }
.csv-status-tag.error { background: var(--accent-red-soft); color: var(--accent-red); }

.csv-preview-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-color);
}

.csv-selection-total {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.csv-selection-total strong {
  display: block;
  font-size: 0.95rem;
  color: var(--text-main);
}

.csv-footer-buttons {
  display: flex;
  gap: var(--space-2);
}

.import-status-box {
  margin-top: var(--space-3);
  font-size: 0.84rem;
}

/* ==========================================================================
   CALENDÁRIO DE SELEÇÃO DE MÊS
   ========================================================================== */
.month-calendar-card {
  max-width: 350px !important;
  padding: var(--space-4) var(--space-5) !important;
}

.month-cal-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border-color);
}

.month-cal-card-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.96rem;
  font-weight: 700;
}

.cal-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border-color);
  gap: var(--space-2);
}

.cal-nav-btn {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-color);
  background: var(--bg-subtle);
  color: var(--text-main);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
}

.cal-nav-btn:hover {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

.cal-year-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 1rem;
  font-weight: 800;
}

.cal-today-pill {
  padding: 3px 10px;
  font-size: 0.73rem;
  font-weight: 600;
  background: var(--brand-soft);
  color: var(--brand-primary);
  border: 1px solid var(--border-highlight);
  border-radius: var(--radius-pill);
  cursor: pointer;
}

.cal-months-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-2);
  margin: var(--space-3) 0;
}

.cal-month-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 7px 4px 5px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-subtle);
  color: var(--text-main);
  cursor: pointer;
  min-height: 48px;
  font-family: inherit;
  transition: all var(--transition);
}

.cal-month-cell:hover {
  border-color: var(--brand-primary);
}

.cal-month-cell.selected {
  background: var(--brand-primary);
  color: #ffffff;
  border-color: var(--brand-primary);
}

.cal-month-cell.is-today:not(.selected) {
  border: 1.5px solid var(--brand-primary);
}

.cal-month-num {
  font-size: 0.92rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.cal-month-name {
  font-size: 0.69rem;
  color: var(--text-dim);
  text-transform: uppercase;
}

.cal-month-cell.selected .cal-month-name {
  color: rgba(255, 255, 255, 0.9);
}

.cal-data-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--brand-primary);
  margin-top: 2px;
  visibility: hidden;
}

.cal-month-cell.has-data .cal-data-dot { visibility: visible; }
.cal-month-cell.selected.has-data .cal-data-dot { background: #ffffff; }

.cal-popover-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: var(--space-2);
  border-top: 1px solid var(--border-color);
  font-size: 0.74rem;
  color: var(--text-dim);
}

.cal-legend {
  display: flex;
  align-items: center;
  gap: 5px;
}

.cal-legend-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand-primary);
}

.cal-native-trigger-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xs);
  color: var(--text-dim);
  font-size: 0.73rem;
  padding: 3px 8px;
  cursor: pointer;
}

/* ==========================================================================
   AUTH OVERLAY, TOASTS & FOOTER
   ========================================================================== */
html.auth-booting header.header,
html.auth-booting main.container,
html.auth-booting nav.mobile-bottom-bar,
html.auth-required header.header,
html.auth-required main.container,
html.auth-required nav.mobile-bottom-bar {
  visibility: hidden;
  pointer-events: none;
}

html.auth-required .auth-overlay {
  display: flex;
}

.auth-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-canvas);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  padding: var(--space-5);
  overflow-y: auto;
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 420px;
  padding: var(--space-6) var(--space-6) var(--space-8);
  box-shadow: var(--shadow-lg);
}

.auth-top-nav {
  display: flex;
  justify-content: flex-start;
  margin-bottom: var(--space-3);
}

.auth-home-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 6px 10px 6px 4px;
  margin-left: -4px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.84rem;
  font-weight: 600;
  text-decoration: none;
  transition: color var(--transition), background var(--transition);
}

.auth-home-link:hover {
  color: var(--brand-primary);
  background: var(--brand-soft);
}

.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: var(--space-6);
}

.auth-brand-link {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  color: inherit;
}

.auth-brand-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: var(--brand-primary);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-3);
}

.auth-brand h2 {
  font-size: 1.35rem;
  font-weight: 800;
}

.auth-brand p {
  font-size: 0.83rem;
  color: var(--text-dim);
  margin-top: 4px;
}

.auth-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: var(--space-5);
  background: var(--bg-secondary);
  padding: 4px;
  border-radius: var(--radius-sm);
}

.auth-tab {
  flex: 1;
  min-height: 44px;
  padding: 8px 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
}

.auth-tab.active {
  background: var(--bg-card);
  color: var(--text-main);
  box-shadow: var(--shadow-xs);
}

.auth-error {
  display: none;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--accent-red-soft);
  border: 1px solid rgba(220, 38, 38, 0.25);
  color: var(--accent-red);
  font-size: 0.82rem;
  margin-bottom: var(--space-4);
}

.auth-error.success-msg {
  background: var(--accent-green-soft);
  border-color: rgba(5, 150, 105, 0.28);
  color: var(--accent-green);
}

.auth-submit-btn {
  width: 100%;
  min-height: 46px;
  height: 46px;
  font-size: 0.92rem;
}

.auth-link-btn {
  background: none;
  border: none;
  color: var(--brand-primary);
  font-family: inherit;
  font-size: 0.81rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 0 4px;
}

.auth-back-btn {
  display: block;
  margin: var(--space-4) auto 0;
}

.auth-forgot-hint {
  display: none;
  font-size: 0.83rem;
  color: var(--text-muted);
  margin-bottom: var(--space-4);
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
}

.auth-invite-footer {
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-dim);
  text-align: center;
}

.auth-invite-link {
  color: var(--brand-primary);
  font-weight: 600;
  text-decoration: none;
  transition: color 0.16s ease, opacity 0.16s ease;
}

.auth-invite-link:hover {
  text-decoration: underline;
  opacity: 0.88;
}

.user-menu-summary {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  padding: var(--space-3);
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.user-menu-meta {
  min-width: 0;
  flex: 1;
}

.user-menu-caption {
  display: block;
  font-size: 0.73rem;
  color: var(--text-dim);
}

.user-menu-meta strong {
  display: block;
  font-size: 0.88rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toast-container {
  position: fixed;
  bottom: var(--space-5);
  left: var(--space-5);
  top: auto;
  transform: none;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
  max-width: min(420px, calc(100vw - 40px));
  z-index: 10500;
  pointer-events: none;
}

.toast-container .toast {
  pointer-events: auto;
}

.toast {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--brand-primary);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  font-weight: 500;
  transition: opacity 0.25s ease;
}

.toast.success { border-left-color: var(--accent-green); }
.toast.error { border-left-color: var(--accent-red); }
.toast.info { border-left-color: var(--brand-primary); }

.app-footer {
  margin-top: var(--space-8);
  padding: var(--space-5) 4px var(--space-3);
  border-top: 1px solid var(--border-color);
}

.app-footer-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.app-footer-left {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px var(--space-2);
}

.app-footer-title {
  color: var(--text-dim);
  font-size: 0.8rem;
  font-weight: 500;
}

.app-footer-sep {
  color: var(--text-dim);
  opacity: 0.55;
  font-size: 0.85rem;
}

.app-footer-credits {
  color: var(--text-dim);
  font-size: 0.78rem;
  font-weight: 500;
}

.app-footer-author {
  color: var(--text-main);
  font-weight: 600;
  text-decoration: none;
  transition: color 0.15s ease;
}

.app-footer-author:hover {
  color: var(--brand-primary);
  text-decoration: underline;
}

/* Bottom Bar Mobile */
.mobile-bottom-bar {
  display: none;
}

.mobile-actions-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.mobile-action-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 11px 13px;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  color: var(--text-main);
}

.mobile-action-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--brand-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.mobile-action-icon.icon-danger {
  color: var(--accent-red);
}

.mobile-action-text {
  flex: 1;
  min-width: 0;
}

.mobile-action-text strong {
  display: block;
  font-size: 0.87rem;
}

.mobile-action-text span {
  display: block;
  font-size: 0.74rem;
  color: var(--text-dim);
}

.mobile-action-arrow {
  font-size: 1.2rem;
  color: var(--text-dim);
}

/* Skeleton Loader, Barra de Sincronização & Transições Suaves de Dados */
.header-sync-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2.5px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  background: var(--brand-soft);
  transition: opacity 0.25s ease;
}

.header-sync-bar::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 38%;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, var(--brand-primary-light), var(--brand-primary), transparent);
  transform: translateX(-100%);
  animation: headerSyncSweep 1.25s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

body.is-syncing .header-sync-bar {
  opacity: 1;
}

body.is-syncing .month-calendar-btn .month-cal-svg {
  animation: softPulseIcon 1.2s ease-in-out infinite;
  color: var(--brand-primary);
}

@keyframes headerSyncSweep {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(360%); }
}

@keyframes softPulseIcon {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.55; transform: scale(0.94); }
}

.skeleton-value {
  display: inline-block;
  width: 110px;
  height: 24px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--bg-subtle) 25%, var(--border-color) 50%, var(--bg-subtle) 75%);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.3s ease-in-out infinite;
  color: transparent !important;
}

.skeleton-line {
  display: block;
  width: 100%;
  height: 14px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--bg-subtle) 25%, var(--border-color) 50%, var(--bg-subtle) 75%);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.3s ease-in-out infinite;
}

@keyframes skeletonShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Estados .is-loading para KPIs, Fluxo Orçamentário e Metas (sem reflow/CLS) */
.balance-grid.is-loading .balance-card-val,
.balance-grid.is-loading .balance-card-sub,
.balance-grid.is-loading .kpi-delta-pill,
.cashflow-strip.is-loading .cashflow-value,
.chart-card.is-loading .chart-total-pill,
.rule-banner.is-loading .rule-values-row strong,
.rule-banner.is-loading .rule-balance-tag span:last-child,
.sheet-grid.is-loading .sheet-col-footer span:last-child {
  position: relative;
  color: transparent !important;
  background: transparent !important;
  border-color: transparent !important;
  user-select: none;
  pointer-events: none;
}

.balance-grid.is-loading .balance-card-val::after,
.balance-grid.is-loading .balance-card-sub::after,
.balance-grid.is-loading .kpi-delta-pill::after,
.cashflow-strip.is-loading .cashflow-value::after,
.chart-card.is-loading .chart-total-pill::after,
.rule-banner.is-loading .rule-values-row strong::after,
.rule-banner.is-loading .rule-balance-tag span:last-child::after,
.sheet-grid.is-loading .sheet-col-footer span:last-child::after {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  border-radius: 6px;
  background: linear-gradient(90deg, var(--bg-subtle) 25%, var(--border-color) 50%, var(--bg-subtle) 75%);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.3s ease-in-out infinite;
}

.balance-grid.is-loading .balance-card-val::after {
  width: 72%;
  height: 26px;
}

.balance-grid.is-loading .balance-card-sub::after {
  width: 84%;
  height: 12px;
}

.balance-grid.is-loading .kpi-delta-pill {
  min-width: 64px;
  min-height: 20px;
}

.balance-grid.is-loading .kpi-delta-pill::after,
.chart-card.is-loading .chart-total-pill::after {
  left: auto;
  right: 0;
  width: 64px;
  height: 18px;
  border-radius: 999px;
}

.chart-card.is-loading .chart-total-pill {
  min-width: 78px;
  min-height: 22px;
}

.chart-card.is-loading .chart-total-pill::after {
  width: 78px;
  height: 22px;
}

.cashflow-strip.is-loading .cashflow-value::after {
  width: 88px;
  height: 16px;
}

.rule-banner.is-loading .rule-values-row strong::after,
.rule-banner.is-loading .rule-balance-tag span:last-child::after,
.sheet-grid.is-loading .sheet-col-footer span:last-child::after {
  left: auto;
  right: 0;
  width: 82px;
  height: 15px;
}

.balance-grid.is-loading .kpi-limit-fill,
.rule-banner.is-loading .rule-progress-fill {
  opacity: 0.35;
  transition: opacity 0.25s ease;
}

.kpi-limit-fill,
.rule-progress-fill {
  transition: width 0.55s cubic-bezier(0.22, 1, 0.36, 1), background-color 0.25s ease, opacity 0.25s ease;
}

/* Overlays de carregamento suave dentro dos gráficos */
.chart-loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  background: color-mix(in srgb, var(--bg-card) 86%, transparent);
  backdrop-filter: blur(2px);
  z-index: 3;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: scale(0.985);
  transition: opacity 0.28s ease, transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), visibility 0s linear 0.28s;
}

.chart-card.is-loading .chart-loading-overlay {
  opacity: 1;
  visibility: visible;
  transform: scale(1);
  transition: opacity 0.16s ease, transform 0.16s ease, visibility 0s linear 0s;
}

.chart-loader-ring {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3.5px solid var(--border-color);
  border-top-color: var(--brand-primary);
  animation: chartRingSpin 0.85s linear infinite;
}

@keyframes chartRingSpin {
  to { transform: rotate(360deg); }
}

.chart-loader-bars {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 36px;
}

.chart-loader-bars span {
  width: 7px;
  border-radius: 4px;
  background: var(--brand-primary);
  opacity: 0.78;
  animation: chartBarWave 1.1s ease-in-out infinite;
}

.chart-loader-bars span:nth-child(1) { height: 18px; animation-delay: 0s; }
.chart-loader-bars span:nth-child(2) { height: 32px; animation-delay: 0.14s; background: var(--accent-green); }
.chart-loader-bars span:nth-child(3) { height: 24px; animation-delay: 0.28s; background: var(--text-dim); }
.chart-loader-bars span:nth-child(4) { height: 28px; animation-delay: 0.42s; }

@keyframes chartBarWave {
  0%, 100% { transform: scaleY(0.5); opacity: 0.45; }
  50% { transform: scaleY(1); opacity: 0.95; }
}

.chart-loader-text {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-dim);
}

.cat-skeleton-row,
.merchant-skeleton-row,
.sheet-skeleton-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-subtle);
}

/* Transição suave ao finalizar o carregamento dos dados */
.data-reveal {
  animation: softDataReveal 0.34s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.balance-grid.data-reveal .balance-card:nth-child(1) .balance-card-val,
.balance-grid.data-reveal .balance-card:nth-child(1) .balance-card-sub { animation: softDataReveal 0.30s cubic-bezier(0.22, 1, 0.36, 1) 0ms both; }
.balance-grid.data-reveal .balance-card:nth-child(2) .balance-card-val,
.balance-grid.data-reveal .balance-card:nth-child(2) .balance-card-sub { animation: softDataReveal 0.30s cubic-bezier(0.22, 1, 0.36, 1) 40ms both; }
.balance-grid.data-reveal .balance-card:nth-child(3) .balance-card-val,
.balance-grid.data-reveal .balance-card:nth-child(3) .balance-card-sub { animation: softDataReveal 0.30s cubic-bezier(0.22, 1, 0.36, 1) 80ms both; }
.balance-grid.data-reveal .balance-card:nth-child(4) .balance-card-val,
.balance-grid.data-reveal .balance-card:nth-child(4) .balance-card-sub { animation: softDataReveal 0.30s cubic-bezier(0.22, 1, 0.36, 1) 120ms both; }
.balance-grid.data-reveal .balance-card:nth-child(5) .balance-card-val,
.balance-grid.data-reveal .balance-card:nth-child(5) .balance-card-sub { animation: softDataReveal 0.30s cubic-bezier(0.22, 1, 0.36, 1) 160ms both; }

@keyframes softDataReveal {
  0% {
    opacity: 0;
    transform: translateY(5px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .header-sync-bar::after,
  body.is-syncing .month-calendar-btn .month-cal-svg,
  .skeleton-value,
  .skeleton-line,
  .balance-grid.is-loading .balance-card-val::after,
  .balance-grid.is-loading .balance-card-sub::after,
  .balance-grid.is-loading .kpi-delta-pill::after,
  .cashflow-strip.is-loading .cashflow-value::after,
  .rule-banner.is-loading .rule-values-row strong::after,
  .rule-banner.is-loading .rule-balance-tag span:last-child::after,
  .sheet-grid.is-loading .sheet-col-footer span:last-child::after,
  .chart-loader-ring,
  .chart-loader-bars span,
  .data-reveal {
    animation: none !important;
    transition: opacity 0.15s ease !important;
  }
}

/* ==========================================================================
   RESPONSIVIDADE: NOTEBOOKS COMPACTOS (<= 1220px) — 5 CARDS EM 3 + 2
   ========================================================================== */
@media (max-width: 1220px) {
  .balance-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: var(--space-4);
  }

  .balance-grid .balance-card:nth-child(-n+3) {
    grid-column: span 2;
  }

  .balance-grid .balance-card:nth-child(n+4) {
    grid-column: span 3;
  }

  .balance-card {
    padding: var(--space-5);
  }

  .balance-card-val {
    font-size: 1.55rem;
  }
}

/* ==========================================================================
   RESPONSIVIDADE: TABLETS & NOTEBOOKS COMPACTOS (<= 1080px)
   ========================================================================== */
@media (max-width: 1080px) {
  .balance-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .balance-grid .balance-card:nth-child(-n+3),
  .balance-grid .balance-card:nth-child(n+4) {
    grid-column: auto;
  }

  .balance-grid .balance-card:last-child {
    grid-column: 1 / -1;
  }

  .analytics-grid {
    grid-template-columns: 1fr;
  }

  .rule-cards-grid,
  .sheet-grid {
    grid-template-columns: 1fr;
  }

  .desktop-action-btn,
  .desktop-only-text,
  .desktop-theme-btn,
  .desktop-profile-widget {
    display: none !important;
  }

  header.header {
    padding: 10px var(--space-4);
  }

  .header-content {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .brand-subtitle,
  .brand-title-row .app-version-badge {
    display: none;
  }

  .mobile-header-tools {
    display: flex;
    align-items: center;
    gap: var(--space-2);
  }

  .mobile-quick-add-btn {
    height: 34px;
    padding: 0 10px;
  }

  .mobile-theme-btn,
  .mobile-user-btn {
    width: 34px;
    height: 34px;
    padding: 0;
    justify-content: center;
  }

  .month-picker-wrapper,
  .month-calendar-btn {
    width: 100%;
    justify-content: center;
  }

  .container {
    padding: var(--space-4) var(--space-3) calc(76px + env(safe-area-inset-bottom));
  }

  .workspace-nav-bar {
    display: none;
  }

  .mobile-bottom-bar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 300;
    background: var(--nav-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--border-color);
    padding: 4px 6px max(6px, env(safe-area-inset-bottom));
    justify-content: space-around;
  }

  .mobile-bottom-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 48px;
    background: none;
    border: none;
    color: var(--text-dim);
    font-family: inherit;
    font-size: 0.68rem;
    font-weight: 600;
    cursor: pointer;
  }

  .mobile-bottom-item.active,
  .mobile-bottom-item.mobile-action-trigger {
    color: var(--brand-primary);
  }

  .mobile-action-pulse {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--brand-primary);
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}

/* ==========================================================================
   RESPONSIVIDADE: MOBILE (<= 768px) — TABELA VIRA CARDS COMPACTOS
   ========================================================================== */
@media (max-width: 768px) {
  .transactions-header {
    gap: var(--space-3);
  }

  .transactions-header-actions {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: var(--space-2);
  }

  .transactions-header-actions .btn {
    width: 100%;
    height: 38px;
    justify-content: center;
  }

  .tx-filters-bar {
    gap: 8px;
  }

  .tx-search-input {
    height: 40px;
  }

  .tx-filter-controls {
    display: grid;
    grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
    gap: 8px;
    width: 100%;
    align-items: stretch;
  }

  .tx-mobile-filters-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    width: 100%;
    height: 40px;
    padding: 0 11px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    min-width: 0;
    transition: border-color var(--transition), background-color var(--transition), color var(--transition);
  }

  .tx-mobile-toggle-left {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
  }

  .tx-mobile-toggle-left svg {
    color: var(--text-dim);
    flex-shrink: 0;
  }

  .tx-mobile-toggle-chevron {
    color: var(--text-dim);
    flex-shrink: 0;
    transition: transform 0.2s ease, color var(--transition);
  }

  .tx-mobile-filters-toggle.is-open {
    border-color: var(--brand-primary);
    background: var(--bg-subtle);
  }

  .tx-mobile-filters-toggle.is-open .tx-mobile-toggle-chevron {
    transform: rotate(180deg);
    color: var(--brand-primary);
  }

  .tx-mobile-filters-toggle.has-active {
    border-color: var(--border-highlight);
    background: var(--brand-soft);
  }

  .tx-mobile-filters-toggle.has-active .tx-mobile-toggle-left svg {
    color: var(--brand-primary);
  }

  .tx-filter-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: var(--radius-pill);
    background: var(--brand-primary);
    color: #ffffff;
    font-size: 0.7rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1;
  }

  .tx-filter-field-sort {
    order: 0;
    width: 100%;
    height: 40px;
    min-width: 0;
  }

  .tx-filter-field-sort .tx-filter-label {
    position: absolute;
    left: 9px;
    top: 50%;
    transform: translateY(-50%);
    padding: 0;
  }

  .tx-filter-field-sort .tx-filter-label::after,
  .tx-filter-field-sort .tx-filter-label-text {
    display: none;
    content: none;
  }

  .tx-filter-field-sort .tx-sort-mobile-icon {
    display: block;
    color: var(--text-dim);
  }

  .tx-filter-field-sort.is-active .tx-sort-mobile-icon {
    color: var(--brand-primary);
  }

  .tx-filter-field-sort .tx-filter-select {
    width: 100%;
    max-width: none;
    height: 100%;
    padding: 0 24px 0 26px;
    font-size: 0.8rem;
    font-weight: 600;
  }

  .tx-filter-field-sort .tx-filter-chevron {
    right: 7px;
  }

  .tx-filter-panel {
    display: none;
    grid-column: 1 / -1;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
    padding: 10px;
    background: var(--bg-subtle);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
  }

  .tx-filters-bar.is-mobile-filters-open .tx-filter-panel {
    display: grid;
    animation: fadeSlideIn 0.16s ease-out;
  }

  .tx-filter-panel .tx-filter-field {
    display: block;
    width: 100%;
    height: 50px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    min-width: 0;
  }

  .tx-filter-panel .tx-filter-field.is-active {
    background: var(--brand-soft);
    border-color: var(--border-highlight);
  }

  .tx-filter-panel .tx-filter-label {
    position: absolute;
    top: 7px;
    left: 10px;
    right: 26px;
    padding: 0;
    font-size: 0.63rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
    line-height: 1.1;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .tx-filter-panel .tx-filter-label::after {
    content: none;
  }

  .tx-filter-panel .tx-filter-select {
    display: block;
    width: 100%;
    max-width: none;
    height: 100%;
    padding: 20px 24px 6px 10px;
    font-size: 0.81rem;
    font-weight: 600;
    line-height: 1.25;
  }

  .tx-filter-panel .tx-filter-chevron {
    top: auto;
    bottom: 10px;
    transform: none;
    right: 8px;
  }

  .tx-reset-filters-btn {
    order: 0;
    grid-column: 1 / -1;
    width: 100%;
    height: 36px;
    justify-content: center;
  }

  .tx-desktop-wrapper {
    display: none;
  }

  .tx-mobile-list {
    display: flex;
  }

  .category-chart-layout {
    grid-template-columns: 1fr;
  }

  .donut-canvas-wrap {
    width: 170px;
    height: 170px;
  }

  .gemini-summary-card {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .gemini-score-box {
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    padding-right: 0;
    padding-bottom: var(--space-3);
  }

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

  .csv-preview-table th:nth-child(4),
  .csv-preview-table td:nth-child(4) {
    display: none;
  }
}

/* ==========================================================================
   RESPONSIVIDADE: SMARTPHONES ESTREITOS (<= 640px)
   ========================================================================== */
@media (max-width: 640px) {
  .balance-grid {
    gap: var(--space-2);
  }

  .balance-card {
    padding: 12px;
    border-radius: var(--radius-md);
    min-width: 0;
  }

  .balance-card-header {
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: var(--space-2);
  }

  .kpi-delta-pill {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.67rem;
    padding: 2px 6px;
  }

  .balance-card-title {
    font-size: 0.65rem;
  }

  .balance-card-val {
    font-size: clamp(1rem, 4.2vw, 1.28rem);
  }

  .balance-card-sub {
    font-size: 0.69rem;
  }

  .cashflow-strip {
    padding: 10px 12px;
    gap: var(--space-2);
  }

  .cashflow-strip-items {
    gap: var(--space-3);
  }

  .cashflow-divider {
    display: none;
  }

  .surface-card {
    padding: var(--space-4);
    border-radius: var(--radius-md);
  }

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

  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="date"],
  select:not(.tx-filter-select) {
    font-size: 16px !important;
  }

  /* Modais & Drawers viram Bottom Sheets nativos no mobile */
  .modal-overlay,
  .modal-drawer-overlay {
    align-items: flex-end;
    justify-content: center;
    padding: 0;
  }

  .modal-card,
  .modal-drawer,
  .modal-drawer-lg {
    max-width: 100%;
    height: auto;
    max-height: 90vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border-bottom: none;
    transform: translateY(0);
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }

  .toast-container {
    top: auto;
    left: 50%;
    right: auto;
    bottom: calc(var(--mobile-nav-height, 64px) + var(--space-3));
    width: calc(100vw - 24px);
    align-items: center;
    transform: translateX(-50%);
  }

  .app-footer-content {
    flex-wrap: wrap;
    align-items: flex-start;
    gap: var(--space-2);
  }

  .app-footer-sep {
    display: none;
  }
}
