:root {
  --ink: #241f1a;
  --ink-soft: #6d635a;
  --paper: #fbf7f2;
  --card: #ffffff;
  --line: #e8e0d6;
  --accent: #8a6a4f;
  --green: #3f7d55;
  --green-bg: #eaf3ed;
  --amber: #9a6f17;
  --amber-bg: #fbf2dd;
  --red: #a3402f;
  --red-bg: #fbeae6;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(36, 31, 26, .05), 0 8px 24px rgba(36, 31, 26, .05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.5 ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

body.centered { display: flex; align-items: center; min-height: 100vh; }

.wrap {
  width: 100%;
  max-width: 540px;
  margin: 0 auto;
  padding: 28px 18px 48px;
}

body.centered .wrap { padding-block: 32px; }

/* --- header --- */
.head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.head__title { margin: 0; font-size: 1.25rem; font-weight: 650; letter-spacing: -.01em; }
.head__out { margin: 0; }
.link {
  background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--ink-soft); font: inherit; font-size: .875rem; text-decoration: underline;
  text-underline-offset: 3px;
}
.link:hover { color: var(--ink); }

/* --- hero --- */
.hero { margin: 26px 0 20px; }
.hero__label { margin: 0 0 6px; color: var(--ink-soft); font-size: .8125rem; text-transform: uppercase; letter-spacing: .08em; }
.hero__value { margin: 0; font-size: clamp(2.5rem, 12vw, 3.5rem); font-weight: 680; letter-spacing: -.03em; line-height: 1.05; font-variant-numeric: tabular-nums; }

/* --- runway panel --- */
.panel { border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; background: var(--card); box-shadow: var(--shadow); }
.panel--green { background: var(--green-bg); border-color: #cfe3d6; }
.panel--amber { background: var(--amber-bg); border-color: #ecdcb6; }
.panel--red { background: var(--red-bg); border-color: #f0cdc4; }
.panel__row { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.panel__label { margin: 0 0 2px; color: var(--ink-soft); font-size: .8125rem; }
.panel__value { margin: 0; font-size: 1.75rem; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.panel__note { margin: 12px 0 0; color: var(--ink-soft); font-size: .8125rem; line-height: 1.45; }
.badge { flex: none; border-radius: 999px; padding: 5px 12px; font-size: .8125rem; font-weight: 600; white-space: nowrap; }
.badge--green { background: var(--green); color: #fff; }
.badge--amber { background: var(--amber); color: #fff; }
.badge--red { background: var(--red); color: #fff; }
.badge--unknown { background: var(--ink-soft); color: #fff; }

/* --- blocks --- */
.block { margin-top: 32px; }
.block__title { margin: 0; font-size: .8125rem; font-weight: 650; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); }
.block__sub { margin: 4px 0 0; color: var(--ink-soft); font-size: .8125rem; }

/* --- goals --- */
.goals { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 12px; }
.goal { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.goal__head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.goal__name { font-weight: 600; }
.goal__sum { font-variant-numeric: tabular-nums; font-weight: 650; }
.goal__note { margin: 10px 0 0; color: var(--ink-soft); font-size: .8125rem; font-variant-numeric: tabular-nums; }
.bar { margin-top: 12px; height: 7px; border-radius: 999px; background: #efe8df; overflow: hidden; }
.bar__fill { display: block; height: 100%; border-radius: 999px; background: var(--accent); min-width: 0; }

/* --- categories --- */
.cats { list-style: none; margin: 14px 0 0; padding: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.cat { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; padding: 13px 16px; border-top: 1px solid var(--line); }
.cat:first-child { border-top: 0; }
.cat__sum { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.empty { margin: 14px 0 0; padding: 20px 16px; background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); color: var(--ink-soft); text-align: center; }

.foot { margin-top: 36px; color: var(--ink-soft); font-size: .75rem; text-align: center; }
.foot p { margin: 0; }

/* --- cards / forms --- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 28px 24px; box-shadow: var(--shadow); }
.card--narrow { max-width: 380px; margin: 0 auto; }
.card__title { margin: 0 0 6px; font-size: 1.375rem; font-weight: 650; letter-spacing: -.02em; }
.muted { margin: 0 0 20px; color: var(--ink-soft); font-size: .9375rem; }
.small { font-size: .8125rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; font-size: .875rem; background: var(--paper); border-radius: 8px; padding: 10px; }

label { display: block; margin: 14px 0 6px; font-size: .8125rem; font-weight: 600; color: var(--ink-soft); }
input[type=text], input[type=password] {
  width: 100%; padding: 11px 12px; font: inherit; color: var(--ink);
  background: var(--paper); border: 1px solid var(--line); border-radius: 10px;
}
input:focus-visible, button:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button[type=submit] {
  width: 100%; margin-top: 22px; padding: 12px; font: inherit; font-weight: 600;
  color: #fff; background: var(--ink); border: 0; border-radius: 10px; cursor: pointer;
}
button[type=submit]:hover { background: #3a3129; }

.alert { margin: 16px 0 0; padding: 11px 13px; border-radius: 10px; background: var(--red-bg); border: 1px solid #f0cdc4; color: var(--red); font-size: .875rem; }

.qr { display: flex; justify-content: center; padding: 16px; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.qr svg { width: 100%; max-width: 220px; height: auto; display: block; }
.details { margin-top: 14px; font-size: .875rem; color: var(--ink-soft); }
.details summary { cursor: pointer; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) {
    --ink: #f0eae3; --ink-soft: #a89d92; --paper: #17140f; --card: #211d18;
    --line: #342e27; --accent: #c49a73;
    --green: #6fb98a; --green-bg: #1b2a21; --amber: #d6a842; --amber-bg: #2b2415;
    --red: #e08470; --red-bg: #2d1b17;
    --shadow: 0 1px 2px rgba(0,0,0,.3);
  }
  :root:not([data-theme=light]) .badge--green,
  :root:not([data-theme=light]) .badge--amber,
  :root:not([data-theme=light]) .badge--red { color: #17140f; }
  :root:not([data-theme=light]) .bar { background: #342e27; }
  :root:not([data-theme=light]) button[type=submit] { background: var(--accent); color: #17140f; }
  :root:not([data-theme=light]) button[type=submit]:hover { background: #d4ab84; }
  :root:not([data-theme=light]) .qr { background: #fff; }
}

/* progress-bar widths as classes: a strict CSP forbids inline style attributes */
.bar__fill[data-pct="0"] { width: 0%; }
.bar__fill[data-pct="5"] { width: 5%; }
.bar__fill[data-pct="10"] { width: 10%; }
.bar__fill[data-pct="15"] { width: 15%; }
.bar__fill[data-pct="20"] { width: 20%; }
.bar__fill[data-pct="25"] { width: 25%; }
.bar__fill[data-pct="30"] { width: 30%; }
.bar__fill[data-pct="35"] { width: 35%; }
.bar__fill[data-pct="40"] { width: 40%; }
.bar__fill[data-pct="45"] { width: 45%; }
.bar__fill[data-pct="50"] { width: 50%; }
.bar__fill[data-pct="55"] { width: 55%; }
.bar__fill[data-pct="60"] { width: 60%; }
.bar__fill[data-pct="65"] { width: 65%; }
.bar__fill[data-pct="70"] { width: 70%; }
.bar__fill[data-pct="75"] { width: 75%; }
.bar__fill[data-pct="80"] { width: 80%; }
.bar__fill[data-pct="85"] { width: 85%; }
.bar__fill[data-pct="90"] { width: 90%; }
.bar__fill[data-pct="95"] { width: 95%; }
.bar__fill[data-pct="100"] { width: 100%; }
