/* iTfiTco — панель управления (зона admin). Своя система цветов:
   сине-фиолетовый акцент, тёмная и светлая темы — html[data-theme]. */

:root,
[data-theme="dark"] {
  --bg: #070b16;
  --bg-glow: radial-gradient(1200px 600px at 20% -10%, rgba(79, 70, 229, 0.18), transparent 60%);
  --surface: #0e1424;
  --surface-2: #131a2e;
  --surface-3: #1b2440;
  --line: rgba(148, 163, 216, 0.14);
  --text: #eef1fb;
  --muted: #8d97b5;
  --accent: #6d6af8;
  --accent-strong: #8583ff;
  --accent-soft: rgba(109, 106, 248, 0.16);
  --accent-text: #ffffff;
  --good: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.14);
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 12px 32px rgba(0, 0, 0, 0.35);

  /* Цвета показателей и сегментов (яркие — на тёмной поверхности). */
  --tone-users: #34d399;
  --tone-workouts: #5b8cff;
  --tone-clients: #a78bfa;
  --tone-payments: #fbbf24;
  --tone-camera: #818cf8;
  --tone-manual: #c084fc;
  --tone-web: #2dd4bf;
  --tone-accent: #6d6af8;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f4f6fc;
  --bg-glow: none;
  --surface: #ffffff;
  --surface-2: #f6f7fd;
  --surface-3: #eceffa;
  --line: #e4e8f4;
  --text: #141a33;
  --muted: #6b7394;
  --accent: #4f46e5;
  --accent-strong: #4338ca;
  --accent-soft: #eceafe;
  --accent-text: #ffffff;
  --good: #059669;
  --warn: #b7791f;
  --danger: #dc2626;
  --danger-soft: #fdeaea;
  --shadow: 0 1px 2px rgba(20, 26, 51, 0.04), 0 10px 28px rgba(20, 26, 51, 0.06);

  /* Темнее, чем в тёмной теме: контраст с белым ≥ 3:1. */
  --tone-users: #059669;
  --tone-workouts: #3b6cf6;
  --tone-clients: #7c3aed;
  --tone-payments: #b7791f;
  --tone-camera: #4f46e5;
  --tone-manual: #9333ea;
  --tone-web: #0d9488;
  --tone-accent: #4f46e5;
  color-scheme: light;
}

.tone--users { --tone: var(--tone-users); }
.tone--workouts { --tone: var(--tone-workouts); }
.tone--clients { --tone: var(--tone-clients); }
.tone--payments { --tone: var(--tone-payments); }
.tone--camera { --tone: var(--tone-camera); }
.tone--manual { --tone: var(--tone-manual); }
.tone--web { --tone: var(--tone-web); }
.tone--accent { --tone: var(--tone-accent); }

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg-glow), var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 14px/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; letter-spacing: -0.01em; }
h2 { font-size: 16px; }

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; }
.error { color: var(--danger); font-size: 13px; min-height: 0; margin: 6px 0 0; }
.error:empty { display: none; }

[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/1.2 inherit;
  font-family: inherit;
  cursor: pointer;
  background: var(--surface-2);
  color: var(--text);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.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--outline { background: transparent; border-color: var(--accent); color: var(--accent); }
.btn--outline:hover { background: var(--accent-soft); }
.btn--light { background: #ffffff; color: #3730a3; }
[data-theme="light"] .btn--light { background: var(--accent); color: #ffffff; }
.btn--danger { background: transparent; border-color: var(--line); 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 {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn--small { width: 30px; height: 30px; border-radius: 8px; }
.icon-btn--small svg { width: 16px; height: 16px; }

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 13px; color: var(--muted); font-weight: 500; }

input,
.input,
.select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
}
input:focus, .select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.select { width: auto; cursor: pointer; }
.select--small { padding: 6px 10px; font-size: 13px; border-radius: 10px; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--surface-3);
  color: var(--muted);
  white-space: nowrap;
}
.badge--paid { background: rgba(52, 211, 153, 0.14); color: var(--good); }
.badge--pending { background: rgba(251, 191, 36, 0.14); color: var(--warn); }
.badge--cancelled { background: var(--danger-soft); color: var(--danger); }
.badge--role, .badge--soon { background: var(--accent-soft); color: var(--accent); }
.badge--trainer { background: rgba(167, 139, 250, 0.16); color: var(--tone-clients); }

.spinner {
  width: 34px;
  height: 34px;
  margin: 24px auto;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading { min-height: 100vh; display: grid; place-items: center; }

.empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
}

/* ------------------------------------------------------------------ */
/* Вход и заглушки                                                      */
/* ------------------------------------------------------------------ */

.gate { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.gate__card {
  width: min(400px, 100%);
  display: grid;
  gap: 14px;
  padding: 32px;
  border-radius: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

/* ------------------------------------------------------------------ */
/* Раскладка: меню слева, верхняя панель, содержимое                   */
/* ------------------------------------------------------------------ */

.app {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px 16px;
  border-right: 1px solid var(--line);
  overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px; }
.brand--center { justify-content: center; }
.brand__mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  color: var(--text);
}
.brand__mark svg { width: 34px; height: 34px; stroke-width: 2; }
.brand__text { display: grid; line-height: 1.15; }
.brand__text b { font-size: 22px; letter-spacing: -0.02em; }
.brand__text small { color: var(--muted); font-size: 11px; }

.menu { display: grid; gap: 4px; }
.menu a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 12px;
  color: var(--text);
  opacity: 0.82;
  font-weight: 500;
}
.menu a svg { width: 18px; height: 18px; }
.menu a:hover { background: var(--surface-2); opacity: 1; }
.menu a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--text);
  opacity: 1;
  font-weight: 600;
}
[data-theme="light"] .menu a[aria-current="page"] { color: var(--accent); }

