/* ═══════════════════════════════════════════════════════════════════
   FINANCIAL PLANNER — Premium Fintech Design System
   Version 2.0 · Token-Driven · WCAG AA · Zero Layout Shift

   Design Direction: Refined Editorial Fintech
   Philosophy: Precision over decoration. Clarity over ornament.
   ═══════════════════════════════════════════════════════════════════ */

/* ─── RESET ───────────────────────────────────────────────────── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ─── CUSTOM PROPERTIES — DESIGN TOKENS ───────────────────────── */
:root {
  /* ── Surfaces ── */
  --bg:               #F8F7F4;
  --surface:          #FFFFFF;
  --surface-raised:   #FFFFFF;

  /* ── Text ── */
  --text-primary:     #0F1117;
  --text-secondary:   #5C5F66;
  --text-muted:       #9CA0A8;

  /* ── Dividers ── */
  --divider:          #E8E7E3;
  --divider-strong:   #D3D2CD;

  /* ── Brand / Accent ── */
  --accent:           #5E5CE6;
  --accent-hover:     #4F4DD8;
  --accent-soft:      #F0EFFE;
  --accent-mid:       #C4C3F5;

  /* ── Semantic: Income ── */
  --income-bg:        #EFFCF4;
  --income-bg-hover:  #DDFAE9;
  --income-border:    rgba(34,197,94,0.14);
  --income-amount:    #0D9F4F;
  --income-amount-bg: #D1FAE5;

  /* ── Semantic: Expense ── */
  --expense-bg:       #F4F1FF;
  --expense-bg-hover: #EDEAFF;
  --expense-border:   rgba(124,92,191,0.12);
  --expense-amount:   #6D28D9;
  --expense-amount-bg:#EDE9FE;

  /* ── Today ── */
  --today-accent:     #3B82F6;
  --today-soft:       #EFF6FF;

  /* ── Shadows — Soft Ambient ── */
  --shadow-xs:  0 1px 2px rgba(15,17,23,0.04), 0 1px 3px rgba(15,17,23,0.03);
  --shadow-sm:  0 1px 3px rgba(15,17,23,0.04), 0 4px 12px rgba(15,17,23,0.04);
  --shadow-md:  0 2px 6px rgba(15,17,23,0.04), 0 8px 24px rgba(15,17,23,0.06);
  --shadow-lg:  0 4px 12px rgba(15,17,23,0.04), 0 20px 48px rgba(15,17,23,0.08);
  --shadow-modal: 0 8px 24px rgba(15,17,23,0.06), 0 32px 64px rgba(15,17,23,0.12);

  /* ── Radii ── */
  --r-sm:  8px;
  --r-md:  12px;
  --r-lg:  16px;
  --r-xl:  22px;

  /* ── Typography Scale ── */
  --font-display: 'DM Serif Display', Georgia, 'Times New Roman', serif;
  --font-body:    'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* ── Spacing Scale ── */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-7:  28px;
  --space-8:  32px;
  --space-10: 40px;
  --space-12: 48px;

  /* ── Motion ── */
  --ease-out:       cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out:    cubic-bezier(0.45, 0, 0.55, 1);
  --ease-spring:    cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-snap:      cubic-bezier(0.25, 1, 0.5, 1);
  --dur-fast:       0.12s;
  --dur-normal:     0.2s;
  --dur-slow:       0.32s;
  --dur-slower:     0.48s;

  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* ─── REDUCED MOTION ──────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  :root {
    --dur-fast:   0.01ms;
    --dur-normal: 0.01ms;
    --dur-slow:   0.01ms;
    --dur-slower: 0.01ms;
  }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ─── BODY ────────────────────────────────────────────────────── */
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text-primary);
  padding: var(--space-8) var(--space-10);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
  letter-spacing: -0.011em;
}

/* Prevent text selection only on interactive drag targets */
.txn-chip, .row, .day-header, .icon-btn {
  user-select: none;
  -webkit-user-select: none;
}

/* Subtle noise texture — adds tactile warmth */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.02'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
  opacity: 0.35;
}

.container {
  max-width: 1520px;
  margin: auto;
  position: relative;
  z-index: 1;
}

/* ─── FOCUS VISIBLE — ACCESSIBILITY ───────────────────────────── */
*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

button:focus-visible,
[role="button"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(94,92,230,0.15);
}

/* ═══════════════════════════════════════════════════════════════════
   HEADER
   ═══════════════════════════════════════════════════════════════════ */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
}

.left-bar {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.header {
  font-family: var(--font-display);
  font-size: clamp(26px, 3vw, 34px);
  font-weight: 400;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  line-height: 1;
}

.view-toggle-btn {
  padding: 7px 16px;
  border-radius: 100px;
  border: 1.5px solid var(--accent-mid);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-body);
  letter-spacing: 0.02em;
  transition:
    background var(--dur-normal) var(--ease-out),
    border-color var(--dur-normal) var(--ease-out),
    transform var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-normal) var(--ease-out);
}
.view-toggle-btn:hover {
  background: #E8E7FE;
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(94,92,230,0.15);
}
.view-toggle-btn:active {
  transform: translateY(0);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* ─── ICON BUTTONS ────────────────────────────────────────────── */
.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  transition:
    opacity var(--dur-normal) var(--ease-out),
    transform var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-normal) var(--ease-out),
    background var(--dur-normal) var(--ease-out);
  box-shadow: var(--shadow-xs);
  position: relative;
}
.icon-btn:hover {
  opacity: 0.88;
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.icon-btn:active {
  transform: translateY(0);
  box-shadow: var(--shadow-xs);
}
.icon-btn.light {
  background: var(--accent-soft);
  color: var(--accent);
}
.icon-btn.purple {
  background: var(--accent);
  color: #fff;
}
.icon-btn.dark {
  background: var(--text-primary);
  color: #fff;
}
.icon-btn.active {
  background: var(--accent) !important;
  color: #fff !important;
  box-shadow: 0 2px 8px rgba(94,92,230,0.3);
}

/* ═══════════════════════════════════════════════════════════════════
   SETTINGS MENU
   ═══════════════════════════════════════════════════════════════════ */
.settings-wrapper {
  position: relative;
}

.settings-menu {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  min-width: 200px;
  z-index: 200;
  padding: var(--space-2);
  animation: menuFadeIn var(--dur-normal) var(--ease-out);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

@keyframes menuFadeIn {
  from { opacity: 0; transform: translateY(-4px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.settings-item {
  padding: 10px 14px;
  font-size: 13.5px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2);
  color: var(--text-secondary);
  border-radius: var(--r-sm);
  transition:
    background var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out);
  font-weight: 400;
}
.settings-item:hover {
  background: var(--bg);
  color: var(--text-primary);
}
.settings-item.muted {
  color: var(--text-muted);
  cursor: not-allowed;
}
.settings-item.muted:hover {
  background: transparent;
  color: var(--text-muted);
}

.crown {
  font-size: 12px;
  color: #D4A600;
}

.settings-divider {
  height: 1px;
  background: var(--divider);
  margin: 5px 0;
}

/* ─── Theme Swatch in Settings ── */
.theme-swatch {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 5px;
  flex-shrink: 0;
  border: 1px solid rgba(0,0,0,0.06);
}

/* ═══════════════════════════════════════════════════════════════════
   USAGE BAR
   ═══════════════════════════════════════════════════════════════════ */
.usage-bar-wrapper {
  margin-bottom: var(--space-7);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.usage-track {
  flex: 1;
  max-width: 200px;
  height: 3px;
  background: var(--divider);
  border-radius: 10px;
  overflow: hidden;
}

.usage-fill {
  height: 100%;
  border-radius: 10px;
  background: var(--accent);
  transition:
    width 0.5s var(--ease-snap),
    background 0.3s var(--ease-out);
  width: 0%;
}
.usage-fill.warn { background: #D97706; }
.usage-fill.full { background: #DC2626; }

.usage-label {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  font-weight: 400;
  letter-spacing: 0.02em;
}
.usage-warn {
  font-size: 11px;
  color: #B45309;
  font-weight: 600;
}

/* ═══════════════════════════════════════════════════════════════════
   GRID LAYOUT
   ═══════════════════════════════════════════════════════════════════ */
.grid-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.grid-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  padding-bottom: var(--space-7);
  margin-bottom: var(--space-7);
  border-bottom: 1px solid var(--divider);
}
.grid-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 0;
}

/* ─── Day Column ──────────────────────────────────────────────── */
.day {
  padding: 0 var(--space-6) 0 0;
  position: relative;
  transition: background var(--dur-normal) var(--ease-out);
}

.day + .day {
  padding-left: var(--space-6);
  border-left: 1px solid var(--divider);
}

.day:nth-child(even) { background: transparent; }

.day-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}

.date {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 400;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  line-height: 1;
}

.weekday {
  font-size: 10.5px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.divider {
  height: 1.5px;
  background: var(--divider-strong);
  margin-bottom: var(--space-4);
  border-radius: 2px;
}

/* ═══════════════════════════════════════════════════════════════════
   ROW SLOTS
   ═══════════════════════════════════════════════════════════════════ */
.row {
  height: 40px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid transparent;
  font-size: 13.5px;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out);
  position: relative;
  overflow: visible;
  border-radius: var(--r-sm);
  margin: 1px 0;
}
.row:hover {
  background: rgba(94,92,230,0.03);
}
.row.drag-over {
  background: var(--today-soft);
  border-radius: var(--r-sm);
  outline: 1.5px dashed var(--today-accent);
  outline-offset: -1px;
}
.row.empty-row { cursor: default; }
.row.empty-row:hover { background: transparent; }

/* Locked rows */
.row.locked-row {
  cursor: not-allowed;
  opacity: 0.35;
}
.row.locked-row:hover { background: transparent; }
.row.locked-row:hover::after { display: none; }
.row.empty-row:hover::after {
  content: '+';
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px dashed var(--divider-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 22px;
  text-align: center;
  cursor: pointer;
  pointer-events: none;
  font-weight: 300;
  transition: border-color var(--dur-normal) var(--ease-out);
}

/* ═══════════════════════════════════════════════════════════════════
   TRANSACTION CHIPS — Primary Interactive Element
   ═══════════════════════════════════════════════════════════════════ */
.txn-chip {
  padding: 5px 10px;
  border-radius: var(--r-md);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
  cursor: grab;
  position: relative;
  transition:
    transform var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-normal) var(--ease-out),
    background var(--dur-normal) var(--ease-out);
}
.txn-chip:active { cursor: grabbing; }
.txn-chip.dragging { opacity: 0.35; transform: scale(0.97); }

/* Income chip — frosted mint */
.txn-income {
  background: var(--income-bg);
  border: 1px solid var(--income-border);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.8),
    inset 0 -1px 0 rgba(34,197,94,0.05),
    var(--shadow-xs);
}
.txn-income:hover {
  background: var(--income-bg-hover);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.9),
    var(--shadow-sm);
  transform: translateY(-1px);
}

/* Expense chip — pale lavender */
.txn-expense {
  background: var(--expense-bg);
  border: 1px solid var(--expense-border);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.8),
    inset 0 -1px 0 rgba(124,92,191,0.05),
    var(--shadow-xs);
}
.txn-expense:hover {
  background: var(--expense-bg-hover);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.9),
    var(--shadow-sm);
  transform: translateY(-1px);
}

