:root {
  --bg: #0b0c09; --bg2: #121310; --card: #17180f; --card2: #1e1f18; --line: #2b2c24;
  --fg: #f4f1e8; --muted: #a3a197; --dim: #6f6e66;
  --acc: #e4a11b; --acc2: #f2c25a; --acc-fg: #0b0c09;
  --ok: #6cc28a; --bad: #e46a5a; --warn: #e4c21b;
  --r: 16px; --r2: 10px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.45 var(--font); min-height: 100vh; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
a { color: var(--acc2); }
button, input, select, textarea { font: inherit; color: inherit; }
h1 { font-size: 26px; line-height: 1.15; margin: 4px 0 6px; letter-spacing: -.01em; }
h2 { font-size: 19px; margin: 22px 0 10px; }
h3 { font-size: 16px; margin: 0 0 6px; }
.muted { color: var(--muted); }
.dim { color: var(--dim); font-size: 13px; }
.small { font-size: 13px; }
.boot { padding: 40vh 0 0; text-align: center; color: var(--dim); letter-spacing: .08em; text-transform: uppercase; font-size: 13px; }

#app { max-width: 760px; margin: 0 auto; padding: 18px 16px 24px; }
body.wide #app { max-width: 1180px; }
.top { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; justify-content: space-between; margin-bottom: 10px; }
.top .who { color: var(--muted); font-size: 14px; }
.brand { font-weight: 700; letter-spacing: .02em; color: var(--acc); font-size: 14px; text-transform: uppercase; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin: 12px 0; }
.card.flat { background: var(--bg2); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1 1 auto; min-width: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.stack > * + * { margin-top: 10px; }

.btn { appearance: none; border: 1px solid var(--line); background: var(--card2); border-radius: 12px; padding: 11px 16px; cursor: pointer; font-weight: 600; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; color: var(--fg); }
.btn:hover { border-color: #3d3e33; }
.btn.acc { background: var(--acc); border-color: var(--acc); color: var(--acc-fg); }
.btn.acc:hover { background: var(--acc2); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); }
.btn.sm { min-height: 34px; padding: 6px 12px; font-size: 14px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: default; }
.link { background: none; border: 0; color: var(--acc2); cursor: pointer; padding: 0; text-decoration: underline; text-underline-offset: 3px; }

label.f { display: block; margin: 10px 0; }
label.f > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
input.in, select.in, textarea.in { width: 100%; background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; min-height: 44px; outline: none; }
input.in:focus, select.in:focus, textarea.in:focus { border-color: var(--acc); }
textarea.in { min-height: 80px; resize: vertical; }
.err { color: var(--bad); font-size: 14px; margin: 8px 0; }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; background: var(--card2); border: 1px solid var(--line); font-size: 13px; color: var(--muted); white-space: nowrap; }
.chip.acc { color: var(--acc); border-color: #5a4313; background: #241b08; }
.chip.ok { color: var(--ok); border-color: #2d5a3b; background: #0f1f15; }
.chip.bad { color: var(--bad); border-color: #5c2a24; background: #22100d; }
.chip.warn { color: var(--warn); border-color: #5a5113; background: #221f08; }

.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { border: 1px solid var(--line); background: var(--bg2); color: var(--muted); border-radius: 999px; padding: 7px 14px; cursor: pointer; white-space: nowrap; font-size: 14px; }
.tab.on { background: var(--acc); color: var(--acc-fg); border-color: var(--acc); font-weight: 600; }

/* нижнее меню */
#nav { position: fixed; left: 0; right: 0; bottom: 0; background: rgba(11, 12, 9, .94); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--line); display: flex; justify-content: center; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); z-index: 20; }
#nav .in { display: flex; width: 100%; max-width: 760px; }
#nav a { flex: 1; text-align: center; text-decoration: none; color: var(--dim); font-size: 11px; padding: 6px 2px; border-radius: 12px; display: flex; flex-direction: column; align-items: center; gap: 3px; }
#nav a svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#nav a.on { color: var(--acc); }

/* плашка обслуживания */
#notice { background: #3a2f07; color: #ffe08a; border-bottom: 1px solid #6b560f; padding: 10px 16px; font-size: 14px; text-align: center; }

/* тренировка */
.ex { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin: 12px 0; }
.ex-h { display: flex; gap: 10px; align-items: flex-start; }
.ex-n { flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--card2); color: var(--acc); display: grid; place-items: center; font-weight: 700; font-size: 14px; }
.ex-name { font-weight: 600; line-height: 1.3; word-break: break-word; }
.ex-meta { color: var(--muted); font-size: 13px; margin-top: 2px; }
.prev { margin: 10px 0 4px; font-size: 13px; color: var(--muted); background: var(--bg2); border-radius: var(--r2); padding: 8px 10px; }
.prev b { color: var(--fg); font-weight: 600; }
.sets { display: grid; grid-template-columns: 34px 1fr 1fr 34px; gap: 6px 8px; align-items: center; margin-top: 8px; }
.sets .hd { font-size: 12px; color: var(--dim); text-transform: uppercase; letter-spacing: .04em; }
.sets .no { color: var(--dim); font-size: 14px; text-align: center; }
.sets input { width: 100%; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; min-height: 44px; text-align: center; font-variant-numeric: tabular-nums; outline: none; }
.sets input:focus { border-color: var(--acc); }
.sets .rm { background: none; border: 0; color: var(--dim); cursor: pointer; font-size: 20px; min-height: 44px; }
.ex-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; gap: 8px; }
.thumbs { display: flex; gap: 6px; }
.thumb { width: 44px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg2); cursor: pointer; font-size: 18px; filter: grayscale(1); opacity: .7; }
.thumb.on { filter: none; opacity: 1; border-color: var(--acc); background: #241b08; }
.warnbox { background: #221f08; border: 1px solid #5a5113; color: #f3dc7a; border-radius: var(--r2); padding: 8px 10px; font-size: 13px; margin-top: 8px; }
.rate { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.rate button { min-height: 64px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg2); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 13px; color: var(--muted); }
.rate button b { font-size: 20px; color: var(--fg); }
.rate button.on { border-color: var(--acc); background: #241b08; color: var(--acc); }
.sticky-done { position: sticky; bottom: calc(76px + env(safe-area-inset-bottom)); padding: 10px 0 0; background: linear-gradient(transparent, var(--bg) 30%); }

/* таблицы */
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th { color: var(--dim); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: var(--bg2); }

/* питание */
.meal { margin: 14px 0; }
.meal h3 { color: var(--acc); font-size: 14px; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
.food { display: flex; gap: 12px; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--line); }
.food:last-child { border-bottom: 0; }
.food .amt { color: var(--fg); font-weight: 600; white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }
.food .alt { color: var(--muted); font-size: 13px; margin-top: 3px; }
.food .cm { color: var(--dim); font-size: 13px; margin-top: 2px; font-style: italic; }

/* замеры */
.mrow { display: grid; grid-template-columns: 1fr 120px; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.mrow input { text-align: center; }
.mimg { width: 100%; border-radius: var(--r2); margin-top: 8px; display: block; }

/* графики */
.chart { width: 100%; height: auto; display: block; border-radius: 10px; }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .ln { fill: none; stroke: var(--acc); stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--acc); }
.chart .bar { fill: var(--acc); }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }

/* тренер */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; }
.kpi b { display: block; font-size: 24px; font-variant-numeric: tabular-nums; }
.kpi span { color: var(--muted); font-size: 13px; }
.feed-i { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.feed-i:last-child { border-bottom: 0; }
.pw { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--bg2); border: 1px dashed var(--acc); padding: 10px 12px; border-radius: 10px; font-size: 16px; user-select: all; word-break: break-all; }

dialog#dlg { background: var(--card); color: var(--fg); border: 1px solid var(--line); border-radius: 20px; padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 40px); }
dialog#dlg::backdrop { background: rgba(0, 0, 0, .6); }
#dlgBody { padding: 18px; overflow: auto; max-height: calc(100vh - 40px); }
#toast { position: fixed; left: 50%; transform: translateX(-50%) translateY(20px); bottom: calc(90px + env(safe-area-inset-bottom)); background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; z-index: 50; max-width: calc(100vw - 32px); }
#toast.on { opacity: 1; transform: translateX(-50%); }
#toast.bad { background: var(--bad); color: #fff; }

.side2 { display: flex; flex-direction: column; gap: 4px; }
.auth { max-width: 380px; margin: 12vh auto 0; }
.auth h1 { font-size: 30px; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

@media (min-width: 900px) {
  body.wide #nav { display: none !important; }
  body.wide { padding-bottom: 0; }
  .side { display: grid; grid-template-columns: 340px 1fr; gap: 24px; align-items: start; }
  .side2 { display: grid; grid-template-columns: 1fr 340px; gap: 24px; align-items: start; }
}
@media (max-width: 420px) {
  h1 { font-size: 23px; }
  .sets { grid-template-columns: 26px 1fr 1fr 30px; gap: 6px; }
}
