/* ============ Save — mobile-first personal finance PWA ============ */
:root {
  color-scheme: light;
  --green-50: #ecfdf5;
  --green-100: #d1fae5;
  --green-500: #10b981;
  --green-600: #059669;
  --green-700: #047857;
  --green-900: #064e3b;
  --red: #dc2626;
  --red-light: #fee2e2;
  --amber: #d97706;
  --amber-light: #fef3c7;
  --blue: #2563eb;
  --bg: #f4f8f6;
  --surface: #ffffff;
  --surface-2: #f0f5f2;
  --text: #0f1f1a;
  --text-muted: #5c7169;
  --border: #e1ebe6;
  --shadow: 0 4px 16px rgba(6, 78, 59, 0.08);
  --shadow-lg: 0 14px 36px rgba(6, 78, 59, 0.22);
  --radius: 18px;
  --radius-sm: 12px;
  --nav-h: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --green-50: #06281f;
    --green-100: #0a3b2d;
    --red-light: #3a1212;
    --amber-light: #3a2a08;
    --bg: #0a1412;
    --surface: #10201b;
    --surface-2: #162a23;
    --text: #e7f3ee;
    --text-muted: #8fada2;
    --border: #1f362e;
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 14px 36px rgba(0, 0, 0, 0.6);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; overscroll-behavior-y: none; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
  min-height: 100dvh;
}
h1, h2, h3, h4 { margin: 0 0 6px; line-height: 1.2; }
p { margin: 0 0 8px; }
a { color: var(--green-700); }
.hidden { display: none !important; }
.muted { color: var(--text-muted); font-size: 13px; }
.right { text-align: right; }
.text-pos { color: var(--green-600); font-weight: 600; }
.text-neg { color: var(--red); font-weight: 600; }
.text-danger { color: var(--red); }
.text-warn { color: var(--amber); }