.chip-amount {
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  flex-shrink: 0;
  font-size: 11.5px;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
}
.txn-income .chip-amount {
  background: var(--income-amount-bg);
  color: var(--income-amount);
}
.txn-expense .chip-amount {
  background: var(--expense-amount-bg);
  color: var(--expense-amount);
}

.chip-emoji {
  font-size: 13px;
  flex-shrink: 0;
  line-height: 1;
}

.chip-category {
  color: var(--text-secondary);
  font-weight: 400;
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
  letter-spacing: 0.01em;
}

.recurring-badge {
  font-size: 10.5px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.instance-badge { color: var(--accent-mid); }

/* Chip actions — visible on hover */
.chip-actions {
  display: none;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
  margin-left: auto;
}
.txn-chip:hover .chip-actions { display: flex; }

.chip-action-btn {
  width: 21px;
  height: 21px;
  border-radius: 50%;
  border: 1.5px solid var(--divider-strong);
  background: rgba(255,255,255,0.8);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  line-height: 1;
  transition:
    border-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out),
    background var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
  padding: 0;
}
.chip-action-btn:hover { transform: scale(1.12); }
.chip-action-btn.add-btn:hover {
  border-color: var(--today-accent);
  color: var(--today-accent);
  background: var(--today-soft);
}
.chip-action-btn.del-btn:hover {
  border-color: #EF4444;
  color: #EF4444;
  background: #FEF2F2;
}

/* ═══════════════════════════════════════════════════════════════════
   TODAY HIGHLIGHT
   ═══════════════════════════════════════════════════════════════════ */
.blue .date { color: var(--today-accent); }
.blue .weekday { color: #93A8E8; }
.blue .divider { background: var(--today-accent); }

/* ═══════════════════════════════════════════════════════════════════
   THIS WEEK COLUMN
   ═══════════════════════════════════════════════════════════════════ */
.this-week-day {
  padding-left: var(--space-6) !important;
}

.this-week-day .day-header {
  margin-bottom: var(--space-4);
}

.this-week-title {
  font-family: var(--font-display) !important;
  font-size: 19px !important;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.this-week-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.week-stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--divider);
  font-size: 13.5px;
  box-shadow: var(--shadow-xs);
  transition: background var(--dur-normal) var(--ease-out), box-shadow var(--dur-normal) var(--ease-out);
}
.week-stat:hover {
  background: var(--bg);
  box-shadow: var(--shadow-sm);
}

.week-stat.net-stat {
  background: var(--accent-soft);
  border: 1px solid rgba(94,92,230,0.12);
}

.week-stat-label {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.02em;
}
.week-stat-val {
  font-weight: 700;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.week-stat-val.income { color: var(--income-amount); }
.week-stat-val.expense { color: var(--expense-amount); }
.week-stat-val.net.positive { color: var(--today-accent); }
.week-stat-val.net.negative { color: #DC2626; }

.week-divider {
  height: 1px;
  background: var(--divider);
  margin: 2px 0;
}

.week-quote {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.65;
  font-style: italic;
  padding: 12px 14px;
  background: var(--surface);
  border-radius: var(--r-md);
  border-left: 2.5px solid var(--accent-mid);
  font-family: var(--font-body);
  font-weight: 300;
  box-shadow: var(--shadow-xs);
}
.week-quote-author {
  display: block;
  margin-top: 5px;
  color: var(--text-muted);
  font-style: normal;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

/* ═══════════════════════════════════════════════════════════════════
   MODAL — iOS Sheet Style
   ═══════════════════════════════════════════════════════════════════ */
#modalOverlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15,17,23,0.10);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  animation: overlayFadeIn var(--dur-normal) var(--ease-out);
}

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

.modal {
  background: rgba(255,255,255,0.97);
  backdrop-filter: blur(40px) saturate(1.8);
  -webkit-backdrop-filter: blur(40px) saturate(1.8);
  padding: 8px var(--space-6) 36px;
  border-radius: 28px 28px 0 0;
  box-shadow: var(--shadow-modal);
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-top: 1px solid rgba(255,255,255,0.9);
  animation: sheetSlideUp 0.28s var(--ease-snap);
}

@keyframes sheetSlideUp {
  from { transform: translateY(100%); opacity: 0.7; }
  to   { transform: translateY(0); opacity: 1; }
}

/* Drag handle */
.modal::before {
  content: '';
  display: block;
  width: 36px;
  height: 4px;
  background: var(--divider-strong);
  border-radius: 2px;
  margin: 0 auto var(--space-3);
  flex-shrink: 0;
}

.modal h3 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 400;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  text-align: center;
  margin-bottom: 4px;
}

/* Inputs — comfortable tap targets */
.modal input,
.modal select {
  padding: 14px 16px;
  border: 1.5px solid var(--divider);
  border-radius: var(--r-md);
  outline: none;
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 400;
  background: var(--bg);
  color: var(--text-primary);
  width: 100%;
  user-select: text;
  -webkit-user-select: text;
  transition:
    background var(--dur-normal) var(--ease-out),
    box-shadow var(--dur-normal) var(--ease-out),
    border-color var(--dur-normal) var(--ease-out);
  -webkit-appearance: none;
  appearance: none;
}

.modal input::placeholder {
  color: var(--text-muted);
  font-weight: 300;
}

/* Validation error state */
.modal input.input-error,
.modal select.input-error {
  background: #FFF5F5;
  border-color: #FCA5A5;
  box-shadow: 0 0 0 3px rgba(239,68,68,0.12);
  color: #B91C1C;
}
.modal input.input-error::placeholder {
  color: #B91C1C;
  opacity: 0.7;
}

.modal input:focus,
.modal select:focus {
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(94,92,230,0.12);
  outline: none;
}

.modal select {
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%239CA0A8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
  cursor: pointer;
}

.modal .btn-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-2);
}
.modal .row-btns {
  display: flex;
  gap: 10px;
}

.modal button {
  flex: 1;
  padding: 15px;
  border: none;
  border-radius: var(--r-md);
  cursor: pointer;
  font-weight: 600;
  font-size: 15px;
  font-family: var(--font-body);
  transition:
    background var(--dur-normal) var(--ease-out),
    transform var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-normal) var(--ease-out);
  letter-spacing: -0.01em;
}
.modal button:hover { transform: translateY(-1px); }
.modal button:active { transform: translateY(0); }

