@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Fraunces:ital,opsz,wght@0,9..144,300;0,9..144,600;1,9..144,300&family=DM+Sans:wght@300;400;500&display=swap');

:root {
  --bg:         #0f0f11;
  --surface:    #17171a;
  --surface2:   #1e1e23;
  --border:     #2a2a32;
  --accent:     #7c6af7;
  --accent2:    #f7a26a;
  --green:      #4ecb8d;
  --red:        #f26c6c;
  --text:       #e8e8f0;
  --text-muted: #6b6b80;
  --text-dim:   #9696a8;
  --radius:     12px;
  --radius-sm:  8px;
  --mono:       'DM Mono', monospace;
  --sans:       'DM Sans', sans-serif;
  --serif:      'Fraunces', serif;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Layout ─────────────────────────────────── */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-logo {
  padding: 0 20px 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.sidebar-logo h1 {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 300;
  letter-spacing: -0.5px;
  color: var(--text);
}

.sidebar-logo span {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--mono);
  letter-spacing: 0.5px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 400;
  cursor: pointer;
  transition: all 0.15s;
  border-left: 2px solid transparent;
  margin: 1px 0;
}

.nav-item:hover {
  color: var(--text);
  background: var(--surface2);
}

.nav-item.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: rgba(124, 106, 247, 0.08);
}

.nav-item svg { flex-shrink: 0; }

.nav-section {
  padding: 16px 20px 6px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  font-family: var(--mono);
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 500;
  color: white;
  flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.logout-btn {
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  font-family: var(--sans);
  transition: color 0.15s;
}
.logout-btn:hover { color: var(--red); }

.main-content {
  margin-left: 220px;
  flex: 1;
  padding: 32px;
  max-width: 1200px;
}

/* ── Page Header ─────────────────────────────── */

.page-header {
  margin-bottom: 28px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.page-title {
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 300;
  letter-spacing: -0.5px;
  line-height: 1.2;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Cards ───────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.card-sm { padding: 16px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  font-family: var(--mono);
  margin-bottom: 8px;
}

.stat-value {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.5px;
  color: var(--text);
}

.stat-value.green { color: var(--green); }
.stat-value.red { color: var(--red); }
.stat-value.accent { color: var(--accent); }

/* ── Budget Progress Bars ────────────────────── */

.budget-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}

.budget-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: border-color 0.15s;
}

.budget-item:hover { border-color: var(--accent); }

.budget-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}

.budget-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.budget-account {
  font-size: 10px;
  font-family: var(--mono);
  color: var(--text-muted);
  background: var(--surface2);
  padding: 2px 6px;
  border-radius: 4px;
}

.budget-amounts {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}

.budget-spent {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-dim);
}

.budget-remaining {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
}

.budget-remaining.ok { color: var(--green); }
.budget-remaining.warn { color: var(--accent2); }
.budget-remaining.over { color: var(--red); }

.progress-bar {
  height: 4px;
  background: var(--surface2);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.5s ease;
  background: var(--green);
}

.progress-fill.warn { background: var(--accent2); }
.progress-fill.over { background: var(--red); width: 100% !important; }

/* ── Buttons ─────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: none;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: white;
}
.btn-primary:hover { background: #6a58e0; }

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

.btn-danger {
  background: transparent;
  color: var(--red);
  border: 1px solid var(--red);
}
.btn-danger:hover { background: rgba(242, 108, 108, 0.1); }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-icon { padding: 8px; width: 34px; height: 34px; justify-content: center; }

/* ── Forms ───────────────────────────────────── */

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

.form-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  font-family: var(--mono);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  transition: border-color 0.15s;
  outline: none;
  appearance: none;
}

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

.form-control option { background: var(--surface2); }

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

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

/* ── Tables ──────────────────────────────────── */

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  padding: 12px 16px;
  text-align: left;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  font-family: var(--mono);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface2); }

tbody td {
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text);
  vertical-align: middle;
}

.mono { font-family: var(--mono); }
.amount-positive { color: var(--green); font-family: var(--mono); }
.amount-negative { color: var(--red); font-family: var(--mono); }

