/* Budgeteer — original styles. System fonts, iOS-like grouped lists. */
:root {
  --bg: #F2F2F7;
  --elevated: #FFFFFF;
  --label: #1C1C1E;
  --secondary: #6C6C70;
  --tertiary: #AEAEB2;
  --separator: rgba(60, 60, 67, 0.14);
  --fill: rgba(118, 118, 128, 0.12);
  --fill-strong: rgba(118, 118, 128, 0.2);
  --accent: #0B7D6B;
  --accent-soft: rgba(11, 125, 107, 0.14);
  --accent-press: #086357;
  --income: #1B8A58;
  --expense: #D3252F;
  --danger: #D3252F;
  --toolbar: rgba(242, 242, 247, 0.88);
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.16);
  --radius: 12px;
  --radius-lg: 16px;
  --row: 68px;
  --max: 720px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "Helvetica Neue", Roboto, sans-serif;
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #000000;
  --elevated: #1C1C1E;
  --label: #F5F5F7;
  --secondary: #98989D;
  --tertiary: #636366;
  --separator: rgba(84, 84, 88, 0.65);
  --fill: rgba(118, 118, 128, 0.28);
  --fill-strong: rgba(118, 118, 128, 0.4);
  --accent: #3DDCB2;
  --accent-soft: rgba(61, 220, 178, 0.16);
  --accent-press: #2BB894;
  --income: #32D74B;
  --expense: #FF453A;
  --danger: #FF453A;
  --toolbar: rgba(0, 0, 0, 0.82);
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--label);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body {
  padding: 0;
  min-height: 100dvh;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button { cursor: pointer; }

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

.view {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.view[hidden] { display: none !important; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  min-height: 56px;
  padding: calc(10px + var(--safe-top)) 12px 10px;
  background: var(--toolbar);
  backdrop-filter: saturate(1.4) blur(18px);
  -webkit-backdrop-filter: saturate(1.4) blur(18px);
  border-bottom: 1px solid var(--separator);
}

#view-home .topbar {
  grid-template-columns: 1fr auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand img {
  width: 32px;
  height: 32px;
  border-radius: 8px;
}

.brand h1,
.topbar-title,
#budget-title {
  margin: 0;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-title {
  justify-self: center;
  text-align: center;
  max-width: 46vw;
  font-size: 17px;
  font-weight: 650;
}

.topbar-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
}

.icon-btn,
.back-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 12px;
  padding: 0 6px;
}

.icon-btn svg,
.back-btn svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.1;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-btn.accent {
  background: var(--accent);
  color: #fff;
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  margin-left: 2px;
}

html[data-theme="dark"] .icon-btn.accent { color: #07352E; }

.icon-btn:active,
.back-btn:active,
.btn:active { opacity: 0.72; transform: scale(0.97); }

.back-btn {
  justify-self: start;
  font-size: 17px;
  font-weight: 500;
  padding-left: 0;
}

.back-btn svg { width: 24px; height: 24px; margin-right: -2px; }

.search-wrap {
  padding: 8px 16px 10px;
  background: var(--toolbar);
  position: sticky;
  top: calc(56px + var(--safe-top) - 10px);
  z-index: 15;
}

.search-wrap[hidden] { display: none !important; }

.search-wrap input[type="search"] {
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  display: block;
  border: 0;
  background: var(--fill);
  border-radius: 10px;
  padding: 10px 14px;
  outline: none;
}

.search-wrap input[type="search"]:focus {
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.page {
  width: min(var(--max), 100%);
  margin: 0 auto;
  padding: 16px 16px calc(28px + var(--safe-bottom));
  flex: 1;
}

.card-list {
  background: var(--elevated);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.03);
}

.card-list:empty { display: none; }

.row {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  align-items: center;
  gap: 8px 10px;
  min-height: var(--row);
  padding: 12px 14px;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: inherit;
  position: relative;
  touch-action: pan-y;
}

.row + .row,
.budget-row + .budget-row,
.entry-row + .entry-row {
  border-top: 1px solid var(--separator);
}

.row:active { background: var(--fill); }

.row.dragging {
  background: var(--elevated);
  box-shadow: var(--shadow);
  border-radius: 12px;
  z-index: 5;
  opacity: 0.96;
}

.drag-handle {
  appearance: none;
  border: 0;
  background: transparent;
  width: 28px;
  height: 44px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--secondary);
  cursor: grab;
  touch-action: none;
  border-radius: 8px;
  opacity: 0.55;
}

