/* ===== FONTS ===== */
@font-face {
  font-family: 'Manrope';
  src: url('/static/fonts/Manrope.ttf') format('truetype');
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

/* ===== LIGHT THEME — высокий контраст и акцент ===== */
:root {
  --bg: #f0f3f7;
  --surface: #ffffff;
  --surface-2: #f5f7fa;
  --surface-3: #e8edf3;
  --border: #d8e0ea;
  --border-strong: #b8c4d4;
  --text: #0a1020;
  --text-2: #2c3648;
  --muted: #6b7589;

  --primary: #0055FF;
  --primary-h: #0044cc;
  --primary-soft: #e0ecff;
  --primary-strong: #003db8;

  --accent: #FF3D00;
  --accent-soft: #ffe5dc;

  --ok: #16a34a;
  --ok-strong: #15803d;
  --ok-soft: #dcfce7;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --danger: #dc2626;
  --danger-strong: #991b1b;
  --danger-soft: #fee2e2;
  --running: #0284c7;
  --running-soft: #e0f2fe;

  --gold: #d4a017;
  --gold-bg: #fef3c7;
  --silver: #4b5563;
  --silver-bg: #e5e7eb;
  --bronze: #b45309;
  --bronze-bg: #fed7aa;

  --font: 'Manrope', system-ui, -apple-system, sans-serif;

  --shadow-xs: 0 1px 2px rgba(10,16,32,0.05);
  --shadow-sm: 0 2px 4px rgba(10,16,32,0.06), 0 1px 2px rgba(10,16,32,0.04);
  --shadow: 0 4px 12px rgba(10,16,32,0.08), 0 1px 3px rgba(10,16,32,0.05);
  --shadow-lg: 0 12px 32px rgba(10,16,32,0.12);
  --shadow-primary: 0 4px 16px rgba(0,85,255,0.25);
  --shadow-accent: 0 4px 16px rgba(255,61,0,0.25);

  --radius: 8px;
  --radius-lg: 12px;
}

* { box-sizing: border-box }
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01";
}

.container { max-width: 1280px; margin: 0 auto; padding: 0 24px }
.muted { color: var(--muted) }
.small { font-size: 13px }

/* ===== HEADER ===== */
.top {
  background: var(--surface);
  border-bottom: 2px solid var(--text);
  margin-bottom: 32px;
  position: sticky; top: 0; z-index: 10;
  box-shadow: var(--shadow-sm);
}
.top .container {
  display: flex; align-items: center; gap: 24px;
  padding: 16px 24px;
}
.brand {
  font-weight: 800;
  font-size: 18px;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand::before {
  content: '';
  width: 10px; height: 10px;
  background: var(--accent);
  border-radius: 2px;
  display: inline-block;
}
.brand .muted {
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.02em;
}
nav { display: flex; gap: 2px; flex-wrap: wrap; margin-left: auto }
nav a {
  padding: 10px 16px;
  color: var(--text-2);
  text-decoration: none;
  border-radius: 6px;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.01em;
  transition: all 0.15s;
  position: relative;
}
nav a:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

/* ===== HEADINGS ===== */
main { padding-bottom: 80px }
h1, h2, h3 {
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1.1;
}
h1 {
  font-size: 40px;
  margin: 0 0 12px;
  text-transform: uppercase;
}
h2 {
  font-size: 24px;
  margin: 32px 0 16px;
  text-transform: uppercase;
  letter-spacing: -0.02em;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
h2::before {
  content: '';
  width: 6px; height: 24px;
  background: var(--primary);
  border-radius: 2px;
}
h3 { font-size: 17px; margin: 0 0 8px; letter-spacing: -0.02em }
p { margin: 0 0 12px; color: var(--text-2) }
hr { border: none; border-top: 2px solid var(--border); margin: 32px 0 }

/* ===== FORMS ===== */
.form, .form-vert { display: grid; gap: 14px; margin: 14px 0 }
.form {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  align-items: end;
}
.form > button,
.form > .btn {
  grid-column: -2 / -1;
  align-self: end;
  height: 46px;
  margin: 0;
}
.form-vert { grid-template-columns: 1fr; max-width: 600px }
label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 11px;
  color: var(--text-2);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
label.big { font-size: 12px }
input, select, textarea,
button, .btn {
  height: 46px;
  box-sizing: border-box;
  border-radius: var(--radius);
  font: 15px/1 var(--font);
  font-weight: 600;
  border: 1.5px solid var(--border-strong);
  transition: all 0.15s;
}
input, select, textarea {
  padding: 0 14px;
  background: var(--surface);
  color: var(--text);
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
  vertical-align: middle;
}
textarea { height: auto; padding: 12px 14px; line-height: 1.4 }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}

button, .btn {
  padding: 0 20px;
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
  letter-spacing: -0.01em;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}
button:hover, .btn:hover {
  background: var(--text);
  color: #fff;
  border-color: var(--text);
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-primary);
}
.btn-primary:hover {
  background: var(--primary-strong);
  border-color: var(--primary-strong);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0,85,255,0.35);
}

/* Маленькие inline-кнопки внутри ячеек таблицы */
table .btn,
table button {
  height: 32px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 700;
}

.btn-danger {
  height: 32px;
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
  padding: 0 12px;
  font-size: 12px;
}
.btn-danger:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

