/* S-Fitness CRM — дизайн-система (оригинальная, не копия стороннего продукта) */

:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-raised: #ffffff;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --border: rgba(11, 11, 11, 0.10);
  --border-strong: #e1e0d9;

  --brand: #2a78d6;
  --brand-dark: #184f95;
  --brand-light: #e8f1fc;
  --brand-accent: #5aa3e8;

  /* Фирменные цвета клуба — по эмблеме тренажёрного зала (чёрный + золото). */
  --club-ink: #14120d;
  --club-ink-hover: #262319;
  --club-gold: #e7bc3a;
  --club-gold-dark: #b6912a;

  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #4a3aa7;
  --series-8: #e34948;

  --good: #0ca30c;
  --good-bg: #e7f7e7;
  --warning: #fab219;
  --warning-bg: #fff6e2;
  --serious: #ec835a;
  --serious-bg: #fdeee6;
  --critical: #d03b3b;
  --critical-bg: #fbe9e9;

  --sidebar-bg: #eaf3fd;
  --sidebar-bg-hover: #d7e9fb;
  --sidebar-text: #4d6f92;
  --sidebar-text-active: #ffffff;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(11,11,11,0.06);
  --shadow-md: 0 4px 16px rgba(11,11,11,0.08);
  --sidebar-w: 240px;
  --topbar-h: 64px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
::selection { background: var(--brand-light); }

.boot-loader { display:flex; align-items:center; justify-content:center; height:100vh; }
.spinner { width:32px; height:32px; border-radius:50%; border:3px solid var(--border-strong); border-top-color: var(--brand); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- layout ---------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  border-right: 1px solid #d3e3f5;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px;
  color: var(--brand-dark);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.2px;
}
.sidebar-brand .mark {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--club-ink);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: var(--club-gold);
}
.sidebar-nav { flex: 1; padding: 8px 12px; overflow-y: auto; }
.sidebar-nav .nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  margin-bottom: 2px; cursor: pointer;
  font-size: 13.5px; font-weight: 500;
  transition: background .12s ease, color .12s ease;
}
.sidebar-nav .nav-item:hover { background: var(--sidebar-bg-hover); color: var(--brand-dark); }
.sidebar-nav .nav-item.active { background: var(--club-ink); color: var(--club-gold); box-shadow: inset 3px 0 0 var(--club-gold); }
.sidebar-nav .nav-item .icon { width: 18px; text-align: center; opacity: .9; }
.sidebar-foot { padding: 14px 20px; border-top: 1px solid #d3e3f5; font-size: 12px; color: var(--sidebar-text); }

/* Всплывающее (раскрывающееся) меню — «Абонементы» и подобные группы, как
   «Занятия» в ListokCRM: клик по родителю раскрывает список подстраниц. */
.nav-item--parent { justify-content: space-between; }
.nav-item--parent.open { background: var(--sidebar-bg-hover); color: var(--brand-dark); }
.nav-item--parent .nav-caret { margin-left: auto; font-size: 10px; transition: transform .15s ease; opacity: .7; }
.nav-item--parent.open .nav-caret { transform: rotate(180deg); }
.nav-submenu { max-height: 0; overflow: hidden; transition: max-height .18s ease; }
.nav-submenu.open { max-height: 300px; }
.nav-submenu .nav-item--child {
  padding-left: 40px; font-size: 12.5px; font-weight: 400;
  color: var(--sidebar-text);
}
.nav-submenu .nav-item--child.active { background: var(--club-ink); color: var(--club-gold); box-shadow: inset 3px 0 0 var(--club-gold); }

.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  background: var(--surface-raised);
  border-bottom: 1px solid var(--border-strong);
  position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 18px; margin: 0; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.user-chip { display:flex; align-items:center; gap:8px; padding: 6px 10px; border-radius: 999px; background: var(--page); cursor:pointer; }
.avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--brand); color:#fff; display:flex; align-items:center; justify-content:center; font-size:12px; font-weight:700; }