.drag-handle svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.drag-handle:active { cursor: grabbing; }

.check {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--tertiary);
  background: transparent;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fff;
}

.check[aria-checked="true"] {
  background: var(--accent);
  border-color: var(--accent);
}

.check svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
}

.check[aria-checked="true"] svg { opacity: 1; }

html[data-theme="dark"] .check[aria-checked="true"] { color: #07352E; }

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

.row-title {
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-meta {
  color: var(--secondary);
  font-size: 13px;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-aside {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

.row-amount {
  font-weight: 650;
  letter-spacing: -0.02em;
}

.row-amount.income { color: var(--income); }
.row-amount.expense { color: var(--expense); }

.row-running {
  display: block;
  margin-top: 2px;
  color: var(--secondary);
  font-size: 12px;
}

.budget-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
}

.row-menu {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--tertiary);
  width: 36px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.row-menu svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.balance-pill {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.02em;
}

.balance-pill.positive { color: var(--income); }
.balance-pill.negative { color: var(--expense); }
.balance-pill.zero { color: var(--secondary); }

.totals {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  width: min(var(--max), calc(100% - 32px));
  margin: 12px auto 0;
  background: var(--separator);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.total {
  background: var(--elevated);
  padding: 12px 8px 14px;
  text-align: center;
}

.total-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--secondary);
  margin-bottom: 4px;
}

.total-value {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.03em;
  color: var(--label);
}

.total-value.income { color: var(--income); }
.total-value.expense { color: var(--expense); }
.total-value.positive { color: var(--income); }
.total-value.negative { color: var(--expense); }

.paid-line {
  width: min(var(--max), calc(100% - 32px));
  margin: 8px auto 0;
  color: var(--secondary);
  font-size: 13px;
  text-align: center;
}

.empty {
  text-align: center;
  padding: 48px 24px 24px;
  color: var(--secondary);
}

.empty.compact { padding-top: 32px; }

.empty h2 {
  margin: 12px 0 8px;
  color: var(--label);
  font-size: 22px;
  letter-spacing: -0.03em;
}

.empty p {
  margin: 0 auto 20px;
  max-width: 28em;
  line-height: 1.45;
}

.empty-art { color: var(--accent); margin-bottom: 8px; }

.btn {
  appearance: none;
  border: 0;
  background: var(--fill);
  color: var(--label);
  border-radius: 12px;
  padding: 11px 16px;
  font-weight: 600;
  min-height: 44px;
}

.btn.primary {
  background: var(--accent);
  color: #fff;
}

html[data-theme="dark"] .btn.primary { color: #07352E; }

.btn.ghost { background: transparent; color: var(--accent); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger.ghost { background: transparent; color: var(--danger); }
.btn.block { width: 100%; text-align: center; margin: 0 0 8px; display: block; }

.sheet,
.menu {
  border: 0;
  padding: 8px 20px 20px;
  width: min(520px, calc(100% - 24px));
  max-height: min(92vh, 880px);
  overflow: auto;
  border-radius: 20px;
  background: var(--elevated);
  color: var(--label);
  box-shadow: var(--shadow);
}

.sheet::backdrop,
.menu::backdrop {
  background: rgba(0, 0, 0, 0.42);
}

.sheet-handle {
  width: 36px;
  height: 5px;
  border-radius: 99px;
  background: var(--fill-strong);
  margin: 4px auto 12px;
}

.sheet h2 {
  margin: 0 0 16px;
  font-size: 22px;
  letter-spacing: -0.03em;
  text-align: center;
}

.field {
  display: block;
  margin: 0 0 14px;
}

.field > span,
.settings-block h3 {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--secondary);
  margin-bottom: 6px;
}

.field em {
  font-style: normal;
  font-weight: 400;
  color: var(--tertiary);
}

.field input[type="text"],
.field input[type="date"],
.field input[type="search"],
.field select,
.field textarea {
  width: 100%;
  border: 0;
  background: var(--fill);
  border-radius: 12px;
  padding: 12px 14px;
  outline: none;
}

.field textarea { resize: vertical; min-height: 68px; }

.field input:focus,
.field select:focus,
.field textarea:focus {
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.amount-wrap {
  display: flex;
  align-items: center;
  background: var(--fill);
  border-radius: 12px;
  padding-left: 14px;
}

.amount-prefix {
  color: var(--secondary);
  font-weight: 600;
}

.amount-wrap input {
  background: transparent !important;
  border-radius: 0 12px 12px 0 !important;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  background: var(--fill);
  padding: 4px;
  border-radius: 12px;
}

.segmented[aria-label="Appearance"] { grid-template-columns: 1fr 1fr 1fr; }

.segmented label {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border-radius: 9px;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
}

.segmented input { position: absolute; opacity: 0; pointer-events: none; }

.segmented label:has(input:checked) {
  background: var(--elevated);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
  color: var(--accent);
}

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

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  margin: 4px 0 12px;
  font-weight: 550;
}

.check-row input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}

.sheet-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding-bottom: var(--safe-bottom);
}

.spacer { flex: 1; }

.settings-row,
.settings-block {
  margin: 0 0 18px;
}

.settings-row p,
.settings-block p,
.hint, .about p {
  margin: 4px 0 0;
  color: var(--secondary);
  font-size: 14px;
  line-height: 1.45;
}

.menu {
  padding: 8px;
  width: min(360px, calc(100% - 24px));
}

.menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 12px;
  padding: 14px 14px;
  font-weight: 550;
  min-height: 48px;
}

