/* ===================================================
   JENTRAX — COMPONENT STYLES
   Buttons, cards, forms, badges, modals, toasts,
   tables, progress bars, color pickers
   =================================================== */

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s, opacity 0.15s;
  white-space: nowrap;
  border: 1px solid transparent;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-dark);
  box-shadow: 0 2px 8px rgba(108,99,255,.35);
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--color-bg);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--color-bg);
  color: var(--color-text);
}

.btn-danger {
  background: var(--color-danger);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  background: var(--color-danger-dark);
}

.btn-icon {
  padding: 8px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

/* ── Search Bar ── */
.search-wrap {
  position: relative;
  flex: 1;
  min-width: 180px;
  max-width: 320px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
  pointer-events: none;
}

.search-input {
  padding-left: 36px !important;
}

/* ── Filter Button ── */
.filter-btn {
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-text-muted);
  background: transparent;
  transition: background 0.15s, color 0.15s;
}

.filter-btn.active {
  background: var(--color-primary);
  color: #fff;
}

.filter-btn:hover:not(.active) {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

/* ── Stat Cards (Premium Gradient) ── */
.stat-card {
  border: none;
  border-radius: var(--radius-xl);
  padding: var(--space-lg) var(--space-xl);
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
  color: #fff;
  transition: box-shadow 0.2s ease;
}

.stat-card:hover {
  box-shadow: var(--shadow-lg);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: -30%;
  right: -20%;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(255,255,255,.12);
}

.stat-card::after {
  content: '';
  position: absolute;
  bottom: -20%;
  left: -10%;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(255,255,255,.08);
}

.stat-card--income {
  background: linear-gradient(135deg, #22c55e 0%, #16a34a 50%, #15803d 100%);
}

.stat-card--expense {
  background: linear-gradient(135deg, #f43f5e 0%, #e11d48 50%, #be123c 100%);
}

.stat-card--net {
  background: linear-gradient(135deg, #6C63FF 0%, #7c3aed 50%, #6d28d9 100%);
}

.stat-card--budget {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 50%, #b45309 100%);
}

.stat-label {
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255,255,255,.95);
  margin-bottom: var(--space-sm);
  position: relative;
  z-index: 1;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.15;
  margin-bottom: var(--space-xs);
  position: relative;
  z-index: 1;
  word-break: break-word;
  overflow-wrap: break-word;
}

.stat-value--positive { color: #fff; }
.stat-value--negative { color: #fff; }

.stat-sub {
  font-size: 0.8125rem;
  color: rgba(255,255,255,.9);
  position: relative;
  z-index: 1;
}

/* ── Chart Cards (Premium Glass) ── */
.chart-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
  transition: box-shadow 0.2s ease;
}

.chart-card:hover {
  box-shadow: var(--shadow-lg);
}

.chart-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--color-primary);
}

.chart-card__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.chart-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text);
}

.chart-subtitle {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  font-weight: 500;
}

/* ── Forms ── */
.form-group {
  margin-bottom: var(--space-lg);
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: var(--space-sm);
}

.form-hint {
  display: block;
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--color-text-muted);
  margin-top: 2px;
}

.required {
  color: var(--color-expense);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-md);
  margin-top: var(--space-lg);
}

.input {
  width: 100%;
  padding: 9px 12px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 0.9375rem;
  color: var(--color-text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(108,99,255,.12);
}

.input.error {
  border-color: var(--color-expense);
}

.select {
  width: 100%;
  padding: 9px 32px 9px 12px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 0.9375rem;
  color: var(--color-text);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%2364748b' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
  transition: border-color 0.15s;
}

.select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(108,99,255,.12);
}

