@import url("/static/css/tokens.css");

/* ---------- base ---------- */
[hidden] { display: none !important; }
html { color-scheme: dark; }
body { min-height: 100vh; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 18px; height: 18px; flex: 0 0 auto; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 22px; height: 22px; }

.container { width: 100%; max-width: 1280px; margin: 0 auto; padding: 0 16px; }
.container-narrow { width: 100%; max-width: 896px; margin: 0 auto; padding: 0 24px; }
.page { padding-top: 32px; padding-bottom: 64px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 8px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.muted { color: var(--text-secondary); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  height: 56px;
  background: var(--bg-base);
  border-bottom: 1px solid var(--border);
}
.site-header .container { height: 100%; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text-primary); text-decoration: none; font-weight: 700; font-size: 15px; white-space: nowrap; }
.brand .icon { color: var(--accent); }
.main-nav { display: none; align-items: center; gap: 4px; }
.main-nav a { color: var(--text-secondary); text-decoration: none; font-size: 14px; padding: 8px 12px; border-radius: 8px; transition: background-color 150ms ease-out, color 150ms ease-out; }
.main-nav a:hover { background: var(--bg-hover); color: var(--text-primary); }
.main-nav a.active { color: var(--text-primary); background: var(--bg-input); }
.header-user { display: flex; align-items: center; gap: 8px; }
.header-user .name { display: none; color: var(--text-secondary); font-size: 13px; }
.avatar { width: 32px; height: 32px; border-radius: 999px; background: var(--bg-input); color: var(--text-secondary); display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex: 0 0 auto; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

@media (min-width: 768px) {
  .main-nav { display: flex; }
  .header-user .name { display: inline; }
}

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--border); margin-top: 48px; padding: 24px 0 88px; color: var(--text-muted); font-size: 12px; }
.site-footer .container { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.site-footer a { color: var(--text-secondary); }

/* ---------- mobile nav ---------- */
.mobile-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: calc(64px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  display: flex; align-items: stretch;
}
.mobile-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--text-muted); text-decoration: none; font-size: 10px; }
.mobile-nav a.active { color: var(--accent); }
@media (min-width: 768px) { .mobile-nav { display: none; } .site-footer { padding-bottom: 24px; } }

/* ---------- buttons ---------- */
.btn-accent, .btn-secondary, .btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 8px; border: 1px solid transparent; padding: 10px 16px;
  font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: none;
  transition: background-color 150ms ease-out, border-color 150ms ease-out, color 150ms ease-out;
}
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--bg-input); color: var(--text-primary); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--border-strong); }
.btn-ghost { background: transparent; color: var(--text-muted); padding: 8px; }
.btn-ghost:hover { color: var(--accent); }
.btn-sm { padding: 6px 10px; font-size: 13px; }
button:disabled, .btn-accent:disabled, .btn-secondary:disabled { opacity: 0.5; cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
/* Подписи полей и показателей: --text-muted #525252 давал 2.2–2.4:1 на
   тёмных поверхностях админки (D2-04). --text-secondary — 6.9–7.6:1. */
label, .label { font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-secondary); }
/* width:100% применялся и к чекбоксам: на /admin/seasons оба чекбокса
   подтверждения были 452×13px и разъезжалась колонка «Действия» (D2-13).
   Типы checkbox/radio исключены из общего правила. */
input:not([type="checkbox"]):not([type="radio"]), select, textarea {
  width: 100%; background: var(--bg-input); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; font-size: 14px;
}
input[type="checkbox"], input[type="radio"] {
  width: auto; margin: 0 6px 0 0; vertical-align: middle; accent-color: var(--accent);
}
textarea { min-height: 96px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--text-muted); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; }

