/* ============================================================
   HAUSHALTSBUCH — Dark Luxury Financial App
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@300;400;500&family=Syne:wght@400;600;700;800&family=Instrument+Sans:wght@300;400;500;600&display=swap');

:root {
  --bg-primary:     #090c10;
  --bg-secondary:   #0f1520;
  --bg-card:        #131a24;
  --bg-card-hover:  #182030;
  --bg-input:       #0c1219;
  --border:         #1e2d3d;
  --border-light:   #243547;
  --accent-teal:    #2dd4bf;
  --accent-teal-dim:#1a7a6e;
  --accent-amber:   #f59e0b;
  --accent-rose:    #f43f5e;
  --accent-emerald: #10b981;
  --text-primary:   #e8edf5;
  --text-secondary: #7a8fa6;
  /*--text-muted:     #445566;*/
  --text-muted:     #7a8fa6;
  --income-color:   #10b981;
  --expense-color:  #f43f5e;
  --font-display:   'Syne', sans-serif;
  --font-body:      'Instrument Sans', sans-serif;
  --font-mono:      'DM Mono', monospace;
  --radius-sm:      6px;
  --radius-md:      12px;
  --radius-lg:      18px;
  --shadow-card:    0 4px 24px rgba(0,0,0,0.4), 0 1px 3px rgba(0,0,0,0.6);
  --shadow-teal:    0 0 24px rgba(45, 212, 191, 0.15);
  --transition:     0.2s cubic-bezier(0.4,0,0.2,1);
  --mobile-nav-h:   64px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  /* prevent pull-to-refresh on iOS causing layout jumps */
  overscroll-behavior-y: contain;
}

/* Background grid */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: 0;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 48px 48px;
  opacity: 0.3;
  pointer-events: none;
}

/* ── AUTH SCREEN ── */
#auth-screen {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-primary);
  padding: 20px;
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 48px 40px;
  text-align: center;
  max-width: 400px; width: 100%;
  box-shadow: var(--shadow-card), var(--shadow-teal);
  position: relative; overflow: hidden;
}
.auth-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-teal), transparent);
}
.auth-logo { font-family: var(--font-display); font-weight: 800; font-size: 2rem; letter-spacing: -1px; }
.auth-logo span { color: var(--accent-teal); }
.auth-subtitle { font-size: 0.875rem; color: var(--text-secondary); margin-bottom: 36px; font-family: var(--font-mono); letter-spacing: 0.05em; }

.btn-google {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  width: 100%; padding: 14px 24px;
  background: var(--bg-input); border: 1px solid var(--border-light);
  border-radius: var(--radius-md); color: var(--text-primary);
  font-family: var(--font-body); font-size: 0.95rem; font-weight: 500;
  cursor: pointer; transition: var(--transition); text-decoration: none; margin-bottom: 12px;
}
.btn-google:hover { background: var(--bg-card-hover); border-color: var(--accent-teal); box-shadow: var(--shadow-teal); transform: translateY(-1px); }
.btn-google img { width: 20px; height: 20px; }

.auth-demo-btn {
  width: 100%; padding: 12px;
  background: transparent; border: 1px solid var(--border);
  border-radius: var(--radius-md); color: var(--text-secondary);
  font-family: var(--font-body); font-size: 0.875rem; cursor: pointer; transition: var(--transition);
}
.auth-demo-btn:hover { border-color: var(--accent-amber); color: var(--accent-amber); }

/* ── MAIN APP LAYOUT ── */
#app-screen { display: none; min-height: 100vh; }

/* ── TOPBAR ── */
.topbar {
  position: sticky; top: 0; z-index: 100;
  background: rgba(9,12,16,0.92); backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px; height: 64px;
  display: flex; align-items: center; justify-content: space-between;
}
.topbar-brand { font-family: var(--font-display); font-weight: 800; font-size: 1.25rem; letter-spacing: -0.5px; }
.topbar-brand span { color: var(--accent-teal); }
.topbar-right { display: flex; align-items: center; gap: 16px; }

.sync-indicator { display: flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 0.7rem; color: var(--text-muted); }
.sync-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted); transition: var(--transition); }
.sync-dot.online  { background: var(--accent-emerald); box-shadow: 0 0 8px var(--accent-emerald); }
.sync-dot.syncing { background: var(--accent-amber); animation: pulse 1s infinite; }
.sync-dot.offline { background: var(--accent-rose); }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:0.3; } }

