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

:root {
  --color-background-primary: #f5f5f3;
  --color-background-secondary: #ffffff;
  --color-background-tertiary: #ececea;
  --color-text-primary: #1a1a18;
  --color-text-secondary: #5a5a57;
  --color-text-tertiary: #9a9995;
  --color-border-tertiary: #d8d8d5;
  --color-accent: #2563eb;
  --color-danger: #dc2626;
  --color-warning: #d97706;
  --color-success: #16a34a;
  --radius-card: 12px;
  --radius-metric: 8px;
  --shadow-card: 0 1px 3px rgba(0,0,0,0.06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  font-family: var(--font);
  background: var(--color-background-primary);
  color: var(--color-text-primary);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  padding-left: 64px;
  padding-top: 48px;
}

/* ── TOP NAV (section page links) ── */
.top-nav {
  position: fixed;
  top: 0; left: 64px; right: 0;
  height: 48px;
  background: var(--color-background-secondary);
  border-bottom: 0.5px solid var(--color-border-tertiary);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 20px;
  z-index: 99;
}
.top-nav-link {
  text-decoration: none;
  color: var(--color-text-secondary);
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 6px;
  transition: background .12s, color .12s;
  white-space: nowrap;
}
.top-nav-link:hover { background: var(--color-background-tertiary); color: var(--color-text-primary); }
.top-nav-link.active { background: var(--color-background-tertiary); color: var(--color-text-primary); font-weight: 500; }

/* ── SIDEBAR NAV ── */
.nav {
  position: fixed;
  left: 0; top: 0;
  width: 64px; height: 100vh;
  background: var(--color-background-secondary);
  border-right: 0.5px solid var(--color-border-tertiary);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar-brand {
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  border-bottom: 0.5px solid var(--color-border-tertiary);
  flex-shrink: 0;
}
.sidebar-items {
  display: flex;
  flex-direction: column;
  padding: 8px 0;
  flex: 1;
}
.sidebar-divider {
  height: 0.5px;
  background: var(--color-border-tertiary);
  margin: 6px 10px;
}
.sidebar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 4px;
  text-decoration: none;
  color: var(--color-text-tertiary);
  border-radius: 8px;
  margin: 1px 6px;
  transition: background .12s, color .12s;
  cursor: pointer;
  border: none;
  font-family: var(--font);
  background: none;
  width: calc(100% - 12px);
  position: relative;
}
.sidebar-item[data-importing] .sidebar-icon::after {
  content: '';
  position: absolute;
  top: 1px;
  right: 1px;
  width: 9px;
  height: 9px;
  background: #ef4444;
  border-radius: 50%;
  border: 2px solid var(--color-background-primary, #fff);
  animation: import-pulse 1.2s ease-in-out infinite;
}
.sidebar-icon { position: relative; }
@keyframes import-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}
.sidebar-item:hover { background: var(--color-background-tertiary); color: var(--color-text-secondary); }
.sidebar-item.active { color: var(--color-text-primary); }
.sidebar-item.active .sidebar-icon {
  background: var(--color-text-primary);
  color: #fff;
}
.sidebar-icon {
  width: 36px; height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 16px;
  background: var(--color-background-primary);
  flex-shrink: 0;
}
.sidebar-label {
  font-size: 9px;
  font-weight: 500;
  text-align: center;
  line-height: 1;
  letter-spacing: 0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 52px;
}
.sidebar-footer {
  border-top: 0.5px solid var(--color-border-tertiary);
  padding: 6px 0;
  flex-shrink: 0;
}

/* ── PAGE WRAPPER ── */
.page { max-width: 1100px; margin: 0 auto; padding: 24px 20px 64px; }

/* ── TOP BAR ── */
.top-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.month-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--color-background-secondary);
  border: 0.5px solid var(--color-border-tertiary);
  border-radius: 8px;
  padding: 6px 12px;
}
.month-nav button {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-secondary);
  font-size: 16px;
  padding: 0 4px;
  line-height: 1;
}
.month-nav button:hover { color: var(--color-text-primary); }
.month-label { font-weight: 500; font-size: 14px; min-width: 100px; text-align: center; }

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 0.5px solid var(--color-border-tertiary);
  background: var(--color-background-secondary);
  color: var(--color-text-primary);
  transition: background .12s;
  text-decoration: none;
}
.btn:hover { background: var(--color-background-tertiary); }
.btn-primary {
  background: var(--color-text-primary);
  color: #fff;
  border-color: var(--color-text-primary);
}
.btn-primary:hover { opacity: .88; background: var(--color-text-primary); }
.btn-danger { color: var(--color-danger); }
.btn-danger:hover { background: #fef2f2; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ── CARDS ── */
.card {
  background: var(--color-background-secondary);
  border: 0.5px solid var(--color-border-tertiary);
  border-radius: var(--radius-card);
  padding: 14px 16px;
  box-shadow: var(--shadow-card);
}

/* ── METRIC CARDS ── */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.metric-card {
  background: var(--color-background-secondary);
  border-radius: var(--radius-metric);
  padding: 14px 16px;
  border: 0.5px solid var(--color-border-tertiary);
}
.metric-label { font-size: 12px; color: var(--color-text-tertiary); margin-bottom: 4px; }
.metric-value { font-size: 22px; font-weight: 500; line-height: 1.2; overflow-wrap: break-word; }
.metric-sub { font-size: 12px; color: var(--color-text-secondary); margin-top: 3px; }
.metric-sub.up { color: var(--color-danger); }
.metric-sub.down { color: var(--color-success); }

/* ── BANNER ── */
.banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 13px;
}
.banner-warning {
  background: #fffbeb;
  border: 0.5px solid #fcd34d;
  color: #92400e;
}
.banner-danger {
  background: #fef2f2;
  border-left: 3px solid var(--color-danger);
  border-radius: 0 8px 8px 0;
  color: #7f1d1d;
}
.banner a { color: inherit; font-weight: 500; }