.input-prefix-wrap {
  display: flex;
  align-items: center;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input-prefix-wrap:focus-within {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(108,99,255,.12);
}

.input-prefix {
  padding: 9px 10px 9px 12px;
  background: var(--color-bg);
  color: var(--color-text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  border-right: 1px solid var(--color-border);
  white-space: nowrap;
}

.input--prefixed {
  border: none !important;
  box-shadow: none !important;
  border-radius: 0 var(--radius-md) var(--radius-md) 0 !important;
}

.field-error {
  font-size: 0.8125rem;
  color: var(--color-expense);
  margin-top: var(--space-xs);
}

/* ── Type Toggle ── */
.type-toggle {
  display: flex;
  gap: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.type-toggle__option {
  flex: 1;
  cursor: pointer;
}

.type-toggle__option input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.type-toggle__option span {
  display: block;
  padding: 9px 16px;
  text-align: center;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-muted);
  background: var(--color-surface);
  transition: background 0.15s, color 0.15s;
  border-right: 1px solid var(--color-border);
}

.type-toggle__option:last-child span {
  border-right: none;
}

.type-toggle__option input:checked + span {
  background: var(--color-primary);
  color: #fff;
}

/* ── Color Picker ── */
.color-picker {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  padding: var(--space-sm);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.color-swatch-label {
  cursor: pointer;
  position: relative;
}

.color-swatch-label input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: block;
  transition: transform 0.15s, box-shadow 0.15s;
}

.color-swatch-label input:checked + .color-swatch {
  box-shadow: 0 0 0 2px var(--color-surface), 0 0 0 4px currentColor;
  transform: scale(1.15);
}

.color-swatch-label:hover .color-swatch {
  transform: scale(1.1);
}

/* ── Modals ── */
.modal {
  padding: 0;
  border: none;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  max-width: 520px;
  width: calc(100vw - var(--space-xl));
  background: var(--color-surface);
}

.modal--sm {
  max-width: 360px;
}

.modal::backdrop {
  background: rgba(15,23,42,.45);
  backdrop-filter: blur(2px);
}

.modal-inner {
  padding: var(--space-xl);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
}

.modal-title {
  font-size: 1.125rem;
  font-weight: 700;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-md);
  margin-top: var(--space-xl);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--color-border);
}

.confirm-message {
  color: var(--color-text-muted);
  margin-bottom: var(--space-lg);
}

/* ── Toast Notifications ── */
.toast-container {
  position: fixed;
  bottom: var(--space-xl);
  right: var(--space-xl);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 12px 16px;
  background: var(--color-text);
  color: #fff;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  min-width: 220px;
  max-width: 360px;
  animation: toastIn 0.25s ease;
  pointer-events: auto;
}

.toast--success { background: var(--color-success); }
.toast--error   { background: var(--color-danger); }
.toast--warning { background: var(--color-warning); color: var(--color-text); }
.toast--info    { background: var(--color-primary); display: flex; align-items: center; gap: var(--space-md); }

.toast--out {
  animation: toastOut 0.25s ease forwards;
}

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

@keyframes toastOut {
  to { opacity: 0; transform: translateY(12px) scale(0.95); }
}

/* ── Table ── */
.table-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

.table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table tbody tr:hover {
  background: var(--color-bg);
}

.table tfoot td {
  padding: 12px 16px;
  font-weight: 600;
  background: var(--color-bg);
  border-top: 2px solid var(--color-border);
}

.col-desc {
  min-width: 180px;
}

.col-amount {
  white-space: nowrap;
}

.col-amount {
  text-align: right;
  white-space: nowrap;
}

.col-actions {
  text-align: right;
  white-space: nowrap;
}

.tfoot-label {
  color: var(--color-text-muted);
  font-size: 0.75rem;
}

.empty-row td {
  text-align: center;
  color: var(--color-text-muted);
  padding: var(--space-2xl) var(--space-lg);
}

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
}

.badge--income {
  background: var(--color-income-bg);
  color: var(--color-income);
}

.badge--expense {
  background: var(--color-expense-bg);
  color: var(--color-expense);
}

.badge--cat {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.amount--income {
  color: var(--color-income);
  font-weight: 600;
}

.amount--expense {
  color: var(--color-expense);
  font-weight: 600;
}

/* ── Category Cards ── */
.category-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
}

.category-card__header {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.cat-color-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}

.category-card__name {
  font-weight: 600;
  font-size: 1rem;
  flex: 1;
}

.category-card__stats {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  margin-bottom: var(--space-sm);
}

