/* ─── MODALS & OVERLAYS ──────────────────────────────────── */
#modalOverlay {
  position: fixed; top:0; left:0; width:100%; height:100%;
  background: rgba(26,26,24,0.55); 
  display: none; align-items: flex-end; justify-content: center;
  z-index: var(--z-overlay);
  will-change: transform;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: overlayFadeIn 0.2s ease;
}

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

.modal {
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  padding: 8px 24px 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 cubic-bezier(0.32,0.72,0,1);
}

@supports not (backdrop-filter: blur(1px)) {
  .modal {
    background: #FFFFFF;
  }
}

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

.modal::before {
  content: '';
  display: block;
  width: 36px;
  height: 4px;
  background: var(--divider-strong);
  border-radius: 2px;
  margin: 0 auto 12px;
  flex-shrink: 0;
  cursor: grab;
  touch-action: pan-y;
}

.modal h3 {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 20px;
  font-weight: 400;
  color: var(--text-primary);
  letter-spacing: -0.3px;
  text-align: center;
  margin-bottom: 4px;
}

/* Comfortable tap-friendly inputs */
.modal input,
.modal select {
  padding: 14px 16px;
  border: none;
  border-radius: var(--r-md);
  outline: none;
  font-family: 'DM Sans', sans-serif;
  font-size: 16px; 
  font-weight: 400;
  background: var(--bg);
  color: var(--text-primary);
  width: 100%;
  user-select: text;
  -webkit-user-select: text;
  transition: background 0.2s ease, box-shadow 0.2s ease;
  -webkit-appearance: none;
  appearance: none;
}

.modal input[type="date"] {
  position: relative;
  z-index: 1;
  cursor: pointer;
  min-height: 52px;
}
@supports (-webkit-touch-callout: none) {
  #modalOverlay {
    padding-bottom: env(safe-area-inset-bottom, 0px);
    align-items: flex-start;
    padding-top: max(40px, env(safe-area-inset-top, 40px));
  }
}

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

.modal input.input-error,
.modal select.input-error {
  background: var(--error-bg); 
  box-shadow: 0 0 0 2px rgba(239,68,68,0.25);
  color: #DC2626;
}
.modal input.input-error::placeholder {
  color: #DC2626;
  opacity: 0.8;
}

.modal input:focus,
.modal select:focus {
  background: #F0EDFF;
  box-shadow: 0 0 0 2px rgba(107,86,232,0.18);
  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='%23A8A89E' 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: 8px; margin-top: 8px; }
.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: 'DM Sans', sans-serif;
  transition: background 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
  letter-spacing: -0.1px;
}
.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(26,26,24,0.18);
}
.btn-save:hover { background: #2D2D2A; box-shadow: 0 4px 14px rgba(26,26,24,0.22); }

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

/* Categories Modal */
.categories-modal {
  gap: 0 !important;
}
.cat-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 2px;
}
.cat-tab {
  padding: 7px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--divider);
  background: transparent;
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.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);
}
.cat-section-divider {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  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 0.15s ease;
  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 0.15s ease, color 0.15s ease;
  line-height: 1;
  padding: 0;
}
.cat-item-del:hover { border-color: var(--error); color: var(--error); background: var(--error-bg); } 
.cat-add-row {
  display: flex;
  align-items: center;
  gap: 8px;
  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 0.15s ease;
}
.cat-emoji-btn:hover { background: var(--accent-soft); border-color: var(--accent-mid); }

/* Paywall */
#paywallOverlay {
  position: fixed; top:0; left:0; width:100%; height:100%;
  background: rgba(26,26,24,0.65); 
  display: none; align-items: center; justify-content: center;
  z-index: var(--z-overlay);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 24px;
  will-change: transform;
}
.paywall-modal {
  background: rgba(255,255,255,0.97);
  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: 16px;
  border: 1px solid rgba(255,255,255,0.9);
  animation: modalPopIn 0.25s cubic-bezier(0.32,0.72,0,1);
}
@keyframes modalPopIn {
  from { transform: scale(0.94) 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: 'DM Serif Display', Georgia, serif;
  font-size: 24px;
  font-weight: 400;
  color: var(--text-primary);
  letter-spacing: -0.4px;
}
.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;
}
.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.5px;
  margin-left: 6px;
  vertical-align: middle;
}
.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: 'DM Sans', sans-serif;
  transition: background 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
  letter-spacing: -0.1px;
  box-shadow: 0 4px 16px rgba(107,86,232,0.3);
}
.paywall-cta:hover {
  background: #5B48D8;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(107,86,232,0.35);
}
.paywall-dismiss {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  padding: 4px;
  transition: color 0.2s ease;
  font-weight: 300;
}
.paywall-dismiss:hover { color: var(--text-secondary); }

/* Goal Overlay */
#goalOverlay {
  position: fixed;
  inset: 0;
  background: rgba(26,26,24,0.14);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: var(--z-overlay);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
#goalOverlay.open {
  display: flex;
}

/* Additional Overlays */
.overlay-hidden {
  display: none;
}
#depositOverlay, 
#weeklyDigestOverlay {
  position: fixed;
  inset: 0;
  background: rgba(26,26,24,0.12);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: var(--z-overlay);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
#recurringDeleteConfirm {
  animation: fadeIn 0.18s ease;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Calendar Day Popup */
#calDayPopup {
  position: fixed;
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--divider);
  padding: 0;
  min-width: 260px;
  max-width: 320px;
  max-height: 360px;
  overflow-y: auto;
  z-index: var(--z-popup);
  display: none;
  animation: menuFadeIn 0.15s ease;
}
.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;
}
.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; }

