/* ============================================================
   NeonLedger — Cyberpunk Budget PWA
   ============================================================ */

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
button, input, select, textarea { font: inherit; }

:root {
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-card: #1a1f35;
  --bg-card-hover: #222845;
  --bg-input: #0f1629;
  --border: #2a3050;
  --border-glow: #00f0ff33;

  /* Surfaces & depth */
  --surface-card: linear-gradient(165deg, #1e2444 0%, #171c33 60%, #141830 100%);
  --surface-chrome: rgba(14, 20, 36, 0.82);
  --border-soft: rgba(148, 163, 204, 0.12);
  --border-strong: rgba(148, 163, 204, 0.22);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.35), 0 6px 20px rgba(2, 6, 18, 0.35);
  --shadow-2: 0 2px 4px rgba(0, 0, 0, 0.40), 0 12px 32px rgba(2, 6, 18, 0.50);

  --cyan: #00f0ff;
  --magenta: #ff00e5;
  --green: #39ff14;
  --red: #ff3366;
  --yellow: #ffe066;
  --orange: #ff8c42;
  --purple: #b388ff;

  --text-primary: #e0e6f0;
  --text-secondary: #8892a8;
  --text-muted: #7d87a3;

  --font-mono: ui-monospace, 'Cascadia Code', 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
  --font-sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 16px;

  --header-h: 56px;
  --bottom-nav-h: 64px;
  --sidebar-w: 260px;

  /* Glows: single soft layer, reserved for emphasis */
  --glow-cyan: 0 0 14px rgba(0, 240, 255, 0.16);
  --glow-magenta: 0 0 14px rgba(255, 0, 229, 0.14);
  --glow-green: 0 0 14px rgba(57, 255, 20, 0.14);
  --glow-red: 0 0 14px rgba(255, 51, 102, 0.14);

  --transition: 0.2s ease;
}

html { font-size: 16px; }

body {
  font-family: var(--font-sans);
  background:
    radial-gradient(1100px 600px at 85% -10%, rgba(0, 240, 255, 0.05), transparent 60%),
    radial-gradient(900px 600px at -15% 108%, rgba(255, 0, 229, 0.04), transparent 55%),
    var(--bg-primary);
  color: var(--text-primary);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
.no-scroll { overflow: hidden; }

/* Numbers, dates, and brand keep the terminal voice */
.logo, .stat-value, .list-item-amount, .month-picker-label, .header-date,
.bar-value, .legend-value, .envelope-amounts {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.form-input[type="number"], .form-input[type="date"] { font-family: var(--font-mono); }

/* Scanline overlay — a whisper, not a wash */
body::after {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 3px,
    rgba(0, 240, 255, 0.006) 3px,
    rgba(0, 240, 255, 0.006) 6px
  );
  pointer-events: none;
  z-index: 9999;
}

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

/* Keyboard focus */
:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0, 240, 255, 0.45); }

/* --- Typography --- */
h1, h2, h3, h4 { font-weight: 700; }
.accent { color: var(--cyan); }
.text-magenta { color: var(--magenta); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-yellow { color: var(--yellow); }
.text-muted { color: var(--text-secondary); }

/* --- Layout --- */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* --- Header --- */
#app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--surface-chrome);
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
}

.header-left { display: flex; align-items: center; gap: 12px; }
.header-right { display: flex; align-items: center; gap: 12px; }
.header-date {
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
}
@media (max-width: 399px) {
  .header-date { display: none; }
}

/* Header search — desktop shows the input (see ≥1024px block);
   on mobile the icon opens the full-screen overlay instead */
.header-search { display: flex; align-items: center; }
.search-input {
  display: none;
  padding: 6px 12px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.8rem;
}
.search-input:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 2px rgba(0,240,255,0.15); }
.search-input::-webkit-search-cancel-button { -webkit-appearance: none; }

/* Full-screen mobile search overlay */
.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 250; /* above sidebar (200), below modal (300) and toast (500) */
  background: rgba(10, 14, 26, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.15s ease;
}
.search-overlay-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--border-soft);
}
.search-overlay-input {
  flex: 1;
  padding: 10px 14px;
  font-family: var(--font-sans);
  font-size: 1rem; /* ≥16px prevents iOS focus zoom */
  line-height: 1.2;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.search-overlay-input:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 2px rgba(0,240,255,0.15); }
.search-overlay-input::-webkit-search-cancel-button { -webkit-appearance: none; }
.search-overlay-results {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
}