.category-card__spent {
  font-weight: 600;
  color: var(--color-text);
}

/* ── Progress Bar ── */
.progress-bar {
  height: 6px;
  background: var(--color-bg);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: var(--space-md);
}

.progress-bar__fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  transition: width 0.4s ease;
}

.progress-bar__fill--warning { background: var(--color-warning); }
.progress-bar__fill--danger  { background: var(--color-expense); }

.category-card__actions {
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
}

/* ── Settings Cards ── */
.settings-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  box-shadow: var(--shadow-sm);
}

.settings-card__title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: var(--space-xl);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--color-border);
}

.data-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.data-action-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  flex-wrap: wrap;
}

.data-action-item--danger {
  background: var(--color-expense-bg);
  border-color: rgba(239,68,68,.2);
}

.data-action-title {
  font-weight: 600;
  font-size: 0.875rem;
  margin-bottom: 2px;
}

.data-action-desc {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

.data-action-buttons {
  display: flex;
  gap: var(--space-sm);
  flex-shrink: 0;
}

/* ── Budget Warning Banner ── */
.warning-banner {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 10px var(--space-md);
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  font-weight: 500;
}

.warning-banner--warning {
  background: var(--color-warning-bg);
  color: #92400e;
  border: 1px solid rgba(245,158,11,.3);
}

.warning-banner--danger {
  background: var(--color-expense-bg);
  color: #991b1b;
  border: 1px solid rgba(239,68,68,.3);
}

/* ── Goal Cards ── */
.goals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--space-lg);
}

.goal-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
}

.goal-card--complete {
  border-color: var(--color-income);
}

.goal-card__header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.goal-card__color {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.goal-card__name {
  font-weight: 600;
  font-size: 1rem;
  flex: 1;
}

.goal-card__amounts {
  display: flex;
  align-items: baseline;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.goal-card__saved {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-text);
}

.goal-card__target {
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

.progress-bar--goal {
  height: 10px;
  margin-bottom: var(--space-md);
}

.progress-bar__fill--complete {
  background: var(--color-income) !important;
}

.goal-card__meta {
  display: flex;
  gap: var(--space-lg);
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  margin-bottom: var(--space-md);
}

.goal-card__actions {
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
  align-items: center;
}

.btn-sm {
  padding: 5px 12px;
  font-size: 0.8125rem;
}

/* ── Recurring Cards ── */
.recurring-info {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin-bottom: var(--space-lg);
}

.recurring-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.recurring-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
  transition: opacity 0.15s;
}

.recurring-card--paused {
  opacity: 0.6;
}

.recurring-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.recurring-card__info {
  display: flex;
  gap: var(--space-sm);
}

.recurring-card__amount {
  font-size: 1.25rem;
  font-weight: 700;
}

.recurring-card__body {
  margin-bottom: var(--space-md);
}

.recurring-card__desc {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: var(--space-xs);
}

.recurring-card__meta {
  display: flex;
  gap: var(--space-lg);
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

.recurring-card__actions {
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
  border-top: 1px solid var(--color-border);
  padding-top: var(--space-md);
}

/* ── Tag Badges ── */
.tag-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.6875rem;
  font-weight: 500;
  background: var(--color-primary-light);
  color: var(--color-primary);
  margin: 1px 2px;
  white-space: nowrap;
}

.col-tags {
  min-width: 120px;
}

/* ── Insight Cards ── */
.insights-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.insight-card {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s, box-shadow 0.15s;
}

.insight-card:hover {
  box-shadow: var(--shadow-md);
}

.insight-card__icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.insight-card__label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  margin-bottom: 2px;
}

.insight-card__value {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--color-text);
  line-height: 1.2;
}

.insight-card__detail {
  font-size: 0.75rem;
  color: var(--color-text-faint);
  margin-top: 2px;
}

/* ── Row action buttons ── */
.row-actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}

/* ── Responsive tweaks ── */