/* ── SIDEBAR NAV ── */
.app-layout { display: flex; min-height: calc(100vh - 64px); position: relative; z-index: 1; }

.sidebar {
  width: 240px; flex-shrink: 0;
  background: var(--bg-secondary); border-right: 1px solid var(--border);
  padding: 24px 12px;
  position: sticky; top: 64px; height: calc(100vh - 64px); overflow-y: auto;
}
.nav-section-label {
  font-family: var(--font-mono); font-size: 0.65rem; color: var(--text-muted);
  letter-spacing: 0.12em; text-transform: uppercase; padding: 0 12px;
  margin: 20px 0 8px;
}
.nav-section-label:first-child { margin-top: 0; }
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--text-secondary); font-size: 0.9rem; font-weight: 500;
  cursor: pointer; transition: var(--transition); text-decoration: none;
  border: 1px solid transparent; margin-bottom: 2px;
}
.nav-link i { width: 18px; text-align: center; font-size: 0.875rem; }
.nav-link:hover { background: var(--bg-card); color: var(--text-primary); border-color: var(--border); }
.nav-link.active { background: rgba(45,212,191,0.1); color: var(--accent-teal); border-color: rgba(45,212,191,0.25); }

/* ── MAIN CONTENT ── */
.main-content { flex: 1; padding: 32px; overflow-x: hidden; min-width: 0; }

/* ── PAGE SECTIONS ── */
.page-section { display: none; }
.page-section.active { display: block; animation: fadeIn 0.25s ease; }
@keyframes fadeIn { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:none; } }

.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 28px; flex-wrap: wrap; gap: 12px;
}
.page-title { font-family: var(--font-display); font-weight: 700; font-size: 1.75rem; letter-spacing: -0.5px; }
.page-subtitle { font-size: 0.875rem; color: var(--text-secondary); margin-top: 3px; }

/* ── CARDS ── */
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-card); overflow: hidden;
}
.card-body { padding: 24px; }
.card-header-custom {
  padding: 16px 24px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-family: var(--font-display); font-weight: 600; font-size: 1rem; }

/* ── KPI CARDS ── */
.kpi-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px; margin-bottom: 24px;
}
.kpi-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 22px 24px;
  position: relative; overflow: hidden; transition: var(--transition);
}
.kpi-card:hover { border-color: var(--border-light); transform: translateY(-2px); }
.kpi-card::after {
  content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 2px;
  background: var(--accent-color, var(--accent-teal));
  transform: scaleX(0); transform-origin: left; transition: transform 0.3s ease;
}
.kpi-card:hover::after { transform: scaleX(1); }
.kpi-label { font-family: var(--font-mono); font-size: 0.7rem; color: var(--text-muted); letter-spacing: 0.1em; text-transform: uppercase; margin-bottom: 8px; }
.kpi-value { font-family: var(--font-display); font-weight: 700; font-size: 1.6rem; letter-spacing: -1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-value.positive { color: var(--income-color); }
.kpi-value.negative { color: var(--expense-color); }
.kpi-sub { font-size: 0.75rem; color: var(--text-muted); margin-top: 6px; }
.kpi-icon {
  position: absolute; right: 16px; top: 16px; width: 36px; height: 36px;
  border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; font-size: 0.9rem; opacity: 0.8;
}

/* ── TRANSACTION TABLE ── */
.tx-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.tx-table thead th {
  font-family: var(--font-mono); font-size: 0.7rem; color: var(--text-primary);
  letter-spacing: 0.1em; text-transform: uppercase; padding: 12px 16px;
  border-bottom: 1px solid var(--border); white-space: nowrap; text-align: left;
}
.tx-table tbody tr { border-bottom: 1px solid var(--border); transition: var(--transition); }
.tx-table tbody tr:last-child { border-bottom: none; }
.tx-table tbody tr:hover { background: var(--bg-card-hover); }
.tx-table td { padding: 12px 16px; font-size: 0.875rem; vertical-align: middle; overflow: hidden; text-overflow: ellipsis; }

/* Column widths on desktop */
.tx-col-desc    { width: 40%; }
.tx-col-amount  { width: 18%; }
.tx-col-date    { width: 16%; }
.tx-col-type    { width: 18%; }
.tx-col-actions { width: 8%; }

.tx-amount { font-family: var(--font-mono); font-weight: 500; white-space: nowrap; }
.tx-amount.income  { color: var(--income-color); }
.tx-amount.income::before  { content: '+'; }
.tx-amount.expense { color: var(--expense-color); }
.tx-amount.expense::before { content: '−'; }

.tx-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 100px;
  font-size: 0.7rem; font-family: var(--font-mono); font-weight: 500; border: 1px solid;
  white-space: nowrap;
}
.tx-badge.income    { background: rgba(16,185,129,0.1);  border-color: rgba(16,185,129,0.3);  color: var(--income-color); }
.tx-badge.expense   { background: rgba(244,63,94,0.1);   border-color: rgba(244,63,94,0.3);   color: var(--expense-color); }
.tx-badge.recurring { background: rgba(245,158,11,0.1);  border-color: rgba(245,158,11,0.3);  color: var(--accent-amber); }
.tx-badge.installment { background: rgba(139,92,246,0.1); border-color: rgba(139,92,246,0.3); color: #a78bfa; }

.category-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; flex-shrink: 0; }

