/* FinTrack Design System */
:root {
  --bg: #F5F5F7;
  --bg-secondary: #FFFFFF;
  --surface: #FFFFFF;
  --surface-secondary: #F2F2F7;
  --text-primary: #1D1D1F;
  --text-secondary: #6E6E73;
  --text-tertiary: #AEAEB2;
  --accent: #0071E3;
  --accent-hover: #0077ED;
  --income: #34C759;
  --expense: #FF3B30;
  --debt: #FF9500;
  --border: rgba(0,0,0,0.08);
  --shadow-card: 0 2px 8px rgba(0,0,0,0.06), 0 0 1px rgba(0,0,0,0.04);
  --shadow-modal: 0 20px 60px rgba(0,0,0,0.15);
  --radius-card: 12px;
  --radius-input: 10px;
  --radius-btn: 8px;
  --radius-pill: 20px;
  --transition: 200ms ease;
  --sidebar-width: 240px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --topbar-height: 60px;
  --bottom-nav-height: 64px;
}

[data-theme="dark"] {
  --bg: #000000;
  --bg-secondary: #1C1C1E;
  --surface: #1C1C1E;
  --surface-secondary: #2C2C2E;
  --text-primary: #F5F5F7;
  --text-secondary: #98989D;
  --text-tertiary: #636366;
  --border: rgba(255,255,255,0.08);
  --shadow-card: 0 2px 8px rgba(0,0,0,0.4);
  --shadow-modal: 0 20px 60px rgba(0,0,0,0.5);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  font-size: 15px;
  color: var(--text-primary);
  background: var(--bg);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

.text-display  { font-size: 34px; font-weight: 700; letter-spacing: -0.5px; }
.text-title    { font-size: 22px; font-weight: 600; letter-spacing: -0.3px; }
.text-headline { font-size: 17px; font-weight: 600; }
.text-body     { font-size: 15px; font-weight: 400; }
.text-small    { font-size: 13px; }
.text-caption  { font-size: 11px; font-weight: 500; letter-spacing: 0.5px; text-transform: uppercase; }
.text-secondary { color: var(--text-secondary); }
.text-tertiary  { color: var(--text-tertiary); }
.text-income    { color: var(--income); }
.text-expense   { color: var(--expense); }
.text-debt      { color: var(--debt); }
.mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

.hidden { display: none !important; }

/* Layout */
.sidebar {
  width: var(--sidebar-width);
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo { font-size: 24px; }
.sidebar-brand { font-weight: 700; font-size: 17px; }

.sidebar-nav { flex: 1; padding: 12px 8px; overflow-y: auto; }
.sidebar-footer { padding: 8px; border-top: 1px solid var(--border); }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-btn);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  min-height: 44px;
}

.nav-item:hover { background: var(--surface-secondary); color: var(--text-primary); }
.nav-item.active { background: rgba(0,113,227,0.1); color: var(--accent); }
.nav-item-danger:hover { color: var(--expense); }
.nav-item svg { width: 20px; height: 20px; flex-shrink: 0; }

.app-shell {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  width: calc(100% - var(--sidebar-width));
  max-width: calc(100vw - var(--sidebar-width));
  overflow-x: hidden;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--topbar-height);
  padding: 0 32px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  width: 100%;
}

.topbar-title {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.sidebar-toggle { display: none; }

.main-content {
  padding: 32px;
  max-width: 1100px;
  width: 100%;
  box-sizing: border-box;
}

.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-height);
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 100;
  justify-content: space-around;
  align-items: center;
  padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 8px;
  color: var(--text-tertiary);
  font-size: 10px;
  font-weight: 500;
  background: none;
  border: none;
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
  justify-content: center;
  font-family: var(--font);
}

.bottom-nav-item svg { width: 22px; height: 22px; }
.bottom-nav-item.active { color: var(--accent); }

/* Drawer */
.drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 250;
}

.drawer-overlay.open { display: block; }

.drawer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  padding: 12px 16px 32px;
  z-index: 300;
  transform: translateY(100%);
  transition: transform var(--transition);
}

.drawer.open { transform: translateY(0); }

.drawer-handle {
  width: 36px;
  height: 4px;
  background: var(--text-tertiary);
  border-radius: 2px;
  margin: 0 auto 16px;
}