/* Tablet and below */
@media (max-width: 768px) {
  .stat-card {
    padding: var(--space-md) var(--space-lg);
  }

  .stat-value {
    font-size: 1.5rem;
  }

  .chart-card {
    padding: var(--space-lg);
  }

  .chart-card__header {
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
  }

  /* Data action items stack on smaller screens */
  .data-action-item {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-sm);
  }

  .data-action-buttons {
    align-self: stretch;
    justify-content: flex-end;
  }

  /* Recurring card meta wraps */
  .recurring-card__meta {
    flex-wrap: wrap;
    gap: var(--space-sm);
  }

  .goal-card__meta {
    flex-wrap: wrap;
    gap: var(--space-sm);
  }

  .debt-card__meta {
    flex-wrap: wrap;
    gap: var(--space-sm);
  }
}

@media (max-width: 640px) {
  .form-row {
    grid-template-columns: 1fr;
  }

  .modal-inner {
    padding: var(--space-lg);
  }

  /* Hide non-essential table columns */
  .table th.col-desc,
  .table td.col-desc,
  .table th.col-tags,
  .table td.col-tags {
    display: none;
  }

  .table th,
  .table td {
    padding: 10px 12px;
    font-size: 0.8125rem;
  }

  .col-amount {
    min-width: 80px;
  }

  /* Toasts above bottom nav */
  .toast-container {
    right: var(--space-md);
    bottom: 80px;
    left: var(--space-md);
  }

  .toast {
    min-width: 0;
    max-width: 100%;
  }

  /* Summary cards stack */
  .summary-cards {
    flex-direction: column;
  }

  /* Goals grid single column */
  .goals-grid {
    grid-template-columns: 1fr;
  }

  /* Debts grid single column */
  .debts-list {
    grid-template-columns: 1fr;
  }

  /* Wishlist grid single column */
  .wishlist-grid {
    grid-template-columns: 1fr;
  }

  /* Accounts grid single column */
  .accounts-grid {
    grid-template-columns: 1fr;
  }

  /* Insight cards */
  .insights-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: var(--space-sm);
  }

  .insight-card {
    padding: var(--space-md);
    gap: var(--space-sm);
  }

  .insight-card__value {
    font-size: 1rem;
  }
}

/* ── Debt Cards ── */
.debts-summary {
  display: flex;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.debt-summary-card {
  flex: 1;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  text-align: center;
}

.debt-summary-card__label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-xs);
}

.debt-summary-card__value {
  font-size: 1.5rem;
  font-weight: 800;
}

.debts-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.debt-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
}

.debt-card--settled {
  opacity: 0.6;
}

.debt-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}

.debt-card__person {
  font-weight: 700;
  font-size: 1rem;
}

.debt-card__amount {
  font-size: 1.25rem;
  font-weight: 700;
}

.debt-card__meta {
  display: flex;
  gap: var(--space-lg);
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  margin-bottom: var(--space-md);
}

.debt-card__desc {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin-bottom: var(--space-xs);
}

.debt-card__due {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  margin-bottom: var(--space-md);
}

.debt-card__actions {
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
  border-top: 1px solid var(--color-border);
  padding-top: var(--space-md);
}

.debt-card__progress {
  margin-bottom: var(--space-md);
}

.debt-card__progress-text {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-bottom: var(--space-xs);
}

/* ── Debts Summary ── */
.debts-summary {
  display: flex;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.debts-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr));
  gap: var(--space-lg);
}

.summary-cards {
  display: flex;
  gap: var(--space-md);
}

.summary-card {
  flex: 1;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  text-align: center;
}

.summary-card__label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-xs);
}

.summary-card__value {
  font-size: 1.5rem;
  font-weight: 800;
  word-break: break-word;
  overflow-wrap: break-word;
}

/* ── Wishlist ── */
.wishlist-total {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin-bottom: var(--space-lg);
}

.wishlist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
  gap: var(--space-lg);
}

.wish-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
  transition: opacity 0.15s;
}

.wish-card--purchased {
  opacity: 0.5;
}

.wish-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.wish-card__name {
  font-weight: 600;
  font-size: 1rem;
  flex: 1;
}

.wish-card__price {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--color-primary);
}