.content { padding: 24px; flex: 1; }

/* ---------- primitives ---------- */
.card {
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.card + .card { margin-top: 16px; }
.card-title { font-size: 14px; font-weight: 700; margin: 0 0 14px; display:flex; align-items:center; justify-content:space-between; padding-left: 10px; border-left: 3px solid var(--club-gold); }

.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2,1fr);} .grid-3 { grid-template-columns: repeat(2,1fr);} }

.stat-tile { background: var(--surface-raised); border:1px solid var(--border-strong); border-radius: var(--radius-lg); padding: 18px 20px; }
.stat-tile .label { color: var(--text-muted); font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat-tile .value { font-size: 26px; font-weight: 800; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat-tile .delta { margin-top: 6px; font-size: 12.5px; font-weight: 600; }
.stat-tile .delta.good { color: var(--good); }

/* Сводка «Отчёты» — цветные карточки с итогами за период, как на странице
   отчётов ListokCRM: заметный цветной фон вместо нейтральной карточки,
   значения крупным светлым шрифтом, изменение к пред. периоду — плашкой. */
.summary-card { border: none; color: #fff; }
.summary-card .card-title { color: rgba(255,255,255,.92); border-left-color: rgba(255,255,255,.55); }
.summary-card .kv-list dt { color: rgba(255,255,255,.78); }
.summary-card .kv-list dd { color: #fff; font-size: 15px; }
.summary-card .delta-pill {
  display: inline-flex; align-items: center; gap: 3px; margin-left: 8px;
  padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 700;
  background: rgba(255,255,255,.92); vertical-align: middle; white-space: nowrap;
}
.summary-card .delta-pill.good { color: #157347; }
.summary-card .delta-pill.bad { color: #b42318; }
.summary-tone-finance { background: linear-gradient(135deg, #e2574a, #c94436); }
.summary-tone-visits { background: linear-gradient(135deg, #4a7fc9, #3a63a8); }
.summary-tone-stats { background: linear-gradient(135deg, #7c5cbf, #63459f); }
.stat-tile .delta.bad { color: var(--critical); }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-raised); color: var(--text-primary);
  font-size: 13.5px; font-weight: 600; cursor: pointer;
  transition: background .12s ease, border-color .12s ease;
}
.btn:hover { background: var(--page); }
.btn-primary { background: var(--club-ink); border-color: var(--club-ink); color: var(--club-gold); font-weight: 700; }
.btn-primary:hover { background: var(--club-ink-hover); border-color: var(--club-ink-hover); color: var(--club-gold); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--page); }

.input, select.input, textarea.input {
  width: 100%; padding: 9px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface-raised);
  font-size: 13.5px; color: var(--text-primary); font-family: inherit;
}
.input:focus, select.input:focus, textarea.input:focus { outline: 2px solid var(--brand-light); border-color: var(--brand); }
.field { margin-bottom: 14px; }
.field label { display:block; font-size: 12.5px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }

.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.search-box { position: relative; min-width: 240px; }
.search-box input { padding-left: 32px; }
.search-box .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }

table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th {
  text-align: left; padding: 10px 12px; color: var(--text-muted);
  font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em;
  border-bottom: 1px solid var(--border-strong); white-space: nowrap;
}
.data-table td { padding: 12px; border-bottom: 1px solid var(--border-strong); vertical-align: middle; }
.data-table tbody tr { cursor: pointer; }
.data-table tbody tr:hover { background: var(--page); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700;
}
.badge-good { background: var(--good-bg); color: var(--good); }
.badge-warning { background: var(--warning-bg); color: #8a5a00; }
.badge-serious { background: var(--serious-bg); color: #9a4321; }
.badge-critical { background: var(--critical-bg); color: var(--critical); }
.badge-neutral { background: var(--page); color: var(--text-secondary); border: 1px solid var(--border-strong); }

.empty-state { text-align:center; padding: 48px 20px; color: var(--text-muted); }
.pagination { display:flex; align-items:center; justify-content:flex-end; gap:8px; margin-top:14px; }
.pagination .page-info { color: var(--text-muted); font-size: 12.5px; margin-right: 8px; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(11,11,11,0.35);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal { background: var(--surface-raised); border-radius: var(--radius-lg); width: 480px; max-width: 92vw; max-height: 86vh; overflow-y: auto; box-shadow: var(--shadow-md); }
.modal-head { display:flex; align-items:center; justify-content:space-between; padding: 18px 20px; border-bottom: 1px solid var(--border-strong); }
.modal-head h3 { margin: 0; font-size: 15px; }
.modal-body { padding: 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border-strong); display:flex; justify-content:flex-end; gap:10px; }

.toast-stack { position: fixed; bottom: 20px; right: 20px; display:flex; flex-direction:column; gap:8px; z-index: 100; }
.toast { background: var(--text-primary); color: #fff; padding: 11px 16px; border-radius: var(--radius-sm); font-size: 13px; box-shadow: var(--shadow-md); }
.toast.error { background: var(--critical); }
.toast.success { background: var(--good); }

.tabs { display:flex; gap: 4px; border-bottom: 1px solid var(--border-strong); margin-bottom: 18px; }
.tab { padding: 10px 4px; margin-right: 20px; font-weight: 600; color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; }
.tab.active { color: var(--text-primary); border-color: var(--club-gold); border-bottom-width: 3px; }

.login-screen { min-height: 100vh; display:flex; align-items:center; justify-content:center; background: linear-gradient(160deg, #14120d, #262319 65%, #b6912a); }
.login-card { width: 380px; background: var(--surface-raised); border-radius: var(--radius-lg); padding: 32px; box-shadow: var(--shadow-md); }
.login-card .mark { width: 44px; height: 44px; border-radius: 50%; background: var(--club-ink); color: var(--club-gold); display:flex; align-items:center; justify-content:center; font-weight:800; font-size:18px; margin-bottom: 14px; }
.login-card h2 { margin: 0 0 4px; font-size: 20px; }
.login-card p.sub { margin: 0 0 22px; color: var(--text-muted); font-size: 13px; }
.login-error { background: var(--critical-bg); color: var(--critical); padding: 10px 12px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 14px; }

.section-title { font-size: 20px; font-weight: 800; margin: 0 0 4px; padding-left: 12px; border-left: 4px solid var(--club-gold); }
.section-sub { color: var(--text-muted); font-size: 13px; margin: 0 0 20px; }

.kv-list { display:grid; grid-template-columns: 140px 1fr; row-gap: 10px; column-gap: 10px; font-size: 13.5px; }
.kv-list dt { color: var(--text-muted); }
.kv-list dd { margin: 0; font-weight: 600; }

/* ---------- charts ---------- */
.chart-wrap { position: relative; }
.chart-tooltip {
  position: fixed; pointer-events: none; background: var(--text-primary); color: #fff;
  padding: 7px 10px; border-radius: 6px; font-size: 12px; z-index: 60; transform: translate(-50%, -110%);
  white-space: nowrap; box-shadow: var(--shadow-md); opacity: 0; transition: opacity .1s ease;
}
.chart-legend { display:flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; font-size: 12px; color: var(--text-secondary); }
.chart-legend .item { display:flex; align-items:center; gap:6px; }
.chart-legend .swatch { width: 10px; height: 10px; border-radius: 3px; }

.menu-toggle { display: none; }
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
  .sidebar.open { transform: translateX(0); }
  .sidebar { position: fixed; top: 0; left: 0; height: 100vh; z-index: 1000; overflow-y: auto; }
  .menu-toggle { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; margin-right: 10px; background: transparent; border: none; font-size: 24px; cursor: pointer; }
  .sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 999; }
  .sidebar-backdrop.open { display: block; }
  .main { margin-left: 0; }
}
