/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 9px 18px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  transition: all var(--transition-fast);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: white;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.btn:active::after { opacity: 0.08; }

.btn-primary {
  background: var(--accent);
  color: white;
  box-shadow: var(--shadow-accent);
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 6px 24px var(--accent-glow); }

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-card-hover); border-color: var(--border-hover); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--bg-tertiary); color: var(--text-primary); }

.btn-danger {
  background: var(--color-expense-soft);
  color: var(--color-expense);
  border: 1px solid rgba(255,107,107,0.2);
}
.btn-danger:hover { background: var(--color-expense); color: white; }

.btn-success {
  background: var(--color-income-soft);
  color: var(--color-income);
  border: 1px solid rgba(34,211,165,0.2);
}
.btn-success:hover { background: var(--color-income); color: white; }

.btn-sm { padding: 6px 12px; font-size: 0.8125rem; border-radius: var(--radius-sm); }
.btn-lg { padding: 12px 24px; font-size: 1rem; border-radius: var(--radius-lg); }
.btn-icon { padding: 8px; border-radius: var(--radius-md); }
.btn-icon-sm { padding: 6px; border-radius: var(--radius-sm); }

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.card:hover { border-color: var(--border-hover); }
.card-glass {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

/* ── Stat Cards ── */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  position: relative;
  overflow: hidden;
  transition: all var(--transition-base);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--accent);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.stat-card:hover::before { opacity: 1; }
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.stat-card.income::before { background: var(--color-income); }
.stat-card.expense::before { background: var(--color-expense); }
.stat-card.highlight::before { background: var(--accent); opacity: 1; }

.stat-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-sm);
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  font-family: var(--font-mono);
}

.stat-value.income { color: var(--color-income); }
.stat-value.expense { color: var(--color-expense); }
.stat-value.accent { color: var(--accent); }

.stat-sub {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: var(--space-xs);
}

.stat-icon {
  position: absolute;
  top: var(--space-lg);
  right: var(--space-lg);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

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

.badge-accent   { background: var(--accent-soft); color: var(--accent); }
.badge-income   { background: var(--color-income-soft); color: var(--color-income); }
.badge-expense  { background: var(--color-expense-soft); color: var(--color-expense); }
.badge-warning  { background: var(--color-warning-soft); color: var(--color-warning); }
.badge-info     { background: var(--color-info-soft); color: var(--color-info); }
.badge-muted    { background: var(--bg-tertiary); color: var(--text-muted); }

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

.progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--accent);
  transition: width var(--transition-slow);
}

.progress-fill.danger { background: var(--color-expense); }
.progress-fill.warning { background: var(--color-warning); }
.progress-fill.success { background: var(--color-income); }

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(4px);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px) scale(0.97);
  transition: transform var(--transition-base);
}

.modal-overlay.open .modal {
  transform: translateY(0) scale(1);
}

.modal-lg { max-width: 680px; }
.modal-xl { max-width: 860px; }

.modal-header {
  padding: var(--space-lg) var(--space-xl);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: var(--bg-card);
  z-index: 1;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

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

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

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.modal-close:hover { background: var(--color-expense-soft); color: var(--color-expense); border-color: transparent; }

/* ── Form Groups ── */
.form-group { margin-bottom: var(--space-md); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-md); }
.form-hint { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: 0.75rem; color: var(--color-expense); margin-top: 4px; }

