@font-face {
  font-family: "MagistralTT";
  src: url("/static/fonts/ofont_ru_Magistral_C.ttf") format("truetype");
  font-weight: normal;
  font-style: normal;
}

:root {
  --red: #CD191E;
  --orange: #F58C1E;
  --burgundy: #730000;
  --blue: #2FC6F6;
  --blue-dark: #1E88C7;
  --bg: #EEF2F4;
  --panel: #FFFFFF;
  --line: #E2E7EA;
  --text: #1B2124;
  --text-dim: #7A868C;
  --sidebar-bg: #2A3744;
  --sidebar-text: #B9C6CF;
  --shadow: 0 2px 6px rgba(20,30,40,0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2 { font-family: "MagistralTT", -apple-system, sans-serif; margin: 0; letter-spacing: 0.01em; }
a { color: inherit; text-decoration: none; }

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

.sidebar {
  width: 220px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  flex-shrink: 0;
}
.sidebar__brand { display: flex; align-items: center; gap: 12px; padding: 0 6px 26px; }
.sidebar__mark {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--red), var(--burgundy));
  color: #fff; font-family: "MagistralTT", sans-serif; font-weight: bold; font-size: 17px;
  border-radius: 10px;
  flex-shrink: 0;
}
.sidebar__name { font-size: 13.5px; font-weight: 600; color: #fff; line-height: 1.3; }
.sidebar__name em { font-style: normal; color: var(--orange); }

.sidebar__nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar__nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--sidebar-text);
}
.sidebar__nav a .nav-ico { width: 18px; text-align: center; opacity: 0.8; }
.sidebar__nav a:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar__nav a.is-active { background: var(--blue-dark); color: #fff; }

.sidebar__logout {
  font-size: 13px;
  color: var(--sidebar-text);
  padding: 10px 12px;
  border-top: 1px solid rgba(255,255,255,0.08);
  margin-top: 10px;
}
.sidebar__logout:hover { color: #fff; }

.club-switch { padding: 14px 12px 4px; border-top: 1px solid rgba(255,255,255,0.08); margin-top: 6px; }
.club-switch__label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.04em; color: rgba(255,255,255,0.35); margin-bottom: 8px; padding: 0 2px; }
.club-switch__item { display: block; padding: 8px 10px; border-radius: 7px; font-size: 13.5px; color: var(--sidebar-text); margin-bottom: 2px; }
.club-switch__item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.club-switch__item.is-active { background: rgba(245,140,30,0.16); color: var(--orange); font-weight: 600; }

.content { flex: 1; padding: 30px 36px 60px; max-width: 1180px; }
.content-plain { min-height: 100vh; }

/* ── Page head ── */
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.page-head h1 { font-size: 23px; }
.back-link { color: var(--text-dim); font-size: 13.5px; font-weight: 500; }
.back-link:hover { color: var(--blue-dark); }

.btn-ghost {
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 500;
}
.btn-ghost:hover { border-color: var(--blue-dark); color: var(--blue-dark); }

/* ── Period tabs ── */
.period-tabs { display: flex; gap: 6px; margin-bottom: 22px; }
.period-tabs a {
  padding: 7px 16px;
  border-radius: 7px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-dim);
  background: var(--panel);
  border: 1px solid var(--line);
}
.period-tabs a.is-active { background: var(--blue-dark); color: #fff; border-color: var(--blue-dark); }

/* ── Custom period picker ── */
.period-custom {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
  padding: 10px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-dim);
}
.period-custom.is-active { border-color: var(--blue-dark); }
.period-custom label { display: flex; align-items: center; gap: 6px; }
.period-custom input[type="date"] {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
}
.period-custom button { margin-left: auto; }

/* ── Stat grid ── */
.stat-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 30px; }
.stat-grid--compact { grid-template-columns: repeat(6, 1fr); margin-bottom: 24px; }
.stat-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  box-shadow: var(--shadow);
}
.stat-card--primary { border-top: 3px solid var(--blue-dark); }
.stat-card--warn { border-top: 3px solid var(--orange); }
.stat-card__value { font-size: 26px; font-weight: 700; font-family: "MagistralTT", sans-serif; }
.stat-card__label { font-size: 11.5px; color: var(--text-dim); margin-top: 4px; font-weight: 500; }

/* ── Section blocks (Обзор) ── */
.section-row { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.section-block {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.section-block__head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.section-block__head h2 { font-size: 15px; }
.section-block__head a { font-size: 12.5px; color: var(--blue-dark); font-weight: 600; }

.section-block--nav { display: flex; flex-direction: column; gap: 12px; background: none; border: none; box-shadow: none; padding: 0; }
.nav-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 4px;
}
.nav-card:hover { border-color: var(--blue-dark); }
.nav-card__title { font-size: 15px; font-weight: 700; }
.nav-card__hint { font-size: 12.5px; color: var(--text-dim); }

.section-title { font-size: 16px; margin: 26px 0 12px; }

/* ── Tables ── */
.mini-table, .data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.mini-table th, .data-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-dim);
  font-weight: 600;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}
