/* ── Dark Theme (default) ── */
:root {
  --bg:       #0d1117;
  --surface:  #161b22;
  --surface2: #1c2230;
  --border:   #273042;
  --accent:   #e8a838;
  --accent2:  #c48a20;
  --text:     #e0e6f0;
  --muted:    #5c6d86;
  --danger:   #e05c4b;
  --green:    #3fb97a;
  --radius:   12px;
  --contrast: #0d1117;
  --select-bg:#1c2230;
  --hover-accent: #f0b845;
  --hover-green:  #4fd490;
  --header-bg: rgba(13,17,23,0.94);
  --overlay-bg: rgba(0,0,0,0.6);
  --shadow: rgba(0,0,0,0.5);
  --info:        #4a9eff;
  --ui-blue:     #6b8cba;
  --ui-purple:   #a78bfa;
  --rec-auto:    #5b9be0;
  --white-force: #ffffff;
}

/* ── Light Theme ── */
[data-theme="light"] {
  --bg:       #f5f1eb;
  --surface:  #ffffff;
  --surface2: #ece7df;
  --border:   #d5cfc5;
  --accent:   #d49520;
  --accent2:  #b87d14;
  --text:     #1a1814;
  --muted:    #7d7567;
  --danger:   #c9402e;
  --green:    #2e9c62;
  --contrast: #ffffff;
  --select-bg:#f5f1eb;
  --hover-accent: #e8a838;
  --hover-green:  #3fb97a;
  --header-bg: rgba(245,241,235,0.94);
  --overlay-bg: rgba(0,0,0,0.35);
  --shadow: rgba(0,0,0,0.15);
  --info:       #2a7fd4;
  --ui-blue:    #5a7ba8;
  --ui-purple:  #8b6fe8;
  --rec-auto:   #4a8ed0;
  --white-force: #ffffff;
}

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

html { font-size: 17px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Header ── */
header {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 20px 36px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--header-bg);
  backdrop-filter: blur(14px);
  z-index: 100;
}

.logo {
  font-family: 'DM Serif Display', serif;
  font-size: 1.7rem;
  color: var(--accent);
  letter-spacing: -0.5px;
  flex-shrink: 0;
}
.logo span { color: var(--text); font-style: italic; }

.header-right {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-left: auto;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--muted);
}

.btn-signout {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 3px 8px;
  transition: color 0.15s, border-color 0.15s;
}
.btn-signout:hover { color: var(--danger); border-color: var(--danger); }

/* ── Budget tabs ── */
.budget-tabs { display: flex; gap: 6px; flex-wrap: wrap; }

.budget-tab {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.82rem;
  font-weight: 500;
  padding: 6px 16px;
  transition: all 0.15s;
  white-space: nowrap;
}
.budget-tab:hover { border-color: var(--accent2); color: var(--text); }
.budget-tab.active { background: var(--accent); border-color: var(--accent); color: var(--contrast); }

/* ── App screen wrapper — flex column so footer sits at bottom ── */
#app-screen {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Layout ── */
.container {
  display: grid;
  grid-template-columns: 420px 1fr;
  flex: 1; /* grow to fill space above footer */
}

/* ── LEFT SIDEBAR: form + transactions ── */
.sidebar {
  border-right: 1px solid var(--border);
  padding: 28px 24px;
  position: sticky;
  top: 69px;
  height: calc(100vh - 69px);
  overflow-y: auto;
}

.sidebar h2 {
  font-family: 'DM Serif Display', serif;
  font-size: 1.25rem;
  margin-bottom: 20px;
  transition: color 0.3s;
}

/* ── Form elements ── */
label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

input, select {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.92rem;
  padding: 10px 13px;
  outline: none;
  transition: border-color 0.2s;
  margin-bottom: 14px;
}
input:focus, select:focus { border-color: var(--accent); }
input::placeholder { color: var(--muted); }
select option, select optgroup { background: var(--select-bg); }

/* Date picker calendar icon — match category select arrow colour */
input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.7) sepia(0.5) saturate(3) hue-rotate(10deg);
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s;
}
input[type="date"]::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
}
[data-theme="light"] input[type="date"]::-webkit-calendar-picker-indicator {
  filter: none;
  opacity: 0.6;
}
[data-theme="light"] input[type="date"]::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
}

.amount-wrap { position: relative; }
.amount-wrap span {
  position: absolute; left: 13px; top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  pointer-events: none; margin-top: -7px;
}
.amount-wrap input { padding-left: 26px; }

/* ── Add button ── */
.btn-add {
  width: 100%; border: none;
  border-radius: var(--radius);
  font-family: 'DM Sans', sans-serif;
  font-weight: 500; font-size: 0.95rem;
  padding: 12px; cursor: pointer;
  transition: background 0.25s, transform 0.1s;
  margin-top: 2px;
}
.btn-add.expense-mode { background: var(--accent); color: var(--contrast); }
.btn-add.expense-mode:hover { background: var(--hover-accent); }
.btn-add.income-mode  { background: var(--green);  color: var(--contrast); }
.btn-add.income-mode:hover  { background: var(--hover-green); }
.btn-add:active { transform: scale(0.98); }
.btn-add:disabled { opacity: 0.6; cursor: not-allowed; }

hr.divider { border: none; border-top: 1px solid var(--border); }

/* ── Section header (Transactions) ── */
.section-header {
  display: flex; align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.section-title {
  font-family: 'DM Serif Display', serif;
  font-size: 1rem;
  color: var(--text);
}

/* ── Tabs ── */
.tabs { display: flex; gap: 4px; }
.tab {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 5px 10px;
  transition: all 0.15s;
}
.tab:hover { border-color: var(--accent2); color: var(--text); }
.tab.active { background: var(--surface2); border-color: var(--accent); color: var(--accent); }

/* ── Transaction list ── */
.expense-group { margin-bottom: 20px; }
.group-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 0; margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.group-label { font-size: 0.75rem; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; }
.group-total { font-family: 'DM Mono', monospace; font-size: 0.82rem; font-weight: 500; flex-shrink: 0; white-space: nowrap; }

.expense-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 10px;
  transition: background 0.15s;
  animation: slideIn 0.2s ease;
}
.expense-item:hover { background: var(--surface2); }

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.cat-icon {
  width: 34px; height: 34px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; flex-shrink: 0;
  position: relative;
}
.expense-info { flex: 1; min-width: 0; }
.expense-name {
  font-weight: 500; font-size: 0.88rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.expense-meta {
  font-size: 0.72rem; color: var(--muted);
  margin-top: 2px; font-family: 'DM Mono', monospace;
}
.entry-who { color: var(--accent2); font-weight: 500; }
.expense-amount {
  font-family: 'DM Mono', monospace;
  font-size: 0.9rem; font-weight: 500; flex-shrink: 0;
}
.btn-delete {
  background: none; border: none;
  color: var(--muted); cursor: pointer;
  font-size: 0.75rem; padding: 4px 6px;
  border-radius: 6px; flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}
.btn-delete:hover { color: var(--danger); background: rgba(224,92,75,0.1); }
.btn-delete-placeholder { width: 28px; flex-shrink: 0; }

/* ── Entry list density ── */
/* comfortable = default, no overrides needed */

#expense-list.density-compact .expense-item,
#drilldown-list.density-compact .expense-item {
  padding: 5px 8px;
  gap: 8px;
}
#expense-list.density-compact .cat-icon,
#drilldown-list.density-compact .cat-icon {
  width: 28px; height: 28px;
  font-size: 0.85rem;
  border-radius: 7px;
}
#expense-list.density-compact .expense-name,
#drilldown-list.density-compact .expense-name {
  font-size: 0.84rem;
}
#expense-list.density-compact .expense-meta,
#drilldown-list.density-compact .expense-meta {
  font-size: 0.68rem;
  margin-top: 1px;
}
#expense-list.density-compact .expense-amount,
#drilldown-list.density-compact .expense-amount {
  font-size: 0.84rem;
}
#expense-list.density-compact .expense-group,
#drilldown-list.density-compact .expense-group {
  margin-bottom: 12px;
}
#expense-list.density-compact .group-body,
#drilldown-list.density-compact .group-body {
  margin-bottom: 4px;
}

#expense-list.density-ultra-compact .expense-item,
#drilldown-list.density-ultra-compact .expense-item {
  padding: 3px 8px;
  gap: 7px;
  min-height: 44px; /* maintain tappable height on mobile */
}
#expense-list.density-ultra-compact .cat-icon,
#drilldown-list.density-ultra-compact .cat-icon {
  width: 24px; height: 24px;
  font-size: 0.75rem;
  border-radius: 6px;
}
#expense-list.density-ultra-compact .expense-name,
#drilldown-list.density-ultra-compact .expense-name {
  font-size: 0.82rem;
}
#expense-list.density-ultra-compact .expense-meta,
#drilldown-list.density-ultra-compact .expense-meta {
  display: none; /* hide category · type · who line */
}
#expense-list.density-ultra-compact .expense-amount,
#drilldown-list.density-ultra-compact .expense-amount {
  font-size: 0.82rem;
}
#expense-list.density-ultra-compact .expense-group,
#drilldown-list.density-ultra-compact .expense-group {
  margin-bottom: 6px;
}
#expense-list.density-ultra-compact .group-body,
#drilldown-list.density-ultra-compact .group-body {
  margin-bottom: 2px;
}

/* ── Density toggle buttons ── */
.density-toggle {
  display: flex; gap: 6px;
}
.density-btn {
  flex: 1;
  padding: 7px 4px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.density-btn .density-icon {
  display: flex; flex-direction: column; gap: 2px; width: 22px;
}
.density-btn .density-icon span {
  display: block; background: currentColor;
  border-radius: 2px; width: 100%; opacity: 0.5;
}
.density-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent)18;
}
.density-btn:hover:not(.active) {
  border-color: var(--muted);
  color: var(--text);
}

/* ── Empty state ── */
.empty-state {
  text-align: center; padding: 28px 16px;
  color: var(--muted); line-height: 1.7; font-size: 0.88rem;
}
.empty-state .emoji { font-size: 2rem; margin-bottom: 10px; }

/* ── MAIN PANEL: cards + category breakdown ── */
.main { padding: 28px 36px; overflow-y: auto; }

/* ── KPI chips ── */
.kpi-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
  margin-bottom: 20px;
}

.kpi-chip {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  cursor: default;
  position: relative;
  transition: border-color 0.2s;
  min-width: 0;
}
.kpi-chip.kpi-income  { border-top: 2px solid var(--green); }
.kpi-chip.kpi-expense { border-top: 2px solid var(--danger); }
.kpi-chip.kpi-net     { border-top: 2px solid var(--accent); }

.kpi-front { display: flex; flex-direction: column; gap: 3px; }

.kpi-type {
  font-family: 'DM Mono', monospace;
  font-size: 0.6rem; font-weight: 500;
  letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--muted);
  display: flex; align-items: center; gap: 5px;
}
.kpi-dot {
  width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0;
}
.kpi-income .kpi-dot  { background: var(--green); }
.kpi-expense .kpi-dot { background: var(--danger); }
.kpi-net .kpi-dot     { background: var(--accent); }

.kpi-amount {
  font-family: 'DM Serif Display', serif;
  font-size: 1.3rem; line-height: 1.1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.kpi-meta {
  font-family: 'DM Mono', monospace;
  font-size: 0.62rem; color: var(--muted);
  display: flex; align-items: center; gap: 6px;
}
.kpi-period-tag {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px; padding: 1px 5px;
  font-size: 0.58rem; color: var(--muted);
  white-space: nowrap;
}

/* Flip panel — positioned fixed via JS to escape overflow:auto stacking context */
.kpi-flip {
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  box-shadow: 0 12px 32px var(--shadow);
  z-index: 9000;
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
  min-width: 260px;
}
.kpi-flip-caret {
  position: absolute;
  top: -7px;
  width: 0; height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-bottom: 7px solid var(--border);
  transform: translateX(-50%);
  pointer-events: none;
}
.kpi-flip-caret::after {
  content: '';
  position: absolute;
  top: 2px;
  left: -6px;
  width: 0; height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 6px solid var(--surface);
}

.kpi-flip-title {
  font-family: 'DM Mono', monospace;
  font-size: 0.6rem; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em;
  margin-bottom: 10px;
}
.kpi-flip-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.kpi-flip-cell { display: flex; flex-direction: column; gap: 2px; }
.kpi-flip-label {
  font-family: 'DM Mono', monospace;
  font-size: 0.58rem; color: var(--muted);
}
.kpi-flip-val {
  font-family: 'DM Serif Display', serif;
  font-size: 0.92rem; white-space: nowrap;
}
.kpi-flip-sub {
  font-family: 'DM Mono', monospace;
  font-size: 0.58rem; color: var(--muted);
}

.pos { color: var(--green); }
.neg { color: var(--danger); }
.neu { color: var(--text); }

/* ── Collapsible card sections (kept for export.js compat) ── */
.cards-section-header {
  display: flex; align-items: center;
  justify-content: space-between;
  cursor: pointer; padding: 6px 2px;
  border-radius: 6px; margin-bottom: 0;
  user-select: none; transition: opacity 0.15s;
}
.cards-section-header:hover { opacity: 0.75; }
.collapse-chevron {
  font-size: 1.1rem; color: var(--muted);
  transform: rotate(90deg);
  transition: transform 0.25s ease; line-height: 1;
}
.collapse-chevron.expanded { transform: rotate(270deg); }
.summary-grid-wrap {
  overflow: hidden; max-height: 200px;
  transition: max-height 0.35s ease, opacity 0.3s ease, margin 0.3s ease;
  opacity: 1; margin-bottom: 4px;
}
.summary-grid-wrap.collapsed { max-height: 0; opacity: 0; margin-bottom: 0; }
.cards-section-label {
  font-size: 0.7rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 0;
}
.summary-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 12px; margin-bottom: 8px;
}
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; transition: border-color 0.2s;
}
.card:hover { border-color: var(--accent2); }
.card-income  { border-left: 3px solid var(--green); }
.card-expense { border-left: 3px solid var(--danger); }
.card-net     { border-left: 3px solid var(--accent); }
.card-label   { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 8px; font-weight: 600; }
.card-amount  { font-family: 'DM Serif Display', serif; font-size: 1.5rem; line-height: 1.1; margin-bottom: 4px; }
.card-sub     { font-size: 0.7rem; color: var(--muted); font-family: 'DM Mono', monospace; }