.btn-save {
  background: var(--text-primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(15,17,23,0.18);
}
.btn-save:hover {
  background: #252730;
  box-shadow: 0 4px 14px rgba(15,17,23,0.22);
}

.btn-cancel {
  background: var(--bg);
  color: var(--text-secondary);
  border: 1.5px solid var(--divider);
}
.btn-cancel:hover {
  background: var(--divider);
}

/* ═══════════════════════════════════════════════════════════════════
   PAYWALL
   ═══════════════════════════════════════════════════════════════════ */
#paywallOverlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15,17,23,0.35);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 300;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: var(--space-6);
}

.paywall-modal {
  background: rgba(255,255,255,0.98);
  padding: 40px 36px;
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-modal);
  max-width: 400px;
  width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  border: 1px solid rgba(255,255,255,0.9);
  animation: modalPopIn 0.25s var(--ease-snap);
}

@keyframes modalPopIn {
  from { transform: scale(0.95) translateY(8px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}

.paywall-crown {
  font-size: 42px;
  color: #D4A600;
  line-height: 1;
}

.paywall-modal h2 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 400;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.paywall-modal p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.65;
  font-weight: 300;
}

.paywall-features {
  background: var(--bg);
  border-radius: var(--r-md);
  padding: 16px 20px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 9px;
  border: 1px solid var(--divider);
}
.pf-item {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 400;
}

.paywall-cta {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--r-md);
  padding: 16px;
  font-size: 15.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-body);
  transition:
    background var(--dur-normal) var(--ease-out),
    transform var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-normal) var(--ease-out);
  letter-spacing: -0.01em;
  box-shadow: 0 4px 16px rgba(94,92,230,0.3);
}
.paywall-cta:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(94,92,230,0.35);
}
.paywall-cta:active {
  transform: translateY(0);
}

.paywall-dismiss {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  font-family: var(--font-body);
  padding: 4px;
  transition: color var(--dur-normal) var(--ease-out);
  font-weight: 300;
}
.paywall-dismiss:hover { color: var(--text-secondary); }

/* Paywall coming soon badges */
.pf-coming-soon { opacity: 0.6; }
.pf-badge {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 9px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 100px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-left: 6px;
  vertical-align: middle;
}

/* ═══════════════════════════════════════════════════════════════════
   MONTHLY VIEW
   ═══════════════════════════════════════════════════════════════════ */
.monthly-view {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4);
  padding-bottom: var(--space-6);
}

.monthly-card {
  padding: var(--space-5) var(--space-6);
  border-radius: var(--r-lg);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--divider);
  transition:
    transform var(--dur-normal) var(--ease-out),
    box-shadow var(--dur-normal) var(--ease-out);
}
.monthly-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.monthly-card.income-card { border-left: 3px solid #059669; }
.monthly-card.expense-card { border-left: 3px solid var(--accent); }
.monthly-card.fixed-card { border-left: 3px solid #D97706; }
.monthly-card.safe-card {
  border-left: 3px solid #059669;
  background: #F0FDF8;
}

.mc-label {
  font-size: 10.5px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.mc-val {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 400;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.mc-val.positive { color: #059669; }
.mc-val.negative { color: #DC2626; }
.mc-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
  font-weight: 300;
}

.monthly-breakdown {
  grid-column: 1 / -1;
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: var(--space-5) var(--space-6);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--divider);
}

.monthly-breakdown h4 {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 18px;
}

.category-bars {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cat-bar-row {
  display: grid;
  grid-template-columns: 130px 1fr 70px;
  align-items: center;
  gap: var(--space-4);
}
.cat-bar-label {
  font-size: 13px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 400;
}
.cat-bar-track {
  height: 6px;
  background: var(--divider);
  border-radius: 10px;
  overflow: visible;
  position: relative;
}
.cat-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 10px;
  transition: width 0.6s var(--ease-snap);
}
.cat-bar-fill--income {
  background: var(--income-amount);
}
.cat-bar-amt {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.no-data {
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
  font-weight: 300;
  padding: var(--space-2) 0;
}

/* Category bar extras */
.cat-bar-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}

.cat-bar-over .cat-bar-fill { background: #DC2626 !important; }
.cat-bar-budget-label {
  font-size: 10px;
  color: var(--accent);
  white-space: nowrap;
  margin-left: 4px;
}

/* Budget marker on category bars */
.cat-budget-marker {
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 2.5px;
  border-radius: 2px;
  pointer-events: auto;
  cursor: help;
  z-index: 2;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.6);
  transition: transform var(--dur-fast) var(--ease-out);
}
.cat-budget-marker:hover { transform: scaleX(1.8); }

/* ═══════════════════════════════════════════════════════════════════
   UNDO SNACKBAR
   ═══════════════════════════════════════════════════════════════════ */
#undoSnackbar {
  position: fixed;
  bottom: var(--space-8);
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--text-primary);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--r-md);
  font-size: 13.5px;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  box-shadow: var(--shadow-lg);
  z-index: 500;
  white-space: nowrap;
  transition:
    transform var(--dur-slow) var(--ease-snap),
    opacity var(--dur-slow) var(--ease-out);
  opacity: 0;
  pointer-events: none;
}

#undoSnackbar.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

#undoSnackbar strong { font-weight: 600; }

#undoSnackbar button {
  background: none;
  border: 1.5px solid rgba(255,255,255,0.35);
  color: #fff;
  border-radius: var(--r-sm);
  padding: 4px 12px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-body);
  transition: background var(--dur-fast) var(--ease-out);
}
#undoSnackbar button:hover {
  background: rgba(255,255,255,0.12);
}

.back-to-week-btn {
  grid-column: 1 / -1;
  background: none;
  border: 1.5px solid var(--divider);
  border-radius: var(--r-md);
  padding: 13px;
  font-size: 13.5px;
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font-body);
  transition:
    border-color var(--dur-normal) var(--ease-out),
    color var(--dur-normal) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
  font-weight: 400;
}
.back-to-week-btn:hover {
  border-color: var(--divider-strong);
  color: var(--text-secondary);
  transform: translateY(-1px);
}

/* ═══════════════════════════════════════════════════════════════════
   CATEGORIES SHEET
   ═══════════════════════════════════════════════════════════════════ */
.categories-modal {
  gap: 0 !important;
}

.cat-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 2px;
}

.cat-tab {
  padding: 7px 14px;
  border-radius: 100px;
  border: 1.5px solid var(--divider);
  background: transparent;
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font-body);
  transition:
    background var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out);
}
.cat-tab:hover {
  background: var(--bg);
  color: var(--text-secondary);
}
.cat-tab.active {
  background: var(--accent-soft);
  border-color: var(--accent-mid);
  color: var(--accent);
  font-weight: 600;
}

.cat-section-divider {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 10px 16px 6px;
}

.cat-list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: var(--r-sm);
  transition: background var(--dur-fast) var(--ease-out);
  cursor: default;
}
.cat-list-item:hover { background: var(--bg); }

.cat-item-emoji {
  font-size: 16px;
  flex-shrink: 0;
  width: 22px;
  text-align: center;
}
.cat-item-name {
  flex: 1;
  font-size: 13.5px;
  color: var(--text-primary);
  font-weight: 400;
}
.cat-item-type {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  flex-shrink: 0;
}
.cat-item-type.expense {
  background: var(--expense-amount-bg);
  color: var(--expense-amount);
}
.cat-item-type.income {
  background: var(--income-amount-bg);
  color: var(--income-amount);
}

.cat-item-del {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--divider-strong);
  background: rgba(255,255,255,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-muted);
  flex-shrink: 0;
  transition:
    border-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out);
  line-height: 1;
  padding: 0;
}
.cat-item-del:hover {
  border-color: #EF4444;
  color: #EF4444;
  background: #FEF2F2;
}

.cat-add-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 12px 16px;
  border-top: 1px solid var(--divider);
  background: var(--surface);
  position: sticky;
  bottom: 0;
}

.cat-emoji-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--r-sm);
  border: 1.5px solid var(--divider);
  background: var(--bg);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--dur-fast) var(--ease-out);
}
.cat-emoji-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent-mid);
}

/* Move-to-date label in modal */
#txnMoveDate {
  color: var(--text-secondary);
}

/* ═══════════════════════════════════════════════════════════════════
   NO-SPEND DAY VISUAL REWARD
   ═══════════════════════════════════════════════════════════════════ */