/* Иконки-кнопки удаления внутри таблиц (× символ) */
table .btn-danger {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 50%;
  font-size: 16px;
  line-height: 1;
}
.actions { display: flex; gap: 10px; margin-top: 8px }
fieldset {
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin: 0 0 14px;
  background: var(--surface-2);
}
legend {
  padding: 0 10px;
  color: var(--primary);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ===== TABLES ===== */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  font-size: 14px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
th, td {
  padding: 13px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
th {
  color: var(--muted);
  font-weight: 800;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: var(--surface-3);
  border-bottom: 2px solid var(--border-strong);
}
tbody tr { transition: background 0.1s }
tbody tr:hover { background: var(--primary-soft) }
tbody tr:last-child td { border-bottom: none }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700 }
td.center { text-align: center }

/* ===== STANDINGS — самый заметный экран ===== */
.standings {
  font-size: 15px;
  box-shadow: var(--shadow);
}
.standings .place {
  width: 72px;
  text-align: center;
  font-weight: 900;
  font-size: 22px;
  color: var(--muted);
  letter-spacing: -0.04em;
}
.standings tbody tr:nth-child(1) {
  background: linear-gradient(90deg, var(--gold-bg) 0%, transparent 30%);
}
.standings tbody tr:nth-child(1) .place {
  color: var(--gold);
  font-size: 26px;
}
.standings tbody tr:nth-child(2) .place { color: var(--silver) }
.standings tbody tr:nth-child(3) .place { color: var(--bronze) }
.standings .total {
  color: var(--primary);
  font-size: 17px;
  font-weight: 900;
  letter-spacing: -0.02em;
}
.standings .row-done { background: rgba(22,163,74,0.05) }
.standings .row-dnf { opacity: 0.45 }
.standings .dnf {
  color: var(--danger);
  font-weight: 800;
  background: var(--danger-soft);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 12px;
}

/* ===== CARDS / GRID ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  margin: 18px 0;
  box-shadow: var(--shadow-xs);
  transition: box-shadow 0.15s;
}
.card:hover { box-shadow: var(--shadow-sm) }
.card-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; margin-bottom: 10px;
}
.grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}
.grid-2 {
  display: grid; gap: 18px;
  grid-template-columns: 1fr 1fr;
  margin: 18px 0;
}
@media (max-width: 768px) {
  .grid-2 { grid-template-columns: 1fr }
  h1 { font-size: 30px }
}

details summary {
  cursor: pointer; padding: 10px 0;
  font-weight: 800;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary);
}
.empty {
  padding: 56px;
  text-align: center;
  color: var(--muted);
  background: var(--surface);
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg);
}

/* ===== THEORY ===== */
.theory-total {
  color: var(--primary);
  font-weight: 900;
  font-size: 18px;
  letter-spacing: -0.02em;
}
.q-row {
  display: flex; gap: 8px; align-items: center;
  padding: 12px 0;
  border-bottom: 1px dashed var(--border);
  flex-wrap: wrap;
}
.q-row:last-child { border: none }
.q-label {
  min-width: 110px;
  font-weight: 800;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--text-2);
}
.opt {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px;
  background: var(--surface);
  border: 2px solid var(--border-strong);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.12s;
  font-weight: 700;
  font-size: 14px;
}
.opt:hover { border-color: var(--primary); background: var(--primary-soft) }
.opt input { width: auto; margin: 0 }
.opt:has(input:checked) {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-primary);
}
.opt-none { background: transparent }
.opt-none:has(input:checked) {
  background: var(--text);
  border-color: var(--text);
}
.opt-task {
  padding: 16px 22px;
  font-size: 15px;
  border-color: var(--ok);
}
.opt-task:has(input:checked) {
  background: var(--ok);
  border-color: var(--ok);
  box-shadow: 0 4px 16px rgba(22,163,74,0.3);
}

/* ===== STAGE / STOPWATCH — большой акцент ===== */
.stopwatch {
  margin-top: 18px;
  padding: 24px;
  background: linear-gradient(135deg, var(--text) 0%, #1a2238 100%);
  color: #fff;
  border-radius: var(--radius-lg);
  text-align: center;
  box-shadow: var(--shadow-lg);
}
.stopwatch h3 {
  color: var(--accent);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 8px;
  font-weight: 800;
}
.sw-display {
  font-size: 64px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: #fff;
  margin: 8px 0 16px;
  letter-spacing: -0.04em;
  line-height: 1;
}
.sw-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap }
.sw-actions button {
  background: rgba(255,255,255,0.12);
  color: #fff;
  border-color: rgba(255,255,255,0.2);
  font-weight: 700;
}
.sw-actions button:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  transform: translateY(-1px);
}

.totals { font-size: 16px }
.totals td { padding: 14px 16px; font-weight: 700 }
.totals .grand {
  border-top: 3px solid var(--primary);
  background: var(--primary-soft);
}
.totals .grand td {
  padding: 16px;
  font-size: 22px;
  font-weight: 900;
  color: var(--primary);
  letter-spacing: -0.02em;
}

.penalty-add { grid-template-columns: 2fr 1fr 1.5fr auto }
.penalties tbody tr { vertical-align: middle }

/* ===== BADGES ===== */
.badge {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 14px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--surface-3);
  color: var(--text-2);
  border: 1px solid var(--border-strong);
}
.badge.run  { background: var(--running-soft); color: var(--running); border-color: var(--running) }
.badge.done { background: var(--ok-soft); color: var(--ok-strong); border-color: var(--ok) }
.badge.dnf  { background: var(--danger-soft); color: var(--danger); border-color: var(--danger) }
