@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700;800&display=swap');

:root {
  --primary: #2dd4a0;
  --primary-dim: rgba(45, 212, 160, 0.15);
  --accent: #facc15;
  --bg: #0f172a;
  --bg-2: #0a0f1a;
  --card: rgba(30, 41, 59, 0.6);
  --card-solid: #1e293b;
  --text: #e2e8f0;
  --text-dim: #94a3b8;
  --text-faint: #64748b;
  --border: rgba(45, 212, 160, 0.25);
  --border-soft: rgba(255, 255, 255, 0.08);
  --income: #2dd4a0;
  --expense: #f87171;
  --savings: #facc15;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Poppins', sans-serif;
  background: radial-gradient(ellipse at top, #1e293b 0%, var(--bg) 50%, var(--bg-2) 100%);
  background-attachment: fixed;
  color: var(--text);
  margin: 0;
  min-height: 100vh;
  line-height: 1.6;
}

/* HEADER */
header {
  position: sticky;
  top: 0;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2.5rem;
}

.logo {
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--primary);
  text-decoration: none;
  letter-spacing: 0.5px;
}

nav {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

nav a {
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  transition: color 0.2s;
}

nav a:hover { color: var(--primary); }

.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  flex-direction: column;
  gap: 5px;
}

.nav-toggle span {
  width: 24px;
  height: 2.5px;
  background: var(--primary);
  border-radius: 2px;
}

.mobile-nav {
  display: none;
  position: fixed;
  top: 70px;
  left: 0;
  right: 0;
  background: rgba(15, 23, 42, 0.98);
  flex-direction: column;
  padding: 1.5rem 2.5rem;
  gap: 1rem;
  border-bottom: 1px solid var(--border);
}

.mobile-nav.open { display: flex; }

/* BUTTONS */
.btn-primary, .btn-secondary, .btn-ghost {
  font-family: inherit;
  font-weight: 600;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #22b387);
  color: #0f172a;
  padding: 0.8rem 1.6rem;
  box-shadow: 0 6px 20px rgba(45, 212, 160, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(45, 212, 160, 0.45);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  padding: 0.8rem 1.4rem;
  border: 1px solid var(--border-soft);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--primary);
}

.btn-ghost {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--border);
  padding: 0.5rem 1.1rem;
  font-size: 0.85rem;
}

.btn-ghost:hover {
  background: var(--primary-dim);
}

/* MAIN LAYOUT */
main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* BALANCE HERO */
.balance-hero {
  margin-bottom: 2rem;
}

.balance-card {
  background: linear-gradient(135deg, rgba(45, 212, 160, 0.1), rgba(250, 204, 21, 0.05));
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2.5rem;
  text-align: center;
  backdrop-filter: blur(12px);
  position: relative;
  overflow: hidden;
}

.balance-card::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(45, 212, 160, 0.15), transparent 70%);
  pointer-events: none;
}

.balance-label {
  color: var(--text-dim);
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.balance-amount {
  font-size: clamp(2.5rem, 7vw, 4.5rem);
  font-weight: 800;
  color: var(--text);
  line-height: 1;
  margin-bottom: 1rem;
  letter-spacing: -2px;
}

.balance-amount .currency {
  color: var(--primary);
  font-size: 0.6em;
  margin-right: 0.2em;
  vertical-align: 0.15em;
}

.balance-meta {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
  color: var(--text-dim);
  font-size: 0.95rem;
}

.meta-item.up { color: var(--income); }
.meta-item.down { color: var(--expense); }
.meta-meta { color: var(--text-faint); }

.balance-actions {
  display: flex;
  gap: 0.8rem;
  justify-content: center;
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
}

/* STATS GRID */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 1.3rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  backdrop-filter: blur(10px);
  transition: transform 0.2s, border-color 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--border);
}

.stat-icon {
  font-size: 2rem;
  width: 50px;
  height: 50px;
  background: var(--primary-dim);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-info { flex: 1; min-width: 0; }

.stat-label {
  color: var(--text-dim);
  font-size: 0.8rem;
  margin-bottom: 0.2rem;
}

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

.stat-value.income { color: var(--income); }
.stat-value.expense { color: var(--expense); }
.stat-value.savings { color: var(--savings); }

/* CHARTS */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.chart-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  backdrop-filter: blur(10px);
}

.chart-card.wide { grid-column: 1 / -1; }

.chart-card h3 {
  margin: 0 0 0.2rem;
  font-size: 1.15rem;
  color: var(--text);
}

.chart-sub {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin: 0 0 1rem;
}

.chart-wrap {
  position: relative;
  height: 280px;
}

.chart-card.wide .chart-wrap { height: 250px; }

/* INSIGHTS */
.insights-section {
  margin-bottom: 2rem;
}

.insights-card {
  background: linear-gradient(135deg, rgba(45, 212, 160, 0.08), rgba(250, 204, 21, 0.04));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  backdrop-filter: blur(10px);
}

.insights-header h2 {
  margin: 0 0 0.3rem;
  color: var(--primary);
  font-size: 1.5rem;
}

.insights-header p {
  color: var(--text-dim);
  margin: 0 0 1.5rem;
}

.insights-list {
  display: grid;
  gap: 0.8rem;
}

.insight-item {
  background: rgba(15, 23, 42, 0.5);
  border-left: 3px solid var(--accent);
  padding: 1rem 1.2rem;
  border-radius: 8px;
  display: flex;
  gap: 0.8rem;
  align-items: flex-start;
  line-height: 1.5;
}

.insight-item .insight-emoji {
  font-size: 1.3rem;
  flex-shrink: 0;
}

.insight-item strong { color: var(--accent); }

.insight-empty {
  color: var(--text-dim);
  font-style: italic;
  padding: 1rem;
  text-align: center;
}

