:root {
  --bg: #0e0f11;
  --bg2: #141518;
  --bg3: #1a1c20;
  --bg4: #21242a;
  --border: rgba(255, 255, 255, 0.07);
  --border2: rgba(255, 255, 255, 0.12);
  --text: #e8e9ec;
  --text2: #7f8390;
  --text3: #4a4f5a;
  --green: #2dd87a;
  --green-dim: rgba(45, 216, 122, 0.12);
  --amber: #f0a733;
  --amber-dim: rgba(240, 167, 51, 0.12);
  --red: #f05050;
  --red-dim: rgba(240, 80, 80, 0.1);
  --blue: #5b9cf6;
  --blue-dim: rgba(91, 156, 246, 0.12);
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* Светлая тема: data-theme="light" на <html>
 *
 * Было: --bg #fafbfc, --bg2 #ffffff. Между холстом и карточкой полтора процента
 * яркости — то есть их нельзя различить, «белое на белом». В тёмной теме такой
 * проблемы нет: там холст почти чёрный, а поверхности заметно светлее.
 *
 * Стало: холст — отчётливо серый, карточки — чистый белый, вложенные поверхности
 * (инпуты, ховер, чипы) — серее холста. Плюс границы вдвое плотнее: 7% чёрного
 * на белом фоне глаз не видит вовсе.
 */
[data-theme="light"] {
  --bg:  #dde2e8;   /* холст: заметно серый — на нём белая карточка читается сразу */
  --bg2: #ffffff;   /* карточки, панели, таблицы */
  --bg3: #eef1f5;   /* инпуты, ховер, чипы */
  --bg4: #d3d9e1;   /* нажатое / активное состояние */
  --border:  rgba(0, 0, 0, 0.18);
  --border2: rgba(0, 0, 0, 0.30);
  --text:  #080b0f;
  --text2: #414a57;
  --text3: #69737f;   /* было #9aa0aa — на 10-11px подписях нечитаемо */
  --green: #0f7a3f;
  --green-dim: rgba(15, 122, 63, 0.16);
  --amber: #ff5a00;
  --amber-dim: rgba(255, 90, 0, 0.18);
  --red: #b32626;
  --red-dim: rgba(179, 38, 38, 0.13);
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.08), 0 2px 6px rgba(16, 24, 40, 0.09);
  --shadow-lg: 0 10px 32px rgba(16, 24, 40, 0.20);
}

/* В тёмной теме поверхности разделяет разница яркости, тень не нужна и
   выглядит грязно. В светлой — наоборот, тень и есть основной признак «карточка». */
:root { --shadow: none; --shadow-lg: none; }

[data-theme="light"] .topbar,
[data-theme="light"] .sidebar { box-shadow: var(--shadow); }
[data-theme="light"] dialog { box-shadow: var(--shadow-lg); }
[data-theme="light"] table { box-shadow: var(--shadow); }
[data-theme="light"] .btn,
[data-theme="light"] .theme-toggle,
[data-theme="light"] input,
[data-theme="light"] select,
[data-theme="light"] textarea { box-shadow: inset 0 1px 1px rgba(16, 24, 40, 0.03); }

/* Тело таблиц прозрачное — в тёмной теме сквозь него виден тёмный холст, и это
   правильно (шапка светлее тела = «приподнята»). В светлой получалось наоборот:
   серое тело и белая шапка. Возвращаем привычный порядок — белое тело, серая шапка. */
[data-theme="light"] table { background: var(--bg2); border-radius: 6px; overflow: hidden; }
[data-theme="light"] .daily-grid th,
[data-theme="light"] .wk-table thead th,
[data-theme="light"] .plan-table th { background: var(--bg3); }
[data-theme="light"] .wk-selector-cell { background: var(--bg3) !important; }
[data-theme="light"] tbody tr:hover td { background: rgba(0, 0, 0, 0.045); }

/* Разделители внутри таблиц: на белом фоне общий --border всё ещё бледноват,
   а именно по ним глаз выстраивает сетку. */
[data-theme="light"] .daily-grid th,
[data-theme="light"] .daily-grid td,
[data-theme="light"] .wk-table th,
[data-theme="light"] .wk-table td { border-color: rgba(0, 0, 0, 0.14); }
[data-theme="light"] .daily-grid thead th,
[data-theme="light"] .wk-table thead th { border-bottom: 2px solid rgba(0, 0, 0, 0.28); }