/* ── Net income hint ── */

/* ── Category breakdown (now in main panel) ── */
.cat-breakdown { margin-top: 4px; }

.cat-section-label {
  font-size: 0.7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em;
  margin: 14px 0 10px;
}

.cat-bar-item {
  display: grid;
  grid-template-columns: 130px 1fr auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
  padding: 5px 8px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s, opacity 0.2s;
}
.cat-bar-item:hover { background: rgba(255,255,255,0.04); }
.cat-bar-item.cat-row-dim { opacity: 0.32; }
.cat-bar-item.cat-row-dim:hover { opacity: 1; }
.cat-name { font-size: 0.82rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 6px; }
.cat-bar-col { display: flex; flex-direction: column; gap: 2px; }
.cat-bar-wrap { position: relative; background: rgba(255,255,255,0.07); border-radius: 999px; height: 12px; overflow: hidden; }
.cat-bar { height: 100%; border-radius: 999px; min-width: 4px; transition: box-shadow 0.2s; }
.cat-bar-item:hover .cat-bar { filter: brightness(1.15); }
.cat-bar-above-pct {
  font-size: 0.72rem;
  font-weight: 600;
  font-family: 'DM Mono', monospace;
  color: var(--muted);
  line-height: 1;
  pointer-events: none;
}
.cat-amt { font-family: 'DM Mono', monospace; font-size: 0.78rem; font-weight: 500; text-align: right; white-space: nowrap; min-width: 90px; }
.cat-pct-aside { color: var(--muted); font-weight: 400; font-size: 0.7rem; margin-left: 4px; }

/* ── Dim divider ── */
.cat-dim-divider {
  font-size: 0.68rem;
  color: var(--muted);
  font-style: italic;
  padding: 6px 10px 4px;
  border-top: 1px dashed var(--border);
  margin: 4px 0 2px;
}

/* ── Dim threshold settings controls ── */
.cat-dim-controls {
  overflow: hidden;
  max-height: 120px;
  opacity: 1;
  transition: max-height 0.35s ease, opacity 0.3s ease, margin-top 0.35s ease;
  margin-top: 0;
}
.cat-dim-controls.hidden {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
}
.cat-dim-threshold-row {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  max-height: 40px;
  opacity: 1;
  margin-top: 10px;
  transition: max-height 0.35s ease, opacity 0.3s ease, margin-top 0.35s ease;
}
.cat-dim-threshold-row.hidden {
  max-height: 0;
  opacity: 0;
  margin-top: 0;
  pointer-events: none;
}
.cat-dim-slider {
  flex: 1;
  min-width: 0;
  accent-color: var(--accent);
  cursor: pointer;
  height: 4px;
}
.cat-dim-unit {
  font-size: 0.82rem;
  color: var(--muted);
  white-space: nowrap;
}

/* ── Category spending limit bar ── */
.cat-limit-bar-wrap {
  grid-column: 1 / -1;
  margin-top: -2px;
  margin-bottom: 6px;
  padding: 4px 0;
}
.cat-limit-bar-track {
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.cat-limit-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease;
}
.cat-limit-label {
  font-size: 0.72rem;
  font-family: 'DM Mono', monospace;
  color: var(--text);
  margin-top: 3px;
}
.cat-limit-over {
  color: var(--danger);
  font-weight: 600;
}
.cat-limit-remaining {
  color: var(--green);
  font-weight: 500;
}
.cat-limit-of {
  color: var(--muted);
}

/* ── Category edit form — limit field ── */
.cat-limit-section {
  margin-top: 12px;
}
.cat-limit-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.cat-limit-currency {
  font-family: 'DM Mono', monospace;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--muted);
}
.cat-limit-hint {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 4px;
}

/* ── Auth screen ── */
#auth-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); z-index: 9999;
}
.auth-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; padding: 44px 36px;
  text-align: center; max-width: 400px; width: 92%;
}
.auth-logo { font-family: 'DM Serif Display', serif; font-size: 2.2rem; color: var(--accent); margin-bottom: 8px; }
.auth-logo span { color: var(--text); font-style: italic; }
.auth-tagline { color: var(--muted); font-size: 0.92rem; margin-bottom: 28px; }

/* ── Auth checking state ── */
.auth-checking {
  padding: 4px 0 8px;
}
.auth-checking-label {
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 14px;
  font-family: 'DM Mono', monospace;
  letter-spacing: 0.03em;
}

/* Progress track — full width pill */
.auth-progress-track {
  width: 100%;
  height: 3px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

/* Animated bar — sweeps left to right repeatedly using a gradient shimmer */
.auth-progress-bar {
  height: 100%;
  width: 45%;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    var(--accent) 0%,
    var(--hover-accent) 40%,
    var(--accent) 100%
  );
  background-size: 200% 100%;
  animation: auth-sweep 1.4s ease-in-out infinite;
}

@keyframes auth-sweep {
  0%   { transform: translateX(-120%); }
  100% { transform: translateX(340%);  }
}

/* Sign-in state — fades in smoothly after check completes */
.auth-signin {
  animation: auth-fadein 0.3s ease both;
}

@keyframes auth-fadein {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0);   }
}

.btn-google {
  display: flex; align-items: center; justify-content: center;
  gap: 12px; width: 100%; background: var(--white-force); color: var(--contrast);
  border: none; border-radius: var(--radius);
  font-family: 'DM Sans', sans-serif; font-size: 0.92rem; font-weight: 500;
  padding: 12px 20px; cursor: pointer;
  transition: background 0.2s, transform 0.1s; margin-bottom: 18px;
}
.btn-google:hover { background: var(--surface2); }
.btn-google:active { transform: scale(0.98); }
.btn-google:disabled { opacity: 0.7; cursor: not-allowed; }
.auth-note { font-size: 0.76rem; color: var(--muted); line-height: 1.6; }

/* Auth tabs */
.auth-tabs {
  display: flex; gap: 0; margin-bottom: 20px;
  background: var(--surface2); border-radius: var(--radius); padding: 3px;
}
.auth-tab {
  flex: 1; padding: 9px 0; border: none; background: transparent;
  color: var(--muted); font-family: 'DM Sans', sans-serif;
  font-size: 0.88rem; font-weight: 500; cursor: pointer;
  border-radius: calc(var(--radius) - 2px); transition: background 0.2s, color 0.2s;
}
.auth-tab.active {
  background: var(--surface); color: var(--text);
  box-shadow: 0 1px 3px var(--shadow);
}
.auth-tab:hover:not(.active) { color: var(--text); }

/* Auth form */
.auth-form { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.auth-input {
  width: 100%; padding: 11px 14px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--bg); color: var(--text);
  font-family: 'DM Sans', sans-serif; font-size: 0.9rem;
  box-sizing: border-box; transition: border-color 0.15s;
}
.auth-input:focus { outline: none; border-color: var(--accent); }
.auth-input::placeholder { color: var(--muted); }
.auth-password-wrap { position: relative; }
.auth-password-wrap .auth-input { padding-right: 44px; }
.auth-pw-toggle {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 1rem; padding: 4px; line-height: 1;
}
.auth-pw-toggle:hover { color: var(--text); }
.auth-confirm-wrap {
  overflow: hidden; transition: max-height 0.25s ease, opacity 0.25s ease;
  max-height: 0; opacity: 0;
}
.auth-confirm-wrap.visible { max-height: 60px; opacity: 1; }
.auth-submit-btn {
  width: 100%; padding: 12px; border: none; border-radius: var(--radius);
  background: var(--accent); color: var(--contrast);
  font-family: 'DM Sans', sans-serif; font-size: 0.92rem; font-weight: 600;
  cursor: pointer; transition: opacity 0.15s; margin-top: 4px;
}
.auth-submit-btn:hover { opacity: 0.85; }
.auth-submit-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.auth-forgot-btn {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 0.78rem; font-family: 'DM Sans', sans-serif;
  padding: 2px 0; text-align: center;
}
.auth-forgot-btn:hover { color: var(--accent); }
.auth-message {
  font-size: 0.82rem; font-family: 'DM Mono', monospace;
  padding: 10px 14px; border-radius: var(--radius);
  margin-bottom: 12px; text-align: center; line-height: 1.5;
}
.auth-message.success { background: rgba(46,156,98,0.12); color: var(--green); border: 1px solid rgba(46,156,98,0.25); }
.auth-message.error { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 25%, transparent); }
.auth-message.info { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent); }
.auth-divider {
  display: flex; align-items: center; gap: 12px;
  margin: 4px 0 16px; color: var(--muted); font-size: 0.78rem;
}
.auth-divider::before, .auth-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

/* ── Toast notifications ── */
.toast {
  position: fixed; bottom: 28px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 999px; padding: 10px 22px;
  font-size: 0.84rem; font-family: 'DM Mono', monospace;
  color: var(--text); opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 99999; pointer-events: none; white-space: nowrap;
}
.toast-visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast-success { border-color: var(--green);  color: var(--green); }
.toast-error   { border-color: var(--danger); color: var(--danger); }
.toast-info    { border-color: var(--accent); color: var(--accent); }

/* ── Live sync indicator ── */
.sync-indicator {
  font-family: 'DM Mono', monospace; font-size: 0.72rem;
  font-weight: 500; color: var(--muted);
  letter-spacing: 0.03em; white-space: nowrap;
  transition: color 0.3s;
}

/* ── Budget loading state ── */
.budget-loading {
  font-size: 0.82rem; color: var(--muted);
  font-family: 'DM Mono', monospace; padding: 6px 4px;
  animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ── Responsive ── */
@media (max-width: 960px) {
  html { font-size: 16px; }
  .container { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: none; border-bottom: 1px solid var(--border); }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  header { padding: 14px 20px; }
  .main { padding: 24px 20px; }
  .kpi-amount { font-size: 1.05rem; }
  .kpi-chip { padding: 10px 12px; cursor: pointer; }
  .kpi-flip-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kpi-meta { flex-direction: column; align-items: flex-start; gap: 3px; }
  .kpi-period-tag { font-size: 0.6rem; }
}

/* ── Breakdown filter bar ── */
.breakdown-filters {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 4px;
  position: relative;
}

/* Export button in breakdown tabs */
.bd-export-btn {
  margin-left: 4px;
  border-color: var(--accent) !important;
  color: var(--accent) !important;
}
.bd-export-btn:hover {
  background: var(--accent) !important;
  color: var(--contrast) !important;
}

/* Export dropdown menu */
.bd-export-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
  z-index: 50;
  box-shadow: 0 8px 24px var(--shadow);
  min-width: 160px;
}
.bd-export-menu.open { display: flex; flex-direction: column; gap: 2px; }
.bd-export-menu button {
  background: none;
  border: none;
  border-radius: 6px;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.82rem;
  padding: 8px 12px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}
.bd-export-menu button:hover {
  background: var(--surface2);
}

.breakdown-range {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.breakdown-range input {
  width: auto;
  flex: 1;
  min-width: 130px;
  padding: 7px 11px;
  font-size: 0.82rem;
  margin-bottom: 0;
}

/* ── Monthly breakdown sections ── */
.monthly-section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  overflow: hidden;
}

.monthly-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 16px;
  cursor: pointer;
  background: var(--surface);
  transition: background 0.15s;
  user-select: none;
}
.monthly-header:hover { background: var(--surface2); }

.monthly-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.monthly-net {
  font-family: 'DM Mono', monospace;
  font-size: 0.82rem;
  font-weight: 500;
  margin-left: auto;
  margin-right: 12px;
}

.monthly-chevron {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
}

.monthly-body {
  padding: 14px 16px;
  background: var(--bg);
}

/* ── Period navigation ── */
.period-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 4px;
  margin-bottom: 8px;
}

.period-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  font-family: 'DM Mono', monospace;
  text-align: center;
  flex: 1;
}

.period-arrow {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  font-size: 1rem;
  padding: 4px 10px;
  transition: all 0.15s;
  line-height: 1.4;
}
.period-arrow:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.period-arrow:disabled,
.period-arrow-dim { opacity: 0.3; cursor: default; }

/* ── Collapsible date groups ── */
.group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 6px;
  margin-bottom: 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  border-radius: 6px 6px 0 0;
  transition: background 0.15s;
  user-select: none;
}
.group-header:hover { background: var(--surface2); }

.group-header-left {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
}
.group-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-chevron {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  width: 14px;
  text-align: center;
}