/* GOALS */
.goals-section {
  margin-bottom: 2rem;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.2rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.section-head h2 {
  margin: 0;
  color: var(--text);
  font-size: 1.5rem;
}

.goals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.goal-card {
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 1.3rem;
  backdrop-filter: blur(10px);
  position: relative;
  transition: transform 0.2s, border-color 0.2s;
}

.goal-card:hover {
  transform: translateY(-2px);
  border-color: var(--border);
}

.goal-emoji {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.goal-name {
  font-weight: 600;
  font-size: 1.1rem;
  margin-bottom: 0.3rem;
}

.goal-amounts {
  color: var(--text-dim);
  font-size: 0.9rem;
  margin-bottom: 0.8rem;
}

.goal-amounts .current { color: var(--primary); font-weight: 600; }

.goal-progress {
  height: 10px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.goal-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 999px;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.goal-pct {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-dim);
  display: flex;
  justify-content: space-between;
}

.goal-pct .pct-val { color: var(--accent); font-weight: 600; }

.goal-delete {
  position: absolute;
  top: 0.8rem;
  right: 0.8rem;
  background: none;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0.3rem;
  border-radius: 6px;
  transition: all 0.2s;
}

.goal-delete:hover {
  color: var(--expense);
  background: rgba(248, 113, 113, 0.1);
}

/* TRANSACTIONS */
.transactions-section { margin-bottom: 3rem; }

.filters {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.filters select, .filters input {
  background: rgba(15, 23, 42, 0.6);
  border: 1.5px solid var(--border-soft);
  border-radius: 8px;
  color: var(--text);
  padding: 0.5rem 0.9rem;
  font-family: inherit;
  font-size: 0.9rem;
}

.filters select:focus, .filters input:focus {
  outline: none;
  border-color: var(--primary);
}

.transactions-table-wrap {
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  overflow: hidden;
  backdrop-filter: blur(10px);
}

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

.transactions-table thead {
  background: rgba(15, 23, 42, 0.5);
  border-bottom: 1px solid var(--border-soft);
}

.transactions-table th {
  text-align: left;
  padding: 1rem 1.2rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  font-weight: 600;
}

.transactions-table th.num { text-align: right; }

.transactions-table td {
  padding: 0.9rem 1.2rem;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text);
  font-size: 0.92rem;
}

.transactions-table tr:last-child td { border-bottom: none; }
.transactions-table tr:hover td { background: rgba(45, 212, 160, 0.03); }

.tx-amount {
  text-align: right;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.tx-amount.income { color: var(--income); }
.tx-amount.expense { color: var(--expense); }

.tx-cat {
  display: inline-block;
  background: var(--primary-dim);
  color: var(--primary);
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 500;
}

.tx-delete {
  background: none;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 1rem;
  padding: 0.3rem 0.5rem;
  border-radius: 6px;
  transition: all 0.2s;
}

.tx-delete:hover {
  color: var(--expense);
  background: rgba(248, 113, 113, 0.1);
}

.empty-tx {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-dim);
}

/* MODAL */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  animation: fadeIn 0.2s ease;
}

.modal[hidden] {
  display: none;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  background: var(--card-solid);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2.5rem;
  max-width: 500px;
  width: 100%;
  position: relative;
  animation: slideUp 0.3s ease;
  max-height: 90vh;
  overflow-y: auto;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-content h2 {
  margin: 0 0 1.5rem;
  color: var(--primary);
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1.2rem;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.8rem;
  cursor: pointer;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  transition: all 0.2s;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

.form-row {
  margin-bottom: 1.2rem;
}

.form-row.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-row label {
  display: block;
  color: var(--text-dim);
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.4rem;
}

.form-row input, .form-row select {
  width: 100%;
  background: rgba(15, 23, 42, 0.6);
  border: 1.5px solid var(--border-soft);
  border-radius: 8px;
  color: var(--text);
  padding: 0.7rem 0.9rem;
  font-family: inherit;
  font-size: 0.95rem;
  transition: border-color 0.2s;
}

.form-row input:focus, .form-row select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-dim);
}

.type-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.type-toggle input[type="radio"] {
  display: none;
}

.type-toggle label {
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.8rem;
  background: rgba(15, 23, 42, 0.6);
  border: 1.5px solid var(--border-soft);
  border-radius: 10px;
  cursor: pointer;
  color: var(--text);
  font-weight: 500;
  transition: all 0.2s;
}

.type-toggle input:checked + label {
  background: var(--primary-dim);
  border-color: var(--primary);
  color: var(--primary);
}

.form-actions {
  display: flex;
  gap: 0.8rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
}

/* FOOTER */
.cta-footer {
  text-align: center;
  padding: 3rem 1.5rem;
  background: rgba(45, 212, 160, 0.04);
  border-top: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 3rem;
}

.cta-footer h2 {
  color: var(--text);
  font-size: 1.4rem;
  margin: 0 0 0.5rem;
}

.cta-footer a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.cta-footer a:hover { text-decoration: underline; }
.cta-footer p { color: var(--text-dim); margin: 0; }

.site-footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-faint);
  font-size: 0.85rem;
}

/* RESPONSIVE */
@media (max-width: 900px) {
  .charts-grid { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  header { padding: 1rem 1.25rem; }
  nav { display: none; }
  .nav-toggle { display: flex; }
  main { padding: 1.5rem 1rem; }
  .balance-card { padding: 1.8rem 1.2rem; }
  .modal-content { padding: 1.8rem 1.5rem; }
  .form-row.split { grid-template-columns: 1fr; }
  .transactions-table th, .transactions-table td {
    padding: 0.7rem 0.6rem;
    font-size: 0.85rem;
  }
  .filters { width: 100%; }
  .filters select, .filters input { flex: 1; min-width: 0; }
}