/* ── TWO-COL GRID ── */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }

/* ── CATEGORY LIST ── */
.category-list { display: flex; flex-direction: column; gap: 8px; }
.cat-row { display: flex; align-items: center; gap: 10px; }
.cat-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.cat-name { flex: 1; font-size: 13px; color: var(--color-text-secondary); }
.cat-bar-wrap { width: 80px; height: 4px; background: var(--color-background-tertiary); border-radius: 2px; }
.cat-bar { height: 100%; border-radius: 2px; }
.cat-amount { font-size: 13px; font-weight: 500; min-width: 60px; text-align: right; }

/* ── TREND SPARKLINES ── */
.trend-list { display: flex; flex-direction: column; gap: 10px; }
.trend-row { display: flex; align-items: center; gap: 10px; }
.trend-name { flex: 1; font-size: 13px; color: var(--color-text-secondary); }
.trend-bars { display: flex; align-items: flex-end; gap: 3px; height: 28px; }
.trend-bar { width: 12px; border-radius: 2px 2px 0 0; background: var(--color-background-tertiary); }
.trend-badge { font-size: 12px; min-width: 20px; }

/* ── SECTION HEADER ── */
.section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.section-title { font-size: 13px; font-weight: 500; color: var(--color-text-secondary); }

/* ── FILTER CHIPS ── */
.filter-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chip {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  border: 0.5px solid var(--color-border-tertiary);
  background: var(--color-background-secondary);
  color: var(--color-text-secondary);
  transition: all .12s;
}
.chip:hover { background: var(--color-background-tertiary); }
.chip.active { background: var(--color-text-primary); color: #fff; border-color: var(--color-text-primary); }

/* ── TRANSACTION ROWS ── */
.tx-list { display: flex; flex-direction: column; }
.tx-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 0.5px solid var(--color-border-tertiary);
  cursor: pointer;
  transition: background .1s;
  border-radius: 4px;
}
.tx-row:hover { background: var(--color-background-primary); padding-left: 6px; padding-right: 6px; }
.tx-icon { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 15px; flex-shrink: 0; }
.tx-info { flex: 1; min-width: 0; }
.tx-merchant { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-meta { font-size: 12px; color: var(--color-text-tertiary); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.tx-right { text-align: right; flex-shrink: 0; }
.tx-amount { font-size: 14px; font-weight: 500; }
.tx-date { font-size: 12px; color: var(--color-text-tertiary); }

/* ── BADGES ── */
.badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}
.badge-foreign { background: #eff6ff; color: #1d4ed8; }
.badge-installment { background: #f5f3ff; color: #5b21b6; }
.badge-recurring { width: 6px; height: 6px; border-radius: 50%; background: var(--color-success); display: inline-block; }

/* ── INLINE EDIT PANEL ── */
.tx-expand {
  background: var(--color-background-primary);
  border: 0.5px solid var(--color-border-tertiary);
  border-radius: 8px;
  padding: 12px;
  margin: 4px 0 8px 44px;
  display: none;
}
.tx-expand.open { display: block; }
.expand-fields { display: flex; flex-direction: column; gap: 8px; }
.tx-edit-row td { padding: 10px 16px; background: var(--color-background-primary); }
.field-group { display: flex; flex-direction: column; gap: 4px; }
.field-label { font-size: 11px; color: var(--color-text-tertiary); }
.field-input, .field-select {
  padding: 5px 8px;
  border: 0.5px solid var(--color-border-tertiary);
  border-radius: 6px;
  font-size: 13px;
  background: var(--color-background-secondary);
  color: var(--color-text-primary);
  font-family: var(--font);
}
.field-input:focus, .field-select:focus { outline: 2px solid var(--color-accent); outline-offset: -1px; }

/* ── INSTALLMENTS TABLE ── */
.inst-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.inst-table th { color: var(--color-text-tertiary); font-weight: 500; text-align: left; padding: 6px 8px; border-bottom: 0.5px solid var(--color-border-tertiary); }
.inst-table td { padding: 8px; border-bottom: 0.5px solid var(--color-border-tertiary); }

/* ── COLLAPSIBLE ── */
.collapsible-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  font-family: var(--font);
}
.collapsible-btn:hover { color: var(--color-text-primary); }

/* ── FULL TABLE (transactions page) ── */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  color: var(--color-text-tertiary);
  font-weight: 500;
  text-align: left;
  padding: 8px 10px;
  border-bottom: 0.5px solid var(--color-border-tertiary);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}
.data-table th:hover { color: var(--color-text-primary); }
.data-table td { padding: 9px 10px; border-bottom: 0.5px solid var(--color-border-tertiary); vertical-align: middle; }
.data-table tr:hover td { background: var(--color-background-primary); }

/* ── SIDEBAR FILTERS ── */
.page-layout { display: grid; grid-template-columns: 220px 1fr; gap: 16px; align-items: start; }
.sidebar { position: sticky; top: 64px; }
.filter-section { margin-bottom: 16px; }
.filter-label { font-size: 11px; font-weight: 500; color: var(--color-text-tertiary); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px; }
.filter-input {
  width: 100%;
  padding: 7px 10px;
  border: 0.5px solid var(--color-border-tertiary);
  border-radius: 7px;
  font-size: 13px;
  background: var(--color-background-secondary);
  color: var(--color-text-primary);
  font-family: var(--font);
}
.filter-input:focus { outline: 2px solid var(--color-accent); outline-offset: -1px; }
.filter-toggle { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.filter-toggle input[type=checkbox] { width: 14px; height: 14px; cursor: pointer; }

/* ── SETTINGS ── */
.settings-section { margin-bottom: 28px; }
.settings-title { font-size: 15px; font-weight: 500; margin-bottom: 12px; }
.rule-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.rule-table th, .rule-table td { padding: 9px 10px; border-bottom: 0.5px solid var(--color-border-tertiary); text-align: left; }
.rule-table th { color: var(--color-text-tertiary); font-weight: 500; }
.config-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 0.5px solid var(--color-border-tertiary); }
.config-label { flex: 1; font-size: 13px; }
.config-sub { font-size: 12px; color: var(--color-text-tertiary); }
.toggle-switch { position: relative; width: 36px; height: 20px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute; inset: 0;
  background: var(--color-border-tertiary);
  border-radius: 20px;
  cursor: pointer;
  transition: background .2s;
}
.toggle-track::after {
  content: '';
  position: absolute;
  left: 3px; top: 3px;
  width: 14px; height: 14px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
}
.toggle-switch input:checked + .toggle-track { background: var(--color-text-primary); }
.toggle-switch input:checked + .toggle-track::after { transform: translateX(16px); }

/* ── PAGINATION ── */
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 16px; align-items: center; font-size: 13px; }
.page-info { color: var(--color-text-secondary); }