.group-body {
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

/* ── Month overview (header) ── */
.month-overview {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 16px;
  white-space: nowrap;
  font-size: 0.82rem;
}

.overview-label {
  color: var(--muted);
  font-weight: 500;
}

.overview-divider {
  color: var(--border);
  font-size: 0.9rem;
}

.overview-item {
  color: var(--muted);
}

.overview-item strong {
  font-family: 'DM Mono', monospace;
  font-size: 0.85rem;
}

/* ── Compare view ── */
.cmp-summary {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-top: 12px;
  margin-bottom: 12px;
}

.cmp-summary-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cmp-summary-month {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

.cmp-summary-row {
  display: flex;
  gap: 12px;
  font-family: 'DM Mono', monospace;
  font-size: 0.88rem;
  font-weight: 500;
}

.cmp-summary-net {
  font-family: 'DM Serif Display', serif;
  font-size: 1.1rem;
  margin-top: 4px;
}

.cmp-summary-vs {
  font-family: 'DM Serif Display', serif;
  font-size: 1.3rem;
  color: var(--muted);
  font-style: italic;
  flex-shrink: 0;
}

.cmp-deltas {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
}

.cmp-delta-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.84rem;
}

.cmp-delta-label {
  color: var(--muted);
  font-weight: 600;
  width: 70px;
  flex-shrink: 0;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.cmp-delta {
  font-family: 'DM Mono', monospace;
  font-size: 0.84rem;
  font-weight: 500;
}

/* Per-category compare rows */
.cmp-cat-row {
  display: grid;
  grid-template-columns: 130px 1fr 80px;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.cmp-cat-name {
  font-size: 0.8rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 6px;
}

.cmp-bars {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cmp-bar-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cmp-bar-wrap {
  flex: 1;
  background: var(--surface2);
  border-radius: 999px;
  height: 7px;
  overflow: hidden;
}

.cmp-bar {
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease;
  min-width: 3px;
}

.cmp-bar-amt {
  font-family: 'DM Mono', monospace;
  font-size: 0.72rem;
  width: 60px;
  text-align: right;
  flex-shrink: 0;
}

.cmp-delta-cell {
  font-family: 'DM Mono', monospace;
  font-size: 0.75rem;
  font-weight: 600;
  text-align: right;
}

/* ── Search trigger button (desktop, beside view tabs) ── */
.search-trigger-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  flex-shrink: 0;
}
.search-trigger-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--surface);
}
.search-trigger-btn svg {
  transition: transform 0.3s ease;
}
.search-trigger-btn:hover svg {
  animation: searchPeek 0.45s ease;
}
@keyframes searchPeek {
  0%   { transform: scale(1) rotate(0deg); }
  40%  { transform: scale(1.18) rotate(-8deg); }
  100% { transform: scale(1) rotate(0deg); }
}

/* ── Search modal ── */
.search-modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-bg);
  backdrop-filter: blur(4px);
  z-index: 650;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 60px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.search-modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}
.search-modal-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  width: min(620px, 94vw);
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(-10px);
  transition: transform 0.2s ease;
  box-shadow: 0 24px 64px var(--shadow);
}
.search-modal-overlay.active .search-modal-panel {
  transform: translateY(0);
}
.search-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.search-modal-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'DM Serif Display', serif;
  font-size: 1.1rem;
  font-weight: 400;
  color: var(--text);
}
.search-modal-title svg {
  color: var(--accent);
  flex-shrink: 0;
}
.search-modal-input-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.search-input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  padding: 0 14px;
  height: 38px;
  transition: border-color 0.15s;
  min-width: 0;
  box-sizing: border-box;
}
.search-input:focus {
  outline: none;
  border-color: var(--accent);
}
.search-btn {
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: var(--contrast);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0 18px;
  height: 38px;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s;
  flex-shrink: 0;
}
.search-btn:disabled { opacity: 0.55; cursor: default; }
.search-btn:not(:disabled):hover { opacity: 0.85; }

/* ── Search expand/collapse controls ── */
.search-controls-row {
  display: none;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  padding: 6px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.search-controls-row.visible { display: flex; }
.search-control-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.75rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}
.search-control-btn:hover { color: var(--accent); background: var(--surface2); }
.search-control-divider { color: var(--border); font-size: 0.75rem; user-select: none; }

/* Status messages */
.search-status {
  padding: 14px 20px;
  font-size: 0.85rem;
  text-align: center;
  flex-shrink: 0;
}
.search-status--info  { color: var(--muted); }
.search-status--empty { color: var(--muted); font-style: italic; }
.search-status--error { color: var(--danger); }

/* Results area */
.search-results {
  overflow-y: auto;
  flex: 1;
  padding: 10px 14px 4px;
}
.search-result-group {
  margin-bottom: 8px;
}

/* Highlighted match portion */
mark.search-highlight {
  background: none;
  color: var(--accent);
  font-weight: 700;
}

/* Load more */
.search-load-more-wrap {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: center;
  flex-shrink: 0;
}
.search-load-more-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  padding: 8px 24px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.search-load-more-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Mobile — full height sheet from bottom */
@media (max-width: 768px) {
  .search-modal-overlay {
    align-items: flex-end;
    padding-top: 0;
  }
  .search-modal-panel {
    width: 100%;
    border-radius: 18px 18px 0 0;
    max-height: var(--sheet-max-h, 92vh);
    transform: translateY(20px);
  }
  .search-modal-overlay.active .search-modal-panel {
    transform: translateY(0);
  }
}

/* ── Entry detail modal ── */
.entry-modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-bg);
  backdrop-filter: blur(4px);
  z-index: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.entry-modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}
.entry-modal-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  width: min(480px, 94vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(16px) scale(0.98);
  transition: transform 0.2s ease;
  box-shadow: 0 24px 64px var(--shadow);
}
.entry-modal-overlay.active .entry-modal-panel {
  transform: translateY(0) scale(1);
}

/* Header — icon, description, amount, close */
.entry-modal-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}
.entry-modal-cat-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
  margin-top: 2px;
}
.entry-modal-header-info {
  flex: 1;
  min-width: 0;
}
.entry-modal-title {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.97rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.35;
  /* Full description is always shown in the Description row below */
}
.entry-modal-subtitle {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 2px;
}
.entry-modal-amount {
  font-family: 'DM Mono', monospace;
  font-size: 1.15rem;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 2px;
}
.entry-modal-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 2px 4px;
  flex-shrink: 0;
  line-height: 1;
  transition: color 0.15s;
}
.entry-modal-close:hover { color: var(--text); }

/* Body — field rows */
.entry-modal-body {
  padding: 8px 0;
  overflow-y: auto;
}
.entry-modal-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 9px 20px;
  border-bottom: 1px solid var(--border);
}
.entry-modal-row:last-child { border-bottom: none; }

/* Description row — stacks vertically so long text has full width */
.entry-modal-row--desc {
  flex-direction: column;
  gap: 6px;
}
.entry-modal-field-label {
  font-size: 0.74rem;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  white-space: nowrap;
  flex-shrink: 0;
  width: 82px;
}
.entry-modal-row--desc .entry-modal-field-label {
  width: auto;
}
.entry-modal-field-value {
  font-size: 0.88rem;
  color: var(--text);
  word-break: break-word;
}
.entry-modal-field-value--desc {
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--text);
  white-space: pre-wrap; /* preserve line breaks if any */
  word-break: break-word;
}

/* Footer — delete button */
.entry-modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
}
.entry-modal-delete-btn {
  background: none;
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: var(--radius);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.84rem;
  padding: 7px 16px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.entry-modal-delete-btn:hover {
  background: var(--danger);
  color: var(--white-force);
}

/* Mobile — full-width panel from bottom */
@media (max-width: 768px) {
  .entry-modal-overlay {
    align-items: flex-end;
  }
  .entry-modal-panel {
    width: 100%;
    border-radius: 18px 18px 0 0;
    max-height: var(--sheet-max-h, 88vh);
    transform: translateY(30px);
  }
  .entry-modal-overlay.active .entry-modal-panel {
    transform: translateY(0);
  }
}

/* ── Drilldown loading spinner ── */
@keyframes dd-spin {
  to { transform: rotate(360deg); }
}
.dd-loading-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: dd-spin 0.6s linear infinite;
  flex-shrink: 0;
}
/* Dim the cat bar item while loading */
.cat-drilldown.dd-fetching {
  opacity: 0.5;
  pointer-events: none;
}
.cat-drilldown.dd-fetching .cat-bar-fill {
  animation: pulse 1s ease-in-out infinite;
}

/* ── Category drill-down modal ── */
.drilldown-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-bg);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 6vh;
  padding-bottom: 4vh;
  overflow-y: auto;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.drilldown-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.drilldown-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  width: min(900px, 94vw);
  max-height: calc(90vh - 6vh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(20px);
  transition: transform 0.25s ease;
  box-shadow: 0 24px 64px var(--shadow);
  flex-shrink: 0;
}

.drilldown-overlay.active .drilldown-panel {
  transform: translateY(0);
}

.drilldown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 16px;
}

.drilldown-header-left {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.drilldown-header-right {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.drilldown-title {
  font-family: 'DM Serif Display', serif;
  font-size: 1.4rem;
  color: var(--text);
}

.drilldown-period {
  font-size: 0.75rem;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.drilldown-total {
  font-family: 'DM Mono', monospace;
  font-size: 0.9rem;
  font-weight: 600;
}

.drilldown-close {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 6px 10px;
  transition: color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.drilldown-close:hover { color: var(--danger); border-color: var(--danger); }

.drilldown-view-tabs {
  display: flex;
  justify-content: center;
  gap: 0;
  padding: 12px 24px;
  background: var(--surface);
}
.drilldown-view-tab {
  padding: 6px 20px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.drilldown-view-tab:first-child {
  border-radius: 8px 0 0 8px;
  border-right: none;
}
.drilldown-view-tab:last-child {
  border-radius: 0 8px 8px 0;
}
.drilldown-view-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--contrast);
  font-weight: 600;
}
.drilldown-view-tab:hover:not(.active) {
  background: var(--border);
  color: var(--text);
}

/* Member view — avatar + date column */
.dd-member-header-info {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.dd-member-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--contrast);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-weight: 700;
  font-family: 'DM Mono', monospace;
  flex-shrink: 0;
}
.dd-member-count {
  font-size: 0.72rem;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  white-space: nowrap;
  flex-shrink: 0;
}
.dd-member-date {
  width: 52px;
  flex-shrink: 0;
  font-size: 0.75rem;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  text-align: center;
}

.drilldown-body {
  overflow-y: auto;
  padding: 16px 24px 24px;
  flex: 1;
  min-height: 0;
}

/* ── Category drilldown sparkline ─────────────────────────────────────────── */
.dd-sparkline-section {
  padding: 12px 24px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface);
}
/* ── Settings switch toggle ──────────────────────────────────────────────── */
.settings-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.settings-toggle-label {
  font-size: 0.82rem;
  color: var(--text);
}
.settings-switch {
  position: relative;
  width: 40px;
  height: 22px;
  background: var(--surface2);
  border-radius: 11px;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
  border: 1px solid var(--border);
}
.settings-switch.on {
  background: var(--accent);
  border-color: var(--accent);
}
.settings-switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.2s, background 0.2s;
}
.settings-switch.on .settings-switch-thumb {
  transform: translateX(18px);
  background: var(--white-force);
}

.dd-spark-period-toggle {
  display: flex;
  gap: 2px;
  background: var(--surface2);
  border-radius: 6px;
  padding: 2px;
}
.dd-spark-period-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  letter-spacing: 0.04em;
}
.dd-spark-period-btn.active {
  background: var(--surface3, var(--border));
  color: var(--text);
}
.dd-spark-period-btn:hover:not(.active) {
  color: var(--text);
}
.dd-sparkline-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 9px;
}
.dd-sparkline-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
}
.dd-sparkline-legend {
  display: flex;
  align-items: center;
  gap: 12px;
}
.dd-sparkline-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.65rem;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
}
.dd-spark-legend-bar {
  width: 14px;
  height: 8px;
  border-radius: 3px;
  opacity: 0.85;
}
.dd-spark-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  opacity: 0.9;
  flex-shrink: 0;
}
.dd-spark-legend-dash {
  width: 16px;
  height: 0;
  border-top: 2px dashed var(--accent);
  opacity: 0.4;
}
.dd-sparkline-wrap {
  position: relative;
  height: 96px;
  width: 100%;
}
.dd-sparkline-wrap canvas {
  display: block; /* prevents inline gap on mobile */
  width: 100% !important;
  height: 100% !important;
}
.dd-sparkline-months {
  display: flex;
  justify-content: space-between;
  margin-top: 5px;
}
.dd-spark-mlabel {
  font-size: 0.6rem;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  flex: 1;
  text-align: center;
}
.dd-spark-mlabel.now {
  color: var(--accent);
  font-weight: 500;
}


.drilldown-load-more {
  display: flex;
  justify-content: center;
  padding: 12px 0 4px;
}
.drilldown-load-more-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 7px 20px;
  transition: color 0.15s, border-color 0.15s;
}
.drilldown-load-more-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* Clickable category rows in breakdown */
.cat-drilldown {
  cursor: pointer;
  border-radius: 8px;
  padding: 4px 6px;
  margin: 0 -6px;
  transition: background 0.15s;
}
.cat-drilldown:hover {
  background: var(--surface2);
}
.cat-drilldown:hover .cat-name {
  color: var(--accent);
}

/* ── Compare drill-down two-card layout ── */
.cmp-drill-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}

.cmp-drill-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 14px 8px;
  min-width: 0;
}

.cmp-drill-month-label {
  font-family: 'DM Mono', monospace;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  border-left: 3px solid var(--border);
  padding-left: 8px;
  margin-bottom: 14px;
}

/* Make compare bars feel clickable */
.cmp-bar-line.cat-drilldown {
  cursor: pointer;
  border-radius: 6px;
  padding: 3px 4px;
  margin: 0 -4px;
  transition: background 0.15s;
}
.cmp-bar-line.cat-drilldown:hover {
  background: var(--surface2);
}

@media (max-width: 700px) {
  .cmp-drill-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Activity Log Button ── */
.btn-activity {
  background: color-mix(in srgb, var(--accent) 8%, var(--surface2));
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--border));
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 5px 12px;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  white-space: nowrap;
}
.btn-activity:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, var(--surface2));
}
.btn-activity svg {
  transition: transform 0.35s ease;
  display: inline-block;
  vertical-align: middle;
  margin-right: 5px;
  margin-bottom: 1px;
}
.btn-activity:hover svg {
  animation: scrollUnfurl 0.5s ease forwards;
}
@keyframes scrollUnfurl {
  0%   { transform: translateY(0) scaleY(1); }
  30%  { transform: translateY(-3px) scaleY(0.92); }
  65%  { transform: translateY(2px) scaleY(1.06); }
  100% { transform: translateY(0) scaleY(1); }
}