/* ---------- Header ---------- */
.app-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + var(--safe-top)) 16px 10px;
  background: linear-gradient(135deg, var(--green-900), var(--green-700));
  color: #fff;
  box-shadow: var(--shadow);
}
.app-header__brand { display: flex; align-items: center; gap: 10px; }
.app-header__logo { width: 38px; height: 38px; border-radius: 10px; display: block; }
.app-header h1 { font-size: 19px; margin: 0; }
.app-header__date { font-size: 12px; opacity: 0.85; margin: 0; }
.app-header__actions { display: flex; align-items: center; gap: 10px; }
.icon-btn--light { color: #fff; }

/* ---------- Layout ---------- */
.views {
  padding: 14px 14px calc(var(--nav-h) + var(--safe-bottom) + 90px);
  max-width: 560px;
  margin: 0 auto;
}
.view { animation: fadein 0.18s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.view-header { display: flex; align-items: center; gap: 8px; margin: 4px 0 12px; }
.view-header h2 { font-size: 21px; flex: 1; }
.icon-btn-row { display: flex; gap: 4px; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}
.card__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.card__head h3, .card__head h4 { margin: 0; font-size: 16px; }
.empty-card { text-align: center; color: var(--text-muted); }
.info-card { background: var(--green-50); font-size: 14px; }
.link { font-size: 13px; font-weight: 600; text-decoration: none; }

/* ---------- Hero card ---------- */
.hero-card {
  background: linear-gradient(135deg, var(--green-700), var(--green-500));
  color: #fff; border-radius: var(--radius); padding: 20px; margin-bottom: 14px;
  box-shadow: var(--shadow-lg);
}
.hero-card--debt { background: linear-gradient(135deg, #7f1d1d, var(--red)); }
.hero-card__label { font-size: 13px; opacity: 0.85; }
.hero-card__value { font-size: 34px; font-weight: 700; margin: 2px 0 10px; }
.hero-card__row { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; opacity: 0.95; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }
.dot--green { background: #6ee7b7; } .dot--red { background: #fca5a5; } .dot--blue { background: #93c5fd; }

/* ---------- Quick actions ---------- */
.quick-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.qa-btn {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 4px; display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-size: 12px; color: var(--text); box-shadow: var(--shadow);
  transition: transform 0.12s ease;
}
.qa-btn:active { transform: scale(0.94); }
.qa-btn span { font-size: 20px; }

/* ---------- Stats ---------- */
.stat-row { display: flex; gap: 10px; }
.stat { flex: 1; text-align: center; }
.stat__label { font-size: 12px; color: var(--text-muted); }
.stat__value { font-size: 18px; font-weight: 700; }
.stat__value--pos { color: var(--green-600); }
.stat__value--neg { color: var(--red); }

/* ---------- Buttons ---------- */
.btn {
  font-family: inherit; font-size: 14.5px; font-weight: 600; border-radius: 12px; border: none;
  padding: 11px 16px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: transform 0.1s ease, opacity 0.1s ease;
}
.btn:active { transform: scale(0.97); }
.btn--primary { background: var(--green-600); color: #fff; }
.btn--outline { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn--danger { background: var(--red-light); color: var(--red); }
.btn--light { background: rgba(255,255,255,0.18); color: #fff; }
.btn--sm { padding: 7px 12px; font-size: 13px; }
.btn--block { width: 100%; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 50%; border: none; background: transparent; color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; font-size: 17px; cursor: pointer;
}
.icon-btn:active { background: var(--surface-2); }

/* ---------- FAB ---------- */
.fab {
  position: fixed; right: 18px; bottom: calc(var(--nav-h) + var(--safe-bottom) + 16px); z-index: 25;
  width: 58px; height: 58px; border-radius: 50%; border: none;
  background: linear-gradient(135deg, var(--green-500), var(--green-700)); color: #fff;
  font-size: 26px; box-shadow: var(--shadow-lg); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.12s ease;
}
.fab:active { transform: scale(0.92); }

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; justify-content: space-around; align-items: center;
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--surface); border-top: 1px solid var(--border);
}
.bottom-nav__btn {
  background: none; border: none; display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--text-muted); font-size: 10.5px; flex: 1; padding: 6px 0; cursor: pointer;
  transition: color 0.15s ease, transform 0.12s ease;
}
.bottom-nav__btn.is-active { color: var(--green-600); }
.bottom-nav__btn:active { transform: scale(0.93); }

/* ---------- Sync dot ---------- */
.sync-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: #9ca3af; }
.sync-dot--ok { background: #34d399; }
.sync-dot--syncing { background: #fbbf24; animation: pulse 1s infinite; }
.sync-dot--error { background: #f87171; }
.sync-dot--offline { background: #9ca3af; }
.sync-dot--off { background: rgba(255,255,255,0.35); }
.sync-dot--idle { background: #34d399; }
.sync-dot--inline { position: relative; top: -1px; margin-left: 6px; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

/* ---------- Modal / bottom sheet ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(6, 20, 15, 0.5); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; transition: opacity 0.2s ease;
}
.modal-backdrop.is-visible { opacity: 1; }
.modal {
  background: var(--surface); width: 100%; max-width: 560px; border-radius: 22px 22px 0 0;
  padding: 10px 20px calc(24px + var(--safe-bottom)); max-height: 88dvh; overflow-y: auto;
  position: relative; transform: translateY(100%); transition: transform 0.22s cubic-bezier(.22,1,.36,1);
  box-shadow: var(--shadow-lg);
}
.modal-backdrop.is-visible .modal { transform: translateY(0); }
.sheet-handle { width: 40px; height: 4px; background: var(--border); border-radius: 4px; margin: 2px auto 14px; }
.modal__close { position: absolute; top: 10px; right: 14px; background: none; border: none; font-size: 24px; color: var(--text-muted); cursor: pointer; }
.modal h3 { font-size: 18px; margin-bottom: 14px; }
.modal-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 18px; }
.modal-actions .btn { flex: 1; }

/* ---------- Forms ---------- */
.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-size: 12.5px; color: var(--text-muted); margin-bottom: 4px; }
.field input, .field select {
  width: 100%; padding: 11px 12px; border-radius: 10px; border: 1.5px solid var(--border);
  background: var(--surface-2); color: var(--text); font-size: 16px; font-family: inherit;
}
.field input:focus, .field select:focus { outline: 2px solid var(--green-500); outline-offset: 1px; }
.field input::placeholder { color: var(--text-muted); opacity: 1; }
.field__amount { font-size: 26px; font-weight: 700; text-align: center; padding: 14px; }
.field--row { display: flex; align-items: center; gap: 10px; }
.field--row span { margin: 0; font-size: 14.5px; color: var(--text); }
.field--row input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--green-600); }

.segmented { display: flex; background: var(--surface-2); border-radius: 12px; padding: 3px; margin-bottom: 14px; }
.segmented__btn { flex: 1; border: none; background: none; padding: 9px; border-radius: 9px; font-weight: 600; font-size: 13.5px; color: var(--text-muted); cursor: pointer; }
.segmented__btn.is-active { background: var(--surface); color: var(--green-700); box-shadow: 0 1px 4px rgba(0,0,0,0.12); }

.tabs { display: flex; gap: 10px; margin-bottom: 12px; border-bottom: 1px solid var(--border); }
.tab { background: none; border: none; padding: 8px 2px; font-weight: 600; color: var(--text-muted); border-bottom: 2px solid transparent; cursor: pointer; }
.tab.is-active { color: var(--green-700); border-color: var(--green-600); }
.auth-error { color: var(--red); font-size: 13px; margin-top: 6px; }

/* ---------- Charts ---------- */
.chart-row { display: flex; align-items: center; gap: 16px; }
.donut-chart__total { font-size: 16px; font-weight: 700; fill: var(--text); }
.donut-chart__label { font-size: 10px; fill: var(--text-muted); }
.legend { list-style: none; margin: 0; padding: 0; flex: 1; font-size: 13px; }
.legend li { display: flex; align-items: center; gap: 6px; padding: 3px 0; justify-content: space-between; }
.legend__dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.bar-chart__label { font-size: 9px; fill: var(--text-muted); }
.ring-chart__label { font-size: 13px; font-weight: 700; fill: var(--text); }
.spark-wrap { margin: 10px 0; }

/* ---------- Progress bars ---------- */
.progress { height: 8px; background: var(--surface-2); border-radius: 6px; overflow: hidden; margin-top: 4px; }
.progress__fill { height: 100%; background: var(--green-500); border-radius: 6px; transition: width 0.3s ease; }
.progress__fill--warn { background: var(--amber); }
.progress__fill--danger { background: var(--red); }
.budget-row { margin-bottom: 12px; }
.budget-row__top { display: flex; justify-content: space-between; font-size: 13.5px; margin-bottom: 2px; }

/* ---------- Lists / swipe rows ---------- */
.swipe-row { position: relative; overflow: hidden; border-radius: var(--radius-sm); margin-bottom: 8px; list-style: none; }
.swipe-row__delete {
  position: absolute; right: 0; top: 0; bottom: 0; width: 96px; background: var(--red); color: #fff;
  border: none; font-weight: 600; font-size: 13px; cursor: pointer;
}
.swipe-row__content { position: relative; background: var(--surface-2); border-radius: var(--radius-sm); will-change: transform; }

.txn-list, .debt-list, .manage-list, .grocery-list, .upcoming-list, .payoff-order, .list-cards { list-style: none; margin: 0; padding: 0; }
.txn-list__item, .debt-list__item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; cursor: pointer; }
.txn-list__icon { font-size: 20px; width: 30px; text-align: center; }
.txn-list__mid { flex: 1; font-size: 14px; }
.txn-list__amt { font-weight: 700; font-size: 14.5px; }

.debt-list__item { flex-direction: column; align-items: stretch; gap: 6px; }
.debt-list__top { display: flex; align-items: center; gap: 10px; }
.debt-list__dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.manage-list__mid { flex: 1; font-size: 14px; }

.manage-list__item { display: flex; align-items: center; gap: 10px; padding: 8px 2px; border-bottom: 1px solid var(--border); }
.manage-list__dot { width: 10px; height: 10px; border-radius: 50%; }

.upcoming-list li { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.upcoming-list li:last-child { border-bottom: none; }
.upcoming-list__icon { font-size: 18px; }

.goal-ring-row { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 4px; }
.goal-ring { text-align: center; flex-shrink: 0; }
.goal-ring__name { font-size: 11.5px; margin-top: 4px; max-width: 76px; }

.achievement-card { display: flex; align-items: center; gap: 12px; background: var(--green-50); }
.achievement-card__icon { font-size: 28px; }

.payoff-order { padding-left: 4px; }
.payoff-order li { padding: 5px 0; font-size: 14px; }
.payoff-order__num {
  display: inline-flex; width: 20px; height: 20px; border-radius: 50%; background: var(--green-600); color: #fff;
  align-items: center; justify-content: center; font-size: 11px; margin-right: 6px;
}
.plan-summary { display: flex; gap: 10px; margin: 14px 0; }
.plan-summary__item { flex: 1; text-align: center; background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 4px; }
.plan-summary__big { font-size: 15px; font-weight: 700; }
.plan-compare { background: var(--green-50); border-radius: var(--radius-sm); padding: 12px; margin: 10px 0; font-size: 13.5px; }
.plan-compare .btn { margin-top: 8px; }

/* ---------- Goal cards ---------- */
.goal-cards { display: flex; flex-direction: column; gap: 12px; }
.goal-card { background: var(--surface); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.goal-card__top { display: flex; align-items: center; gap: 12px; }
.goal-card__mid { flex: 1; }
.goal-card__mid h4 { margin: 0; font-size: 15.5px; }
.goal-card__actions { margin-top: 10px; }

/* ---------- Groceries ---------- */
.list-cards { display: flex; flex-direction: column; gap: 8px; }
.list-card { display: flex; align-items: center; gap: 12px; background: var(--surface); border-radius: var(--radius-sm); padding: 14px; box-shadow: var(--shadow); cursor: pointer; }
.list-card__icon { font-size: 22px; }
.list-card__mid { flex: 1; font-size: 14.5px; }
.chevron { color: var(--text-muted); font-size: 18px; }
.chip { display: inline-block; background: var(--green-100); color: var(--green-700); font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 20px; margin-left: 4px; }
.chip-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.add-item-bar { display: flex; gap: 6px; margin-bottom: 14px; }
.add-item-bar input { flex: 1; padding: 11px 12px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--surface-2); color: var(--text); font-size: 16px; font-family: inherit; }
.add-item-bar input::placeholder { color: var(--text-muted); opacity: 1; }
.add-item-bar__qty { flex: 0 0 64px !important; }
.grocery-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.grocery-item.is-checked .grocery-item__label span { text-decoration: line-through; color: var(--text-muted); }
.grocery-item__label { display: flex; align-items: center; gap: 10px; flex: 1; cursor: pointer; }
.grocery-item__check { width: 21px; height: 21px; accent-color: var(--green-600); }
.list-total { text-align: center; padding: 10px; color: var(--text-muted); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-bottom) + 76px); transform: translateX(-50%);
  background: #0f1f1a; color: #fff; padding: 11px 18px; border-radius: 30px; font-size: 13.5px; z-index: 60;
  box-shadow: var(--shadow-lg); max-width: 86%; text-align: center; transition: opacity 0.2s ease;
}
.toast--error { background: var(--red); }
.toast--success { background: var(--green-700); }

/* ---------- Notification settings rows ---------- */
.notif-settings { margin-top: 4px; }

/* ---------- Misc ---------- */
.month-switcher { display: flex; align-items: center; justify-content: center; gap: 14px; margin-bottom: 12px; font-size: 15px; }
