:root {
  --bg: #121212;
  --surface: #1c1c1e;      /* hero, inputs, chips */
  --surface-2: #262628;    /* hover / pressed */
  --card: var(--surface);  /* kept for compatibility */
  --text: #ececec;
  --heading: #c8c8c8;
  --muted: #8e8e93;
  --accent: #4caf50;
  --yellow: #fbc02d;
  --danger: #e57373;
  --hairline: rgba(255, 255, 255, 0.08);
  --border: var(--hairline);

  /* spacing scale */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;

  --radius: 10px;
  --tabbar-h: 60px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

main {
  max-width: 480px;
  margin: 0 auto;
  /* room for the tab bar + FAB + safe area */
  padding: var(--s4) var(--s4) calc(var(--tabbar-h) + 96px + env(safe-area-inset-bottom));
}

h3 {
  margin: var(--s5) 0 var(--s2);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.hint {
  margin: var(--s1) 0 var(--s2);
  color: var(--muted);
  font-size: 0.85rem;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

h2 {
  margin: 0 0 var(--s3);
  font-size: 1rem;
  font-weight: 600;
  color: var(--heading);
  letter-spacing: 0.01em;
}

p { margin: 0 0 var(--s2); }

/* Sections: no boxes, just space and a hairline between them */
.card {
  background: transparent;
  border-radius: 0;
  padding: 0;
  margin: 0;
}

.tab > .card + .card {
  margin-top: var(--s6);
  padding-top: var(--s6);
  border-top: 1px solid var(--hairline);
}

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.negative { color: var(--danger); }
.positive { color: var(--accent); }
.tight { color: var(--yellow); }

/* ===== Collapsible secondary content ===== */

details.more {
  margin-top: var(--s3);
}

details.more > summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  min-height: 44px;
  padding: var(--s2) 0;
  color: var(--muted);
  font-size: 0.95rem;
  cursor: pointer;
  user-select: none;
  border-radius: 6px;
}

details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::marker { content: ""; }

details.more > summary::after {
  content: "";
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  margin-right: var(--s1);
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  transition: transform 0.15s ease;
}

details.more[open] > summary::after {
  transform: rotate(225deg) translate(-2px, 0);
}

details.more > summary:hover { color: var(--text); }

details.more > summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

details.more[open] > summary { color: var(--text); }

details.more > summary + * { margin-top: var(--s3); }

/* ===== Dashboard ===== */

.hero {
  text-align: center;
  background: var(--surface);
  border-radius: 16px;
  padding: var(--s5) var(--s4) var(--s4);
}

.hero p { margin: var(--s1) 0; }

.tab > .card.hero + .card {
  border-top: none;
  padding-top: 0;
}

.big {
  font-size: 3rem;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: var(--s2) 0 !important;
  font-variant-numeric: tabular-nums;
}

.hero-sub {
  color: var(--muted);
  font-size: 0.9rem;
}

.hero details.more { text-align: left; margin-top: var(--s3); }
.hero details.more > summary { justify-content: center; gap: var(--s2); }

.stats {
  display: flex;
  gap: var(--s3);
  margin: var(--s3) 0;
}

.stats > div {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: var(--s2) 0;
}

.stat {
  font-size: 1.35rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.warning {
  background: rgba(229, 115, 115, 0.1);
  color: var(--danger);
  border-radius: var(--radius);
  padding: var(--s2) var(--s3);
}

.bar-row { margin-bottom: var(--s4); }

.bar-label {
  display: flex;
  justify-content: space-between;
  gap: var(--s2);
  font-size: 0.9rem;
  margin-bottom: var(--s1);
}

.bar {
  height: 6px;
  background: var(--surface-2);
  border-radius: 3px;
  overflow: hidden;
  margin: var(--s1) 0;
}

.bar-fill { height: 100%; border-radius: 3px; }
.bar-fill.green { background: var(--accent); }
.bar-fill.yellow { background: var(--yellow); }
.bar-fill.red { background: var(--danger); }

#category-bars > p.muted.small { margin-top: var(--s3); }

/* Tips: show only the first one; hiding it reveals the next */
.tips li + li { display: none; }

.tips li {
  flex-direction: column;
  align-items: stretch;
  border-top: none;
  padding-top: 0;
}

.tips .actions { justify-content: flex-end; }

/* Pie chart */
.pie-wrap {
  display: flex;
  align-items: center;
  gap: var(--s5);
  margin-top: var(--s3);
}

.pie {
  flex: 0 0 112px;
  height: 112px;
  border-radius: 50%;
}

.legend {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.85rem;
  min-width: 0;
}

.legend li { margin: var(--s1) 0; }

.swatch {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: var(--s2);
}

/* ===== Forms ===== */

.next-payday { margin: 0 0 var(--s3); color: var(--muted); }
.next-payday strong { color: var(--text); }

label {
  display: block;
  margin: var(--s4) 0 var(--s1);
  color: var(--muted);
  font-size: 0.85rem;
}

textarea { resize: vertical; }

input, select, button, textarea {
  width: 100%;
  max-width: 100%;
  min-height: 44px;
  padding: var(--s3);
  font-size: 1rem;
  line-height: 1.3;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
}

input::placeholder, textarea::placeholder { color: #6a6a6e; }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.2);
}

button:focus-visible, .button-like:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#tab-home input { margin-bottom: var(--s2); }

button {
  margin-top: var(--s4);
  background: var(--accent);
  border: none;
  color: #0b0b0b;
  font-weight: 600;
  cursor: pointer;
}

button:active { filter: brightness(0.92); }

/* A label that looks like a button (opens the file picker for Import) */
.button-like {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  margin: var(--s4) 0 0;
  padding: var(--s3);
  text-align: center;
  background: var(--surface);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
}

.check {
  display: flex;
  align-items: center;
  gap: var(--s2);
  color: var(--text);
}

.check input { width: auto; min-height: 0; accent-color: var(--accent); }

.bank-choice {
  width: 112px;
  flex: 0 0 auto;
  padding: var(--s2);
  min-height: 36px;
}

button.secondary {
  background: var(--surface);
  color: var(--text);
  border: none;
  font-weight: 500;
}

button.danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(229, 115, 115, 0.35);
}

/* Text-only danger link (edit dialog) */
button.link-danger {
  display: block;
  width: auto;
  min-height: 44px;
  margin: var(--s3) auto 0;
  padding: var(--s2) var(--s4);
  background: transparent;
  border: none;
  color: var(--danger);
  font-weight: 500;
  font-size: 0.95rem;
}

button.link-danger:hover { text-decoration: underline; }

.row {
  display: flex;
  gap: var(--s2);
  align-items: flex-end;
}

.row > * { flex: 1; min-width: 0; }

#category-form { margin-top: var(--s3); }
#category-form .small-btn { flex: 0 0 auto; }

.estimate { margin-top: var(--s4); }
.estimate summary { color: var(--muted); cursor: pointer; min-height: 44px; display: flex; align-items: center; }

/* Category buttons for quick add */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
  margin: var(--s2) 0 var(--s3);
}

.chip {
  width: auto;
  min-height: 40px;
  margin: 0;
  padding: var(--s2) var(--s4);
  background: var(--surface);
  color: var(--text);
  border: none;
  border-radius: 999px;
  font-weight: normal;
  font-size: 0.95rem;
}

.chip:hover { background: var(--surface-2); }

.chip.recent { color: var(--muted); }

.chip.selected {
  background: rgba(76, 175, 80, 0.15);
  color: var(--accent);
  box-shadow: inset 0 0 0 1.5px var(--accent);
  font-weight: 600;
}

/* History filter rows: one scrollable line each, never widens the page */
#history-period-chips,
#history-category-chips {
  flex-wrap: nowrap;
  overflow-x: auto;
  max-width: 100%;
  padding-bottom: var(--s1);
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

#history-period-chips::-webkit-scrollbar,
#history-category-chips::-webkit-scrollbar { display: none; }

#history-period-chips .chip,
#history-category-chips .chip { flex: 0 0 auto; white-space: nowrap; }

/* ===== Status pill (home hero) ===== */

.status-pill {
  display: block;
  width: 100%;
  min-height: 36px;
  margin: var(--s3) 0 0;
  padding: var(--s2) var(--s4);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 500;
  text-align: center;
  overflow-wrap: anywhere;
}

.status-pill.warn {
  background: rgba(251, 192, 45, 0.14);
  color: var(--yellow);
}

.status-pill.danger {
  background: rgba(229, 115, 115, 0.14);
  color: var(--danger);
}

/* ===== Can I afford it? ===== */
/* Only the answer is colored; the numbers under it stay plain */

#afford-result { margin-top: var(--s3); color: var(--text); }
#afford-result.negative strong { color: var(--danger); }
#afford-result.tight strong { color: var(--yellow); }
#afford-result.positive strong { color: var(--accent); }

.afford-lines {
  list-style: none;
  padding: 0;
  margin: var(--s2) 0;
}

.afford-lines li {
  display: flex;
  justify-content: space-between;
  gap: var(--s3);
  padding: var(--s1) 0;
  border-top: 1px solid var(--hairline);
  font-variant-numeric: tabular-nums;
}

.afford-lines li span:first-child { color: var(--muted); }

/* ===== Forecast ===== */

.whatif {
  display: flex;
  align-items: center;
  gap: var(--s2);
  margin: var(--s3) 0;
}

.whatif button {
  flex: 0 0 auto;
  width: auto;
  margin: 0;
  padding: var(--s2) var(--s3);
  font-size: 0.9rem;
}

#fc-whatif-label {
  flex: 1;
  min-width: 0;
  text-align: center;
  font-size: 0.9rem;
  color: var(--muted);
}