.drawer-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 12px;
  color: var(--text-primary);
  font-size: 16px;
  border-radius: var(--radius-btn);
  min-height: 44px;
}

.drawer-item:hover { background: var(--surface-secondary); }
.drawer-item-danger { color: var(--expense); }
.drawer-item svg { width: 20px; height: 20px; }

/* Cards */
.card {
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 20px;
  border: 1px solid var(--border);
}

.card-stat {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
}

.card-stat-label { font-size: 13px; color: var(--text-secondary); font-weight: 500; }
.card-stat-value {
  font-size: clamp(20px, 2vw, 28px);
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1.2;
}
.card-stat-footer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
}

.card-stat-trend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: wrap;
  min-height: 22px;
}

.trend-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
}

.trend-up { background: rgba(52,199,89,0.12); color: var(--income); }
.trend-down { background: rgba(255,59,48,0.12); color: var(--expense); }
.trend-neutral { background: var(--surface-secondary); color: var(--text-secondary); }

.sparkline-wrap { height: 40px; width: 100%; min-width: 0; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
  width: 100%;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-btn);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font);
  border: none;
  cursor: pointer;
  transition: background var(--transition), transform 100ms ease, opacity var(--transition);
  min-height: 44px;
  white-space: nowrap;
}

.btn:active { transform: scale(0.98); }
.btn svg { width: 18px; height: 18px; }

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

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

.btn-danger { background: var(--expense); color: #fff; }
.btn-danger:hover { opacity: 0.9; }

.btn-sm { padding: 6px 12px; font-size: 13px; min-height: 36px; }
.btn-icon { padding: 10px; min-width: 44px; }
.btn-full { width: 100%; }

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

.badge-income { background: rgba(52,199,89,0.12); color: var(--income); }
.badge-expense { background: rgba(255,59,48,0.12); color: var(--expense); }
.badge-debt { background: rgba(255,149,0,0.12); color: var(--debt); }
.badge-paid { background: rgba(52,199,89,0.12); color: var(--income); }
.badge-overdue { background: rgba(255,59,48,0.12); color: var(--expense); }
.badge-active { background: rgba(0,113,227,0.12); color: var(--accent); }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text-secondary); }
.form-row { display: flex; gap: 12px; align-items: flex-end; }
.flex-grow { flex: 1; }
.currency-col { width: 100px; flex-shrink: 0; }

.input, .select, .textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  background: var(--surface);
  color: var(--text-primary);
  font-size: 15px;
  font-family: var(--font);
  transition: border-color var(--transition), box-shadow var(--transition);
  min-height: 44px;
}

.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,113,227,0.15);
}

.select-sm { padding: 6px 10px; font-size: 13px; min-height: 36px; }
.textarea { min-height: 80px; resize: vertical; }
.field-error { display: block; color: var(--expense); font-size: 12px; margin-top: 4px; }

/* Table */
.table-wrap { overflow-x: auto; border-radius: var(--radius-card); }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-tertiary);
  border-bottom: 1px solid var(--border);
  background: var(--surface-secondary);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

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

.table tbody tr:hover { background: var(--surface-secondary); }
.table tbody tr:last-child td { border-bottom: none; }

/* Mobile card list (replaces table) */
.mobile-cards { display: none; }

.mobile-card {
  background: var(--surface);
  border-radius: var(--radius-card);
  padding: 16px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
}

.mobile-card:active { transform: scale(0.98); }

.mobile-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.mobile-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.mobile-card-actions .btn { flex: 1; }

/* Progress bar */
.progress-bar {
  height: 8px;
  background: var(--surface-secondary);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 400ms ease;
}

.progress-warning .progress-fill { background: var(--debt); }
.progress-danger .progress-fill { background: var(--expense); }

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 400;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-modal);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 0;
}

.modal-body { padding: 20px; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 20px 20px;
}

.confirm-icon { width: 48px; height: 48px; color: var(--debt); margin-bottom: 12px; }

/* Tabs */
.tab-group {
  display: flex;
  gap: 4px;
  background: var(--surface-secondary);
  border-radius: var(--radius-btn);
  padding: 4px;
  margin-bottom: 20px;
  overflow-x: auto;
}

.tab {
  flex: 1;
  padding: 8px 12px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: var(--font);
  min-height: 36px;
  white-space: nowrap;
}

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

/* Filter bar */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 20px;
}

