:root {
  --accent: #2d6a4f; --accent2: #1f5f8b; --ok: #1e6b3a; --bad: #b3261e; --warnc: #8a4b00;
  --bg: #f3f6f2; --card: #ffffff; --text: #17201b; --muted: #5b6862; --line: #dce3de; --soft: #e6f0ea; --track: #e3e9e5;
  --hero1: #2d6a4f; --hero2: #1f5f8b; --onaccent: #ffffff;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --accent: #74c69d; --accent2: #8ec5f0; --ok: #7fd49a; --bad: #ffb4ab; --warnc: #ffc078;
    --bg: #101613; --card: #19211d; --text: #e9f1ec; --muted: #a0aca6; --line: #2c3631; --soft: #1d2f26; --track: #2a3530;
    --hero1: #1f4d39; --hero2: #17405f; --onaccent: #08251a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --accent: #74c69d; --accent2: #8ec5f0; --ok: #7fd49a; --bad: #ffb4ab; --warnc: #ffc078;
  --bg: #101613; --card: #19211d; --text: #e9f1ec; --muted: #a0aca6; --line: #2c3631; --soft: #1d2f26; --track: #2a3530;
  --hero1: #1f4d39; --hero2: #17405f; --onaccent: #08251a;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 17px/1.45 -apple-system, system-ui, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
body { overflow-x: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent2); overflow-wrap: anywhere; }
h1 { font-size: 1.4rem; margin: 6px 0 12px; }
h2 { font-size: .9rem; margin: 0 0 8px; color: var(--accent); text-transform: uppercase; letter-spacing: .04em; }
h3.month { font-size: .85rem; color: var(--muted); margin: 14px 0 4px; font-weight: 600; }
p { margin: 6px 0; }
.muted { color: var(--muted); } .small { font-size: .86rem; } .center { text-align: center; }
.warn { color: var(--warnc); } .ok { color: var(--ok); }
.danger { color: var(--bad) !important; }
.cap { margin-top: -2px; }

