:root {
  --primary: #6b46c1;
  --primary-dark: #553c9a;
  --primary-light: #9f7aea;
  --accent: #ed64a6;
  --bg: #f7f7fb;
  --card: #ffffff;
  --text: #1a202c;
  --text-muted: #718096;
  --border: #e2e8f0;
  --success: #38a169;
  --warning: #d97706;
  --danger: #e53e3e;
  --radius: 10px;
  --shadow: 0 2px 8px rgba(107,70,193,0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

/* ── Шапка ── */
.header {
  background: var(--primary);
  color: #fff;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-logo {
  font-size: 1.3rem;
  font-weight: 700;
  text-decoration: none;
  color: #fff;
  letter-spacing: 0.5px;
}
.header-logo span { color: var(--accent); }
.header-nav { display: flex; align-items: center; gap: 16px; }
.header-nav a { color: rgba(255,255,255,0.88); text-decoration: none; font-size: 0.9rem; }
.header-nav a:hover { color: #fff; }
.btn-header {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff;
  padding: 6px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  text-decoration: none;
  transition: background 0.2s;
}
.btn-header:hover { background: rgba(255,255,255,0.25); }

/* ── Контент ── */
.container { max-width: 1100px; margin: 0 auto; padding: 32px 24px; }
.page-title { font-size: 1.8rem; font-weight: 700; margin-bottom: 8px; color: var(--primary); }
.page-subtitle { color: var(--text-muted); margin-bottom: 28px; }

/* ── Карточки соревнований ── */
.competitions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}
.comp-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: box-shadow 0.2s, transform 0.2s;
  text-decoration: none;
  color: inherit;
}
.comp-card:hover { box-shadow: 0 6px 20px rgba(107,70,193,0.15); transform: translateY(-2px); }
.comp-card-name { font-size: 1.05rem; font-weight: 600; color: var(--primary-dark); }
.comp-card-meta { display: flex; flex-wrap: wrap; gap: 8px; }
.meta-item {
  display: flex; align-items: center; gap: 4px;
  font-size: 0.82rem; color: var(--text-muted);
}
.meta-item svg { width: 14px; height: 14px; flex-shrink: 0; }
.comp-card-categories { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  background: #ede9fe; color: var(--primary);
  border-radius: 12px; padding: 2px 10px;
  font-size: 0.75rem; font-weight: 500;
}
.tag.status-active { background: #dcfce7; color: var(--success); }
.tag.status-closed { background: #fee2e2; color: var(--danger); }
.comp-card-deadline { font-size: 0.8rem; color: var(--warning); font-weight: 500; }

/* ── Кнопки ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 20px; border-radius: 8px; border: none;
  cursor: pointer; font-size: 0.9rem; font-weight: 500;
  text-decoration: none; transition: all 0.2s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #2f855a; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c53030; }
.btn-outline { background: transparent; border: 1.5px solid var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-sm { padding: 6px 14px; font-size: 0.82rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Форма ── */
.form-card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); border: 1px solid var(--border);
  padding: 32px; max-width: 520px; margin: 0 auto;
}
.form-title { font-size: 1.4rem; font-weight: 700; margin-bottom: 24px; color: var(--primary); }
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 0.88rem; font-weight: 500; margin-bottom: 6px; color: var(--text); }
.form-control {
  width: 100%; padding: 10px 14px; border: 1.5px solid var(--border);
  border-radius: 8px; font-size: 0.9rem; color: var(--text);
  background: #fff; transition: border-color 0.2s;
  font-family: inherit;
}
.form-control:focus { outline: none; border-color: var(--primary-light); }
.form-control.error { border-color: var(--danger); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-hint { font-size: 0.78rem; color: var(--text-muted); margin-top: 4px; }

/* ── Алерты ── */
.alert {
  padding: 12px 16px; border-radius: 8px;
  margin-bottom: 16px; font-size: 0.88rem;
}
.alert-error { background: #fff5f5; border: 1px solid #feb2b2; color: var(--danger); }
.alert-success { background: #f0fff4; border: 1px solid #9ae6b4; color: var(--success); }
.alert-info { background: #ebf8ff; border: 1px solid #90cdf4; color: #2b6cb0; }

/* ── Таблица ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th {
  background: var(--primary); color: #fff;
  padding: 10px 14px; text-align: left; font-weight: 500;
}
td { padding: 10px 14px; border-bottom: 1px solid var(--border); }
tr:hover td { background: #f8f5ff; }
.badge {
  display: inline-block; padding: 3px 10px;
  border-radius: 10px; font-size: 0.75rem; font-weight: 600;
}
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-approved { background: #dcfce7; color: #166534; }
.badge-rejected { background: #fee2e2; color: #991b1b; }

/* ── Детали соревнования ── */
.comp-detail { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); }
.comp-detail-header { background: var(--primary); color: #fff; padding: 28px 32px; border-radius: var(--radius) var(--radius) 0 0; }
.comp-detail-header h1 { font-size: 1.6rem; margin-bottom: 8px; }
.comp-detail-body { padding: 28px 32px; }
.comp-info-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 20px; margin-bottom: 24px; }
.comp-info-item label { font-size: 0.78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; display: block; margin-bottom: 4px; }
.comp-info-item p { font-weight: 500; }

/* ── Список спортсменов в заявке ── */
.athletes-list { border: 1.5px solid var(--border); border-radius: 8px; overflow: hidden; }
.athlete-row {
  display: grid; grid-template-columns: 1fr 1fr auto auto auto auto 40px;
  gap: 8px; align-items: center;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.athlete-row:last-child { border-bottom: none; }
.athlete-row.header { background: #f8f5ff; font-weight: 600; font-size: 0.78rem; color: var(--text-muted); }
.athlete-row input, .athlete-row select {
  border: 1px solid var(--border); border-radius: 6px;
  padding: 6px 8px; font-size: 0.82rem; width: 100%;
  font-family: inherit;
}
.athlete-row input:focus, .athlete-row select:focus { outline: none; border-color: var(--primary-light); }
.btn-remove {
  background: none; border: none; cursor: pointer;
  color: var(--danger); padding: 4px; border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
}
.btn-remove:hover { background: #fff5f5; }

/* ── Панель организатора — сайдбар ── */
.admin-layout { display: flex; min-height: calc(100vh - 60px); }
.admin-sidebar {
  width: 220px; flex-shrink: 0;
  background: var(--primary-dark); color: #fff; padding: 24px 0;
}
.admin-sidebar-title { padding: 0 20px 16px; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.8px; color: rgba(255,255,255,0.5); }
.admin-sidebar a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px; color: rgba(255,255,255,0.8);
  text-decoration: none; font-size: 0.88rem;
  transition: background 0.15s;
}
.admin-sidebar a:hover, .admin-sidebar a.active { background: rgba(255,255,255,0.1); color: #fff; }
.admin-content { flex: 1; padding: 32px; overflow-x: auto; }

/* ── Статистика ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); border: 1px solid var(--border);
  padding: 20px; text-align: center;
}
.stat-card .num { font-size: 2rem; font-weight: 700; color: var(--primary); }
.stat-card .label { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }

/* ── Пустое состояние ── */
.empty-state {
  text-align: center; padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state svg { width: 64px; height: 64px; opacity: 0.3; margin-bottom: 16px; }
.empty-state p { font-size: 1rem; }

/* ── Модальное окно ── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.5); z-index: 200;
  align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff; border-radius: var(--radius);
  padding: 28px; max-width: 600px; width: 90%;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-title { font-size: 1.2rem; font-weight: 700; color: var(--primary); }
.modal-close { background: none; border: none; cursor: pointer; font-size: 1.4rem; color: var(--text-muted); line-height: 1; }

/* ── Auth layout (вход/регистрация) ── */
.auth-layout {
  display: flex; min-height: 100vh;
}
.auth-left {
  flex: 1; background: linear-gradient(135deg, #6b46c1 0%, #9f7aea 50%, #ed64a6 100%);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 48px; color: #fff; position: relative; overflow: hidden;
}
.auth-left::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(circle at 30% 70%, rgba(255,255,255,0.1) 0%, transparent 60%);
}
.auth-left-logo { font-size: 2rem; font-weight: 700; letter-spacing: 1px; z-index: 1; margin-bottom: 8px; }
.auth-left-logo span { color: rgba(255,255,255,0.7); }
.auth-left-slogan { font-size: 1rem; opacity: 0.85; text-align: center; max-width: 320px; line-height: 1.6; z-index: 1; margin-bottom: 40px; }
.auth-left svg { z-index: 1; max-width: 300px; opacity: 0.9; }
.auth-right {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 48px 40px; background: var(--bg);
}
.auth-form { width: 100%; max-width: 400px; }
.auth-form h1 { font-size: 1.6rem; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.auth-form .subtitle { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 28px; }
.auth-form .subtitle a { color: var(--primary); font-weight: 500; text-decoration: none; }
.input-icon-wrap {
  position: relative;
}
.input-icon-wrap .form-control { padding-right: 42px; }
.input-icon-wrap .input-icon {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; color: var(--text-muted);
  padding: 4px; display: flex; align-items: center;
}
.auth-form .btn-primary { width: 100%; padding: 13px; font-size: 1rem; margin-top: 4px; }
.auth-form .auth-links {
  margin-top: 20px; text-align: center; font-size: 0.88rem; color: var(--text-muted);
  display: flex; flex-direction: column; gap: 8px;
}
.auth-form .auth-links a { color: var(--primary); font-weight: 500; text-decoration: none; }

@media (max-width: 768px) {
  .auth-left { display: none; }
  .auth-right { padding: 24px 20px; }
}

/* ── Toggle switch ── */
.toggle-switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0; cursor: pointer;
  background: #cbd5e0; border-radius: 24px; transition: background 0.25s;
}
.toggle-slider::before {
  content: ''; position: absolute; left: 3px; top: 3px;
  width: 18px; height: 18px; background: #fff; border-radius: 50%;
  transition: transform 0.25s; box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle-switch input:checked + .toggle-slider { background: var(--primary); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }
.toggle-label {
  display: inline-flex; align-items: center; gap: 10px;
  cursor: pointer; font-size: 0.9rem; font-weight: 500; user-select: none;
}

/* ── Гамбургер-меню (скрыт на десктопе) ── */
.sidebar-toggle {
  display: none;
  background: rgba(255,255,255,0.15); border: none; color: #fff;
  font-size: 1.3rem; cursor: pointer; padding: 6px 10px;
  border-radius: 6px; line-height: 1; margin-right: 12px; flex-shrink: 0;
}
.sidebar-backdrop { display: none; }

/* ── Touch-friendly: hover → active ── */
@media (hover: none) {
  .comp-card:hover { box-shadow: var(--shadow); transform: none; }
  .comp-card:active { transform: scale(0.98); }
  .btn-primary:active { background: var(--primary-dark); }
  .btn-outline:active { background: var(--primary); color: #fff; }
  tr:hover td { background: inherit; }
  .admin-sidebar a:hover { background: none; }
  .admin-sidebar a:active { background: rgba(255,255,255,0.15); }
}

/* ── Адаптив: планшеты (768px) ── */
@media (max-width: 768px) {
  .form-row { grid-template-columns: 1fr; }
  .admin-layout { flex-direction: column; }
  .athlete-row { grid-template-columns: 1fr 1fr; }
  .athlete-row.header { display: none; }
  .competitions-grid { grid-template-columns: 1fr; }

  /* Хедер */
  .header { padding: 0 12px; }
  .header-logo { font-size: 1.1rem; }
  .header-nav { gap: 8px; }
  .header-nav a { font-size: 0.82rem; }

  /* Гамбургер-сайдбар */
  .sidebar-toggle { display: block; }
  .admin-sidebar {
    position: fixed; top: 60px; left: 0; bottom: 0;
    width: 260px; z-index: 120;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    overflow-y: auto;
    padding: 24px 0;
  }
  .admin-sidebar.open { transform: translateX(0); }
  .sidebar-backdrop.open {
    display: block; position: fixed; inset: 0;
    top: 60px; background: rgba(0,0,0,0.4); z-index: 110;
  }

  /* Контент */
  .container { padding: 20px 16px; }
  .page-title { font-size: 1.4rem; }
  .admin-content { padding: 16px; }

  /* Кнопки — увеличенные для тач */
  .btn { padding: 11px 20px; }
  .btn-sm { padding: 8px 14px; font-size: 0.84rem; }
  .btn-header { padding: 8px 14px; }
  .btn-remove { padding: 8px; min-width: 40px; min-height: 40px; }
  .admin-sidebar a { padding: 14px 20px; font-size: 0.95rem; }
}

/* ── Адаптив: большие телефоны (600px) ── */
@media (max-width: 600px) {
  /* Модалки — sheet снизу */
  .modal-overlay { align-items: flex-end; }
  .modal {
    width: 100%; max-width: 100%;
    max-height: 92vh; padding: 20px 16px;
    border-radius: 16px 16px 0 0;
    margin: 0;
  }
  .modal-header { margin-bottom: 14px; }
  .modal-close { font-size: 1.8rem; padding: 8px; }

  /* Таблицы → карточки */
  .table-wrap table thead { display: none; }
  .table-wrap table tbody tr {
    display: block;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
    background: var(--card);
  }
  .table-wrap table tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.85rem;
  }
  .table-wrap table tbody td:last-child { border-bottom: none; }
  .table-wrap table tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.78rem;
    flex-shrink: 0;
    margin-right: 12px;
  }
  .table-wrap table tbody td[data-label=""]::before { display: none; }
  .table-wrap table tbody td[data-label=""] { justify-content: flex-end; border-bottom: none; padding-top: 8px; }
  .table-wrap table tbody td.check-col { display: none; }

  /* Статистика */
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 14px 10px; }
  .stat-card .num { font-size: 1.5rem; }
  .stat-card .label { font-size: 0.72rem; }

  /* Экспорт-бар */
  .export-groups { flex-wrap: wrap; }
  .export-sep { display: none; }
}

/* ── Адаптив: маленькие телефоны (480px) ── */
@media (max-width: 480px) {
  .header { height: 52px; padding: 0 10px; }
  .header-logo { font-size: 1rem; }
  .header-nav { gap: 6px; }
  .header-nav a { font-size: 0.78rem; }
  .btn-header { padding: 8px 12px; font-size: 0.78rem; }

  .container { padding: 16px 12px; }
  .page-title { font-size: 1.2rem; }
  .admin-content { padding: 12px; }
  .admin-sidebar { top: 52px; }

  .form-card { padding: 20px 16px; }
  .comp-detail-header { padding: 20px 16px; }
  .comp-detail-header h1 { font-size: 1.2rem; }
  .comp-detail-body { padding: 20px 16px; }

  .competitions-grid { gap: 12px; }
  .comp-card { padding: 14px; }
  .comp-card-name { font-size: 0.95rem; }
}

/* ── Адаптив: совсем маленькие (380px) ── */
@media (max-width: 380px) {
  .stats-grid { grid-template-columns: 1fr; }
}

/* ── Загрузка ── */
.spinner {
  display: inline-block; width: 20px; height: 20px;
  border: 2px solid rgba(107,70,193,0.2);
  border-top-color: var(--primary);
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading { text-align: center; padding: 40px; color: var(--text-muted); }