.filter-bar .input, .filter-bar .select { width: auto; min-width: 140px; }

.custom-range { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.search-input { flex: 1; min-width: 200px; }

/* Summary bar */
.summary-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  padding: 16px 20px;
  background: var(--surface);
  border-radius: var(--radius-card);
  border: 1px solid var(--border);
  margin-bottom: 20px;
}

.summary-item { display: flex; flex-direction: column; gap: 2px; }
.summary-label { font-size: 12px; color: var(--text-secondary); }
.summary-value { font-size: 18px; font-weight: 700; }

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 20px;
}

.pagination button {
  min-width: 44px;
  min-height: 44px;
}

.pagination .page-info { font-size: 13px; color: var(--text-secondary); }

/* Debt cards */
.debt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
  gap: 16px;
  align-items: start;
}

.debt-card {
  cursor: pointer;
  transition: box-shadow var(--transition);
  border-left: 4px solid transparent;
  min-width: 0;
  overflow: hidden;
}

.debt-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.1); }
.debt-card.overdue { border-left-color: var(--expense); }

.debt-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.debt-card-header h3 {
  word-break: break-word;
}

.debt-card-body { margin-bottom: 12px; }

.debt-payments {
  display: none;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.debt-card.expanded .debt-payments { display: block; }

.debt-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.debt-actions .btn {
  flex: 0 1 auto;
  white-space: nowrap;
}

@media (min-width: 769px) {
  .debt-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Calendar */
.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.calendar-legend {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.dot-income { background: var(--income); }
.dot-expense { background: var(--expense); }
.dot-debt { background: var(--debt); }

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.calendar-day-name {
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  padding: 8px 4px;
}

.calendar-cell {
  aspect-ratio: 1;
  min-height: 60px;
  background: var(--surface);
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 6px;
  cursor: pointer;
  transition: background var(--transition);
  display: flex;
  flex-direction: column;
}

.calendar-cell:hover { background: var(--surface-secondary); }
.calendar-cell.today { background: rgba(0,113,227,0.1); border-color: var(--accent); }
.calendar-cell.other-month { opacity: 0.4; }

.calendar-date { font-size: 13px; font-weight: 600; margin-bottom: 4px; }

.calendar-dots { display: flex; gap: 3px; flex-wrap: wrap; margin-top: auto; }
.calendar-dot { width: 6px; height: 6px; border-radius: 50%; }

.day-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 380px;
  max-width: 100%;
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 200;
  transform: translateX(100%);
  transition: transform var(--transition);
  overflow-y: auto;
  padding: 24px;
}

.day-panel.open { transform: translateX(0); }

.day-panel-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 199;
}

.day-panel-overlay.open { display: block; }

/* Charts */
.chart-container {
  position: relative;
  height: 280px;
  margin-bottom: 16px;
}

.chart-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 13px;
  color: var(--text-secondary);
}

.reports-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

/* Budget */
.budget-list { display: flex; flex-direction: column; gap: 16px; }

.budget-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.budget-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.budget-amounts {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: var(--text-secondary);
}

/* Settings */
.settings-section { margin-bottom: 32px; }
.settings-section-title {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.category-list { display: flex; flex-direction: column; gap: 8px; }

.category-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--surface-secondary);
  border-radius: var(--radius-btn);
}

.category-item-left { display: flex; align-items: center; gap: 10px; }

.icon-picker {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  max-width: 360px;
}