.no-spend-day { position: relative; }
.no-spend-day .day-header .date { color: #B45309; }
.no-spend-day .divider { background: linear-gradient(90deg, #D97706, #FBBF24); }
.no-spend-day::after {
  content: '👑';
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 14px;
  pointer-events: none;
  animation: crownPop 0.4s var(--ease-snap);
  z-index: 2;
}
@keyframes crownPop {
  from { transform: scale(0) rotate(-20deg); opacity: 0; }
  to   { transform: scale(1) rotate(0deg); opacity: 1; }
}

/* ═══════════════════════════════════════════════════════════════════
   PENDING / FREELANCE CHIPS
   ═══════════════════════════════════════════════════════════════════ */
.txn-pending {
  background: #FFFBEB !important;
  border: 1.5px dashed #D97706 !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.85), var(--shadow-xs) !important;
  animation: pendingPulse 2.5s ease-in-out infinite;
}
.txn-pending:hover {
  background: #FEF3C7 !important;
}
@keyframes pendingPulse {
  0%, 100% { border-color: #D97706; }
  50% { border-color: #B45309; box-shadow: 0 0 0 3px rgba(217,119,6,0.10), var(--shadow-xs); }
}
.txn-pending .chip-amount {
  background: #FEF3C7 !important;
  color: #B45309 !important;
}
.pending-badge {
  font-size: 10px;
  background: #FEF3C7;
  color: #B45309;
  border-radius: 6px;
  padding: 1px 5px;
  font-weight: 600;
  flex-shrink: 0;
  border: 1px solid #FCD34D;
}
.confirm-paid-btn {
  font-size: 10px !important;
  padding: 2px 7px !important;
  background: #FEF3C7 !important;
  color: #B45309 !important;
  border: 1px solid #FCD34D !important;
  border-radius: 6px !important;
  cursor: pointer;
  font-family: var(--font-body) !important;
  font-weight: 600 !important;
  transition: background var(--dur-fast) var(--ease-out);
  flex-shrink: 0;
}
.confirm-paid-btn:hover {
  background: #D97706 !important;
  color: #fff !important;
  border-color: #D97706 !important;
}

/* Pending income summary split */
.week-stat-pending {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.pending-split {
  font-size: 10.5px;
  color: #B45309;
  font-weight: 500;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 8px;
  background: #FFFBEB;
  border-radius: 6px;
  border: 1px solid #FCD34D;
}

/* ═══════════════════════════════════════════════════════════════════
   SUBSCRIPTION / FIXED COSTS TOGGLE
   ═══════════════════════════════════════════════════════════════════ */
body.subscription-mode .txn-chip:not(.txn-fixed) {
  opacity: 0.28;
  filter: grayscale(0.6);
  pointer-events: none;
}
body.subscription-mode .txn-chip.txn-fixed {
  outline: 2px solid #D97706;
  outline-offset: 1px;
  box-shadow: 0 0 0 4px rgba(217,119,6,0.10), var(--shadow-sm);
}
#subscriptionToggleBtn.active {
  background: #FEF3C7 !important;
  color: #B45309 !important;
  outline: 2px solid #D97706;
  outline-offset: 1px;
}
.subscription-banner {
  background: linear-gradient(135deg, #FFFBEB 0%, #FEF3C7 100%);
  border: 1px solid #FCD34D;
  border-radius: var(--r-md);
  padding: 10px 16px;
  font-size: 12.5px;
  color: #92400E;
  font-weight: 500;
  margin-bottom: var(--space-4);
  display: none;
  align-items: center;
  gap: 10px;
  animation: slideDown var(--dur-normal) var(--ease-out);
}
.subscription-banner.visible { display: flex; }
@keyframes slideDown {
  from { transform: translateY(-8px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

/* ═══════════════════════════════════════════════════════════════════
   WISHLIST / PARKING LOT DOCK
   ═══════════════════════════════════════════════════════════════════ */
.wishlist-dock {
  margin-top: var(--space-8);
  border-top: 1px solid var(--divider);
  padding-top: var(--space-5);
}
.wishlist-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}
.wishlist-title {
  font-family: var(--font-display);
  font-size: 16px;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}
.wishlist-subtitle {
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 300;
  flex: 1;
}
.wishlist-add-btn {
  padding: 6px 14px;
  border-radius: 100px;
  border: 1.5px solid var(--divider-strong);
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-body);
  transition:
    background var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out);
}
.wishlist-add-btn:hover {
  background: var(--bg);
  border-color: var(--accent-mid);
  color: var(--accent);
}

.wishlist-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  min-height: 48px;
  padding: var(--space-3);
  background: var(--surface);
  border-radius: var(--r-md);
  border: 1.5px dashed var(--divider-strong);
}
.wishlist-chips:empty::before {
  content: 'No impulse purchases parked. Stay strong! 💪';
  font-size: 12.5px;
  color: var(--text-muted);
  font-style: italic;
  font-weight: 300;
  display: flex;
  align-items: center;
}

.wishlist-chip {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 7px 12px;
  background: #FFFBEB;
  border: 1.5px solid #FCD34D;
  border-radius: var(--r-md);
  font-size: 13px;
  cursor: pointer;
  position: relative;
  transition:
    transform var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out);
  max-width: 220px;
}
.wishlist-chip:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.wishlist-chip-amount {
  font-weight: 700;
  color: #B45309;
  font-size: 12px;
  background: #FEF3C7;
  padding: 1px 6px;
  border-radius: 5px;
  font-variant-numeric: tabular-nums;
}
.wishlist-chip-label {
  color: var(--text-secondary);
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.wishlist-chip-countdown {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.wishlist-chip-countdown.ready {
  color: #059669;
  font-weight: 600;
}
.wishlist-chip-actions {
  display: none;
  align-items: center;
  gap: 4px;
}
.wishlist-chip:hover .wishlist-chip-actions { display: flex; }
.wishlist-chip-commit {
  font-size: 10px;
  padding: 2px 7px;
  border: 1px solid #059669;
  background: #D1FAE5;
  color: #059669;
  border-radius: 5px;
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 600;
  white-space: nowrap;
}
.wishlist-chip-commit:hover {
  background: #059669;
  color: #fff;
}
.wishlist-chip-del {
  font-size: 10px;
  padding: 2px 7px;
  border: 1px solid #FCA5A5;
  background: #FEF2F2;
  color: #DC2626;
  border-radius: 5px;
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 600;
}
.wishlist-chip-del:hover {
  background: #DC2626;
  color: #fff;
}

/* ═══════════════════════════════════════════════════════════════════
   BILLING DATE TOOLTIP
   ═══════════════════════════════════════════════════════════════════ */
.billing-tooltip {
  position: fixed;
  background: var(--text-primary);
  color: #fff;
  font-size: 12px;
  font-family: var(--font-body);
  padding: 8px 12px;
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  pointer-events: none;
  z-index: 9999;
  max-width: 220px;
  line-height: 1.5;
  animation: tooltipFade var(--dur-fast) var(--ease-out);
  white-space: normal;
}
@keyframes tooltipFade {
  from { opacity: 0; transform: translateY(4px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ═══════════════════════════════════════════════════════════════════
   SPARKLINE
   ═══════════════════════════════════════════════════════════════════ */
.sparkline-wrapper {
  padding: 0 0 12px 0;
  overflow: hidden;
  transition: opacity var(--dur-slow) var(--ease-out);
}
.sparkline-wrapper svg {
  width: 100%;
  height: 54px;
  display: block;
  overflow: visible;
}
.sparkline-label {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
  padding: 0 2px;
}

/* ═══════════════════════════════════════════════════════════════════
   INSIGHT BANNER
   ═══════════════════════════════════════════════════════════════════ */
.insight-banner {
  background: var(--accent-soft);
  border: 1px solid var(--accent-mid);
  border-radius: var(--r-md);
  padding: 12px 16px;
  font-size: 12.5px;
  color: var(--accent);
  font-weight: 400;
  margin-bottom: var(--space-4);
  display: none;
  align-items: flex-start;
  gap: 10px;
  line-height: 1.55;
  animation: slideDown 0.25s var(--ease-out);
}
.insight-banner.visible { display: flex; }
.insight-icon {
  font-size: 16px;
  flex-shrink: 0;
}
.insight-text { flex: 1; }
.insight-dismiss {
  font-size: 11px;
  color: var(--accent-mid);
  cursor: pointer;
  flex-shrink: 0;
  padding: 2px;
  transition: color var(--dur-fast) var(--ease-out);
}
.insight-dismiss:hover { color: var(--accent); }

/* ═══════════════════════════════════════════════════════════════════
   SCROLLBAR
   ═══════════════════════════════════════════════════════════════════ */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--divider-strong);
  border-radius: 2px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ═══════════════════════════════════════════════════════════════════
   DRAG & DROP PHYSICS
   ═══════════════════════════════════════════════════════════════════ */

/* 1. ELEVATION — chip lifts when grabbed */
.txn-chip.dragging {
  opacity: 0.92;
  transform: scale(1.06) rotate(1.5deg);
  box-shadow:
    0 16px 36px rgba(15,17,23,0.14),
    0 4px 12px rgba(15,17,23,0.08),
    inset 0 1px 0 rgba(255,255,255,0.9);
  cursor: grabbing;
  z-index: 50;
}

/* 2. MAGNETISM — drop target welcomes the chip */
.row.drag-over {
  background: rgba(94,92,230,0.05);
  border-radius: var(--r-md);
  outline: 1.5px dashed var(--accent-mid);
  outline-offset: -1px;
  transform: scaleY(0.97);
  transition:
    transform var(--dur-fast) var(--ease-snap),
    background var(--dur-fast) var(--ease-out),
    outline-color var(--dur-fast) var(--ease-out);
}

/* 3. SNAP — bouncy landing on drop */
@keyframes dropSnap {
  0%   { transform: scale(1.06) rotate(1.5deg); box-shadow: 0 12px 28px rgba(15,17,23,0.12); }
  55%  { transform: scale(0.965); box-shadow: 0 2px 6px rgba(15,17,23,0.05); }
  80%  { transform: scale(1.015); box-shadow: var(--shadow-xs); }
  100% { transform: scale(1) rotate(0deg); box-shadow: var(--shadow-xs); }
}

.txn-chip.dropped {
  animation: dropSnap 0.38s var(--ease-snap) forwards;
}

/* ═══════════════════════════════════════════════════════════════════
   SEARCH BAR
   ═══════════════════════════════════════════════════════════════════ */
.search-bar-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: var(--space-3);
  padding: 0 2px;
}

.search-input {
  flex: 1;
  padding: 11px 16px;
  border: 1.5px solid var(--accent-mid);
  border-radius: 100px;
  background: var(--surface);
  font-size: 14px;
  font-family: var(--font-body);
  color: var(--text-primary);
  outline: none;
  transition:
    border-color var(--dur-normal) var(--ease-out),
    box-shadow var(--dur-normal) var(--ease-out);
}
.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(94,92,230,0.10);
}
.search-input::placeholder {
  color: var(--text-muted);
}

.search-result-count {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  font-weight: 500;
  min-width: 60px;
}

/* Dimmed / matched chips during search */
.txn-chip.search-dim {
  opacity: 0.18;
  filter: grayscale(0.5);
  transition: opacity var(--dur-normal) var(--ease-out), filter var(--dur-normal) var(--ease-out);
}
.txn-chip.search-match {
  box-shadow: 0 0 0 2px var(--accent);
  opacity: 1;
}

/* ═══════════════════════════════════════════════════════════════════
   RECOVERY BANNER
   ═══════════════════════════════════════════════════════════════════ */
.recovery-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-mid);
  border-radius: var(--r-md);
  margin-bottom: var(--space-4);
  font-size: 13.5px;
  color: var(--accent);
  animation: bannerFadeIn 0.4s var(--ease-out);
}
body[data-theme="dark"] .recovery-banner,
body[data-theme="ocean"] .recovery-banner,
body[data-theme="forest"] .recovery-banner {
  background: var(--income-bg);
  border-color: var(--income-border);
}

@keyframes bannerFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.recovery-icon {
  font-size: 18px;
  flex-shrink: 0;
}
.recovery-text {
  flex: 1;
  line-height: 1.4;
}
body[data-theme="dark"] .recovery-text,
body[data-theme="ocean"] .recovery-text,
body[data-theme="forest"] .recovery-text {
  color: var(--income-amount);
}
.recovery-dismiss {
  cursor: pointer;
  font-size: 14px;
  color: var(--accent-mid);
  flex-shrink: 0;
  padding: 2px;
}
.recovery-dismiss:hover { color: var(--accent); }

/* ═══════════════════════════════════════════════════════════════════
   SPLIT BUTTON
   ═══════════════════════════════════════════════════════════════════ */
.btn-split {
  padding: 14px 16px;
  background: var(--bg);
  border: 1.5px solid var(--divider);
  border-radius: var(--r-md);
  font-size: 14px;
  font-family: var(--font-body);
  cursor: pointer;
  color: var(--text-secondary);
  font-weight: 500;
  transition:
    background var(--dur-normal) var(--ease-out),
    border-color var(--dur-normal) var(--ease-out),
    color var(--dur-normal) var(--ease-out);
  white-space: nowrap;
}
.btn-split:hover {
  background: var(--accent-soft);
  border-color: var(--accent-mid);
  color: var(--accent);
}
.btn-split.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ═══════════════════════════════════════════════════════════════════
   SPENDING PACE BAR
   ═══════════════════════════════════════════════════════════════════ */
.spending-pace-wrapper {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--divider);
}
.spending-pace-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 6px;
}
.spending-pace-track {
  position: relative;
  height: 6px;
  background: var(--divider);
  border-radius: 3px;
  overflow: visible;
  margin-bottom: 5px;
}
.spending-pace-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
  transition: width 0.6s var(--ease-snap), background var(--dur-slow) var(--ease-out);
}
.spending-pace-fill.warn { background: #D97706; }
.spending-pace-fill.over { background: #DC2626; }
.spending-pace-day-marker {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 2px;
  background: var(--text-muted);
  border-radius: 1px;
  transform: translateX(-50%);
}
.spending-pace-sub {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ═══════════════════════════════════════════════════════════════════
   PAYCHECK BADGE
   ═══════════════════════════════════════════════════════════════════ */
.paycheck-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 3px;
  flex-wrap: wrap;
}
.paycheck-badge.payday {
  color: #B45309;
  font-weight: 700;
}
.paycheck-hint {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 100px;
  padding: 2px 8px;
  font-size: 10px;
  cursor: pointer;
  font-weight: 600;
  transition: background var(--dur-fast) var(--ease-out);
}
.paycheck-hint:hover { background: var(--accent-mid); }

/* ═══════════════════════════════════════════════════════════════════
   MILESTONE TOAST
   ═══════════════════════════════════════════════════════════════════ */
.milestone-toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text-primary);
  color: #fff;
  border-radius: 100px;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  white-space: nowrap;
  opacity: 0;
  transition:
    opacity var(--dur-slow) var(--ease-out),
    transform var(--dur-slow) var(--ease-out);
  pointer-events: none;
}
.milestone-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ═══════════════════════════════════════════════════════════════════
   HEAT COLOURS ON DAY COLUMNS
   ═══════════════════════════════════════════════════════════════════ */
.day-col.heat-green { background: linear-gradient(180deg, rgba(16,185,129,0.06) 0%, transparent 40%); }
.day-col.heat-amber { background: linear-gradient(180deg, rgba(217,119,6,0.07) 0%, transparent 40%); }
.day-col.heat-red   { background: linear-gradient(180deg, rgba(239,68,68,0.08) 0%, transparent 40%); }
.day-col.heat-none  { /* no tint — zero spending day */ }

[data-theme="dark"] .day-col.heat-green { background: linear-gradient(180deg, rgba(16,185,129,0.12) 0%, transparent 40%); }
[data-theme="dark"] .day-col.heat-amber { background: linear-gradient(180deg, rgba(217,119,6,0.13) 0%, transparent 40%); }
[data-theme="dark"] .day-col.heat-red   { background: linear-gradient(180deg, rgba(239,68,68,0.13) 0%, transparent 40%); }

.day-col.heat-green .day-header { border-top: 2px solid #4ade80; }
.day-col.heat-amber .day-header { border-top: 2px solid #fbbf24; }
.day-col.heat-red   .day-header { border-top: 2px solid #f87171; }

/* ═══════════════════════════════════════════════════════════════════
   SCENARIO SIMULATOR
   ═══════════════════════════════════════════════════════════════════ */
.scenario-modal {
  max-height: 90vh;
  overflow-y: auto;
}
.scenario-current-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg);
  border-radius: var(--r-md);
  padding: 12px 16px;
  margin-bottom: 4px;
}
.scenario-result-card {
  border-radius: var(--r-md);
  padding: 16px;
  display: flex;
  gap: var(--space-4);
  align-items: flex-start;
  margin-top: 4px;
}
.scenario-result-card.ok {
  background: #F0FDF4;
  border: 1.5px solid #BBF7D0;
}
.scenario-result-card.warn {
  background: #FFFBEB;
  border: 1.5px solid #FDE68A;
}
[data-theme="dark"] .scenario-result-card.ok {
  background: rgba(16,185,129,0.1);
  border-color: rgba(16,185,129,0.25);
}
[data-theme="dark"] .scenario-result-card.warn {
  background: rgba(217,119,6,0.1);
  border-color: rgba(217,119,6,0.25);
}
.scenario-result-icon {
  font-size: 22px;
  flex-shrink: 0;
}
.scenario-result-body { flex: 1; }
.scenario-result-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 10px;
}
.scenario-stat {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-secondary);
  padding: 4px 0;
  border-bottom: 1px solid var(--divider);
}
.scenario-stat:last-child { border-bottom: none; }
.scenario-stat strong { font-weight: 700; }
.scenario-stat .pos { color: #059669; }
.scenario-stat .neg { color: #DC2626; }
.scenario-advice {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  line-height: 1.5;
}

/* ═══════════════════════════════════════════════════════════════════
   YEARLY VIEW
   ═══════════════════════════════════════════════════════════════════ */
.yearly-view {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: 0 4px var(--space-8);
}
.year-hero {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
@media (max-width: 700px) {
  .year-hero { grid-template-columns: repeat(2, 1fr); }
}
.year-hero-stat {
  background: var(--surface);
  border-radius: var(--r-md);
  padding: 16px 14px;
  text-align: center;
  box-shadow: var(--shadow-xs);
  border: 1px solid var(--divider);
}
.year-hero-label {
  font-size: 10.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
  font-weight: 600;
}
.year-hero-val {
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.year-hero-val.income { color: #059669; }
.year-hero-val.expense { color: #DC2626; }
.year-hero-val.positive { color: #059669; }
.year-hero-val.negative { color: #DC2626; }

.year-chart-card {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: var(--space-5) 16px 14px;
  border: 1px solid var(--divider);
  box-shadow: var(--shadow-xs);
}
.year-chart-card h4 {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: var(--space-4);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.year-bar-chart {
  display: flex;
  gap: 6px;
  align-items: flex-end;
  height: 110px;
  padding-bottom: var(--space-2);
}
.year-bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  border-radius: var(--r-sm);
  padding: 4px 2px;
  transition: background var(--dur-fast) var(--ease-out);
}
.year-bar-col:hover { background: var(--bg); }
.year-bar-pair {
  display: flex;
  gap: 2px;
  align-items: flex-end;
  height: 80px;
}
.year-bar {
  width: 10px;
  border-radius: 4px 4px 0 0;
  transition: height 0.4s var(--ease-spring);
  min-height: 2px;
}
.income-bar  { background: #6B56E8; }
.expense-bar { background: #E879A8; }
.year-bar-label {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 500;
}
.year-bar-net {
  font-size: 9px;
  font-weight: 700;
}
.year-bar-net.pos { color: #059669; }
.year-bar-net.neg { color: #DC2626; }
.year-chart-legend {
  display: flex;
  gap: var(--space-4);
  justify-content: center;
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-muted);
}
.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 4px;
}
.income-dot  { background: #6B56E8; }
.expense-dot { background: #E879A8; }

.year-highlights {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}
.year-highlight-card {
  background: var(--surface);
  border-radius: var(--r-md);
  padding: 18px 16px;
  text-align: center;
  border: 1px solid var(--divider);
  box-shadow: var(--shadow-xs);
}
.year-highlight-card.best  { border-left: 3px solid #059669; }
.year-highlight-card.worst { border-left: 3px solid #E879A8; }
.yh-label {
  font-size: 10.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
  font-weight: 600;
}
.yh-month {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.yh-val { font-size: 18px; font-weight: 700; }

.year-cats-card {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: var(--space-5) 16px;
  border: 1px solid var(--divider);
  box-shadow: var(--shadow-xs);
}
.year-cats-card h4 {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: var(--space-4);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.year-cat-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--divider);
}
.year-cat-row:last-child { border-bottom: none; }
.year-cat-rank {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 700;
  width: 18px;
  text-align: center;
}
.year-cat-name {
  font-size: 13px;
  color: var(--text-primary);
  width: 130px;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.year-cat-bar-track {
  flex: 1;
  height: 8px;
  background: var(--divider);
  border-radius: 4px;
  overflow: hidden;
}
.year-cat-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #6B56E8, #9B87F5);
  border-radius: 4px;
}
.year-cat-amt {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

.wrapped-launch-btn {
  background: var(--text-primary);
  color: #fff;
  border: none;
  border-radius: var(--r-md);
  padding: 16px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font-body);
  width: 100%;
  letter-spacing: 0.01em;
  transition:
    opacity var(--dur-normal) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
  box-shadow: 0 2px 8px rgba(15,17,23,0.18);
}
.wrapped-launch-btn:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

/* ═══════════════════════════════════════════════════════════════════
   WRAPPED MODAL
   ═══════════════════════════════════════════════════════════════════ */
.wrapped-modal {
  background: linear-gradient(160deg, #1a0533 0%, #0d1b4b 50%, #0a2635 100%);
  border-radius: 28px;
  padding: var(--space-8) var(--space-7);
  max-width: 480px;
  width: 100%;
  margin: var(--space-6);
  color: #fff;
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}
.wrapped-close {
  position: absolute;
  top: 18px;
  right: 20px;
  background: rgba(255,255,255,0.12);
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--dur-fast) var(--ease-out);
}
.wrapped-close:hover { background: rgba(255,255,255,0.2); }
.wrapped-header {
  text-align: center;
  margin-bottom: var(--space-6);
}
.wrapped-logo {
  font-size: 24px;
  font-weight: 800;
  background: linear-gradient(90deg, #9B87F5, #E879A8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 4px;
}
.wrapped-period {
  font-size: 14px;
  color: rgba(255,255,255,0.6);
  font-weight: 300;
}
.wrapped-slides {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.wrapped-slide {
  padding: var(--space-5) var(--space-2);
  text-align: center;
}
.ws-eyebrow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(255,255,255,0.5);
  font-weight: 600;
  margin-bottom: var(--space-2);
}
.ws-big-num {
  font-size: 38px;
  font-weight: 800;
  background: linear-gradient(90deg, #9B87F5, #60a5fa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 4px;
  line-height: 1;
}
.ws-emoji {
  font-size: 32px;
  margin: 6px 0;
}
.ws-label {
  font-size: 16px;
  font-weight: 600;
  color: rgba(255,255,255,0.9);
  margin-bottom: 4px;
}
.ws-sub {
  font-size: 13px;
  color: rgba(255,255,255,0.5);
  font-weight: 300;
}
.wrapped-divider {
  height: 1px;
  background: rgba(255,255,255,0.08);
  margin: 4px 0;
}
.wrapped-share-btn {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 14px;
  padding: 14px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-body);
  width: 100%;
  margin-top: var(--space-5);
  transition: background var(--dur-normal) var(--ease-out);
}
.wrapped-share-btn:hover { background: rgba(255,255,255,0.2); }

/* ═══════════════════════════════════════════════════════════════════
   SUBSCRIPTION GRAVEYARD
   ═══════════════════════════════════════════════════════════════════ */
.graveyard-modal {
  max-width: 500px;
  max-height: 80vh;
  overflow-y: auto;
}
.graveyard-header {
  text-align: center;
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--divider);
  margin-bottom: var(--space-3);
}
.graveyard-header h3 { margin: var(--space-2) 0 4px; }
.graveyard-savings {
  font-size: 13px;
  color: #059669;
  font-weight: 500;
  margin-top: var(--space-2);
  background: #ECFDF5;
  border-radius: 100px;
  padding: 5px 14px;
  display: inline-block;
}
[data-theme="dark"] .graveyard-savings {
  background: rgba(16,185,129,0.12);
}
.graveyard-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--bg);
  border-radius: var(--r-md);
  margin-bottom: var(--space-2);
  gap: var(--space-3);
}
.gc-category {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 3px;
}
.gc-meta {
  font-size: 12px;
  color: var(--text-muted);
}
.gc-actions {
  display: flex;
  gap: var(--space-2);
  flex-shrink: 0;
}
.gc-keep-btn {
  padding: 7px 14px;
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-secondary);
  font-family: var(--font-body);
  transition: background var(--dur-fast) var(--ease-out);
}
[data-theme="dark"] .gc-keep-btn {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.12);
  color: var(--text-secondary);
}
.gc-cancel-btn {
  padding: 7px 14px;
  background: #FFF5F5;
  border: 1px solid #FECACA;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: #DC2626;
  font-family: var(--font-body);
  transition: background var(--dur-fast) var(--ease-out);
}
[data-theme="dark"] .gc-cancel-btn {
  background: rgba(239,68,68,0.1);
  border-color: rgba(239,68,68,0.25);
}
.graveyard-empty {
  text-align: center;
  padding: var(--space-7) 16px;
  color: var(--text-muted);
}

/* ═══════════════════════════════════════════════════════════════════
   BUDGET TARGETS SHEET
   ═══════════════════════════════════════════════════════════════════ */
.budget-target-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg);
  border-radius: var(--r-md);
  margin-bottom: var(--space-2);
}
.bt-info { flex: 1; min-width: 100px; }
.bt-cat {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
.bt-spent {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}
.bt-progress-track {
  width: 100%;
  height: 6px;
  background: var(--divider);
  border-radius: 3px;
  overflow: hidden;
}
.bt-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.4s var(--ease-snap);
}
.bt-progress-fill.warn { background: #D97706; }
.bt-progress-fill.over { background: #DC2626; }
.bt-pct {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  min-width: 36px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.bt-pct.over { color: #DC2626; }
.bt-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
}
.bt-cap-input {
  flex: 1;
  padding: 8px 12px;
  border: 1.5px solid var(--divider);
  border-radius: var(--r-sm);
  background: var(--surface);
  font-size: 13px;
  font-family: var(--font-body);
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--dur-normal) var(--ease-out), box-shadow var(--dur-normal) var(--ease-out);
}
.bt-cap-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(94,92,230,0.10);
}
.bt-save-btn {
  padding: 8px 14px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--r-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-body);
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease-out);
}
.bt-save-btn:hover { background: var(--accent-hover); }
.bt-clear-btn {
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--divider);
  border-radius: var(--r-sm);
  font-size: 12px;
  cursor: pointer;
  color: var(--text-muted);
  font-family: var(--font-body);
  transition: border-color var(--dur-fast) var(--ease-out);
}
.bt-clear-btn:hover { border-color: var(--divider-strong); }

/* ═══════════════════════════════════════════════════════════════════
   MONTHLY CASH FLOW PROJECTION
   ═══════════════════════════════════════════════════════════════════ */
.monthly-projection-card {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 18px 16px 12px;
  border: 1px solid var(--divider);
  box-shadow: var(--shadow-xs);
}
.mp-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-3);
}
.mp-header h4 {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.mp-end-balance {
  font-size: 13px;
  font-weight: 600;
}
.mp-end-balance.positive { color: #059669; }
.mp-end-balance.negative { color: #DC2626; }
.mp-legend {
  display: flex;
  gap: var(--space-4);
  justify-content: flex-end;
  margin-top: var(--space-2);
  font-size: 11px;
  color: var(--text-muted);
}
.mp-legend-line {
  display: inline-block;
  width: 20px;
  height: 2px;
  vertical-align: middle;
  margin-right: 4px;
  border-radius: 2px;
}
.mp-legend-line.solid  { background: var(--today-accent); }
.mp-legend-line.dashed { background: var(--accent); }

/* ═══════════════════════════════════════════════════════════════════
   MONTHLY INSIGHTS CARD
   ═══════════════════════════════════════════════════════════════════ */
.monthly-insights-card {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: var(--space-5) 18px;
  border: 1px solid var(--divider);
  box-shadow: var(--shadow-xs);
}
.monthly-insights-card h4 {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--space-4);
  display: flex;
  align-items: center;
  gap: 6px;
}
.insight-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--divider);
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.5;
}
.insight-item:last-child { border-bottom: none; }
.insight-item-icon {
  font-size: 16px;
  flex-shrink: 0;
  margin-top: 1px;
}

/* ═══════════════════════════════════════════════════════════════════
   GOALS SECTION
   ═══════════════════════════════════════════════════════════════════ */
.goals-section {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: var(--space-5) 18px;
  border: 1px solid var(--divider);
  box-shadow: var(--shadow-xs);
  margin-top: var(--space-7);
}
.goals-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-4);
}
.goals-header h4 {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.goals-add-btn {
  padding: 7px 14px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1.5px solid var(--accent-mid);
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-body);
  transition: background var(--dur-fast) var(--ease-out);
}
.goals-add-btn:hover { background: #E4E3FE; }
.goals-row {
  display: flex;
  gap: var(--space-3);
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: none;
}
.goals-row::-webkit-scrollbar { display: none; }
.goal-card {
  min-width: 180px;
  max-width: 200px;
  flex-shrink: 0;
  background: var(--bg);
  border-radius: var(--r-md);
  padding: 14px;
  border: 1.5px solid var(--divider);
  transition: border-color var(--dur-normal) var(--ease-out), box-shadow var(--dur-normal) var(--ease-out);
}
.goal-card:hover {
  box-shadow: var(--shadow-sm);
  border-color: var(--divider-strong);
}
.goal-card.completed {
  border-color: #059669;
  background: #F0FDF4;
}
[data-theme="dark"] .goal-card.completed {
  background: rgba(5,150,105,0.1);
  border-color: rgba(5,150,105,0.4);
}
.goal-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.goal-amounts {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}
.goal-amounts strong { color: var(--text-primary); }
.goal-progress-track {
  height: 6px;
  background: var(--divider);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
}
.goal-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #9B87F5);
  border-radius: 3px;
  transition: width 0.6s var(--ease-snap);
}
.goal-card.completed .goal-progress-fill {
  background: linear-gradient(90deg, #059669, #34D399);
}
.goal-deadline {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
  min-height: 14px;
}
.goal-actions {
  display: flex;
  gap: 6px;
}
.goal-deposit-btn {
  flex: 1;
  padding: 6px 10px;
  background: var(--accent-soft);
  color: var(--accent);
  border: none;
  border-radius: var(--r-sm);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-body);
  transition: background var(--dur-fast) var(--ease-out);
}
.goal-deposit-btn:hover { background: #E4E3FE; }
.goal-del-btn {
  padding: 6px 10px;
  background: none;
  border: 1px solid var(--divider);
  border-radius: var(--r-sm);
  font-size: 11px;
  cursor: pointer;
  color: var(--text-muted);
  font-family: var(--font-body);
  transition: border-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.goal-del-btn:hover {
  color: #DC2626;
  border-color: #FCA5A5;
}

/* Goals modal */
#goalOverlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,17,23,0.10);
  align-items: flex-end;
  justify-content: center;
  z-index: 150;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
#goalOverlay.open {
  display: flex;
}

/* ═══════════════════════════════════════════════════════════════════
   FULL CALENDAR VIEW
   ═══════════════════════════════════════════════════════════════════ */
.month-calendar-section {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: var(--space-5) 16px;
  border: 1px solid var(--divider);
  box-shadow: var(--shadow-xs);
  margin-top: var(--space-7);
}
.month-calendar-section h4 {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--space-4);
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-header-cell {
  text-align: center;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 4px 0 var(--space-2);
}
.cal-cell {
  min-height: 58px;
  background: var(--bg);
  border-radius: var(--r-sm);
  padding: 6px 5px;
  cursor: pointer;
  transition:
    background var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out);
  position: relative;
}
.cal-cell:hover {
  background: var(--divider);
  transform: translateY(-1px);
  box-shadow: var(--shadow-xs);
  z-index: 1;
}
.cal-cell.empty {
  background: transparent;
  cursor: default;
}
.cal-cell.empty:hover {
  background: transparent;
  transform: none;
  box-shadow: none;
}
.cal-cell.today {
  background: var(--today-soft);
  border: 1.5px solid var(--today-accent);
}
.cal-date-num {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 3px;
}
.cal-cell.today .cal-date-num { color: var(--today-accent); }
.cal-cell-income {
  font-size: 9px;
  color: var(--income-amount);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-cell-expense {
  font-size: 9px;
  color: var(--expense-amount);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Calendar day popup */
#calDayPopup {
  display: none;
  position: fixed;
  z-index: 500;
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: 0;
  min-width: 260px;
  max-width: 320px;
  max-height: 360px;
  overflow-y: auto;
  animation: menuFadeIn var(--dur-normal) var(--ease-out);
}
.cal-popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--divider);
}
.cal-popup-date {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}
.cal-popup-close {
  background: none;
  border: none;
  font-size: 14px;
  cursor: pointer;
  color: var(--text-muted);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--dur-fast) var(--ease-out);
}
.cal-popup-close:hover { background: var(--bg); }
.cal-popup-chips {
  padding: 10px 12px 14px;
}
.cal-popup-chip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  margin-bottom: 6px;
  font-size: 13px;
}
.cal-popup-chip.income { background: var(--income-bg); }
.cal-popup-chip.expense { background: var(--expense-bg); }
.cal-popup-chip-amount { font-weight: 700; }
.cal-popup-chip.income .cal-popup-chip-amount { color: var(--income-amount); }
.cal-popup-chip.expense .cal-popup-chip-amount { color: var(--expense-amount); }
.cal-popup-chip-cat {
  color: var(--text-muted);
  font-size: 12px;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cal-popup-empty {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  padding: 12px 0;
  font-style: italic;
}

/* ═══════════════════════════════════════════════════════════════════
   RECURRING DELETE CONFIRM
   ═══════════════════════════════════════════════════════════════════ */
#recurringDeleteConfirm {
  animation: overlayFadeIn var(--dur-fast) var(--ease-out);
}

