.budget-container {
  padding: 0.5rem;
  padding-bottom: 80px;
  max-width: 600px;
  margin: 0 auto;
}

/* Total Spending Section */
.total-spending-section {
  margin-bottom: 0.75rem;
}

.total-spending-card {
  background: var(--white);
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

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

.budget-summary-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-color);
}

.budget-summary-pill {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.budget-summary-pill.is-over {
  background-color: rgba(220, 53, 69, 0.12);
  color: #c62828;
}

.budget-summary-pill.is-under {
  background-color: rgba(40, 167, 69, 0.12);
  color: #2e7d32;
}

.budget-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

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

.budget-summary-metric {
  background: #f8f9fa;
  border-radius: 10px;
  padding: 0.75rem;
}

.budget-summary-label {
  font-size: 0.75rem;
  color: #6c757d;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 0.25rem;
}

.budget-summary-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: #1a1a1a;
}

.text-positive {
  color: #2e7d32;
}

.text-negative {
  color: #c62828;
}

.budget-summary-status {
  font-size: 0.85rem;
  margin-top: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  line-height: 1.4;
}

.budget-summary-status--over {
  background-color: rgba(220, 53, 69, 0.08);
  color: #c62828;
}

.budget-summary-status--under {
  background-color: rgba(40, 167, 69, 0.08);
  color: #2e7d32;
}

/* Date Range Display */
.date-range-display {
  background: #f8f9fa;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.date-range-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #6c757d;
}

.date-range-value {
  font-size: 0.75rem;
  color: #1a1a1a;
  font-weight: 500;
}

/* Category Breakdown Section */
.category-breakdown-section {
  margin-bottom: 0.75rem;
}

.category-breakdown-section h2 {
  font-size: 1rem;
  font-weight: 700;
  color: #1a1a1a;
  margin: 0 0 0.5rem 0;
}

.category-table {
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  overflow: hidden;
}

.category-table-header {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  background: #f8f9fa;
  border-bottom: 1px solid #e0e0e0;
  font-size: 0.75rem;
  color: #6c757d;
  font-weight: 600;
  text-transform: uppercase;
}

.category-table-header span {
  flex: 1;
  text-align: right;
}

.category-table-header .header-label {
  text-align: left;
  flex: 1.4;
}

.category-row,
.subcategory-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #f0f0f0;
}

.category-row {
  cursor: pointer;
  transition: background-color 0.15s;
}

.category-row:hover {
  background-color: #f8f9fa;
}

.category-row:last-child {
  border-bottom: none;
}

.category-cell {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
}

.arrow {
  font-size: 0.625rem;
  color: #6c757d;
  width: 0.75rem;
  display: inline-block;
  text-align: center;
}

.arrow-placeholder {
  width: 0.75rem;
  display: inline-block;
}

.category-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #1a1a1a;
}

.amount-group {
  display: flex;
  gap: 0.5rem;
  flex: 1;
  justify-content: flex-end;
}

.amount-cell {
  text-align: right;
  min-width: 90px;
  flex: 1;
}

.amount-cell .amount-value {
  font-size: 0.8125rem;
  font-weight: 600;
}

.amount-cell--spent .amount-value {
  color: #212529;
}

.amount-cell--budget .amount-value {
  color: #0069d9;
}

.subcategory-row .amount-value {
  font-size: 0.75rem;
}

.budget-value-button {
  width: 100%;
  text-align: right;
  border: none;
  background: transparent;
  font-weight: 600;
  color: #0069d9;
  cursor: pointer;
  padding: 0;
}

.budget-value-button:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* Subcategories */
.subcategory-rows {
  background-color: #f8f9fa;
  border-top: 1px solid #e0e0e0;
}

.subcategory-row {
  padding-left: 2rem;
}

.subcategory-row:last-child {
  border-bottom: 1px solid #f0f0f0;
}

.subcategory-cell {
  font-size: 0.75rem;
  color: #495057;
  flex: 1.4;
}

/* Modal */
.budget-allocation-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.budget-allocation-modal.is-visible {
  display: flex;
}

.budget-allocation-overlay {
  position: absolute;
  inset: 0;
}

.budget-allocation-panel {
  position: relative;
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: 16px;
  padding: 1.25rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
  animation: modalFadeIn 0.2s ease;
  z-index: 1;
}

.budget-allocation-title {
  text-align: center;
  margin-bottom: 1rem;
  font-size: 1rem;
  font-weight: 600;
}

.budget-allocation-form .form-group {
  margin-bottom: 1rem;
}

#budget-allocation-errors .budget-error {
  color: #d9534f;
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}

.budget-error-actions {
  margin-top: 0.5rem;
}

.modal-actions {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ======================================
   BUDGET GAUGE STYLES
   ====================================== */
.budget-gauge-section {
  background: var(--white);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 0.75rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.budget-gauge-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.budget-gauge-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-color);
}

.budget-gauge-percentage {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
}

.budget-gauge-percentage.budget-gauge--healthy {
  background: rgba(40, 167, 69, 0.12);
  color: #2e7d32;
}

.budget-gauge-percentage.budget-gauge--warning {
  background: rgba(255, 152, 0, 0.12);
  color: #f57c00;
}

.budget-gauge-percentage.budget-gauge--over {
  background: rgba(220, 53, 69, 0.12);
  color: #c62828;
}

.budget-gauge-container {
  margin-top: 0.5rem;
}

.budget-gauge-track {
  height: 12px;
  background: linear-gradient(90deg, #4CAF50 0%, #8BC34A 25%, #FFEB3B 50%, #FF9800 75%, #f44336 100%);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}

.budget-gauge-bar {
  position: absolute;
  right: 0;
  top: 0;
  height: 100%;
  background: #e0e0e0;
  transition: width 0.8s ease-out;
}

.budget-gauge-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 0.25rem;
  font-size: 0.7rem;
  color: #6c757d;
}

/* ======================================
   BUDGET METRICS STYLES
   ====================================== */
.budget-metrics-section {
  margin-bottom: 0.75rem;
}

.budget-metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}

.budget-metric-card {
  background: var(--white);
  border-radius: 10px;
  padding: 0.75rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.budget-metric-card--wide {
  grid-column: span 2;
}

.budget-metric-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: #6c757d;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 0.25rem;
}

.budget-metric-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-color);
  margin-bottom: 0.125rem;
}

.budget-metric-sub {
  font-size: 0.7rem;
  color: #9e9e9e;
}

/* Comparison icons */
.comparison-icon {
  display: inline-block;
  width: 0;
  height: 0;
  margin-right: 0.25rem;
  vertical-align: middle;
}

.comparison-icon--increase {
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 6px solid #c62828;
}

.comparison-icon--decrease {
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid #2e7d32;
}

/* ======================================
   CHART CONTAINER VARIANTS
   ====================================== */
.chart-container--doughnut {
  max-height: 280px;
  display: flex;
  justify-content: center;
  padding: 0.5rem;
}

.chart-container--doughnut canvas {
  max-height: 280px;
}

.chart-container--bar {
  min-height: 150px;
}

/* ======================================
   MOBILE RESPONSIVE
   ====================================== */
@media (max-width: 520px) {
  .budget-metrics-grid {
    grid-template-columns: 1fr;
  }

  .budget-metric-card--wide {
    grid-column: span 1;
  }

  .budget-gauge-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }

  .budget-metric-value {
    font-size: 1.125rem;
  }
}