/* ── PWA INSTALL BUTTON ── */
.btn-install {
  display: none; /* shown via JS when installable */
  align-items: center; gap: 7px;
  padding: 7px 14px; border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(45,212,191,0.15), rgba(45,212,191,0.08));
  border: 1px solid rgba(45,212,191,0.4);
  color: var(--accent-teal);
  font-family: var(--font-mono); font-size: 0.72rem; font-weight: 500;
  cursor: pointer; transition: var(--transition);
  letter-spacing: 0.04em; white-space: nowrap;
}
.btn-install:hover {
  background: rgba(45,212,191,0.2);
  border-color: var(--accent-teal);
  box-shadow: var(--shadow-teal);
  transform: translateY(-1px);
}
.btn-install i { font-size: 0.8rem; }
@media (max-width: 480px) {
  .btn-install span { display: none; }
  .btn-install { padding: 7px 10px; }
}

/* ── BUTTONS ── */
.btn-primary-custom {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 20px;
  border-radius: var(--radius-md); background: var(--accent-teal); color: var(--bg-primary);
  font-family: var(--font-body); font-size: 0.875rem; font-weight: 600;
  border: none; cursor: pointer; transition: var(--transition);
}
.btn-primary-custom:hover { background: #3aecd6; transform: translateY(-1px); box-shadow: var(--shadow-teal); }
.btn-secondary-custom {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 20px;
  border-radius: var(--radius-md); background: var(--bg-card); color: var(--text-primary);
  font-family: var(--font-body); font-size: 0.875rem; font-weight: 500;
  border: 1px solid var(--border-light); cursor: pointer; transition: var(--transition);
}
.btn-secondary-custom:hover { background: var(--bg-card-hover); border-color: var(--accent-teal); color: var(--accent-teal); }
.btn-icon {
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text-secondary); cursor: pointer; transition: var(--transition); font-size: 0.8rem; flex-shrink: 0;
}
.btn-icon:hover { border-color: var(--accent-teal); color: var(--accent-teal); }

/* ── FORMS ── */
.form-label-custom { font-family: var(--font-mono); font-size: 0.7rem; color: var(--text-secondary); letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 6px; display: block; }
.form-control-custom {
  width: 100%; padding: 10px 14px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-primary);
  font-family: var(--font-body); font-size: 0.9rem;
  transition: var(--transition); outline: none;
}
.form-control-custom:focus { border-color: var(--accent-teal); box-shadow: 0 0 0 3px rgba(45,212,191,0.1); }
.form-control-custom option { background: var(--bg-card); }
.form-select-custom {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%237a8fa6' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px;
}
.form-group { margin-bottom: 18px; }

/* ── MODAL ── */
.modal-custom {
  display: none; position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(4px);
  align-items: center; justify-content: center;
  padding: 20px;
  padding-bottom: max(20px, env(safe-area-inset-bottom));
  overflow-y: auto;
}
.modal-custom.show { display: flex; }
.modal-box {
  background: var(--bg-card); border: 1px solid var(--border-light);
  border-radius: var(--radius-lg); width: 100%; max-width: 560px;
  max-height: calc(100vh - 40px); overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  animation: modalIn 0.25s cubic-bezier(0.34,1.56,0.64,1);
  /* On mobile, modal appears as bottom sheet */
}
@keyframes modalIn { from { transform: scale(0.95) translateY(20px); opacity:0; } to { transform:none; opacity:1; } }
.modal-header-custom { padding: 22px 24px 0; display: flex; align-items: center; justify-content: space-between; }
.modal-title-custom { font-family: var(--font-display); font-weight: 700; font-size: 1.2rem; }
.modal-close {
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  background: var(--bg-input); border: 1px solid var(--border);
  color: var(--text-secondary); cursor: pointer; transition: var(--transition);
  display: flex; align-items: center; justify-content: center; font-size: 0.875rem;
}
.modal-close:hover { border-color: var(--accent-rose); color: var(--accent-rose); }
.modal-body-custom { padding: 24px; }