/* Wrapped Modal */
.wrapped-modal {
  background: linear-gradient(160deg, #1a0533 0%, #0d1b4b 50%, #0a2635 100%);
  border-radius: 28px;
  padding: 32px 28px;
  max-width: 480px;
  width: 100%;
  margin: 24px;
  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;
}
.wrapped-header { text-align: center; margin-bottom: 24px; }
.wrapped-logo { font-size: 24px; font-weight: 800; background: linear-gradient(90deg,#9B87F5,#F472B6); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; 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: 20px 8px;
  text-align: center;
}
.ws-eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px; color: rgba(255,255,255,0.5); font-weight: 600; margin-bottom: 8px; }
.ws-big-num { font-size: 38px; font-weight: 800; background: linear-gradient(90deg,#9B87F5,#60a5fa); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; 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: 'DM Sans', sans-serif;
  width: 100%;
  margin-top: 20px;
  transition: background 0.2s;
}
.wrapped-share-btn:hover { background: rgba(255,255,255,0.2); }

/* Subscription Graveyard Modal */
.graveyard-modal {
  max-width: 500px;
  max-height: 80vh;
  overflow-y: auto;
}
.graveyard-header {
  text-align: center;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--divider);
  margin-bottom: 12px;
}
.graveyard-header h3 { margin: 8px 0 4px; }
.graveyard-savings {
  font-size: 13px;
  color: var(--income-amount); 
  font-weight: 500;
  margin-top: 8px;
  background: var(--income-bg); 
  border-radius: 100px;
  padding: 5px 14px;
  display: inline-block;
}
.graveyard-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--bg);
  border-radius: var(--r-md);
  margin-bottom: 8px;
  gap: 12px;
}
.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: 8px; 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: 'DM Sans', sans-serif;
}
.gc-cancel-btn {
  padding: 7px 14px;
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: var(--error);
  font-family: 'DM Sans', sans-serif;
}
[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: 28px 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: 8px;
}
.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; }
.bt-progress-fill.warn { background: #D97706; }
.bt-progress-fill.over { background: var(--error); } 
.bt-pct { font-size: 11px; font-weight: 700; color: var(--text-muted); min-width: 36px; text-align: right; }
.bt-pct.over { color: var(--error); } 
.bt-actions { display: flex; align-items: center; gap: 6px; width: 100%; }
.bt-cap-input {
  flex: 1;
  padding: 8px 12px;
  border: none;
  border-radius: 8px;
  background: var(--surface);
  font-size: 13px;
  font-family: 'DM Sans', sans-serif;
  color: var(--text-primary);
  outline: none;
}
.bt-save-btn {
  padding: 8px 14px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  white-space: nowrap;
}
.bt-clear-btn {
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--divider);
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-muted);
  font-family: 'DM Sans', sans-serif;
}

/* Debt Payoff Modal */
.debt-payoff-modal {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.debt-payoff-result-card {
  background: var(--accent-soft, rgba(108,99,255,0.06));
  border: 1px solid var(--accent-mid, rgba(108,99,255,0.18));
  border-radius: var(--r-md);
  padding: 14px 16px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.7;
}
.debt-payoff-result-card strong { color: var(--text-primary); }
.debt-payoff-result-card .dp-highlight {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  display: block;
  margin: 4px 0 2px;
  font-family: var(--font-display);
}
.debt-payoff-result-card .dp-saving {
  color: #059669;
  font-weight: 600;
}
.debt-payoff-result-card .dp-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px solid var(--divider);
  font-size: 12px;
}
.debt-payoff-result-card .dp-row:last-child { border-bottom: none; }

/* Ghost chips — seductive empty state */
.txn-ghost {
  opacity: 0.28;
  pointer-events: none;
  animation: ghostBreathe 3s ease-in-out infinite;
  filter: blur(0.3px);
}
@keyframes ghostBreathe {
  0%, 100% { opacity: 0.22; }
  50%       { opacity: 0.38; }
}

/* Pulsing + button on today */
.ghost-add-pulse {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 18px;
  font-weight: 300;
  border: none;
  cursor: pointer;
  margin: 8px auto 4px;
  animation: ghostPulse 2s ease-in-out infinite;
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent);
}
@keyframes ghostPulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 50%, transparent); }
  70%  { box-shadow: 0 0 0 10px color-mix(in srgb, var(--accent) 0%, transparent); }
  100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 0%, transparent); }
}

/* Floating hint bar */
.onboarding-hint {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text-primary);
  color: var(--bg);
  font-size: 13px;
  font-weight: 500;
  padding: 9px 18px;
  border-radius: 100px;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.6s ease;
  z-index: 200;
  white-space: nowrap;
}

/* More Menu (overflow dropdown) */
.more-group {
  position: relative;
}
.more-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.06);
  overflow: hidden;
  z-index: var(--z-popup);
  opacity: 0;
  transform: translateY(-6px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  transform-origin: top right;
}
.more-menu.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.more-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background 0.12s ease;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}
.more-menu-item:hover {
  background: var(--bg);
}
.more-menu-item:active {
  background: var(--accent-soft);
}
.more-menu-icon {
  font-size: 17px;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}
.more-menu-label {
  flex: 1;
  font-family: var(--font-body);
}
.more-menu-divider {
  height: 1px;
  background: var(--divider);
  margin: 4px 0;
}

