/* =========================================================
   PT платформа — стиль v2 (мінімалістичний, як у спорт-трекерах)
   Усі старі класи збережено, тож PHP-шаблони правити не обов'язково.
   У <head> онови посилання на шрифти (додано Unbounded):
   <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Onest:wght@400;500;600;700&family=Unbounded:wght@500;600&display=swap">
   ========================================================= */

:root {
  /* нові токени */
  --bg: #F4F4F1;
  --surface: #FFFFFF;
  --surface-2: #F8F8F5;
  --line: #E4E4DF;
  --line-soft: #EFEFEA;
  --ink: #16181D;
  --ink-2: #3A3D43;
  --muted: #5B5F66;
  --accent: #D9480F;       /* головні дії, тривоги */
  --accent-hover: #C03F0C;
  --accent-ink: #9A3412;
  --accent-soft: #FFF1EA;
  --data: #1D4ED8;         /* дані, графіки, «виконано», посилання */
  --data-ink: #1E3A8A;
  --data-soft: #E6ECFB;
  --display: "Unbounded", "Onest", system-ui, sans-serif;
  --radius: 12px;
  --radius-lg: 16px;

  /* старі назви — лишаються як псевдоніми, якщо десь використані в шаблонах чи JS */
  --panel: var(--surface);
  --spruce: var(--data);
  --spruce-dark: var(--ink);
  --amber: var(--accent);
  --danger: #B3361F;
  --ok: var(--data-ink);

  /* кольори для графіків */
  --chart-main: var(--data);
  --chart-second: var(--accent);
  --chart-grid: #EFEFEA;
  --chart-band: rgba(29, 78, 216, .07);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.55 "Onest", system-ui, -apple-system, "Segoe UI", sans-serif;
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 .6em; font-weight: 600; letter-spacing: -.01em; }
h1 { font-family: var(--display); font-size: 1.6rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 1em; max-width: 68ch; }
a { color: var(--data); }
a:hover { color: var(--data-ink); }
:focus-visible { outline: 2px solid var(--data); outline-offset: 2px; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Верхня панель ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: .75rem clamp(1rem, 4vw, 2.5rem);
  background: var(--surface); color: var(--ink);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand {
  display: inline-flex; align-items: center; gap: .6rem;
  color: var(--ink); text-decoration: none;
  font-family: var(--display); font-weight: 600; font-size: .95rem;
}
.brand::before {
  content: ""; width: 28px; height: 28px; border-radius: 8px; background: var(--accent); flex-shrink: 0;
}
.topnav { display: flex; align-items: center; gap: .25rem; flex-wrap: wrap; font-size: .95rem; }
.topnav a, .linklike {
  color: var(--ink-2); text-decoration: none;
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 .8rem; border-radius: 10px;
}
.topnav a:hover, .linklike:hover { color: var(--ink); background: var(--surface-2); text-decoration: none; }
.topnav a[aria-current="page"] { color: var(--ink); font-weight: 600; background: var(--bg); text-decoration: none; }
.who { color: var(--muted); font-weight: 500; padding: 0 .8rem; }
.inline { display: inline; margin: 0; }
.linklike { background: none; border: 0; font: inherit; cursor: pointer; }
.nav-sep { display: none; }

/* Випадаючі групи меню */
.nav-group { position: relative; }
.nav-group > summary {
  list-style: none; cursor: pointer; user-select: none;
  display: inline-flex; align-items: center; gap: .4rem; min-height: 40px; padding: 0 .8rem; border-radius: 10px;
  color: var(--ink-2);
}
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group > summary::after {
  content: ""; width: 6px; height: 6px; margin-left: .1rem;
  border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: translateY(-2px) rotate(45deg); transition: transform .15s;
}
.nav-group[open] > summary::after { transform: translateY(1px) rotate(-135deg); }
.nav-group > summary:hover, .nav-group[open] > summary { color: var(--ink); background: var(--surface-2); }
.nav-group > summary.is-current { color: var(--ink); font-weight: 600; background: var(--bg); }
.nav-menu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 30; min-width: 200px;
  display: flex; flex-direction: column; gap: .1rem; padding: .35rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(22, 24, 29, .12);
}
.nav-account .nav-menu { left: auto; right: 0; }
.nav-menu a, .nav-menu .linklike { width: 100%; white-space: nowrap; }
.nav-menu form { display: block; }
.nav-menu form .linklike { text-align: left; }
.avatar-sm {
  display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: var(--data-soft); color: var(--data-ink); font-size: .72rem; font-weight: 600;
}
.nav-account > summary { color: var(--muted); font-weight: 500; }