/* ── EMPTY STATE ── */
.empty { text-align: center; padding: 48px 20px; color: var(--color-text-tertiary); }
.empty p { margin-bottom: 12px; }

/* ── LOADING ── */
.loading { color: var(--color-text-tertiary); font-size: 13px; padding: 12px 0; }

/* ── OVERVIEW PAGE ── */
.ov-hero {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.ov-hero-card {
  background: var(--color-background-secondary);
  border: 0.5px solid var(--color-border-tertiary);
  border-radius: var(--radius-card);
  padding: 20px 20px 16px;
  box-shadow: var(--shadow-card);
}
.ov-hero-label { font-size: 12px; color: var(--color-text-tertiary); margin-bottom: 6px; }
.ov-hero-value { font-size: 28px; font-weight: 500; line-height: 1.1; margin-bottom: 4px; overflow-wrap: break-word; }
.ov-hero-sub { font-size: 12px; color: var(--color-text-tertiary); }
.ov-flow-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.ov-flow-label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--color-text-secondary); }
.ov-flow-icon { width: 26px; height: 26px; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 13px; flex-shrink: 0; }
.ov-flow-right { display: flex; align-items: center; gap: 8px; }
.ov-flow-amount { font-size: 14px; font-weight: 500; }
.ov-income { color: var(--color-success); }
.ov-expense { color: var(--color-danger); }
.ov-flow-bar-wrap { height: 5px; background: var(--color-background-tertiary); border-radius: 3px; margin-bottom: 4px; }
.ov-flow-bar { height: 100%; border-radius: 3px; }
.ov-bar-income { background: var(--color-success); }
.ov-bar-expense { background: var(--color-danger); }
.ov-flow-divider { height: 0.5px; background: var(--color-border-tertiary); margin: 12px 0; }
.ov-flow-result { font-size: 13px; font-weight: 500; color: var(--color-text-primary); }
.ov-coming-soon { font-size: 11px; color: var(--color-accent); text-decoration: none; cursor: pointer; }
.ov-coming-soon:hover { text-decoration: underline; }
.ov-link { font-size: 12px; color: var(--color-accent); text-decoration: none; margin-left: auto; }
.ov-link:hover { text-decoration: underline; }

