/* Админка мероприятия. Ноль зависимостей и сборки: один CSS, один JS —
   чтобы стенд поднимался тем же деплоем, что и бэкенд. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-alt: #f1f3f6;
  --border: #e2e5ea;
  --text: #16181d;
  --text-muted: #6b7280;
  --accent: #2f6fed;
  --accent-contrast: #ffffff;
  --danger: #d64545;
  --success: #1f9254;
  --warning: #b45309;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 8px 24px rgba(16, 24, 40, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --surface: #1b1e24;
    --surface-alt: #23262d;
    --border: #2e323a;
    --text: #e8eaed;
    --text-muted: #9aa1ac;
    --accent: #6f9bff;
    --accent-contrast: #0f1115;
    --danger: #f87171;
    --success: #4ade80;
    --warning: #fbbf24;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}

* {
  box-sizing: border-box;
}

/* Обязательно с !important: у .gate и .layout ниже задан display: grid,
   а правило класса перебивает браузерное [hidden] { display: none }.
   Без этого экран входа не прятался и панель уезжала под него. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    'Helvetica Neue', Arial, sans-serif;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9em;
  background: var(--surface-alt);
  padding: 1px 5px;
  border-radius: 5px;
}

/* --- Вход --- */

.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.gate__card {
  width: min(380px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  display: grid;
  gap: 14px;
}

.gate__title {
  margin: 0;
  font-size: 20px;
}

.gate__hint,
.gate__error {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

.gate__error {
  color: var(--danger);
}

/* --- Каркас --- */

.layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  font-weight: 600;
  font-size: 16px;
}

.nav {
  display: grid;
  gap: 2px;
}

.nav__item {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  text-align: left;
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
}

.nav__item:hover {
  background: var(--surface-alt);
  color: var(--text);
}

.nav__item.is-active {
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 500;
}

.sidebar__footer {
  margin-top: auto;
}

.content {
  padding: 28px 32px 64px;
  max-width: 1100px;
}

/* --- Типовые блоки --- */

.page-title {
  margin: 0 0 4px;
  font-size: 22px;
}

.page-subtitle {
  margin: 0 0 22px;
  color: var(--text-muted);
  font-size: 14px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
}

.card__title {
  margin: 0 0 14px;
  font-size: 16px;
  font-weight: 600;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.stat__value {
  font-size: 26px;
  font-weight: 600;
}

.stat__label {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 2px;
}

.grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.field {
  display: grid;
  gap: 6px;
  font-size: 14px;
}

.field--compact .field__label {
  font-size: 12px;
}

.field__label {
  color: var(--text-muted);
  font-size: 13px;
}

.field__hint {
  color: var(--text-muted);
  font-size: 12px;
}

.input,
select.input,
textarea.input {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

textarea.input {
  min-height: 90px;
  resize: vertical;
}

.input:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  padding: 7px 0;
}

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 9px 14px;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
}

.btn:hover {
  background: var(--surface-alt);
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}

.btn--primary:hover {
  filter: brightness(1.05);
  background: var(--accent);
}

.btn--danger {
  color: var(--danger);
}

.btn--ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn--sm {
  padding: 5px 9px;
  font-size: 13px;
}

.btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.row--end {
  justify-content: flex-end;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 13px;
  white-space: nowrap;
}

tbody tr:hover {
  background: var(--surface-alt);
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--surface-alt);
  color: var(--text-muted);
  white-space: nowrap;
}

.badge--new {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--accent);
}

.badge--answered {
  background: color-mix(in srgb, var(--success) 18%, transparent);
  color: var(--success);
}

.badge--rejected {
  background: color-mix(in srgb, var(--danger) 18%, transparent);
  color: var(--danger);
}

.badge--progress {
  background: color-mix(in srgb, var(--warning) 20%, transparent);
  color: var(--warning);
}

.muted {
  color: var(--text-muted);
}

.empty {
  color: var(--text-muted);
  padding: 18px 0;
  text-align: center;
}

.result {
  background: var(--surface-alt);
  border-radius: 8px;
  padding: 12px;
  font-size: 13px;
  white-space: pre-wrap;
  margin-top: 12px;
}

/* --- Тост --- */

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 12px 16px;
  box-shadow: var(--shadow);
  max-width: 380px;
  z-index: 10;
}

.toast--error {
  border-left-color: var(--danger);
}

.toast--success {
  border-left-color: var(--success);
}

@media (max-width: 820px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .nav {
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    overflow-x: auto;
  }

  .content {
    padding: 20px 16px 48px;
  }
}