.nav-toggle { position: absolute; opacity: 0; pointer-events: none; }
.nav-burger { display: none; }
@media (max-width: 720px) {
  .nav-burger {
    display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 4px;
    width: 44px; height: 44px; padding: 0; margin-left: auto; cursor: pointer; border-radius: 12px;
  }
  .nav-burger span { display: block; width: 22px; height: 2px; background: var(--ink); border-radius: 1px; }
  .nav-burger:hover { background: var(--surface-2); }
  .nav-toggle:focus-visible ~ .nav-burger { outline: 2px solid var(--data); outline-offset: 2px; }
  .topnav {
    display: none; flex-direction: column; align-items: stretch; gap: .15rem;
    flex-basis: 100%; width: 100%; padding-top: .5rem; margin-top: .5rem;
    border-top: 1px solid var(--line);
  }
  .nav-toggle:checked ~ .topnav { display: flex; }
  .topnav a, .who, .topnav .linklike { min-height: 44px; width: 100%; }
  .nav-group > summary { min-height: 44px; width: 100%; }
  .nav-group > summary::after { margin-left: auto; }
  .nav-menu {
    position: static; min-width: 0; padding: 0 0 .25rem .8rem; margin-top: .1rem;
    border: 0; border-left: 2px solid var(--line); border-radius: 0; box-shadow: none; background: none;
  }
  .who { display: flex; align-items: center; }
  .nav-sep { display: block; width: 100%; height: 1px; background: var(--line); margin: .3rem 0; }
}

/* ---------- Контейнери ---------- */
.wrap { max-width: 1200px; margin: 0 auto; padding: 2rem clamp(1rem, 4vw, 2.5rem) 4rem; }
.wrap.narrow { max-width: 520px; }
.panel {
  background: var(--surface); border: 0; border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem; margin-bottom: 1rem;
}
.split { display: grid; gap: 1rem; grid-template-columns: 1fr; }
/* Без цього колонка сітки не стискається вужче за широку таблицю, і на телефоні вся сторінка роз'їжджається */
.split > * { min-width: 0; }
@media (min-width: 860px) { .split { grid-template-columns: 1.6fr 1fr; align-items: start; } }
@media (max-width: 480px) {
  .wrap { padding: 1.25rem 1rem 6rem; }
  .panel { padding: 1rem 1.1rem; border-radius: 20px; }
  h1 { font-size: 1.4rem; }
}