/* ═══════════════════════════════════════════════════════════════════
   WEEKLY DIGEST OVERLAY
   ═══════════════════════════════════════════════════════════════════ */
#weeklyDigestOverlay {
  animation: overlayFadeIn var(--dur-normal) var(--ease-out);
}

/* ═══════════════════════════════════════════════════════════════════
   LOCKED ROW MICRO-FEEDBACK
   ═══════════════════════════════════════════════════════════════════ */
.locked-row {
  cursor: not-allowed;
  opacity: 0.45;
  position: relative;
}
.locked-row-tooltip {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: var(--text-primary);
  color: #fff;
  font-size: 11px;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: var(--r-sm);
  white-space: nowrap;
  pointer-events: none;
  z-index: 50;
  animation: tooltipFadeIn var(--dur-fast) var(--ease-out);
  box-shadow: var(--shadow-sm);
}
@keyframes tooltipFadeIn {
  from { opacity: 0; transform: translate(-50%, -46%); }
  to   { opacity: 1; transform: translate(-50%, -50%); }
}
@keyframes lockedShake {
  0%, 100% { transform: translateX(0); }
  25%       { transform: translateX(-3px); }
  75%       { transform: translateX(3px); }
}
.locked-row-shake {
  animation: lockedShake 0.4s var(--ease-out);
}

