/* ==========================================================================
   eRAsolar Cloud System - Control de Presupuesto y Ejecución Presupuestal
   Design System: Pro-Elite Dark & Light Fusion, Glassmorphism, Tailwind Compatible
   ========================================================================== */

:root {
  --era-navy: #0f172a;
  --era-navy-deep: #070b14;
  --era-navy-light: #1e293b;
  --era-gold: #fdb813;
  --era-gold-hover: #e5a40b;
  --era-orange: #f97316;
  --era-blue: #0ea5e9;
  --era-emerald: #10b981;
  --era-emerald-dark: #059669;
  --era-red: #ef4444;
  --era-purple: #8b5cf6;
  --era-slate-50: #f8fafc;
  --era-slate-100: #f1f5f9;
  --era-slate-200: #e2e8f0;
  --era-slate-300: #cbd5e1;
  --era-slate-400: #94a3b8;
  --era-slate-500: #64748b;
  --era-slate-600: #475569;
  --era-slate-700: #334155;
  --era-slate-800: #1e293b;
  --era-slate-900: #0f172a;

  --font-brand: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 16px 40px rgba(15, 23, 42, 0.12);
  --shadow-gold: 0 8px 25px rgba(253, 184, 19, 0.25);
}

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

body {
  font-family: var(--font-body);
  background: #f8fafc;
  color: var(--era-slate-800);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
}

h1, h2, h3, h4, .font-brand {
  font-family: var(--font-brand);
}

/* App Container */
.budget-app-container {
  max-width: 1480px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 3rem;
}

/* Glass Header */
.budget-header {
  background: var(--era-navy);
  color: white;
  border-radius: var(--radius-lg);
  padding: 1rem 1.5rem;
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand-logo-img {
  max-height: 42px;
  width: auto;
  object-fit: contain;
}

.brand-titles h1 {
  font-size: 1.35rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: white;
  letter-spacing: -0.02em;
}

.brand-tag {
  background: linear-gradient(135deg, var(--era-gold), #f59e0b);
  color: var(--era-navy-deep);
  font-size: 0.68rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.brand-sub {
  font-size: 0.78rem;
  color: var(--era-slate-400);
}

/* Navigation & Session Controls */
.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.nav-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.12);
  text-decoration: none;
  transition: all 0.2s ease;
  cursor: pointer;
}

.nav-pill-btn:hover {
  background: rgba(253, 184, 19, 0.15);
  color: var(--era-gold);
  border-color: rgba(253, 184, 19, 0.4);
  transform: translateY(-1px);
}

.nav-pill-btn.active {
  background: var(--era-gold);
  color: var(--era-navy);
  font-weight: 700;
  border-color: var(--era-gold);
}

/* Selector Bar */
.project-banner {
  background: white;
  border-radius: var(--radius-md);
  padding: 1rem 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--era-slate-200);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1.5rem;
}

@media (max-width: 900px) {
  .project-banner {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}

.project-select-wrapper {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--era-slate-50);
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--era-slate-200);
  min-width: 280px;
}

.project-select-wrapper:focus-within {
  border-color: var(--era-gold);
  box-shadow: 0 0 0 3px rgba(253, 184, 19, 0.15);
}

.project-select {
  border: none;
  background: transparent;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--era-slate-800);
  width: 100%;
  outline: none;
  cursor: pointer;
}

.project-meta-badges {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.meta-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  background: var(--era-slate-100);
  color: var(--era-slate-700);
  border: 1px solid var(--era-slate-200);
}

.meta-badge.highlight {
  background: rgba(253, 184, 19, 0.12);
  color: #92400e;
  border-color: rgba(253, 184, 19, 0.3);
}

.meta-badge.emerald {
  background: #dcfce7;
  color: #166534;
  border-color: #bbf7d0;
}

.meta-badge.blue {
  background: #e0f2fe;
  color: #0369a1;
  border-color: #bae6fd;
}

/* KPI Cards Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.kpi-card {
  background: white;
  border-radius: var(--radius-md);
  padding: 1.25rem;
  border: 1px solid var(--era-slate-200);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--card-accent, var(--era-gold));
}

.kpi-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.6rem;
}

.kpi-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--era-slate-500);
}

.kpi-icon-wrap {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--icon-bg, #fef3c7);
  color: var(--icon-color, #d97706);
}

.kpi-value {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--era-slate-900);
  font-family: var(--font-brand);
  line-height: 1.1;
  margin-bottom: 0.35rem;
}

.kpi-subtext {
  font-size: 0.78rem;
  color: var(--era-slate-500);
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

/* Master Progress Bar */
.master-progress-card {
  background: white;
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  border: 1px solid var(--era-slate-200);
  box-shadow: var(--shadow-sm);
}