.icon-picker-btn {
  aspect-ratio: 1;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  font-size: 24px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.icon-picker-btn:hover {
  border-color: var(--primary);
  transform: scale(1.05);
}

.icon-picker-btn.active {
  border-color: var(--primary);
  background: rgba(0, 113, 227, 0.1);
  box-shadow: 0 0 0 1px var(--primary);
}

.danger-zone {
  border: 1px solid rgba(255,59,48,0.3);
  border-radius: var(--radius-card);
  padding: 20px;
}

/* Dashboard */
.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

.insights-box {
  background: linear-gradient(135deg, rgba(0,113,227,0.08), rgba(52,199,89,0.08));
  border-radius: var(--radius-card);
  padding: 20px;
  border: 1px solid var(--border);
}

.insight-item {
  display: flex;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.insight-item:last-child { border-bottom: none; }
.insight-icon { font-size: 18px; flex-shrink: 0; }

.rates-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.rates-compact {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.rate-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 8px;
  background: var(--bg-secondary);
  font-size: 12px;
  line-height: 1;
}

.rate-pill strong {
  font-weight: 600;
  color: var(--text-secondary);
}

.rate-pill .mono {
  font-size: 12px;
  color: var(--text-primary);
}

.card-compact {
  padding: 14px 16px;
}

.dash-list { display: none; }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

/* Quick add */
.quick-add-btn {
  position: fixed;
  bottom: 32px;
  right: 32px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,113,227,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 90;
  transition: transform var(--transition), background var(--transition);
}

.quick-add-btn:hover { background: var(--accent-hover); transform: scale(1.05); }
.quick-add-btn svg { width: 24px; height: 24px; }

/* User avatar */
.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
}

/* Dark mode toggle icons */
[data-theme="light"] .icon-light { display: none; }
[data-theme="dark"] .icon-dark { display: none; }

/* Toast */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius-btn);
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  box-shadow: var(--shadow-modal);
  animation: slideIn 300ms ease;
  min-width: 260px;
}

.toast-success { background: var(--income); }
.toast-error { background: var(--expense); }
.toast-warning { background: var(--debt); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Skeleton */
.skeleton {
  background: linear-gradient(90deg, var(--surface-secondary) 25%, var(--border) 50%, var(--surface-secondary) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 6px;
}

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

.skeleton-text { height: 16px; margin-bottom: 8px; }
.skeleton-title { height: 28px; width: 60%; margin-bottom: 12px; }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-secondary);
}

.empty-state-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h3 { font-size: 17px; font-weight: 600; color: var(--text-primary); margin-bottom: 8px; }
.empty-state p { font-size: 14px; margin-bottom: 20px; }

/* Auth pages */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background: var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: var(--radius-card);
  padding: 32px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
}

.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-logo-icon { font-size: 40px; display: block; margin-bottom: 8px; }
.auth-form { margin-bottom: 20px; }
.auth-footer { text-align: center; color: var(--text-secondary); }

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-btn);
  font-size: 14px;
  margin-bottom: 16px;
}

.alert-error { background: rgba(255,59,48,0.1); color: var(--expense); border: 1px solid rgba(255,59,48,0.2); }
.alert-success { background: rgba(52,199,89,0.1); color: var(--income); }

/* Toggle switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 32px;
}

.toggle-switch input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--surface-secondary);
  border-radius: 16px;
  transition: var(--transition);
  border: 1px solid var(--border);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 26px;
  width: 26px;
  left: 2px;
  bottom: 2px;
  background: #fff;
  border-radius: 50%;
  transition: var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-slider { background: var(--accent); border-color: var(--accent); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }

/* Page header actions */
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Month picker */
.month-nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.month-nav-label { font-weight: 600; min-width: 140px; text-align: center; }

/* Mobile-only / desktop-only helpers */
.mobile-only { display: none; }

@media (max-width: 767px) {
  .mobile-only { display: block; }
  .desktop-only { display: none !important; }
}
/* Sidebar overlay (mobil/tablet) */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 150;
}

.sidebar-backdrop.open { display: block; }