.logo {
  font-size: 1.15rem;
  letter-spacing: 1px;
  color: var(--text-primary);
}
.logo .accent { text-shadow: 0 0 18px rgba(0, 240, 255, 0.35); }

.icon-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.icon-btn:hover { color: var(--cyan); background: rgba(0,240,255,0.08); }

/* --- Sidebar --- */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: rgba(14, 20, 36, 0.88);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border-right: 1px solid var(--border-soft);
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  z-index: 200;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.sidebar.open { transform: translateX(0); }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border-soft);
}

.nav-list { list-style: none; padding: 8px; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  transition: var(--transition);
}
.nav-link:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
  text-decoration: none;
}
.nav-link.active {
  color: var(--cyan);
  background: rgba(0, 240, 255, 0.10);
  box-shadow: inset 2px 0 0 var(--cyan);
  text-decoration: none;
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 150;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.sidebar-overlay.open { opacity: 1; pointer-events: auto; }

/* --- Main Content --- */
.main-content {
  margin-top: var(--header-h);
  margin-bottom: var(--bottom-nav-h);
  padding: 16px;
  min-height: calc(100dvh - var(--header-h) - var(--bottom-nav-h));
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* --- Bottom Nav --- */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bottom-nav-h);
  background: var(--surface-chrome);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border-top: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.bottom-nav-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.6875rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius);
  transition: var(--transition);
  text-decoration: none;
}
.bottom-nav-item:hover, .bottom-nav-item.active {
  color: var(--cyan);
  text-decoration: none;
}
.bottom-nav-item.active::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 2px;
  border-radius: 2px;
  background: var(--cyan);
}

/* --- Card Grid --- */
.card-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* --- Cards --- */
.card {
  background: var(--surface-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-1);
  transition: var(--transition);
}
.card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-2); }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.card-title {
  font-family: var(--font-sans);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
}

/* --- Stat Cards --- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  position: relative;
  overflow: hidden;
  background: var(--surface-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-1);
}
/* Accent hairline along the top instead of a glowing border */
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--stat-accent, transparent);
}
.stat-label {
  font-family: var(--font-sans);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.stat-sub {
  font-family: var(--font-sans);
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.stat-card.glow-cyan    { --stat-accent: linear-gradient(90deg, var(--cyan) 0%, transparent 80%); }
.stat-card.glow-magenta { --stat-accent: linear-gradient(90deg, var(--magenta) 0%, transparent 80%); }
.stat-card.glow-green   { --stat-accent: linear-gradient(90deg, var(--green) 0%, transparent 80%); }
.stat-card.glow-red     { --stat-accent: linear-gradient(90deg, var(--red) 0%, transparent 80%); }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}
.btn:hover { border-color: var(--cyan); color: var(--cyan); }
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: linear-gradient(135deg, rgba(0,240,255,0.15), rgba(0,240,255,0.05));
  border-color: var(--cyan);
  color: var(--cyan);
}
.btn-primary:hover {
  background: linear-gradient(135deg, rgba(0,240,255,0.25), rgba(0,240,255,0.1));
  box-shadow: var(--glow-cyan);
}

.btn-danger {
  border-color: var(--red);
  color: var(--red);
}
.btn-danger:hover { background: rgba(255,51,102,0.1); box-shadow: var(--glow-red); }

.btn-sm { padding: 6px 12px; font-size: 0.75rem; }
.btn-block { width: 100%; }

.fab {
  position: fixed;
  bottom: calc(var(--bottom-nav-h) + 16px);
  right: 16px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cyan), #0080ff);
  border: none;
  color: var(--bg-primary);
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 240, 255, 0.30), 0 2px 6px rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  transition: var(--transition);
}
.fab:hover { transform: scale(1.05); filter: brightness(1.1); }
.fab:active { transform: scale(0.96); }

