:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --text: #111827;
  --muted: #6b7280;
  --border: #d1d5db;
  --danger: #ef4444;
  --success: #10b981;
  --surface-alt: #f8fafc;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.container {
  width: min(1140px, calc(100% - 32px));
  margin: 0 auto;
  padding: 0;
}

.header {
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: white;
  padding: 24px 0;
  margin-bottom: 24px;
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.header h1 {
  margin: 0 0 8px;
  font-size: clamp(1.8rem, 2.5vw, 2.5rem);
}

.header p {
  margin: 0;
  color: rgba(255, 255, 255, 0.88);
}

.income-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin: 20px 0;
}

.income-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 14px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  font-size: 0.95rem;
  font-weight: 600;
}

.income-button:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
  transform: translateY(-2px);
}

.income-button.highlight {
  background: linear-gradient(135deg, #3b82f6, #1e40af);
  color: white;
  border-color: #1e40af;
}

.income-button .value {
  font-size: 1.3rem;
  font-weight: 700;
  word-break: break-word;
}

.toggle-visibility {
  position: absolute;
  top: 8px;
  right: 8px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 1.2rem;
  padding: 4px 8px;
}

.savings-goal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  margin: 20px 0;
}

.savings-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
  font-weight: 600;
}

.progress-bar {
  width: 100%;
  height: 24px;
  background: #e5e7eb;
  border-radius: 12px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--success));
  width: 0%;
  transition: width 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  color: white;
  font-weight: 600;
  font-size: 0.75rem;
}

.category-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin: 20px 0;
}

.category-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.9rem;
  font-weight: 600;
}

.category-btn:hover {
  border-color: var(--primary);
  background: #eef6ff;
  transform: translateY(-2px);
}

.category-btn .amount {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--primary);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
  overflow: hidden;
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}

.card-header h2 {
  margin: 0;
  font-size: 1.15rem;
}

.card-body {
  padding: 20px;
}

.collapsible.closed .card-body {
  display: none;
}

.collapsible.closed .card-header {
  border-bottom: none;
}

.toggle-section {
  border: none;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
  font-weight: 600;
  padding: 4px 8px;
}

h2,
h3 {
  margin-top: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1.25rem;
}

h3 {
  margin-bottom: 14px;
  margin-top: 16px;
  font-size: 1rem;
  color: var(--muted);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.filter-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  align-items: flex-end;
}

.form-group {
  display: grid;
  gap: 8px;
  margin-bottom: 0;
}

label {
  font-weight: 600;
  font-size: 0.95rem;
}

input,
select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 0.95rem;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.primary-button,
.secondary-button,
.action-button {
  border: none;
  border-radius: 12px;
  font-size: 0.95rem;
  padding: 10px 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 600;
}

.primary-button {
  width: 100%;
  background: var(--primary);
  color: white;
}

.primary-button:hover {
  background: var(--primary-dark);
}

.secondary-button {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.secondary-button:hover,
.secondary-button.active {
  background: rgba(59, 130, 246, 0.14);
  border-color: var(--primary);
}

.action-button {
  background: transparent;
  color: var(--danger);
}

.action-button:hover {
  background: rgba(239, 68, 68, 0.1);
}

.purchase-actions,
.service-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.alerts-list,
.purchases-list,
.services-list,
.category-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.alert-item,
.purchase-item--bought,
.service-item--paid,
.purchases-list li,
.services-list li {
  padding: 12px 14px;
  border-radius: 12px;
  background: #f8fafc;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.alert-item {
  background: #fef2f2;
  border: 1px solid #fecaca;
}

.alert-item.alert-warning {
  border-left: 4px solid var(--danger);
}

.alert-detail {
  font-size: 0.85rem;
  color: var(--muted);
  width: 100%;
}

.purchase-item--bought,
.service-item--paid {
  opacity: 0.6;
}

.purchase-item--bought span,
.service-item--paid span {
  text-decoration: line-through;
}

.purchases-list li > div,
.services-list li > div {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.empty-row {
  padding: 24px 12px !important;
  text-align: center;
  color: var(--muted);
  background: transparent !important;
  margin-bottom: 0 !important;
}

.table-card table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0;
}

.table-card th,
.table-card td {
  text-align: left;
  padding: 12px;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}

.table-card th {
  background: #f9fafb;
  color: var(--muted);
  font-weight: 600;
}

.table-card tbody tr:nth-child(even) {
  background: #fbfdff;
}

.monthly-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
}

.stat-card {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
}

.stat-card.alert {
  background: #fef2f2;
  border-color: var(--danger);
}

.stat-card.success {
  background: #f0fdf4;
  border-color: var(--success);
}

.stat-label {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
}

.stat-value {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
}

.stat-percent {
  font-size: 0.8rem;
  color: var(--muted);
}

.small-text {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.9rem;
}

.budget-form {
  margin-top: 16px;
}

.export-button-row {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.export-button-row .primary-button {
  max-width: 200px;
}

@media (max-width: 768px) {
  .header h1 {
    font-size: 1.5rem;
  }

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

  .category-buttons {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  }

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

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

@media (max-width: 480px) {
  .container {
    width: calc(100% - 16px);
  }

  .income-summary {
    grid-template-columns: 1fr;
  }

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

  .income-button {
    padding: 12px 10px;
  }

  .category-btn {
    padding: 12px 10px;
  }
}