/* ── Badge ───────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-family: var(--mono);
  font-weight: 500;
}

.badge-income { background: rgba(78, 203, 141, 0.15); color: var(--green); }
.badge-expense { background: rgba(242, 108, 108, 0.15); color: var(--red); }
.badge-save { background: rgba(124, 106, 247, 0.15); color: var(--accent); }

/* ── Savings Card ────────────────────────────── */

.savings-hero {
  background: linear-gradient(135deg, #1a1830 0%, #1e1a2e 100%);
  border: 1px solid rgba(124, 106, 247, 0.3);
  border-radius: var(--radius);
  padding: 28px 32px;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}

.savings-hero::before {
  content: '';
  position: absolute;
  top: -40px; right: -40px;
  width: 180px; height: 180px;
  background: radial-gradient(circle, rgba(124,106,247,0.15) 0%, transparent 70%);
  pointer-events: none;
}

.savings-balance-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: rgba(124, 106, 247, 0.8);
  font-family: var(--mono);
  margin-bottom: 8px;
}

.savings-balance {
  font-family: var(--serif);
  font-size: 48px;
  font-weight: 300;
  letter-spacing: -2px;
  color: var(--text);
  line-height: 1;
}

.savings-balance .currency {
  font-size: 24px;
  color: var(--text-muted);
  margin-right: 4px;
}

.savings-meta {
  display: flex;
  gap: 24px;
  margin-top: 16px;
}

.savings-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.savings-stat-label {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--mono);
}

.savings-stat-value {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 500;
}

/* ── Modal ───────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 480px;
  transform: translateY(16px);
  transition: transform 0.2s;
}

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

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

.modal-title {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 300;
}

/* ── Filter Bar ──────────────────────────────── */

.filter-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.filter-bar .form-control {
  width: auto;
  min-width: 130px;
}

/* ── Login Page ──────────────────────────────── */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  position: relative;
}

.login-page::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  width: 100%;
  max-width: 360px;
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo h1 {
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 300;
  letter-spacing: -1px;
}

.login-logo p {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--mono);
  margin-top: 4px;
}

.error-msg {
  background: rgba(242, 108, 108, 0.1);
  border: 1px solid rgba(242, 108, 108, 0.3);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  color: var(--red);
  margin-bottom: 16px;
  display: none;
}

.error-msg.show { display: block; }

/* ── Paycheck Banner ─────────────────────────── */

.paycheck-banner {
  background: linear-gradient(135deg, #1a2818, #1e2a1a);
  border: 1px solid rgba(78, 203, 141, 0.25);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.paycheck-banner.funded {
  background: linear-gradient(135deg, #181828, #1a1a28);
  border-color: rgba(124, 106, 247, 0.2);
}

.paycheck-info { flex: 1; }
.paycheck-title { font-size: 13px; font-weight: 500; color: var(--text); }
.paycheck-sub { font-size: 11px; color: var(--text-muted); font-family: var(--mono); }

/* ── Month Selector ──────────────────────────── */

.month-nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.month-nav button {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  width: 30px; height: 30px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.month-nav button:hover { border-color: var(--accent); color: var(--accent); }

.month-label {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text);
  min-width: 80px;
  text-align: center;
}

/* ── Toast ───────────────────────────────────── */

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text);
  box-shadow: 0 4px 24px rgba(0,0,0,0.4);
  animation: slideIn 0.25s ease;
  max-width: 300px;
}

.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }

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

/* ── Responsive ──────────────────────────────── */

.hamburger {
  display: none;
  position: fixed;
  top: 16px; left: 16px;
  z-index: 200;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 38px; height: 38px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text);
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: 20px 16px; padding-top: 64px; }
  .hamburger { display: flex; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .budget-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .savings-balance { font-size: 36px; }
}

/* ── Utility ─────────────────────────────────── */

.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.hidden { display: none !important; }
.section-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  font-family: var(--mono);
  margin-bottom: 12px;
}
