/* Stash — dark ground, money green for progress and "good", amber for "watch it",
   red for "over". One accent per meaning, so colour alone tells you how you're doing. */
:root {
  --bg: #0b0f17;
  --surface: #131a25;
  --surface-2: #1a2331;
  --line: #263142;
  --text: #e8edf5;
  --muted: #8b97a8;
  --faint: #5d6a7d;
  --green: #3ddc97;
  --green-dim: #1f7a55;
  --green-bg: rgba(61, 220, 151, 0.12);
  --cyan: #4cc9f0;
  --amber: #ffb547;
  --amber-bg: rgba(255, 181, 71, 0.12);
  --red: #ff6b6b;
  --red-bg: rgba(255, 107, 107, 0.12);
  --radius: 16px;
  --radius-sm: 10px;
  --font: "Space Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
a { color: var(--cyan); }
b { font-weight: 700; }

#app { display: flex; flex-direction: column; height: 100%; max-width: 640px; margin: 0 auto; }
#screen {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: max(16px, env(safe-area-inset-top)) 16px 24px;
}

/* ---- Tab bar ---- */
#tabs {
  display: flex; gap: 2px; padding: 6px 8px max(8px, env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--line);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 0; border: none; background: none; color: var(--faint);
  font-size: 11px; font-weight: 600; cursor: pointer; border-radius: var(--radius-sm);
}
.tab svg { width: 22px; height: 22px; }
.tab.active { color: var(--green); }

/* ---- Header ---- */
.head { display: flex; align-items: flex-start; gap: 12px; margin: 6px 0 18px; }
.head h1 { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.head .sub { color: var(--muted); font-size: 13px; }
.head .grow { flex: 1; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--muted); display: grid; place-items: center; cursor: pointer;
}
.icon-btn svg { width: 20px; height: 20px; }

/* ---- Cards ---- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px;
}
.card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.card-head h2 { margin: 0; font-size: 13px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.card-head .right { margin-left: auto; }
.section-title { margin: 22px 0 10px; font-size: 13px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }

.big { font-size: 32px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.05; font-variant-numeric: tabular-nums; }
.big small { font-size: 14px; font-weight: 500; color: var(--muted); letter-spacing: 0; white-space: nowrap; }
.row-between { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.pct { font-size: 13px; font-weight: 600; color: var(--green); white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }

.line { margin: 10px 0 0; font-size: 14px; color: var(--muted); }
.line:empty { display: none; }
.line b { color: var(--text); }
.hint { font-size: 12px; color: var(--faint); }
.good { color: var(--green); }
.warn { color: var(--amber); }
.bad { color: var(--red); }
.status { min-height: 1.4em; }
.status:empty { display: block; }

/* ---- Progress ---- */
.bar { height: 10px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-top: 10px; }
.bar > i { display: block; height: 100%; width: 0; border-radius: 99px; background: var(--green); transition: width 0.4s ease; }
.bar > i.warn { background: var(--amber); }
.bar > i.bad { background: var(--red); }

/* Paycheck breakdown: one stacked bar, then the rows it's made of */
.stack { display: flex; height: 14px; border-radius: 99px; overflow: hidden; background: var(--surface-2); margin: 12px 0; }
.stack > i { display: block; height: 100%; }
.legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.legend li { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.legend .dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend .name { flex: 1; color: var(--muted); }
.legend .amt { font-weight: 600; font-variant-numeric: tabular-nums; }
.legend li.total { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 2px; }
.legend li.total .name { color: var(--text); font-weight: 600; }

/* ---- Forms ---- */
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label { font-size: 12px; font-weight: 600; color: var(--muted); }
.input, select.input {
  width: 100%; min-width: 0; padding: 11px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--bg); color: var(--text); font-size: 15px;
}
.input:focus { outline: none; border-color: var(--green); }
.input.invalid { border-color: var(--red); background: var(--red-bg); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.full { grid-column: 1 / -1; }
.row { display: flex; gap: 8px; margin-top: 10px; align-items: stretch; }
.row .input { flex: 1; }
.row .amt-input { flex: 0 0 92px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 0 16px; min-height: 44px; border-radius: var(--radius-sm); border: none;
  background: var(--green); color: #06281a; font-weight: 700; cursor: pointer; white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn.ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: var(--red-bg); color: var(--red); }
.btn.wide { width: 100%; margin-top: 12px; }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 13px; }
.grow { flex: 1; }
.link-btn { border: none; background: none; color: var(--cyan); padding: 0; cursor: pointer; font-size: 13px; font-weight: 600; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 7px 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface-2);
  font-size: 13px; font-weight: 600; cursor: pointer; color: var(--text);
}
.chip.active { background: var(--green); border-color: var(--green); color: #06281a; }
.tag {
  display: inline-block; padding: 3px 9px; border-radius: 99px; font-size: 11px; font-weight: 700;
  background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.tag.good { background: var(--green-bg); color: var(--green); }
.tag.warn { background: var(--amber-bg); color: var(--amber); }
.tag.bad { background: var(--red-bg); color: var(--red); }

/* ---- Lists ---- */
.list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: var(--surface-2); border-radius: var(--radius-sm); font-size: 14px;
}
.item .main { flex: 1; min-width: 0; }
.item .title { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.item .meta { display: block; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.item.done .title, .item.done .amt { color: var(--faint); text-decoration: line-through; }
.x {
  flex: none; width: 28px; height: 28px; border-radius: 50%; border: none; background: none;
  color: var(--faint); font-size: 20px; line-height: 1; cursor: pointer;
}
.check {
  flex: none; width: 28px; height: 28px; border-radius: 8px; border: 2px solid var(--line);
  background: none; cursor: pointer; display: grid; place-items: center; color: #06281a;
}
.check.on { background: var(--green); border-color: var(--green); }
.check svg { width: 16px; height: 16px; }
.empty { color: var(--faint); font-size: 14px; padding: 6px 2px; }
.mini-select {
  border: 1px solid var(--line); background: var(--bg); color: var(--text); border-radius: 8px;
  padding: 4px 6px; font-size: 12px; max-width: 110px;
}

details.card > summary { cursor: pointer; list-style: none; font-weight: 600; display: flex; align-items: center; gap: 8px; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::after { content: "▾"; margin-left: auto; color: var(--faint); transition: transform 0.2s; }
details.card[open] > summary::after { transform: rotate(180deg); }

/* Month bars on Spend */
.bars { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.bars .b { display: grid; grid-template-columns: 74px 1fr 64px; align-items: center; gap: 8px; font-size: 13px; }
.bars .b .t { height: 10px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bars .b .t i { display: block; height: 100%; background: var(--cyan); border-radius: 99px; }
.bars .b .v { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }

/* ---- Toast ---- */
.toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--green); color: #06281a; font-weight: 700; font-size: 14px;
  padding: 10px 16px; border-radius: 99px; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
  max-width: calc(100% - 32px); text-align: center; z-index: 10; animation: toast-in 0.25s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } .bar > i { transition: none; } }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }
