/* Editorial fonts — only used by the light theme. Loaded eagerly so toggling
   into light mode is instant; ~50KB cached one-time cost. */
@import url('https://fonts.googleapis.com/css2?family=Newsreader:opsz,wght@6..72,300..700&family=Public+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  /* Dark theme tokens (default — Geri's original look) */
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-2: #273449;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #34d399;
  --accent-2: #34d399;
  --danger: #f87171;
  --expense: #fb7185;   /* coral — "money out"; distinct from danger red */
  --border: #334155;
  --rule: #334155;

  /* Font stacks — overridden by .theme-light to swap in editorial families */
  --font-ui:    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  --font-serif: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  --font-mono:  -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;

  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

/* ============================================================
   Light theme — warm paper palette + editorial typography.
   Activated by adding `.theme-light` to <html>. Overrides tokens
   first, then layout/typography for sections that need editorial
   treatment per the mockup at mockup/app-redesign.html.
   ============================================================ */
html.theme-light {
  --bg: #F4EFE5;
  --panel: #FAF7EE;
  --panel-2: #EFE9DC;
  --text: #1A1A1F;
  --muted: #8B847A;
  --accent: #1F5C3A;
  --accent-2: #B8956A;
  --danger: #A33A3A;
  --expense: #C2410C;   /* warm terracotta — readable "money out" on paper bg */
  --border: #D9CFBE;
  --rule: #D9CFBE;

  --font-ui:    'Public Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-serif: 'Newsreader', Georgia, serif;
  --font-mono:  'JetBrains Mono', ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

button {
  font-family: inherit;
  touch-action: manipulation;       /* kills the 300ms double-tap zoom delay */
  -webkit-touch-callout: none;      /* no iOS long-press context menu */
  user-select: none;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: contain;     /* no pull-to-refresh full-reload on Android Chrome */
}

body {
  min-height: 100dvh;
  /* Clear the fixed bottom tab bar (~64px) plus the iOS home indicator. */
  padding-bottom: calc(76px + var(--safe-bottom));
}

.topbar {
  padding: calc(16px + var(--safe-top)) 16px 12px;
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
  position: sticky;
  top: 0;
  z-index: 5;
}
/* Slim header now that totals moved into the Home view — just identity + theme. */
.topbar.topbar-slim { padding-bottom: 10px; }
.topbar.topbar-slim .topbar-row { margin-bottom: 0; }

/* ============================================================
   Bottom tab bar + views + add sheet (app shell).
   ============================================================ */

/* Each tab maps to one view; only the active one is shown. */
.view { display: none; }
.view.active { display: block; }

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 12;
  background: var(--panel);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr 1fr 70px 1fr 1fr;
  align-items: center;
  padding: 8px 4px calc(8px + var(--safe-bottom));
}
.tab {
  background: none; border: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--muted); font-size: 10.5px; font-weight: 600;
  padding: 4px 0; font-family: inherit;
  transition: color 0.15s;
}
.tab svg {
  width: 22px; height: 22px;
  stroke: currentColor; fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.tab.active { color: var(--accent); }
.tab:active { transform: scale(0.94); }

/* Center add button — overlaps the bar top edge. */
.tab-fab {
  width: 58px; height: 58px; border-radius: 50%;
  background: var(--accent); color: #04261b;
  border: none; cursor: pointer;
  display: grid; place-items: center;
  margin: -24px auto 0;
  box-shadow: 0 8px 20px rgba(52, 211, 153, 0.45);
  transition: transform 0.12s;
}
.tab-fab:active { transform: scale(0.92); }
.tab-fab svg {
  width: 28px; height: 28px;
  stroke: currentColor; fill: none;
  stroke-width: 2.6; stroke-linecap: round;
}

/* Add sheet — slides up from the bottom; backdrop dims the rest. */
.sheet-backdrop {
  position: fixed; inset: 0;
  z-index: 18;
  background: rgba(0, 0, 0, 0.5);
}
.add-sheet {
  position: fixed; left: 0; right: 0; bottom: 0;
  z-index: 19;
  background: var(--panel);
  border-top: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  padding: 10px 16px calc(18px + var(--safe-bottom));
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.3);
  animation: sheet-up 0.24s cubic-bezier(0.2, 0.7, 0.2, 1);
}
@keyframes sheet-up {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
.sheet-grip {
  width: 40px; height: 4px; border-radius: 999px;
  background: var(--border);
  margin: 2px auto 14px;
}
/* Add-date chip — the native date input overlays the chip transparently so the
   whole pill is the tap target. */
.add-date-chip {
  position: relative;
  display: inline-flex; align-items: center; gap: 7px;
  margin-top: 10px;
  padding: 7px 13px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px; font-weight: 600;
  cursor: pointer;
}
.add-date-chip svg {
  width: 15px; height: 15px;
  stroke: currentColor; fill: none; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}
.add-date-chip #addDateLabel.set { color: var(--accent); }
.add-date-chip input[type="date"] {
  position: absolute; inset: 0;
  opacity: 0; width: 100%; height: 100%;
  border: none; padding: 0; margin: 0; cursor: pointer;
}
html.theme-light .add-date-chip {
  background: var(--bg); border-color: var(--rule);
  font-family: var(--font-mono); font-size: 11px;
  letter-spacing: 0.06em; text-transform: uppercase;
}

/* "More" tab — settings list (replaces the old ⋮ dropdown). */
.more-list { display: flex; flex-direction: column; }
.more-item {
  background: transparent; border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text); font: inherit; font-size: 15px;
  text-align: left; cursor: pointer;
  padding: 16px 4px;
  transition: background 0.15s;
}
.more-item:active { background: var(--panel-2); }
.more-item.danger { color: var(--danger); }
/* Rows that show their current value on the right (Currency, Language). */
.more-item-value { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.more-item-current { color: var(--muted); font-weight: 600; }

/* ============================================================
   Balance hero — balance on top + tappable Income / Expenses halves.
   ============================================================ */
.hero {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px 14px 14px;
}
.hero-top {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  color: var(--muted); font-size: 12px;
}
.hero-label { letter-spacing: 0.03em; }
.hero-balance {
  text-align: center;
  font-size: clamp(28px, 9vw, 38px);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-top: 4px;
  color: var(--text);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.hero-balance.negative { color: var(--expense); }
/* Currency unit — smaller + muted, attached to the number on one line. */
.total-unit { font-size: 0.55em; font-weight: 700; color: var(--muted); margin-left: 1px; }
.hero-delta {
  text-align: center; font-size: 11.5px; margin-top: 4px;
  font-variant-numeric: tabular-nums; color: var(--muted);
}
.hero-delta.up   { color: var(--expense); }   /* spent more than last month */
.hero-delta.down { color: var(--accent); }    /* spent less — good */
/* Carry-over line — "including +200 carried over" under the balance. */
.hero-carry {
  text-align: center; font-size: 11.5px; margin-top: 5px;
  color: var(--muted); font-variant-numeric: tabular-nums;
}
.hero-carry b { color: var(--accent); font-weight: 700; }
.hero-carry b.neg { color: var(--expense); }

.hero-split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.hero-half {
  display: flex; align-items: center; gap: 9px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 11px;
  cursor: pointer; font: inherit; text-align: left; color: inherit;
  transition: transform 0.12s, border-color 0.15s;
}
.hero-half:active { transform: scale(0.97); }
.hero-half:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hero-ic { width: 30px; height: 30px; border-radius: 50%; flex: none; display: grid; place-items: center; }
.hero-ic svg { width: 16px; height: 16px; stroke-width: 2.4; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.hero-ic.inc { background: color-mix(in srgb, var(--accent) 20%, transparent); }
.hero-ic.inc svg { stroke: var(--accent); }
.hero-ic.exp { background: color-mix(in srgb, var(--expense) 20%, transparent); }
.hero-ic.exp svg { stroke: var(--expense); }
.hero-half .h-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.hero-half .h-amt { font-size: 15px; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hero-half .h-amt.inc { color: var(--accent); }
.hero-half .h-amt.exp { color: var(--expense); }
.hero-half .h-amt .total-unit { font-size: 0.62em; color: inherit; opacity: 0.75; }
.hero-half .h-cap { font-size: 10.5px; color: var(--muted); margin-top: 1px; }
.hero-half .h-chev { color: var(--muted); flex: none; display: grid; place-items: center; }
.hero-half .h-chev svg { width: 15px; height: 15px; stroke: currentColor; stroke-width: 2.2; fill: none; }

/* Income / Expenses drill-in sheet */
.fullsheet-spacer { width: 28px; }
.filter-summary { padding: 4px 2px 10px; }
.filter-total { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.filter-total.income  { color: var(--accent); }
.filter-total.expense { color: var(--expense); }
.filter-people { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; color: var(--muted); font-size: 12px; }
.filter-people strong { color: var(--text); font-weight: 600; }

main {
  padding: 16px;
  max-width: 560px;
  margin: 0 auto;
}

/* Two-row layout: Amount gets the full width (it's typed every time and
   often has 5 digits — squeezing it into 25% of a row is daily friction).
   Note + Add share the second row, where Note is the elastic field. */
#addForm {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "amount amount"
    "note   add";
  gap: 8px;
  margin-bottom: 20px;
}
#amount { grid-area: amount; font-size: 18px; font-weight: 600; }
#note   { grid-area: note;   }
#addBtn { grid-area: add;    }

#addForm input,
#addForm button {
  height: 48px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 16px;
  padding: 0 14px;
  outline: none;
}

#addForm input:focus {
  border-color: var(--accent);
}

#addForm button {
  background: var(--accent);
  color: #0f172a;
  font-weight: 600;
  border: none;
  padding: 0 22px;
  cursor: pointer;
}

#addForm button:active { transform: scale(0.97); }

.chart-section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 20px;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.chart-total {
  color: var(--text);
  font-weight: 600;
}

/* Range selector above the trend chart — segmented pill (Week/Month/6M/Year). */
.range-toggle {
  display: flex;
  gap: 4px;
  background: var(--panel-2);
  border-radius: 999px;
  padding: 3px;
  margin-bottom: 12px;
}
.range-btn {
  flex: 1;
  border: none;
  background: none;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  padding: 7px 4px;
  border-radius: 999px;
  transition: background 0.15s, color 0.15s;
}
.range-btn.active { background: var(--accent); color: #04261b; }

/* 30-day trend chart — inline SVG line. color:var(--accent) drives the line,
   dot, and gradient (all use currentColor), so it follows the theme. */
.chart-svg {
  width: 100%;
  height: 130px;
  display: block;
  color: var(--accent);
  overflow: visible;
}
.chart-svg .chart-line {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.chart-svg .chart-grid {
  stroke: var(--rule);
  stroke-width: 1;
  stroke-dasharray: 3 5;
}
.chart-svg .chart-dot {
  fill: currentColor;
  stroke: var(--panel);
  stroke-width: 2.5;
}
.chart-x {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  padding: 0 2px;
  color: var(--muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

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

.list-header h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0;
}

.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  min-height: 40px;
  padding: 0 14px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
}

@media (hover: hover) {
  .ghost:hover { color: var(--text); border-color: var(--accent); }
}
.ghost:active { color: var(--text); background: var(--panel-2); border-color: var(--accent); }

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.list li {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 10px;
  align-items: center;
}

/* Icon chip on each list row — tap to recategorize. Sized for thumbs. */
.row-cat {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: 0 0 auto;
  transition: color 0.15s, background 0.15s;
}
.row-cat svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.row-cat:active { background: var(--panel); transform: scale(0.95); color: var(--accent); }
.row-cat:disabled { cursor: default; opacity: 0.7; }
.row-cat.is-other { border-style: dashed; opacity: 0.7; }

.list .day-divider {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 12px;
  padding: 12px 4px 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  /* Span the full 4-column grid so the date and total flank cleanly. */
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.list .day-divider .day-total {
  color: var(--text);
  font-weight: 600;
}

.row-main {
  min-width: 0;
}

.row-note {
  color: var(--text);
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-note.empty-note {
  color: var(--muted);
  font-style: italic;
}

.row-time {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.row-amount {
  font-size: 17px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
/* Signed timeline: expenses coral (money out), income green (money in).
   Coral is deliberately NOT the danger red — danger stays reserved for
   delete/over-budget so a real warning still stands out. */
.row-amount.expense { color: var(--expense); }
.row-amount.income  { color: var(--accent); font-weight: 700; }
.row-cat.is-income  { color: var(--accent); border-style: solid; }
/* Net day total: green when the day was net-positive, coral when net-negative. */
.list .day-divider .day-total.net-pos { color: var(--accent); }
.list .day-divider .day-total.net-neg { color: var(--expense); }

.row-delete {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 22px;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  cursor: pointer;
  line-height: 1;
}

@media (hover: hover) {
  .row-delete:hover { color: var(--danger); background: rgba(248,113,113,0.08); }
}
.row-delete:active { color: var(--danger); background: rgba(248,113,113,0.18); }

.empty {
  color: var(--muted);
  text-align: center;
  padding: 24px 12px;
  background: var(--panel);
  border: 1px dashed var(--border);
  border-radius: 12px;
}

.topbar-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.who { color: var(--muted); font-size: 13px; }
.who strong { color: var(--text); font-weight: 600; }

.ghost.small {
  width: 40px;
  min-height: 40px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
}

.person-chip {
  display: inline-block;
  font-size: 11px;
  color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 999px;
  margin-left: 6px;
  vertical-align: middle;
  text-transform: lowercase;
  letter-spacing: 0.02em;
}

.setup {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.setup-card {
  width: 100%;
  max-width: 360px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.setup-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.setup-logo {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  display: block;
}

/* Theme-aware brand logo (inline SVG). Night: green wallet on dark navy.
   Day: cream wallet on deep-green — a dedicated light-mode variant that
   sits warmly on the cream card instead of a heavy dark badge. */
.bl-coin { fill: #0f172a; }
.bl-mark { stroke: #34d399; }
.bl-dot  { fill: #34d399; stroke: none; }
html.theme-light .bl-coin { fill: #1F5C3A; }
html.theme-light .bl-mark { stroke: #F4EFE5; }
html.theme-light .bl-dot  { fill: #F4EFE5; }
.setup-card h1 { margin: 0; font-size: 22px; color: var(--accent); }
.setup-sub { margin: 0; color: var(--muted); font-size: 14px; }

/* Password input with show/hide eye toggle */
.pw-wrap {
  position: relative;
  display: block;
}
.pw-wrap input {
  width: 100%;
  padding-right: 44px;
  /* match other inputs */
  height: 46px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  padding-left: 12px;
  outline: none;
  box-sizing: border-box;
}
.pw-wrap input:focus { border-color: var(--accent); }
/* Matches the password-toggle pattern from the Booking dashboard project:
   transparent by default, subtle hover/focus background, two SVGs swapped
   via the .is-visible class on the button. */
.pw-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: rgba(232, 232, 240, 0.55);
  width: 40px;
  height: 40px;
  padding: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: color 0.15s, background 0.15s;
}
@media (hover: hover) {
  .pw-toggle:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }
}
.pw-toggle:focus-visible {
  outline: none;
  color: var(--text);
  background: rgba(120, 144, 255, 0.12);
}

.pw-toggle .eye {
  width: 20px;
  height: 20px;
  display: block;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.pw-toggle .eye-off { display: none; }
.pw-toggle.is-visible .eye-on  { display: none; }
.pw-toggle.is-visible .eye-off { display: block; }
/* Inside modals, the input sits in the panel — give it a slightly different bg */
.modal-card .pw-wrap input { background: var(--bg); }

.setup-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.setup-card input {
  height: 46px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  padding: 0 12px;
  outline: none;
}
.setup-card input:focus { border-color: var(--accent); }

/* Primary submit button styling. Excludes .pw-toggle — the eye icon lives
   inside the same form but must stay backgroundless. */
.setup-card button:not(.pw-toggle) {
  height: 46px;
  border-radius: 10px;
  background: var(--accent);
  color: #0f172a;
  font-weight: 600;
  border: none;
  font-size: 16px;
  cursor: pointer;
}
.setup-card button:not(.pw-toggle):active { transform: scale(0.98); }

.setup-error { margin: 0; color: var(--danger); font-size: 13px; }

.reg-back {
  margin: 4px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.reg-back a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  margin-left: 4px;
}
.reg-back a:active { opacity: 0.7; }

.status {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  margin: 16px 0 0;
}
.status.error { color: var(--danger); }

/* Compact dropdown menu — anchored to the ⋮ button (top-right) */
.dropdown-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9;
  background: transparent;
}
.dropdown {
  position: fixed;
  top: calc(var(--safe-top) + 56px);
  right: 12px;
  z-index: 10;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px;
  min-width: 220px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: dropdown-in 110ms ease-out;
}
@keyframes dropdown-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.dropdown-item {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 15px;
  padding: 12px 14px;
  text-align: left;
  border-radius: 8px;
  cursor: pointer;
}
.dropdown-item:hover, .dropdown-item:active { background: var(--panel-2); }
.dropdown-item.danger { color: var(--danger); }

/* Month navigator inside the month card */
.month-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.nav-arrow {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 22px;
  width: 40px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}
@media (hover: hover) {
  .nav-arrow:hover:not(:disabled) { color: var(--text); background: var(--panel-2); }
}
.nav-arrow:active:not(:disabled) { color: var(--text); background: var(--panel-2); }
.nav-arrow:disabled { opacity: 0.25; cursor: default; }

/* Quick-add note chips */
.quick-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: -12px;
  margin-bottom: 20px;
}
.quick-chip {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  min-height: 34px;
}
@media (hover: hover) {
  .quick-chip:hover { color: var(--text); border-color: var(--accent); }
}
.quick-chip:active { color: var(--text); border-color: var(--accent); background: var(--panel-2); }

/* Bills section */
.bills-section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 20px;
}
.bills-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 10px;
}
.bills-header strong { color: var(--text); }
.bills-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.bill-card {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}
.bill-card.paid { border-color: rgba(52, 211, 153, 0.4); background: rgba(52, 211, 153, 0.05); }
.bill-card.overdue { border-color: rgba(248, 113, 113, 0.5); background: rgba(248, 113, 113, 0.06); }
.bill-card.due-soon { border-color: rgba(250, 204, 21, 0.45); }
.bill-name {
  font-size: 15px;
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bill-meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}
.bill-meta.paid { color: var(--accent); }
.bill-meta.overdue { color: var(--danger); }
.bill-amount {
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.bill-amount.unknown { color: var(--muted); font-weight: 500; }
.bill-pay-btn {
  background: var(--accent);
  color: #0f172a;
  border: none;
  font-weight: 600;
  font-size: 14px;
  padding: 10px 18px;
  border-radius: 8px;
  cursor: pointer;
  min-height: 40px;
}
.bill-pay-btn:active { transform: scale(0.95); }
.bill-pay-btn.paid { background: transparent; color: var(--accent); cursor: default; padding: 6px 4px; min-height: 0; transform: none; }

.no-bills {
  background: var(--panel);
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 20px;
  text-align: center;
}
.no-bills p { margin: 0 0 10px; color: var(--muted); font-size: 14px; }
.no-bills button {
  background: var(--accent);
  color: #0f172a;
  border: none;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  min-height: 40px;
}
.no-bills button:active { transform: scale(0.97); }

/* Modals (centered card) */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 20;
  padding: 16px;
}
.modal-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  width: 100%;
  max-width: 380px;
  display: flex; flex-direction: column;
  gap: 12px;
  /* When the on-screen keyboard cuts the modal in half, let the card
     scroll internally instead of the buttons being hidden. */
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.modal-card h3 { margin: 0; font-size: 17px; color: var(--text); }
.modal-sub { margin: 0; color: var(--muted); font-size: 13px; }
.modal-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.modal-card input {
  height: 42px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font-size: 16px; padding: 0 12px; outline: none;
}
.modal-card input:focus { border-color: var(--accent); }
.modal-actions {
  display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px;
}
.modal-actions button {
  min-height: 44px; padding: 0 18px; border-radius: 10px;
  background: var(--accent); color: #0f172a; font-weight: 600; border: none; cursor: pointer;
  font-size: 15px;
}
.modal-actions button:active { transform: scale(0.97); }
.modal-actions button.ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.modal-actions button.danger { background: var(--danger); color: #fff; }
.modal-actions-split { justify-content: space-between; }
.modal-actions-right { display: flex; gap: 8px; }
.danger-text {
  background: transparent; border: none; color: var(--danger); cursor: pointer; font-size: 14px; padding: 0 8px;
}

/* Full-screen sheet (manage bills) */
.fullsheet {
  position: fixed; inset: 0;
  background: var(--bg);
  z-index: 15;
  display: flex; flex-direction: column;
}
.fullsheet-header {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: calc(12px + var(--safe-top)) 16px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.fullsheet-header h2 { margin: 0; font-size: 16px; text-align: center; }
.fullsheet-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  padding-bottom: calc(16px + var(--safe-bottom));
}
.manage-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.manage-list li {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  cursor: pointer;
}
.manage-list .manage-name { font-size: 15px; color: var(--text); }
.manage-list .manage-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.manage-list .manage-amt { font-size: 14px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.manage-list .manage-amt.unknown { color: var(--muted); font-weight: 500; }

.small-text { font-size: 13px; padding: 0 12px; min-height: 36px; }
.row-edit-hint { font-size: 11px; color: var(--muted); }

/* Language picker — two big tappable options inside a modal */
.lang-options {
  display: flex;
  gap: 8px;
}
.lang-option {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 12px;
  font-size: 14px;
  cursor: pointer;
  min-height: 88px;
}
.lang-option.active {
  border-color: var(--accent);
  background: rgba(52, 211, 153, 0.08);
}
.lang-option:active { transform: scale(0.98); background: var(--panel-2); }
.lang-flag { font-size: 28px; line-height: 1; }
.lang-name { font-weight: 600; }

/* Categories this month — bar-chart-style breakdown below the 30-day chart. */
.cat-section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 16px;
}
.cat-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 10px;
}
.cat-total { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.cat-list { display: block; }

/* Spendee-style report: thin donut ring on the left, color legend on the right. */
.cat-report { display: flex; align-items: center; gap: 16px; }
.cat-donut {
  position: relative;
  width: 120px; height: 120px; flex: none;
  border-radius: 50%;
}
.cat-donut::after {                 /* hole reveals the card color → thin ring */
  content: '';
  position: absolute; inset: 11px;
  background: var(--panel);
  border-radius: 50%;
}
.cat-donut-center {
  position: absolute; inset: 0; z-index: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center; padding: 0 10px;
}
.cat-donut-center b {
  color: var(--text); font-size: 15px; font-weight: 700;
  font-variant-numeric: tabular-nums; line-height: 1.1;
}
.cat-donut-center i {
  color: var(--muted); font-size: 9px; font-style: normal;
  text-transform: uppercase; letter-spacing: 0.1em; margin-top: 3px;
}
.cat-legend { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cat-row {
  display: flex; align-items: center; gap: 10px;
  /* a <button> so the row is tappable — reset native button chrome */
  background: transparent; border: none;
  width: 100%; text-align: left; cursor: pointer;
  color: inherit; font: inherit;
  padding: 8px 4px; border-radius: 8px;
  transition: background 0.15s;
}
.cat-row + .cat-row { border-top: 1px solid var(--rule); }
.cat-row:active { background: var(--panel-2); }
.cat-row:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cat-dot { width: 11px; height: 11px; border-radius: 3px; flex: none; }
.cat-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.cat-row-name {
  color: var(--text); font-size: 13.5px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cat-row-amount {
  color: var(--muted); font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}
.cat-row-budget {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px; margin-left: 3px;
}
.cat-row-pct {
  flex: none; font-size: 14px; font-weight: 800;
  font-variant-numeric: tabular-nums;
}
/* Budget status — tint the amount line when near/over (no per-row bar now). */
.cat-row.near .cat-row-amount { color: #d99a00; }
.cat-row.over .cat-row-amount { color: var(--danger); }
.cat-hint {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

/* Category picker modal — grid of options, current one highlighted. */
.cat-picker-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 10px 0 6px;
}
.cat-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  min-height: 52px;
  text-align: left;
}
.cat-option.active {
  border-color: var(--accent);
  background: rgba(52, 211, 153, 0.08);
}
.cat-option:active { transform: scale(0.98); background: var(--panel-2); }
.cat-option-emoji {
  display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
  width: 28px; height: 28px;
  color: var(--muted);
}
.cat-option-emoji svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.cat-option.active .cat-option-emoji { color: var(--accent); }
.cat-option-name  { font-weight: 600; }

@media (max-width: 380px) {
  /* Hero balance sizing is handled by clamp() (never wraps). */
  .row-cat { width: 32px; height: 32px; font-size: 16px; }
}

/* ============================================================
   INCOME — add-form toggle, month net line, income section.
   Reuses .bills-section / .list / .row-delete / .person-chip.
   ============================================================ */

/* Expense / income segmented toggle above the add form */
.add-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  margin-bottom: 8px;
}
.add-toggle-btn {
  height: 34px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.add-toggle-btn.active {
  background: var(--accent);
  color: #0f172a;
}
/* Income mode: tint the Add button so the form reads as "income" */
#addForm.income-mode #addBtn { background: #22c55e; }

/* Income list rows (mirror .list li grid, no category chip) */
.income-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 6px;
}
.income-main { min-width: 0; }
.income-note {
  color: var(--text);
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.income-note.empty-note { color: var(--muted); font-style: italic; }
.income-time { color: var(--muted); font-size: 12px; margin-top: 2px; }
.income-amount {
  font-size: 17px;
  font-weight: 600;
  color: #22c55e;
  font-variant-numeric: tabular-nums;
}

/* ---- Light-theme overrides ---- */
html.theme-light .add-toggle { background: var(--panel); border-color: var(--rule); }
html.theme-light .add-toggle-btn {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
html.theme-light .add-toggle-btn.active { background: var(--accent); color: var(--bg); }
html.theme-light #addForm.income-mode #addBtn { background: var(--accent); }
html.theme-light .income-card { background: var(--panel); border-color: var(--rule); }
html.theme-light .income-note { color: var(--text); }
html.theme-light .income-time {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
html.theme-light .income-amount {
  font-family: var(--font-serif);
  font-size: 16px;
  color: var(--accent);
}

/* ============================================================
   Category drill-in (fullsheet) — opened by tapping a row in
   the categories breakdown. Header row with title + month +
   close, then a budget block (current total, budget value,
   progress bar, set/edit button), then the filtered list of
   expenses in that category for the viewed month.
   ============================================================ */
.cat-detail-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}
.cat-detail-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}
.cat-detail-icon svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.cat-detail-month {
  font-size: 12px;
  color: var(--muted);
  margin-left: auto;
}
.cat-detail-budget-block {
  margin-bottom: 18px;
  padding: 14px 14px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.cat-detail-amount-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}
.cat-detail-amount {
  font-size: 26px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.cat-detail-budget {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.cat-detail-budget.near { color: #fbbf24; }
.cat-detail-budget.over { color: var(--danger); }
.cat-detail-bar {
  height: 6px;
  background: var(--panel-2);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 10px;
}
.cat-detail-bar > span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.25s ease-out, background 0.15s;
}
.cat-detail-budget-block:has(.cat-detail-budget.near) .cat-detail-bar > span { background: #fbbf24; }
.cat-detail-budget-block:has(.cat-detail-budget.over) .cat-detail-bar > span { background: var(--danger); }

/* Light-theme tweaks for the drill-in */
html.theme-light .cat-detail-budget-block {
  background: var(--panel);
  border-color: var(--rule);
  border-radius: 14px;
}
html.theme-light .cat-detail-amount {
  font-family: var(--font-serif);
  font-weight: 380;
  letter-spacing: -0.02em;
  font-variation-settings: 'opsz' 72;
}
html.theme-light .cat-detail-budget {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
html.theme-light .cat-detail-title { font-family: var(--font-serif); font-weight: 500; letter-spacing: -0.01em; }
html.theme-light .cat-detail-month {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

/* ============================================================
   THEME-LIGHT OVERRIDES
   The HTML doesn't change — these rules adopt the editorial
   styling (serif money values, mono small-caps labels, combined
   totals card with hairline divider, etc.) only when the user
   has toggled into light mode. Dark theme keeps its original
   look untouched (the rules above are still authoritative there).
   ============================================================ */

/* Topbar — drop the slate gradient, sit on the warm paper bg */
html.theme-light .topbar {
  background: var(--bg);
  border-bottom: 1px solid var(--rule);
}

/* "Adding as" label */
html.theme-light .who {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}
html.theme-light .who strong {
  font-family: var(--font-ui);
  font-size: 13px;
  letter-spacing: normal;
  text-transform: none;
  color: var(--text);
  font-weight: 600;
  margin-left: 6px;
}

/* Balance hero — editorial treatment: serif balance, mono uppercase labels,
   warm paper surfaces for the two halves. */
html.theme-light .hero {
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 16px;
}
html.theme-light .hero-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}
html.theme-light .hero-balance {
  font-family: var(--font-serif);
  font-weight: 420;
  letter-spacing: -0.02em;
  font-variation-settings: 'opsz' 72;
}
html.theme-light .hero-balance .total-unit { font-family: var(--font-mono); font-weight: 500; }
html.theme-light .hero-delta,
html.theme-light .hero-carry {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
html.theme-light .hero-half {
  background: var(--bg);
  border-color: var(--rule);
}
html.theme-light .hero-half .h-amt { font-family: var(--font-serif); font-weight: 500; }
html.theme-light .hero-half .h-cap {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
/* Drill-in sheet */
html.theme-light .filter-total { font-family: var(--font-serif); font-weight: 500; }
html.theme-light .filter-people {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
html.theme-light .filter-people strong { font-family: var(--font-serif); text-transform: none; font-size: 13px; color: var(--text); }
html.theme-light #filterTitle { font-family: var(--font-serif); font-weight: 500; }
html.theme-light .nav-arrow { color: var(--accent-2); }

/* Add form — bigger serif amount, smaller note + button row */
html.theme-light #addForm {
  margin: 18px 0;
}
html.theme-light #addForm input,
html.theme-light #addForm button {
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 12px;
  color: var(--text);
}
html.theme-light #amount {
  height: 54px;
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 380;
  letter-spacing: -0.02em;
  color: var(--text);
  padding: 0 18px;
}
html.theme-light #amount::placeholder {
  color: var(--muted);
  font-style: italic;
  opacity: 0.6;
}
html.theme-light #note { height: 44px; font-size: 14px; }
html.theme-light #addBtn {
  background: var(--accent);
  color: var(--bg);
  border: none;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  height: 44px;
}

/* Quick-add chips */
html.theme-light .quick-chip {
  background: var(--panel);
  border: 1px solid var(--rule);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* Chart */
html.theme-light .chart-section {
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 14px;
  padding: 14px 16px;
}
html.theme-light .range-btn.active { color: #fff; }
html.theme-light .chart-header {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}
html.theme-light .chart-total {
  font-family: var(--font-serif);
  font-size: 13px;
  letter-spacing: -0.005em;
  text-transform: none;
  color: var(--text);
  font-weight: 500;
}

/* Categories — editorial card */
html.theme-light .cat-section {
  background: var(--panel);
  border-color: var(--rule);
  border-radius: 14px;
}
html.theme-light .cat-header {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}
html.theme-light .cat-total {
  font-family: var(--font-serif);
  font-size: 13px;
  letter-spacing: -0.005em;
  color: var(--text);
}
html.theme-light .cat-row-name { color: var(--text); font-weight: 600; font-size: 13.5px; }
html.theme-light .cat-row-amount {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--muted);
}
html.theme-light .cat-donut-center b { font-family: var(--font-serif); font-weight: 600; }
html.theme-light .cat-donut-center i { font-family: var(--font-mono); }
html.theme-light .cat-hint {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* Bills section */
html.theme-light .bills-section { background: transparent; border: none; padding: 0; }
html.theme-light .bills-header {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 4px 10px;
}
html.theme-light .bills-header strong { color: var(--text); }
html.theme-light .bill-card {
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 12px;
}
html.theme-light .bill-name { color: var(--text); font-weight: 500; }
html.theme-light .bill-meta {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
html.theme-light .bill-meta.paid    { color: var(--accent); }
html.theme-light .bill-meta.overdue { color: var(--danger); }
html.theme-light .bill-amount {
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
}
html.theme-light .bill-pay-btn {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--text);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
html.theme-light .bill-pay-btn.paid { border-color: var(--accent); color: var(--accent); }

/* Recent list — editorial day divider + serif amounts */
html.theme-light .list li {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--rule);
  border-radius: 0;
  padding: 10px 4px;
}
html.theme-light .list li:last-child { border-bottom: 1px solid var(--rule); }
html.theme-light .day-divider {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text);              /* was --muted — too faint on cream */
  font-weight: 600;
  border-bottom: 1px solid var(--rule);
  /* Generous top padding so "Sot" / "Dje" reads as a section break,
     not part of the previous day's entries. */
  padding: 26px 4px 10px;
}
/* First divider sits right under "Të fundit" — no extra top space needed. */
html.theme-light .list > .day-divider:first-child { padding-top: 6px; }
html.theme-light .day-divider .day-total {
  font-family: var(--font-serif);
  font-size: 14px;
  letter-spacing: -0.005em;
  text-transform: none;
  color: var(--text);
  font-weight: 600;
  font-variation-settings: 'opsz' 36;
}
html.theme-light .row-note { color: var(--text); }
html.theme-light .row-time {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
html.theme-light .row-amount {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
}
html.theme-light .person-chip {
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--muted);
  font-family: var(--font-mono);
  letter-spacing: 0.14em;
}
html.theme-light .row-cat {
  background: transparent;
  border-color: var(--rule);
  color: var(--muted);
}
html.theme-light .row-cat:active { background: var(--panel); color: var(--accent); }
html.theme-light .list-header h2 {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text);
  text-transform: none;
}

/* Setup / login / register cards */
html.theme-light .setup-card,
html.theme-light .modal-card,
html.theme-light .dropdown,
html.theme-light .fullsheet,
html.theme-light .fullsheet-header,
html.theme-light .fullsheet-body {
  background: var(--panel);
  border-color: var(--rule);
}
html.theme-light .setup-card h1 {
  font-family: var(--font-serif);
  font-weight: 500;
  color: var(--accent);
}
html.theme-light .setup-card button:not(.pw-toggle) {
  background: var(--accent);
  color: var(--bg);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 600;
}
html.theme-light .setup-card input,
html.theme-light .pw-wrap input,
html.theme-light .modal-card input {
  background: var(--bg);
  border-color: var(--rule);
  color: var(--text);
}

/* Status / error */
html.theme-light .setup-error,
html.theme-light .status.error { color: var(--danger); }

/* Modals + dropdown */
html.theme-light .modal { background: rgba(26, 26, 31, 0.55); }
html.theme-light .dropdown-item { color: var(--text); }
html.theme-light .dropdown-item.danger { color: var(--danger); }

/* Tab bar + sheet + More list */
html.theme-light .tabbar { background: var(--panel); border-top-color: var(--rule); }
html.theme-light .tab-fab { color: #fff; box-shadow: 0 8px 20px rgba(31, 92, 58, 0.4); }
html.theme-light .add-sheet { background: var(--panel); border-top-color: var(--rule); }
html.theme-light .sheet-backdrop { background: rgba(26, 26, 31, 0.5); }
html.theme-light .more-item { color: var(--text); border-bottom-color: var(--rule); }
html.theme-light .more-item.danger { color: var(--danger); }

/* Headings inside modals */
html.theme-light .modal-card h3 {
  font-family: var(--font-serif);
  font-weight: 500;
  letter-spacing: -0.01em;
}

/* ============================================================
   Theme toggle button (.theme-toggle) — sun/moon SVG swap
   ============================================================ */
.theme-toggle {
  width: 40px;
  height: 40px;
  padding: 0;
  background: transparent;
  border: none;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 8px;
  transition: color 0.15s, background 0.15s;
}
@media (hover: hover) {
  .theme-toggle:hover { color: var(--text); background: var(--panel-2); }
}
.theme-toggle:active { color: var(--accent); }
.theme-toggle svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
/* Show sun in dark mode, moon in light mode (the icon represents what
   tapping will SWITCH TO — clearer than "current state"). */
.theme-toggle .icon-sun  { display: block; }
.theme-toggle .icon-moon { display: none; }
html.theme-light .theme-toggle .icon-sun  { display: none; }
html.theme-light .theme-toggle .icon-moon { display: block; }
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ============================================================
   PWA install pill — first-visit nudge centered near the top.
   Floats above content (position: fixed) so it doesn't push the
   layout around when it appears or vanishes.
   ============================================================ */
.install-pill {
  position: fixed;
  top: calc(12px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: var(--accent);
  color: var(--bg);
  padding: 0 6px 0 0;
  border-radius: 999px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.32);
  animation: install-pill-in 280ms cubic-bezier(.2,.7,.2,1);
}
@keyframes install-pill-in {
  from { opacity: 0; transform: translate(-50%, -12px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
.install-pill-action {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 6px 10px 16px;
  background: transparent;
  border: none;
  color: var(--bg);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 999px 0 0 999px;
}
.install-pill-icon { font-size: 16px; line-height: 1; }
.install-pill-dismiss {
  background: transparent;
  border: none;
  color: var(--bg);
  width: 32px;
  height: 32px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 14px;
  opacity: 0.75;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.install-pill-dismiss:active { opacity: 1; background: rgba(0,0,0,0.12); }

/* ============================================================
   iOS install steps modal — three numbered rows with a small
   icon mock per step. Modal-card structure reused.
   ============================================================ */
.ios-install-card { max-width: 380px; }
.ios-install-card h3 {
  font-size: 18px;
  margin-bottom: 6px;
}
.ios-steps {
  list-style: none;
  padding: 0;
  margin: 14px 0 8px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.ios-steps li {
  display: grid;
  grid-template-columns: 26px 44px 1fr;
  align-items: center;
  gap: 14px;
}
.ios-step-num {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.ios-step-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.ios-step-icon svg {
  width: 22px; height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ios-step-icon-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
}
.ios-step-text {
  color: var(--text);
  font-size: 14px;
  line-height: 1.4;
}

/* Light-theme pill — keep brand accent but soften the shadow for paper bg */
html.theme-light .install-pill {
  box-shadow: 0 6px 18px rgba(31, 92, 58, 0.18);
}
html.theme-light .install-pill-action { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; padding-left: 14px; }
html.theme-light .ios-step-icon-text  { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.1em; }
html.theme-light .ios-step-text       { font-size: 14px; }
html.theme-light .ios-install-card h3 { font-family: var(--font-serif); font-weight: 500; letter-spacing: -0.01em; }