/* --- Forms --- */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-family: var(--font-sans);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  transition: var(--transition);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 0 2px rgba(0,240,255,0.15);
}
.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%238892a8' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
.form-textarea { resize: vertical; min-height: 80px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.form-check input[type="checkbox"] {
  appearance: none;
  width: 18px;
  height: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  cursor: pointer;
  position: relative;
}
.form-check input[type="checkbox"]:checked {
  background: var(--cyan);
  border-color: var(--cyan);
}
.form-check input[type="checkbox"]:checked::after {
  content: '✓';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  color: var(--bg-primary);
  font-size: 12px;
  font-weight: 700;
}

/* --- List Items --- */
.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  margin-bottom: 8px;
  transition: var(--transition);
}
.list-item:hover { background: var(--bg-card-hover); border-color: var(--border-strong); }
.list-item-left { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.list-item-name {
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-item-sub { font-family: var(--font-sans); font-size: 0.75rem; color: var(--text-secondary); }
.list-item-right { display: flex; align-items: center; gap: 12px; }
.list-item-amount { font-size: 1rem; font-weight: 700; white-space: nowrap; }
.list-item-actions { display: flex; gap: 8px; }

/* Bill rows: actions drop to their own full-width row on small screens so
   the name never fights the buttons for space */
.bill-row { flex-wrap: wrap; }
.bill-row .list-item-actions {
  flex-basis: 100%;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border-soft);
}
@media (min-width: 768px) {
  .bill-row { flex-wrap: nowrap; }
  .bill-row .list-item-actions {
    flex-basis: auto;
    margin: 0 0 0 12px;
    padding: 0;
    border: 0;
  }
}

/* Paid indicator */
.paid-badge {
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 700;
}
.paid-badge.paid { background: rgba(57,255,20,0.15); color: var(--green); }
.paid-badge.unpaid { background: rgba(255,51,102,0.15); color: var(--red); }

/* Variable amount badge */
.variable-badge {
  font-size: 0.6rem;
  padding: 2px 5px;
  border-radius: var(--radius-sm);
  background: rgba(255,140,66,0.15);
  color: #ff8c42;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  vertical-align: middle;
}

/* --- Tags / Chips --- */
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

/* --- Progress Bar --- */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-input);
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}
.progress-fill.cyan { background: var(--cyan); }
.progress-fill.magenta { background: var(--magenta); }
.progress-fill.green { background: var(--green); }
.progress-fill.red { background: var(--red); }
.progress-fill.yellow { background: var(--yellow); }

/* --- Modal --- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 12, 0.70);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 300;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.15s ease;
}
.modal {
  background: var(--surface-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%;
  max-width: 500px;
  max-height: 90dvh;
  overflow-y: auto;
  padding: 24px 20px;
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.5);
  animation: slideUp 0.25s ease;
}
/* Sheet grab handle on mobile */
.modal::before {
  content: '';
  display: block;
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: rgba(148, 163, 204, 0.25);
  margin: -8px auto 16px;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.modal-title {
  font-family: var(--font-sans);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* --- Toast --- */
.toast-container {
  position: fixed;
  top: calc(var(--header-h) + 8px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--surface-card);
  border: 1px solid rgba(0, 240, 255, 0.4);
  border-radius: var(--radius);
  padding: 10px 16px;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  color: var(--text-primary);
  box-shadow: var(--shadow-2);
  pointer-events: auto;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
}
.toast.error { border-color: rgba(255, 51, 102, 0.5); }
.toast { display: flex; align-items: center; gap: 12px; }
.toast.sticky { animation: toastIn 0.3s ease; }
.toast-action {
  background: none;
  border: 1px solid var(--cyan);
  border-radius: var(--radius-sm);
  color: var(--cyan);
  font-family: var(--font-sans);
  font-size: 0.75rem;
  padding: 4px 10px;
  cursor: pointer;
  white-space: nowrap;
}
.toast-action:hover { background: rgba(0,240,255,0.1); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-10px); } }

/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: 56px 20px;
  color: var(--text-muted);
}
.empty-state svg { margin-bottom: 16px; opacity: 0.25; }
.empty-state p {
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  line-height: 1.6;
  max-width: 280px;
  margin: 0 auto;
}

/* --- Section Title --- */
.section-title {
  font-family: var(--font-sans);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-secondary);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-soft);
}

/* --- Calendar Grid --- */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.calendar-header-cell {
  text-align: center;
  font-size: 0.65rem;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 8px 0;
}
.calendar-cell {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 4px 2px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  color: var(--text-secondary);
  position: relative;
  cursor: pointer;
  transition: var(--transition);
}
.calendar-cell:hover { background: var(--bg-card-hover); }
.calendar-cell.today { background: rgba(0,240,255,0.1); color: var(--cyan); font-weight: 700; }
.calendar-cell.other-month { opacity: 0.3; }
.calendar-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  margin-top: 2px;
}
.calendar-dots { display: flex; gap: 2px; margin-top: 2px; }