.mini-table td, .data-table td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
}
.data-table {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow);
  border-spacing: 0;
}
.data-table th { background: #F7F9FA; }
.data-table tbody tr { cursor: pointer; transition: background .12s; }
.data-table tbody tr:hover { background: #F2F8FC; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table__strong { font-weight: 600; }
.data-table__muted { color: var(--text-dim); }

.mini-table tbody tr { cursor: pointer; }
.mini-table tbody tr:hover { background: #F2F8FC; }
.mini-table tbody tr:last-child td { border-bottom: none; }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  background: #EEF1F3;
  color: var(--text-dim);
}
.badge--success { background: #E4F6EA; color: #1E8A44; }
.badge--info { background: #E3F3FC; color: var(--blue-dark); }
.badge--warn { background: #FDEFDE; color: #B9670C; }

/* ── Conversion bar ── */
.conv-cell { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.conv-bar { width: 56px; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.conv-bar__fill { display: block; height: 100%; background: linear-gradient(90deg, var(--blue), var(--blue-dark)); border-radius: 3px; }

/* ── Search ── */
.search-bar { display: flex; gap: 10px; margin-bottom: 22px; }
.search-bar input {
  flex: 1;
  padding: 11px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
}
.search-bar input:focus { outline: none; border-color: var(--blue-dark); }
.search-bar button {
  padding: 11px 22px;
  border: none;
  border-radius: 8px;
  background: var(--blue-dark);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}
.search-bar button:hover { filter: brightness(1.08); }

.empty-state { color: var(--text-dim); padding: 20px 0; font-size: 14px; }

.search-bar--compact { max-width: 480px; margin-bottom: 18px; }

/* ── Entity header (client/trainer/request) ── */
.entity-header {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px 22px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}
.entity-header__avatar {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), var(--blue-dark));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 19px; font-weight: 700;
  flex-shrink: 0;
}
.entity-header h1 { font-size: 20px; }
.entity-header__phone { color: var(--text-dim); font-size: 13px; margin-top: 3px; }
.entity-header__stats { display: flex; gap: 20px; margin-left: auto; }
.entity-header__stats div { text-align: center; font-size: 11.5px; color: var(--text-dim); }
.entity-header__stats span { display: block; font-size: 19px; font-weight: 700; color: var(--text); }

/* ── Detail grid (request card) ── */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px 20px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
}
.detail-grid div span {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 600;
  margin-bottom: 3px;
}

/* ── Worklog (timeline) ── */
.worklog {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px 22px;
  box-shadow: var(--shadow);
}
.worklog-item { display: flex; gap: 14px; padding: 10px 0; position: relative; }
.worklog-item::before {
  content: "";
  position: absolute;
  left: 5px; top: 26px; bottom: -4px;
  width: 2px;
  background: var(--line);
}
.worklog-item:last-child::before { display: none; }
.worklog-item__dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--line);
  margin-top: 4px;
  flex-shrink: 0;
  z-index: 1;
}
.worklog-item.is-done .worklog-item__dot { background: var(--blue-dark); }
.worklog-item__label { font-weight: 600; font-size: 14px; color: var(--text-dim); }
.worklog-item.is-done .worklog-item__label { color: var(--text); }
.worklog-item__comment { font-size: 13px; color: var(--text-dim); margin-top: 2px; font-style: italic; }
.worklog-item__meta { font-size: 12.5px; color: var(--text-dim); margin-top: 2px; }

/* ── Login ── */
.login-screen { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--sidebar-bg); }
.login-card {
  background: var(--panel);
  border-radius: 14px;
  padding: 40px 36px;
  width: 100%;
  max-width: 340px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0,0,0,0.3);
}
.login-card__mark {
  width: 52px; height: 52px; margin: 0 auto 16px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--red), var(--burgundy));
  color: #fff; font-family: "MagistralTT", sans-serif; font-size: 22px; font-weight: bold;
  border-radius: 12px;
}
.login-card h1 { font-size: 19px; color: var(--text); }
.login-card__sub { color: var(--text-dim); font-size: 13px; margin: 6px 0 24px; }
.login-form { display: flex; flex-direction: column; gap: 14px; text-align: left; }
.login-form label span { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 6px; font-weight: 500; }
.login-form input {
  width: 100%; padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
}
.login-form input:focus { outline: none; border-color: var(--blue-dark); }
.login-form button {
  margin-top: 6px;
  padding: 11px;
  border: none;
  border-radius: 8px;
  background: var(--blue-dark);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}
.login-form button:hover { filter: brightness(1.08); }
.login-error { color: var(--red); font-size: 13px; margin: 0; }

/* ── Users page ── */
.user-form { display: flex; flex-direction: column; gap: 14px; }
.user-form__row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.user-form label span { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 5px; font-weight: 500; }
.user-form input[type="text"] {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  font-size: 13.5px;
}
.user-form input[type="text"]:focus { outline: none; border-color: var(--blue-dark); }
.user-form__checkbox { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text-dim); }
.btn-primary {
  align-self: flex-start;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  background: var(--blue-dark);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  font-size: 13.5px;
}
.btn-primary:hover { filter: brightness(1.08); }
.table-action { color: var(--blue-dark); font-size: 12.5px; font-weight: 600; }
.table-action:hover { text-decoration: underline; }

@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; align-items: center; padding: 12px 16px; }
  .sidebar__brand { padding: 0; }
  .sidebar__nav { flex-direction: row; }
  .sidebar__logout { margin: 0; border: none; padding: 8px 12px; }
  .content { padding: 20px; }
  .stat-grid, .stat-grid--compact { grid-template-columns: repeat(2, 1fr); }
  .section-row { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr 1fr; }
}