/* ═══════════════════════════════════════════════════════════════════
   RESPONSIVE — TABLET (iPad portrait & landscape)
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  body { padding: var(--space-6) var(--space-7); }

  .grid-row {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-6) var(--space-7);
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
  }

  .day {
    padding: 0 !important;
    border-left: none !important;
  }
  .day-col {
    border-bottom: 1px solid var(--divider);
    padding-bottom: var(--space-6);
  }

  .this-week-day {
    grid-column: 1 / -1;
    border-bottom: none;
  }

  .this-week-content {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 10px;
  }
  .this-week-content .week-stat { flex: 1 1 calc(33% - 10px); }
  .this-week-content .week-divider { display: none; }
  .week-quote { flex: 1 1 100%; }
}

/* ═══════════════════════════════════════════════════════════════════
   RESPONSIVE — MOBILE (iPhone / Android)
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 600px) {
  body { padding: var(--space-4) var(--space-4); }

  .header { font-size: clamp(22px, 6vw, 28px); }
  .top-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-4);
  }
  .top-actions {
    width: 100%;
    justify-content: space-between;
  }

  /* Single column stacking */
  .grid-row { grid-template-columns: 1fr; }

  /* Card treatment when stacked */
  .day-col {
    background: var(--surface);
    border-radius: var(--r-md);
    padding: 16px !important;
    box-shadow: var(--shadow-xs);
    border: 1px solid var(--divider);
    border-bottom: 1px solid var(--divider) !important;
  }

  .this-week-day { grid-column: 1; }

  .this-week-content {
    flex-direction: column;
    gap: var(--space-2);
  }
  .this-week-content .week-stat { flex: none; }
  .this-week-content .week-divider { display: block; }

  /* Monthly view stacks 1 col */
  .monthly-view { grid-template-columns: 1fr; }
  .cat-bar-row { grid-template-columns: 90px 1fr 56px; }

  /* Modal — above iPhone home indicator */
  .modal {
    padding-bottom: max(36px, env(safe-area-inset-bottom, 24px));
    border-radius: 24px 24px 0 0;
  }

  /* Larger tap targets */
  .modal input,
  .modal select {
    padding: 16px;
    font-size: 16px; /* prevent iOS zoom */
  }

  /* Usage bar compact */
  .usage-bar-wrapper { flex-wrap: nowrap; }
  .usage-track { max-width: 120px; }
}