/* --- Charts --- */
.chart-container {
  width: 100%;
  overflow-x: auto;
}
.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 180px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-soft);
}
.bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 30px;
}
.bar {
  width: 100%;
  max-width: 32px;
  border-radius: 6px 6px 0 0;
  transition: height 0.4s ease;
}
.bar-label {
  font-family: var(--font-sans);
  font-size: 0.625rem;
  color: var(--text-muted);
  text-align: center;
}
.bar-value {
  font-size: 0.625rem;
  color: var(--text-secondary);
}

/* Donut chart */
.donut-container {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.donut-svg { width: 132px; height: 132px; }
.donut-legend { display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 120px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-family: var(--font-sans); font-size: 0.75rem; }
.legend-dot { width: 8px; height: 8px; border-radius: 3px; flex-shrink: 0; }
.legend-label { color: var(--text-secondary); flex: 1; }
.legend-value { color: var(--text-primary); font-weight: 600; }

/* --- Envelope Budget --- */
.envelope {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 8px;
}
.envelope-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}
.envelope-name { font-size: 0.85rem; font-weight: 600; }
.envelope-amounts { font-size: 0.75rem; color: var(--text-secondary); }

/* --- Receipt Scan --- */
.receipt-preview {
  width: 100%;
  max-height: 300px;
  object-fit: contain;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 16px;
}
.capture-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
}
.capture-area:hover { border-color: var(--cyan); background: rgba(0,240,255,0.03); }
.capture-options {
  display: flex;
  gap: 12px;
  padding: 16px;
}
.capture-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 24px 12px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  transition: var(--transition);
}
.capture-btn:hover, .capture-btn:active {
  border-color: var(--cyan);
  color: var(--cyan);
  background: rgba(0,240,255,0.04);
}

/* --- Filter Bar --- */
.filter-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 16px;
  scrollbar-width: none;
}
.filter-bar::-webkit-scrollbar { display: none; }
.filter-chip {
  padding: 6px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font-size: 0.75rem;
  font-family: var(--font-sans);
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
}
.filter-chip:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
}
.filter-chip.active {
  border-color: rgba(0, 240, 255, 0.5);
  color: var(--cyan);
  background: rgba(0, 240, 255, 0.12);
}

/* --- Settings --- */
.settings-group { margin-bottom: 24px; }
.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-soft);
}
.settings-item:last-child { border-bottom: none; }
.settings-item-label { font-size: 0.85rem; }
.settings-item-desc { font-size: 0.7rem; color: var(--text-muted); }

/* --- Month Picker (segmented pill) --- */
.month-picker {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: fit-content;
  margin: 0 auto 20px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-soft);
}
.month-picker .icon-btn { border-radius: 999px; }
.month-picker-label {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
  min-width: 150px;
  text-align: center;
}

/* --- Responsive --- */
@media (min-width: 768px) {
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .modal-backdrop { align-items: center; }
  .modal { border-radius: var(--radius-lg); }
  .modal::before { display: none; } /* grab handle is a bottom-sheet affordance */
  .form-row { grid-template-columns: 1fr 1fr 1fr; }
}

/* Desktop: persistent sidebar, no bottom tabs, two-column card flow */
@media (min-width: 1024px) {
  #menu-toggle { display: none; }
  #app-header .logo { display: none; } /* sidebar shows the logo instead */

  .sidebar {
    transform: none;
    top: 0;
    z-index: 120;
  }
  .sidebar-header #sidebar-close { display: none; }
  .sidebar-overlay { display: none; }

  #app-header { left: var(--sidebar-w); }

  .bottom-nav { display: none; }

  .main-content {
    --content-max: 1100px;
    margin-left: calc(var(--sidebar-w) + max(0px, (100vw - var(--sidebar-w) - var(--content-max)) / 2));
    margin-bottom: 0;
    max-width: var(--content-max);
    padding: 24px 32px 40px;
    min-height: calc(100dvh - var(--header-h));
  }

  .card-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }

  .fab {
    bottom: 32px;
    right: max(32px, calc((100vw - var(--sidebar-w) - var(--content-max)) / 2));
  }

  .month-picker-label { font-size: 1rem; }

  /* Search box is always visible on desktop; the overlay is mobile-only */
  #search-toggle { display: none; }
  .search-input { display: block; width: 220px; }
}

/* Respect reduced-motion preferences */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
