/* ==========================================================================
   ESTILOS GLOBAIS & TEMA FINTECH PREMIUM (ITAÚ / NUBANK STYLE)
   ========================================================================== */

:root {
  --bg-main: #0a0e17;
  --bg-card: #121826;
  --bg-card-hover: #172033;
  --bg-input: #1a2236;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: #3b82f6;

  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;

  --accent-primary: #3b82f6;
  --accent-primary-hover: #2563eb;
  --accent-success: #10b981;
  --accent-success-hover: #059669;
  --accent-warning: #f59e0b;
  --accent-danger: #ef4444;
  --accent-purple: #8b5cf6;
  --itau-orange: #ec7000;
  --gold-accent: #eab308;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 22px;

  --shadow-card: 0 8px 24px -4px rgba(0, 0, 0, 0.45);
  --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.25);
  --shadow-success-glow: 0 0 20px rgba(16, 185, 129, 0.35);
  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'Inter', system-ui, sans-serif; /* Usamos Inter com tabular-nums para números limpos sem zeros cortados */
}

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

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  padding-bottom: 60px;
}

/* Container Principal */
.app-container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 24px 20px;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
  gap: 16px;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-icon {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--itau-orange), #ff9800);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 22px;
  box-shadow: 0 4px 12px rgba(236, 112, 0, 0.35);
}

.brand-title {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff;
}

.brand-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 2px;
}

.card-pill-tag {
  background: rgba(234, 179, 8, 0.15);
  color: var(--gold-accent);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  border: 1px solid rgba(234, 179, 8, 0.3);
}

/* Indicador de Sincronização */
.sync-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid transparent;
}

.sync-live {
  background: rgba(16, 185, 129, 0.12);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.25);
}

.sync-saving {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border-color: rgba(59, 130, 246, 0.3);
}

.sync-offline {
  background: rgba(245, 158, 11, 0.12);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.25);
}

.sync-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: currentColor;
  box-shadow: 0 0 8px currentColor;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Cartões do Topo - 3 Colunas Simétricas no Desktop */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}

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

.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: border-color 0.2s ease;
}

.card:hover {
  border-color: rgba(255, 255, 255, 0.14);
}

.card-hero {
  background: linear-gradient(135deg, #131b2e 0%, #15223c 100%);
  border: 1px solid rgba(59, 130, 246, 0.25);
  position: relative;
  overflow: hidden;
}

.card-hero::after {
  content: "";
  position: absolute;
  top: -50%;
  right: -20%;
  width: 250px;
  height: 250px;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.12) 0%, transparent 70%);
  pointer-events: none;
}

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

.card-caption {
  font-size: 0.78rem;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.card-amount {
  font-size: 2.1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
  font-variant-numeric: tabular-nums;
  margin-top: 4px;
  margin-bottom: 4px;
}

.card-amount-sm {
  font-size: 1.55rem;
  font-weight: 700;
}

/* Navegador de Mês */
.month-selector-bar {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-input);
  padding: 4px 8px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.month-label-display {
  font-size: 0.95rem;
  font-weight: 700;
  min-width: 140px;
  text-align: center;
  color: #fff;
}

.btn-nav-month {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.btn-nav-month:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

/* Badges de Status */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.status-open {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.status-paid {
  background: rgba(16, 185, 129, 0.18);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.35);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.2);
}

/* Botões */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
  text-decoration: none;
}

.btn-device {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(124, 58, 237, 0.3);
}

.btn-device:hover {
  filter: brightness(1.15);
}

.btn-primary {
  background-color: var(--accent-primary);
  color: #fff;
}

.btn-primary:hover {
  background-color: var(--accent-primary-hover);
  box-shadow: var(--shadow-glow);
}

.btn-pay {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #fff;
  font-size: 0.95rem;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-success-glow);
  width: 100%;
}

.btn-pay:hover {
  filter: brightness(1.1);
}

.btn-pay.pulse {
  animation: pulse-glow 2.5s infinite;
}

@keyframes pulse-glow {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5); }
  70% { box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.btn-secondary {
  background-color: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

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

.btn-outline:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.25);
}