#fc-timeline { margin: var(--s3) 0 var(--s4); }

.fc-now { margin-bottom: var(--s3); }

/* Each payday is a tap-to-open row */
details.fc-row {
  border-left: 3px solid transparent;
  border-top: 1px solid var(--hairline);
}

details.fc-row:first-child { border-top: none; }

details.fc-row > summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "date balance"
    "detail detail"
    "flag flag";
  column-gap: var(--s3);
  row-gap: 2px;
  padding: var(--s3);
  list-style: none;
  cursor: pointer;
}

details.fc-row > summary::-webkit-details-marker { display: none; }
details.fc-row > summary::marker { content: ""; }
details.fc-row > summary:hover { background: var(--surface); }
details.fc-row[open] > summary { background: var(--surface); }

.fc-date { grid-area: date; font-weight: 600; min-width: 0; }
.fc-date::after { content: " ›"; color: var(--muted); font-weight: normal; }
details.fc-row[open] .fc-date::after { content: " ⌄"; }
.fc-balance { grid-area: balance; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.fc-detail { grid-area: detail; min-width: 0; overflow-wrap: anywhere; }

.fc-breakdown {
  padding: var(--s2) var(--s3) var(--s4);
  background: var(--surface);
}

.fc-lines {
  list-style: none;
  padding: 0;
  margin: 0 0 var(--s3);
}

.fc-lines li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: var(--s3);
  padding: var(--s1) 0;
}