/* ── Timeline ── */
.ov-timeline-card { margin-bottom: 16px; }
.ov-proj-legend { font-size: 11px; color: var(--color-text-tertiary); margin-left: auto; }
.ov-timeline {
  display: flex;
  align-items: stretch;
  gap: 0;
  overflow-x: auto;
  padding-bottom: 4px;
}
.ov-tl-col {
  flex: 1;
  min-width: 100px;
  padding: 8px 10px;
  border-radius: 8px;
}
.ov-tl-col:hover { background: var(--color-background-primary); }
.ov-tl-projected {
  background: var(--color-background-primary);
  border: 0.5px dashed var(--color-border-tertiary);
  opacity: 0.85;
}
.ov-tl-divider {
  width: 1px;
  background: var(--color-border-tertiary);
  margin: 0 4px;
  flex-shrink: 0;
  align-self: stretch;
}
.ov-tl-month {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 3px;
}
.ov-tl-star { color: var(--color-accent); font-size: 9px; }
.ov-tl-rows { display: flex; flex-direction: column; gap: 4px; }
.ov-tl-row { display: flex; justify-content: space-between; align-items: baseline; gap: 4px; }
.ov-tl-label { font-size: 10px; color: var(--color-text-tertiary); white-space: nowrap; }
.ov-tl-val { font-size: 12px; font-weight: 500; white-space: nowrap; }
.ov-tl-income { color: var(--color-success); }
.ov-tl-expense { color: var(--color-text-primary); }
.ov-tl-bar-wrap { height: 3px; background: var(--color-background-tertiary); border-radius: 2px; margin: 3px 0; }
.ov-tl-bar { height: 100%; background: var(--color-danger); border-radius: 2px; opacity: 0.6; }
.ov-tl-net-row { border-top: 0.5px solid var(--color-border-tertiary); padding-top: 4px; margin-top: 2px; }

