/* =========================================================================
   Paycheck Allocator - design system
   Premium dark "money app" look: near-black canvas, layered surfaces,
   hairline borders, mint accent, large tabular numerals.
   Phone (<1024px): frosted bottom tab bar, single column.
   Laptop (>=1024px): left sidebar, Home + Settings flow into two columns.
   Every class name the JavaScript emits is kept - this file is look only.
   ========================================================================= */

:root {
  color-scheme: dark; /* native date pickers, select lists, scrollbars follow */

  /* surfaces */
  --bg: #07090d;
  --surface: #10141b;
  --surface-2: #171c26;
  --surface-3: #212838;
  --card: #10141b;            /* legacy alias - older rules/inline styles read it */

  /* lines */
  --border: #232a38;          /* solid hairline - JS reads this for chart fallbacks */
  --line: rgba(255, 255, 255, 0.07);

  /* text */
  --text: #f2f5fa;
  --muted: #8f9ab0;
  --faint: #5b6579;

  /* brand + status */
  /* Accent = one hue (Settings > Preferences > Accent color). --accent-l
     is set by applyAccentHue() in index.html so every hue keeps the same
     brightness as the original green (hue 156, ~47% lightness). */
  --accent-h: 156;
  --accent-l: 47%;
  --accent: hsl(var(--accent-h) 75% var(--accent-l));
  --accent-hover: hsl(var(--accent-h) 73% calc(var(--accent-l) + 12%));
  --accent-ink: hsl(var(--accent-h) 75% 5%);      /* text that sits ON the accent color */
  --accent-soft: hsl(var(--accent-h) 75% var(--accent-l) / 0.13);
  --accent-glow: hsl(var(--accent-h) 75% var(--accent-l) / 0.38);
  --accent-outline: hsl(var(--accent-h) 75% var(--accent-l) / 0.22); /* faint accent outlines (cards, rows, controls) */
  --danger: #ff5d73;
  --danger-soft: rgba(255, 93, 115, 0.14);

  /* shape */
  --radius-card: 22px;
  --radius-row: 14px;
  --radius-ctl: 12px;
  --sidebar-w: 248px;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.4;
  letter-spacing: -0.006em;
  font-variant-numeric: tabular-nums; /* digits line up in columns, like a bank statement */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Soft green glow behind everything - a fixed pseudo-element rather than
   background-attachment:fixed, which iOS ignores/janks. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 460px at 50% -160px, hsl(var(--accent-h) 75% var(--accent-l) / 0.11), transparent 70%),
    radial-gradient(640px 380px at 100% 0%, rgba(90, 120, 255, 0.07), transparent 70%);
}
#app, #login-screen, #loading-screen { position: relative; z-index: 1; }

::selection { background: var(--accent-soft); }
* { scrollbar-width: thin; scrollbar-color: #2b3445 transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #2b3445; border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

.hidden { display: none !important; }
.screen { min-height: 100vh; }

/* ---------- brand mark ---------- */
.brand-mark {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  color: var(--accent-ink);
  background: linear-gradient(135deg, var(--accent-hover), hsl(var(--accent-h) 82% calc(var(--accent-l) - 8%)));
  box-shadow: 0 6px 16px -6px var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

/* ---------- loading + login ---------- */
#loading-screen { display: flex; align-items: center; justify-content: center; }
.loading-center { text-align: center; }
.loading-spinner {
  width: 38px;
  height: 38px;
  margin: 0 auto 16px;
  border: 3px solid rgba(255, 255, 255, 0.08);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#login-screen { display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card {
  width: 100%;
  max-width: 380px;
  padding: 36px 28px 28px;
  text-align: center;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0) 140px), var(--surface);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.85);
}
.login-card .brand-mark { width: 52px; height: 52px; border-radius: 16px; margin: 0 auto; }
.login-card .brand-mark svg { width: 28px; height: 28px; }
.login-card h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.03em; margin: 16px 0 4px; }
.login-card .login-sub { margin: 0 0 18px; }
.login-card input { width: 100%; margin: 6px 0; }
.login-card button { width: 100%; margin-top: 10px; }