.fc-amount { text-align: right; font-variant-numeric: tabular-nums; }
.fc-note { grid-column: 1 / -1; }

.fc-lines li.fc-total {
  border-top: 1px solid var(--hairline);
  margin-top: var(--s1);
  padding-top: var(--s2);
  font-weight: 600;
}

.fc-breakdown .row { align-items: center; }
.fc-breakdown .row input { flex: 1; }
.fc-breakdown .row .small-btn { flex: 0 0 auto; }

.fc-help { padding-left: var(--s5); margin: 0; }
.fc-help li { margin-bottom: var(--s2); color: var(--muted); font-size: 0.9rem; }
.fc-help strong { color: var(--text); }

#fc-reset { margin-top: var(--s4); }

.fc-flag {
  grid-area: flag;
  justify-self: start;
  margin-top: var(--s1);
  padding: 2px var(--s2);
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 0.75rem;
  font-weight: 600;
}

.fc-row.fc-negative { border-left-color: var(--danger); }
.fc-row.fc-negative .fc-balance,
.fc-row.fc-negative .fc-flag { color: var(--danger); }
.fc-row.fc-negative .fc-flag { background: rgba(229, 115, 115, 0.14); }

/* "Could go negative": only the flag is yellow; the expected balance is still fine */
.fc-row.fc-tight { border-left-color: var(--yellow); }
.fc-row.fc-tight .fc-flag { color: var(--yellow); background: rgba(251, 192, 45, 0.14); }

#shift-form { margin-top: var(--s2); }

/* ===== App lock ===== */

/* While locked, only the lock screen shows */
body.locked > :not(#lock-screen) { display: none !important; }

#lock-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s4);
  background: var(--bg);
  z-index: 100;
}

#unlock-form {
  width: 100%;
  max-width: 340px;
  text-align: center;
}