/* ═══════════════════════════════════════════════════════════════════
   DARK THEME
   Neutral charcoals, deep graphite surface hierarchy.
   ═══════════════════════════════════════════════════════════════════ */
body[data-theme="dark"] {
  --bg:              #0C0C0E;
  --bg-primary:      #0C0C0E;
  --bg-secondary:    #141418;
  --surface:         #1A1A20;
  --surface-raised:  #222228;

  --text-primary:    #EDEDF0;
  --text-secondary:  #8E8E9A;
  --text-muted:      #4E4E58;

  --divider:         #252530;
  --divider-strong:  #32323C;

  --accent:          #8B82F5;
  --accent-hover:    #A09AFF;
  --accent-soft:     #1A1638;
  --accent-mid:      #3E3870;

  --border:          #252530;
  --shadow:          0 8px 32px rgba(0,0,0,0.55);
  --radius:          12px;

  --shadow-xs:       0 1px 3px rgba(0,0,0,0.40);
  --shadow-sm:       0 2px 8px rgba(0,0,0,0.45);
  --shadow-md:       0 8px 24px rgba(0,0,0,0.55);
  --shadow-lg:       0 20px 60px rgba(0,0,0,0.65);
  --shadow-modal:    0 32px 80px rgba(0,0,0,0.72);

  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 22px;

  --income-bg:           #0A1F16;
  --income-bg-hover:     #0F2A1E;
  --income-border:       rgba(34,197,94,0.16);
  --income-amount:       #4ADE80;
  --income-amount-bg:    #14532D;

  --expense-bg:          #16102C;
  --expense-bg-hover:    #1E1540;
  --expense-border:      rgba(139,130,245,0.16);
  --expense-amount:      #C4B5FD;
  --expense-amount-bg:   #2E1F5E;

  --today-accent:    #6B8AFF;
  --today-soft:      #121830;
}