/* ---------- app shell: header ---------- */
/* Phones/tablets: a solid header that scrolls away with the page (not
   pinned, nothing shows through it). Laptops override this below. */
header {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  /* +28px: keeps the title clear of the blur iOS adds under the status bar */
  padding-top: calc(max(12px, env(safe-area-inset-top)) + 28px); /* clears the notch / Dynamic Island in standalone mode */
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
/* Once the header scrolls away, keep page content from sliding under the
   iPhone status bar (clock/battery) in the home-screen app - a solid strip
   exactly the status bar's height. Zero height everywhere else. */
#app::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 25;
  height: env(safe-area-inset-top);
  background: var(--bg);
  pointer-events: none;
}
header h1 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -0.02em; }

/* ---------- app shell: bottom tab bar (phones + tablets) ---------- */
#bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  gap: 2px;
  padding: 6px 8px;
  padding-bottom: max(8px, env(safe-area-inset-bottom)); /* clears the home-indicator bar */
  background: rgba(11, 14, 20, 0.82);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  backdrop-filter: saturate(180%) blur(22px);
  border-top: 1px solid var(--line);
}
.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 54px;
  padding: 4px 2px;
  background: none;
  border: none;
  border-radius: 14px;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s ease;
}
/* Every icon lives in an identical box, so all the tabs sit on the same
   baseline - this is what keeps Activity level with the rest. */
.tab-icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 30px;
  border-radius: 15px;
  transition: background 0.2s ease;
}
.tab-icon svg { display: block; width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.tab-label { font-size: 11px; font-weight: 600; letter-spacing: 0.01em; line-height: 1; }
.tab-btn.active { color: var(--accent); }
.tab-btn.active .tab-icon { background: var(--accent-soft); }
.tab-btn:active .tab-icon { transform: scale(0.94); }

/* Settings gear - top right of the header (phones) / page (laptops). */
#settings-gear {
  flex: none;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  min-height: 0;
  margin-left: auto;
  padding: 0;
  border-radius: 50%;
  color: var(--muted);
  background: none;
}
#settings-gear svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.3s ease; }
#settings-gear:hover { color: var(--text); }
#settings-gear:hover svg { transform: rotate(30deg); }
#settings-gear.active { color: var(--accent); background: var(--accent-soft); }

main {
  position: relative;
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px calc(100px + env(safe-area-inset-bottom)); /* clears the fixed tab bar */
}

.tab-panel:not(.hidden) { animation: panelIn 0.3s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
@keyframes panelIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- cards ---------- */
.card {
  position: relative;
  margin: 0 0 16px;
  padding: 20px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0) 130px), var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: 0 20px 44px -24px rgba(0, 0, 0, 0.8);
}
.card h2 { margin: 0; font-size: 18px; font-weight: 650; letter-spacing: -0.018em; color: var(--text); }
/* Faint accent-colored underline under card titles (follows the accent
   color) - centered and inset from both ends, so it's shorter than the
   text. The title shrinks to its text width (margin-right: auto keeps the
   collapse arrow on the right) so the inset is measured from the words. */
.card h2 { position: relative; }
.card h2::after {
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: -1px;
  height: 2px;
  border-radius: 2px;
  /* solid in the middle, fading out toward both ends */
  background: linear-gradient(90deg, transparent, hsl(var(--accent-h) 75% var(--accent-l) / 0.22) 35%, hsl(var(--accent-h) 75% var(--accent-l) / 0.22) 65%, transparent);
  pointer-events: none;
}
.card-header-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card h2.collapse-toggle { flex: 0 1 auto; margin-right: auto; }

/* Collapse chevron: the ▾ text glyph is hidden and a drawn chevron replaces
   it, so it renders crisply and identically everywhere. */
.collapse-arrow {
  position: relative;
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  padding: 12px;
  margin: -12px;
  box-sizing: content-box;
  font-size: 0;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  transition: transform 0.2s ease;
}
.collapse-arrow::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 8px;
  height: 8px;
  margin: -6px 0 0 -4px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  border-radius: 1px;
  transform: rotate(45deg);
}
.card.collapsed .collapse-arrow { transform: rotate(-90deg); }
.card.collapsed .card-body { display: none; }
.card.collapsed .card-header-row { margin-bottom: 0; }
/* Tap targets: a whole collapsed card opens it; an open card's title line closes it. */
.card.collapsible.collapsed, .card.collapsible .card-header-row { cursor: pointer; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }

/* Cards on every tab get a faint outline in the accent color. */
:is(#tab-home, #tab-settings, #tab-transactions, #tab-recurring, #tab-schedule) .card { border: 3px solid var(--accent-outline); }
/* Log out: just the button, no bubble around it. */
#tab-settings .card.logout-card { padding: 0; background: none; border: none; box-shadow: none; }
#tab-settings .card.logout-card #logout-btn { margin-top: 0; }
/* ...and the rows inside them (balances, cards, buckets) get a 1px one. */
:is(#tab-home, #tab-settings, #tab-transactions, #tab-recurring, #tab-schedule) .list-item { border-color: var(--accent-outline); }
/* Text boxes, dropdowns and outlined buttons there too - accent instead of
   grey. (:not(:focus) keeps the full-accent focus ring when typing.) */
:is(#tab-home, #tab-settings, #tab-transactions, #tab-recurring, #tab-schedule) :is(input, select):not(:focus),
:is(#tab-home, #tab-settings, #tab-transactions, #tab-recurring, #tab-schedule) button.secondary { border-color: var(--accent-outline); }
:is(#tab-home, #tab-settings, #tab-transactions, #tab-recurring, #tab-schedule) button.secondary:hover { border-color: var(--accent-glow); }

/* Pay-rate forms (Settings > Schedule): company and shift name each get a
   full-width line so what you type is readable; $/hr + break share the last. */
.rate-fields { display: flex; flex-direction: column; gap: 8px; }
.rate-fields > input { flex: none; width: 100%; }
.rate-fields-last { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.rate-fields-last input[type="number"] { flex: 0 1 130px; }
.break-toggle { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); cursor: pointer; }

/* Bucket rows (Settings > Savings buckets): details across the full width,
   buttons in their own row underneath - wrapping evenly and filling the
   line - instead of squeezing the text beside them on phones. */
.list-item.bucket-row { flex-direction: column; align-items: stretch; gap: 10px; }
.list-item.bucket-row > div:first-child { flex: none; }
.list-item.bucket-row > .row-inline { flex-wrap: wrap; gap: 8px; }
.list-item.bucket-row > .row-inline > button { flex: 1 1 auto; }

/* "Pays down loan" picker on a fixed bucket row */
.loan-link { display: flex; align-items: center; gap: 10px; margin-top: 8px; font-size: 13px; color: var(--muted); }
.loan-link select { flex: 1; min-height: 40px; padding-top: 8px; padding-bottom: 8px; font-size: 16px; }

/* Home > Loans: name + balance on one line, time left under it, then a
   full-width Log payment button - nothing squeezed into a thin column. */
.list-item.loan-home-row { flex-direction: column; align-items: stretch; gap: 2px; }
.loan-home-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.loan-home-head > span { flex: none; font-weight: 600; white-space: nowrap; }
.list-item.loan-home-row > button { margin-top: 10px; }

/* Home notifications (recurring charges due soon) */
/* Just the notifications themselves - no surrounding box or heading.
   (Still a .card wrapper only so the Home column layout places it.) */
#tab-home .card.notifications-card { padding: 0; background: none; border: none; box-shadow: none; }
#home-notifications-list { margin: 0; }
.notification-item { box-shadow: inset 3px 0 0 var(--accent); }
.notif-title { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.notif-test-tag { padding: 2px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 700; letter-spacing: 0.02em; text-transform: uppercase; }
.notif-dismiss { flex: none; width: 34px; padding: 0; }

/* Small icon-only buttons (e.g. Untag) - same size/outline as the
   Recurring "..." button. */
button.icon-btn, button.small.icon-btn { flex: none; display: inline-flex; align-items: center; justify-content: center; min-width: 24px; min-height: 28px; padding: 0 4px; border-radius: 8px; }
button.icon-btn svg { display: block; width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* Accent color picker (Settings > Preferences) */
.hue-row { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.hue-swatch { flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input.hue-slider {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  min-height: 0;
  height: 14px;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: linear-gradient(90deg, hsl(0 75% 55%), hsl(60 75% 50%), hsl(120 75% 45%), hsl(180 75% 45%), hsl(240 75% 62%), hsl(300 75% 58%), hsl(360 75% 55%));
  cursor: pointer;
}
input.hue-slider:focus { box-shadow: none; }
input.hue-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 24px; border-radius: 50%; background: var(--accent); border: 3px solid var(--text); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5); }
input.hue-slider::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--accent); border: 3px solid var(--text); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5); }
input.hue-slider:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Home's Account Balance is the hero: total balance big and first, accounts
   beneath. Targets the card by its key (the cards can be reordered). */
.card[data-card-key="home-balance"] {
  background:
    radial-gradient(520px 240px at 100% 0%, hsl(var(--accent-h) 75% var(--accent-l) / 0.17), transparent 70%),
    linear-gradient(180deg, #141c24, #0f151c);
  border-color: hsl(var(--accent-h) 75% var(--accent-l) / 0.2);
}
.card[data-card-key="home-balance"]:not(.collapsed) .card-body { display: flex; flex-direction: column; }
#balance-total-row {
  order: -1;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 2px 0 18px;
  border: none;
  font-weight: 400;
}
#balance-total-row > span:first-child { font-size: 13px; font-weight: 500; color: var(--muted); }
.card[data-card-key="home-balance"] .card-body > .list { margin-bottom: 0; }
#balance-total { font-size: clamp(34px, 9.5vw, 46px); font-weight: 700; letter-spacing: -0.035em; line-height: 1.05; }

/* ---------- lists + rows ---------- */
.list { display: flex; flex-direction: column; gap: 8px; margin: 0 0 14px; }
.list:empty { margin: 0; }
.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 16px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid transparent;
  border-radius: var(--radius-row);
  font-size: 15px;
  font-weight: 500;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}
.list-item > span, .list-item > .row-inline > span { font-weight: 600; }
.meta, .list-item .meta { margin-top: 2px; color: var(--muted); font-size: 13px; font-weight: 400; }
.row-inline { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.list-item.clickable, .allocation-line.clickable { cursor: pointer; }
.list-item.clickable:active { transform: scale(0.992); }

.allocation-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--accent-outline);
  font-size: 15px;
}
.allocation-line > span:last-child, .allocation-line > .row-inline > span { font-weight: 600; }
#balance-list .list-item > div:last-child, #savings-accounts-list .list-item > div:last-child { font-weight: 600; }
.allocation-line.total { padding-top: 14px; border-bottom: none; font-size: 16px; font-weight: 700; }
.allocation-line.total > span { font-weight: 700; }
.allocation-line.total > span:last-child { letter-spacing: -0.015em; }
#overview-result .allocation-line.total > span:last-child { font-size: 24px; letter-spacing: -0.03em; }

/* Settings account rows stack their controls under the account info.
   The three-class selectors are deliberate: the phone rules further down
   (.list-item { align-items:center }, .list-item > .row-inline { nowrap })
   would otherwise centre the title and force the controls off the edge. */
.list-item.account-row { flex-direction: column; flex-wrap: nowrap; align-items: stretch; justify-content: flex-start; gap: 10px; }
.list-item.account-row > .account-row-controls { width: 100%; flex-wrap: wrap; flex-shrink: 1; }
.account-row-controls select { flex: 1 1 140px; min-width: 0; }

.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 10px; }
.row label { flex: 1 1 100%; font-size: 13px; color: var(--muted); }

.muted { color: var(--muted); font-size: 13px; }
.card-body > p:empty { display: none; } /* e.g. the empty sync-status line - it was leaving a gap under the hero balance */
.card-body > p.muted:last-child { margin-bottom: 0; }
.error-text { color: var(--danger); font-size: 13px; }
.error-text:empty { margin: 0; } /* an empty note still has default <p> margin - that was dead space at a card's bottom */

/* Waiting paychecks: payer name on its own line (no more three-line wraps),
   then date on the left with amount + Untag on the right. */
#paycheck-list .list-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "name name" "date amount";
  align-items: center;
  column-gap: 12px;
  row-gap: 6px;
}
#paycheck-list .list-item > div:first-child { grid-area: name; min-width: 0; overflow-wrap: anywhere; }
#paycheck-list .list-item > .meta { grid-area: date; margin: 0; white-space: nowrap; }
#paycheck-list .list-item > .row-inline { grid-area: amount; flex-wrap: nowrap; justify-content: flex-end; }