/* ---------- alerts / toast ---------- */
.alert { background: rgba(231,76,60,.1); border: 1px solid rgba(231,76,60,.4); color: var(--accent); border-radius: 8px; padding: 10px 12px; font-size: 13px; }
.alert-info { background: var(--bg-surface); border-color: var(--border); color: var(--text-secondary); }
.toast-root { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--accent); color: #fff; font-size: 14px; font-weight: 500; border-radius: 999px; padding: 10px 18px; box-shadow: 0 8px 24px rgba(0,0,0,.35); animation: toast-in 200ms ease-out; }
.toast.is-hiding { opacity: 0; transition: opacity 200ms ease-out; }
@keyframes toast-in { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ---------- auth ---------- */
.auth-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { width: 100%; max-width: 420px; background: var(--bg-surface); border: 1px solid var(--border); border-radius: 12px; padding: 32px; }
.auth-card h1 { font-size: 24px; font-weight: 700; margin-bottom: 8px; }
.auth-card .muted { margin-top: 0; }

/* ---------- voting ---------- */
.vote-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.vote-head h1 { font-size: 20px; font-weight: 700; }
@media (min-width: 768px) { .vote-head h1 { font-size: 24px; } }
.vote-head p { margin: 4px 0 0; }
.progress-sticky { position: sticky; top: 56px; z-index: 30; background: var(--bg-base); border-bottom: 1px solid var(--border); padding: 10px 0; }
.progress-track { height: 6px; background: var(--bg-input); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width 300ms ease-out; }
.category-section { padding-bottom: 32px; margin-bottom: 32px; border-bottom: 1px solid var(--border); scroll-margin-top: 132px; }
.category-section:last-child { border-bottom: 0; }
.category-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.category-head h2 { font-size: 18px; font-weight: 700; }
.category-desc { margin: 0 0 16px; color: var(--text-secondary); font-size: 13px; }
.nominee-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 640px) { .nominee-grid { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (min-width: 1024px) { .nominee-grid { grid-template-columns: repeat(3, minmax(0,1fr)); } }
@media (min-width: 1280px) { .nominee-grid { grid-template-columns: repeat(4, minmax(0,1fr)); } }
.nominee-card {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 20px 16px 16px; transition: border-color 150ms ease-out, opacity 200ms ease-out;
}
.nominee-card:hover { border-color: var(--border-strong); }
.nominee-avatar { width: 72px; height: 72px; border-radius: 999px; background: var(--bg-input); color: var(--text-secondary); display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 700; margin-bottom: 12px; overflow: hidden; }
.nominee-avatar img { width: 100%; height: 100%; object-fit: cover; }
.nominee-name { font-size: 16px; font-weight: 600; }
.nominee-dept { margin: 2px 0 16px; color: var(--text-muted); font-size: 12px; }
.btn-vote { margin-top: auto; width: 100%; background: var(--bg-input); color: var(--text-primary); border: 1px solid var(--border); border-radius: 8px; padding: 10px; font-weight: 600; cursor: pointer; transition: background-color 150ms ease-out, border-color 150ms ease-out; }
.btn-vote:hover { border-color: var(--border-strong); background: var(--bg-hover); }
.nominee-card.is-selected { border-color: var(--accent); }
.nominee-card.is-selected .nominee-avatar { box-shadow: 0 0 0 2px var(--accent); }
.nominee-card.is-selected .btn-vote { background: var(--bg-input); color: var(--text-secondary); cursor: default; }
.nominee-card.is-selected .btn-vote .icon { color: var(--accent); }
.category-section.is-locked .nominee-card:not(.is-selected) { opacity: .45; pointer-events: none; }
.category-section.is-closed .btn-vote { opacity: .5; pointer-events: none; }
.banner { display: flex; align-items: center; gap: 10px; background: var(--bg-surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin-bottom: 24px; color: var(--text-secondary); font-size: 13px; }

/* ---------- cards / panels ---------- */
.panel { background: var(--bg-surface); border: 1px solid var(--border); border-radius: 12px; }
.panel-pad { padding: 20px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.stat { background: var(--bg-surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
.stat .value { font-size: 28px; font-weight: 700; }
.stat .label { margin-top: 4px; }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; border-radius: 4px; padding: 2px 8px; font-size: 11px; font-weight: 600; border: 1px solid transparent; }
.badge-employee { background: rgba(163,163,163,.1); color: #A3A3A3; border-color: rgba(163,163,163,.35); }
.badge-jury { background: rgba(231,76,60,.1); color: var(--accent); border-color: rgba(231,76,60,.35); }
.badge-admin { background: rgba(231,76,60,.16); color: var(--accent); border-color: rgba(231,76,60,.5); }
.badge-muted { background: var(--bg-input); color: var(--text-secondary); border-color: var(--border); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead { background: var(--bg-elevated); }
/* Заголовки таблиц: --text-muted #525252 на --bg-elevated #141414 — 2.36:1
   (D2-04). --text-secondary — 7.3:1. */
th { text-align: left; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-secondary); padding: 10px 14px; white-space: nowrap; }
td { padding: 10px 14px; border-bottom: 1px solid var(--border); }
tbody tr:nth-child(even) { background: var(--bg-row-alt); }
tbody tr:hover { background: var(--bg-hover); box-shadow: inset 2px 0 0 var(--accent); }
tbody tr:last-child td { border-bottom: 0; }
.actions { display: flex; gap: 4px; justify-content: flex-end; }

/* ---------- modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 70; }
.modal { width: 100%; max-width: 440px; background: var(--bg-surface); border: 1px solid var(--border); border-radius: 12px; padding: 24px; box-shadow: 0 12px 40px rgba(0,0,0,.5); animation: modal-in 160ms ease-out; }
.modal h2 { font-size: 18px; margin-bottom: 8px; }
.modal .actions { justify-content: flex-end; margin-top: 20px; }
@keyframes modal-in { from { opacity: 0; transform: scale(.98); } to { opacity: 1; transform: scale(1); } }

/* ---------- results ---------- */
.result-row { display: grid; grid-template-columns: 1fr; gap: 6px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.result-row:last-child { border-bottom: 0; }
.result-line { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.result-track { height: 8px; background: var(--bg-input); border-radius: 999px; overflow: hidden; }
.result-fill { height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width 450ms cubic-bezier(.22,1,.36,1); }
.result-row.is-winner .result-line { font-weight: 700; }

/* ---------- screen ---------- */
.screen-body { height: 100vh; overflow: hidden; }
.screen { height: 100vh; display: flex; flex-direction: column; padding: 3vh 3vw; gap: 3vh; }
.screen-title { font-size: clamp(24px, 4vw, 72px); font-weight: 700; text-align: center; }
.screen-grid { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 3vw; min-height: 0; }
.screen-block { background: var(--bg-surface); border: 1px solid var(--border); border-radius: 16px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1vh; }
.screen-block .value { font-size: clamp(24px, 5vw, 72px); font-weight: 700; }
.screen-block .label { font-size: clamp(11px, 1.2vw, 18px); }
.screen-winners { flex: 1; overflow: hidden; display: grid; gap: 2vh; }
.screen-offline { position: fixed; bottom: 16px; right: 16px; font-size: 12px; color: var(--text-muted); }

/* ---------- misc ---------- */
.empty { text-align: center; padding: 48px 16px; color: var(--text-secondary); }
.empty .icon { width: 32px; height: 32px; margin-bottom: 12px; color: var(--text-muted); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--text-secondary); text-decoration: none; font-size: 14px; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--text-primary); border-bottom-color: var(--accent); }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; font-size: 13px; }
.skeleton { background: var(--bg-input); border-radius: 8px; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .6; } }

.page h1 { font-size: 20px; font-weight: 700; margin-bottom: 20px; }
@media (min-width: 768px) { .page h1 { font-size: 24px; } }
.panel + .panel { margin-top: 16px; }
.panel h2 { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.panel p { margin: 0; }
.panel p + p { margin-top: 8px; }
.rules-list { margin: 0; padding-left: 20px; }
.rules-list li { margin: 2px 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