#unlock-form h1 { margin: 0 0 var(--s1); font-size: 1.6rem; }
#unlock-form label { text-align: left; }
#unlock-error { min-height: 1.4em; margin-top: var(--s3); color: var(--danger); }
#unlock-erase { margin-top: var(--s5); }

#lock-now { margin-bottom: var(--s3); }

/* ===== Danger zone ===== */

.tab > .card.danger-zone {
  margin-top: var(--s6);
  padding: var(--s4);
  border: 1px solid rgba(229, 115, 115, 0.3);
  border-radius: var(--radius);
  background: rgba(229, 115, 115, 0.05);
}

.danger-zone h2 { color: var(--danger); }
.danger-zone button.danger { margin-top: var(--s2); }

/* ===== Lists ===== */

.list {
  list-style: none;
  padding: 0;
  margin: var(--s3) 0 0;
}

.list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3) 0;
  border-top: 1px solid var(--hairline);
}

.list li:first-child { border-top: none; }

.grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }

.actions { display: flex; gap: var(--s1); flex: 0 0 auto; }

.list button, .small-btn {
  width: auto;
  min-height: 36px;
  margin: 0;
  padding: var(--s2) var(--s3);
  font-weight: normal;
  font-size: 0.9rem;
}

.small-btn, .list .small-btn {
  background: transparent;
  color: var(--muted);
  border: none;
}

.small-btn:hover, .small-btn:focus-visible { color: var(--text); background: var(--surface); }

.list .delete {
  background: transparent;
  color: var(--muted);
  border: none;
}

.list .delete:hover, .list .delete:focus-visible { color: var(--danger); }

/* Tappable history rows (open edit dialog) */
.list li:has(> .row-btn) { padding: 0; }

.row-btn,
.list .row-btn {
  display: block;
  width: 100%;
  min-height: 44px;
  margin: 0;
  padding: var(--s3) var(--s1);
  background: transparent;
  border: none;
  border-radius: 6px;
  color: inherit;
  font: inherit;
  font-weight: normal;
  text-align: left;
}

.row-btn:hover, .row-btn:active { background: rgba(255, 255, 255, 0.04); filter: none; }

.row-btn .muted.small { margin-top: 2px; }

.edit-row input { margin: 0; padding: var(--s2); min-height: 36px; }
.edit-row input[data-cat-planned] { width: 96px; flex: 0 0 auto; }

/* ===== Pop-up, toast, tab bar ===== */

dialog {
  background: var(--surface);
  color: var(--text);
  border: none;
  border-radius: 16px;
  padding: var(--s5) var(--s4) var(--s4);
  width: calc(100% - 32px);
  max-width: 420px;
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  overflow-x: hidden;
}

dialog h2 { font-size: 1.05rem; color: var(--text); }

dialog label:first-of-type { margin-top: var(--s2); }

dialog .chips { margin-bottom: var(--s2); }

dialog .dialog-cancel {
  margin-top: var(--s2);
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--hairline);
}

dialog .dialog-cancel:hover { color: var(--text); background: var(--surface-2); }

dialog input, dialog select, dialog textarea { background: var(--bg); }

dialog::backdrop { background: rgba(0, 0, 0, 0.6); }

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + var(--s3) + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 448px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  background: #2c2c2e;
  padding: var(--s2) var(--s4);
  border-radius: var(--radius);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  z-index: 20;
}

#toast button {
  width: auto;
  margin: 0;
  padding: var(--s2) var(--s3);
  background: transparent;
  color: var(--accent);
}

/* ===== Top bar, tab bar, FAB ===== */

.topbar {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  max-width: 480px;
  margin: 0 auto;
  padding: var(--s2) var(--s2) var(--s1) var(--s4);
  padding-top: calc(var(--s2) + env(safe-area-inset-top));
  background: var(--bg);
  z-index: 10;
}

.icon-btn {
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
  font-size: 1.4rem;
  font-weight: normal;
  border-radius: var(--radius);
}

.icon-btn:hover { background: var(--surface); }

#settings-btn { flex: 0 0 auto; color: var(--muted); }
#settings-btn:hover, #settings-btn.active { color: var(--accent); }

#page-title {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--heading);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  padding: 0 max(var(--s2), env(safe-area-inset-left)) env(safe-area-inset-bottom) max(var(--s2), env(safe-area-inset-right));
  background: var(--surface);
  border-top: 1px solid var(--hairline);
  z-index: 10;
}

