/* iTfiTco для тренеров (зона pro). Своя система цветов — не смешивается
   с клиентским сайтом. Светлая и тёмная темы: html[data-theme]. */

:root,
[data-theme="light"] {
  --bg: #eef3f0;
  --surface: #ffffff;
  --surface-2: #f5f8f6;
  --surface-3: #e7eee9;
  --line: #dde6e0;
  --text: #16241d;
  --muted: #66776d;
  --accent: #2f8a64;
  --accent-strong: #226e4f;
  --accent-soft: #e2f1e9;
  --accent-text: #ffffff;
  --good: #2f8a64;
  --warn: #c07a12;
  --danger: #d4483d;
  --danger-soft: #fbe7e5;
  --shadow: 0 1px 2px rgba(22, 36, 29, 0.04), 0 8px 24px rgba(22, 36, 29, 0.06);
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0e141b;
  --surface: #151d26;
  --surface-2: #1a242f;
  --surface-3: #223040;
  --line: #243242;
  --text: #e7eef3;
  --muted: #8d9cab;
  --accent: #3fb58a;
  --accent-strong: #5ccb9f;
  --accent-soft: rgba(63, 181, 138, 0.14);
  --accent-text: #06140e;
  --good: #3fb58a;
  --warn: #e0a64a;
  --danger: #f06a5f;
  --danger-soft: rgba(240, 106, 95, 0.14);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 28px; }
h2 { font-size: 18px; }

a { color: inherit; text-decoration: none; }
.link { color: var(--accent); font-weight: 600; }
.link:hover { text-decoration: underline; }
.muted, .hint { color: var(--muted); }
.hint { font-size: 13px; }

[hidden] { display: none !important; }

.sprite { display: none; }

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

/* ------------------------------------------------------------------ */
/* Кнопки и поля                                                        */
/* ------------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid transparent;
  font: 600 14px inherit;
  font-family: inherit;
  cursor: pointer;
  background: var(--surface-2);
  color: var(--text);
  transition: background 0.15s, border-color 0.15s;
}

.btn svg { width: 18px; height: 18px; }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn--primary { background: var(--accent); color: var(--accent-text); }
.btn--primary:hover:not(:disabled) { background: var(--accent-strong); }
.btn--ghost { background: transparent; border-color: var(--line); }
.btn--ghost:hover:not(:disabled) { border-color: var(--accent); }
.btn--danger { color: var(--danger); }
.btn--danger:hover:not(:disabled) { border-color: var(--danger); background: var(--danger-soft); }
.btn--small { padding: 6px 12px; font-size: 13px; border-radius: 10px; }
.btn--block { width: 100%; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  color: var(--muted);
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }

.field { display: grid; gap: 6px; margin-bottom: 14px; font-size: 13px; color: var(--muted); }

input, textarea, select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font: 15px inherit;
  font-family: inherit;
}

input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { resize: vertical; }

.error { color: var(--danger); font-size: 13px; min-height: 18px; margin: 4px 0 10px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ------------------------------------------------------------------ */
/* Каркас: меню · центр · быстрые действия                              */
/* ------------------------------------------------------------------ */

.app {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr) 300px;
  min-height: 100vh;
}

.app--no-aside { grid-template-columns: 248px minmax(0, 1fr); }
.app--no-aside .aside { display: none; }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 22px 16px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.brand--center { justify-content: center; margin-bottom: 20px; }
.brand b { display: block; font-size: 20px; letter-spacing: 0.2px; }
.brand small { display: block; color: var(--muted); font-size: 12px; margin-top: -2px; }

.brand__mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-text);
}

.menu { display: grid; gap: 4px; }

.menu a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--muted);
  font-weight: 500;
}

.menu a:hover { background: var(--surface-2); color: var(--text); }
.menu a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.profile {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 8px 0;
  border-top: 1px solid var(--line);
}

.profile__text { flex: 1; min-width: 0; }
.profile__text b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile__text small { color: var(--muted); font-size: 12px; }

.avatar {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

.avatar--lg { width: 64px; height: 64px; font-size: 24px; }

.main { padding: 28px 32px 48px; min-width: 0; }

.aside {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 28px 20px;
  border-left: 1px solid var(--line);
  background: var(--surface-2);
}

.aside h2 { margin-bottom: 4px; }

.action {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: transform 0.15s;
}

.action:hover { transform: translateY(-1px); }
.action > span:nth-child(2) { flex: 1; min-width: 0; }
.action b { display: block; font-size: 14px; }
.action small { color: var(--muted); font-size: 12px; }
.chevron { color: var(--muted); width: 16px; height: 16px; }

.action__icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
}

