/* ─── COMPONENTS ─────────────────────────────────────────── */
/* Search Bar */
.search-bar-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1.5px solid var(--divider-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  animation: searchSlideIn 0.2s ease;
}
.search-bar-wrapper:focus-within {
  border-color: var(--accent);
}
@keyframes searchSlideIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.search-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  color: var(--text-primary);
}
.search-input::placeholder { color: var(--text-muted); }
.search-result-count {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  font-weight: 500;
}
.txn-chip.search-dim {
  opacity: 0.18;
  filter: grayscale(0.5);
  transition: opacity 0.2s, filter 0.2s;
}
.txn-chip.search-match {
  box-shadow: 0 0 0 2px var(--accent);
  opacity: 1;
}

/* ─── FILTER BAR ─────────────────────────────── */
.txn-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 18px;
}

.txn-filter-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.txn-filter-chip {
  padding: 5px 13px;
  border-radius: var(--r-full);
  border: 1.5px solid var(--divider-strong);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out);
  white-space: nowrap;
}
.txn-filter-chip:hover {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent-mid);
}
.txn-filter-chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.txn-sort-select {
  padding: 5px 28px 5px 12px;
  border-radius: var(--r-full);
  border: 1.5px solid var(--divider-strong);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  /* inline chevron */
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%236B6B65' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: border-color var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out);
  flex-shrink: 0;
}
.txn-sort-select:hover,
.txn-sort-select:focus {
  border-color: var(--accent-mid);
  color: var(--text-primary);
}

/* Dark / themed variants */
[data-theme="dark"] .txn-sort-select {
  background-color: var(--surface);
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%23A8A89E' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

@media (max-width: 600px) {
  .txn-filter-bar {
    gap: 8px;
  }
  .txn-filter-chip {
    padding: 4px 10px;
    font-size: 11px;
  }
  .txn-sort-select {
    font-size: 11px;
    padding: 4px 24px 4px 10px;
  }
}

/* Heatmap on Day Columns */
.day-col.heat-green { background: linear-gradient(180deg, rgba(16,185,129,0.07) 0%, transparent 40%); }
.day-col.heat-amber { background: linear-gradient(180deg, rgba(217,119,6,0.08) 0%, transparent 40%); }
.day-col.heat-red   { background: linear-gradient(180deg, rgba(239,68,68,0.09) 0%, transparent 40%); }
.day-col.heat-none  { /* 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%); }

/* Spending Pace Bar */
.spending-pace-wrapper {
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--bg);
  border-radius: var(--r-md);
  border: 1px solid var(--divider);
}
.spending-pace-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.2px;
  margin-bottom: 8px;
  text-transform: uppercase;
}
.spending-pace-track {
  height: 6px;
  background: var(--divider);
  border-radius: 10px;
  overflow: visible;
  position: relative;
}
.spending-pace-fill {
  height: 100%;
  border-radius: 10px;
  background: var(--accent);
  transition: width 0.6s cubic-bezier(0.4,0,0.2,1), background 0.3s;
  position: relative;
}
.spending-pace-fill.over { background: var(--error); } 
.spending-pace-fill.warn { background: #F59E0B; }
.spending-pace-day-marker {
  position: absolute;
  top: -4px;
  width: 2px;
  height: 14px;
  background: var(--text-muted);
  border-radius: 2px;
  transform: translateX(-50%);
}
.spending-pace-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  font-weight: 500;
}

/* Category Budget Lines */
.cat-bar-budget-line {
  position: absolute;
  top: 0;
  width: 2px;
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  opacity: 0.7;
  z-index: 2;
}
.cat-bar-over .cat-bar-fill { background: var(--error) !important; } 
.cat-bar-budget-label {
  font-size: 10px;
  color: var(--accent);
  white-space: nowrap;
  margin-left: 4px;
}
.cat-bar-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.cat-bar-fill--income {
  background: var(--income-amount);
}