.wish-card__link {
  display: inline-block;
  font-size: 0.8125rem;
  color: var(--color-primary);
  text-decoration: none;
  margin-bottom: var(--space-xs);
}
.wish-card__link:hover { text-decoration: underline; }

.wish-card__notes {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  margin-bottom: var(--space-md);
}

.wish-card__meta {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  margin-bottom: var(--space-md);
}

.wish-card__actions {
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
}

.priority-badge {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.6875rem;
  font-weight: 600;
}

.priority-badge--high { background: var(--color-expense-bg); color: var(--color-expense); }
.priority-badge--medium { background: var(--color-warning-bg); color: #92400e; }
.priority-badge--low { background: var(--color-primary-light); color: var(--color-primary); }

/* ── Account Cards ── */
.accounts-summary {
  display: flex;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.accounts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
  gap: var(--space-lg);
}

.account-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
  border-left: 4px solid var(--color-primary);
}

.account-card__header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.account-card__color {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.account-card__name {
  font-weight: 600;
  font-size: 1rem;
  flex: 1;
}

.account-card__balance {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: var(--space-xs);
  word-break: break-word;
  overflow-wrap: break-word;
}

.account-card__type {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  text-transform: capitalize;
  margin-bottom: var(--space-md);
}

.account-card__actions {
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
  border-top: 1px solid var(--color-border);
  padding-top: var(--space-md);
}

/* ── Net Worth Cards ── */
.net-worth-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
}

.nw-card {
  text-align: center;
  padding: var(--space-lg);
  border-radius: var(--radius-md);
  background: var(--color-bg);
}

.nw-card__label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-xs);
}

.nw-card__value {
  font-size: 1.5rem;
  font-weight: 800;
}

/* ── Keyboard Shortcuts ── */
.shortcuts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr));
  gap: var(--space-md);
}

.shortcut-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  font-size: 0.875rem;
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  padding: 2px 8px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-muted);
  box-shadow: 0 1px 0 var(--color-border);
}

/* ── Undo Toast ── */
.toast-undo {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
}