/* ═══════════════════════════════════════════════════════════════════
   OCEAN THEME
   Deep navy base, teal-to-aqua accent spectrum.
   ═══════════════════════════════════════════════════════════════════ */
body[data-theme="ocean"] {
  --bg:              #050D1A;
  --bg-primary:      #050D1A;
  --bg-secondary:    #0B1724;
  --surface:         #0F1E2E;
  --surface-raised:  #142838;

  --text-primary:    #D0E8F4;
  --text-secondary:  #74A4C0;
  --text-muted:      #3A6278;

  --divider:         #152A3C;
  --divider-strong:  #1D3850;

  --accent:          #0CB8A6;
  --accent-hover:    #0FD6C2;
  --accent-soft:     #052420;
  --accent-mid:      #0A6460;

  --border:          #152A3C;
  --shadow:          0 8px 32px rgba(0,8,28,0.60);
  --radius:          12px;

  --shadow-xs:       0 1px 3px rgba(0,8,28,0.45);
  --shadow-sm:       0 2px 8px rgba(0,8,28,0.50);
  --shadow-md:       0 8px 24px rgba(0,8,28,0.60);
  --shadow-lg:       0 20px 60px rgba(0,8,28,0.70);
  --shadow-modal:    0 32px 80px rgba(0,8,28,0.78);

  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 22px;

  --income-bg:           #041C16;
  --income-bg-hover:     #072620;
  --income-border:       rgba(12,184,166,0.16);
  --income-amount:       #0CB8A6;
  --income-amount-bg:    #042E26;

  --expense-bg:          #091624;
  --expense-bg-hover:    #0C1E30;
  --expense-border:      rgba(12,184,166,0.10);
  --expense-amount:      #5DD6CE;
  --expense-amount-bg:   #092C28;

  --today-accent:    #0CB8A6;
  --today-soft:      #061E1A;
}

/* ═══════════════════════════════════════════════════════════════════
   FOREST THEME
   Deep forest green with earthy midtones.
   ═══════════════════════════════════════════════════════════════════ */
body[data-theme="forest"] {
  --bg:              #070D0A;
  --bg-primary:      #070D0A;
  --bg-secondary:    #0D1810;
  --surface:         #121E16;
  --surface-raised:  #192A1E;

  --text-primary:    #D0E4D4;
  --text-secondary:  #72A07C;
  --text-muted:      #3A6042;

  --divider:         #182C1C;
  --divider-strong:  #203E26;

  --accent:          #48A86C;
  --accent-hover:    #5EC484;
  --accent-soft:     #091C0E;
  --accent-mid:      #215A30;

  --border:          #182C1C;
  --shadow:          0 8px 32px rgba(0,6,3,0.58);
  --radius:          12px;

  --shadow-xs:       0 1px 3px rgba(0,6,3,0.42);
  --shadow-sm:       0 2px 8px rgba(0,6,3,0.48);
  --shadow-md:       0 8px 24px rgba(0,6,3,0.58);
  --shadow-lg:       0 20px 60px rgba(0,6,3,0.68);
  --shadow-modal:    0 32px 80px rgba(0,6,3,0.75);

  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 22px;

  --income-bg:           #07180A;
  --income-bg-hover:     #0B2210;
  --income-border:       rgba(72,168,108,0.16);
  --income-amount:       #48A86C;
  --income-amount-bg:    #0E2E18;

  --expense-bg:          #0E160A;
  --expense-bg-hover:    #141E0E;
  --expense-border:      rgba(72,168,108,0.08);
  --expense-amount:      #A4D1AC;
  --expense-amount-bg:   #121E16;

  --today-accent:    #48A86C;
  --today-soft:      #0B1C0E;
}