/* Paycheck calculator rows: job name on its own line; hours, rate and
   Remove share the next one instead of Remove wrapping alone. */
.job-row .job-name { flex: 1 1 100%; }
.job-row .job-hours, .job-row .job-rate { flex: 1 1 0; min-width: 0; }
.job-row .remove-job-btn { flex: none; }

/* ---------- badges + chips ---------- */
.flag-badge {
  display: inline-block;
  margin-top: 6px;
  padding: 4px 10px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 12px;
  font-weight: 600;
  border-radius: 999px;
}
.tag-badge {
  display: inline-block;
  margin: 2px 0 2px 4px;
  padding: 3px 9px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
  border-radius: 999px;
}
.toggle-chip {
  display: inline-block;
  margin: 4px 0 0 4px;
  padding: 3px 10px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  min-height: 0;
}
.toggle-chip.active { background: var(--accent-soft); color: var(--accent); }

/* ---------- form controls ---------- */
input, select {
  flex: 1;
  min-width: 0;     /* flex items default to their content's width; a select sizes itself to its LONGEST option, which pushed whole forms off-screen */
  max-width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-ctl);
  color: var(--text);
  font-family: inherit;
  /* 16px minimum - iOS Safari auto-zooms the whole page on focus for any
     input under 16px. */
  font-size: 16px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