/* ── Expense Type Selector ── */
.type-selector {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.type-option {
  padding: var(--space-md);
  border-radius: var(--radius-md);
  border: 2px solid var(--border);
  background: var(--bg-tertiary);
  cursor: pointer;
  text-align: center;
  transition: all var(--transition-fast);
}

.type-option:hover { border-color: var(--border-hover); background: var(--bg-card-hover); }
.type-option.selected { border-color: var(--accent); background: var(--accent-soft); }

.type-option-icon { font-size: 1.5rem; margin-bottom: var(--space-xs); }
.type-option-label { font-size: 0.8125rem; font-weight: 600; color: var(--text-primary); }
.type-option-desc { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }

/* ── Toast ── */
.toast-container {
  position: fixed;
  bottom: var(--space-xl);
  right: var(--space-xl);
  z-index: var(--z-toast);
  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(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  pointer-events: all;
  min-width: 280px;
  max-width: 380px;
  transform: translateX(120%);
  transition: transform var(--transition-base);
}

.toast.show { transform: translateX(0); }
.toast.success { border-left: 3px solid var(--color-income); }
.toast.error   { border-left: 3px solid var(--color-expense); }
.toast.warning { border-left: 3px solid var(--color-warning); }
.toast.info    { border-left: 3px solid var(--accent); }

.toast-icon { font-size: 1rem; flex-shrink: 0; }
.toast-msg  { flex: 1; }
.toast-undo {
  font-size: 0.75rem;
  color: var(--accent);
  cursor: pointer;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}
.toast-undo:hover { background: var(--accent-soft); }

/* ── Transaction Item ── */
.txn-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
  cursor: pointer;
  min-width: 0;
}

.txn-item:hover { background: var(--bg-tertiary); }

.txn-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.txn-info { flex: 1; min-width: 0; overflow: hidden; }
.txn-title {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.txn-meta  {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.txn-amount {
  font-size: 0.9375rem;
  font-weight: 700;
  font-family: var(--font-mono);
  text-align: right;
  white-space: nowrap;
  flex-shrink: 0;
}

.txn-amount.out { color: var(--color-expense); }
.txn-amount.in  { color: var(--color-income); }

/* ── Date Group ── */
.date-group { margin-bottom: var(--space-lg); }
.date-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: var(--space-sm) var(--space-md);
  margin-bottom: var(--space-xs);
}

/* ── Friend Card ── */
.friend-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  transition: all var(--transition-fast);
}

.friend-card:hover { border-color: var(--border-hover); box-shadow: var(--shadow-sm); }

.friend-avatar {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background: var(--accent-soft);
  border: 2px solid var(--border-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
}

.friend-balance {
  font-size: 1.125rem;
  font-weight: 700;
  font-family: var(--font-mono);
}

.friend-balance.owe    { color: var(--color-expense); }
.friend-balance.owed   { color: var(--color-income); }
.friend-balance.settled { color: var(--text-muted); }

/* ── Budget Item ── */
.budget-item {
  padding: var(--space-md) 0;
  border-bottom: 1px solid var(--border);
}
.budget-item:last-child { border-bottom: none; }

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: 3px;
}

.tab {
  flex: 1;
  padding: 7px 14px;
  border-radius: calc(var(--radius-md) - 2px);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  text-align: center;
  transition: all var(--transition-fast);
}

.tab.active {
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

/* ── Search ── */
.search-bar {
  position: relative;
  display: flex;
  align-items: center;
}

.search-bar input {
  padding-left: 38px;
  background: var(--bg-tertiary);
}

.search-icon {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  pointer-events: none;
  font-size: 0.9rem;
}

/* ── Empty State ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl);
  text-align: center;
  gap: var(--space-md);
}

.empty-icon {
  font-size: 3rem;
  opacity: 0.3;
}

.empty-title {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.empty-desc {
  font-size: 0.875rem;
  color: var(--text-muted);
  max-width: 280px;
}

/* ── Chip / Tag ── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 500;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.chip:hover, .chip.active { background: var(--accent-soft); color: var(--accent); border-color: var(--border-accent); }
.chip-remove { cursor: pointer; opacity: 0.6; }
.chip-remove:hover { opacity: 1; }

/* ── Divider ── */
.divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-md) 0;
}

/* ── Tooltip ── */
[data-tooltip] { position: relative; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 0.75rem;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-fast);
  z-index: var(--z-tooltip);
  box-shadow: var(--shadow-sm);
}

[data-tooltip]:hover::after { opacity: 1; }

/* ── Dropdown ── */
.dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  z-index: 50;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
  transition: all var(--transition-fast);
}

