:root {
  --bg: #f4f6f5;
  --card: #ffffff;
  --text: #14201d;
  --muted: #64736f;
  --line: #e2e8e6;
  --brand: #0f766e;
  --brand-text: #ffffff;
  --up: #15803d;
  --down: #b91c1c;
  --warn-bg: #fef3c7;
  --warn-text: #78350f;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1513;
    --card: #17211e;
    --text: #e6eeeb;
    --muted: #93a39e;
    --line: #26332f;
    --brand: #2dd4bf;
    --brand-text: #06201c;
    --up: #4ade80;
    --down: #f87171;
    --warn-bg: #3b2f0b;
    --warn-text: #fde68a;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
hr { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
#app { max-width: 640px; margin: 0 auto; padding: 16px 16px calc(84px + env(safe-area-inset-bottom)); }

h1 { font-size: 20px; margin: 4px 0 16px; }
h2 { font-size: 16px; margin: 24px 0 8px; }
p { margin: 8px 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.up { color: var(--up); }
.down { color: var(--down); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; margin: 0 0 12px; }
.hero .label { color: var(--muted); font-size: 13px; }
.hero .value { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid .card { margin: 0; }
.stat .label { color: var(--muted); font-size: 12px; }
.stat .value { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }

.row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row > div:last-child { text-align: right; }
.row .title { font-weight: 600; }
.row .sub { color: var(--muted); font-size: 13px; }

.alert { background: var(--warn-bg); color: var(--warn-text); border-radius: 12px; padding: 10px 14px; margin: 0 0 12px; font-size: 14px; }

form { display: grid; gap: 10px; }
label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; min-height: 44px;
}
input[type="checkbox"] { width: 22px; min-height: 22px; height: 22px; padding: 0; accent-color: var(--brand); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; }
.check { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.check:first-child { border-top: 0; }
.check .name { flex: 1; color: var(--text); font-size: 15px; }
.check select { width: auto; min-height: 36px; padding: 4px 8px; font-size: 13px; }

button {
  font: inherit; font-weight: 600; border: 0; border-radius: 10px; padding: 11px 16px; min-height: 44px;
  background: var(--brand); color: var(--brand-text); cursor: pointer;
}
button.ghost { background: transparent; color: var(--brand); border: 1px solid var(--line); }
button.danger { background: transparent; color: var(--down); border: 1px solid var(--line); }
button.mini { min-height: 32px; padding: 4px 10px; font-size: 13px; }
button:disabled { opacity: .5; }

details.card > summary { font-weight: 600; cursor: pointer; list-style: none; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::after { content: "+"; float: right; color: var(--muted); }
details.card[open] > summary::after { content: "–"; }
details.card[open] > summary { margin-bottom: 12px; }

nav {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center;
  background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
nav button {
  flex: 1; max-width: 128px; background: none; color: var(--muted); border-radius: 0;
  font-size: 12px; font-weight: 500; padding: 10px 2px; min-height: 56px;
}
nav button.active { color: var(--brand); font-weight: 700; }

#toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); margin: 0 auto; max-width: 480px;
  background: var(--text); color: var(--bg); padding: 12px 16px; border-radius: 12px; font-size: 14px; text-align: center; z-index: 10;
}
.login { max-width: 360px; margin: 12vh auto 0; }