/* Сайдбар и топбар — отдельные плоскости, а не продолжение холста */
[data-theme="light"] .sidebar { border-right: 2px solid var(--green); }
[data-theme="light"] .topbar { border-bottom: 1px solid rgba(0, 0, 0, 0.16); }

/* Активный элемент списка клиентов должен быть виден без всматривания */
[data-theme="light"] .list-item.active { background: var(--bg4); }
[data-theme="light"] .list-item:hover { background: var(--bg3); }

/* Ссылка и акцент: #5b9cf6 рассчитан на тёмный фон, на белом слепит */
[data-theme="light"] { --blue: #1a63c9; --blue-dim: rgba(26, 99, 201, 0.12); }

/* Затемнение под модалкой на светлом фоне должно быть мягче */
[data-theme="light"] .ex-overlay { background: rgba(16, 24, 40, 0.45); }

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 14px; }
a { color: var(--blue); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 6px 12px; border: 1px solid var(--border2);
  background: var(--bg3); color: var(--text); border-radius: 4px;
  font-size: 13px; transition: all 0.15s;
}
.btn:hover { background: var(--bg4); }
.btn-primary { background: var(--green); color: #fff; border-color: var(--green); }
.btn-primary:hover { background: #25b566; }
[data-theme="light"] .btn-primary { color: #fff; }
.btn-danger { color: var(--red); border-color: var(--red-dim); }
.btn-danger:hover { background: var(--red-dim); }

/* Переключатель темы — маленькая кнопка-иконка */
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  background: var(--bg3); border: 1px solid var(--border2);
  border-radius: 4px; color: var(--text2); cursor: pointer;
  transition: all 0.15s; padding: 0;
}
.theme-toggle:hover { background: var(--bg4); color: var(--text); }
.theme-toggle svg { width: 16px; height: 16px; }

dialog {
  background: var(--bg2); color: var(--text); border: 1px solid var(--border2);
  border-radius: 8px; padding: 24px; max-width: 500px; width: 90%;

  /* Центрирование через inset:0 + margin:auto, а не top/left + translate(-50%,-50%).
     Старый приём ломается на высоких модалках: смещение считается от исходной
     позиции, и когда высота упирается в max-height, коробку утягивает вверх за
     границу окна — а доскроллить туда нельзя, элемент fixed. Ловилось на каталоге
     упражнений и на «Плане недели» с 8 строками.
     inset:0 + margin:auto центрирует коробку с ограниченными размерами всегда
     и выехать за экран не может по определению. */
  position: fixed;
  inset: 0;
  margin: auto;
  max-height: 88vh;
  overflow-y: auto;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.7); }
[data-theme="light"] dialog::backdrop { background: rgba(0, 0, 0, 0.4); }
dialog h3 { font-size: 16px; margin-bottom: 16px; }
dialog label { display: block; margin-bottom: 10px; font-size: 12px; color: var(--text2); }
dialog input:not([type="checkbox"]):not([type="radio"]), dialog select, dialog textarea {
  width: 100%; margin-top: 4px; padding: 8px 10px;
  background: var(--bg); border: 1px solid var(--border2); border-radius: 4px; color: var(--text);
  font-size: 13px; font-family: inherit;
}
input[type="checkbox"], input[type="radio"] {
  accent-color: var(--green);
}
dialog input[type="checkbox"], dialog input[type="radio"] {
  width: auto; margin-top: 0; flex-shrink: 0;
}
dialog label:has(> input[type="checkbox"]), dialog label:has(> input[type="radio"]) {
  display: flex; align-items: center;
}
.dialog-btns { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

/* Оценка тренера — общий полноэкранный экран (client.html — форма оценки
   звёздами по deep-link ?startapp=trainer_rating; coach.html — детальный
   просмотр по клику на бейдж "⭐ X.X" в шапке). НАСТОЯЩИЙ полный экран, не
   поповер/боттом-шит: своя страница на всю высоту вьюпорта, поверх всего. */
.tr-screen {
  display: none; position: fixed; inset: 0; z-index: 400;
  background: var(--bg); flex-direction: column;
}
.tr-screen.open { display: flex; }
.tr-screen-head {
  flex: 0 0 auto; display: flex; align-items: center; gap: 12px;
  padding: 16px 18px; border-bottom: 1px solid var(--border);
}
.tr-screen-head .tr-title { font-size: 16px; font-weight: 700; flex: 1; }
.tr-screen-close {
  background: none; border: none; color: var(--text3); font-size: 22px;
  line-height: 1; cursor: pointer; padding: 4px 8px;
}
.tr-screen-close:hover { color: var(--text); }
/* Крестик «Общих настроек» — на полноэкранной странице с кучей карточек
   обычный tr-screen-close (тусклый text3) визуально теряется в шапке,
   янтарём выделяем именно этот, остальные tr-screen (рейтинг и т.п.) не трогаем. */
#alert-thresholds-dialog .tr-screen-close { color: var(--amber); }
#alert-thresholds-dialog .tr-screen-close:hover { color: var(--amber); opacity: .8; }
.tr-screen-body {
  flex: 1; overflow-y: auto; padding: 26px 20px 40px;
  display: flex; flex-direction: column; align-items: center;
}
.tr-screen-inner { width: 100%; max-width: 440px; display: flex; flex-direction: column; gap: 22px; }

/* Узкий вариант .tr-screen — центрированная модалка ~640px с затемнением,
   вместо полноэкранной страницы (сам .tr-screen остаётся полноэкранным —
   форма оценки звёздами в client.html). Используется для детального
   просмотра рейтинга тренера в coach.html (openTrainerRatingBadge) — в паре
   с «Общими настройками» тренера, которые, наоборот, стали полноэкранными. */
.tr-screen.tr-screen-narrow {
  background: rgba(0, 0, 0, .55); align-items: center; justify-content: center; padding: 20px;
}
.tr-screen-narrow .tr-screen-panel {
  width: 100%; max-width: 640px; max-height: 88vh;
  background: var(--bg); border: 1px solid var(--border); border-radius: 12px;
  display: flex; flex-direction: column; overflow: hidden;
}
.tr-screen-narrow .tr-screen-head { flex: 0 0 auto; }
.tr-screen-narrow .tr-screen-body { flex: 1; overflow-y: auto; }
.tr-intro { font-size: 14px; color: var(--text2); line-height: 1.5; text-align: center; }
.tr-stars { display: flex; justify-content: center; gap: 10px; }
.tr-star {
  background: none; border: none; padding: 0; font-size: 44px; line-height: 1;
  color: var(--text3); cursor: pointer; transition: color .15s ease, transform .1s ease;
}
.tr-star.on { color: var(--amber); }
.tr-star:active { transform: scale(1.12); }
.tr-label { text-align: center; font-size: 14px; color: var(--text2); min-height: 18px; }
.tr-comment {
  width: 100%; min-height: 110px; background: var(--bg2); border: 1px solid var(--border2);
  border-radius: 8px; padding: 12px; color: var(--text); font-size: 14px; resize: vertical; font-family: inherit;
}
.tr-comment::placeholder { color: var(--text3); }
.tr-comment-label { font-size: 12px; color: var(--text3); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 8px; }
.tr-submit-wrap { padding-top: 4px; }
.tr-submit {
  width: 100%; padding: 14px; border-radius: 8px; border: none; cursor: pointer;
  background: var(--text3); color: #fff; font-size: 15px; font-weight: 600; transition: background .15s ease;
}
.tr-submit.ready { background: var(--green); cursor: pointer; }
.tr-submit:disabled { cursor: default; }
.tr-thanks { display: flex; flex-direction: column; align-items: center; justify-content: center; flex: 1; gap: 14px; text-align: center; padding: 0 30px; }
.tr-thanks-emoji { font-size: 48px; }
.tr-thanks-title { font-size: 18px; font-weight: 700; }
.tr-thanks-sub { font-size: 14px; color: var(--text2); line-height: 1.5; }

/* Шкала NPS (0-10 кнопками) — экран «Оцените нас» в client.html, тот же
   .tr-screen контейнер, что у звёзд рейтинга тренера, только сама шкала своя. */
.nps-scale { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.nps-btn {
  aspect-ratio: 1; border-radius: 8px; border: 1px solid var(--border2); background: var(--bg2);
  color: var(--text2); font-size: 16px; font-weight: 600; cursor: pointer; transition: all .15s ease;
}
.nps-btn:active { transform: scale(.95); }
.nps-btn.on { background: var(--amber); border-color: var(--amber); color: #1a1300; }
.nps-scale-ends { display: flex; justify-content: space-between; font-size: 11px; color: var(--text3); margin-top: -12px; }