/* ── TOAST ── */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--color-text-primary);
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 9999;
  opacity: 0;
  transform: translateY(8px);
  transition: all .2s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ── MODAL ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.3);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity .15s;
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--color-background-secondary);
  border-radius: var(--radius-card);
  padding: 20px;
  min-width: 320px;
  max-width: 480px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,.12);
}
.modal h3 { font-size: 15px; font-weight: 500; margin-bottom: 14px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

/* ── SETTINGS TABS ── */
.settings-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 0.5px solid var(--color-border-tertiary);
  padding-bottom: 0;
}
.settings-tab {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  color: var(--color-text-tertiary);
  padding: 8px 16px;
  border-bottom: 2px solid transparent;
  margin-bottom: -0.5px;
  transition: color .15s, border-color .15s;
}
.settings-tab:hover { color: var(--color-text-secondary); }
.settings-tab.active { color: var(--color-text-primary); border-bottom-color: var(--color-text-primary); }

/* ── TAG PICKER ── */
.tp-container { position: relative; }
.tp-chips { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; min-height: 28px; padding: 2px 0; }
.tp-chip { display: inline-flex; align-items: center; gap: 2px; background: #f3f4f6; border-radius: 4px; padding: 2px 6px 2px 8px; font-size: 12px; color: var(--color-text-secondary); }
.tp-chip-remove { background: none; border: none; cursor: pointer; color: var(--color-text-tertiary); padding: 0 2px; font-size: 15px; line-height: 1; display: flex; align-items: center; }
.tp-chip-remove:hover { color: var(--color-danger); }
.tp-add-btn { font-size: 11px; padding: 2px 8px; }
.tp-dropdown { min-width: 220px; background: var(--color-background-secondary); border: 0.5px solid var(--color-border-secondary); border-radius: var(--radius-card); box-shadow: 0 4px 16px rgba(0,0,0,.14); padding: 6px; }
.tp-list { max-height: 180px; overflow-y: auto; margin-top: 4px; }
.tp-item { display: flex; align-items: center; gap: 6px; padding: 5px 6px; border-radius: 4px; cursor: pointer; font-size: 13px; }
.tp-item:hover { background: var(--color-background-tertiary); }
.tp-item-selected { color: var(--color-accent); font-weight: 500; }
.tp-check { width: 14px; font-size: 11px; color: var(--color-success); flex-shrink: 0; }
.tp-create { color: var(--color-accent); font-style: italic; }
.tp-empty { padding: 8px 6px; color: var(--color-text-tertiary); font-size: 12px; }


/* ── DAILY CALENDAR ── */
.cal-weekdays {
  display: grid; grid-template-columns: repeat(7, 1fr);
  margin-bottom: 4px;
}
.cal-wday {
  text-align: center; font-size: 11px; color: var(--color-text-tertiary);
  padding: 4px 0; font-weight: 500;
}
.cal-days {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px;
}
.cal-day {
  min-height: 56px; padding: 5px 4px 4px;
  border-radius: 8px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  transition: background .12s;
}
.cal-day:hover { background: var(--color-background-tertiary); }
.cal-day-empty { cursor: default; pointer-events: none; }
.cal-day-num {
  font-size: 12px; color: var(--color-text-tertiary); line-height: 1;
  font-weight: 400; align-self: flex-end; margin-right: 2px;
  width: 100%; text-align: right;
}
.cal-day-bubble {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--color-background-tertiary);
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 1px;
}
.cal-day-has-tx .cal-day-bubble {
  background: #fee2e2;
}
.cal-day-bubble-amt {
  font-size: 9px; font-weight: 600; color: var(--color-danger); line-height: 1;
}
.cal-day-bubble-count {
  font-size: 8px; color: var(--color-text-tertiary); line-height: 1;
}
.cal-day-today .cal-day-num { color: var(--color-accent); font-weight: 700; }
.cal-day-selected .cal-day-bubble {
  background: var(--color-text-primary) !important;
}
.cal-day-selected .cal-day-bubble-amt,
.cal-day-selected .cal-day-bubble-count {
  color: #fff !important;
}
.cal-day-selected .cal-day-num { color: var(--color-text-primary); font-weight: 600; }
.cal-day-selected { background: var(--color-background-tertiary); }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ov-hero { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-col { grid-template-columns: 1fr; }
  .page-layout { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  body { padding-left: 0; padding-top: 48px; padding-bottom: 64px; }
  .page { padding: 16px 12px 64px; }
  .nav {
    width: 100%; height: 64px;
    top: auto; bottom: 0; left: 0;
    flex-direction: row;
    border-right: none;
    border-top: 0.5px solid var(--color-border-tertiary);
    overflow-x: auto; overflow-y: hidden;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .top-nav {
    left: 0;
    overflow-x: auto; overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .top-nav::-webkit-scrollbar { display: none; }
  .top-nav-link { padding: 12px 12px; font-size: 14px; }
  .sidebar-brand { display: none; }
  .sidebar-items { flex-direction: row; padding: 0; flex: 1; }
  .sidebar-divider { display: none; }
  .sidebar-footer { border-top: none; border-left: 0.5px solid var(--color-border-tertiary); padding: 0; display: flex; align-items: center; }
  .sidebar-item { margin: 2px; padding: 4px 2px; min-width: 44px; min-height: 44px; justify-content: center; }
  .sidebar-icon { width: 32px; height: 32px; }

  /* Touch targets ≥44px */
  .btn { min-height: 44px; padding: 10px 16px; }
  .btn-sm { min-height: 40px; padding: 8px 12px; }
  select, input[type="text"], input[type="date"], input[type="number"], input[type="color"] { min-height: 44px; }
  input[type="checkbox"] { width: 20px; height: 20px; }

  /* Settings tables (rules/merchants/tags/categories/accounts) — scroll rather than clip */
  .rule-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }

  /* Transaction table → stacked cards */
  .data-table thead { display: none; }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
  .data-table tr {
    margin-bottom: 10px;
    border: 0.5px solid var(--color-border-tertiary);
    border-radius: var(--radius-card);
    padding: 10px 12px;
    background: var(--color-background-secondary);
  }
  .data-table tr:hover td { background: none; }
  .data-table tr.tx-edit-row { border: none; padding: 0; background: none; margin-bottom: 0; }
  .data-table td {
    border-bottom: none;
    padding: 6px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
  }
  .data-table td[data-label]::before {
    content: attr(data-label);
    font-size: 11px;
    color: var(--color-text-tertiary);
    flex-shrink: 0;
  }
}
@media (max-width: 480px) {
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ov-hero { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