.menu button:active { background: var(--fill); }
.menu button.danger { color: var(--danger); }
.menu button[data-action="close"] {
  color: var(--secondary);
  margin-top: 4px;
  border-top: 1px solid var(--separator);
  border-radius: 0 0 12px 12px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + var(--safe-bottom));
  transform: translateX(-50%);
  background: #1C1C1E;
  color: #fff;
  padding: 12px 18px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 550;
  box-shadow: var(--shadow);
  z-index: 80;
  max-width: calc(100% - 32px);
}

html[data-theme="dark"] .toast {
  background: #EBEBF0;
  color: #1C1C1E;
}

.stats-body {
  background: var(--elevated);
  border-radius: var(--radius-lg);
  padding: 24px 20px 28px;
}

.donut-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.donut {
  width: min(260px, 70vw);
  height: auto;
}

.donut-center-label {
  text-align: center;
  margin-top: -148px;
  margin-bottom: 120px;
  pointer-events: none;
}

.donut-wrap .chart-caption {
  margin: 8px 0 0;
  text-align: center;
}

.chart-caption {
  color: var(--secondary);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.chart-total {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.legend { list-style: none; margin: 24px 0 0; padding: 0; }

.legend li {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--separator);
  font-size: 15px;
}

.swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
}

.legend .amt {
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}

.search-hit {
  margin-top: 20px;
}

.search-hit h3 {
  margin: 0 0 8px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--secondary);
}

.entry-row.unpaid .row-title { /* no extra style needed */ }

.entry-row.paid .row-title,
.entry-row.paid .row-amount {
  color: var(--secondary);
}

@media (max-width: 600px) {
  .sheet, .menu {
    width: 100%;
    margin: auto 0 0;
    border-radius: 20px 20px 0 0;
    max-height: 94vh;
  }
  .topbar-title { max-width: 38vw; }
}

@media (prefers-reduced-motion: reduce) {
  .icon-btn:active, .back-btn:active, .btn:active { transform: none; }
}

@media (min-width: 821px) {
  .total-value { font-size: 18px; }
  .page { padding-top: 22px; }
}