.tabbar button {
  flex: 1;
  max-width: 120px;
  min-width: 0;
  width: auto;
  height: var(--tabbar-h);
  margin: 0;
  padding: var(--s1);
  background: transparent;
  color: var(--muted);
  border-radius: 0;
  font-size: 0.8rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tabbar button:hover { color: var(--text); }

.tabbar button.active {
  color: var(--accent);
  font-weight: 600;
  box-shadow: inset 0 2px 0 var(--accent);
}

.tabbar button:focus-visible { outline-offset: -2px; }

.fab {
  position: fixed;
  right: max(var(--s4), calc((100vw - 480px) / 2 + var(--s4)));
  bottom: calc(var(--tabbar-h) + var(--s4) + env(safe-area-inset-bottom));
  width: 56px;
  height: 56px;
  min-height: 56px;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--accent);
  color: #0b0b0b;
  font-size: 2rem;
  font-weight: 400;
  line-height: 1;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  z-index: 15;
}

.fab:hover { filter: brightness(1.08); }

/* toast sits above the FAB's layer so undo is always tappable */
#toast { z-index: 20; }

/* ===== Savings goals ===== */

/* Home: save button under the status pill */
#home-save-btn {
  display: block;
  width: 100%;
  min-height: 40px;
  margin: var(--s2) 0 0;
  padding: var(--s2) var(--s4);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 500;
}

#home-save-btn:hover { color: var(--accent); }

/* Home nudge: subtle accent-tinted card */
.tab > .card.nudge,
.card.nudge {
  margin-top: var(--s4);
  padding: var(--s3) var(--s4);
  background: rgba(76, 175, 80, 0.08);
  border: 1px solid rgba(76, 175, 80, 0.25);
  border-radius: var(--radius);
}

.tab > .card.nudge + .card { border-top: none; padding-top: 0; }

.nudge p { margin: 0; overflow-wrap: anywhere; }

.nudge .row { margin-top: var(--s3); align-items: stretch; }

.nudge .row button { margin: 0; min-height: 40px; padding: var(--s2) var(--s3); }

.nudge button.secondary { background: transparent; color: var(--muted); border: 1px solid var(--hairline); }
.nudge button.secondary:hover { color: var(--text); }

/* Text-only accent button */
button.link-btn {
  display: block;
  width: auto;
  min-height: 44px;
  margin: 0 auto var(--s2);
  padding: var(--s2) var(--s3);
  background: transparent;
  border: none;
  color: var(--accent);
  font-weight: 500;
  font-size: 0.95rem;
}

button.link-btn:hover { text-decoration: underline; }

/* Goal rows */
.goals li.goal {
  display: block;
  padding: var(--s4) 0;
}

.goal-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--s1) var(--s2);
}

.goal-head strong { min-width: 0; overflow-wrap: anywhere; }

.goal-amount {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.goal-default {
  padding: 1px var(--s2);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.goals .bar { margin: var(--s2) 0; }

.goal-plan { margin: var(--s1) 0 0; overflow-wrap: anywhere; }

.goal-status {
  display: inline-block;
  margin-left: var(--s1);
  padding: 1px var(--s2);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.goal-status.ahead { background: rgba(76, 175, 80, 0.14); color: var(--accent); }
.goal-status.on-track { background: var(--surface-2); color: var(--text); }
.goal-status.behind { background: rgba(251, 192, 45, 0.14); color: var(--yellow); }

.milestones {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s1);
  margin-top: var(--s2);
}

.milestone {
  padding: 1px var(--s2);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.milestone.reached {
  background: rgba(76, 175, 80, 0.15);
  color: var(--accent);
  font-weight: 600;
}

.goal-actions {
  display: flex;
  gap: var(--s1);
  margin-top: var(--s2);
  margin-left: calc(-1 * var(--s3));
}

.goal-actions .small-btn { flex: 0 0 auto; }

.goals li.goal details.more { margin-top: var(--s1); }

.goal-history {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.85rem;
}

.goals .goal-history li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  column-gap: var(--s2);
  align-items: baseline;
  padding: var(--s1) 0;
  border-top: none;
}

.goal-history li > * { min-width: 0; overflow-wrap: anywhere; }
.goal-history .plus,
.goal-history .minus { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.plus { color: var(--accent); }
.minus { color: var(--danger); }

/* Settings: round-up checkbox row */
label.check { margin-top: var(--s4); line-height: 1.35; }
label.check input { flex: 0 0 auto; margin: 0; }