/* Responsive */
@media (max-width: 1200px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1023px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .reports-grid { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .icon-picker { grid-template-columns: repeat(4, 1fr); max-width: 100%; }
  .sidebar-toggle { display: flex; }
  .sidebar { transform: translateX(-100%); z-index: 200; box-shadow: var(--shadow-modal); }
  .sidebar.open { transform: translateX(0); }
}

@media (max-width: 767px) {
  .app-shell {
    margin-left: 0;
    width: 100%;
    max-width: 100vw;
  }

  .main-content {
    margin-left: 0;
    padding: 16px 16px calc(var(--bottom-nav-height) + 88px);
    max-width: 100%;
    width: 100%;
  }

  .topbar {
    padding: 0 12px;
    width: 100%;
    gap: 8px;
  }

  .topbar-title { font-size: 16px; }

  .bottom-nav { display: flex; }

  /* Kartlar tek sütun */
  .stat-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .card {
    padding: 16px;
    border-radius: 10px;
  }

  .card-stat-value { font-size: 24px; }

  .card-stat-label { font-size: 12px; }

  .card-stat-trend-row { min-height: auto; }

  .sparkline-wrap { height: 36px; }

  /* Tablolar gizle, mobil kartlar göster */
  .table-wrap { display: none !important; }
  .mobile-cards { display: block; width: 100%; }

  /* Dashboard liste — mobilde göster */
  .dash-list { display: flex; flex-direction: column; }

  .dash-list-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
  }

  .dash-list-item:last-child { border-bottom: none; }

  /* Filtreler */
  .filter-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .filter-bar .input,
  .filter-bar .select,
  .filter-bar .tab-group {
    width: 100%;
    min-width: unset;
  }

  .filter-bar .tab-group {
    margin-bottom: 0;
    -webkit-overflow-scrolling: touch;
  }

  .page-actions {
    width: 100%;
    flex-direction: column;
  }

  .page-actions .btn { width: 100%; }

  .search-input { min-width: unset; width: 100%; }

  .summary-bar {
    flex-direction: column;
    gap: 12px;
    padding: 14px 16px;
  }

  .summary-item { width: 100%; }

  /* Borç kartları */
  .debt-grid { grid-template-columns: 1fr; }

  .debt-card-header {
    flex-direction: column;
    gap: 8px;
  }

  .debt-card-header .text-right { text-align: left; width: 100%; }

  .debt-actions .btn { flex: 1 1 auto; min-width: calc(50% - 4px); }

  /* Takvim */
  .calendar-header {
    flex-wrap: wrap;
    gap: 8px;
  }

  .calendar-header .text-title {
    font-size: 18px;
    flex: 1;
    text-align: center;
    min-width: 120px;
  }

  .calendar-cell {
    min-height: 40px;
    aspect-ratio: unset;
    padding: 4px;
  }

  .calendar-date { font-size: 11px; }

  .calendar-day-name { font-size: 10px; padding: 4px 2px; }

  .day-panel {
    width: 100%;
    padding: 16px;
    padding-bottom: calc(var(--bottom-nav-height) + 16px);
  }

  /* Grafikler */
  .chart-container { height: 220px; }

  .reports-grid { gap: 16px; }

  /* Modaller — bottom sheet */
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .modal {
    max-width: 100%;
    border-radius: 16px 16px 0 0;
    max-height: 90vh;
  }

  .modal::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    background: var(--text-tertiary);
    border-radius: 2px;
    margin: 12px auto 0;
  }

  .modal-footer {
    flex-direction: column-reverse;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }

  .modal-footer .btn { width: 100%; }

  .form-row { flex-direction: column; }

  .form-row .currency-col { width: 100%; }

  .amount-row { flex-direction: row !important; }
  .amount-row .currency-col { width: 100px; flex-shrink: 0; }

  /* Hızlı ekle */
  .quick-add-btn {
    bottom: calc(var(--bottom-nav-height) + 16px);
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    z-index: 95;
  }

  .quick-add-btn:hover { transform: translateX(-50%) scale(1.05); }

  /* Toast */
  .toast-container {
    bottom: calc(var(--bottom-nav-height) + 16px);
    left: 16px;
    right: 16px;
  }

  .toast { min-width: unset; width: 100%; }

  .user-avatar { display: none; }

  .currency-switcher .select-sm { max-width: 72px; padding: 6px 8px; }

  /* Ayarlar */
  .settings-section { margin-bottom: 20px; }

  .category-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .category-item > div:last-child {
    width: 100%;
    display: flex;
    gap: 8px;
  }

  .category-item .btn { flex: 1; }

  /* Bütçe */
  .budget-item-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .budget-amounts { flex-direction: column; gap: 4px; }

  /* Pagination */
  .pagination { gap: 4px; }

  /* Boş durum */
  .empty-state { padding: 32px 16px; }

  .text-display { font-size: 28px; }
  .text-title { font-size: 20px; }

  /* Insights */
  .insights-box { padding: 16px; }

  .insight-item { font-size: 13px; }

  /* Mobil kart swipe alanı */
  .mobile-card { padding: 14px; }

  .mobile-card-actions { flex-direction: column; }
  .mobile-card-actions .btn { width: 100%; }

  /* Auth */
  .auth-card { padding: 24px 20px; }
  .auth-page { padding: 16px; }
}

@media (max-width: 374px) {
  .tab { font-size: 12px; padding: 8px 8px; }
  .bottom-nav-item span { font-size: 9px; }
}