.master-progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.progress-track {
  width: 100%;
  height: 14px;
  background: var(--era-slate-100);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
  border: 1px solid var(--era-slate-200);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #10b981, #f59e0b);
  border-radius: 999px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-fill.over-budget {
  background: linear-gradient(90deg, #f59e0b, #ef4444);
}

/* Category Progress Bars Grid */
.category-progress-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--era-slate-100);
}

.cat-progress-item {
  background: var(--era-slate-50);
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--era-slate-200);
}

.cat-progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
  color: var(--era-slate-700);
}

.cat-progress-bar {
  width: 100%;
  height: 6px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.cat-progress-bar-inner {
  height: 100%;
  border-radius: 999px;
  background: var(--bar-color, var(--era-gold));
  transition: width 0.4s ease;
}

/* Layout 2 Columns: Baseline vs Purchases */
.main-budget-grid {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 1100px) {
  .main-budget-grid {
    grid-template-columns: 1fr;
  }
}

/* Section Cards */
.section-card {
  background: white;
  border-radius: var(--radius-md);
  border: 1px solid var(--era-slate-200);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.section-card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--era-slate-200);
  background: var(--era-slate-50);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.section-card-header h3 {
  font-size: 1rem;
  font-weight: 800;
  color: var(--era-slate-900);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section-card-body {
  padding: 1.25rem;
  flex: 1;
}

/* Data Tables */
.table-wrapper {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--era-slate-200);
}

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

.era-table thead {
  background: var(--era-slate-100);
  border-bottom: 2px solid var(--era-slate-200);
}

.era-table th {
  padding: 0.6rem 0.75rem;
  font-weight: 700;
  color: var(--era-slate-600);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.era-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--era-slate-100);
  color: var(--era-slate-800);
  vertical-align: middle;
}

.era-table tbody tr:hover {
  background: #f8fafc;
}

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

/* Badges for VAT (IVA) */
.badge-iva {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

.badge-iva.exento {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

.badge-iva.gravado {
  background: #e0e7ff;
  color: #4338ca;
  border: 1px solid #c7d2fe;
}

.badge-status {
  display: inline-flex;
  align-items: center;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
}

.badge-status.pagado {
  background: #dcfce7;
  color: #166534;
}

.badge-status.pendiente {
  background: #fef3c7;
  color: #b45309;
}

.badge-status.abono {
  background: #e0f2fe;
  color: #0369a1;
}

/* Buttons */
.btn-primary {
  background: var(--era-navy);
  color: white;
  border: none;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
}

.btn-primary:hover {
  background: var(--era-slate-800);
  transform: translateY(-1px);
}

.btn-gold {
  background: var(--era-gold);
  color: var(--era-navy-deep);
  border: none;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  box-shadow: 0 4px 12px rgba(253, 184, 19, 0.25);
  transition: all 0.2s ease;
}

.btn-gold:hover {
  background: var(--era-gold-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--era-slate-100);
  color: var(--era-slate-700);
  border: 1px solid var(--era-slate-200);
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: var(--era-slate-200);
}

.btn-danger {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fecaca;
  padding: 0.3rem 0.5rem;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  transition: all 0.15s ease;
}

.btn-danger:hover {
  background: #fca5a5;
}

.btn-icon {
  background: transparent;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: var(--era-slate-500);
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover {
  background: var(--era-slate-100);
  color: var(--era-slate-800);
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-container {
  background: white;
  border-radius: var(--radius-lg);
  max-width: 680px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.35);
  border: 1px solid var(--era-slate-200);
  transform: translateY(20px) scale(0.97);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.active .modal-container {
  transform: translateY(0) scale(1);
}

.modal-header {
  padding: 1.15rem 1.4rem;
  border-bottom: 1px solid var(--era-slate-200);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--era-slate-50);
}

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--era-slate-900);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 1.25rem;
  color: var(--era-slate-400);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: var(--era-slate-200);
  color: var(--era-slate-700);
}

.modal-body {
  padding: 1.4rem;
}

.modal-footer {
  padding: 0.9rem 1.4rem;
  border-top: 1px solid var(--era-slate-200);
  background: var(--era-slate-50);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

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

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

.form-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--era-slate-700);
}

.form-control {
  padding: 0.55rem 0.75rem;
  border: 1.5px solid var(--era-slate-300);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-family: var(--font-body);
  color: var(--era-slate-800);
  background: white;
  transition: all 0.2s ease;
}

.form-control:focus {
  border-color: var(--era-gold);
  outline: none;
  box-shadow: 0 0 0 3px rgba(253, 184, 19, 0.15);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--era-navy);
  color: white;
  padding: 0.75rem 1.15rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
  border-left: 4px solid var(--era-gold);
  animation: slideIn 0.3s ease;
}

.toast.success {
  border-left-color: var(--era-emerald);
}

.toast.error {
  border-left-color: var(--era-red);
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}