/* ── TYPE TOGGLE ── */
.type-toggle { display: flex; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border); margin-bottom: 20px; }
.type-toggle-btn { flex: 1; padding: 10px; text-align: center; cursor: pointer; transition: var(--transition); font-size: 0.875rem; font-weight: 500; border: none; background: transparent; color: var(--text-muted); }
.type-toggle-btn.active-income  { background: rgba(16,185,129,0.15); color: var(--income-color);  font-weight: 600; }
.type-toggle-btn.active-expense { background: rgba(244,63,94,0.15);  color: var(--expense-color); font-weight: 600; }

/* ── CATEGORY COLORS ── */
.cat-color-picker { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.cat-color-swatch { width: 28px; height: 28px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; transition: var(--transition); }
.cat-color-swatch.selected { border-color: white; transform: scale(1.15); }

/* ── CHART CONTAINER ── */
.chart-container { position: relative; width: 100%; padding: 24px; }
.period-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.period-tab {
  padding: 6px 14px; border-radius: var(--radius-sm);
  font-family: var(--font-mono); font-size: 0.75rem;
  cursor: pointer; transition: var(--transition);
  border: 1px solid var(--border); background: transparent; color: var(--text-muted);
}
.period-tab.active { background: rgba(45,212,191,0.1); border-color: rgba(45,212,191,0.4); color: var(--accent-teal); }

/* ── PROGRESS BAR ── */
.progress-custom { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; margin-top: 8px; }
.progress-fill { height: 100%; border-radius: 2px; background: var(--accent-teal); transition: width 0.6s ease; }

/* ── EMPTY STATE ── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state i { font-size: 3rem; opacity: 0.3; margin-bottom: 16px; display: block; }
.empty-state p { font-size: 0.9rem; }

/* ── TOAST ── */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast-custom {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 18px; border-radius: var(--radius-md);
  background: var(--bg-card); border: 1px solid var(--border-light);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  font-size: 0.875rem; min-width: 240px; max-width: 320px;
  animation: toastIn 0.3s cubic-bezier(0.34,1.56,0.64,1);
  pointer-events: all;
}
@keyframes toastIn { from { transform: translateX(120%); opacity:0; } to { transform:none; opacity:1; } }
.toast-custom.toast-out { animation: toastOut 0.3s ease forwards; }
@keyframes toastOut { to { transform: translateX(120%); opacity:0; } }
.toast-custom.success { border-left: 3px solid var(--accent-emerald); }
.toast-custom.error   { border-left: 3px solid var(--accent-rose); }
.toast-custom.info    { border-left: 3px solid var(--accent-teal); }
.toast-custom.warning { border-left: 3px solid var(--accent-amber); }

/* ── MOBILE BOTTOM NAV ── */
.mobile-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  z-index: 200;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  /* Safe area for notched iPhones */
  padding-bottom: env(safe-area-inset-bottom, 0px);
  /* Prevent it from scrolling with content */
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}
.mobile-nav-grid { display: flex; justify-content: space-around; }
.mobile-nav-item {
  display: flex; flex-direction: column; align-items: center;
  gap: 3px; padding: 10px 8px;
  cursor: pointer; color: var(--text-muted);
  font-size: 0.6rem; font-family: var(--font-mono); letter-spacing: 0.04em;
  transition: var(--transition); border: none; background: none; flex: 1;
}
.mobile-nav-item i { font-size: 1.1rem; }
.mobile-nav-item.active { color: var(--accent-teal); }

/* ── DELETE CONFIRM BUTTON ── */
#btn-confirm-delete:hover:not(:disabled) {
  background: #e02347 !important;
  transform: translateY(-1px);
  box-shadow: 0 0 20px rgba(244,63,94,0.3);
}
#btn-confirm-delete:disabled {
  opacity: 0.7; cursor: not-allowed;
}

/* ── FILTER BAR ── */
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.filter-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 100px;
  background: var(--bg-input); border: 1px solid var(--border);
  color: var(--text-secondary); font-size: 0.8rem; cursor: pointer; transition: var(--transition);
}
.filter-chip:hover, .filter-chip.active { border-color: var(--accent-teal); color: var(--accent-teal); background: rgba(45,212,191,0.08); }