.dropdown-menu.open { opacity: 1; pointer-events: all; transform: translateY(0); }

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 10px var(--space-md);
  font-size: 0.875rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.dropdown-item:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.dropdown-item.danger { color: var(--color-expense); }
.dropdown-item.danger:hover { background: var(--color-expense-soft); }

/* ── Calendar Heatmap ── */
.heatmap-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}

.heatmap-cell {
  aspect-ratio: 1;
  border-radius: 3px;
  background: var(--bg-tertiary);
  transition: all var(--transition-fast);
  cursor: pointer;
}

.heatmap-cell:hover { transform: scale(1.2); }
.heatmap-cell.l1 { background: rgba(108,99,255,0.2); }
.heatmap-cell.l2 { background: rgba(108,99,255,0.4); }
.heatmap-cell.l3 { background: rgba(108,99,255,0.6); }
.heatmap-cell.l4 { background: rgba(108,99,255,0.85); }

/* ── Recurring Badge ── */
.recurring-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
}

/* ── Split Friends List ── */
.split-friend-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--border);
}

.split-friend-row:last-child { border-bottom: none; }

.split-friend-row input[type="number"] {
  width: 120px;
  flex-shrink: 0;
}

/* ── Accent Picker ── */
.accent-picker {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.accent-dot {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  cursor: pointer;
  border: 2px solid transparent;
  transition: all var(--transition-fast);
}

.accent-dot.active { border-color: white; transform: scale(1.15); }

/* ── Pending Balance Row ── */
.pending-row {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-sm);
}

.pending-row:last-child { margin-bottom: 0; }

/* ── Chart Container ── */
.chart-container {
  position: relative;
  width: 100%;
}

/* ── Skeleton Loader ── */
.skeleton {
  background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-card-hover) 50%, var(--bg-tertiary) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Mobile Menu Button ── */
.mobile-menu-btn {
  display: none;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

@media (max-width: 900px) {
  .mobile-menu-btn { display: flex; }
}

/* ── Overlay for mobile sidebar ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: calc(var(--z-sidebar) - 1);
}

.sidebar-overlay.active { display: block; }

/* ── Transaction row hover actions ── */
.txn-item:hover .txn-actions { opacity: 1 !important; }

/* ── Responsive overrides ── */
@media (max-width: 600px) {
  .stat-value { font-size: 1.375rem; }
  .stat-card { padding: var(--space-md); }
  .modal { border-radius: var(--radius-lg); }
  .modal-body { padding: var(--space-md); }
  .modal-header { padding: var(--space-md); }
  .modal-footer { padding: var(--space-md); }
  .toast-container { right: var(--space-sm); bottom: var(--space-sm); left: var(--space-sm); }
  .toast { min-width: unset; max-width: 100%; }
  .pending-row { flex-wrap: wrap; gap: var(--space-sm); }
  .tabs .tab { padding: 6px 10px; font-size: 0.8125rem; }
  .txn-item { gap: var(--space-sm); padding: var(--space-sm); }
  .txn-title { font-size: 0.875rem; }
}

@media (max-width: 480px) {
  .stat-value { font-size: 1.25rem; }
  .stat-card { padding: var(--space-sm) var(--space-md); }
  .form-row { grid-template-columns: 1fr; }
  .type-selector { grid-template-columns: 1fr; gap: var(--space-xs); }
  .type-option { padding: var(--space-sm); display: flex; align-items: center; gap: var(--space-sm); text-align: left; }
  .type-option-icon { font-size: 1.25rem; margin-bottom: 0; flex-shrink: 0; }
  .type-option-desc { display: none; }
  .modal { border-radius: var(--radius-md) var(--radius-md) 0 0; margin-top: auto; max-height: 92vh; }
  .modal-overlay { align-items: flex-end; padding: 0; }
  .friend-card { padding: var(--space-md); }
  .txn-icon { width: 34px; height: 34px; font-size: 0.95rem; }
}