/* ── Activity Log Overlay & Panel ── */
.activity-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-bg);
  backdrop-filter: blur(4px);
  z-index: 400;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 6vh;
  padding-bottom: 4vh;
  overflow-y: auto;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.activity-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.activity-panel {
  position: relative;
  top: auto; left: auto;
  transform: translateY(20px);
  width: min(700px, 94vw);
  max-height: calc(90vh - 6vh);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  transition: transform 0.25s ease, opacity 0.25s ease;
  box-shadow: 0 24px 64px var(--shadow);
  opacity: 0;
  flex-shrink: 0;
}
.activity-overlay.active .activity-panel {
  transform: translateY(0);
  opacity: 1;
}

/* Settings stays as a right-docked side panel */
.settings-panel {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: min(480px, 96vw);
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  box-shadow: -16px 0 48px var(--shadow);
}
.activity-overlay.active .settings-panel {
  transform: translateX(0);
}

.activity-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.activity-header-left {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.activity-title .hdr-icon-box {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.activity-title {
  font-family: 'DM Serif Display', serif;
  font-size: 1.2rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}
.activity-budget-name {
  font-size: 0.75rem;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
}

/* Month navigation */
.activity-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.activity-arrow {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 4px 12px;
  transition: color 0.15s, border-color 0.15s;
}
.activity-arrow:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--text);
}
.activity-period-label {
  font-family: 'DM Serif Display', serif;
  font-size: 1rem;
  color: var(--text);
}

/* Scrollable body */
.activity-body {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  padding: 12px 16px 24px;
}

/* Day groups */
.activity-group {
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.activity-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  cursor: pointer;
  background: var(--surface2);
  transition: background 0.15s;
  gap: 12px;
}
.activity-group-header:hover { background: var(--surface); }

.activity-group-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.activity-group-chevron {
  color: var(--muted);
  font-size: 1rem;
  flex-shrink: 0;
}
.activity-group-date {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.activity-group-summary {
  font-size: 0.75rem;
  font-family: 'DM Mono', monospace;
  flex-shrink: 0;
  display: flex;
  gap: 6px;
  align-items: center;
}

/* Individual log rows */
.activity-group-body {
  padding: 6px 10px 8px;
}
.activity-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--border);
}
.activity-row:last-child { border-bottom: none; }

.activity-action-icon {
  font-size: 0.85rem;
  font-weight: 700;
  font-family: 'DM Mono', monospace;
  width: 20px;
  flex-shrink: 0;
  text-align: center;
  margin-top: 2px;
}
.activity-action-icon.pos { color: var(--income); }
.activity-action-icon.neg { color: var(--expense); }
.activity-action-icon.neu { color: var(--accent); }
.activity-info {
  flex: 1;
  min-width: 0;
}
.activity-desc {
  font-size: 0.83rem;
  color: var(--text);
  margin-bottom: 3px;
  display: flex;
  align-items: baseline;
  gap: 4px;
  min-width: 0;
}
.activity-desc strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1 1 0;
}

.activity-desc-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
}
.activity-verb {
  font-weight: 600;
  margin-right: 4px;
  flex-shrink: 0;
  white-space: nowrap;
}
.activity-meta {
  font-size: 0.73rem;
  color: var(--muted);
  line-height: 1.5;
}
.activity-amount {
  font-family: 'DM Mono', monospace;
  font-size: 0.8rem;
  font-weight: 500;
  flex-shrink: 0;
  margin-top: 2px;
}

/* ── Description autocomplete ── */
.autocomplete-wrap {
  position: relative;
  margin-bottom: 16px;
}
.autocomplete-wrap input {
  margin-bottom: 0;
  width: 100%;
}
.autocomplete-list {
  display: none;
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  list-style: none;
  margin: 0;
  padding: 4px 0;
  z-index: 200;
  box-shadow: 0 8px 24px var(--shadow);
  max-height: 210px;
  overflow-y: auto;
}
.autocomplete-list li {
  padding: 9px 14px;
  font-size: 0.88rem;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.autocomplete-list li:hover,
.autocomplete-list li.active {
  background: var(--surface);
  color: var(--text);
}
.autocomplete-list li strong {
  color: var(--accent);
  font-weight: 600;
}

/* ── Gear button ── */
.btn-gear {
  background: color-mix(in srgb, var(--accent) 8%, var(--surface2));
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--border));
  color: var(--muted);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 5px 10px;
  border-radius: 8px;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  display: flex;
  align-items: center;
  gap: 7px;
}
.btn-gear:hover {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, var(--surface2));
  border-color: var(--accent);
}
.btn-gear svg {
  display: block;
  flex-shrink: 0;
  transition: transform 0.4s ease;
}
.btn-gear:hover svg {
  transform: rotate(90deg);
}

/* ── Settings panel sections ── */
.settings-section {
  padding: 18px 0 4px;
}
.settings-section-title {
  font-family: 'DM Serif Display', serif;
  font-size: 0.95rem;
  color: var(--text);
  margin-bottom: 14px;
}

/* ── Settings panel section headers (Lucide icon style) ── */
.sp-panel-section {
  padding: 16px 0 4px;
}
.sp-panel-section-header {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.sp-panel-section-icon {
  width: 28px; height: 28px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: transform 0.25s ease;
}
.sp-panel-section-header:hover .sp-panel-section-icon {
  transform: scale(1.12) rotate(4deg);
}
.sp-panel-section-title {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
}
/* colour variants — match settings page */
.sp-panel-section-icon.icon-amber  { background: color-mix(in srgb, var(--accent) 15%, transparent);  color: var(--accent); }
.sp-panel-section-icon.icon-blue   { background: color-mix(in srgb, var(--info) 15%, transparent);        color: var(--info); }
.sp-panel-section-icon.icon-green  { background: color-mix(in srgb, var(--green) 15%, transparent);   color: var(--green); }
.sp-panel-section-icon.icon-purple { background: color-mix(in srgb, var(--ui-purple) 15%, transparent);        color: var(--ui-purple); }
.sp-panel-section-icon.icon-red    { background: color-mix(in srgb, var(--danger) 15%, transparent);  color: var(--danger); }

/* ── Category display toggle ── */
/* ── Settings side-by-side pair ── */
.settings-row-pair {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}
.settings-pair-col {
  flex: 1;
  min-width: 0;
}

.cat-display-toggle {
  display: flex;
  gap: 0;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}
.cdt-btn {
  flex: 1;
  background: var(--surface2);
  color: var(--muted);
  border: none;
  padding: 8px 6px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.72rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  white-space: nowrap;
}
.cdt-btn:not(:last-child) {
  border-right: 1px solid var(--border);
}
.cdt-btn:hover { color: var(--text); }
.cdt-btn.active {
  background: var(--accent);
  color: var(--contrast);
  font-weight: 600;
}

.settings-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}
.settings-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}
.settings-input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  padding: 9px 12px;
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
  margin-bottom: 0;
}
.settings-input:focus { border-color: var(--accent); }

.settings-select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  padding: 9px 12px;
  outline: none;
  width: 100%;
  cursor: pointer;
  margin-bottom: 0;
  transition: border-color 0.2s;
}
.settings-select:focus { border-color: var(--accent); }
.settings-select option { background: var(--select-bg); }

.settings-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.settings-currency-hint {
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
}
.settings-save-btn {
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: var(--contrast);
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 9px 16px;
  transition: background 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}
.settings-save-btn:hover { background: var(--hover-accent); }
.settings-save-full {
  width: 100%;
  margin-top: 18px;
  padding: 11px;
  font-size: 0.88rem;
}
.settings-budget-badge {
  font-family: 'DM Mono', monospace;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 14px;
}

/* ── Budget members list ── */
.settings-members-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.settings-member-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  transition: opacity 0.3s ease, transform 0.3s ease, max-height 0.35s ease, padding 0.3s ease, margin 0.3s ease;
}
.settings-member-row.member-entering {
  animation: memberSlideIn 0.32s ease forwards;
}
.settings-member-row.member-leaving {
  opacity: 0;
  transform: translateY(-6px);
  max-height: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  margin-top: 0 !important;
  margin-bottom: 0 !important;
  border-width: 0 !important;
  pointer-events: none;
}
@keyframes memberSlideIn {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.settings-member-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--contrast);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
  font-family: 'DM Mono', monospace;
  flex-shrink: 0;
}
.settings-member-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.settings-member-email {
  font-size: 0.82rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.settings-member-you {
  font-size: 0.68rem;
  color: var(--accent);
  font-family: 'DM Mono', monospace;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.settings-member-remove {
  margin-left: auto;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: none;
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.settings-member-remove:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--white-force);
}

/* ── Settings budget tabs ── */
.settings-budget-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 4px;
}
.settings-budget-tab {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 6px 14px;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.settings-budget-tab:hover {
  color: var(--text);
  border-color: var(--text);
}
.settings-budget-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--contrast);
  font-weight: 600;
}

/* ── Calculable amount field ── */
.amount-wrap {
  position: relative;
}
.calc-bubble {
  display: none;
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 12px;
  font-family: 'DM Mono', monospace;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 4px 16px var(--shadow);
  pointer-events: none;
  z-index: 10;
}
.calc-bubble::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 18px;
  border: 5px solid transparent;
  border-top-color: var(--border);
}
.calc-bubble--ok {
  color: var(--accent);
  border-color: var(--accent);
}
.calc-bubble--ok::after {
  border-top-color: var(--accent);
}
.calc-bubble--error {
  color: var(--danger);
  border-color: var(--danger);
}
.calc-bubble--error::after {
  border-top-color: var(--danger);
}

/* ── Description character counter ── */
.desc-char-counter {
  font-size: 0.72rem;
  font-family: 'DM Mono', monospace;
  color: var(--muted);
  text-align: right;
  margin-top: 3px;
  transition: color 0.15s;
}
/* >80% of limit — amber warning */
.desc-char-counter--warn {
  color: var(--accent);
}
/* Over limit — red, prevents saving */
.desc-char-counter--over {
  color: var(--danger);
  font-weight: 600;
}

/* ── Entry count badge on date group headers ── */
.group-entry-count {
  font-size: 0.68rem;
  font-family: 'DM Mono', monospace;
  color: var(--muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 7px;
  margin-left: 6px;
  white-space: nowrap;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s;
}
/* At limit — accent warning colour */
.group-entry-count--full {
  color: var(--danger);
  border-color: var(--danger);
  font-weight: 600;
}

/* ── Budget count label in Settings ── */
.budget-count-label {
  font-size: 0.76rem;
  font-family: 'DM Mono', monospace;
  color: var(--muted);
  margin-bottom: 10px;
}
.budget-count-label--full {
  color: var(--danger);
  font-weight: 600;
}

/* ── Mobile calculator operator strip ── */
/* Shown below the amount field on mobile when it is focused.
   Lets users insert operators without hunting the soft keyboard. */
.mob-calc-strip {
  display: none; /* shown via JS on focus */
  gap: 8px;
  margin-top: 8px;
}
.mob-calc-key {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: 'DM Mono', monospace;
  font-size: 1.1rem;
  font-weight: 500;
  padding: 11px 0;
  cursor: pointer;
  transition: background 0.12s, transform 0.08s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.mob-calc-key:active {
  background: var(--border);
  transform: scale(0.94);
}
/* Backspace key gets accent tint to stand out */
.mob-calc-key--wide {
  flex: 1.4;
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
}

/* ── Settings sign out button ── */
.settings-signout-btn {
  width: 100%;
  background: none;
  border: 1px solid var(--danger);
  border-radius: 8px;
  color: var(--danger);
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.88rem;
  font-weight: 500;
  padding: 10px;
  transition: background 0.15s, color 0.15s;
  text-align: center;
}
.settings-signout-btn:hover {
  background: var(--danger);
  color: var(--white-force);
}

/* ── Budget error message in header tabs area ── */
/* ── Category section period label ── */
.cat-period-label {
  font-family: 'DM Mono', monospace;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--muted);
  margin-left: 8px;
  vertical-align: middle;
}

/* ── Week start toggle ── */
/* ── Theme toggle ── */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  padding: 4px 0;
}

.tt-label {
  font-size: 0.82rem;
  font-family: 'DM Mono', monospace;
  font-weight: 600;
  color: var(--muted);
  transition: color 0.2s;
  min-width: 48px;
}
.tt-dark { text-align: right; }

.theme-toggle[data-value="dark"]  .tt-dark  { color: var(--accent); }
.theme-toggle[data-value="light"] .tt-light { color: var(--accent); }

.tt-track {
  position: relative;
  width: 48px;
  height: 26px;
  background: var(--surface2);
  border: 1px solid var(--accent);
  border-radius: 99px;
  transition: background 0.25s, border-color 0.25s;
  flex-shrink: 0;
}

.tt-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: var(--accent);
  border-radius: 50%;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.theme-toggle[data-value="light"] .tt-thumb {
  transform: translateX(22px);
}

.theme-toggle:hover .tt-track {
  background: var(--surface);
}

.week-start-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  padding: 4px 0;
}

.wst-label {
  font-size: 0.82rem;
  font-family: 'DM Mono', monospace;
  font-weight: 600;
  color: var(--muted);
  transition: color 0.2s;
  min-width: 28px;
}

/* Sun label active when value=0, Mon label active when value=1 */
.week-start-toggle[data-value="0"] .wst-sun { color: var(--accent); }
.week-start-toggle[data-value="1"] .wst-mon { color: var(--accent); }

.wst-track {
  position: relative;
  width: 48px;
  height: 26px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 99px;
  transition: background 0.25s, border-color 0.25s;
  flex-shrink: 0;
}

.week-start-toggle[data-value="0"] .wst-track,
.week-start-toggle[data-value="1"] .wst-track {
  border-color: var(--accent);
}