.top { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px; background: var(--bg); border-bottom: 1px solid var(--line); }
.brand { font-size: 1.12rem; }
.hb { flex: 0 0 auto; background: var(--card); color: var(--accent); border: 1px solid var(--line); border-radius: 20px; padding: 6px 14px; font-weight: 600; min-height: 36px; }
main { padding: 12px 16px calc(100px + env(safe-area-inset-bottom)); max-width: 640px; margin: 0 auto; }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs button { background: none; border: 0; padding: 8px 0 6px; font-size: .7rem; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 52px; }
.tabs button span { font-size: 1.25rem; line-height: 1; }
.tabs button.on { color: var(--accent); font-weight: 700; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; margin: 0 0 12px; display: block; width: 100%; }
.btn, button.btn { display: inline-block; background: var(--accent); color: var(--onaccent); border: 0; border-radius: 12px; padding: 10px 16px; font-weight: 600; text-decoration: none; text-align: center; min-height: 44px; cursor: pointer; }
.btn[disabled] { opacity: .5; }
.btn.big { display: block; width: 100%; padding: 14px; font-size: 1.05rem; margin-bottom: 12px; }
.btn.light { background: #fff; color: #2d6a4f; }
.ghost, button.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; min-height: 40px; cursor: pointer; }
button.ghost.small { padding: 4px 10px; font-size: .82rem; min-height: 34px; }
.linkish { background: none; border: 0; color: var(--accent2); text-decoration: underline; padding: 0; cursor: pointer; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid2 > * { min-width: 0; }
input, select, textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); min-height: 44px; }
textarea { min-height: 96px; font-size: .9rem; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.form label { display: block; margin-bottom: 10px; font-size: .86rem; color: var(--muted); }
.form label input, .form label select, .form label textarea { margin-top: 4px; color: var(--text); font-size: 1rem; }
label.inline { display: flex; align-items: center; gap: 8px; font-size: .9rem; color: var(--muted); }
label.inline input { flex: 1; min-width: 0; color: var(--text); }
.check { display: flex !important; align-items: flex-start; gap: 10px; padding: 6px 0; color: var(--text) !important; font-size: .95rem !important; }
.check input { width: 22px; height: 22px; min-height: 0; flex-shrink: 0; accent-color: var(--accent); margin: 2px 0 0; }
[hidden] { display: none !important; }

.hero { background: linear-gradient(135deg, var(--hero1), var(--hero2)); color: #fff; border: 0; }
.hero h1 { color: #fff; font-size: 1.3rem; margin: 2px 0 6px; }
.hero p { color: rgba(255,255,255,.93); }
.status p { margin: 2px 0; }

.route .rhead, .rhead { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.route .rhead h2 { margin: 0; }
.big { font-size: 2rem; font-weight: 800; line-height: 1.15; margin-top: 6px; font-variant-numeric: tabular-nums; }
.bar { height: 10px; border-radius: 6px; background: var(--track); overflow: hidden; margin: 8px 0 6px; }
.bar > span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 6px; }
.bar.thin { height: 6px; }
.bar.over > span { background: var(--bad); }
.onhand { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 6px; }

.kv { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); align-items: baseline; }
.kv:last-child { border-bottom: 0; }
.kv > span:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.kv .l { flex: 1 1 auto; min-width: 0; }

.badge { display: inline-block; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--warnc); border: 1px solid currentColor; border-radius: 8px; padding: 0 6px; vertical-align: middle; white-space: nowrap; }
.badge.soft { color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: var(--soft); border: 1px solid var(--line); color: var(--text); border-radius: 12px; padding: 8px 12px; text-align: left; min-height: 44px; cursor: pointer; max-width: 100%; overflow-wrap: anywhere; }
.chip.grow { flex: 1; min-width: 0; }
.fav { display: flex; gap: 8px; align-items: center; margin: 0 0 8px; }
.chipsrow { display: flex; gap: 8px; flex-wrap: wrap; }
.chipsrow button { background: var(--bg); border: 1px solid var(--line); border-radius: 20px; padding: 8px 14px; min-height: 40px; cursor: pointer; }
.chipsrow button.on { background: var(--accent); color: var(--onaccent); border-color: var(--accent); font-weight: 600; }

.basket .item { display: flex; justify-content: space-between; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.basket .item:last-child { border-bottom: 0; }
.basket .l { min-width: 0; overflow-wrap: anywhere; }
.stepper { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.stepper span { min-width: 1.6em; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.verdict { font-size: 1.1rem; margin-bottom: 6px; }
.result.good { border: 2px solid var(--ok); }
.result.bad { border: 2px solid var(--bad); }
.fitlist { margin: 6px 0; padding-left: 20px; }

.entry { display: flex; width: 100%; justify-content: space-between; gap: 10px; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line); padding: 10px 0; cursor: pointer; color: var(--text); }
.entry .l { min-width: 0; overflow-wrap: anywhere; }
.entry .r { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.calc { background: var(--soft); border-radius: 10px; padding: 8px 10px; margin: 0 0 10px; }
.routeset { border-top: 1px solid var(--line); padding: 6px 0 4px; }
.routeset:first-of-type { border-top: 0; }
.filebtn { display: inline-block; position: relative; overflow: hidden; margin-top: 8px; text-align: center; }
.filebtn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.preview { background: var(--soft); border-radius: 10px; padding: 10px; }
ul.rules, ul.srcs { padding-left: 18px; margin: 6px 0; }
ul.rules li, ul.srcs li { margin: 4px 0; }
details summary { cursor: pointer; color: var(--accent); margin: 6px 0; }
.foot { margin-top: 18px; }

.toast { position: fixed; left: 12px; right: 12px; bottom: calc(64px + env(safe-area-inset-bottom)); z-index: 6; background: var(--text); color: var(--bg);
  border-radius: 12px; padding: 10px 12px; display: flex; gap: 10px; justify-content: space-between; align-items: center; max-width: 616px; margin: 0 auto; box-shadow: 0 4px 16px rgba(0,0,0,.25); }
.toast .ghost { color: var(--bg); border-color: var(--bg); }

.lock { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
.lockcard { max-width: 360px; text-align: center; }
.lockicon { font-size: 2.2rem; }
.lockcard .form label { text-align: left; }
.lockcard input { font-size: 1.4rem; letter-spacing: .3em; text-align: center; }