/* ---- Hours & Pay, Budget Sheet, Pay Stubs, login ---- */
.section-h { margin: 22px 4px 8px; font-size: 13px; font-weight: 600; color: var(--secondary); text-transform: uppercase; letter-spacing: .02em; }
.tools { margin-bottom: 4px; }
.tool-row { display: flex; align-items: center; width: 100%; gap: 10px; padding: 14px 16px; border: 0; background: transparent; text-align: left; color: inherit; min-height: 64px; }
.tool-row + .tool-row { border-top: 1px solid var(--separator); }
.tool-row:active { background: var(--fill); }
.tool-main { flex: 1; display: grid; gap: 2px; min-width: 0; }
.tool-main .row-title { font-weight: 600; }
.tool-row svg { width: 18px; height: 18px; fill: none; stroke: var(--tertiary); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.card { background: var(--elevated); border-radius: var(--radius-lg); overflow: hidden; }
.pcard { padding: 6px 16px 14px; margin-bottom: 4px; }
.kv { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--separator); }
.kv.sub { padding: 0 0 8px; font-size: 13px; color: var(--secondary); border-bottom: 1px solid var(--separator); }
.kv.strong { font-weight: 700; }
.kv.net { font-size: 21px; color: var(--income); border-bottom: 0; padding-top: 12px; }
.pbtns { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.pbtns .btn { flex: 1; min-width: 150px; }
.pnav, .calhead { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; text-align: center; }
.calhead { margin: 0; padding: 10px 12px 4px; }
.pnav-t { font-weight: 700; font-size: 18px; }
.pnav .icon-btn:disabled { opacity: .3; }
.calgrid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; padding: 4px 12px; }
.calgrid.dow { text-align: center; font-size: 12px; color: var(--secondary); padding-bottom: 0; }
.cd { aspect-ratio: 1.15; min-height: 52px; border: 0; border-radius: 10px; background: transparent; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 5px 2px; color: var(--label); }
.cd.empty { visibility: hidden; }
.cd i { font-style: normal; font-size: 13px; color: var(--secondary); }
.cd b { font-size: 15px; color: var(--accent); min-height: 18px; }
.cd.inp { background: var(--fill); }
.cd.today i { color: #fff; background: var(--accent); border-radius: 50%; min-width: 22px; text-align: center; }
html[data-theme="dark"] .cd.today i { color: #07352E; }
.cd.stat b { color: var(--expense); }
.cd:active { background: var(--fill-strong); }
.calnote { padding: 6px 16px 14px; margin: 0; }
.check { display: flex; gap: 10px; align-items: center; margin: 0 0 16px; }
.days { display: flex; gap: 6px; }
.days label { flex: 1; text-align: center; }
.days input { position: absolute; opacity: 0; }
.days span { display: block; padding: 10px 0; border-radius: 10px; background: var(--fill); font-weight: 600; font-size: 14px; color: var(--label); }
.days input:checked + span { background: var(--accent); color: #fff; }
.sect { margin-bottom: 16px; }
.sect-h { background: var(--sc, #444); color: #fff; font-weight: 700; font-size: 13px; padding: 10px 16px; letter-spacing: .02em; }
.prow { display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%; border: 0; background: transparent; color: inherit; text-align: left; padding: 11px 16px; min-height: 48px; border-bottom: 1px solid var(--separator); }
button.prow:active { background: var(--fill); }
.pn { display: grid; min-width: 0; }
.pn small { color: var(--secondary); font-size: 12px; font-weight: 400; overflow: hidden; text-overflow: ellipsis; }
.prow b { white-space: nowrap; font-variant-numeric: tabular-nums; }
.prow b.inc { color: var(--income); } .prow b.exp { color: var(--expense); }
.prow.tot { font-weight: 700; background: var(--fill); }
.prow.cheque { font-weight: 600; background: var(--accent-soft); }
.prow.left { font-weight: 700; }
.prow.left.good b { color: var(--income); } .prow.left.bad b { color: var(--expense); }
.padd { width: 100%; border: 0; background: transparent; color: var(--accent); font-weight: 600; padding: 12px; }
.stub { flex-wrap: wrap; }
.stub-acts { display: flex; gap: 6px; flex-wrap: wrap; }
.stub-acts .btn { min-height: 36px; padding: 6px 12px; text-decoration: none; font-size: 15px; }
.login { max-width: 360px; text-align: center; padding-top: 12vh; }
.login img { border-radius: 16px; }
.login-err { color: var(--danger); font-size: 14px; }
.totals + .card { margin-top: 16px; }