.wst-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: var(--accent);
  border-radius: 50%;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Thumb slides right when Monday (value=1) */
.week-start-toggle[data-value="1"] .wst-thumb {
  transform: translateX(22px);
}

.week-start-toggle:hover .wst-track {
  background: var(--surface);
}

/* ── My Wallets list ── */
.settings-my-wallets-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}
.settings-my-budget-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.settings-my-budget-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}
.settings-my-budget-name {
  flex: 1;
  font-size: 0.88rem;
  color: var(--text);
}
.settings-default-btn {
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--muted);
  padding: 2px 4px;
  border-radius: 4px;
  transition: color 0.15s, transform 0.15s;
  line-height: 1;
}
.settings-default-btn:hover { color: var(--accent); transform: scale(1.2); }
.settings-default-btn.active { color: var(--accent); }

/* Create wallet form */
.settings-create-budget {
  margin-bottom: 8px;
}
.settings-add-btn {
  width: 100%;
  background: none;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  padding: 9px;
  transition: color 0.15s, border-color 0.15s;
  text-align: center;
}
.settings-add-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.settings-cancel-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.82rem;
  padding: 9px 14px;
  transition: color 0.15s, border-color 0.15s;
}
.settings-cancel-btn:hover {
  color: var(--text);
  border-color: var(--text);
}

/* ── Emoji Picker ── */
.emoji-picker-wrap {
  position: relative;
  flex-shrink: 0;
}

.emoji-trigger {
  width: 52px;
  height: 44px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s;
  line-height: 1;
}
.emoji-trigger:hover { border-color: var(--accent); }

.emoji-picker-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 280px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 40px var(--shadow);
  z-index: 500;
  overflow: hidden;
}

.emoji-search-wrap {
  padding: 10px 10px 6px;
}
.emoji-search {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.82rem;
  padding: 7px 10px;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.15s;
}
.emoji-search:focus { border-color: var(--accent); }
.emoji-search::placeholder { color: var(--muted); }

.emoji-category-tabs {
  display: flex;
  gap: 2px;
  padding: 4px 8px 6px;
  overflow-x: auto;
  scrollbar-width: none;
}
.emoji-category-tabs::-webkit-scrollbar { display: none; }

.emoji-cat-tab {
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  padding: 4px 6px;
  flex-shrink: 0;
  transition: background 0.12s, border-color 0.12s;
  line-height: 1;
}
.emoji-cat-tab:hover { background: var(--surface); }
.emoji-cat-tab.active {
  background: var(--surface);
  border-color: var(--accent);
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  padding: 4px 8px 10px;
  max-height: 200px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.emoji-item {
  background: none;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1.15rem;
  padding: 5px 2px;
  text-align: center;
  transition: background 0.1s, transform 0.1s;
  line-height: 1;
}
.emoji-item:hover {
  background: var(--surface);
  transform: scale(1.2);
}

/* ── Delete budget button ── */
.settings-delete-budget-btn {
  width: 100%;
  background: none;
  border: 1px solid var(--danger);
  border-radius: 8px;
  color: var(--danger);
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 10px;
  transition: background 0.15s, color 0.15s;
  text-align: center;
}
.settings-delete-budget-btn:hover {
  background: var(--danger);
  color: var(--white-force);
}
.settings-char-count {
  font-family: 'DM Mono', monospace;
  font-size: 0.62rem;
  color: var(--muted);
  text-align: right;
  margin-bottom: 10px;
}

.settings-delete-hint {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 6px;
  text-align: center;
  line-height: 1.4;
}

.settings-leave-wallet-btn {
  width: 100%;
  background: none;
  border: 1px solid var(--muted);
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 10px;
  margin-top: 14px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  text-align: center;
}
.settings-leave-wallet-btn:hover {
  border-color: var(--danger);
  color: var(--danger);
}
.settings-leave-hint {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 6px;
  text-align: center;
  line-height: 1.4;
}

/* ── Activity log budget tag ── */
.activity-budget-tag {
  font-size: 0.72rem;
  font-family: 'DM Mono', monospace;
  color: var(--muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  margin-left: 4px;
  white-space: nowrap;
  flex-shrink: 0;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}

/* ── Member list display name ── */
.settings-member-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
}
.settings-member-email {
  font-size: 0.75rem;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  margin-top: 1px;
}

/* ── No Wallets Empty State Screen ── */
.no-wallets-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 24px 40px;
  max-width: 420px;
  margin: 0 auto;
  animation: fadeUp 0.5s ease both;
}

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

.no-wallets-glyph {
  font-size: 3.5rem;
  margin-bottom: 20px;
  position: relative;
  display: inline-block;
  animation: nb-pulse 2.4s ease-in-out infinite;
  filter: drop-shadow(0 0 8px color-mix(in srgb, var(--accent) 50%, transparent));
}

/* Rays via radial pseudo-element */
.no-wallets-glyph::before {
  content: '';
  position: absolute;
  inset: -18px;
  border-radius: 50%;
  background: transparent;
  box-shadow:
    0 -22px 0 2px color-mix(in srgb, var(--accent) 55%, transparent),
    0  22px 0 2px color-mix(in srgb, var(--accent) 55%, transparent),
   22px  0  0 2px color-mix(in srgb, var(--accent) 55%, transparent),
  -22px  0  0 2px color-mix(in srgb, var(--accent) 55%, transparent),
   16px -16px 0 2px color-mix(in srgb, var(--accent) 38%, transparent),
  -16px -16px 0 2px color-mix(in srgb, var(--accent) 38%, transparent),
   16px  16px 0 2px color-mix(in srgb, var(--accent) 38%, transparent),
  -16px  16px 0 2px color-mix(in srgb, var(--accent) 38%, transparent);
  animation: nb-rays 2.4s ease-in-out infinite;
  pointer-events: none;
}

@keyframes nb-pulse {
  0%, 100% { transform: scale(1);    filter: drop-shadow(0 0 6px color-mix(in srgb, var(--accent) 40%, transparent)); }
  50%       { transform: scale(1.14); filter: drop-shadow(0 0 18px color-mix(in srgb, var(--accent) 85%, transparent)); }
}

@keyframes nb-rays {
  0%, 100% { opacity: 0.5; transform: scale(0.92) rotate(0deg); }
  50%       { opacity: 1;   transform: scale(1.08) rotate(22deg); }
}

.no-wallets-title {
  font-family: 'DM Serif Display', serif;
  font-size: 1.8rem;
  font-weight: 400;
  color: var(--text);
  margin: 0 0 10px;
  line-height: 1.2;
}

.no-wallets-sub {
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.6;
  margin: 0 0 32px;
}