input::placeholder { color: var(--faint); }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select {
  -webkit-appearance: none;
  appearance: none;
  text-overflow: ellipsis; /* long option text truncates instead of widening the select */
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238f9ab0' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px;
}
input[type="date"], input[type="time"], input[type="file"] { min-width: 0; }
input[type="file"] { max-width: 100%; }

button {
  min-height: 46px;
  padding: 11px 18px;
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.005em;
  border: none;
  border-radius: var(--radius-ctl);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.12s ease, opacity 0.15s ease;
}
button:active { transform: scale(0.98); }
button:disabled { opacity: 0.55; cursor: default; transform: none; }
button:focus-visible, .tab-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.primary {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 10px 24px -12px var(--accent-glow);
}
button.secondary {
  margin-top: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  color: var(--text);
}
button.small { min-height: 34px; padding: 6px 12px; font-size: 13px; border-radius: 10px; }
button.small.secondary { margin-top: 0; }

/* Shows which savings account a transaction is currently assigned to -
   tap the same one again to un-assign, tap a different one to swap. */
button.savings-selected {
  border: 2px solid var(--accent) !important;
  background: var(--accent-soft) !important;
  color: var(--accent);
  font-weight: 700;
}

/* Transaction row actions - one dropdown, revealed on tap, on its own
   line under the transaction so the name + amount stay readable. */