.btn-icon {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Barra de Progresso do Limite */
.progress-container {
  width: 100%;
  height: 8px;
  background-color: var(--bg-input);
  border-radius: 999px;
  overflow: hidden;
  margin: 10px 0 8px;
  border: 1px solid var(--border-color);
}

.progress-fill {
  height: 100%;
  transition: width 0.4s ease;
}

.bg-success { background: linear-gradient(90deg, #10b981, #34d399); }
.bg-warning { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.bg-danger { background: linear-gradient(90deg, #ef4444, #f87171); }

.limit-stats {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Projeção Timeline e Gráfico de Barras */
.timeline-section {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 22px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-card);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.section-title {
  font-size: 1.15rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.timeline-scroll-container {
  display: flex;
  gap: 8px;
  justify-content: space-between;
  padding: 10px 2px 14px 2px;
  overflow-x: auto;
}

.timeline-bar-col {
  flex: 1;
  min-width: 78px;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  padding: 8px 4px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  transition: all 0.2s ease;
  user-select: none;
}

.timeline-bar-col:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.1);
}

.timeline-bar-col.selected {
  background: rgba(59, 130, 246, 0.12);
  border-color: rgba(59, 130, 246, 0.5);
  box-shadow: 0 0 14px rgba(59, 130, 246, 0.15);
}

.timeline-bar-val {
  font-size: 0.72rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  margin-bottom: 8px;
  text-align: center;
  white-space: nowrap;
}

.timeline-bar-col.selected .timeline-bar-val {
  color: #fff;
}

.timeline-bar-track {
  width: 28px;
  height: 110px;
  background: var(--bg-input);
  border-radius: 6px;
  display: flex;
  align-items: flex-end;
  padding: 3px;
  margin-bottom: 8px;
}

.timeline-bar-fill {
  width: 100%;
  border-radius: 4px;
  transition: height 0.3s ease;
}

.bar-projected {
  background: linear-gradient(180deg, #3b82f6, #1d4ed8);
}

.bar-selected {
  background: linear-gradient(180deg, #60a5fa, #2563eb);
  box-shadow: 0 0 8px rgba(96, 165, 250, 0.6);
}

.bar-paid {
  background: linear-gradient(180deg, #10b981, #059669);
  opacity: 0.85;
}

.timeline-bar-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 4px;
}

.timeline-bar-badge {
  height: 18px;
}

.timeline-tag {
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 700;
  text-transform: uppercase;
}

.tag-paid {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
}

.tag-current {
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
}

/* Área da Tabela de Transações */
.transactions-section {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-card);
}

.table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.search-input-wrapper {
  position: relative;
  flex: 1;
  min-width: 240px;
}

.search-input-wrapper input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: #fff;
  padding: 9px 14px 9px 36px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.2s;
}

.search-input-wrapper input:focus {
  border-color: var(--border-focus);
}

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

.table-filter-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-tab {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 7px 12px;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.2s;
}

.filter-tab.active {
  background: var(--accent-primary);
  color: #fff;
  border-color: var(--accent-primary);
}

.select-filter {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 7px 12px;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  outline: none;
}

/* Tabela */
.table-responsive {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.88rem;
}

.data-table th {
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border-color);
}

.data-table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--border-color);
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.tr-negative {
  background: rgba(16, 185, 129, 0.04);
}

.item-desc {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.category-pill {
  font-size: 0.72rem;
  color: var(--text-muted);
  background: var(--bg-input);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  font-size: 0.74rem;
  font-weight: 600;
}

.badge-installment {
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
  font-variant-numeric: tabular-nums;
}

.badge-single {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}

.badge-warning {
  background: rgba(245, 158, 11, 0.2);
  color: #fcd34d;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

/* Modais */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  padding: 16px;
}

.modal-backdrop.modal-open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  max-width: 520px;
  width: 100%;
  padding: 26px;
  box-shadow: var(--shadow-card);
  transform: translateY(15px);
  transition: transform 0.2s ease;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-backdrop.modal-open .modal-card {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
}

.form-group {
  margin-bottom: 16px;
}

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

.form-control {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: #fff;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  outline: none;
}

.form-control:focus {
  border-color: var(--border-focus);
}

.radio-group {
  display: flex;
  gap: 16px;
  margin-top: 6px;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--text-muted);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

@media (max-width: 540px) {
  .form-row {
    grid-template-columns: 1fr;
  }
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

/* Notificações Toasts */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 2000;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  font-size: 0.88rem;
  min-width: 280px;
  max-width: 400px;
  transition: all 0.3s ease;
}

.toast-success {
  border-left: 4px solid var(--accent-success);
}

.toast-info {
  border-left: 4px solid var(--accent-primary);
}

.toast-error {
  border-left: 4px solid var(--accent-danger);
}

.toast-icon {
  font-weight: 700;
  font-size: 1rem;
}

.toast-out {
  opacity: 0;
  transform: translateX(30px);
}

/* Responsividade Mobile Refinada */
@media (max-width: 768px) {
  .app-container {
    padding: 16px 12px;
  }

  .app-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .month-selector-bar {
    width: 100%;
    justify-content: space-between;
  }

  .month-label-display {
    min-width: auto;
    font-size: 0.95rem;
  }

  .card-amount {
    font-size: 1.8rem;
  }

  .data-table th, .data-table td {
    padding: 10px 8px;
    font-size: 0.8rem;
  }

  #toast-container {
    left: 16px;
    right: 16px;
    bottom: 16px;
  }

  .toast {
    min-width: auto;
    max-width: 100%;
  }
}

/* Classes Utilitárias */
.font-mono {
  font-variant-numeric: tabular-nums;
}
.font-semibold { font-weight: 600; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-dim { color: var(--text-dim); }
.text-primary { color: #60a5fa; }
.text-success { color: #34d399; }
.text-danger { color: #f87171; }
.text-xs { font-size: 0.72rem; }
.py-8 { padding-top: 32px; padding-bottom: 32px; }