.side-card {
  margin-top: auto;
  display: grid;
  gap: 8px;
  padding: 18px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.side-card__icon { width: 26px; height: 26px; color: var(--warn); }
.side-card p { margin: 0 0 6px; color: var(--muted); font-size: 13px; }

/* Затемнение под выезжающим меню — только на узком экране. */
.scrim { display: none; }

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 18px 32px 0;
}
.topbar__menu { display: none; margin-right: auto; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  margin-right: auto;
}
.pill svg { width: 16px; height: 16px; }
.pill--warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }

.check { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.check--wide, .field--wide { grid-column: 1 / -1; }

.theme-switch {
  display: inline-flex;
  padding: 4px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.theme-switch button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 32px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.theme-switch button svg { width: 18px; height: 18px; }
.theme-switch button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }

.bell__dot {
  position: absolute;
  top: 9px;
  right: 10px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 2px var(--bg);
}

.account { position: relative; }
.account__button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 6px 6px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  text-align: left;
}
.account__button:hover { background: var(--surface-2); }
.account__button svg { width: 16px; height: 16px; color: var(--muted); }
.account__text { display: grid; line-height: 1.2; }
.account__text small { color: var(--muted); font-size: 12px; }

.avatar {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--tone-camera), var(--tone-manual));
  color: #ffffff;
  font-weight: 700;
  font-size: 14px;
  flex: none;
}
.avatar--small { width: 34px; height: 34px; font-size: 12px; }

.account__menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 20;
  min-width: 220px;
  display: grid;
  gap: 2px;
  padding: 8px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.account__menu a,
.account__menu > button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  text-align: left;
}
.account__menu a:hover,
.account__menu > button:hover { background: var(--surface-2); }
.account__menu svg { width: 18px; height: 18px; color: var(--muted); }

.lang { display: flex; gap: 4px; padding: 6px 4px; }
.lang button {
  flex: 1;
  padding: 6px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font: 600 12px inherit;
  font-family: inherit;
  cursor: pointer;
}
.lang button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }

.content { padding: 12px 32px 40px; }

.page-head { margin-bottom: 22px; }
.page-head h1 { margin-bottom: 6px; }
.page-head p { margin: 0; max-width: 560px; }

/* ------------------------------------------------------------------ */
/* Панели                                                               */
/* ------------------------------------------------------------------ */

.panel {
  position: relative;
  padding: 20px;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

/* ------------------------------------------------------------------ */
/* Главная                                                              */
/* ------------------------------------------------------------------ */

.home {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  align-items: start;
}
.home__side { display: grid; gap: 20px; }
.home__side .panel { margin-bottom: 0; }

.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.kpi {
  display: grid;
  gap: 4px;
  padding: 18px;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  min-width: 0;
  overflow: hidden;
}
.kpi__icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  margin-bottom: 8px;
  border-radius: 12px;
  color: var(--tone);
  background: color-mix(in srgb, var(--tone) 16%, transparent);
}
.kpi__label { color: var(--muted); font-size: 13px; }
.kpi__value { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
.kpi__foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; margin-top: 6px; }
.kpi__trend { display: grid; gap: 2px; font-size: 12px; min-width: 0; }
.kpi__change { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; color: var(--good); }
.kpi__change svg { width: 14px; height: 14px; stroke-width: 2.4; }
.kpi__change--down { color: var(--danger); }
.kpi__change--flat { color: var(--muted); }
.kpi__period { color: var(--muted); white-space: nowrap; }

.spark { width: 84px; height: 44px; flex: 0 1 84px; min-width: 40px; }
.spark__line { fill: none; stroke: var(--tone); stroke-width: 2; }
.grad-stop--top { stop-color: var(--tone); stop-opacity: 0.35; }
.grad-stop--bottom { stop-color: var(--tone); stop-opacity: 0; }