.list-item.txn-row {
  flex-wrap: wrap;
  /* Skip rendering rows that are off-screen - Activity can list hundreds,
     which made it sluggish on iPhone. ~66px is a collapsed row's height. */
  content-visibility: auto;
  contain-intrinsic-size: auto 66px;
}
.txn-actions { flex-basis: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.txn-actions select { flex: 1 1 200px; min-height: 42px; padding-top: 9px; padding-bottom: 9px; }
.txn-actions select.savings-selected { border-color: var(--accent); background-color: var(--accent-soft); }
.txn-action-status { margin-top: 0; flex: 0 1 auto; }
.txn-action-status:empty { display: none; }

/* Custom checkbox - all screen sizes. The native one renders inconsistently
   (chunky on iOS), so this replaces it everywhere. Every box-model property
   is repeated identically on :checked: iOS reverts toward native rendering
   once checked, shifting size/position, unless the whole box is pinned on
   both states. !important throughout since the JS also sets inline
   width/height on some checkboxes. Only colors + the tick change on check. */
input[type="checkbox"] {
  -webkit-appearance: none !important;
  appearance: none !important;
  box-sizing: border-box !important;
  width: 18px !important;
  height: 18px !important;
  min-width: 18px !important;
  min-height: 18px !important;
  max-width: 18px !important;
  max-height: 18px !important;
  margin: 0 !important;
  padding: 0 !important;
  flex-shrink: 0 !important;
  border: 1.5px solid #3b475c !important;
  border-radius: 6px !important;
  background: transparent !important;
  outline: none !important;
  box-shadow: none !important;
  vertical-align: middle !important;
  cursor: pointer;
}
input[type="checkbox"]:checked {
  -webkit-appearance: none !important;
  appearance: none !important;
  box-sizing: border-box !important;
  width: 18px !important;
  height: 18px !important;
  min-width: 18px !important;
  min-height: 18px !important;
  max-width: 18px !important;
  max-height: 18px !important;
  margin: 0 !important;
  padding: 0 !important;
  border-radius: 6px !important;
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Cpath d='M4.6 9.4l2.8 2.8 6-6.4' fill='none' stroke='%2303150d' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 100% 100% no-repeat !important;
  border: 1.5px solid var(--accent) !important;
  outline: none !important;
  box-shadow: none !important;
}
input[type="checkbox"]:focus-visible { box-shadow: 0 0 0 3px var(--accent-soft) !important; }

/* ---------- sub-nav (Activity: All Transactions / Needs Review) ---------- */
.sub-nav {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  padding: 4px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 16px;
}
.sub-tab-btn {
  flex: 1;
  min-height: 40px;
  padding: 8px 14px;
  background: none;
  border: none;
  border-radius: 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}
.sub-tab-btn.active { background: var(--surface-3); color: var(--text); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35); }