.no-wallets-card {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 28px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.no-wallets-step {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.no-wallets-step-num {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  background: var(--accent);
  color: var(--contrast);
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}

.no-wallets-step-text {
  font-size: 0.87rem;
  color: var(--text);
  line-height: 1.5;
}

.no-wallets-step-text strong {
  color: var(--accent);
}

.no-wallets-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: var(--contrast);
  border: none;
  border-radius: 10px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.92rem;
  font-weight: 600;
  padding: 12px 28px;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.15s;
  margin-bottom: 24px;
}

.no-wallets-cta:hover {
  opacity: 0.88;
  transform: translateY(-1px);
}

.no-wallets-invite {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.5;
  max-width: 320px;
  border-top: 1px solid var(--border);
  padding-top: 20px;
  margin: 0;
}

/* ── Members list empty state ── */
.settings-members-empty {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 4px;
  color: var(--muted);
  font-size: 0.82rem;
  font-style: italic;
}

.settings-members-empty-icon {
  font-size: 1rem;
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════
   MOBILE RESPONSIVE ≤768px
   Desktop untouched by everything below
   ═══════════════════════════════════════════════════════════════ */

/* ── Mobile-only elements — hidden on desktop ── */
.bubble-nav           { display: none; }
.bubble-menu          { display: none; }
.mobile-sheet-overlay { display: none; }
.mobile-sheet         { display: none; }
.mobile-budget-select { display: none; }
.mob-breakdown-select { display: none; }
.mob-export-row { display: none; }

@media (max-width: 768px) {

  /* ── Body ── */
  html, body {
    overflow-x: hidden;
    max-width: 100vw;
  }

  /* ── Header ── */
  header {
    padding: 0 12px;
    height: 52px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 0;
  }

  #budget-tabs       { display: none !important; }
  .month-overview    { display: none !important; }
  #sync-indicator    { display: none !important; }
  .btn-activity      { display: none !important; }
  #user-name         { display: none !important; }
  .header-right      { gap: 6px; }
  .btn-gear          { padding: 8px; min-width: 44px; min-height: 44px; justify-content: center; }
  /* Mobile budget dropdown — centred in header */
  .mobile-budget-select {
    display: flex;
    align-items: center;
    background: none;
    border: none;
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.88rem;
    font-weight: 600;
    text-align: center;
    text-align-last: center;
    width: 100%;
    height: 52px;          /* match header height exactly */
    padding: 0 20px 0 4px;
    margin: 0;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23f5b942' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 4px center;
    cursor: pointer;
    vertical-align: middle;
  }

  .mobile-budget-select option {
    background: var(--surface);
    color: var(--text);
  }

  /* ── Container ── */
  .container {
    grid-template-columns: 1fr !important;
    height: auto !important;
    overflow: visible !important;
  }

  /* ── Sidebar: hidden, shown via mob-show ── */
  .sidebar {
    display: none !important;
    border: none !important;
    height: auto !important;
    overflow: visible !important;
    padding: 0 !important;
  }
  .sidebar.mob-show {
    display: block !important;
    padding: 16px !important;
  }

  /* ── Main panel ── */
  .main {
    display: none !important;
    padding: 12px !important;
    overflow-x: hidden !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }
  .main.mob-show { display: block !important; }

  /* ── Summary cards ── */
  .summary-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }
  .card            { padding: 10px 12px !important; }
  .card-label      { font-size: 0.7rem !important; }
  .card-amount     { font-size: 1.1rem !important; }
  .card-sub        { font-size: 0.68rem !important; }
  .cards-section-header { padding: 6px 0 !important; }

  /* ── Breakdown section: no overflow ── */
  .breakdown-section-header {
    margin-top: 10px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  /* ── Breakdown filters: hide tabs, show dropdown on mobile ── */
  .breakdown-filters { display: none !important; }

  .mob-breakdown-select {
    display: block !important;
    width: 100%;
    box-sizing: border-box;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.88rem;
    font-weight: 500;
    padding: 8px 36px 8px 12px;
    min-height: 40px;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23f5b942' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    cursor: pointer;
    margin-bottom: 4px;
  }

  .mob-breakdown-select option {
    background: var(--surface);
    color: var(--text);
  }

  /* Category period nav — bigger touch targets on mobile */
  .cat-period-nav {
    margin: 4px 0;
  }
  .period-nav-btn {
    min-width: 44px;
    min-height: 44px;
    justify-content: center;
    border-radius: 10px;
  }
  .period-nav-label {
    font-size: 0.92rem;
  }

  /* Mobile export buttons */
  .mob-export-row {
    display: flex !important;
    gap: 6px;
    margin-bottom: 4px;
  }
  .mob-export-btn {
    flex: 1;
    background: none;
    border: 1px solid var(--accent);
    border-radius: 8px;
    color: var(--accent);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.8rem;
    font-weight: 500;
    padding: 7px 10px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
  }
  .mob-export-btn:active {
    background: var(--accent);
    color: var(--contrast);
  }

  /* ── Category rows ── */
  .cat-row {
    grid-template-columns: 80px 1fr 60px !important;
    font-size: 0.75rem !important;
    gap: 4px !important;
  }

  /* ── Transaction tabs ── */
  .tabs { gap: 3px !important; }
  .tab  { min-height: 36px !important; padding: 5px 10px !important; font-size: 0.78rem !important; }

  /* ── Add button ── */
  .btn-add { min-height: 48px !important; font-size: 1rem !important; }

  /* ── Form inputs ── */
  .sidebar select, .sidebar input[type="text"], .sidebar input[type="date"],
  .mobile-sheet-inner select, .mobile-sheet-inner input {
    min-height: 44px !important;
    font-size: 1rem !important;
  }

  /* ── Settings panel: full screen ── */
  .settings-panel {
    position: fixed !important;
    inset: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    border-radius: 0 !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    box-sizing: border-box !important;
  }
  .settings-inner {
    padding: 16px !important;
    box-sizing: border-box !important;
    width: 100% !important;
    overflow-x: hidden !important;
  }
  /* ── Activity panel: full screen ── */
  .activity-panel {
    position: fixed !important;
    inset: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    height: 100% !important;
    border-radius: 0 !important;
    box-sizing: border-box !important;
    top: 0 !important; left: 0 !important;
    transform: none !important;
    opacity: 1 !important;
  }
  .activity-overlay.active .activity-panel {
    transform: none !important;
  }

  /* ── Drilldown modal ── */
  .drilldown-modal {
    position: fixed !important;
    inset: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    border-radius: 0 !important;
    transform: none !important;
  }

  /* Drilldown view tabs — bigger tap targets on mobile */
  .drilldown-view-tabs {
    padding: 10px 16px;
  }
  .drilldown-view-tab {
    min-height: 36px;
    font-size: 0.8rem;
    padding: 6px 16px;
  }
  .drilldown-header {
    padding: 16px 16px 12px !important;
  }
  .drilldown-body {
    padding: 12px 16px 20px !important;
  }
  .dd-sparkline-section {
    padding: 10px 16px 12px !important;
  }

  /* Member view — tighter spacing */
  .dd-member-avatar {
    width: 26px;
    height: 26px;
    font-size: 0.62rem;
  }
  .dd-member-date {
    width: 44px;
    font-size: 0.7rem;
  }
  .dd-member-count {
    font-size: 0.68rem;
  }

  /* ── Period nav ── */
  .period-arrow { min-width: 44px !important; min-height: 44px !important; }

  /* ── Onboarding ── */
  .no-wallets-screen { padding: 40px 16px 120px !important; }

  /* ── Compare ── */
  .cmp-header   { flex-direction: column !important; gap: 8px !important; }
  .cmp-controls { flex-wrap: wrap !important; gap: 6px !important; }
  #breakdown-compare { margin-bottom: 16px !important; padding-bottom: 8px !important; }

  /* Summary card: stack months vertically on mobile */
  .cmp-summary {
    flex-direction: column;
    gap: 0;
    padding: 14px 16px;
  }
  .cmp-summary-col {
    width: 100%;
  }
  .cmp-summary-vs {
    align-self: center;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 8px 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    margin: 10px 0;
    width: 100%;
    text-align: center;
  }
  .cmp-summary-row {
    font-size: 0.92rem;
  }
  .cmp-summary-net {
    font-size: 1.2rem;
  }

  /* ══ BUBBLE NAV ══════════════════════════════════════════════ */

  .bubble-nav {
    display: block;
    position: fixed;
    bottom: 60px;
    right: 20px;
    z-index: 900;
  }

  /* The main circle button */
  .bubble-toggle {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--accent);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px color-mix(in srgb, var(--accent) 45%, transparent);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    z-index: 2;
  }

  .bubble-toggle:active { transform: scale(0.92); }

  /* Fade bubble while scrolling */
  .bubble-nav {
    transition: opacity 0.3s ease;
  }
  .bubble-nav.scrolling {
    opacity: 0.2;
    pointer-events: none; /* don't intercept taps while faded */
  }
  .bubble-nav.scrolling .bubble-menu {
    /* collapse menu if open while scrolling */
    pointer-events: none;
  }
  .bubble-toggle .bubble-icon-close { display: none; }
  .bubble-nav.open .bubble-toggle .bubble-icon-menu  { display: none; }
  .bubble-nav.open .bubble-toggle .bubble-icon-close { display: block; }
  .bubble-nav.open .bubble-toggle {
    box-shadow: 0 4px 28px color-mix(in srgb, var(--accent) 65%, transparent);
  }

  /* Menu items that roll up */
  .bubble-menu {
    display: flex;
    flex-direction: column-reverse;
    gap: 10px;
    position: absolute;
    bottom: calc(100% + 12px);
    right: 0;
    pointer-events: none;
  }

  .bubble-item {
    display: flex;
    align-items: center;
    flex-direction: row-reverse;
    gap: 10px;
    opacity: 0;
    transform: translateY(16px) scale(0.85);
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
  }

  /* Stagger delay per item */
  .bubble-item:nth-child(1) { transition-delay: 0s; }
  .bubble-item:nth-child(2) { transition-delay: 0.05s; }
  .bubble-item:nth-child(3) { transition-delay: 0.1s; }
  .bubble-item:nth-child(4) { transition-delay: 0.15s; }

  .bubble-nav.open .bubble-item {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
  }

  /* Reverse delay on close */
  .bubble-nav.open .bubble-item:nth-child(1) { transition-delay: 0.15s; }
  .bubble-nav.open .bubble-item:nth-child(2) { transition-delay: 0.10s; }
  .bubble-nav.open .bubble-item:nth-child(3) { transition-delay: 0.05s; }
  .bubble-nav.open .bubble-item:nth-child(4) { transition-delay: 0s; }

  .bubble-item-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--surface2);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text);
    box-shadow: 0 2px 12px rgba(0,0,0,0.3);
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
  }

  .bubble-item-btn:active { background: var(--accent); color: var(--contrast); }
  .bubble-item-btn svg { width: 20px; height: 20px; }

  /* Amber fill — Add expense */
  .bubble-item-accent {
    background: var(--accent) !important;
    color: var(--contrast) !important;
    border-color: var(--accent) !important;
  }

  /* Amber outline — navigation items */
  .bubble-item-outline {
    border: 1.5px solid var(--accent) !important;
    color: var(--accent) !important;
  }
  .bubble-item-outline svg { stroke: var(--accent); }
  .bubble-item-outline:active { background: var(--accent) !important; color: var(--contrast) !important; }
  .bubble-item-outline:active svg { stroke: var(--contrast); }

  .bubble-item-label {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text);
    background: var(--surface2);
    border: 1px solid var(--border);
    padding: 4px 10px;
    border-radius: 20px;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
    pointer-events: none;
  }

  /* ── Add sheet ── */
  .mobile-sheet-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--overlay-bg);
    z-index: 800;
  }
  .mobile-sheet-overlay.visible { display: block; }

  .mobile-sheet {
    display: block;
    position: fixed;
    bottom: 0;
    left: 0; right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
    z-index: 850;
    transform: translateY(110%);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    max-height: var(--sheet-max-h, 85vh);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .mobile-sheet.open { transform: translateY(0); }

  .mobile-sheet-handle {
    width: 36px; height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 10px auto 0;
  }

  .mobile-sheet-inner {
    padding: 12px 16px 32px;
    box-sizing: border-box;
  }

  /* ── Mobile category picker ───────────────────────────────────────────────── */
  .mob-cat-picker {
    margin-bottom: 4px;
  }
  .mob-cat-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
  }
  .mob-cat-tab {
    flex: 1;
    padding: 8px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface2);
    color: var(--muted);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    min-height: 38px;
  }
  .mob-cat-tab.active {
    background: var(--accent)22;
    border-color: var(--accent);
    color: var(--accent);
  }
  .mob-cat-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 220px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 4px;
    background: var(--surface2);
    margin-bottom: 14px;
  }
  .mob-cat-list::-webkit-scrollbar { width: 3px; }
  .mob-cat-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
  .mob-cat-option {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 10px;
    border-radius: 7px;
    border: 1px solid transparent;
    background: none;
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.9rem;
    text-align: left;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
    min-height: 44px;
    box-sizing: border-box;
  }
  .mob-cat-option:hover,
  .mob-cat-option:active { background: var(--surface); }
  .mob-cat-option.selected {
    background: var(--cat-color, var(--accent))18;
    border-color: var(--cat-color, var(--accent));
  }
  .mob-cat-emoji {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
  }
  .mob-cat-name {
    flex: 1;
    font-weight: 500;
  }
  .mob-cat-check {
    color: var(--accent);
    font-size: 1rem;
    font-weight: 700;
    flex-shrink: 0;
  }

  /* Settings panel: section header tap targets */
  .sp-panel-section-header { padding: 4px 0; min-height: 40px; }
  .sp-panel-section-icon   { width: 32px; height: 32px; }

  /* Settings panel: input+button rows stack on narrow screens */
  .settings-panel .settings-row { flex-wrap: wrap; }
  .settings-panel .settings-row .settings-input {
    flex: 1 1 100%; min-height: 44px; font-size: 1rem;
  }
  .settings-panel .settings-row .settings-save-btn,
  .settings-panel .settings-row .settings-cancel-btn {
    min-height: 44px; font-size: 0.9rem;
  }

  /* Selects and textareas taller for touch */
  .settings-panel .settings-select,
  .settings-panel .settings-input[type="text"],
  .settings-panel .settings-input[type="email"],
  .settings-panel textarea.settings-input {
    min-height: 44px; font-size: 1rem;
  }

  /* Full-width action buttons - tall tap target */
  .settings-panel .settings-save-full,
  .settings-panel .settings-manage-cats-btn,
  .settings-panel .settings-add-btn,
  .settings-panel .settings-signout-btn,
  .settings-panel .settings-delete-budget-btn,
  .settings-panel .settings-leave-wallet-btn {
    min-height: 44px; font-size: 0.9rem;
  }

} /* end @media 768px */

/* ══════════════════════════════════════════════════════════════════════════════
   Category Manager Modal
   ══════════════════════════════════════════════════════════════════════════════ */

/* Fix 9: Toast messages must appear above the category manager overlay */
#toast-container { z-index: 9999 !important; }

/* ══════════════════════════════════════════════════════════════════════════════
   Category Manager Modal
   ══════════════════════════════════════════════════════════════════════════════ */
.cat-manager-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--overlay-bg);
  z-index: 1100;
  align-items: flex-start;
  justify-content: center;
  padding-top: 6vh;
  padding-bottom: 4vh;
  padding-left: 20px;
  padding-right: 20px;
  overflow-y: auto;
  backdrop-filter: blur(4px);
}
.cat-manager-overlay.active { display: flex; }

/* Modal: pins to top, expands downward, scrolls internally */
.cat-manager-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 780px;
  max-height: calc(90vh - 6vh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 64px var(--shadow);
  flex-shrink: 0;
}

.cat-manager-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.cat-manager-title {
  font-family: 'DM Serif Display', serif;
  font-size: 1.15rem;
  color: var(--text);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cat-manager-budget-name {
  font-size: 0.78rem;
  color: var(--muted);
  margin-right: 8px;
}

/* Body: scrolls only when form pushes content past max-height */
.cat-manager-body {
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Two column layout — does NOT stretch; shrinks to content */
.cat-manager-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.cat-manager-col {
  display: flex;
  flex-direction: column;
}

.cat-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.cat-col-title {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.cat-col-count { font-size: 0.7rem; color: var(--muted); }

/* List: fixed item height × 9 max, then scrollbar */
.cat-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  max-height: 324px; /* ~9 items × 36px each */
  padding-right: 4px;
}
.cat-list::-webkit-scrollbar { width: 4px; }
.cat-list::-webkit-scrollbar-track { background: transparent; }
.cat-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.cat-list-empty { font-size: 0.8rem; color: var(--muted); padding: 8px 0; }

.cat-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  border-radius: 8px;
  background: var(--surface2);
  border: 1px solid transparent;
  transition: border-color 0.15s;
  flex-shrink: 0;
  height: 36px;
  box-sizing: border-box;
}
.cat-list-item:hover { border-color: var(--border); }

.cat-item-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}
.cat-item-emoji {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  flex-shrink: 0;
}
.cat-item-name {
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cat-item-color-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-left: 2px;
}
.cat-item-limit {
  font-size: 0.68rem;
  font-family: 'DM Mono', monospace;
  font-weight: 500;
  color: var(--accent);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 6px;
  margin-left: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}
.cat-item-actions { display: flex; gap: 2px; flex-shrink: 0; }

.cat-item-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
  padding: 3px 5px;
  border-radius: 5px;
  line-height: 1;
  transition: opacity 0.15s, background 0.15s;
}
/* Edit button: amber/accent colour */
.cat-edit-btn { color: var(--accent); opacity: 0.75; }
.cat-edit-btn:hover { opacity: 1; background: var(--accent)22; }
/* Delete button: bright red, always visible */
.cat-delete-btn { color: var(--danger); opacity: 0.85; font-size: 1rem; }
.cat-delete-btn:hover { opacity: 1; background: color-mix(in srgb, var(--danger) 18%, transparent); }

/* Add button */
.cat-add-btn {
  margin-top: 8px;
  background: none;
  border: 1px dashed var(--border);
  color: var(--accent);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 0.82rem;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  width: 100%;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}
.cat-add-btn:hover { background: var(--surface2); border-color: var(--accent); }

.cat-btn-row {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.cat-btn-row .cat-add-btn {
  margin-top: 0;
  flex: 1;
}
.cat-remove-all-btn {
  background: none;
  border: 1px dashed var(--border);
  color: var(--danger);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 0.78rem;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.cat-remove-all-btn:hover { background: color-mix(in srgb, var(--danger) 8%, transparent); border-color: var(--danger); }
.cat-remove-all-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.cat-remove-all-btn:disabled:hover { background: none; border-color: var(--border); }

/* Manage Categories button in Settings */
.settings-manage-cats-btn {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 9px 16px;
  background: none;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: var(--radius);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  text-align: center;
}
.settings-manage-cats-btn:hover { background: var(--accent)22; }

/* ── Add / Edit form ─────────────────────────────────────────────────────────── */
.cat-edit-form {
  background: var(--surface2);
  border: 1px solid var(--accent);
  border-radius: 10px;
  padding: 16px;
  margin-top: 16px;
  flex-shrink: 0;
}
.cat-edit-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
}

/* Row 1: emoji + name */
.cat-edit-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
/* Override global input margin inside the edit row */
.cat-edit-row input {
  margin-bottom: 0;
}

/* Colour section label */
.cat-color-section-label {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  margin-bottom: 8px;
}

/* Row 2: palette swatches + Auto button — all in one horizontal line */
.cat-color-palette-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.cat-color-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  flex: 1;
}
.cat-swatch {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: transform 0.1s, border-color 0.1s;
}
.cat-swatch:hover  { transform: scale(1.25); }
.cat-swatch.active { border-color: var(--text); transform: scale(1.2); }

.cat-auto-color-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 0.75rem;
  cursor: pointer;
  white-space: nowrap;
  height: 26px;
  transition: border-color 0.15s, color 0.15s;
  flex-shrink: 0;
}
.cat-auto-color-btn:hover { border-color: var(--accent); color: var(--accent); }

/* Row 3: Custom colour picker + preview */
.cat-color-custom-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px; /* extra room for hex label below preview */
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.cat-color-custom-label {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
  flex: 1;
  cursor: default;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}
.cat-color-divider {
  width: 1px;
  height: 32px;
  background: var(--border);
  flex-shrink: 0;
}
/* Picker and preview sit side by side, both 36×36, vertically centred */
.cat-color-custom {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  border: 1px solid var(--border);
  padding: 2px;
  cursor: pointer;
  background: none;
  flex-shrink: 0;
  display: block;
  box-sizing: border-box;
  align-self: center;
  margin-bottom: 0;   /* override global input margin-bottom: 14px */
  margin-top: 0;
}
.cat-color-preview-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  flex-shrink: 0;
}
.cat-color-preview-label {
  font-size: 0.58rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  margin-bottom: 2px;
}
.cat-color-preview {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  border: 2px solid var(--border);
  position: relative;
  flex-shrink: 0;
  align-self: center;
}
.cat-color-preview::after {
  content: attr(data-hex);
  position: absolute;
  bottom: -15px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.58rem;
  color: var(--muted);
  white-space: nowrap;
  font-family: 'DM Mono', monospace;
}