.charts {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
  gap: 20px;
}
.charts .panel { margin-bottom: 0; }

.chart { position: relative; }
/* Графики — не иконки: без общей обводки svg. */
.line-chart, .spark, .donut__ring { stroke: none; fill: none; stroke-width: 0; }
.line-chart text { stroke: none; }
.line-chart { width: 100%; height: 260px; display: block; }
.line-chart .grid { stroke: var(--line); stroke-width: 1; }
.line-chart .axis { fill: var(--muted); font-size: 11px; }
.line-chart__line { fill: none; stroke: var(--tone); stroke-width: 2.5; }
.line-chart__end { fill: var(--tone); stroke: var(--surface); stroke-width: 3; }
.line-chart .cursor { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }

.chart-tip {
  position: absolute;
  transform: translate(-50%, -100%);
  display: grid;
  gap: 2px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  pointer-events: none;
  white-space: nowrap;
  text-align: center;
}
.chart-tip small { color: var(--muted); font-size: 11px; }

.donut { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; justify-content: center; min-height: 220px; }
.donut__figure { position: relative; width: 180px; height: 180px; flex: none; }
.donut__ring { width: 180px; height: 180px; }
.donut__track { fill: none; stroke: var(--surface-3); }
.donut__arc { fill: none; stroke: var(--tone); stroke-linecap: butt; }
.donut__center {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
}
.donut__center b { font-size: 24px; letter-spacing: -0.02em; }
.donut__center small { color: var(--muted); font-size: 12px; }

.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; min-width: 160px; }
.legend li { display: grid; grid-template-columns: 10px 1fr auto; align-items: center; gap: 10px; }
.legend b { font-weight: 600; }
.legend__dot { width: 10px; height: 10px; border-radius: 50%; background: var(--tone); }

.events { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.event { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.event__icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  color: var(--tone);
  background: color-mix(in srgb, var(--tone) 16%, transparent);
}
.event__icon svg { width: 18px; height: 18px; }
.event__text { min-width: 0; display: grid; }
.event__text b { font-size: 13px; line-height: 1.3; }
.event__text small {
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.event time { color: var(--muted); font-size: 11px; white-space: nowrap; align-self: start; }

.promo { overflow: hidden; display: grid; gap: 10px; justify-items: start; min-height: 220px; }
.promo__icon { width: 32px; height: 32px; color: var(--accent); }
.promo h2 { font-size: 17px; max-width: 200px; }
.promo p { margin: 0; font-size: 13px; max-width: 190px; }
.promo .btn { position: relative; z-index: 1; margin-top: 6px; }
.promo__wave { position: absolute; right: 0; bottom: 0; width: 60%; height: 55%; }

/* ------------------------------------------------------------------ */
/* Списки разделов                                                      */
/* ------------------------------------------------------------------ */

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .input { flex: 1; min-width: 200px; }

.list { display: grid; gap: 10px; }

.row-item {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.panel .row-item { background: var(--surface-2); }
.row-item__main { flex: 1; min-width: 220px; }
.row-item__actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row-item .error { flex-basis: 100%; margin: 0; }
.row-item__title { font-weight: 600; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.row-item__meta { color: var(--muted); font-size: 13px; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0 14px;
  align-items: end;
}
.form-grid .btn { margin-bottom: 14px; }
.form-grid__head { grid-column: 1 / -1; margin-bottom: 14px; }
.form-grid__head p { margin: 6px 0 0; }
.form-grid .error { grid-column: 1 / -1; }
#package-form { margin-bottom: 12px; }

.soon { display: grid; gap: 10px; justify-items: start; }
.soon p { margin: 0; }

/* ------------------------------------------------------------------ */
/* Адаптивность                                                          */
/* ------------------------------------------------------------------ */

@media (max-width: 1360px) {
  .home { grid-template-columns: minmax(0, 1fr); }
  .home__side { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
}

@media (max-width: 1180px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .charts { grid-template-columns: minmax(0, 1fr); }
}

/* Меню выезжает по кнопке. */
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 40;
    width: 260px;
    background: var(--bg);
    transform: translateX(-100%);
    transition: transform 0.2s;
  }
  .app--menu-open .sidebar { transform: none; }
  .scrim {
    position: fixed;
    inset: 0;
    z-index: 30;
    background: rgba(0, 0, 0, 0.45);
    display: none;
  }
  .app--menu-open .scrim { display: block; }
  .topbar { padding: 12px 16px 0; }
  .topbar__menu { display: inline-grid; }
  .content { padding: 12px 16px 32px; }
}

@media (max-width: 560px) {
  h1 { font-size: 22px; }
  .kpis { grid-template-columns: minmax(0, 1fr); }
  .account__text { display: none; }
  .theme-switch button { width: 32px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