/* ---------- bucket pie chart (rendered as a donut) ---------- */
.pie-chart-row { display: flex; align-items: center; flex-wrap: wrap; gap: 22px; margin-bottom: 18px; }
.pie-chart {
  flex-shrink: 0;
  width: 132px;
  height: 132px;
  border-radius: 50%;
  background: var(--accent-outline); /* shows through as "unallocated" when total < 100% */
  -webkit-mask: radial-gradient(circle, transparent 53%, #000 54%);
  mask: radial-gradient(circle, transparent 53%, #000 54%);
}
.pie-legend { display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.pie-legend-item { display: flex; align-items: center; gap: 8px; }
.pie-legend-swatch { width: 10px; height: 10px; flex-shrink: 0; border-radius: 3px; }

/* ---------- modals (bottom sheet on phones, centered dialog on laptops) ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(2, 4, 8, 0.64);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  animation: fadeIn 0.2s ease both;
}
.modal-panel {
  width: 100%;
  max-width: 640px;
  max-height: 86vh;
  overflow-y: auto;
  padding: 12px 20px calc(24px + env(safe-area-inset-bottom));
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: 26px 26px 0 0;
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.6);
  animation: sheetUp 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
@supports (height: 100dvh) { .modal-panel { max-height: 86dvh; } }
.modal-panel::before { content: ""; display: block; width: 40px; height: 5px; margin: 0 auto 14px; border-radius: 3px; background: rgba(255, 255, 255, 0.16); }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.modal-header h2 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -0.02em; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheetUp { from { transform: translateY(32px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- dropdown menu (Recurring list "...") ---------- */
.popup-menu {
  position: fixed;
  z-index: 25;
  min-width: 220px;
  max-width: calc(100vw - 24px);
  padding: 6px;
  background: var(--surface-3);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 16px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.6);
  animation: popIn 0.14s ease both;
}
@keyframes popIn { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; transform: none; } }
.popup-menu .menu-label { padding: 8px 12px 4px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.popup-menu .menu-divider { height: 1px; margin: 6px 4px; background: var(--line); }
.popup-menu button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  margin: 0;
  padding: 0 12px;
  background: none;
  border: none;
  border-radius: 10px;
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  text-align: left;
}
.popup-menu button:focus-visible { background: rgba(255, 255, 255, 0.08); outline: none; }
.popup-menu button.danger { color: var(--danger); }
.popup-menu .menu-check { color: var(--accent); font-weight: 700; }

/* ---------- yearly-payment reminder banner ---------- */
.reminder-banner {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 10px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  width: calc(100% - 24px);
  max-width: 560px;
  padding: 14px 16px 14px 18px;
  background: rgba(20, 27, 38, 0.9);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  border: 1px solid hsl(var(--accent-h) 75% var(--accent-l) / 0.38);
  border-radius: 16px;
  box-shadow: inset 4px 0 0 var(--accent), 0 16px 44px rgba(0, 0, 0, 0.55);
  font-size: 14px;
  line-height: 1.4;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.reminder-banner.show { opacity: 1; }
.reminder-banner .reminder-line + .reminder-line { margin-top: 6px; }

/* ---------- Schedule ---------- */
#schedule-prev-week-btn, #schedule-next-week-btn { position: relative; width: 40px; min-width: 40px; padding: 0; font-size: 0; } /* hides the ◀ ▶ text glyphs */
#schedule-prev-week-btn::after, #schedule-next-week-btn::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  border-radius: 1px;
}
#schedule-prev-week-btn::after { margin: -5px 0 0 -3px; transform: rotate(135deg); }
#schedule-next-week-btn::after { margin: -5px 0 0 -7px; transform: rotate(-45deg); }
#schedule-days { margin-top: 16px; }
#schedule-days .list-item button.small { background: none; border-color: transparent; color: var(--muted); }

/* ---------- Recurring list ---------- */
#refresh-recurring-btn { margin: 4px 0 16px; }
#recurring-list .list-item { align-items: flex-start; gap: 12px; padding: 16px; }
#recurring-list .recurring-body { flex: 1 1 0; min-width: 0; }
#recurring-list .recurring-name { font-size: 16px; font-weight: 650; line-height: 1.3; letter-spacing: -0.015em; word-break: break-word; }
#recurring-list .recurring-tag { margin-left: 8px; color: var(--muted); font-size: 12px; font-weight: 500; white-space: nowrap; }
#recurring-list .recurring-due { margin-top: 5px; font-size: 14px; font-weight: 650; }
#recurring-list .recurring-due.is-soon { color: var(--accent); }
#recurring-list .recurring-due.is-late { color: var(--muted); font-weight: 500; }
#recurring-list .recurring-detail { margin-top: 3px; color: var(--muted); font-size: 13px; font-weight: 400; }
#recurring-list .flag-badge { display: block; width: fit-content; max-width: 100%; margin-top: 10px; font-size: 12px; line-height: 1.35; border-radius: 10px; }
#recurring-list .recurring-menu-btn { flex: none; display: inline-flex; align-items: center; justify-content: center; min-width: 40px; padding: 0 10px; }
#recurring-list .recurring-menu-btn svg { display: block; fill: currentColor; }
#recurring-list .recurring-menu-btn[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); }

/* ---------- hover (mouse devices only, so touch never gets a stuck hover) ---------- */
@media (hover: hover) {
  .list-item.clickable:hover { background: rgba(255, 255, 255, 0.065); border-color: var(--line); }
  .allocation-line.clickable:hover { color: var(--accent); }
  .tab-btn:hover:not(.active) { color: var(--text); }
  button.primary:hover { background: var(--accent-hover); }
  button.secondary:hover { background: rgba(255, 255, 255, 0.09); }
  button.small:not(.primary):hover { border-color: rgba(255, 255, 255, 0.16); }
  .sub-tab-btn:not(.active):hover { color: var(--text); }
  .popup-menu button:hover { background: rgba(255, 255, 255, 0.07); }
  .collapse-arrow:hover { color: var(--text); }
  #schedule-days .list-item button.small:hover { color: var(--danger); background: var(--danger-soft); }
}

/* ---------- phones: row-alignment fixes (unchanged in purpose) ---------- */
@media (max-width: 767px) {
  .allocation-line { align-items: center; }
  .row-inline { align-items: center; }
  /* The amount+checkbox side of a Total Waiting row must never wrap onto its
     own line (that pushed a fixed bucket's checkbox under its amount), and
     the label side wraps its OWN text/badges without squeezing the right
     side, so a "Checked" badge appearing doesn't reflow anything else. */
  .allocation-line { flex-wrap: nowrap; }
  .allocation-line > div:first-child { flex: 1 1 auto; min-width: 0; }
  .allocation-line > .row-inline { flex-wrap: nowrap; flex-shrink: 0; }
  /* Same fix for a checkbox next to a dollar amount inside a plain list row
     (e.g. Credit Card Debt's "mark statement paid" checkbox). */
  .list-item { flex-wrap: nowrap; align-items: center; }
  .list-item > div:first-child { flex: 1 1 auto; min-width: 0; }
  .list-item > .row-inline { flex-wrap: nowrap; flex-shrink: 0; }
}

/* Very narrow phones (iPhone SE/mini class and smaller): a row whose right
   side holds several buttons (e.g. Log payment / Edit balance / Remove) drops
   them onto their own line rather than running off the card. Rows with just
   an amount + checkbox are untouched. */
@media (max-width: 380px) {
  .list-item:has(> .row-inline > button + button) { flex-wrap: wrap; }
  .list-item > .row-inline:has(> button + button) { flex: 1 1 100%; flex-wrap: wrap; }
}

/* ---------- tablets and up: dialogs center instead of sliding up ---------- */
@media (min-width: 768px) {
  .modal-overlay { align-items: center; padding: 24px; }
  .modal-panel { max-width: 560px; padding: 26px; border-bottom: 1px solid var(--line); border-radius: 24px; }
  .modal-panel::before { display: none; }
}

/* ---------- laptops: sidebar + two-column dashboard ---------- */
@media (min-width: 1024px) {
  header {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 21;
    width: var(--sidebar-w);
    height: 84px;
    padding: 0 24px;
    background: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    border-bottom: none;
  }
  header h1 { font-size: 16px; }

  #bottom-nav {
    top: 0;
    right: auto;
    bottom: 0;
    width: var(--sidebar-w);
    flex-direction: column;
    gap: 4px;
    padding: 92px 14px 24px;
    background: rgba(12, 15, 21, 0.7);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    border-top: none;
    border-right: 1px solid var(--line);
  }
  .tab-btn { flex: none; flex-direction: row; justify-content: flex-start; gap: 14px; width: 100%; min-height: 46px; padding: 0 16px; }
  .tab-icon, .tab-btn.active .tab-icon { width: 24px; height: 24px; background: none; border-radius: 0; }
  .tab-label { font-size: 15px; font-weight: 600; letter-spacing: -0.005em; }
  .tab-btn.active { background: var(--accent-soft); }

  main { max-width: none; margin: 0 0 0 var(--sidebar-w); padding: 72px 48px 64px; } /* top room for the gear */
  #settings-gear { position: fixed; top: 20px; right: 28px; z-index: 22; width: 40px; height: 40px; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line); }
  #settings-gear.active { background: var(--accent-soft); border-color: transparent; }
  .tab-panel { max-width: 780px; margin: 0 auto; }
  /* Cards are placed into these two columns by balanceDashboardColumns()
     in app.js - not CSS multi-column, which re-laid-out every card on
     each keystroke and made typing lag. */
  #tab-home, #tab-settings { max-width: 1140px; }
  .mc-row { display: flex; align-items: flex-start; gap: 24px; }
  .mc-col { flex: 1 1 0; min-width: 0; }

  .reminder-banner { left: calc(50% + var(--sidebar-w) / 2); }

  /* On a wide screen the hero's accounts read better as stat tiles than as
     full-width rows: name above, balance big beneath. */
  #balance-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
  #balance-list .list-item { flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: 6px; padding: 16px 18px; }
  #balance-list .list-item > div:first-child { font-size: 14px; font-weight: 500; color: var(--muted); }
  #balance-list .list-item > div:last-child { font-size: 22px; font-weight: 650; letter-spacing: -0.025em; }
}

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