.cat-edit-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px; /* extra space for the hex label below preview */
}

/* Fix: Remove white boxes from emoji buttons */
.emoji-btn {
  background: none !important;
  border: none !important;
  box-shadow: none !important;
  outline: none !important;
}
.emoji-btn:hover {
  background: var(--surface2) !important;
  border-radius: 4px;
}

/* ── Mobile ──────────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Modal slides up from bottom like a sheet */
  .cat-manager-overlay.active {
    align-items: flex-end;
    padding: 0;
  }
  .cat-manager-modal {
    max-height: 94vh;
    border-radius: 16px 16px 0 0;
    width: 100%;
  }
  .cat-manager-body {
    padding: 16px;
  }

  /* Stack columns vertically */
  .cat-manager-columns {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  /* Shorter lists on mobile — 5 items before scroll */
  .cat-list { max-height: 180px; }

  /* Tighter item padding, bigger tap targets on buttons */
  .cat-list-item {
    padding: 10px 10px;
    height: 44px;
  }
  .cat-item-btn {
    font-size: 1.1rem;
    padding: 6px 8px;
    min-width: 36px;
    min-height: 36px;
  }

  /* Add button full width, taller tap target */
  .cat-add-btn {
    padding: 12px;
    font-size: 0.9rem;
    min-height: 44px;
  }

  /* Edit form: tighter padding */
  .cat-edit-form {
    padding: 14px 12px;
    margin-top: 12px;
  }

  /* Emoji trigger — bigger tap target */
  .cat-edit-row .emoji-trigger {
    width: 44px;
    height: 44px;
    font-size: 1.3rem;
    min-width: 44px;
  }

  /* Name input full width, taller */
  .cat-edit-row input {
    font-size: 1rem;
    padding: 12px 13px;
    min-height: 44px;
  }

  /* Swatches: bigger circles for touch */
  .cat-swatch {
    width: 26px;
    height: 26px;
  }

  /* Auto button: taller */
  .cat-auto-color-btn {
    height: 36px;
    padding: 0 14px;
    font-size: 0.82rem;
  }

  /* Custom colour row: stack label above, picker + preview side by side */
  .cat-color-custom-row {
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 12px;
  }
  .cat-color-custom-label {
    width: 100%;
    flex: unset;
    font-size: 0.72rem;
    margin-bottom: 2px;
  }
  .cat-color-custom {
    width: 44px;
    height: 44px;
  }
  .cat-color-preview {
    width: 44px;
    height: 44px;
  }
  .cat-color-divider {
    display: none; /* not needed when row wraps */
  }

  /* Save/Cancel buttons — full width stack */
  .cat-edit-actions {
    flex-direction: column;
    gap: 8px;
    margin-top: 20px;
  }
  .cat-edit-actions .settings-save-btn,
  .cat-edit-actions .settings-cancel-btn {
    width: 100%;
    min-height: 44px;
    font-size: 0.95rem;
    text-align: center;
  }

  /* Emoji picker dropdown — full width on mobile */
  #cat-emoji-picker-dropdown {
    width: calc(100vw - 32px);
    left: 0;
    right: 0;
  }
}

/* ══════════════════════════════════════════════════════════════════════════════
   Footers — auth screen + app slim bar
   ══════════════════════════════════════════════════════════════════════════════ */

/* Auth screen footer links — sit below the sign-in card */
.auth-footer-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px 18px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.auth-footer-links a {
  font-size: 0.75rem;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s;
}
.auth-footer-links a:hover { color: var(--accent); }

/* App slim footer bar — desktop only */
.app-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;
}
.app-footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
}
.app-footer-links a {
  font-size: 0.74rem;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s;
}
.app-footer-links a:hover { color: var(--accent); }
.app-footer-copy {
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Mobile app footer — stacks vertically, centred, enough bottom padding to
   clear the iOS home indicator and sit above the bubble nav's 60px offset */
@media (max-width: 768px) {
  .app-footer {
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 16px 20px 28px;
    text-align: center;
  }
  .app-footer-links {
    justify-content: center;
    gap: 6px 16px;
  }
  .app-footer-links a {
    font-size: 0.76rem;
  }
  .app-footer-copy {
    font-size: 0.72rem;
    white-space: normal;
  }
}


/* Activity Load More Button */
.activity-load-more-wrap {
  display: flex;
  justify-content: center;
  padding: 12px 0 4px;
}
.activity-load-more-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 7px 20px;
  transition: color 0.15s, border-color 0.15s;
}
.activity-load-more-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}
/* PWA Install Banner */
.pwa-install-banner {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 9999;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 24px var(--shadow);
  padding: 14px 16px;
  animation: pwa-slide-up 0.3s ease;
}
@keyframes pwa-slide-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.pwa-install-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 600px;
  margin: 0 auto;
}
.pwa-install-text {
  flex: 1;
  min-width: 0;
}
.pwa-install-text strong {
  display: block;
  font-size: 0.9rem;
  color: var(--text);
  font-family: "DM Serif Display", serif;
}
.pwa-install-text span {
  font-size: 0.78rem;
  color: var(--muted);
}
.pwa-install-btn {
  background: var(--accent);
  color: var(--contrast);
  border: none;
  border-radius: 999px;
  padding: 8px 20px;
  font-family: "DM Sans", sans-serif;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s;
}
.pwa-install-btn:hover { opacity: 0.85; }
.pwa-install-dismiss {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}
.pwa-install-dismiss:hover { color: var(--text); }

/* ── Chart mode toggle ── (hidden pending redesign) */
.chart-toggle-btn {
  display: none !important;
}
.chart-toggle-btn-DISABLED {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 7px;
  cursor: pointer;
  color: var(--muted);
  transition: color 0.2s, border-color 0.2s, background 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.chart-toggle-btn:hover { color: var(--text); border-color: var(--accent); }
.chart-toggle-btn.active {
  color: var(--accent);
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

/* ── Donut chart ── */
.donut-sections-row {
  display: flex;
  gap: 32px;
  flex-direction: row-reverse;
}
.donut-section {
  flex: 1;
  min-width: 0;
  margin-bottom: 24px;
}
@media (max-width: 700px) {
  .donut-sections-row { flex-direction: column; }
}
.donut-section-label {
  font-family: 'DM Mono', monospace;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 16px;
}
.donut-section-label.pos { color: var(--green); }
.donut-section-label.neg { color: var(--danger); }

.donut-container {
  display: flex;
  align-items: center;
  gap: 24px;
}

.donut-svg-wrap {
  position: relative;
  flex-shrink: 0;
}
.donut-centre {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
}
.donut-centre-amount {
  font-family: 'DM Mono', monospace;
  font-size: 1.05rem;
  font-weight: 600;
}
.donut-centre-amount.pos { color: var(--green); }
.donut-centre-amount.neg { color: var(--danger); }

.donut-legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-width: 0;
}
.donut-legend-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  transition: background 0.15s;
}
.donut-legend-item:hover { background: var(--surface2); }
.donut-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 3px;
}
.donut-legend-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.donut-legend-name {
  font-size: 0.78rem;
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.donut-legend-val {
  font-family: 'DM Mono', monospace;
  font-size: 0.74rem;
  font-weight: 500;
  white-space: nowrap;
}
.donut-legend-val.neg { color: var(--danger); }
.donut-legend-val.pos { color: var(--green); }

/* Donut slice animation */
.donut-slice {
  transition: opacity 0.15s;
  cursor: pointer;
}
.donut-slice:hover { opacity: 0.8; }

/* Donut entrance animation */
@keyframes donut-spin-in {
  from { stroke-dashoffset: var(--circumference); }
  to { stroke-dashoffset: var(--final-offset); }
}

/* Leader lines for small slices */
.donut-leader {
  stroke: var(--muted);
  stroke-width: 1;
  fill: none;
  opacity: 0.4;
}

/* Mobile */
@media (max-width: 580px) {
  .donut-container { flex-direction: column; align-items: center; }
  .donut-legend { width: 100%; }
}

/* ── Header icon buttons ── */
/* ── Header icon buttons — settings-style coloured squares ── */
.btn-header-icon,
.btn-notif {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  position: relative;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* The inner square */
.btn-header-icon .hdr-icon-box,
.btn-notif .hdr-icon-box {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, filter 0.2s ease;
}

/* Recurring panel header icon — steel-blue */
.hdr-icon-box-recurring {
  background: color-mix(in srgb, var(--ui-blue) 14%, transparent);
  color: var(--ui-blue);
}

/* Activity log panel header icon — info blue */
.hdr-icon-box-activity {
  background: color-mix(in srgb, var(--info) 14%, transparent);
  color: var(--info);
}

/* Recurring — muted steel-blue */
.btn-header-icon .hdr-icon-box {
  background: color-mix(in srgb, var(--ui-blue) 13%, transparent);
  color: var(--ui-blue);
}
.btn-header-icon:hover .hdr-icon-box {
  transform: scale(1.12) rotate(5deg);
  filter: brightness(1.15);
}

/* Notifications — amber */
.btn-notif .hdr-icon-box {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
}
.btn-notif:hover .hdr-icon-box {
  transform: scale(1.12) rotate(-8deg);
  filter: brightness(1.15);
}

/* Badge sits on corner of the box */
.notif-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  background: var(--danger);
  color: var(--white-force);
  font-size: 0.52rem;
  font-weight: 700;
  min-width: 15px;
  height: 15px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  font-family: 'DM Sans', sans-serif;
  pointer-events: none;
}

/* ── Recurring tabs ── */
.recurring-tabs {
  display: flex;
  gap: 0;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
}
.recurring-tab {
  background: none;
  border: none;
  padding: 10px 16px;
  color: var(--muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}
.recurring-tab:hover { color: var(--text); }
.recurring-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.recurring-create-btn {
  margin-left: auto;
  background: none;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 6px;
  padding: 4px 12px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  align-self: center;
  transition: background 0.2s, color 0.2s;
}
.recurring-create-btn:hover { background: var(--accent); color: var(--contrast); }

/* ── Recurring item ── */
.rec-item {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.rec-item:hover { background: var(--surface2); }
.rec-item.rec-paused { opacity: 0.5; }
.rec-item.rec-overdue { border-left: 3px solid var(--danger); }
.rec-item-header {
  display: flex;
  align-items: center;
  gap: 12px;
}
.rec-item-cat {
  font-size: 1.3rem;
  width: 36px;
  text-align: center;
  flex-shrink: 0;
}
.rec-item-info { flex: 1; min-width: 0; }
.rec-item-desc {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rec-item-meta {
  font-size: 0.68rem;
  color: var(--muted);
  margin-top: 2px;
}
.rec-item-amt {
  font-family: 'DM Mono', monospace;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}
.rec-item-amt.pos { color: var(--green); }
.rec-item-amt.neg { color: var(--danger); }
.rec-item-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.rec-item-actions {
  margin-left: auto;
  display: flex;
  gap: 4px;
}
.rec-action-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 2px 4px;
  border-radius: 4px;
  transition: background 0.15s;
}
.rec-action-btn:hover { background: var(--surface2); }

/* Badges */
.rec-badge {
  font-family: 'DM Mono', monospace;
  font-size: 0.58rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.rec-badge.active { background: rgba(46,156,98,0.12); color: var(--green); }
.rec-badge.paused { background: color-mix(in srgb, var(--muted) 12%, transparent); color: var(--muted); }
.rec-badge.overdue { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.rec-badge.auto { background: color-mix(in srgb, var(--rec-auto) 12%, transparent); color: var(--rec-auto); }
.rec-badge.approval { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); }

/* Pending actions */
.rec-pending-actions {
  gap: 8px;
}
.rec-approve-btn, .rec-skip-btn {
  border: none;
  border-radius: 6px;
  padding: 6px 14px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.rec-approve-btn {
  background: var(--green);
  color: var(--white-force);
}
.rec-approve-btn:hover { opacity: 0.85; }
.rec-skip-btn {
  background: var(--surface2);
  color: var(--muted);
  border: 1px solid var(--border);
}
.rec-skip-btn:hover { color: var(--text); }
.rec-amt-input {
  width: 90px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: 'DM Mono', monospace;
  font-size: 0.78rem;
  padding: 5px 8px;
  outline: none;
}
.rec-amt-input:focus { border-color: var(--accent); }


/* ── Recurring form grid ── */
.rec-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 24px;
}
.rec-form-col {
  display: flex;
  flex-direction: column;
}
@media (max-width: 580px) {
  .rec-form-grid { grid-template-columns: 1fr; }
  .rec-toggles-row { flex-direction: column; gap: 12px; }
}

/* ── Recurring toggles row ── */
.rec-toggles-row {
  display: flex;
  gap: 24px;
  margin-top: 16px;
  padding: 14px 0;
  border-top: 1px solid var(--border);
}
.rec-toggle-item {
  display: flex;
  align-items: center;
  gap: 10px;
}
.rec-toggle-label {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.78rem;
  color: var(--text);
  font-weight: 500;
  user-select: none;
}

/* Toggle switch */
.rec-toggle {
  cursor: pointer;
  display: flex;
  align-items: center;
}
.rec-toggle-track {
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: var(--accent);
  position: relative;
  transition: background 0.2s;
  pointer-events: none;
}
.rec-toggle.off .rec-toggle-track {
  background: var(--border);
}
.rec-toggle-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--white-force);
  position: absolute;
  top: 2px;
  left: 18px;
  transition: left 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  pointer-events: none;
}
.rec-toggle.off .rec-toggle-thumb {
  left: 2px;
}

/* ── Member picker ── */
.rec-member-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.rec-member-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
  transition: all 0.2s;
  user-select: none;
}
.rec-member-pill:hover {
  border-color: var(--accent);
  color: var(--text);
}
.rec-member-pill.selected {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-color: var(--accent);
  color: var(--accent);
}
.rec-member-pill-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 2px solid var(--border);
  transition: all 0.2s;
  flex-shrink: 0;
}
.rec-member-pill.selected .rec-member-pill-dot {
  background: var(--accent);
  border-color: var(--accent);
}

/* ── Recurring form ── (now uses view switching, no absolute positioning) */

.recurring-form-body {
  padding: 20px;
}

/* ── Notification items ── */
.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}
.notif-item:hover { background: var(--surface2); }
.notif-item.notif-read { opacity: 0.55; }
.notif-icon { font-size: 1.2rem; flex-shrink: 0; margin-top: 2px; }
.notif-content { flex: 1; min-width: 0; }
.notif-title {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text);
}
.notif-message {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 2px;
}
.notif-time {
  font-size: 0.62rem;
  color: var(--muted);
  margin-top: 4px;
  font-family: 'DM Mono', monospace;
}
.notif-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  margin-top: 6px;
}

/* ── Invitation notifications ── */
.notif-invite {
  cursor: default;
  background: var(--surface2);
  border-left: 3px solid var(--accent);
}
.notif-invite:hover { background: var(--surface2); }
.notif-invite-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.notif-accept-btn,
.notif-decline-btn {
  padding: 5px 14px;
  border-radius: 999px;
  border: none;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}
.notif-accept-btn:hover,
.notif-decline-btn:hover { opacity: 0.82; transform: translateY(-1px); }
.notif-accept-btn:disabled,
.notif-decline-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.notif-accept-btn  { background: var(--accent); color: #0f1623; }
.notif-decline-btn { background: var(--surface3); color: var(--muted); }

/* ── Pending invite rows in settings member list ── */
.settings-member-pending { opacity: 0.85; }
.settings-member-pending.member-entering { animation: memberSlideIn 0.32s ease forwards; }

/* ═══════════════════════════════════════════════════════════════
   RECEIPTS
   ═══════════════════════════════════════════════════════════════ */

/* ── Attach row in entry form ── */
.receipt-attach-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 2px;
}
.btn-attach-receipt {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0 12px;
  height: 38px;
  width: 100%;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}
.btn-attach-receipt:hover { color: var(--accent); border-color: var(--accent); }
.btn-attach-receipt svg { flex-shrink: 0; }

/* On desktop sidebar the buttons sit side by side */
@media (min-width: 769px) {
  .receipt-attach-row {
    flex-direction: row;
    align-items: center;
  }
  .btn-attach-receipt {
    width: auto;
    flex-shrink: 0;
  }
}

/* ── Pending receipts preview list (under form) ── */
.pending-receipts-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}
.receipt-pending-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
}
.receipt-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
}
.receipt-pdf-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  flex-shrink: 0;
}
.receipt-pending-info {
  flex: 1;
  min-width: 0;
}
.receipt-pending-name {
  font-size: 0.8rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.receipt-pending-size {
  font-size: 0.72rem;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  margin-top: 2px;
}
.receipt-pending-remove {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 4px 6px;
  border-radius: 4px;
  flex-shrink: 0;
  transition: color 0.15s;
}
.receipt-pending-remove:hover { color: var(--danger); }

/* ── Entry modal receipts section ── */
.em-receipts-section {
  border-top: 1px solid var(--border);
  padding: 12px 20px 16px;
}
.em-receipts-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.em-receipts-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.74rem;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.em-add-receipt-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 4px 10px;
  transition: color 0.15s, border-color 0.15s;
}
.em-add-receipt-btn:hover { color: var(--accent); border-color: var(--accent); }

.em-receipts-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.receipt-loading, .receipt-empty {
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
  padding: 8px 0;
}

/* ── Receipt card in entry modal ── */
.receipt-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
}
.receipt-card-preview {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface);
}
.receipt-card-img-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.receipt-card-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: pointer;
}
.receipt-card-spinner { font-size: 1.2rem; }
.receipt-card-info {
  flex: 1;
  min-width: 0;
}
.receipt-card-name {
  font-size: 0.8rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.receipt-card-meta {
  font-size: 0.72rem;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  margin-top: 2px;
}

/* ── Visibility toggle ── */
.receipt-visibility-row {
  display: flex;
  gap: 4px;
  margin-top: 6px;
}
.receipt-vis-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--muted);
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.7rem;
  padding: 2px 8px;
  transition: all 0.15s;
}
.receipt-vis-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--contrast);
  font-weight: 600;
}
.receipt-vis-btn:not(.active):hover { border-color: var(--accent); color: var(--accent); }

/* ── Delete button on receipt card ── */
.receipt-delete-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 4px 6px;
  border-radius: 4px;
  flex-shrink: 0;
  transition: color 0.15s;
}
.receipt-delete-btn:hover { color: var(--danger); }

/* ── Lightbox ── */
.receipt-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.88);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}
.receipt-lightbox.active { display: flex; }
.receipt-lightbox img {
  max-width: 94vw;
  max-height: 92vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 8px 48px rgba(0,0,0,0.6);
}

/* ── Category period navigation (day / week / month / year) ── */
.cat-period-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 0 2px;
  width: 100%;
}
/* Inline variant — lives in the header title row */
.cat-period-nav.cat-period-nav-inline {
  width: auto;
  padding: 0;
  justify-content: flex-start;
  gap: 4px;
}
.cat-period-nav.cat-period-nav-inline .period-nav-label {
  min-width: 88px;
  font-size: 0.78rem;
}
.period-nav-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  padding: 4px 10px;
  display: flex;
  align-items: center;
  transition: border-color 0.15s, color 0.15s;
  flex-shrink: 0;
}
.period-nav-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.period-nav-btn:disabled { opacity: 0.3; cursor: default; }
.period-nav-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  font-family: 'DM Mono', monospace;
  text-align: center;
  flex: 1;
}

/* ══════════════════════════════════════════════════════════════════════════════
   Media & Receipts Modal
   ══════════════════════════════════════════════════════════════════════════════ */

/* ── Header button — green tint to match "media/photo" feel ── */
.btn-media {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  position: relative;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-media .hdr-icon-box {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--info) 13%, transparent);
  color: var(--info);
  transition: transform 0.2s ease, filter 0.2s ease;
}
.btn-media:hover .hdr-icon-box {
  transform: scale(1.12) rotate(-5deg);
  filter: brightness(1.15);
}

/* ── Modal overlay ── */
.media-modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-bg);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 16px;
  opacity: 0;
  transition: opacity 0.2s ease;
  overflow-y: auto;
}
.media-modal-overlay.active { opacity: 1; }

/* ── Modal panel ── */
.media-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 860px;
  min-height: 400px;
  display: flex;
  flex-direction: column;
  transform: translateY(16px);
  transition: transform 0.25s ease;
  overflow: hidden;
}
.media-modal-overlay.active .media-modal { transform: translateY(0); }

/* ── Modal header ── */
.media-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.media-modal-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

/* ── Toolbar ── */
.media-modal-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.media-group-btns { display: flex; gap: 4px; }
.media-group-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.73rem;
  font-weight: 500;
  padding: 5px 10px;
  cursor: pointer;
  transition: all 0.15s;
}
.media-group-btn:hover { color: var(--text); border-color: var(--accent); }
.media-group-btn.active {
  background: color-mix(in srgb, var(--accent) 12%, var(--surface2));
  border-color: var(--accent);
  color: var(--accent);
}
.media-view-btns { display: flex; gap: 3px; }
.media-view-btn {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
}
.media-view-btn:hover { color: var(--text); border-color: var(--accent); }
.media-view-btn.active {
  color: var(--accent);
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--surface2));
}

/* ── Modal body ── */
.media-modal-body {
  padding: 16px 20px 24px;
  overflow-y: auto;
  flex: 1;
}

/* ── Groups ── */
.media-group { margin-bottom: 24px; }
.media-group-header {
  display: flex; align-items: baseline; gap: 8px;
  margin-bottom: 10px;
}
.media-group-label {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.75rem; font-weight: 600;
  color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.media-group-count {
  font-family: 'DM Mono', monospace;
  font-size: 0.68rem; color: var(--muted);
}

/* ── Grid ── */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.media-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.media-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}
.media-card-thumb {
  position: relative;
  aspect-ratio: 1;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.media-thumb-img-wrap {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
}
.media-thumb-img {
  width: 100%; height: 100%;
  object-fit: cover; display: block;
  transition: transform 0.2s ease;
}
.media-card:hover .media-thumb-img { transform: scale(1.04); }
.media-pdf-thumb {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 5px; color: var(--muted);
  font-family: 'DM Mono', monospace;
  font-size: 0.65rem; font-weight: 600; letter-spacing: 0.06em;
}
.media-thumb-spinner { color: var(--muted); }
.media-card-info { padding: 7px 8px 8px; }
.media-card-desc {
  font-size: 0.75rem; font-weight: 500; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 4px;
}
.media-card-meta {
  display: flex; align-items: center; gap: 5px;
  flex-wrap: wrap; margin-bottom: 3px;
}
.media-card-date {
  font-family: 'DM Mono', monospace;
  font-size: 0.65rem; color: var(--muted);
}
.media-cat-chip {
  font-size: 0.65rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px; padding: 1px 5px;
  color: var(--muted); white-space: nowrap;
  max-width: 90px; overflow: hidden; text-overflow: ellipsis;
}
.media-amount {
  font-family: 'DM Mono', monospace;
  font-size: 0.68rem; font-weight: 500; color: var(--text); white-space: nowrap;
}
.media-delete-btn {
  position: absolute; top: 5px; right: 5px;
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(0,0,0,0.55); border: none; color: var(--white-force);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.15s, background 0.15s; z-index: 2;
}
.media-card:hover .media-delete-btn,
.media-list-row:hover .media-delete-btn { opacity: 1; }
.media-delete-btn:hover { background: var(--danger); }

/* ── List ── */
.media-list { display: flex; flex-direction: column; gap: 6px; }
.media-list-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 12px 9px 9px;
  transition: border-color 0.15s, background 0.15s;
}
.media-list-row:hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 5%, var(--surface2));
}
.media-list-thumb {
  width: 44px; height: 44px; border-radius: 7px;
  overflow: hidden; background: var(--bg);
  flex-shrink: 0; display: flex; align-items: center; justify-content: center;
}
.media-list-thumb .media-thumb-img-wrap { width: 44px; height: 44px; }
.media-list-thumb .media-thumb-img { object-fit: cover; }
.media-pdf-thumb-sm { color: var(--muted); }
.media-list-info { flex: 1; min-width: 0; }
.media-list-desc {
  font-size: 0.82rem; font-weight: 500; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 4px;
}
.media-list-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.media-list-date {
  font-family: 'DM Mono', monospace; font-size: 0.68rem; color: var(--muted);
}
.media-list-right {
  display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex-shrink: 0;
}
.media-list-size {
  font-family: 'DM Mono', monospace; font-size: 0.65rem; color: var(--muted);
}
.media-delete-btn-list {
  position: static; opacity: 0;
  background: none; color: var(--muted);
  width: 20px; height: 20px; border-radius: 4px;
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.15s, color 0.15s, background 0.15s;
}
.media-list-row:hover .media-delete-btn-list { opacity: 1; }
.media-delete-btn-list:hover {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 12%, transparent);
}

/* ── States ── */
.media-loading {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; color: var(--muted); font-size: 0.82rem; padding: 40px 0;
}
.media-empty {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 48px 20px; color: var(--muted);
  font-size: 0.85rem; text-align: center; gap: 4px;
}
.media-spinner { animation: spin 1s linear infinite; }

/* ── Mobile ── */
@media (max-width: 768px) {
  .btn-media { display: none !important; }
  .media-modal-overlay { padding: 0; align-items: flex-end; }
  .media-modal {
    border-radius: 16px 16px 0 0;
    max-height: 90vh;
    border-bottom: none;
  }
  .media-modal-body { overflow-y: auto; }
  .media-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
  .media-group-btn { font-size: 0.7rem; padding: 5px 8px; }
  .media-delete-btn { opacity: 1; }
  .media-delete-btn-list { opacity: 1; }
}

/* ── Media pagination ── */
.media-load-more-btn {
  display: block;
  width: 100%;
  margin-top: 20px;
  padding: 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.media-load-more-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface2));
}
.media-all-loaded {
  margin-top: 20px;
  text-align: center;
  font-family: 'DM Mono', monospace;
  font-size: 0.68rem;
  color: var(--muted);
  padding: 8px 0;
}

/* ── Receipt badge — corner pip on category icon ── */
.entry-receipt-badge {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--info);
  border: 2px solid var(--surface);
  display: block;
  pointer-events: none;
}

/* ── Media card info zone — separated from thumb ── */
.media-card-info {
  padding: 7px 8px 8px;
  border-top: 1px solid var(--border);
  transition: background 0.15s;
}
.media-card-info:hover {
  background: color-mix(in srgb, var(--accent) 6%, var(--surface2));
}
.media-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 3px;
}
.media-open-entry-icon {
  color: var(--muted);
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
  flex-shrink: 0;
}
.media-card:hover .media-open-entry-icon {
  opacity: 1;
  color: var(--accent);
}

/* ── List view open-entry button ── */
.media-open-entry-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s, background 0.15s;
}
.media-list-row:hover .media-open-entry-btn { opacity: 1; }
.media-open-entry-btn:hover {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

/* ── List info zone hover ── */
.media-list-info {
  transition: none;
}
.media-list-row:hover .media-list-info .media-list-desc {
  color: var(--accent);
}

/* Mobile — always show badges/buttons */
@media (max-width: 768px) {
  .media-open-entry-icon { opacity: 1; }
  .media-open-entry-btn  { opacity: 1; }
}