/* ---------- Повідомлення ---------- */
.flash { padding: .75rem clamp(1rem, 4vw, 2.5rem); font-weight: 500; font-size: .95rem; }
.flash-ok { background: var(--data-soft); color: var(--data-ink); }
.flash-error { background: #FBE9E5; color: var(--danger); }
.reveal {
  border: 1px solid #F3C3A8; background: var(--accent-soft); border-radius: var(--radius);
  padding: 1rem 1.25rem; margin-bottom: 1.25rem;
}
.reveal code {
  font: 600 1.15rem ui-monospace, Menlo, Consolas, monospace;
  background: #fff; padding: .15rem .5rem; border: 1px solid var(--line); border-radius: 6px;
}

/* ---------- Форми ---------- */
.field { margin-bottom: 1.25rem; }
label { display: block; font-weight: 500; font-size: .95rem; margin-bottom: .35rem; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=search], textarea, select {
  width: 100%; min-height: 44px; padding: .6rem .8rem;
  font: inherit; font-size: 16px; color: inherit;
  border: 1px solid var(--line); border-radius: var(--radius); background: #fff;
}
textarea { min-height: 5.5rem; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.hint { font-size: .875rem; color: var(--muted); margin-top: .3rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 44px; padding: .55rem 1.1rem;
  font: 600 .95rem "Onest", system-ui, sans-serif;
  background: var(--accent); color: #fff; border: 1px solid var(--accent); border-radius: var(--radius);
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn-quiet { background: var(--surface); color: var(--ink); border: 1px solid #D6D6D0; }
.btn-quiet:hover { background: var(--surface-2); border-color: #C9C9C2; color: var(--ink); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid #E8B4A9; }
.btn-danger:hover { background: #FBE9E5; color: var(--danger); border-color: var(--danger); }
.btn-dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-dark:hover { background: #2A2D33; border-color: #2A2D33; color: #fff; }
.btn-small { min-height: 36px; padding: .3rem .85rem; font-size: .875rem; font-weight: 500; }
.btn-block { display: flex; width: 100%; min-height: 52px; font-size: 1rem; }

.actions { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; row-gap: .75rem; }
@media (max-width: 480px) {
  .actions > .btn, .actions > form > .btn { flex: 1 1 auto; }
}

/* ---------- Таблиці ---------- */
.table-scroll { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th, table.data td { text-align: left; padding: .75rem .85rem; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.data th { font-weight: 500; color: var(--muted); font-size: .8125rem; border-bottom-color: var(--line); }
table.data tbody tr:hover td { background: #FBFBF9; }
table.data tr:last-child td { border-bottom: 0; }
table.data td.rx { white-space: nowrap; font-variant-numeric: tabular-nums; }
table.data td.actions-col { white-space: nowrap; width: 1%; }
table.data td.actions-col .row-actions { flex-wrap: nowrap; }

.badge {
  display: inline-block; padding: .2rem .55rem; border-radius: 6px;
  font-size: .75rem; font-weight: 600; white-space: nowrap;
}
.badge-on { background: var(--data-soft); color: var(--data-ink); }
.badge-off { background: var(--bg); color: var(--muted); }
.badge-active { background: var(--accent-soft); color: var(--accent-ink); }
.badge-draft { background: var(--bg); color: var(--ink-2); }
.empty { color: var(--muted); padding: 1rem 0; }

/* ---------- Вхід ---------- */
body.login { min-height: 100vh; display: grid; grid-template-columns: 1fr; }
@media (min-width: 900px) { body.login { grid-template-columns: 1.1fr 1fr; } }
.login-side {
  background: var(--ink); color: #fff; padding: clamp(1.5rem, 5vw, 4rem);
  display: flex; flex-direction: column; justify-content: space-between; gap: 2rem;
}
.login-side h1 { font-size: clamp(1.6rem, 3.2vw, 2.4rem); max-width: 16ch; margin: 0; }
.login-side svg { width: 100%; max-width: 460px; height: auto; }
.login-main { display: flex; align-items: center; justify-content: center; padding: 2rem clamp(1rem, 5vw, 3rem); background: var(--surface); }
.login-main form { width: 100%; max-width: 380px; }
.login-main h2 { font-family: var(--display); font-size: 1.35rem; margin-bottom: 1.25rem; }
.login .flash { grid-column: 1 / -1; }

/* ---------- Плани та вправи ---------- */
.grid-form { display: grid; gap: .3rem 1.25rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.grid-form .wide { grid-column: 1 / -1; }
.phase { border-left: 0; }
.phase.is-active { box-shadow: inset 0 0 0 1.5px #F3C3A8; }
.phase-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; margin-bottom: .85rem; row-gap: .6rem; }
.phase-head h2 { margin: 0; }
.session { margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--line-soft); }
.session:first-of-type { border-top: 0; padding-top: 0; }
.session h3 { font-size: 1rem; margin-bottom: .4rem; }
.crit { background: var(--surface-2); border-radius: var(--radius); padding: .6rem .85rem; font-size: .95rem; }
.row-actions { display: flex; gap: .5rem; align-items: center; justify-content: flex-end; flex-wrap: wrap; row-gap: .4rem; }
@media (min-width: 640px) { .phase-head .row-actions { flex-wrap: nowrap; } }
.row-actions form { margin: 0; }
.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li {
  padding: .85rem 0; border-bottom: 1px solid var(--line-soft);
  display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; flex-wrap: wrap; row-gap: .5rem;
}
.plain-list li:last-child { border-bottom: 0; }

/* ---------- Графіки, світлофор, результати ---------- */
.chart-box { position: relative; height: 300px; overflow: hidden; }
.chart-box canvas { max-width: 100%; }
.charts { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 900px) { .charts.two { grid-template-columns: 1fr 1fr; } }

.tabs { display: flex; gap: 1.5rem; margin-bottom: 1.25rem; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs a {
  padding: .7rem 0; border: 0; border-radius: 0;
  text-decoration: none; color: var(--muted); font-weight: 500; white-space: nowrap;
}
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { background: none; color: var(--ink); font-weight: 600; box-shadow: inset 0 -2px 0 var(--ink); }

.light { display: inline-flex; align-items: center; gap: .4rem; font-weight: 500; }
.light i { width: .75rem; height: .75rem; border-radius: 50%; display: inline-block; }
.light-green i { background: #2E9E66; }
.light-yellow i { background: #E0A21A; }
.light-red i { background: var(--danger); }

.prompt { border: 0; border-radius: var(--radius); background: var(--data-soft); color: var(--data-ink); padding: 1rem 1.25rem; margin-bottom: 1.25rem; }
.scale-row { display: grid; gap: .5rem 1.25rem; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: .5rem; }
table.entry input { min-width: 4.5rem; text-align: center; background: var(--bg); border-color: transparent; }
table.entry input:focus { background: #fff; }
table.entry td, table.entry th { vertical-align: middle; }
.quick-links { display: flex; gap: .75rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
@media (max-width: 480px) {
  .quick-links { flex-direction: column; }
  .quick-links .btn { width: 100%; }
}

.sticky-actions { margin-top: 1.5rem; }
@media (max-width: 720px) {
  .sticky-actions {
    position: sticky; bottom: 0; left: 0; right: 0;
    background: var(--surface); border-top: 1px solid var(--line);
    margin: 1.5rem -1.1rem -1rem; padding: .75rem 1.1rem calc(.75rem + env(safe-area-inset-bottom, 0px));
  }
  .sticky-actions .btn { width: 100%; min-height: 52px; }
}

/* =========================================================
   НОВІ КОМПОНЕНТИ З МАКЕТА — підключаються в шаблонах поступово
   ========================================================= */

/* Заголовок сторінки з датою і кнопками праворуч */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem 1.5rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.page-head h1 { margin: 0; }
.page-sub { font-size: .875rem; color: var(--muted); margin-bottom: .35rem; }
.breadcrumbs { font-size: .875rem; color: var(--muted); margin-bottom: 1rem; }
.breadcrumbs a { color: var(--muted); text-decoration: none; }

/* KPI-картки */
.kpis { display: grid; gap: 1rem; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 1rem; }
@media (max-width: 1000px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi { background: var(--surface); border-radius: var(--radius-lg); padding: 1.1rem 1.25rem; display: flex; flex-direction: column; gap: .4rem; }
.kpi-label { font-size: .875rem; color: var(--muted); }
.kpi-row { display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap; }
.kpi-value { font-family: var(--display); font-size: 2rem; font-weight: 500; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-value.is-alert { color: #B33A0A; }
.kpi-note { font-size: .875rem; color: var(--muted); }
.kpi-up { font-size: .875rem; font-weight: 600; color: var(--data); }
@media (max-width: 480px) { .kpi-value { font-size: 1.6rem; } }

/* Людина в таблиці: аватар + ім'я + протокол */
.avatar {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  background: #EDEDE8; color: var(--ink); font-size: .8rem; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center;
}
.avatar-lg { width: 60px; height: 60px; font-size: 1.1rem; }
.person { display: flex; align-items: center; gap: .75rem; min-width: 0; }
.person-name { display: block; font-weight: 600; color: var(--ink); text-decoration: none; }
.person-meta { display: block; font-size: .8125rem; color: var(--muted); }

/* Смужка прогресу (тиждень 4 з 8) */
.progress { width: 100px; height: 4px; background: #EDEDE8; border-radius: 2px; overflow: hidden; margin-top: .4rem; }
.progress > span { display: block; height: 100%; background: var(--data); }

/* Мітки */
.pill { display: inline-block; font-size: .75rem; font-weight: 600; padding: .25rem .55rem; border-radius: 6px; white-space: nowrap; }
.pill-data { background: var(--data-soft); color: var(--data-ink); }
.pill-accent { background: var(--accent-soft); color: var(--accent-ink); }
.count {
  min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px;
  background: var(--accent); color: #fff; font-size: .75rem; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center;
}

/* Фільтри-чипи */
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip {
  display: inline-flex; align-items: center; min-height: 36px; padding: 0 .9rem; border-radius: 18px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  font: inherit; font-size: .875rem; text-decoration: none; cursor: pointer;
}
.chip[aria-current="page"], .chip.is-active { background: var(--ink); border-color: var(--ink); color: #fff; }

/* «Потребують уваги» */
.attn { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.attn a, .attn > li > div {
  display: flex; gap: .75rem; padding: .75rem; border-radius: var(--radius);
  background: var(--surface-2); color: var(--ink); text-decoration: none;
}
.attn a:hover { background: var(--bg); }
.attn-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: .4rem; flex-shrink: 0; background: var(--data); }
.attn-dot.is-alert { background: var(--accent); }
.attn-title { display: block; font-weight: 600; }
.attn-text { display: block; font-size: .8125rem; color: var(--muted); }

/* Матриця тижневої прогресії */
table.matrix { width: 100%; border-collapse: collapse; font-size: .875rem; }
table.matrix th { font-size: .8125rem; font-weight: 500; color: var(--muted); padding: .5rem .4rem; text-align: center; }
table.matrix td { padding: .5rem .4rem; text-align: center; vertical-align: top; border-top: 1px solid var(--line-soft); }
table.matrix th:first-child, table.matrix td:first-child { text-align: left; padding-left: .6rem; }
table.matrix td:first-child { font-weight: 500; }
.mx-sets { display: block; font-size: .8125rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.mx-load { display: block; font-size: .75rem; color: var(--muted); }
table.matrix .is-current { background: var(--accent-soft); }
table.matrix th.is-current { color: var(--accent-ink); font-weight: 700; border-radius: 8px 8px 0 0; }

/* Шкала-кнопки для RPE 1–10 і самопочуття 1–5 (радіокнопки) */
.pick { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .5rem; }
.pick input { position: absolute; opacity: 0; pointer-events: none; }
.pick label {
  margin: 0; min-height: 44px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; font-weight: 600; cursor: pointer;
}
.pick input:checked + label { background: var(--ink); border-color: var(--ink); color: #fff; }
.pick input:focus-visible + label { outline: 2px solid var(--data); outline-offset: 2px; }
.pick-ends { display: flex; justify-content: space-between; font-size: .75rem; color: var(--muted); margin-top: .35rem; }

/* Нижнє меню клієнта на телефоні */
.tabbar { display: none; }
@media (max-width: 720px) {
  body.has-tabbar .wrap { padding-bottom: 7rem; }
  .tabbar {
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    height: calc(68px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--surface); border-top: 1px solid var(--line);
  }
  .tabbar a {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    font-size: .75rem; color: var(--muted); text-decoration: none;
  }
  .tabbar svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
  .tabbar a[aria-current="page"] { color: var(--accent); font-weight: 600; }
  body.has-tabbar .sticky-actions { bottom: calc(68px + env(safe-area-inset-bottom, 0px)); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* Результат меткону у формі запису тренування */
.score-box { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; background: var(--data-soft); border-radius: var(--radius); padding: .7rem .9rem; margin: .5rem 0 1rem; }
.score-box .score-f { display: inline-flex; align-items: center; gap: .4rem; margin: 0; font-weight: 400; }
.score-box input[type="text"], .score-box select { margin: 0; }

/* ---------- Комплекси в матриці плану ---------- */
table.matrix tr.mx-cx-row.is-first td { border-top: 1px solid var(--line); }
.mx-cx-head { display: block; font-size: .8125rem; font-weight: 600; }
.mx-cx summary { cursor: pointer; font-size: .8125rem; font-weight: 600; list-style-position: inside; white-space: nowrap; }
.mx-cx[open] summary { color: var(--accent-ink); }
.mx-cx-body { white-space: pre-wrap; text-align: left; font-size: .8125rem; line-height: 1.45; color: var(--ink-2); min-width: 11rem; margin-top: .3rem; }

/* ---------- Набір чекбоксів (тренування, тижні) ---------- */
fieldset.checks { border: 0; padding: 0; margin: 0 0 1.25rem; display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .5rem; }
fieldset.checks legend { font-weight: 500; font-size: .95rem; margin-bottom: .35rem; padding: 0; }
fieldset.checks > label { display: inline-flex; align-items: center; gap: .35rem; margin: 0; font-weight: 500;
  padding: .35rem .7rem; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; cursor: pointer; min-height: 40px; }
fieldset.checks > label[hidden] { display: none; }
fieldset.checks > label:has(input:checked) { border-color: var(--ink); background: var(--surface-2); }
fieldset.checks .checks-new input { width: 9rem; min-height: 32px; padding: .2rem .5rem; }
fieldset.checks .hint { flex-basis: 100%; max-width: none; margin: .2rem 0 0; }

/* Менший шрифт на широких екранах; на телефоні поля лишаються 16px, щоб iOS не збільшував сторінку */
@media (min-width: 700px) {
  input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=search], textarea, select { font-size: 15px; }
}
/* ---------- Комплекс у тренуванні клієнта ---------- */
.cx-card { background: var(--surface-2); border: 1px solid var(--line-soft); border-left: 3px solid var(--accent); border-radius: var(--radius); padding: .7rem .9rem; margin: .9rem 0; }
.cx-card-title { font-weight: 600; margin: 0 0 .35rem; max-width: none; }
.cx-card-body { white-space: pre-wrap; font-size: .9rem; line-height: 1.5; color: var(--ink-2); }
.session .cx-card:last-child { margin-bottom: 0; }
.rpe-hint { margin: .75rem 0 0; }
.cx-num { display: inline-block; min-width: 1.6rem; font-weight: 400; }

/* ---------- Харчування: меню й обмеження ---------- */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.pill-warn { background: var(--accent-soft); color: var(--accent-ink); }
.meal-day, .food-group { border-top: 1px solid var(--line-soft); padding: .6rem 0; }
.meal-day > summary, .food-group > summary { cursor: pointer; font-weight: 600; padding: .25rem 0; }
.food-group fieldset.checks { margin: .6rem 0 .4rem; }
table.meal-table tr.meal-head th { color: var(--ink); font-weight: 600; background: var(--surface-2); font-size: .875rem; }
table.meal-table tr.meal-total th { color: var(--ink); font-weight: 600; border-top: 1px solid var(--line); }
table.meal-table th.num, table.meal-table td.num { text-align: right; white-space: nowrap; }
.meal-editor input.mi-food { min-width: 15rem; }
.meal-editor input.mi-grams { width: 5rem; min-width: 0; text-align: right; }
.meal-editor td { padding-top: .4rem; padding-bottom: .4rem; }
.meal-editor .pill-warn { margin-left: .4rem; }
.mi-del { display: inline-flex; align-items: center; gap: .3rem; font-size: .8125rem; color: var(--muted); white-space: nowrap; margin: 0; }
table.meal-view .portion { display: block; font-size: .8125rem; color: var(--muted); white-space: nowrap; }
@media (max-width: 480px) {
  table.meal-view th, table.meal-view td { padding: .55rem .35rem; }
  table.meal-view th:first-child, table.meal-view td:first-child { padding-left: .1rem; }
}
table.meal-view .meal-dish { font-weight: 500; color: var(--ink-2); }
.meal-editor input.mi-dish { display: inline-block; width: auto; min-width: 12rem; min-height: 32px; margin-left: .5rem; padding: .2rem .5rem; font-size: .875rem; font-weight: 500; }

/* ---------- Двофакторна автентифікація ---------- */
body.tfa { grid-template-columns: 1fr !important; }
.tfa-box { width: 100%; max-width: 400px; }
.tfa-box form + form, .tfa-resend { margin-top: .75rem; }
.tfa-recovery { margin-top: 1.25rem; border-top: 1px solid var(--line-soft); padding-top: .75rem; }
.tfa-recovery summary, details.panel > summary { cursor: pointer; }
.tfa-recovery form { margin-top: .75rem; }
.tfa-back { margin-top: 1.25rem; font-size: .9rem; }
.code-input { font-size: 1.4rem; letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; }
.inline-h { display: inline; font-size: 1.1rem; margin: 0; }
details.panel[open] > summary { margin-bottom: .75rem; }
.tfa-methods { border: 0; padding: 0; margin: 0 0 1rem; display: grid; gap: .6rem; }
.tfa-methods legend { font-weight: 600; margin-bottom: .4rem; }
.tfa-method { display: flex; gap: .7rem; align-items: flex-start; padding: .75rem .9rem; border: 1px solid #D6D6D0; border-radius: 12px; cursor: pointer; }
.tfa-method:has(input:checked) { border-color: var(--accent-ink); background: var(--accent-soft); }
.tfa-method input { margin-top: .25rem; }
.tfa-method > span { display: grid; gap: .15rem; }
.tfa-method .hint { margin: 0; }
.tfa-steps { padding-left: 1.2rem; display: grid; gap: .3rem; }
.tfa-qr { display: inline-block; padding: 12px; background: #fff; border-radius: 12px; margin: .5rem 0; min-height: 1px; }
.tfa-qr img, .tfa-qr canvas { display: block; }
.tfa-secret { font-size: 1rem; letter-spacing: .05em; word-break: break-all; }
.tfa-setup-extra { margin-top: .75rem; }
.code-list { columns: 2; padding-left: 1.6rem; font-size: 1.05rem; line-height: 1.9; }
@media print {
  body > *:not(main), main > *:not(.tfa-codes), .tfa-codes .actions { display: none !important; }
}
