:root {
  --ink: #0F1720;
  --ink-2: #0B121A;
  --surface: #16212D;
  --surface-2: #1B2836;
  --line: #26333F;
  --line-soft: #202C38;
  --paper: #F2EFE9;
  --muted: #8A97A6;
  --muted-2: #5E6B78;
  --teal: #5FBFA6;
  --teal-dim: #3C6E62;
  --coral: #E8785B;
  --radius: 14px;
  --maxw: 520px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  min-height: 100dvh;
  font-family: 'Space Grotesk', system-ui, -apple-system, sans-serif;
  color: var(--paper);
  background:
    radial-gradient(120% 78% at 50% -8%, #17242F 0%, rgba(23, 36, 47, 0) 55%),
    linear-gradient(180deg, var(--ink) 0%, var(--ink-2) 100%);
  background-attachment: fixed;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  padding: max(20px, env(safe-area-inset-top)) 20px calc(30px + env(safe-area-inset-bottom));
}

.app { width: 100%; max-width: var(--maxw); margin: 0 auto; }

.eyebrow {
  font-weight: 600;
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- setup ---------- */
.setup {
  padding-top: 13vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-width: 420px;
  margin: 0 auto;
}
.setup__title { font-weight: 600; font-size: 1.5rem; letter-spacing: -0.01em; line-height: 1.25; }
.setup__hint { font-size: 0.86rem; color: var(--muted); }

/* ---------- head ---------- */
.head { padding: 6px 0 22px; }

/* ---------- hero ---------- */
.hero { text-align: center; padding: 6px 0 4px; }
.hero__num {
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-weight: 500;
  font-size: clamp(3rem, 15.5vw, 7.25rem);
  line-height: 0.98;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: var(--paper);
  word-break: break-word;
}
.hero__unit {
  margin-top: 14px;
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- today's budget meter ---------- */
.today { margin: 26px auto 0; max-width: 420px; }
.today__bar { height: 8px; border-radius: 99px; background: var(--line-soft); overflow: hidden; }
.today__fill {
  height: 100%;
  width: 0;
  border-radius: 99px;
  background: var(--teal);
  transition: width 0.45s cubic-bezier(0.2, 0.7, 0.2, 1), background-color 0.3s;
}
.today__label {
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.today.is-over .today__fill { background: var(--coral); }
.today.is-over .today__label { color: var(--coral); }

/* ---------- pay-cycle track (signature) ---------- */
.cycle { margin: 34px auto 0; max-width: 460px; }
.cycle__track { position: relative; height: 2px; border-radius: 2px; background: var(--line); }
.cycle__track::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 2px;
  background: repeating-linear-gradient(
    90deg,
    transparent 0,
    transparent calc(100% / 14 - 1.2px),
    var(--line-soft) calc(100% / 14 - 1.2px),
    var(--line-soft) calc(100% / 14)
  );
}
.cycle__elapsed {
  position: absolute;
  left: 0; top: 0;
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--teal-dim), var(--teal));
  transition: width 0.5s ease;
}
.cycle__marker {
  position: absolute;
  top: 50%;
  left: 0;
  width: 11px; height: 11px;
  border-radius: 50%;
  background: var(--paper);
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 4px rgba(242, 239, 233, 0.07), 0 0 14px rgba(95, 191, 166, 0.55);
  transition: left 0.5s ease;
}
.cycle__ends {
  display: flex;
  justify-content: space-between;
  margin-top: 14px;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted-2);
}
.cycle__countdown {
  margin-top: 8px;
  text-align: center;
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-size: 0.82rem;
  color: var(--muted);
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}

/* ---------- stats ---------- */
.stats {
  display: flex;
  gap: 1px;
  margin: 34px auto 0;
  max-width: 460px;
  background: var(--line-soft);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  overflow: hidden;
}
.stat { flex: 1; background: var(--surface); padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; }
.stat__label { font-size: 0.68rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted-2); font-weight: 600; }
.stat__value {
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-size: 1.3rem;
  color: var(--paper);
  font-variant-numeric: tabular-nums;
}

/* ---------- entry ---------- */
.entry { margin: 26px auto 0; max-width: 460px; display: flex; flex-direction: column; gap: 12px; }
.entry__row { display: flex; gap: 10px; }

.field {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 12px;
  height: 52px;
}
.field--sm { width: 130px; flex: none; }
.field__prefix { font-family: 'IBM Plex Mono', ui-monospace, monospace; color: var(--muted); font-size: 1rem; }
.field__input {
  width: 100%;
  min-width: 0;
  border: none;
  background: none;
  outline: none;
  color: var(--paper);
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
}
.entry__note {
  flex: 1;
  min-width: 0;
  height: 52px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 12px;
  padding: 0 14px;
  color: var(--paper);
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
}
.entry__note::placeholder, .field__input::placeholder { color: var(--muted-2); }
.entry__btns { display: flex; gap: 10px; }

/* ---------- buttons ---------- */
.btn {
  appearance: none;
  cursor: pointer;
  border-radius: 12px;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
  height: 52px;
  padding: 0 18px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--paper);
  transition: background-color 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:active { transform: translateY(1px); }
.entry__btns .btn { flex: 1; }
.btn--credit { border-color: var(--teal-dim); color: var(--teal); }
.btn--credit:hover { background: rgba(95, 191, 166, 0.1); }
.btn--debit { border-color: var(--line); color: var(--paper); }
.btn--debit:hover { background: rgba(242, 239, 233, 0.05); }
.btn--solid { background: var(--paper); color: var(--ink); border-color: var(--paper); }
.btn--solid:hover { background: #fff; }
.btn--ghost { color: var(--muted); border-color: transparent; }
.btn--ghost:hover { color: var(--paper); }

/* ---------- activity log ---------- */
.log { margin: 36px auto 0; max-width: 460px; }
.log__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line-soft);
}
.section-label { font-size: 0.68rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted-2); font-weight: 600; }
.link {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.82rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.link:hover { color: var(--paper); }

.log__list { list-style: none; }
.tx { display: flex; align-items: center; gap: 12px; padding: 13px 2px; border-bottom: 1px solid var(--line-soft); }
.tx__note { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.92rem; color: var(--paper); }
.tx__time { font-size: 0.72rem; color: var(--muted-2); white-space: nowrap; }
.tx__amt {
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.tx__amt--credit { color: var(--teal); }
.tx__amt--debit { color: var(--paper); }
.tx__del {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted-2);
  font-size: 0.95rem;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 6px;
}
.tx__del:hover { color: var(--coral); background: rgba(232, 120, 91, 0.1); }
.log__empty { padding: 20px 2px; color: var(--muted-2); font-size: 0.85rem; }

/* ---------- balance panel ---------- */
.panel {
  margin: 16px auto 0;
  max-width: 460px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.panel__label { display: block; font-size: 0.72rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin-bottom: 10px; }
.panel__row { display: flex; gap: 10px; flex-wrap: wrap; }
.panel__hint { margin-top: 10px; font-size: 0.78rem; color: var(--muted-2); }

/* ---------- a11y + responsive ---------- */
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; border-radius: 8px; }

@media (max-width: 420px) {
  .field--sm { width: 112px; }
  .stat__value { font-size: 1.15rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