/* Savings Goals Section */
.goals-section {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--divider);
}
.goals-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.goals-header h4 { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.goals-add-btn {
  padding: 7px 14px;
  background: var(--accent-soft);
  border: 1.5px solid var(--accent-mid);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: background 0.2s;
}
.goals-add-btn:hover { background: #E4DCFF; }
.goals-row {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: none;
}
.goals-row::-webkit-scrollbar { display: none; }
.goal-card {
  min-width: 200px;
  max-width: 240px;
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: var(--r-lg);
  padding: 16px;
  box-shadow: var(--shadow-xs);
  transition: box-shadow 0.2s, transform 0.2s;
}
.goal-card:hover { box-shadow: var(--shadow-sm); transform: translateY(-2px); }
.goal-card.completed { border-color: var(--income-border); background: var(--income-bg); }
.goal-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.goal-amounts {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.goal-amounts strong { color: var(--income-amount); }
.goal-progress-track {
  height: 6px;
  background: var(--divider);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 8px;
}
.goal-progress-fill {
  height: 100%;
  border-radius: 10px;
  background: var(--income-amount);
  transition: width 0.6s cubic-bezier(0.4,0,0.2,1);
}
.goal-card.completed .goal-progress-fill { background: #22C55E; }
.goal-deadline {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.goal-actions {
  display: flex;
  gap: 6px;
}
.goal-deposit-btn {
  flex: 1;
  padding: 7px;
  background: var(--accent-soft);
  border: none;
  border-radius: var(--r-sm);
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: background 0.15s;
}
.goal-deposit-btn:hover { background: #E4DCFF; }
.goal-del-btn {
  padding: 7px 10px;
  background: transparent;
  border: 1.5px solid var(--divider);
  border-radius: var(--r-sm);
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
}
.goal-del-btn:hover { color: var(--error); border-color: var(--error); } 

/* Calendar Grid */
.month-calendar-section {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--divider);
  grid-column: 1 / -1;
}
.month-calendar-section h4 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}
.cal-header-cell {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 6px 4px;
}
.cal-cell {
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: var(--r-sm);
  padding: 6px 8px;
  min-height: 56px;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s, transform 0.15s;
  position: relative;
  overflow: hidden;
}
.cal-cell:hover {
  background: var(--bg);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
  z-index: 1;
}
.cal-cell.empty { background: transparent; border-color: transparent; cursor: default; }
.cal-cell.empty:hover { transform: none; box-shadow: none; }
.cal-cell.today { border-color: var(--today-accent); background: var(--today-soft); }
.cal-date-num {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.cal-cell.today .cal-date-num { color: var(--today-accent); }
.cal-cell-income {
  font-size: 10px;
  color: var(--income-amount);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-cell-expense {
  font-size: 10px;
  color: var(--expense-amount);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Monthly Cash Flow Projection */
.monthly-projection-card {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 18px 16px 12px;
}
.mp-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.mp-header h4 { font-size: 13px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.4px; }
.mp-end-balance { font-size: 13px; font-weight: 600; }
.mp-end-balance.positive { color: var(--income-amount); } 
.mp-end-balance.negative { color: var(--error); } 
.mp-legend {
  display: flex;
  gap: 16px;
  justify-content: flex-end;
  margin-top: 8px;
  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;
}
:root {
  --mp-confirmed-color: var(--today-accent);
  --mp-projected-color: var(--accent-mid);
}
.mp-legend-line.solid  { background: var(--mp-confirmed-color); }
.mp-legend-line.dashed { background: var(--mp-projected-color); }

.coach-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--r-md);
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: 500;
  background: var(--bg-card);
  border: 1.5px solid var(--divider);
  color: var(--text-primary);
  animation: fadeSlideIn 0.25s ease;
}
.coach-card.coach-warn {
  background: var(--error-bg, #FFF5F5);
  border-color: var(--error-border, #FCA5A5);
}
.coach-icon { font-size: 18px; flex-shrink: 0; }
.coach-text { flex: 1; line-height: 1.45; }
.coach-dismiss {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 16px;
  padding: 0 4px;
  flex-shrink: 0;
}
.coach-dismiss:hover { color: var(--text-primary); }

/* Recovery Banner */
.recovery-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--income-bg);
  border: 1.5px solid var(--income-border);
  border-radius: var(--r-md);
  margin-bottom: 14px;
  animation: bannerFadeIn 0.4s ease;
}
@keyframes bannerFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.recovery-icon { font-size: 18px; flex-shrink: 0; }
.recovery-text { font-size: 13px; color: var(--income-amount); font-weight: 400; flex: 1; line-height: 1.4; } 
.recovery-dismiss {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 13px;
  padding: 2px 4px;
  border-radius: 4px;
  flex-shrink: 0;
}
.recovery-dismiss:hover { color: var(--text-secondary); }

/* 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: 'DM Sans', sans-serif;
  cursor: pointer;
  color: var(--text-secondary);
  font-weight: 500;
  transition: background 0.2s, border-color 0.2s;
  white-space: nowrap;
}
.btn-split:hover { background: var(--accent-soft); border-color: var(--accent-mid); color: var(--accent); }
.btn-split.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* Scenario Simulator */
.scenario-modal .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: 18px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-top: 4px;
}
.scenario-result-card.ok  { background: var(--income-bg, #ecfdf5); border: 1px solid var(--income-border, #a7f3d0); }
.scenario-result-card.warn{ background: #fff7ed; border: 1px solid #fed7aa; }
[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(251,191,36,0.1); border-color: rgba(251,191,36,0.25); }
.scenario-result-icon { font-size: 22px; padding-top: 2px; }
.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: var(--income-amount); } 
.scenario-stat .neg { color: var(--error); } 
.scenario-advice {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  line-height: 1.5;
}

/* ── Recurring Section ──────────────────────────────── */
.recurring-section {
  background: var(--surface);
  border-radius: var(--r-lg);
  border: 1px solid var(--divider);
  padding: 22px 24px;
}
.recurring-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.recurring-monthly-total {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg);
  padding: 3px 10px;
  border-radius: var(--r-full);
  border: 1px solid var(--divider);
}
.recurring-group {
  margin-bottom: 14px;
}
.recurring-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--divider);
  font-size: 13px;
}
.recurring-row:last-child { border-bottom: none; }
.recurring-row-icon {
  font-size: 11px;
  font-weight: 700;
  width: 16px;
  flex-shrink: 0;
  color: var(--text-muted);
}
.recurring-row-cat {
  flex: 1;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.recurring-row-amt {
  font-weight: 700;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.recurring-row-amt.income  { color: var(--income-amount); }
.recurring-row-amt.expense { color: var(--expense-amount); }
.recurring-row-edit,
.recurring-row-del {
  padding: 4px 10px;
  border-radius: var(--r-sm);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-body);
  border: 1.5px solid var(--divider);
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.recurring-row-edit {
  background: var(--bg);
  color: var(--text-secondary);
}
.recurring-row-edit:hover {
  border-color: var(--accent-mid);
  color: var(--accent);
  background: var(--accent-soft);
}
.recurring-row-del {
  background: transparent;
  color: var(--text-muted);
}
.recurring-row-del:hover {
  border-color: var(--error-border);
  color: var(--error);
  background: var(--error-bg);
}

/* ── Calendar Popup Add Button ─────────────────────── */
.cal-popup-add-btn {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 10px;
  background: var(--accent-soft);
  border: 1.5px solid var(--accent-mid);
  border-radius: var(--r-md);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  text-align: center;
  transition: background 0.15s, border-color 0.15s;
}
.cal-popup-add-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