/* ── SETTINGS ── */
.settings-row { display: flex; align-items: center; justify-content: space-between; padding: 16px 0; border-bottom: 1px solid var(--border); }
.settings-row:last-child { border-bottom: none; }

/* ── CATEGORY LIST ── */
.cat-list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-radius: var(--radius-sm);
  background: var(--bg-input); border: 1px solid var(--border);
  margin-bottom: 8px; transition: var(--transition);
}
.cat-list-item:hover { border-color: var(--border-light); }

/* ── DATE RANGE ── */
.date-range-picker { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.date-range-picker span { color: var(--text-muted); font-size: 0.8rem; }

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

/* ── LOADING ── */
.loading-spinner { width: 20px; height: 20px; border: 2px solid var(--border-light); border-top-color: var(--accent-teal); border-radius: 50%; animation: spin 0.7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── MISC UTILS ── */
.text-income   { color: var(--income-color)  !important; }
.text-expense  { color: var(--expense-color) !important; }
.text-teal     { color: var(--accent-teal)   !important; }
.text-muted-custom    { color: var(--text-muted); }
.text-secondary-custom{ color: var(--text-secondary); }
.font-mono     { font-family: var(--font-mono); }
.font-display  { font-family: var(--font-display); }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE — MOBILE FIRST OVERRIDES (max-width: 768px)
══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* Hide desktop sidebar */
  .sidebar { display: none; }

  /* Show mobile bottom nav — fixed so it never scrolls away */
  .mobile-nav { display: block; }

  /* Topbar */
  .topbar { padding: 0 16px; }
  .sync-text { display: none; }

  /* Main content — no horizontal overflow, space for bottom nav */
  .main-content {
    padding: 16px;
    padding-bottom: calc(var(--mobile-nav-h) + env(safe-area-inset-bottom, 0px) + 16px);
    overflow-x: hidden;
  }

  /* Page titles */
  .page-title { font-size: 1.3rem; }
  .page-header { margin-bottom: 18px; }

  /* KPI grid: 2 columns on mobile */
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
  .kpi-card { padding: 14px 16px; }
  .kpi-value { font-size: 1.2rem; }
  .kpi-icon { display: none; }

  /* Charts: ensure no overflow */
  .chart-container { padding: 12px; }
  .period-tabs { gap: 4px; }
  .period-tab { padding: 5px 10px; font-size: 0.7rem; }

  /* Cards */
  .card-body { padding: 16px; }
  .card-header-custom { padding: 12px 16px; }

  /* Filter bar stacks vertically */
  .filter-bar { flex-direction: column; gap: 8px; }
  .filter-bar > * { width: 100%; }

  /* Transaction table:
     - No horizontal scroll wrapper
     - Hide desktop-only columns
     - Full width for description column
  */
  .tx-table { table-layout: auto; }
  .desktop-only { display: none !important; }

  /* Table rows: description gets full width minus amount */
  .tx-table td { padding: 10px 12px; }
  .tx-table thead th:not(.tx-col-desc):not(.tx-col-amount) { display: none; }

  /* Modal: bottom-sheet style on mobile */
  .modal-custom { align-items: flex-end; padding: 0; }
  .modal-box {
    max-width: 100%; width: 100%;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    max-height: 92vh;
    animation: sheetUp 0.3s cubic-bezier(0.4,0,0.2,1);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  @keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }

  /* Modal body scroll */
  .modal-body-custom { padding: 20px 16px; }
  .modal-header-custom { padding: 20px 16px 0; }

  /* Settings rows: stack on narrow screens */
  .settings-row { flex-direction: column; align-items: flex-start; gap: 10px; }

  /* Toast: bottom centered on mobile */
  .toast-container {
    left: 16px; right: 16px; bottom: calc(var(--mobile-nav-h) + env(safe-area-inset-bottom, 0px) + 8px);
    align-items: stretch;
  }
  .toast-custom { min-width: 0; max-width: 100%; }

  /* Date range picker: stack */
  .date-range-picker { flex-direction: column; }
  .date-range-picker input { width: 100%; }

  /* Category list: hide action buttons on very small screens */
  .cat-list-item span:nth-child(4) { display: none; }
}

/* ── Small phones ── */
@media (max-width: 380px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi-value { font-size: 1.1rem; }
}