.toast-undo-btn {
  background: rgba(255,255,255,.25);
  color: #fff;
  border: none;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.toast-undo-btn:hover {
  background: rgba(255,255,255,.4);
}

/* ── Textarea ── */
textarea.input {
  resize: vertical;
  min-height: 60px;
}

/* ── Responsive additions ── */
@media (max-width: 640px) {
  .debts-summary,
  .accounts-summary {
    flex-direction: column;
  }
  .net-worth-cards {
    grid-template-columns: 1fr;
  }
  .shortcuts-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Full-screen modals on small phones ── */
@media (max-width: 480px) {
  .modal {
    max-width: 100%;
    width: 100%;
    max-height: 100vh;
    max-height: 100dvh;
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
    margin: 0;
  }

  .modal--sm {
    max-width: 100%;
  }

  .modal-inner {
    padding: var(--space-lg);
  }

  /* Compact stat cards */
  .stat-card {
    padding: var(--space-md);
    border-radius: var(--radius-lg);
  }

  .stat-label {
    font-size: 0.6875rem;
    margin-bottom: var(--space-xs);
  }

  .stat-value {
    font-size: 1.25rem;
  }

  .stat-sub {
    font-size: 0.75rem;
  }

  .stat-card::before {
    width: 80px;
    height: 80px;
  }

  .stat-card::after {
    width: 50px;
    height: 50px;
  }

  /* Compact form */
  .form-row {
    grid-template-columns: 1fr;
  }

  .form-group {
    margin-bottom: var(--space-md);
  }

  /* Compact cards */
  .settings-card {
    padding: var(--space-lg);
  }

  .settings-card__title {
    margin-bottom: var(--space-lg);
    font-size: 0.9375rem;
  }

  .category-card {
    padding: var(--space-md);
  }

  .goal-card {
    padding: var(--space-md);
  }

  .goal-card__saved {
    font-size: 1.25rem;
  }

  .debt-card {
    padding: var(--space-md);
  }

  .wish-card {
    padding: var(--space-md);
  }

  .recurring-card {
    padding: var(--space-md);
  }

  .account-card {
    padding: var(--space-md);
  }

  .account-card__balance {
    font-size: 1.25rem;
  }

  /* Net worth cards 3-col compact */
  .net-worth-cards {
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-xs);
  }

  .nw-card {
    padding: var(--space-sm);
  }

  .nw-card__label {
    font-size: 0.625rem;
  }

  .nw-card__value {
    font-size: 1rem;
  }

  /* Debt summary cards compact */
  .debt-summary-card {
    padding: var(--space-md);
  }

  .debt-summary-card__value {
    font-size: 1.125rem;
  }

  /* Shortcuts hidden on very small screens (keyboard shortcuts are not useful on mobile) */
  .shortcuts-grid {
    display: none;
  }
}

/* ── Print Styles ── */
@media print {
  body {
    background: #fff !important;
    color: #000 !important;
    font-size: 12pt;
  }
  .app-header,
  .side-panel,
  .toast-container,
  dialog,
  #btn-print-report,
  #btn-add-transaction,
  #btn-dark-mode,
  .month-nav button,
  .budget-warnings,
  .row-actions,
  .col-actions {
    display: none !important;
  }
  .app-main {
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  .app-layout {
    display: block !important;
  }
  .section {
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .section[hidden] {
    display: none !important;
  }
  .stats-grid {
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 8px !important;
  }
  .stat-card {
    box-shadow: none !important;
    border: 1px solid #ccc !important;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
  .chart-card {
    box-shadow: none !important;
    border: 1px solid #ccc !important;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .charts-grid {
    grid-template-columns: 1fr 1fr !important;
  }
  .insight-card {
    box-shadow: none !important;
    border: 1px solid #ccc !important;
  }
  .table-card {
    box-shadow: none !important;
  }
  .section-title {
    background: none !important;
    -webkit-text-fill-color: #000 !important;
    color: #000 !important;
    font-size: 16pt !important;
  }
  .month-label {
    font-size: 12pt;
  }
  /* Print header with title */
  .section-header::before {
    content: 'Jentrak Report';
    display: block;
    font-size: 18pt;
    font-weight: bold;
    margin-bottom: 8px;
    color: #333;
  }
  /* Only show the first section-header before content */
  .section-header ~ .section-header::before {
    display: none;
  }
}

/* ═══════════════════════════════════════════════
   USER DROPDOWN
═══════════════════════════════════════════════ */

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--color-primary, #6C63FF);
}

.user-dropdown {
  position: absolute;
  top: calc(100% + .5rem);
  right: 0;
  background: var(--color-surface, #fff);
  border: 1px solid var(--color-border, #e2e8f0);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,.12);
  min-width: 240px;
  z-index: 9999;
  padding: .5rem 0;
}

.user-dropdown__avatar-section {
  display: flex;
  justify-content: center;
  padding: 1rem 1rem .5rem;
}

.user-dropdown__avatar-wrap {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--color-bg, #f8fafc);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted, #64748b);
  border: 2px solid var(--color-border, #e2e8f0);
  cursor: pointer;
}

.dropdown-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-upload-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity .2s;
  cursor: pointer;
  border-radius: 50%;
}

.user-dropdown__avatar-wrap:hover .avatar-upload-overlay {
  opacity: 1;
}

.user-dropdown__info {
  padding: .5rem 1rem .75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .1rem;
  text-align: center;
}

.user-dropdown__info strong {
  font-size: .92rem;
  color: var(--color-text, #1e293b);
}

.user-dropdown__info small {
  font-size: .78rem;
  color: var(--color-text-muted, #64748b);
}

.user-dropdown hr {
  border: none;
  border-top: 1px solid var(--color-border, #e2e8f0);
  margin: .25rem 0;
}

.user-dropdown__item {
  display: block;
  width: 100%;
  text-align: left;
  padding: .6rem 1rem;
  border: none;
  background: none;
  font-size: .88rem;
  font-family: inherit;
  color: var(--color-text, #1e293b);
  cursor: pointer;
  transition: background .15s;
}

.user-dropdown__item:hover {
  background: var(--color-bg, #f8fafc);
}
