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

:root {
  --bg: #f4f6fb;
  --sidebar-bg: #1a1d2e;
  --sidebar-w: 220px;
  --accent: #6c63ff;
  --accent-hover: #574fd6;
  --green: #22c55e;
  --red: #ef4444;
  --blue: #3b82f6;
  --yellow: #f59e0b;
  --white: #ffffff;
  --card-shadow: 0 2px 12px rgba(0,0,0,0.07);
  --radius: 14px;
  --text: #1e1e2e;
  --muted: #6b7280;
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  min-height: 100vh;
  position: fixed;
  top: 0; left: 0;
  display: flex;
  flex-direction: column;
  padding: 28px 16px;
  gap: 8px;
  z-index: 100;
}

.logo {
  color: #fff;
  font-size: 1.25rem;
  font-weight: 700;
  padding: 0 8px 24px;
  letter-spacing: 0.5px;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 14px;
  background: transparent;
  border: none;
  border-radius: 10px;
  color: #9ca3af;
  font-size: 0.92rem;
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
  text-align: left;
}

.nav-btn:hover { background: rgba(255,255,255,0.07); color: #fff; }
.nav-btn.active { background: var(--accent); color: #fff; }
.nav-icon { font-size: 1rem; }

.reset-btn {
  margin-top: auto;
  padding: 10px 14px;
  background: rgba(239,68,68,0.12);
  color: #f87171;
  border: 1px solid rgba(239,68,68,0.25);
  border-radius: 10px;
  font-size: 0.88rem;
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
  text-align: left;
  width: 100%;
}
.reset-btn:hover { background: rgba(239,68,68,0.25); color: #fca5a5; }

/* ── Main ── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 32px 36px;
  max-width: calc(100vw - var(--sidebar-w));
}

/* ── Tabs ── */
.tab { display: none; }
.tab.active { display: block; }

/* ── Page header ── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
}

.page-header h2 { font-size: 1.5rem; font-weight: 700; }

/* ── Buttons ── */
.btn-primary {
  padding: 10px 20px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 9px;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  padding: 10px 20px;
  background: #f3f4f6;
  color: var(--text);
  border: none;
  border-radius: 9px;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s;
}
.btn-secondary:hover { background: #e5e7eb; }

/* ── Summary cards ── */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  margin-bottom: 28px;
}

.card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 22px 20px;
  box-shadow: var(--card-shadow);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 4px; height: 100%;
  border-radius: var(--radius) 0 0 var(--radius);
}

.card-balance::before { background: var(--accent); }
.card-income::before  { background: var(--green); }
.card-expense::before { background: var(--red); }
.card-savings::before { background: var(--blue); }

.card-label {
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 8px;
}

.card h3 { font-size: 1.7rem; font-weight: 700; }
.card-balance h3 { color: var(--text); }
.card-income h3  { color: var(--green); }
.card-expense h3 { color: var(--red); }
.card-savings h3 { color: var(--blue); }

/* ── Charts ── */
.charts-row {
  display: flex;
  gap: 20px;
  margin-bottom: 24px;
  align-items: flex-start;
}

.chart-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--card-shadow);
  flex: 1;
}

.chart-card.wide { flex: 2; }

.chart-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.7px;
  margin-bottom: 16px;
}

/* ── Filters ── */
.filters {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filters input, .filters select {
  padding: 9px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 9px;
  font-size: 0.9rem;
  outline: none;
  background: var(--white);
  transition: border 0.18s;
}

.filters input { flex: 1; min-width: 220px; }
.filters input:focus, .filters select:focus { border-color: var(--accent); }

/* ── Transaction list ── */
#transaction-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tx-item {
  background: var(--white);
  border-radius: 12px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--card-shadow);
  animation: fadeIn 0.2s ease;
}

.tx-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.tx-item.income .tx-icon  { background: #dcfce7; }
.tx-item.expense .tx-icon { background: #fee2e2; }

.tx-body { flex: 1; }
.tx-desc { font-weight: 600; font-size: 0.95rem; }
.tx-meta { font-size: 0.78rem; color: var(--muted); margin-top: 2px; }

.tx-right { display: flex; align-items: center; gap: 10px; }

.tx-amount { font-weight: 700; font-size: 1rem; min-width: 80px; text-align: right; }
.tx-item.income .tx-amount  { color: var(--green); }
.tx-item.expense .tx-amount { color: var(--red); }

.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 5px;
  border-radius: 7px;
  font-size: 0.95rem;
  color: var(--muted);
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: #f3f4f6; color: var(--text); }
.icon-btn.del:hover { background: #fee2e2; color: var(--red); }

.empty-msg {
  text-align: center;
  color: #d1d5db;
  padding: 60px 0;
  font-size: 0.95rem;
}

/* ── Table ── */
.table-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--card-shadow);
}

table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--muted);
  padding: 0 12px 12px;
  border-bottom: 1px solid #f3f4f6;
}
tbody td {
  padding: 12px;
  font-size: 0.9rem;
  border-bottom: 1px solid #f9fafb;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fafafa; }

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-income  { background: #dcfce7; color: #16a34a; }
.badge-expense { background: #fee2e2; color: #dc2626; }
.badge-pos { background: #dcfce7; color: #16a34a; }
.badge-neg { background: #fee2e2; color: #dc2626; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  backdrop-filter: blur(3px);
}
.modal-overlay.hidden { display: none; }

.modal {
  background: var(--white);
  border-radius: 18px;
  padding: 30px;
  width: 460px;
  max-width: 95vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.18);
  animation: slideUp 0.22s ease;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}
.modal-header h3 { font-size: 1.15rem; font-weight: 700; }

.modal-close {
  background: #f3f4f6;
  border: none;
  border-radius: 8px;
  width: 32px; height: 32px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--muted);
  transition: background 0.15s;
}
.modal-close:hover { background: #e5e7eb; }

.form-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-row label { font-size: 0.82rem; font-weight: 600; color: var(--muted); }
.form-row input, .form-row select {
  padding: 10px 13px;
  border: 1.5px solid #e5e7eb;
  border-radius: 9px;
  font-size: 0.93rem;
  outline: none;
  transition: border 0.18s;
}
.form-row input:focus, .form-row select:focus { border-color: var(--accent); }

.two-col { flex-direction: row; gap: 14px; }
.two-col > div { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.two-col label { font-size: 0.82rem; font-weight: 600; color: var(--muted); }

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

/* ── Animations ── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-5px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Responsive ── */
@media (max-width: 900px) {
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-row { flex-direction: column; }
  .chart-card.wide { flex: unset; }
}

@media (max-width: 640px) {
  .sidebar { width: 64px; padding: 20px 8px; }
  .logo, .nav-btn span:not(.nav-icon) { display: none; }
  .nav-btn { justify-content: center; padding: 12px; }
  .main-content { margin-left: 64px; padding: 20px 16px; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
}
