:root {
  --bg: #0b0d0c;
  --panel: #141917;
  --panel-2: #1c2421;
  --line: rgba(255, 255, 255, .1);
  --text: #eef1ef;
  --muted: #9aa5a0;
  --accent: #2bd48a;
  --accent-ink: #04180e;
  --danger: #ff7a6e;
  --warn: #f2b84b;
  --r: 16px;
  --tab-h: 62px;
  --bar-h: 76px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f3f6f4; --panel: #ffffff; --panel-2: #e9efec; --line: rgba(0, 0, 0, .12);
    --text: #0f1512; --muted: #5a6962; --accent: #0b9a60; --accent-ink: #ffffff;
    --danger: #c8372a; --warn: #9a6208; color-scheme: light;
  }
}

[hidden] { display: none !important; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
.num { font-variant-numeric: tabular-nums; }

#app { max-width: 560px; margin: 0 auto; min-height: 100dvh; }

/* шапка */
.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; background: var(--bg); border-bottom: 1px solid var(--line);
}
.top h1 { margin: 0; font-size: 18px; letter-spacing: .01em; }
.top .sub { color: var(--muted); font-size: 13px; }
.ghost {
  background: none; border: 1px solid var(--line); border-radius: 12px; min-height: 40px; padding: 0 12px; color: var(--muted);
}
.pending { border-color: var(--warn); color: var(--warn); }

main { padding: 14px 16px calc(var(--tab-h) + env(safe-area-inset-bottom) + 24px); }
main.with-bar { padding-bottom: calc(var(--tab-h) + var(--bar-h) + env(safe-area-inset-bottom) + 24px); }

/* нижние панели */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; justify-content: center;
  background: var(--panel); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabs-in { display: flex; width: 100%; max-width: 560px; }
.tab {
  flex: 1; min-height: var(--tab-h); background: none; border: 0; color: var(--muted); font-size: 14px; font-weight: 600;
  border-top: 3px solid transparent;
}
.tab[aria-current="page"] { color: var(--accent); border-top-color: var(--accent); }

.bar {
  position: fixed; left: 0; right: 0; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom)); z-index: 9;
  display: flex; justify-content: center; background: var(--panel); border-top: 1px solid var(--line);
}
.bar-in { width: 100%; max-width: 560px; padding: 10px 16px; display: flex; align-items: center; gap: 12px; min-height: var(--bar-h); }
.bar .sum { flex: 1; min-width: 0; }
.bar .sum b { display: block; font-size: 22px; line-height: 1.1; }
.bar .sum span { display: block; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar .sum .need { color: var(--warn); }

/* блоки формы */
.sec { margin: 0 0 18px; }
.sec > .lbl, label.lbl { display: block; margin: 0 0 8px; color: var(--muted); font-size: 13px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin: 0 0 14px; }
.card h2 { margin: 0 0 10px; font-size: 14px; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; font-weight: 600; }

.chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 8px; }
.chips.sm { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); }
.chips.md { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); }
.chip {
  min-height: 48px; padding: 6px 10px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px;
  font-weight: 600; text-align: center; line-height: 1.2;
}
.chip small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip[aria-pressed="true"] small { color: inherit; opacity: .8; }

.inp {
  width: 100%; min-height: 52px; padding: 0 14px; font-size: 18px; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 14px; outline: none;
}
.inp:focus { border-color: var(--accent); }
.inp::placeholder { color: var(--muted); opacity: .7; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row.pct { grid-template-columns: 96px 1fr; }
.hint { margin: 6px 0 0; color: var(--muted); font-size: 13px; }

.btn {
  min-height: 54px; padding: 0 22px; border: 0; border-radius: 14px; background: var(--accent); color: var(--accent-ink);
  font-weight: 700; font-size: 17px;
}
.btn:disabled { opacity: .35; cursor: not-allowed; }
.btn.block { width: 100%; }
.btn.alt { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: none; color: var(--danger); border: 1px solid var(--danger); }
.btn.sm { min-height: 44px; font-size: 15px; padding: 0 14px; }

.stepper { display: flex; align-items: center; gap: 12px; }
.stepper button { width: 48px; height: 48px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel-2); font-size: 22px; font-weight: 700; }
.stepper output { min-width: 40px; text-align: center; font-size: 20px; font-weight: 700; }

/* итоги */
.nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 14px; }
.nav button { width: 48px; height: 48px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel); font-size: 22px; }
.nav button:disabled { opacity: .3; }
.nav strong { font-size: 18px; text-transform: capitalize; }

.hero { text-align: center; padding: 20px 14px; }
.hero small { color: var(--muted); letter-spacing: .04em; text-transform: uppercase; font-weight: 600; font-size: 13px; }
.hero b { display: block; margin: 4px 0; font-size: 40px; line-height: 1.1; }
.hero span { color: var(--muted); font-size: 14px; }
.pos { color: var(--accent); }
.neg { color: var(--danger); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0 0 14px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 10px; }
.stat small { display: block; color: var(--muted); font-size: 12px; }
.stat b { font-size: 17px; }

.line { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.line:first-of-type { border-top: 0; }
.line .l { min-width: 0; }
.line .l small { display: block; color: var(--muted); font-size: 13px; }
.line .v { text-align: right; font-weight: 700; white-space: nowrap; }
.bar-bg { height: 6px; border-radius: 3px; background: var(--panel-2); margin-top: 6px; overflow: hidden; }
.bar-bg i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }

/* журнал */
.day-h { display: flex; justify-content: space-between; margin: 16px 2px 6px; color: var(--muted); font-size: 13px; font-weight: 600; }
.ord { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; margin: 0 0 8px; overflow: hidden; }
.ord > button { width: 100%; display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 12px 14px; background: none; border: 0; text-align: left; min-height: 56px; }
.ord .t { min-width: 0; }
.ord .t b { display: block; }
.ord .t small { display: block; color: var(--muted); font-size: 13px; }
.ord .m { text-align: right; white-space: nowrap; }
.ord .m small { display: block; font-size: 13px; }
.ord .det { padding: 0 14px 14px; border-top: 1px solid var(--line); }
.ord .acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; background: var(--warn); color: #000; font-size: 12px; font-weight: 700; margin-left: 6px; }
.empty { text-align: center; color: var(--muted); padding: 28px 0; }

.login { padding: 18vh 20px 20px; }
.login h1 { margin: 0 0 6px; }
.login p { color: var(--muted); margin: 0 0 18px; }
.err { color: var(--danger); min-height: 1.4em; margin: 8px 0; }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + var(--bar-h) + env(safe-area-inset-bottom) + 14px); transform: translate(-50%, 20px);
  max-width: min(520px, calc(100vw - 32px)); background: var(--text); color: var(--bg); padding: 12px 16px; border-radius: 14px;
  font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 30; text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }

.svc-pick {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 60px; margin: 0 0 18px;
  padding: 8px 14px; text-align: left; background: var(--panel); border: 1px solid var(--accent); border-radius: 14px;
}
.svc-pick small { display: block; color: var(--muted); font-size: 12px; letter-spacing: .04em; text-transform: uppercase; font-weight: 600; }
.svc-pick b { font-size: 18px; }
.svc-pick .chg { color: var(--accent); font-weight: 600; font-size: 14px; }