.quote {
  margin-top: auto;
  display: flex;
  gap: 12px;
  padding: 18px;
  border-radius: 16px;
  background: var(--accent-soft);
  color: var(--accent);
}

.quote p { margin: 0; font-weight: 500; }

/* ------------------------------------------------------------------ */
/* Содержимое                                                            */
/* ------------------------------------------------------------------ */

.hero {
  padding: 26px 28px;
  border-radius: 20px;
  background: linear-gradient(120deg, var(--surface) 55%, var(--accent-soft));
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.hero h1 { font-size: 32px; margin-bottom: 8px; }
.hero p { margin: 0; color: var(--muted); max-width: 620px; }

.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}

.kpis--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.kpi {
  display: grid;
  gap: 2px;
  padding: 18px;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.kpi b { font-size: 28px; }
.kpi > span:not(.kpi__icon) { color: var(--muted); font-size: 13px; }

.kpi__icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin-bottom: 8px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
}

.kpi__delta { font-size: 12px; color: var(--muted); }
.kpi__delta--up { color: var(--good); }
.kpi__delta--down { color: var(--danger); }

.section-head,
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.page-head { margin-bottom: 20px; }
.page-head h1 { margin-right: auto; }

.client-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
}

.client-card {
  display: grid;
  gap: 10px;
  padding: 16px;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.client-card__top { display: flex; align-items: center; gap: 10px; }
.client-card__top > div { flex: 1; min-width: 0; }
.client-card b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.client-card small { color: var(--muted); font-size: 12px; }

.bar { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.bar > span { display: block; height: 100%; width: 0; border-radius: 99px; background: var(--accent); }
.bar-row { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); }
.bar-row .bar { flex: 1; }

.panel {
  padding: 20px;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.panel h2 { margin-bottom: 12px; }

.table { display: grid; gap: 8px; margin-bottom: 24px; }

.table-row {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1.2fr) minmax(0, 1.4fr) auto;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.table-row--head { background: transparent; box-shadow: none; padding-top: 0; padding-bottom: 0; color: var(--muted); font-size: 12px; }
.table-row .who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.table-row .who > div { min-width: 0; }
.table-row .who b, .table-row .who small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.table-row small { color: var(--muted); font-size: 12px; }
.table-row .actions { display: flex; gap: 6px; justify-content: flex-end; }

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  background: var(--surface-3);
  color: var(--muted);
  white-space: nowrap;
}

.badge--paid { background: var(--accent-soft); color: var(--accent); }
.badge--pending { background: rgba(192, 122, 18, 0.14); color: var(--warn); }
.badge--cancelled { background: var(--danger-soft); color: var(--danger); }

.invite {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 14px 18px;
  margin-bottom: 10px;
  border-radius: 14px;
  border: 1px dashed var(--accent);
  background: var(--accent-soft);
}

.invite > div { flex: 1; min-width: 200px; }

.invite code {
  font: 700 22px ui-monospace, "Cascadia Mono", Consolas, monospace;
  letter-spacing: 3px;
  color: var(--accent);
}

/* Истёкший код: можно обновить или удалить. */
.invite--expired { border-color: var(--muted); background: transparent; }
.invite--expired code { color: var(--muted); text-decoration: line-through; }

/* Использованный код — зачёркнут, рядом клиент. */
.invite-used { grid-template-columns: minmax(0, 0.8fr) minmax(0, 2fr) auto; }
.invite-used s {
  font: 600 16px ui-monospace, "Cascadia Mono", Consolas, monospace;
  letter-spacing: 2px;
  color: var(--muted);
}

.crumbs { color: var(--muted); font-size: 13px; margin: 0 0 12px; }
.crumbs a:hover { color: var(--accent); }

.client-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.client-head > div { flex: 1; min-width: 0; }
.client-head p { margin: 2px 0 0; }

.split { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 18px; }

.workout-line {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.workout-line:last-child { border-bottom: 0; }
.workout-line small { display: block; color: var(--muted); font-size: 12px; }
.workout-line .score { font-weight: 700; color: var(--accent); }
.workout-line .date { color: var(--muted); font-size: 12px; min-width: 64px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }

.card {
  display: grid;
  gap: 10px;
  align-content: start;
  padding: 18px;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.card p { margin: 0; color: var(--muted); }

.items { margin: 0; padding-left: 20px; }
.items li { margin-bottom: 4px; }
.items small { display: block; color: var(--muted); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px 4px 3px 10px;
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
}

.chip button { border: 0; background: transparent; color: inherit; cursor: pointer; font-size: 15px; padding: 0 6px; }

.card .row select { width: auto; flex: 1; min-width: 140px; }

.editor__head,
.editor__item {
  display: grid;
  grid-template-columns: 2fr 0.8fr 0.9fr 0.9fr 2fr auto;
  gap: 8px;
  align-items: center;
}

.editor__head { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.editor__item { margin-bottom: 8px; }
.editor__item input, .editor__item select { padding: 8px 10px; }

.packages { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; margin: 12px 0 28px; }
.package b { font-size: 18px; }
.package .price { font-size: 26px; font-weight: 700; color: var(--accent); }

.notice { padding: 12px 16px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); }

.settings .setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.settings .setting:last-child { border-bottom: 0; }

.segmented { display: inline-flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--surface-2); }

.segmented button {
  border: 0;
  padding: 7px 12px;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font: 600 13px inherit;
  font-family: inherit;
  cursor: pointer;
}

.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.more-menu { display: none; }

.soon { text-align: center; padding: 48px 24px; }
.soon p { color: var(--muted); max-width: 520px; margin: 12px auto 0; }
.soon__badge { display: inline-block; padding: 4px 14px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-weight: 700; }

.empty { color: var(--muted); padding: 24px; text-align: center; }

/* ------------------------------------------------------------------ */
/* Вход и заглушки                                                      */
/* ------------------------------------------------------------------ */

.gate { min-height: 100vh; display: grid; place-items: center; padding: 20px; }

.gate__card {
  width: 100%;
  max-width: 400px;
  padding: 28px;
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
  display: grid;
  gap: 8px;
}

.gate__card h1 { font-size: 22px; }
.gate__card p { margin: 0; color: var(--muted); }

.check { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: var(--muted); cursor: pointer; margin: 8px 0; }
.check input { width: 16px; height: 16px; margin-top: 2px; accent-color: var(--accent); flex: none; }
.gate__card .link { justify-self: center; font-size: 14px; }

.loading { min-height: 100vh; display: grid; place-items: center; }

.spinner {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 3px solid var(--surface-3);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.tabbar { display: none; }

/* ------------------------------------------------------------------ */
/* Адаптивность: планшет — меню значками, телефон — нижняя панель       */
/* ------------------------------------------------------------------ */

@media (max-width: 1279px) {
  .app, .app--no-aside { grid-template-columns: 76px minmax(0, 1fr); }
  .brand__text, .menu a span, .profile__text { display: none; }
  .menu a { justify-content: center; }
  .profile { flex-direction: column; }
  .aside { grid-column: 2; position: static; height: auto; border-left: 0; background: transparent; padding: 0 32px 40px; }
  .app--no-aside .aside { display: none; }
  .quote { margin-top: 8px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 767px) {
  body { padding-bottom: 72px; }
  .app, .app--no-aside { display: block; }
  .sidebar { display: none; }
  .main { padding: 18px 16px 24px; }
  .aside { padding: 0 16px 24px; }
  .hero { padding: 20px; }
  .hero h1 { font-size: 26px; }
  .kpis, .kpis--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 14px; }
  .kpi b { font-size: 24px; }
  .split { grid-template-columns: 1fr; }
  .table-row { grid-template-columns: minmax(0, 1fr) auto; }
  .table-row > :nth-child(2), .table-row > :nth-child(3) { display: none; }
  .invite-used { grid-template-columns: auto minmax(0, 1fr); }
  .invite-used > :nth-child(2) { display: flex; }
  .table-row--head { display: none; }
  .editor__head { display: none; }
  .editor__item { grid-template-columns: 1fr 1fr 1fr auto; }
  .editor__item select, .editor__item input:nth-child(5) { grid-column: 1 / -1; }
  .more-menu { display: grid; }
  .page-head h1 { font-size: 24px; }

  .tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    background: var(--surface);
    border-top: 1px solid var(--line);
  }

  .tabbar a {
    display: grid;
    justify-items: center;
    gap: 2px;
    padding: 4px;
    color: var(--muted);
    font-size: 11px;
  }

  .tabbar a[aria-current="page"] { color: var(--accent); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
