:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #151a21;
  --muted: #6b7482;
  --line: #e2e6ec;
  --accent: #1f6feb;
  --ok: #1a7f4b;
  --err: #b42318;
}

* { box-sizing: border-box; }

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

main { max-width: 760px; margin: 0 auto; padding: 16px 14px 48px; }
main.narrow { padding-top: 15vh; max-width: 380px; }

h1 { font-size: 20px; margin: 0; }
h2 { font-size: 13px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin: 0 0 12px; }

a { color: var(--accent); text-decoration: none; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--err); margin: 8px 0 0; }

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 14px;
  background: rgba(246, 247, 249, .92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.topbar nav { display: flex; gap: 6px; }
.topbar nav a { padding: 8px 12px; border-radius: 10px; color: var(--muted); font-weight: 600; }
.topbar nav a.active { color: var(--text); background: #fff; border: 1px solid var(--line); }
.logout { margin: 0; }

.datebar { display: flex; align-items: center; gap: 10px; margin: 18px 0 14px; }
.datebar h1 { flex: 1; text-align: center; font-size: 19px; }
.navday {
  width: 40px; height: 40px; display: grid; place-items: center;
  border-radius: 12px; background: #fff; border: 1px solid var(--line);
  color: var(--text); font-size: 18px;
}
.navday.disabled { opacity: .35; }

.badge {
  font-size: 11px; font-weight: 600; letter-spacing: .03em;
  background: #e8f0fe; color: var(--accent);
  padding: 2px 8px; border-radius: 999px; vertical-align: middle;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 14px;
}

.flash {
  background: #e7f6ed; color: var(--ok);
  border: 1px solid #bfe6cf; border-radius: 12px;
  padding: 10px 14px; margin-bottom: 14px; font-weight: 600;
}

.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.facts div { display: flex; flex-direction: column; gap: 2px; }
.facts span { font-size: 12px; }
.facts strong { font-size: 18px; font-variant-numeric: tabular-nums; }

.sessions { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.sessions li { border-top: 1px solid var(--line); padding-top: 12px; }
.sessions li:first-child { border-top: none; padding-top: 0; }
.session-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.session-meta { margin-top: 2px; }

.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field > span { font-size: 13px; color: var(--muted); }

select, input[type="number"], input[type="password"], textarea {
  width: 100%;
  font: inherit;
  font-size: 16px;
  padding: 11px 12px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
}
textarea { resize: vertical; }
select:focus, input:focus, textarea:focus { outline: 2px solid #cfe0fb; border-color: var(--accent); }

.checkbox { display: flex; align-items: center; gap: 8px; margin: 4px 0 14px; }
.checkbox input { width: 18px; height: 18px; }

button {
  width: 100%;
  font: inherit;
  font-weight: 600;
  padding: 14px;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 12px;
  cursor: pointer;
}
button:active { transform: translateY(1px); }
button.link {
  width: auto; padding: 8px 10px; background: none;
  color: var(--muted); font-weight: 600;
}

details { margin: 6px 0 16px; }
summary { cursor: pointer; color: var(--muted); font-size: 14px; margin-bottom: 12px; }

.report {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  overflow-x: auto;
  font: 12.5px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
}

@media (min-width: 620px) {
  .facts { grid-template-columns: repeat(6, 1fr); }
  .grid { grid-template-columns: repeat(4, 1fr); }
  main { padding-left: 20px; padding-right: 20px; }
}

/* подсказки к показателям */
.hint {
  display: inline-flex; align-items: center; gap: 5px;
  cursor: help; border-bottom: 1px dotted #cfd6df;
}
.hint .q {
  font-style: normal; font-size: 10px; line-height: 1;
  width: 14px; height: 14px; border-radius: 50%;
  background: #eef1f5; color: var(--muted);
  display: inline-grid; place-items: center;
}
.facts-help { margin-top: 12px; }
.facts-help summary { margin-bottom: 8px; }
.facts-help ul { margin: 0; padding-left: 18px; display: grid; gap: 6px; font-size: 13px; color: var(--muted); }

/* календарь месяца */
.month-totals { grid-template-columns: repeat(3, 1fr); margin-bottom: 0; }

.cal-head, .cal-week {
  display: grid;
  grid-template-columns: repeat(7, 1fr) 62px;
  gap: 6px;
  align-items: center;
}
.cal-head {
  margin-bottom: 6px;
  font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em;
}
.cal-head span { text-align: center; }
.cal-total-head { font-size: 9px; line-height: 1.2; }
.cal-week { margin-bottom: 6px; }

.cal-day {
  position: relative;
  aspect-ratio: 1 / 1;
  min-height: 38px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  display: grid; place-items: center;
  font-size: 14px; font-variant-numeric: tabular-nums;
  color: var(--text);
}
.cal-day.out { opacity: .3; }
.cal-day.today { outline: 2px solid var(--accent); outline-offset: 1px; }
.cal-day .dot {
  position: absolute; right: 5px; bottom: 3px;
  font-size: 9px; color: var(--muted);
}

.cal-week-total {
  display: flex; flex-direction: column; align-items: flex-end; justify-content: center;
  font-size: 12px; color: var(--muted); line-height: 1.3;
}
.cal-week-total strong { color: var(--text); font-size: 13px; font-variant-numeric: tabular-nums; }
.cal-week-total em { font-style: normal; font-size: 11px; }

.cal-legend { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 12px; }
.chip { font-size: 11px; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--line); }

.rpe-easy { background: #e6f4ea; border-color: #c7e6d0; }
.rpe-moderate { background: #eef7d6; border-color: #d6e9a8; }
.rpe-hard { background: #fdf0d0; border-color: #eeda9f; }
.rpe-veryhard { background: #fbe0c4; border-color: #eec08f; }
.rpe-max { background: #f8c9c4; border-color: #e8a29a; }
.rpe-norpe { background: #eef1f5; border-color: #dde2e9; }
.rpe-empty { background: transparent; border-color: transparent; }

/* недельный вид */
main.wide { max-width: 1440px; }
.feed-scroll { overflow-x: auto; padding-bottom: 8px; }
.feed { display: grid; gap: 14px; min-width: 1180px; }

.wk {
  display: grid;
  grid-template-columns: 250px repeat(7, minmax(170px, 1fr));
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}
.wk-current { border-color: #b9cff2; box-shadow: 0 0 0 1px #b9cff2; }

.wk-side {
  position: sticky;
  left: 0;
  z-index: 3;
  border-right: 1px solid var(--line);
  padding: 12px;
  background: #fbfcfd;
  box-shadow: 6px 0 8px -8px rgba(16, 24, 40, .25);
}
.wk-side-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.wk-totals { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.wk-totals div { display: flex; flex-direction: column; }
.wk-totals span { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.wk-totals strong { font-size: 14px; font-variant-numeric: tabular-nums; }

.wk-sport { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; }
.wk-sport-title { font-size: 12px; font-weight: 600; margin-bottom: 6px; }
.wk-row {
  display: grid; grid-template-columns: 36px 1fr; gap: 3px 6px;
  align-items: center; font-size: 11px; color: var(--muted); margin-bottom: 6px;
}
.wk-row-label { font-size: 10px; text-transform: uppercase; letter-spacing: .03em; }
.wk-row em { grid-column: 2; font-style: normal; font-variant-numeric: tabular-nums; }
.wk-strong { color: var(--text); }
.bar { grid-column: 2; display: block; height: 8px; border-radius: 4px; background: #e9eef4; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 4px; }
.bar-time i { background: #2f6fed; }
.bar-load i { background: #2e9e63; }

.wday { border-right: 1px solid var(--line); padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.wday:last-child { border-right: none; }
.wday.is-today { background: #f4f7fb; box-shadow: inset 3px 0 0 var(--accent); }
.wday-head {
  font-size: 11px; color: var(--muted); text-align: center;
  text-transform: uppercase; letter-spacing: .04em;
  padding-bottom: 4px; border-bottom: 1px solid var(--line);
}
.wday.is-today .wday-head { color: var(--accent); font-weight: 700; }
.wday-well { font-size: 10.5px; color: var(--muted); text-align: center; display: grid; gap: 2px; }
.wday-well .hrv { color: #d6336c; }
.wday-note { font-size: 11px; text-align: center; }
.wday-cards { display: grid; gap: 6px; }
.wday-empty { color: var(--muted); text-align: center; font-size: 12px; }

.wcard { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; box-shadow: 0 1px 2px rgba(16, 24, 40, .04); }
.wcard-head { display: flex; align-items: center; gap: 6px; padding: 6px 8px; color: #fff; font-size: 12px; font-weight: 600; }
.wcard-icon { font-size: 13px; }
.wcard-dur { font-variant-numeric: tabular-nums; }
.wcard-dist { margin-left: auto; font-weight: 500; opacity: .95; font-variant-numeric: tabular-nums; }
.wcard-body { padding: 6px 8px 8px; background: #fbfcfd; display: grid; gap: 3px; text-align: center; }
.wcard-title { font-size: 12px; font-weight: 600; }
.wcard-metrics { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; font-size: 11px; color: #a83232; }
.wcard-line { font-size: 11px; color: var(--muted); }
.wcard-gap { font-size: 11px; color: #6b4fbf; }
.wcard-plan { margin-top: 3px; padding-top: 4px; border-top: 1px dashed var(--line); font-size: 10px; color: var(--muted); }
.wcard.is-plan .wcard-body { background: #f6f9fb; }

.zbar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; margin-top: 3px; }
.zbar i { display: block; height: 100%; }
.z1 { background: #9fd6d2; }
.z2 { background: #67c2b8; }
.z3 { background: #f0c65a; }
.z4 { background: #ef8f4b; }
.z5 { background: #e05e5e; }

.cmp { justify-self: center; font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 999px; }
.cmp-good { background: #e7f6ed; color: #1a7f4b; }
.cmp-warn { background: #fdf0d0; color: #8a5a00; }
.cmp-bad { background: #fbe3e1; color: #b42318; }

.sw-teal .wcard-head { background: #2f9e8f; }
.sw-green .wcard-head { background: #3f8f4f; }
.sw-yellow .wcard-head { background: #c99a24; }
.sw-orange .wcard-head { background: #cf6f27; }
.sw-red .wcard-head { background: #c0392b; }
.sw-unknown .wcard-head { background: #6b7482; }
.sw-plan .wcard-head { background: #a8c7dc; color: #12323f; }

.feed-more { text-align: center; margin-top: 14px; }

/* еда и добавки */
.intake-totals { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
.intake-totals strong { color: var(--text); font-variant-numeric: tabular-nums; }
.intake-list { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 8px; }
.intake-list li {
  display: grid; grid-template-columns: 42px 1fr auto auto;
  align-items: baseline; gap: 8px;
  padding-bottom: 6px; border-bottom: 1px solid var(--line); font-size: 14px;
}
.intake-list li:last-child { border-bottom: none; }
.intake-name { font-weight: 600; }
.intake-amount { font-size: 12px; }
.inline-form { margin: 0; }
.inline-form button { padding: 2px 6px; font-size: 16px; line-height: 1; }
.intake-form .grid { margin-bottom: 6px; }

.period-filter { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; }
.period-filter label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.period-filter select { width: auto; min-width: 190px; padding: 9px 12px; }

/* разбор тренировки */
.session-top { display: flex; align-items: center; gap: 12px; margin: 14px 0 16px; }
.session-top h1 { font-size: 19px; }
.session-top p { margin: 2px 0 0; }
.session-facts { grid-template-columns: repeat(2, 1fr); gap: 10px; }
.zones-line { margin-top: 14px; }
.zbar-wide { height: 12px; border-radius: 6px; margin-top: 6px; }
.plan-note {
  margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line);
  font-size: 13px; color: var(--muted);
}
.wcard-link { display: block; color: inherit; }
.session-link { display: block; color: inherit; }
.session-link:hover strong { color: var(--accent); }

@media (min-width: 620px) {
  .session-facts { grid-template-columns: repeat(4, 1fr); }
}

/* профиль тренировки */
.profile-mini-wrap { margin-top: 4px; }
.profile-mini { width: 100%; height: 30px; display: block; }

.workout-layout { display: grid; gap: 16px; }
.steps { margin: 0; padding-left: 18px; font-size: 13px; display: grid; gap: 6px; }
.steps li { line-height: 1.4; }
.step-note { list-style: none; margin-left: -18px; color: var(--muted); }
.step-repeat { list-style: none; margin-left: -18px; }
.repeat-count {
  display: inline-block; font-weight: 700; font-size: 12px;
  background: #eef1f5; color: var(--text);
  border-radius: 6px; padding: 1px 7px; margin-bottom: 4px;
}
.step-repeat ul { margin: 4px 0 0; padding-left: 18px; display: grid; gap: 4px; color: var(--muted); }

.zone-summary { display: grid; gap: 6px; align-content: start; }
.zs-row {
  display: grid; grid-template-columns: 26px 1fr 38px 44px;
  align-items: center; gap: 8px; font-size: 12px;
}
.zs-label { color: var(--muted); }
.zs-bar { display: block; height: 8px; background: #eef1f5; border-radius: 4px; overflow: hidden; }
.zs-bar i { display: block; height: 100%; border-radius: 4px; }
.zs-row strong { text-align: right; font-variant-numeric: tabular-nums; }
.zs-row em { font-style: normal; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.zs-pi { margin-top: 4px; font-size: 12px; color: var(--muted); text-align: center; }
.zs-pi strong { color: var(--text); }

.profile-wrap { margin-top: 14px; }
.profile { width: 100%; height: auto; display: block; }

@media (min-width: 620px) {
  .workout-layout { grid-template-columns: 1fr 260px; }
}
