:root {
  --bg: #f4f6f9;
  --card-bg: #ffffff;
  --text: #1a1a2e;
  --text-muted: #6c757d;
  --primary: #4361ee;
  --primary-hover: #3a56d4;
  --secondary: #7209b7;
  --success: #2ec4b6;
  --danger: #e63946;
  --warning: #ffb703;
  --radius: 16px;
  --shadow: 0 4px 12px rgba(0,0,0,0.08);
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  padding-bottom: 40px;
}

.app-header {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  padding: 24px 16px 18px;
  text-align: center;
  border-radius: 0 0 24px 24px;
  box-shadow: 0 4px 15px rgba(67, 97, 238, 0.3);
}
.app-header h1 { font-size: 1.6rem; margin-bottom: 4px; }
.app-header p { opacity: 0.9; font-size: 0.95rem; }

.container { padding: 16px; max-width: 600px; margin: 0 auto; }

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  transition: var(--transition);
}
.card h2 { font-size: 1.1rem; margin-bottom: 14px; color: var(--text); }

.summary-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.balance-card { background: linear-gradient(135deg, #2a2d3e, #1f2233); color: white; }
.income-card { border-left: 4px solid var(--success); }
.expense-card { border-left: 4px solid var(--danger); }

.amount { font-size: 1.2rem; font-weight: 700; margin-top: 6px; }
.positive { color: var(--success); }
.negative { color: var(--danger); }

form { display: flex; flex-direction: column; gap: 12px; }
input, select {
  width: 100%; padding: 14px; border: 2px solid #e0e6ed; border-radius: 12px;
  font-size: 16px; background: #f8fafc; transition: var(--transition);
}
input:focus, select:focus { outline: none; border-color: var(--primary); background: white; }

.btn-primary, .btn-secondary {
  width: 100%; padding: 14px; border: none; border-radius: 12px; font-size: 1rem; font-weight: 600;
  cursor: pointer; transition: var(--transition); touch-action: manipulation;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover, .btn-primary:active { background: var(--primary-hover); transform: translateY(-1px); }
.btn-secondary { background: #e9ecef; color: var(--text); margin-top: 8px; }
.btn-secondary:hover { background: #dee2e6; }

.input-group { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.input-group label { font-size: 0.9rem; color: var(--text-muted); font-weight: 500; }

.progress-container { margin-top: 12px; }
.progress-bar { height: 10px; background: #e9ecef; border-radius: 6px; overflow: hidden; margin-top: 6px; }
#budgetProgress { height: 100%; background: var(--success); transition: width 0.4s ease, background 0.3s; }

.goals-input { flex-direction: row; align-items: center; gap: 8px; flex-wrap: wrap; }
.goals-input input { flex: 1; min-width: 120px; margin-bottom: 0; }

#goalsList, #transactionList { list-style: none; max-height: 300px; overflow-y: auto; }
.goal-item, .tx-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0; border-bottom: 1px solid #f0f0f0; font-size: 0.95rem;
}
.goal-progress { width: 60%; height: 8px; background: #e9ecef; border-radius: 4px; overflow: hidden; margin-top: 4px; }
.goal-fill { height: 100%; background: var(--secondary); transition: width 0.3s; }

.tx-item.expense .tx-amount { color: var(--danger); }
.tx-item.income .tx-amount { color: var(--success); }
.tx-meta { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }

.ai-tips { background: linear-gradient(135deg, #fff9e6, #fff3cd); border-left: 4px solid var(--warning); }
#aiTip { font-size: 0.95rem; line-height: 1.6; color: #856404; }

.chart-wrapper { position: relative; height: 220px; width: 100%; }

.fade-in { animation: fadeInUp 0.5s ease forwards; opacity: 0; transform: translateY(10px); }
@keyframes fadeInUp { to { opacity: 1; transform: translateY(0); } }

@media (max-width: 380px) {
  .summary-cards { grid-template-columns: 1fr; }
  .goals-input { flex-direction: column; align-items: stretch; }
}
