/* ─── RESET & BASE ──────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root { --accent: #22c55e; }
html { -webkit-tap-highlight-color: transparent; scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0a0f1a;
  color: #e2e8f0;
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: 80px;
  -webkit-font-smoothing: antialiased;
}
input, select, button, textarea {
  font-family: inherit; font-size: 16px; color: inherit;
}
input:focus, select:focus, button:focus-visible {
  outline: 2px solid #22c55e; outline-offset: 2px;
}
a { color: #4ade80; text-decoration: none; }
svg { display: block; }

/* ─── LAYOUT ────────────────────────────────────────── */
.container { width: 100%; max-width: 720px; margin: 0 auto; padding: 0 16px; }
.page:not(.active) { display: none; }
.page.active { display: block; animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* ─── HEADER ────────────────────────────────────────── */
.app-header {
  position: sticky; top: 0; z-index: 40;
  background: rgba(10,15,26,0.92); backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  padding: 12px 0;
}
.app-header .container {
  display: flex; align-items: center; justify-content: space-between;
}
.header-left { display: flex; align-items: center; gap: 10px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, #22c55e, #16a34a); display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 700; }
.header-title { font-size: 17px; font-weight: 600; }
.header-subtitle { font-size: 11px; color: #64748b; }

/* ─── BOTTOM NAV ────────────────────────────────────── */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  background: rgba(15,23,42,0.96); backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex; padding: 4px 0 8px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
}
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 6px 0; font-size: 10px; font-weight: 500;
  color: #475569; background: none; border: none; cursor: pointer;
  transition: color 0.2s; letter-spacing: 0.02em;
}
.nav-item svg { width: 22px; height: 22px; opacity: 0.5; transition: opacity 0.2s; }
.nav-item.active { color: #22c55e; }
.nav-item.active svg { opacity: 1; }

/* ─── CARDS ─────────────────────────────────────────── */
.card {
  background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.06);
  border-radius: 16px; padding: 16px; margin-bottom: 10px;
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card-title { font-size: 13px; font-weight: 600; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.05em; }

/* ─── BUTTONS ───────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px; border-radius: 12px; font-size: 14px; font-weight: 600;
  border: none; cursor: pointer; transition: all 0.15s; white-space: nowrap;
}
.btn-primary { background: #22c55e; color: #000; }
.btn-primary:hover { background: #16a34a; }
.btn-outline { background: transparent; color: #22c55e; border: 1px solid rgba(34,197,94,0.3); }
.btn-outline:hover { background: rgba(34,197,94,0.08); }
.btn-full { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.fab {
  position: fixed; bottom: 100px; right: 20px; z-index: 50;
  width: 56px; height: 56px; border-radius: 50%;
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #000; border: none; box-shadow: 0 4px 20px rgba(34,197,94,0.3);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; cursor: pointer; transition: transform 0.15s;
}
.fab:active { transform: scale(0.92); }

/* ─── FORMS ─────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: #64748b; margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.05em; }
input, select {
  width: 100%; padding: 12px 14px; background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08); border-radius: 12px;
  font-size: 15px; transition: border 0.15s;
}
input:hover { border-color: rgba(255,255,255,0.15); }
input:focus, select:focus { border-color: #22c55e; outline: none; box-shadow: 0 0 0 3px rgba(34,197,94,0.1); }
input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; }

/* ─── BUDGET CARD ───────────────────────────────────── */
.budget-row {
  display: flex; align-items: center; gap: 14px; padding: 14px;
  background: rgba(255,255,255,0.02); border: 1px solid rgba(255,255,255,0.04);
  border-radius: 14px; margin-bottom: 8px; cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.budget-row:hover { border-color: rgba(34,197,94,0.3); background: rgba(255,255,255,0.04); }
.budget-row:active { transform: scale(0.99); }
.budget-icon { font-size: 28px; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,0.04); border-radius: 12px; flex-shrink: 0; }
.budget-info { flex: 1; min-width: 0; }
.budget-name { font-size: 15px; font-weight: 600; margin-bottom: 2px; }
.budget-budgeted { font-size: 12px; color: #64748b; }
.budget-status { text-align: right; flex-shrink: 0; }
.budget-spent { font-size: 17px; font-weight: 700; }
.budget-remaining { font-size: 12px; font-weight: 600; }
.budget-bar {
  height: 4px; background: rgba(255,255,255,0.06); border-radius: 99px;
  margin-top: 8px; overflow: hidden;
}
.budget-bar-fill { height: 100%; border-radius: 99px; transition: width 0.4s ease; }
.budget-alert { font-size: 11px; font-weight: 700; margin-top: 6px; text-transform: uppercase; letter-spacing: 0.04em; }

/* ─── SUMMARY CARD ──────────────────────────────────── */
.summary-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 10px; }
.section-title { font-size: 12px; font-weight: 700; color: #64748b; text-transform: uppercase; letter-spacing: 0.08em; margin: 4px 0 12px; }
.daily-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 10px; }
.daily-card {
  background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.06);
  border-radius: 14px; padding: 12px; min-width: 0;
}
.daily-card span { display: block; color: #64748b; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px; }
.daily-card strong { display: block; font-size: 17px; line-height: 1.1; }
.planning-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.planning-tile {
  text-align: left; background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.06);
  border-radius: 14px; padding: 12px; color: inherit; cursor: pointer; min-width: 0;
}
.planning-tile span { display: block; color: #64748b; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }
.planning-tile strong { display: block; font-size: 18px; margin: 4px 0 2px; }
.planning-tile em { display: block; color: #64748b; font-size: 12px; font-style: normal; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.planning-tile.danger { border-color: rgba(239,68,68,0.28); }
.summary-item {
  background: rgba(255,255,255,0.02); border: 1px solid rgba(255,255,255,0.04);
  border-radius: 14px; padding: 14px; text-align: center;
}
.summary-item .value { font-size: 20px; font-weight: 700; margin-bottom: 2px; }
.summary-item .label { font-size: 11px; color: #64748b; text-transform: uppercase; letter-spacing: 0.05em; }
.summary-item.total .value { color: #e2e8f0; }
.summary-item.income .value { color: #4ade80; }
.summary-item.spent .value { color: #60a5fa; }
.summary-item.available .value { color: #22c55e; }
.summary-bar { height: 6px; background: rgba(255,255,255,0.06); border-radius: 99px; margin-bottom: 16px; overflow: hidden; }
.summary-bar-fill { height: 100%; border-radius: 99px; transition: width 0.4s ease; background: #22c55e; }

/* ─── EXPENSE LIST ──────────────────────────────────── */
.expense-item {
  display: flex; align-items: center; gap: 14px; padding: 12px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.expense-item:last-child { border-bottom: none; }
.expense-dot { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; background: rgba(255,255,255,0.04); }
.expense-desc { flex: 1; min-width: 0; font-size: 14px; }
.expense-meta { font-size: 12px; color: #64748b; margin-top: 1px; }
.expense-amount { font-size: 16px; font-weight: 700; flex-shrink: 0; }
.expense-row { cursor: pointer; border-radius: 12px; padding: 12px 8px; margin: 0 -8px; }
.expense-row:hover { background: rgba(255,255,255,0.03); }
.expense-actions { display: flex; gap: 6px; flex-shrink: 0; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04); color: #94a3b8; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; font-size: 16px;
}
.icon-btn.danger { color: #f87171; border-color: rgba(239,68,68,0.22); }
.icon-btn:active { transform: scale(0.95); }

/* ─── CHARTS ────────────────────────────────────────── */
.chart-bar-group { display: flex; align-items: flex-end; justify-content: space-around; height: 140px; gap: 12px; padding: 0 8px; }
.chart-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.chart-bar { width: 100%; max-width: 48px; border-radius: 8px 8px 0 0; transition: height 0.5s ease; min-height: 4px; }
.chart-bar-label { font-size: 11px; color: #64748b; text-align: center; word-break: break-all; }

/* ─── CHIPS (filter pills) ──────────────────────────── */
.chip-row { display: flex; gap: 8px; margin-bottom: 14px; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
.chip {
  padding: 6px 14px; border-radius: 99px; font-size: 13px; font-weight: 600;
  background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.06);
  color: #64748b; cursor: pointer; white-space: nowrap; transition: all 0.15s;
}
.chip.active { background: rgba(34,197,94,0.12); border-color: #22c55e; color: #22c55e; }

/* ─── AUTH PAGES ────────────────────────────────────── */
.auth-page { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; padding: 24px 0; }
.auth-card { width: 100%; max-width: 400px; margin: 0 auto; background: rgba(255,255,255,0.02); border: 1px solid rgba(255,255,255,0.06); border-radius: 20px; padding: 28px 24px; }
.auth-logo { text-align: center; font-size: 48px; margin-bottom: 12px; }
.auth-title { font-size: 22px; font-weight: 700; text-align: center; margin-bottom: 4px; }
.auth-subtitle { font-size: 13px; color: #64748b; text-align: center; margin-bottom: 24px; }
.auth-link { text-align: center; margin-top: 14px; font-size: 13px; color: #64748b; }

/* ─── MODAL ─────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px); display: flex; align-items: flex-end; justify-content: center;
}
@media (min-width: 640px) {
  .modal-overlay { align-items: center; padding: 24px; }
}
.modal {
  background: #111827; border: 1px solid rgba(255,255,255,0.08);
  border-radius: 20px 20px 0 0; padding: 20px; width: 100%; max-width: 480px;
  max-height: 85vh; overflow-y: auto; animation: slideUp 0.25s ease;
}
@media (min-width: 640px) {
  .modal { border-radius: 20px; }
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-handle { width: 36px; height: 4px; background: rgba(255,255,255,0.2); border-radius: 2px; margin: 0 auto 16px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-title { font-size: 18px; font-weight: 700; }
.modal-close { width: 32px; height: 32px; border-radius: 50%; background: rgba(255,255,255,0.06); border: none; color: #94a3b8; font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.modal-actions { display: grid; grid-template-columns: 1fr; gap: 10px; }
.icon-picker { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.icon-option {
  min-height: 42px; border-radius: 12px; border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04); font-size: 22px; cursor: pointer;
}
.icon-option.active { border-color: #22c55e; background: rgba(34,197,94,0.14); }

/* ─── ALERTS ────────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: 12px; font-size: 13px; font-weight: 500; margin-bottom: 12px; }
.alert-error { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.2); color: #f87171; }
.alert-success { background: rgba(34,197,94,0.1); border: 1px solid rgba(34,197,94,0.2); color: #4ade80; }
.alert-warning { background: rgba(245,158,11,0.1); border: 1px solid rgba(245,158,11,0.2); color: #fbbf24; }
.toast-alert {
  position: fixed; left: 16px; right: 16px; bottom: 92px; z-index: 120;
  box-shadow: 0 18px 60px rgba(0,0,0,0.24); margin: 0;
}

/* ─── EMPTY STATE ───────────────────────────────────── */
.empty-state { text-align: center; padding: 40px 16px; }
.empty-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.4; }
.empty-text { color: #64748b; font-size: 14px; margin-bottom: 16px; }

/* ─── LOADING ───────────────────────────────────────── */
.spinner { width: 32px; height: 32px; border: 3px solid rgba(34,197,94,0.2); border-top-color: #22c55e; border-radius: 50%; animation: spin 0.7s linear infinite; margin: 32px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: rgba(255,255,255,0.04); border-radius: 8px; animation: pulse 1.5s infinite; }
@keyframes pulse { 0%,100% { opacity: 0.3; } 50% { opacity: 0.6; } }

/* ─── UTILITIES ─────────────────────────────────────── */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-green { color: #22c55e; }
.text-red { color: #ef4444; }
.text-blue { color: #60a5fa; }
.text-muted { color: #64748b; }
.text-sm { font-size: 13px; }
.font-bold { font-weight: 700; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }

/* ─── SETTINGS ──────────────────────────────────────── */
.settings-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0; border-bottom: 1px solid rgba(255,255,255,0.04);
}
.settings-item:last-child { border-bottom: none; }
.settings-label { font-size: 15px; }
.settings-value { font-size: 13px; color: #64748b; }
.settings-actions { display: flex; gap: 6px; flex-shrink: 0; }
.settings-stack { display: block; }
.settings-stack .settings-label { display: block; margin-bottom: 10px; }
.inline-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
.action-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
.muted-row { opacity: 0.62; }
.swatch-row { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch {
  width: 34px; height: 34px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.22);
  background: var(--swatch); cursor: pointer;
}
.insight-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.insight-item {
  background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px; padding: 12px; min-width: 0;
}
.insight-item span { display: block; color: #64748b; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 5px; }
.insight-item strong { display: block; font-size: 15px; margin-bottom: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.insight-item em { display: block; color: #64748b; font-size: 12px; font-style: normal; }
.finance-coach-card {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  background: linear-gradient(135deg, rgba(255,255,255,0.08), rgba(255,255,255,0.03)), var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(16px);
}
.finance-score {
  display: grid;
  place-items: center;
  min-height: 148px;
  border-radius: 18px;
  background:
    radial-gradient(circle at center, rgba(255,255,255,0.08) 0 42%, transparent 43%),
    conic-gradient(var(--score-color) var(--score-deg, 0deg), rgba(148,163,184,0.16) 0);
  position: relative;
  overflow: hidden;
}
.finance-score::before {
  content: "";
  position: absolute;
  inset: 14px;
  border-radius: 16px;
  background: rgba(7,11,18,0.74);
}
.finance-score span,
.finance-score strong,
.finance-score em { position: relative; z-index: 1; }
.finance-score span { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; }
.finance-score strong { font-size: 42px; line-height: 1; color: var(--score-color); }
.finance-score em { color: var(--muted); font-style: normal; font-size: 13px; }
.coach-grid,
.finance-plan-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.coach-metric,
.finance-plan-item {
  min-width: 0;
  background: rgba(255,255,255,0.045);
  border: 1px solid rgba(148,163,184,0.14);
  border-radius: 14px;
  padding: 12px;
}
.coach-metric span,
.finance-plan-item span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 5px;
}
.coach-metric strong,
.finance-plan-item strong {
  display: block;
  font-size: 17px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.coach-metric em,
.finance-plan-item em {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.coach-note {
  margin-top: 10px;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 24%, transparent);
  border-radius: 14px;
  color: var(--text);
  padding: 12px;
  font-size: 13px;
  line-height: 1.45;
}
.coach-strip {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}
.coach-strip span {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(148,163,184,0.12);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  padding: 8px 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Dynamic theme overrides */
.btn-primary, .fab, .avatar { background: var(--accent); }
.btn-outline, a, .nav-item.active, .chip.active { color: var(--accent); }
.btn-outline, .chip.active { border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.summary-item.income .value, .summary-item.available .value, .text-green { color: var(--accent); }
.summary-bar-fill { background: var(--accent); }

body[data-theme="light"] {
  background: #f6f8fb; color: #111827;
}
body[data-theme="light"] .app-header,
body[data-theme="light"] .bottom-nav {
  background: rgba(255,255,255,0.92); border-color: rgba(15,23,42,0.1);
}
body[data-theme="light"] .card,
body[data-theme="light"] .summary-item,
body[data-theme="light"] .daily-card,
body[data-theme="light"] .planning-tile,
body[data-theme="light"] .finance-coach-card,
body[data-theme="light"] .coach-metric,
body[data-theme="light"] .finance-plan-item,
body[data-theme="light"] .budget-row,
body[data-theme="light"] .insight-item,
body[data-theme="light"] .modal,
body[data-theme="light"] input,
body[data-theme="light"] select,
body[data-theme="light"] .chip,
body[data-theme="light"] .expense-dot,
body[data-theme="light"] .budget-icon,
body[data-theme="light"] .icon-btn,
body[data-theme="light"] .icon-option {
  background: #ffffff; border-color: rgba(15,23,42,0.1); color: #111827;
}
body[data-theme="light"] .header-subtitle,
body[data-theme="light"] .form-label,
body[data-theme="light"] .summary-item .label,
body[data-theme="light"] .daily-card span,
body[data-theme="light"] .expense-meta,
body[data-theme="light"] .text-muted,
body[data-theme="light"] .settings-value,
body[data-theme="light"] .section-title,
body[data-theme="light"] .insight-item span,
body[data-theme="light"] .insight-item em {
  color: #64748b;
}
body[data-theme="light"] .bottom-nav { box-shadow: 0 18px 60px rgba(15,23,42,0.12); }
body[data-theme="light"] .modal-overlay { background: rgba(15,23,42,0.45); }

/* ─── HISTORIAL BARS ────────────────────────────────── */
.history-chart { display: flex; align-items: flex-end; gap: 8px; height: 100px; margin: 16px 0; }
.history-bar { flex: 1; border-radius: 4px 4px 0 0; transition: height 0.4s; min-width: 20px; }
.history-bar.green { background: #22c55e; }
.history-bar.blue { background: #60a5fa; }
.history-labels { display: flex; gap: 8px; }
.history-label { flex: 1; text-align: center; font-size: 10px; color: #64748b; }

/* ─── RESPONSIVE ────────────────────────────────────── */
@media (min-width: 768px) {
  .container { max-width: 1120px; padding: 0 28px; }
  .app-header { padding: 14px 0; }
  .avatar { width: 44px; height: 44px; font-size: 20px; }
  .header-left { gap: 14px; }
  .header-title { font-size: 24px; }
  .header-subtitle { font-size: 14px; }
  .btn-sm { padding: 10px 16px; font-size: 15px; }
  .summary-grid { grid-template-columns: repeat(4, 1fr); }
  .planning-grid { grid-template-columns: repeat(4, 1fr); }
  .summary-item { padding: 20px 16px; }
  .summary-item .value { font-size: 26px; }
  .summary-item .label { font-size: 12px; }
  #tab-expenses .container,
  #tab-history .container,
  #tab-settings .container { max-width: 980px; }
  .expense-item { padding: 14px 10px; }
  .expense-desc { font-size: 15px; }
  .expense-amount { font-size: 17px; }
  .modal-actions { grid-template-columns: 0.8fr 1.2fr; }
  .inline-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .inline-grid .btn { min-height: 45px; }
  .action-grid { grid-template-columns: repeat(2, 1fr); }
  .icon-picker { grid-template-columns: repeat(8, 1fr); }
  .toast-alert { left: 50%; right: auto; bottom: 110px; width: min(520px, calc(100% - 32px)); transform: translateX(-50%); }
  .bottom-nav {
    left: 50%;
    right: auto;
    bottom: 16px;
    width: min(720px, calc(100% - 32px));
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 18px;
    padding: 8px 10px;
    transform: translateX(-50%);
    box-shadow: 0 18px 60px rgba(0,0,0,0.28);
  }
  .nav-item { border-radius: 12px; font-size: 12px; padding: 8px 0; }
  .nav-item.active { background: rgba(34,197,94,0.08); }
  .app-sidebar {
    display: none;
  }
  .sidebar-nav-item {
    display: none;
  }
  .main-content { padding: 24px; }
  .fab { bottom: 112px; right: max(28px, calc((100vw - 1120px) / 2 + 28px)); }
}

@media (min-width: 1180px) {
  .container { max-width: 1180px; }
  .summary-grid { gap: 14px; }
  .budget-row { padding: 16px; }
}

/* Visual refresh and motion layer */
:root {
  --bg: #070b12;
  --panel: rgba(17, 24, 39, 0.74);
  --panel-strong: rgba(15, 23, 42, 0.92);
  --line: rgba(148, 163, 184, 0.16);
  --text: #e8eef8;
  --muted: #8ea0bb;
  --blue: #38bdf8;
  --gold: #fbbf24;
  --red: #fb7185;
  --shadow-soft: 0 18px 48px rgba(0, 0, 0, 0.28);
  --shadow-card: 0 14px 34px rgba(0, 0, 0, 0.20);
  --radius: 18px;
}

body {
  background:
    linear-gradient(135deg, rgba(34, 197, 94, 0.08), transparent 28%),
    linear-gradient(225deg, rgba(56, 189, 248, 0.08), transparent 32%),
    linear-gradient(180deg, #09111f 0%, var(--bg) 48%, #06080d 100%);
  color: var(--text);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,0.68), rgba(0,0,0,0.12));
}

.page.active.page-entering { animation: pageSlide 0.38s cubic-bezier(.2,.8,.2,1); }
@keyframes pageSlide {
  from { opacity: 0; transform: translateY(14px) scale(0.992); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.motion-in {
  animation: itemRise 0.44s cubic-bezier(.2,.8,.2,1) both;
  animation-delay: calc(var(--stagger, 0) * 34ms);
}
@keyframes itemRise {
  from { opacity: 0; transform: translateY(14px) scale(0.985); filter: blur(3px); }
  to { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
}
.value-pop { animation: valuePop 0.36s cubic-bezier(.2,.8,.2,1); }
@keyframes valuePop {
  0% { transform: translateY(2px) scale(0.96); opacity: 0.72; }
  60% { transform: translateY(-1px) scale(1.035); }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}
.nav-bounce svg { animation: navPop 0.42s cubic-bezier(.2,.8,.2,1); }
@keyframes navPop {
  0% { transform: translateY(2px) scale(0.86); }
  60% { transform: translateY(-2px) scale(1.12); }
  100% { transform: translateY(0) scale(1); }
}

.app-header {
  background: rgba(7, 11, 18, 0.78);
  border-bottom-color: var(--line);
  box-shadow: 0 8px 28px rgba(0,0,0,0.18);
}
.avatar {
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent) 92%, white), var(--accent));
  box-shadow: 0 10px 28px color-mix(in srgb, var(--accent) 26%, transparent);
}
.header-title { letter-spacing: 0; }
.header-subtitle, .text-muted, .empty-text, .expense-meta { color: var(--muted); }

.card,
.summary-item,
.daily-card,
.planning-tile,
.budget-row,
.insight-item,
.auth-card {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.075), rgba(255,255,255,0.026)),
    var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(16px);
}
.card,
.summary-item,
.daily-card,
.planning-tile,
.budget-row,
.insight-item { border-radius: var(--radius); }

.card:hover,
.summary-item:hover,
.daily-card:hover,
.planning-tile:hover,
.budget-row:hover,
.insight-item:hover {
  border-color: color-mix(in srgb, var(--accent) 38%, rgba(148,163,184,0.18));
  transform: translateY(-2px);
  box-shadow: 0 18px 42px rgba(0,0,0,0.26);
}
.card,
.summary-item,
.daily-card,
.planning-tile,
.budget-row,
.insight-item,
.btn,
.icon-btn,
.chip,
.swatch,
.icon-option {
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease, color 0.18s ease;
}

.section-title {
  color: var(--muted);
  letter-spacing: 0.12em;
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-title::before {
  content: "";
  width: 22px;
  height: 2px;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--blue));
}

.summary-item {
  position: relative;
  overflow: hidden;
  text-align: left;
}
.summary-item::after {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 0;
  height: 3px;
  border-radius: 99px 99px 0 0;
  background: linear-gradient(90deg, var(--accent), var(--blue));
  opacity: 0.76;
}
.summary-item .value { font-size: 24px; letter-spacing: 0; }
.summary-item.spent .value, .text-blue { color: var(--blue); }
.summary-item.total .value { color: var(--gold); }
.summary-bar {
  height: 9px;
  background: rgba(148,163,184,0.14);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.32);
}
.summary-bar-fill {
  background: linear-gradient(90deg, var(--accent), var(--blue));
  box-shadow: 0 0 18px color-mix(in srgb, var(--accent) 45%, transparent);
}

.budget-row { position: relative; }
.budget-row::before,
.planning-tile::before,
.daily-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(135deg, rgba(255,255,255,0.10), transparent 42%);
  opacity: 0.45;
}
.budget-icon,
.expense-dot {
  background: rgba(255,255,255,0.075);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
}
.budget-bar {
  height: 7px;
  background: rgba(148,163,184,0.14);
}
.budget-bar-fill { box-shadow: 0 0 14px currentColor; }

.expense-row:hover,
.settings-item:hover {
  background: rgba(255,255,255,0.045);
}
.expense-row:active,
.planning-tile:active,
.budget-row:active,
.btn:active,
.icon-btn:active {
  transform: scale(0.98);
}

.btn {
  min-height: 44px;
  border-radius: 14px;
  letter-spacing: 0;
}
.btn-primary {
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 94%, white), var(--accent));
  color: #03100a;
  box-shadow: 0 12px 28px color-mix(in srgb, var(--accent) 26%, transparent);
}
.btn-primary:hover { filter: brightness(1.05); }
.btn-outline {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  border-color: color-mix(in srgb, var(--accent) 34%, transparent);
}
.btn-outline:hover {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  box-shadow: 0 10px 24px rgba(0,0,0,0.18);
}

input, select {
  background: rgba(255,255,255,0.06);
  border-color: rgba(148,163,184,0.16);
  border-radius: 14px;
}
input:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent);
}

.chip {
  border-radius: 14px;
  background: rgba(255,255,255,0.055);
}
.chip.active {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  box-shadow: 0 8px 22px color-mix(in srgb, var(--accent) 14%, transparent);
}

.bottom-nav {
  background: rgba(10, 15, 26, 0.84);
  border-color: var(--line);
  box-shadow: 0 -14px 40px rgba(0,0,0,0.28);
}
.nav-item {
  position: relative;
  overflow: hidden;
  font-weight: 700;
}
.nav-item.active {
  background: color-mix(in srgb, var(--accent) 13%, transparent);
}
.nav-item.active::after {
  content: "";
  position: absolute;
  left: 22%;
  right: 22%;
  bottom: 0;
  height: 3px;
  border-radius: 99px 99px 0 0;
  background: var(--accent);
}

.fab {
  background: linear-gradient(135deg, var(--accent), var(--blue));
  box-shadow: 0 16px 40px color-mix(in srgb, var(--accent) 28%, rgba(0,0,0,0.28));
  animation: fabFloat 2.8s ease-in-out infinite;
}
@keyframes fabFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

.modal-overlay:not(.hidden) {
  animation: overlayFade 0.22s ease both;
}
.modal {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.035)),
    var(--panel-strong);
  border-color: var(--line);
  box-shadow: var(--shadow-soft);
}
@keyframes overlayFade {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(34px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.auth-page {
  padding: 28px 16px;
  justify-content: center;
}
.auth-card {
  position: relative;
  overflow: hidden;
  border-radius: 24px;
  box-shadow: var(--shadow-soft);
}
.auth-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent) 18%, transparent), transparent 46%),
    linear-gradient(315deg, rgba(56,189,248,0.14), transparent 38%);
}
.auth-card > * { position: relative; }
.auth-logo {
  width: 66px;
  height: 66px;
  margin: 0 auto 14px;
  display: grid;
  place-items: center;
  border-radius: 20px;
  background: color-mix(in srgb, var(--accent) 16%, rgba(255,255,255,0.06));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.14);
}
.auth-title { font-size: 26px; letter-spacing: 0; }

.history-bar {
  background: linear-gradient(180deg, var(--blue), var(--accent));
  box-shadow: 0 10px 22px rgba(56,189,248,0.20);
  animation: barGrow 0.72s cubic-bezier(.2,.8,.2,1) both;
  transform-origin: bottom;
}
@keyframes barGrow {
  from { transform: scaleY(0.15); opacity: 0.45; }
  to { transform: scaleY(1); opacity: 1; }
}

.toast-alert {
  animation: toastIn 0.32s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(18px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

body[data-theme="light"] {
  --bg: #f5f7fb;
  --panel: rgba(255,255,255,0.82);
  --panel-strong: rgba(255,255,255,0.96);
  --line: rgba(15,23,42,0.10);
  --text: #111827;
  --muted: #64748b;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent) 10%, transparent), transparent 28%),
    linear-gradient(225deg, rgba(56,189,248,0.12), transparent 32%),
    linear-gradient(180deg, #fbfdff 0%, #f4f7fb 100%);
}
body[data-theme="light"] .app-header,
body[data-theme="light"] .bottom-nav {
  background: rgba(255,255,255,0.82);
}
body[data-theme="light"] .card,
body[data-theme="light"] .summary-item,
body[data-theme="light"] .daily-card,
body[data-theme="light"] .planning-tile,
body[data-theme="light"] .budget-row,
body[data-theme="light"] .insight-item,
body[data-theme="light"] .auth-card {
  background: linear-gradient(180deg, #ffffff, rgba(255,255,255,0.78));
  box-shadow: 0 16px 36px rgba(15,23,42,0.08);
}
body[data-theme="light"] input,
body[data-theme="light"] select {
  background: #fff;
}

@media (min-width: 768px) {
  .card { padding: 18px; }
  .summary-item .value { font-size: 30px; }
  .finance-coach-card { grid-template-columns: 220px 1fr; align-items: stretch; }
  .finance-plan-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .coach-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .coach-strip { flex-direction: row; }
  .coach-strip span { flex: 1; }
  .bottom-nav { backdrop-filter: blur(24px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
