/* assets/app.css — Ketsetzis Race Timing shared UI (single file, cache-friendly) */
:root {
  --brand-bg: #07111f;
  --brand-panel: #111c2f;
  --brand-panel-2: #17243a;
  --brand-accent: #38bdf8;
  --brand-accent-dark: #0284c7;
  --brand-text: #f8fafc;
  --brand-muted: #94a3b8;
  --brand-border: rgba(148, 163, 184, 0.18);
  --brand-success: #22c55e;
  --brand-warning: #f59e0b;
  --brand-danger: #ef4444;
  --brand-gold: #fbbf24;
  --brand-silver: #cbd5e1;
  --brand-bronze: #d97706;
  --header-bg: #ffffff;
  --header-text: #0f172a;
  --header-muted: #475569;
  --header-height: 68px;
  --radius: 12px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
  --font: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  --touch-min: 44px;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: #1e293b;
  background: #f1f5f9;
  line-height: 1.45;
}

img { max-width: 100%; height: auto; display: block; }

a { color: var(--brand-accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Header / brand — light background for black logo */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--header-bg);
  border-bottom: 1px solid #e2e8f0;
  box-shadow: 0 2px 12px rgba(15, 23, 42, 0.08);
}

.site-header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 8px max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left));
  min-height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--header-text);
  text-decoration: none;
  min-width: 0;
}

.brand:hover { text-decoration: none; opacity: 0.92; }

.logo-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border-radius: 10px;
  padding: 4px 10px;
  border: 1px solid #e2e8f0;
  line-height: 0;
}

.logo-wrap img {
  height: 40px;
  width: auto;
  max-width: min(200px, 42vw);
  object-fit: contain;
}

.logo-wrap--large {
  padding: 10px 16px;
  border-radius: 14px;
  margin: 0 auto 14px;
}

.logo-wrap--large img {
  height: 52px;
  max-width: min(260px, 80vw);
}

.brand-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--header-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  flex: 1 1 auto;
}

.race-controls {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-bottom: 14px;
}

.race-control-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.race-control-card--active {
  border-color: #86efac;
  background: linear-gradient(135deg, #f0fdf4, #fff);
}

.race-control-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.race-control-head h3 {
  margin: 0;
  font-size: 0.95rem;
  color: #0f172a;
}

.race-status {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #64748b;
}

.race-status-active {
  background: #dcfce7;
  color: #166534;
}

.race-control-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.race-control-card .race-timer {
  font-family: ui-monospace, monospace;
  font-size: 1.35rem;
  font-weight: 800;
  color: #0f172a;
  text-align: center;
  padding: 8px;
  background: #f8fafc;
  border-radius: 10px;
}

.race-athletes-count {
  margin: 0 0 10px;
  font-size: 0.82rem;
  color: #64748b;
  font-weight: 600;
}

.distanse-warning {
  margin: 0 0 12px;
  padding: 10px 14px;
  border-radius: 10px;
  background: #fff7ed;
  border: 1px solid #fdba74;
  color: #9a3412;
  font-size: 0.88rem;
  font-weight: 600;
}

.race-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
}

.athletes-panel .race-filter-bar {
  margin: 0;
}

.live-stats + .race-filter-bar,
.live-hero + .live-stats {
  margin-bottom: 0;
}

.page-dark .race-filter-bar {
  background: var(--brand-panel-2);
  border-color: var(--brand-border);
}

.race-filter-btn {
  appearance: none;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #334155;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  touch-action: manipulation;
}

.race-filter-btn:hover {
  border-color: #94a3b8;
  background: #f1f5f9;
}

.race-filter-btn.active {
  background: #1e40af;
  border-color: #1e40af;
  color: #fff;
}

.race-filter-btn[data-race-filter="10km"].active {
  background: #1d4ed8;
  border-color: #1d4ed8;
}

.race-filter-btn[data-race-filter="4.1km"].active {
  background: #c2410c;
  border-color: #c2410c;
}

.page-dark .race-filter-btn {
  background: var(--brand-panel);
  border-color: var(--brand-border);
  color: var(--brand-text);
}

.page-dark .race-filter-btn:hover {
  background: rgba(255, 255, 255, 0.06);
}

.page-dark .race-filter-btn.active {
  color: #fff;
}

.page-wrap > .race-filter-bar {
  margin-bottom: 18px;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.page-dark.page-wrap > .race-filter-bar,
.page-dark .page-wrap > .race-filter-bar {
  background: var(--brand-panel);
  border-color: var(--brand-border);
  box-shadow: none;
}

.race-controls-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.race-control-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid #dbeafe;
  border-radius: 12px;
  background: #f8fafc;
}

.race-control-label {
  font-size: 0.82rem;
  font-weight: 800;
  color: #1e3a8a;
  white-space: nowrap;
}

.race-timer {
  font-family: ui-monospace, monospace;
  font-size: 0.9rem;
  font-weight: 800;
  color: #0f172a;
  min-width: 72px;
  text-align: center;
}

.btn-sm {
  padding: 6px 10px !important;
  font-size: 0.8rem !important;
}

.user-pill {
  font-size: 0.82rem;
  color: var(--header-muted);
  padding: 6px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  white-space: nowrap;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--touch-min);
  padding: 9px 14px;
  border: none;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  color: #fff;
  background: var(--brand-accent-dark);
  transition: filter 0.15s ease, transform 0.15s ease;
  touch-action: manipulation;
}

.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-success { background: #15803d; }
.btn-danger { background: #b91c1c; }
.btn-secondary { background: #475569; }
.btn-warning { background: #c2410c; }
.btn-ghost {
  background: #f8fafc;
  color: var(--header-text);
  border: 1px solid #cbd5e1;
}

/* Layout */
.page-wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px max(16px, env(safe-area-inset-right)) 24px max(16px, env(safe-area-inset-left));
}
.page-dark { background: linear-gradient(180deg, #0b1f3a 0%, var(--brand-bg) 35%); color: var(--brand-text); min-height: 100vh; }
.page-dark .page-wrap { max-width: 1100px; padding: 20px 16px 24px; min-height: calc(100vh - var(--header-height, 64px)); display: flex; flex-direction: column; }

.live-site-footer {
  margin-top: auto;
  padding: 28px 16px 12px;
  text-align: center;
  border-top: 1px solid var(--brand-border);
}

.live-site-footer p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--brand-muted);
  letter-spacing: 0.02em;
}

.live-site-footer a {
  color: #7dd3fc;
  text-decoration: none;
  font-weight: 600;
}

.live-site-footer a:hover {
  color: #bae6fd;
  text-decoration: underline;
}

.card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.card-dark {
  background: var(--brand-panel);
  border: 1px solid var(--brand-border);
  color: var(--brand-text);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  margin-bottom: 14px;
}

.toolbar-divider {
  width: 1px;
  height: 24px;
  background: #cbd5e1;
  flex-shrink: 0;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-scroll .live-table {
  margin: 0;
  box-shadow: none;
  min-width: 640px;
}

/* Athletes table panel */
.athletes-panel {
  overflow: hidden;
  margin-top: 4px;
}

.athletes-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
}

.athletes-panel-head h2 {
  margin: 0;
  font-size: 1rem;
  color: #0f172a;
}

.athletes-panel-count {
  font-size: 0.85rem;
  color: #64748b;
  font-weight: 600;
  background: #fff;
  border: 1px solid #e2e8f0;
  padding: 4px 10px;
  border-radius: 999px;
}

.athletes-table-scroll {
  max-height: min(68vh, 680px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.athletes-table-scroll .data-table {
  margin: 0;
  box-shadow: none;
  border-radius: 0;
  table-layout: fixed;
  width: 100%;
  min-width: 940px;
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: #fff;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  font-size: 0.88rem;
}

.data-table th, .data-table td {
  border-bottom: 1px solid #e2e8f0;
  padding: 9px 10px;
  text-align: left;
  vertical-align: middle;
}

.data-table th {
  background: #1e3a8a;
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 2;
  cursor: pointer;
  user-select: none;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.data-table th span {
  opacity: 0.7;
  font-size: 0.7rem;
}

.data-table tbody tr:nth-child(even) td { background: #fafbfc; }
.data-table tbody tr:hover td { background: #f1f5f9 !important; }

.data-table .col-rank { display: none; width: 0; }
.data-table .col-bib { width: 72px; text-align: center; }
.data-table .col-name { width: 20%; }
.data-table .col-club-h,
.data-table .col-club { width: 22%; }
.data-table .col-distanse { width: 118px; text-align: center; }
.data-table .col-email { width: 14%; }
.data-table .col-gender { width: 96px; text-align: center; }
.data-table .col-time { width: 110px; text-align: center; }
.data-table .col-actions { width: 148px; text-align: center; }

.col-club, .col-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 0;
}

.col-email {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 0;
  font-size: 0.82rem;
  color: #475569;
}

.bib-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  padding: 4px 8px;
  border-radius: 8px;
  background: #eff6ff;
  color: #1d4ed8;
  font-weight: 800;
  font-size: 0.9rem;
}

.gender-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

.gender-m { background: #dcfce7; color: #166534; }
.gender-f { background: #ffe4e6; color: #be123c; }

.race-badge {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 4px 10px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 800;
  white-space: nowrap;
  line-height: 1.2;
  min-width: 72px;
}

.race-badge-km {
  font-size: 0.82rem;
  font-weight: 800;
}

.race-badge-name {
  font-size: 0.68rem;
  font-weight: 600;
  opacity: 0.9;
}

.race-badge-10km {
  background: #dbeafe;
  color: #1e40af;
  border: 1px solid #93c5fd;
}

.race-badge-4 {
  background: #ffedd5;
  color: #c2410c;
  border: 1px solid #fdba74;
}

.race-badge-none {
  background: #f1f5f9;
  color: #94a3b8;
  border: 1px solid #e2e8f0;
  min-width: auto;
  padding: 4px 12px;
}

.bib-race-hint {
  font-size: 0.9rem;
  font-weight: 700;
  color: #475569;
}

.bib-race-hint-active { color: #166534; }
.bib-race-hint-idle { color: #b45309; }
.bib-race-hint-warn { color: #b91c1c; }

.tiles-race-section {
  margin-bottom: 16px;
}

.tiles-race-title {
  margin: 0 0 8px;
  color: #c2410c;
  font-size: 0.95rem;
}

.tiles-empty {
  color: #2e7d32;
  font-weight: 700;
  padding: 8px 0;
  margin: 0;
}

.time-badge {
  display: inline-block;
  font-family: ui-monospace, monospace;
  font-weight: 800;
  font-size: 0.85rem;
  color: #0f172a;
  background: #ecfdf5;
  border: 1px solid #86efac;
  padding: 3px 8px;
  border-radius: 6px;
}

.time-pending { color: #94a3b8; }

.row-actions {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
  transition: filter 0.15s ease, transform 0.15s ease;
  touch-action: manipulation;
}

.icon-btn:hover { filter: brightness(1.05); }
.icon-btn:active { transform: scale(0.95); }

.icon-btn-time { background: #dbeafe; color: #1d4ed8; }
.icon-btn-edit { background: #ffedd5; color: #c2410c; }
.icon-btn-delete { background: #fee2e2; color: #b91c1c; }
.icon-btn-mail { background: #e0e7ff; color: #4338ca; }

.highlight-m td { background: #f8fffb !important; }
.highlight-f td { background: #fffafb !important; }
.finished td { color: #14532d; }
.finished .col-name { font-weight: 600; }

.stats-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 0 14px 14px;
}

.stat-chip {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px 12px;
  text-align: center;
  font-weight: 700;
}

.stat-chip .label { display: block; font-size: 0.78rem; color: #64748b; font-weight: 600; }
.stat-chip .value { font-size: 1.35rem; margin-top: 2px; }
.stat-chip.blue .value { color: #2563eb; }
.stat-chip.green .value { color: #15803d; }
.stat-chip.orange .value { color: #c2410c; }

/* Forms */
input, select, button, textarea {
  font: inherit;
}

.input, input[type="text"], input[type="number"], input[type="password"], input[type="search"], select {
  padding: 10px 12px;
  min-height: var(--touch-min);
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #fff;
  font-size: 16px;
  max-width: 100%;
}

.input:focus, input:focus, select:focus {
  outline: none;
  border-color: var(--brand-accent);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
}

.file-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  cursor: pointer;
}

/* Admin timing */
.timing-panel {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  background: linear-gradient(135deg, #eff6ff, #f8fafc);
  border: 2px solid #93c5fd;
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

.timing-panel label { font-weight: 700; font-size: 1rem; }

#bibInput {
  font-size: 1.35rem;
  width: min(140px, 100%);
  text-align: center;
  font-weight: 800;
}

#recordBtn { font-size: 1rem; padding: 12px 18px; }

#timer-display {
  margin-left: auto;
  font-family: ui-monospace, monospace;
  font-size: 1.6rem;
  font-weight: 800;
  background: #0f172a;
  color: #fff;
  padding: 8px 16px;
  border-radius: 10px;
  min-width: 140px;
  text-align: center;
}

.tiles-wrap {
  display: none;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

.tiles-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.bib-tile {
  font-size: 1.15rem;
  font-weight: 800;
  width: 72px;
  height: 56px;
  min-width: var(--touch-min);
  min-height: var(--touch-min);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  cursor: pointer;
  border: 2px solid #cbd5e1;
  user-select: none;
  touch-action: manipulation;
}

.tile-m { background: #ecfdf5; color: #166534; border-color: #86efac; }
.tile-f { background: #fef2f2; color: #b91c1c; border-color: #fca5a5; }
.bib-tile:active { transform: scale(0.96); }

/* Modals */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(3px);
}

.modal-content {
  background: #fff;
  margin: max(6vh, env(safe-area-inset-top)) auto 20px;
  padding: 22px;
  border-radius: var(--radius);
  width: min(440px, 94vw);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}

.modal-content h3 {
  margin: 0 0 14px;
  padding-bottom: 10px;
  border-bottom: 2px solid #22c55e;
}

.import-result-modal {
  max-width: 640px;
  max-height: 85vh;
  overflow: auto;
}

.import-result-summary {
  margin-bottom: 14px;
}

.import-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.import-stat {
  text-align: center;
  padding: 10px 8px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
}

.import-stat-label {
  display: block;
  font-size: 0.72rem;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.import-stat-value {
  display: block;
  font-size: 1.25rem;
  font-weight: 800;
  color: #0f172a;
}

.import-stat--err { background: #fef2f2; border-color: #fecaca; }
.import-stat--err .import-stat-value { color: #b91c1c; }
.import-stat--warn { background: #fff7ed; border-color: #fed7aa; }
.import-stat--warn .import-stat-value { color: #c2410c; }

.import-result-section h4 {
  margin: 0 0 8px;
  font-size: 0.92rem;
}

.import-result-list {
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 220px;
  overflow: auto;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
}

.import-result-list li {
  padding: 8px 12px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.85rem;
  line-height: 1.45;
}

.import-result-list li:last-child {
  border-bottom: none;
}

.import-detail-reason {
  color: #64748b;
  font-size: 0.82rem;
}

.import-detail-more {
  color: #94a3b8;
  font-style: italic;
  text-align: center;
}

.user-guide-modal {
  max-width: 720px;
  width: min(720px, 94vw);
  max-height: 88vh;
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.user-guide-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid #e2e8f0;
  background: linear-gradient(135deg, #eff6ff 0%, #f8fafc 100%);
}

.user-guide-head h3 {
  margin: 0;
  font-size: 1.05rem;
  color: #1e3a8a;
  border: none;
  padding: 0;
}

.user-guide-close {
  appearance: none;
  border: none;
  background: #e2e8f0;
  color: #475569;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.user-guide-close:hover {
  background: #cbd5e1;
}

.user-guide-body {
  padding: 16px 18px;
  overflow-y: auto;
  flex: 1;
}

.user-guide-foot {
  padding: 12px 18px;
  border-top: 1px solid #e2e8f0;
  text-align: right;
  background: #f8fafc;
}

/* Athlete form modal */
.athlete-modal {
  backdrop-filter: blur(6px);
  background: rgba(15, 23, 42, 0.55);
}

.athlete-form-modal {
  width: min(560px, 94vw);
  max-width: 560px;
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(255, 255, 255, 0.65);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.22);
}

.athlete-form-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 20px;
  background: linear-gradient(135deg, #ecfdf5 0%, #f0fdf4 45%, #f8fafc 100%);
  border-bottom: 1px solid #d1fae5;
}

.athlete-form-modal--edit .athlete-form-head {
  background: linear-gradient(135deg, #eff6ff 0%, #f0f9ff 45%, #f8fafc 100%);
  border-bottom-color: #bfdbfe;
}

.athlete-form-brand {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  min-width: 0;
}

.athlete-form-icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  font-size: 1.35rem;
  border-radius: 12px;
  background: #fff;
  border: 1px solid #bbf7d0;
  box-shadow: 0 4px 14px rgba(34, 197, 94, 0.15);
}

.athlete-form-modal--edit .athlete-form-icon {
  border-color: #bfdbfe;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.12);
}

.athlete-form-head h3 {
  margin: 0;
  padding: 0;
  border: none;
  font-size: 1.12rem;
  font-weight: 800;
  color: #14532d;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.athlete-form-modal--edit .athlete-form-head h3 {
  color: #1e3a8a;
}

.athlete-form-sub {
  margin: 4px 0 0;
  font-size: 0.84rem;
  color: #64748b;
  line-height: 1.4;
}

.athlete-form-close {
  appearance: none;
  border: none;
  background: rgba(255, 255, 255, 0.85);
  color: #64748b;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  border: 1px solid #e2e8f0;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}

.athlete-form-close:hover {
  background: #fff;
  color: #0f172a;
}

.athlete-form-body {
  padding: 18px 20px 8px;
  background: #fff;
}

.athlete-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
}

.athlete-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.athlete-field--wide {
  grid-column: 1 / -1;
}

.athlete-field--bib {
  max-width: 180px;
}

.athlete-field label {
  font-size: 0.78rem;
  font-weight: 700;
  color: #475569;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.athlete-field .input {
  width: 100%;
  min-height: var(--touch-min);
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  font-size: 0.95rem;
  color: #0f172a;
  background: #f8fafc;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.athlete-field .input:hover {
  border-color: #94a3b8;
  background: #fff;
}

.athlete-field .input:focus {
  outline: none;
  border-color: #22c55e;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18);
}

.athlete-form-modal--edit .athlete-field .input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}

.athlete-field select.input {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2364748b' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}

.athlete-form-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px 18px;
  border-top: 1px solid #e2e8f0;
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
}

.athlete-form-save {
  min-width: 148px;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(21, 128, 61, 0.25);
}

@media (max-width: 520px) {
  .athlete-form-grid {
    grid-template-columns: 1fr;
  }

  .athlete-field--bib {
    max-width: none;
  }

  .athlete-form-foot {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .athlete-form-foot .btn {
    width: 100%;
    justify-content: center;
  }
}

.guide-section {
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid #f1f5f9;
}

.guide-section:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.guide-section h4 {
  margin: 0 0 8px;
  font-size: 0.95rem;
  color: #0f172a;
}

.guide-section p,
.guide-section li {
  margin: 0 0 6px;
  font-size: 0.88rem;
  line-height: 1.55;
  color: #475569;
}

.guide-section ol,
.guide-section ul {
  margin: 6px 0 0;
  padding-left: 1.25rem;
}

.guide-section code {
  background: #f1f5f9;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.82rem;
  color: #1e40af;
}

.guide-tip {
  background: #ecfdf5;
  border: 1px solid #86efac;
  border-radius: 8px;
  padding: 8px 12px;
  color: #166534 !important;
  font-size: 0.84rem !important;
}

.guide-section--warn {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 10px;
  padding: 12px 14px;
}

.guide-section--warn h4 {
  color: #9a3412;
}

.guide-flow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

.guide-flow span {
  background: #dbeafe;
  color: #1e40af;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.form-group {
  margin: 12px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.form-group label { font-weight: 600; flex: 1 1 120px; }
.form-group select, .form-group input { width: 200px; max-width: 100%; flex: 1 1 180px; }

/* Login */
.login-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px max(16px, env(safe-area-inset-right)) 24px max(16px, env(safe-area-inset-left));
  background: linear-gradient(180deg, #f8fafc 0%, #e2e8f0 100%);
  color: var(--header-text);
}

.login-shell { width: 100%; max-width: 420px; }

.login-brand {
  text-align: center;
  margin-bottom: 22px;
}

.login-brand img {
  height: 56px;
  width: auto;
  margin: 0 auto 14px;
}

.login-brand h1 {
  margin: 0;
  font-size: 1.35rem;
  color: var(--header-text);
}

.login-brand p {
  margin: 8px 0 0;
  color: var(--header-muted);
  font-size: 0.92rem;
}

.login-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.login-card label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.88rem;
  color: var(--header-muted);
}

.login-card input {
  width: 100%;
  margin-bottom: 14px;
  background: #fff;
  color: var(--header-text);
  border: 1px solid #cbd5e1;
}

.login-card .btn { width: 100%; margin-top: 4px; }

.login-links {
  margin-top: 16px;
  text-align: center;
  font-size: 0.9rem;
}

.login-links a { color: var(--brand-accent); }

.alert-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  padding: 10px 12px;
  border-radius: 10px;
  margin-bottom: 14px;
  font-size: 0.9rem;
}

/* Live page */
/* —— Adaptive theme (auto / light / dark) —— */
html[data-theme="light"] body.page-live {
  --brand-bg: #eef2f7;
  --brand-panel: #ffffff;
  --brand-panel-2: #f8fafc;
  --brand-accent: #0284c7;
  --brand-accent-dark: #0369a1;
  --brand-text: #0f172a;
  --brand-muted: #475569;
  --brand-border: rgba(15, 23, 42, 0.14);
  --live-page-bg: #eef2f7;
  --live-header-bg: #ffffff;
  --live-header-border: #cbd5e1;
  --live-text-muted: #475569;
  --live-rank-gold: #a16207;
  --live-rank-silver: #334155;
  --live-rank-bronze: #9a3412;
  --live-stat-finished: #166534;
  --live-stat-running: #c2410c;
  --live-time-color: #0369a1;
  --live-pill-live-color: #166534;
  --live-pill-live-bg: #dcfce7;
  --live-pill-live-border: #86efac;
  --live-pill-warn-color: #92400e;
  --live-pill-warn-bg: #fef3c7;
  --live-pill-warn-border: #fcd34d;
  --live-badge-run-color: #92400e;
  --live-badge-run-bg: #ffedd5;
  --live-table-stripe: rgba(15, 23, 42, 0.05);
  --live-accent-soft: rgba(2, 132, 199, 0.18);
  --live-search-clear-bg: #cbd5e1;
  --live-search-clear-color: #0f172a;
  --live-footer-link: #0369a1;
  --live-footer-muted: #475569;
  --live-shadow: none;
}

html[data-theme="dark"] body.page-live {
  --brand-muted: #c4d0df;
  --live-page-bg: #07111f;
  --live-header-bg: #0a1628;
  --live-header-border: rgba(148, 163, 184, 0.28);
  --live-text-muted: #c4d0df;
  --live-rank-gold: #fbbf24;
  --live-rank-silver: #e2e8f0;
  --live-rank-bronze: #fb923c;
  --live-stat-finished: #4ade80;
  --live-stat-running: #fbbf24;
  --live-time-color: #38bdf8;
  --live-pill-live-color: #bbf7d0;
  --live-pill-live-bg: rgba(34, 197, 94, 0.22);
  --live-pill-live-border: rgba(74, 222, 128, 0.5);
  --live-pill-warn-color: #fde68a;
  --live-pill-warn-bg: rgba(245, 158, 11, 0.22);
  --live-pill-warn-border: rgba(251, 191, 36, 0.5);
  --live-badge-run-color: #fde68a;
  --live-badge-run-bg: rgba(245, 158, 11, 0.24);
  --live-table-stripe: rgba(255, 255, 255, 0.05);
  --live-accent-soft: rgba(56, 189, 248, 0.22);
  --live-search-clear-bg: #334155;
  --live-search-clear-color: #f8fafc;
  --live-footer-link: #7dd3fc;
  --live-footer-muted: #c4d0df;
  --live-shadow: none;
}

@media (prefers-color-scheme: light) {
  html[data-theme="auto"] body.page-live {
    --brand-bg: #eef2f7;
    --brand-panel: #ffffff;
    --brand-panel-2: #f8fafc;
    --brand-accent: #0284c7;
    --brand-accent-dark: #0369a1;
    --brand-text: #0f172a;
    --brand-muted: #475569;
    --brand-border: rgba(15, 23, 42, 0.14);
    --live-page-bg: #eef2f7;
    --live-header-bg: #ffffff;
    --live-header-border: #cbd5e1;
    --live-text-muted: #475569;
    --live-rank-gold: #a16207;
    --live-rank-silver: #334155;
    --live-rank-bronze: #9a3412;
    --live-stat-finished: #166534;
    --live-stat-running: #c2410c;
    --live-time-color: #0369a1;
    --live-pill-live-color: #166534;
    --live-pill-live-bg: #dcfce7;
    --live-pill-live-border: #86efac;
    --live-pill-warn-color: #92400e;
    --live-pill-warn-bg: #fef3c7;
    --live-pill-warn-border: #fcd34d;
    --live-badge-run-color: #92400e;
    --live-badge-run-bg: #ffedd5;
    --live-table-stripe: rgba(15, 23, 42, 0.05);
    --live-accent-soft: rgba(2, 132, 199, 0.18);
    --live-search-clear-bg: #cbd5e1;
    --live-search-clear-color: #0f172a;
    --live-footer-link: #0369a1;
    --live-footer-muted: #475569;
    --live-shadow: none;
  }
}

@media (prefers-color-scheme: dark) {
  html[data-theme="auto"] body.page-live {
    --brand-muted: #c4d0df;
    --live-page-bg: #07111f;
    --live-header-bg: #0a1628;
    --live-header-border: rgba(148, 163, 184, 0.28);
    --live-text-muted: #c4d0df;
    --live-rank-gold: #fbbf24;
    --live-rank-silver: #e2e8f0;
    --live-rank-bronze: #fb923c;
    --live-stat-finished: #4ade80;
    --live-stat-running: #fbbf24;
    --live-time-color: #38bdf8;
    --live-pill-live-color: #bbf7d0;
    --live-pill-live-bg: rgba(34, 197, 94, 0.22);
    --live-pill-live-border: rgba(74, 222, 128, 0.5);
    --live-pill-warn-color: #fde68a;
    --live-pill-warn-bg: rgba(245, 158, 11, 0.22);
    --live-pill-warn-border: rgba(251, 191, 36, 0.5);
    --live-badge-run-color: #fde68a;
    --live-badge-run-bg: rgba(245, 158, 11, 0.24);
    --live-table-stripe: rgba(255, 255, 255, 0.05);
    --live-accent-soft: rgba(56, 189, 248, 0.22);
    --live-search-clear-bg: #334155;
    --live-search-clear-color: #f8fafc;
    --live-footer-link: #7dd3fc;
    --live-footer-muted: #c4d0df;
    --live-shadow: none;
  }
}

body.page-live {
  --live-gap-xs: 8px;
  --live-gap-sm: 12px;
  --live-gap-md: 16px;
  --live-gap-lg: 20px;
  --live-gap-xl: 24px;
  --live-toolbar-pad: clamp(12px, 2.8vw, 18px);
  --live-page-pad-x: clamp(12px, 3.2vw, 20px);
  --live-radius: 14px;
  background: var(--live-page-bg, #07111f);
  color: var(--brand-text);
  min-height: 100vh;
}

body.page-live h1,
body.page-live h2,
body.page-live h3,
body.page-live .live-table td,
body.page-live .podium-name,
body.page-live .bib-chip {
  color: var(--brand-text);
}

body.page-live .live-table th {
  color: var(--live-text-muted, var(--brand-muted));
  font-weight: 700;
}

body.page-live .live-stat .label,
body.page-live .live-hero-lead,
body.page-live .live-hint,
body.page-live .live-progress-label,
body.page-live .live-stat-sub,
body.page-live .updated-note,
body.page-live .race-live-stats,
body.page-live .empty-state,
body.page-live .live-search-empty {
  color: var(--live-text-muted, var(--brand-muted));
}

body.page-live .empty-state-sub {
  opacity: 1;
  color: var(--live-text-muted, var(--brand-muted));
}

body.page-live .rank-1 { color: var(--live-rank-gold, var(--brand-gold)); }
body.page-live .rank-2 { color: var(--live-rank-silver, var(--brand-silver)); }
body.page-live .rank-3 { color: var(--live-rank-bronze, var(--brand-bronze)); }

body.page-live .live-stat--finished .value { color: var(--live-stat-finished, #22c55e); }
body.page-live .live-stat--running .value { color: var(--live-stat-running, #f59e0b); }
body.page-live .live-stat--total .value { color: var(--brand-accent); }

body.page-live .time-cell,
body.page-live .podium-time {
  color: var(--live-time-color, var(--brand-accent));
}

body.page-live .live-site-footer p {
  color: var(--live-footer-muted, var(--brand-muted));
}

body.page-live .live-progress-label strong {
  color: var(--live-time-color, var(--brand-accent));
}

body.page-live .live-hero-kicker {
  color: var(--brand-accent-dark, var(--brand-accent));
}

body.page-live .live-section-head h2 {
  color: var(--brand-text);
}

body.page-live .race-live-block {
  content-visibility: auto;
  contain-intrinsic-size: auto 720px;
  contain: layout style paint;
}

body.page-live .page-wrap {
  max-width: 1100px;
  padding: var(--live-gap-lg) var(--live-page-pad-x) var(--live-gap-xl);
  padding-left: max(var(--live-page-pad-x), env(safe-area-inset-left));
  padding-right: max(var(--live-page-pad-x), env(safe-area-inset-right));
  min-height: calc(100vh - var(--header-height, 64px));
  display: flex;
  flex-direction: column;
  gap: var(--live-gap-md);
}

body.page-live .site-header {
  background: var(--live-header-bg, var(--header-bg));
  border-bottom-color: var(--live-header-border, #e2e8f0);
}

html[data-theme="dark"] body.page-live .site-header .brand-title,
html[data-theme="dark"] body.page-live .site-header .brand {
  color: var(--brand-text);
}

@media (prefers-color-scheme: dark) {
  html[data-theme="auto"] body.page-live .site-header .brand-title,
  html[data-theme="auto"] body.page-live .site-header .brand {
    color: var(--brand-text);
  }
}

html[data-theme="light"] body.page-live .site-header .brand-title,
html[data-theme="light"] body.page-live .site-header .brand {
  color: var(--header-text);
}

@media (prefers-color-scheme: light) {
  html[data-theme="auto"] body.page-live .site-header .brand-title,
  html[data-theme="auto"] body.page-live .site-header .brand {
    color: var(--header-text);
  }
}

.live-theme-btn {
  appearance: none;
  border: 1px solid var(--brand-border);
  background: var(--brand-panel);
  color: var(--brand-text);
  width: var(--touch-min);
  height: var(--touch-min);
  border-radius: 12px;
  font-size: 1.15rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, background 0.15s ease;
  touch-action: manipulation;
}

.live-theme-btn:hover {
  background: var(--brand-panel-2);
  transform: scale(1.04);
}

.live-reconnect-banner {
  position: sticky;
  top: var(--header-height);
  z-index: 90;
  background: var(--live-pill-warn-bg);
  border-bottom: 1px solid var(--live-pill-warn-border);
  color: var(--live-pill-warn-color);
  text-align: center;
  padding: 10px 16px;
  font-size: 0.9rem;
  font-weight: 600;
}

.live-hero--premium {
  background: var(--brand-panel);
  border: 1px solid var(--brand-border);
  border-radius: 20px;
  padding: clamp(16px, 3.5vw, 24px);
  margin-bottom: 0;
}

.live-hero-kicker {
  margin: 0 0 6px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--brand-accent);
}

.live-hero-lead {
  margin: 8px 0 0;
  color: var(--brand-muted);
  font-size: 0.95rem;
  max-width: 52ch;
  line-height: 1.5;
}

.live-hint {
  margin: 12px 0 0;
  font-size: 0.84rem;
  color: var(--brand-muted);
  padding: 8px 12px;
  background: var(--brand-panel-2);
  border-radius: 10px;
  border: 1px dashed var(--brand-border);
}

.live-hero-progress {
  flex: 1 1 220px;
  max-width: 320px;
  min-width: 200px;
}

.live-progress-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  color: var(--brand-muted);
  margin-bottom: 8px;
}

.live-progress-label strong {
  color: var(--brand-accent);
  font-size: 1.1rem;
}

.live-progress-track {
  height: 10px;
  background: var(--brand-panel-2);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--brand-border);
}

.live-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--brand-accent), #22c55e);
  border-radius: 999px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.live-stat {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.live-stat-icon {
  font-size: 1.35rem;
  line-height: 1;
  margin-bottom: 4px;
}

.live-stat-sub {
  font-size: 0.75rem;
  color: var(--live-text-muted, var(--brand-muted));
  margin-top: 2px;
}

.live-toolbar-sticky {
  position: sticky;
  top: calc(var(--header-height) + var(--live-gap-xs));
  z-index: 50;
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--live-gap-sm);
  align-items: stretch;
  padding: var(--live-toolbar-pad);
  margin-bottom: 0;
  background: var(--brand-panel);
  border: 1px solid var(--brand-border);
  border-radius: 16px;
}

.live-toolbar-races,
.live-toolbar-search {
  min-width: 0;
  width: 100%;
}

.live-toolbar-search {
  display: flex;
  align-items: stretch;
}

/* Live — 2 κουμπιά αγώνων (γρήγορη πλοήγηση) */
.live-race-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--live-gap-sm);
  width: 100%;
}

.live-race-switch .race-filter-btn {
  appearance: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  min-height: clamp(52px, 12vw, 60px);
  padding: clamp(10px, 2.5vw, 14px) clamp(10px, 2vw, 16px);
  border-radius: var(--live-radius, 14px);
  border: 2px solid transparent;
  font-weight: 800;
  line-height: 1.15;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  text-align: center;
}

.live-race-switch .race-filter-km {
  font-size: clamp(0.98rem, 2.8vw, 1.12rem);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.live-race-switch .race-filter-name {
  font-size: clamp(0.72rem, 2.2vw, 0.82rem);
  font-weight: 600;
  opacity: 0.92;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* Light theme — μαύρα γράμματα στα ανενεργά */
html[data-theme="light"] body.page-live .live-race-switch .race-filter-btn:not(.active) {
  color: #0f172a;
  background: #ffffff;
  border-color: #cbd5e1;
}

html[data-theme="light"] body.page-live .live-race-switch .race-filter-btn:not(.active):hover {
  color: #0f172a;
  background: #e2e8f0;
  border-color: #64748b;
}

html[data-theme="light"] body.page-live .live-race-switch .race-filter-btn--10km:not(.active):hover {
  border-color: #3b82f6;
  background: #eff6ff;
}

html[data-theme="light"] body.page-live .live-race-switch .race-filter-btn--4km:not(.active):hover {
  border-color: #ea580c;
  background: #fff7ed;
}

html[data-theme="light"] body.page-live .live-race-switch .race-filter-btn:focus-visible {
  outline: 3px solid rgba(2, 132, 199, 0.45);
  outline-offset: 2px;
}

@media (prefers-color-scheme: light) {
  html[data-theme="auto"] body.page-live .live-race-switch .race-filter-btn:not(.active) {
    color: #0f172a;
    background: #ffffff;
    border-color: #cbd5e1;
  }

  html[data-theme="auto"] body.page-live .live-race-switch .race-filter-btn:not(.active):hover {
    color: #0f172a;
    background: #e2e8f0;
    border-color: #64748b;
  }

  html[data-theme="auto"] body.page-live .live-race-switch .race-filter-btn--10km:not(.active):hover {
    border-color: #3b82f6;
    background: #eff6ff;
  }

  html[data-theme="auto"] body.page-live .live-race-switch .race-filter-btn--4km:not(.active):hover {
    border-color: #ea580c;
    background: #fff7ed;
  }
}

/* Dark theme — ανενεργά */
html[data-theme="dark"] body.page-live .live-race-switch .race-filter-btn:not(.active) {
  color: #f1f5f9;
  background: #17243a;
  border-color: rgba(148, 163, 184, 0.35);
}

html[data-theme="dark"] body.page-live .live-race-switch .race-filter-btn:not(.active):hover {
  color: #ffffff;
  background: #1e293b;
  border-color: #94a3b8;
}

html[data-theme="dark"] body.page-live .live-race-switch .race-filter-btn--10km:not(.active):hover {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.12);
}

html[data-theme="dark"] body.page-live .live-race-switch .race-filter-btn--4km:not(.active):hover {
  border-color: #fb923c;
  background: rgba(251, 146, 60, 0.12);
}

@media (prefers-color-scheme: dark) {
  html[data-theme="auto"] body.page-live .live-race-switch .race-filter-btn:not(.active) {
    color: #f1f5f9;
    background: #17243a;
    border-color: rgba(148, 163, 184, 0.35);
  }

  html[data-theme="auto"] body.page-live .live-race-switch .race-filter-btn:not(.active):hover {
    color: #ffffff;
    background: #1e293b;
    border-color: #94a3b8;
  }

  html[data-theme="auto"] body.page-live .live-race-switch .race-filter-btn--10km:not(.active):hover {
    border-color: #38bdf8;
    background: rgba(56, 189, 248, 0.12);
  }

  html[data-theme="auto"] body.page-live .live-race-switch .race-filter-btn--4km:not(.active):hover {
    border-color: #fb923c;
    background: rgba(251, 146, 60, 0.12);
  }
}

/* Ενεργό κουμπί ανά αγώνα */
body.page-live .live-race-switch .race-filter-btn--10km.active {
  background: #1d4ed8;
  border-color: #1e3a8a;
  color: #ffffff;
}

body.page-live .live-race-switch .race-filter-btn--4km.active {
  background: #c2410c;
  border-color: #9a3412;
  color: #ffffff;
}

body.page-live .live-race-switch .race-filter-btn.active .race-filter-name {
  opacity: 1;
}

body.page-live .live-race-switch .race-filter-btn.active:hover {
  color: #ffffff;
  filter: brightness(1.06);
}

.live-search {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--live-gap-xs);
  background: var(--brand-panel-2);
  border: 1px solid var(--brand-border);
  border-radius: var(--live-radius, 14px);
  padding: 0 clamp(10px, 2.5vw, 14px);
  min-height: clamp(52px, 12vw, 60px);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.live-search:focus-within {
  border-color: var(--brand-accent);
  box-shadow: 0 0 0 3px var(--live-accent-soft, rgba(56, 189, 248, 0.2));
}

.live-search-icon {
  font-size: 1rem;
  opacity: 0.7;
  flex-shrink: 0;
}

.live-search-input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--brand-text);
  font-size: 0.95rem;
  min-width: 0;
  padding: 8px 0;
  outline: none;
}

.live-search-input::placeholder {
  color: var(--brand-muted);
}

.live-search-clear {
  appearance: none;
  border: none;
  background: var(--live-search-clear-bg, var(--brand-panel-2));
  color: var(--live-search-clear-color, var(--brand-text));
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.live-search-empty {
  text-align: center;
  padding: clamp(20px, 4vw, 28px) var(--live-gap-md, 16px);
  margin-bottom: 0;
  background: var(--brand-panel);
  border: 1px dashed var(--brand-border);
  border-radius: 14px;
  color: var(--brand-muted);
  font-size: 0.95rem;
}

.bib-chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 8px;
  background: var(--brand-panel-2);
  border: 1px solid var(--brand-border);
  font-family: ui-monospace, monospace;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
}

.empty-state-sub {
  display: block;
  margin-top: 6px;
  font-size: 0.82rem;
  opacity: 0.85;
}

.live-scroll-top {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 80;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  background: var(--brand-accent-dark, var(--brand-accent));
  color: #fff;
  font-size: 1.25rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.live-scroll-top:hover {
  transform: translateY(-3px);
}

body.page-live .live-site-footer a {
  color: var(--live-footer-link, #7dd3fc);
}

body.page-live .race-badge-10km {
  background: rgba(56, 189, 248, 0.18);
  border-color: rgba(56, 189, 248, 0.45);
}

html[data-theme="light"] body.page-live .race-badge-10km {
  color: #0284c7;
}

html[data-theme="dark"] body.page-live .race-badge-10km {
  color: #7dd3fc;
}

@media (prefers-color-scheme: light) {
  html[data-theme="auto"] body.page-live .race-badge-10km {
    color: #0284c7;
  }
}

@media (prefers-color-scheme: dark) {
  html[data-theme="auto"] body.page-live .race-badge-10km {
    color: #7dd3fc;
  }
}

body.page-live .race-badge-4 {
  background: rgba(251, 146, 60, 0.18);
  border-color: rgba(251, 146, 60, 0.45);
}

html[data-theme="light"] body.page-live .race-badge-4 {
  color: #c2410c;
}

html[data-theme="dark"] body.page-live .race-badge-4 {
  color: #fdba74;
}

@media (prefers-color-scheme: light) {
  html[data-theme="auto"] body.page-live .race-badge-4 {
    color: #c2410c;
  }
}

@media (prefers-color-scheme: dark) {
  html[data-theme="auto"] body.page-live .race-badge-4 {
    color: #fdba74;
  }
}

body.page-live .race-badge-none {
  background: var(--brand-panel-2);
  color: var(--brand-muted);
  border-color: var(--brand-border);
}

body.page-live .live-hero,
body.page-live .live-search-empty {
  margin-bottom: 0;
}

.live-hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--live-gap-md, 16px);
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.live-hero h1 { margin: 0; font-size: clamp(1.5rem, 4vw, 2rem); }
.live-hero p { margin: 6px 0 0; color: var(--brand-muted); }

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--live-pill-live-bg, rgba(34, 197, 94, 0.15));
  border: 1px solid var(--live-pill-live-border, rgba(34, 197, 94, 0.35));
  color: var(--live-pill-live-color, #86efac);
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.88rem;
}

.live-pill.reconnecting {
  background: var(--live-pill-warn-bg, rgba(245, 158, 11, 0.15));
  border-color: var(--live-pill-warn-border, rgba(245, 158, 11, 0.35));
  color: var(--live-pill-warn-color, #fcd34d);
}

.live-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #22c55e;
  animation: livePulse 1.4s infinite;
}

@keyframes livePulse {
  0%, 100% { opacity: 0.4; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.1); }
}

.live-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--live-gap-sm);
  margin-bottom: 0;
}

.live-stat {
  background: var(--brand-panel);
  border: 1px solid var(--brand-border);
  border-radius: 14px;
  padding: 14px;
}

.live-stat .label { color: var(--brand-muted); font-size: 0.82rem; }
.live-stat .value { font-size: 1.6rem; font-weight: 800; margin-top: 4px; }
.live-stat .value.small { font-size: 0.95rem; font-weight: 700; }

.podium {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 0;
}

.podium-dual {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.podium-group {
  background: var(--brand-panel);
  border: 1px solid var(--brand-border);
  border-radius: 16px;
  padding: 14px;
}

.podium-group--men {
  border-color: rgba(56, 189, 248, 0.35);
  background: linear-gradient(180deg, rgba(56, 189, 248, 0.08), var(--brand-panel));
}

.podium-group--women {
  border-color: rgba(244, 114, 182, 0.35);
  background: linear-gradient(180deg, rgba(244, 114, 182, 0.08), var(--brand-panel));
}

.podium-group-title {
  margin: 0 0 12px;
  font-size: 1rem;
  text-align: center;
  color: var(--brand-text);
}

.podium-medal { font-size: 2rem; margin-bottom: 8px; }

.podium-card {
  background: var(--brand-panel);
  border: 1px solid var(--brand-border);
  border-radius: 16px;
  padding: 16px;
  text-align: center;
  min-height: 170px;
}

.podium-card.first {
  border-color: rgba(251, 191, 36, 0.45);
  background: linear-gradient(180deg, rgba(251,191,36,0.12), var(--brand-panel));
}

.podium-card.second { margin-top: 16px; }
.podium-card.third { margin-top: 26px; }

.podium-time {
  margin-top: 10px;
  font-family: ui-monospace, monospace;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--brand-accent);
}

.live-section {
  background: var(--brand-panel);
  border: 1px solid var(--brand-border);
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 18px;
}

.live-section-head {
  padding: 12px 16px;
  background: var(--brand-panel-2);
  border-bottom: 1px solid var(--brand-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.live-section-head h2 { margin: 0; font-size: 1rem; }

.races-live-container {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

#race-sections {
  display: flex;
  flex-direction: column;
  gap: var(--live-gap-xl);
}

.live-race-block,
.race-live-block {
  border: 1px solid var(--brand-border);
  border-radius: 18px;
  overflow: hidden;
  background: var(--brand-panel);
}

.live-race-head,
.race-live-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 16px 18px;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.12), rgba(99, 102, 241, 0.08));
  border-bottom: 1px solid var(--brand-border);
}

.live-race-head h2,
.race-live-head h2 {
  margin: 0;
  font-size: 1.2rem;
}

.race-live-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.live-race-head-badge {
  flex-shrink: 0;
}

.live-race-cell {
  text-align: center;
  white-space: nowrap;
}

.podium-race {
  margin: 8px 0 6px;
  display: flex;
  justify-content: center;
}

.page-dark .race-badge-10km {
  background: rgba(56, 189, 248, 0.18);
  color: #7dd3fc;
  border-color: rgba(56, 189, 248, 0.45);
}

.page-dark .race-badge-4 {
  background: rgba(251, 146, 60, 0.18);
  color: #fdba74;
  border-color: rgba(251, 146, 60, 0.45);
}

.page-dark .race-badge-none {
  background: rgba(255, 255, 255, 0.05);
  color: var(--brand-muted);
  border-color: var(--brand-border);
}

.race-live-block[data-race="10km"] .race-live-head {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.14), rgba(30, 64, 175, 0.1));
}

.race-live-block[data-race="4.1km"] .race-live-head {
  background: linear-gradient(135deg, rgba(251, 146, 60, 0.14), rgba(194, 65, 12, 0.08));
}

.live-race-stats,
.race-live-stats {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--brand-muted);
}

.live-race-block .podium-dual,
.live-race-block .live-section,
.race-live-block .podium-dual,
.race-live-block .live-section {
  margin: 0;
  border: none;
  border-radius: 0;
  border-top: 1px solid var(--brand-border);
}

.live-table { width: 100%; border-collapse: collapse; }
.live-table th, .live-table td {
  padding: 11px 14px;
  text-align: left;
  border-bottom: 1px solid var(--brand-border);
}

.live-table th {
  color: var(--brand-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.live-table tr:last-child td { border-bottom: none; }
.live-table tr:nth-child(even) td { background: var(--live-table-stripe, rgba(255,255,255,0.02)); }

.rank { width: 56px; font-weight: 800; text-align: center; }
.rank-1 { color: var(--brand-gold); }
.rank-2 { color: var(--brand-silver); }
.rank-3 { color: var(--brand-bronze); }

.time-cell {
  font-family: ui-monospace, monospace;
  font-weight: 700;
  color: var(--brand-accent);
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
}

.badge-run {
  background: var(--live-badge-run-bg, rgba(245, 158, 11, 0.18));
  color: var(--live-badge-run-color, #fcd34d);
}
.badge-fin { background: rgba(34, 197, 94, 0.18); color: #86efac; }

.empty-state {
  padding: 24px;
  text-align: center;
  color: var(--brand-muted);
}

.updated-note { color: var(--brand-muted); font-size: 0.82rem; }

.live-updated #live-stats-bar {
  animation: liveFlash 0.35s ease;
}

@keyframes liveFlash {
  0% { outline: 2px solid var(--brand-accent); outline-offset: 2px; }
  100% { outline: 2px solid transparent; outline-offset: 2px; }
}

@media (prefers-reduced-motion: reduce) {
  body.page-live .live-dot { animation: none; opacity: 1; }
  body.page-live .live-progress-bar { transition: none; }
  body.page-live .live-updated #live-stats-bar { animation: none; }
  body.page-live .live-theme-btn:hover { transform: none; }
  body.page-live .live-scroll-top:hover { transform: none; }
}

.search-input { flex: 1 1 220px; min-width: 180px; }

/* Screen: hide rank column */
.print-table .col-rank { display: none; }

/* Print sheet — A4 professional layout */
.print-sheet {
  display: none;
}

.print-sheet-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid #1e40af;
  margin-bottom: 12px;
}

.print-sheet-logo img {
  height: 52px;
  width: auto;
  max-width: 200px;
  object-fit: contain;
}

.print-sheet-titles h1 {
  margin: 0;
  font-size: 1.35rem;
  color: #0f172a;
  letter-spacing: 0.01em;
}

.print-sheet-subtitle {
  margin: 4px 0 0;
  color: #475569;
  font-size: 0.9rem;
}

.print-sheet-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.print-meta-item {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 8px 10px;
  text-align: center;
}

.print-meta-label {
  display: block;
  font-size: 0.72rem;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}

.print-meta-item span:last-child {
  font-size: 1rem;
  font-weight: 800;
  color: #0f172a;
}

.print-footer {
  display: none;
}

.print-output {
  display: none;
}

.print-race-title {
  margin: 10mm 0 4mm;
  font-size: 1.05rem;
  color: #0f172a;
}

.print-race-break {
  page-break-before: always;
}

@media print {
  @page {
    size: A4 portrait;
    margin: 10mm 8mm 12mm 8mm;
  }

  html, body {
    background: #fff !important;
    color: #000 !important;
    font-size: 9.5pt;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .site-header,
  .timing-panel,
  .tiles-wrap,
  .no-print,
  .modal,
  .toolbar,
  .stats-bar,
  .race-controls,
  .distanse-warning,
  #menu,
  .page-wrap {
    display: none !important;
  }

  .print-output {
    display: block !important;
  }

  .print-output .print-table .col-rank {
    display: table-cell !important;
  }

  .print-output .print-table .col-actions,
  .print-table .col-email {
    display: none !important;
  }

  .table-scroll {
    overflow: visible !important;
    box-shadow: none !important;
  }

  .athletes-panel {
    display: none !important;
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
  }

  .athletes-panel-head { display: none !important; }

  .athletes-table-scroll {
    max-height: none !important;
    overflow: visible !important;
  }

  .page-wrap {
    max-width: none;
    padding: 0;
    margin: 0;
  }

  .print-sheet {
    display: block !important;
    margin-bottom: 8mm;
  }

  .print-sheet-meta {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }

  .print-meta-item {
    padding: 6px 8px;
    background: #f1f5f9 !important;
    border: 1px solid #cbd5e1;
  }

  .print-table {
    display: table !important;
    width: 100% !important;
    border-collapse: collapse !important;
    table-layout: fixed !important;
    font-size: 8.5pt !important;
    box-shadow: none !important;
    page-break-inside: auto;
  }

  .print-table thead {
    display: table-header-group !important;
  }

  .print-table tbody {
    display: table-row-group !important;
  }

  .print-table tr {
    display: table-row !important;
    page-break-inside: avoid;
  }

  .print-table .col-rank {
    display: table-cell !important;
    width: 7% !important;
    text-align: center !important;
    font-weight: 700;
  }

  .print-table .col-bib { width: 9% !important; text-align: center !important; }
  .print-table .col-name { width: 32% !important; }
  .print-table .col-club,
  .print-table .col-club-h { width: 24% !important; }
  .print-table .col-distanse { width: 9% !important; text-align: center !important; }
  .print-table .col-gender { width: 9% !important; text-align: center !important; }
  .print-table .col-time { width: 17% !important; text-align: center !important; font-family: ui-monospace, monospace; font-weight: 700; }
  .print-table .col-actions,
  .print-table .col-email { display: none !important; }

  .print-table th,
  .print-table td {
    border: 1px solid #334155 !important;
    padding: 4px 5px !important;
    color: #000 !important;
    background: #fff !important;
    white-space: normal !important;
    word-wrap: break-word;
    vertical-align: middle;
  }

  .print-table th {
    position: static !important;
    background: #1e40af !important;
    color: #fff !important;
    font-weight: 700 !important;
    font-size: 8pt !important;
    text-transform: uppercase;
    letter-spacing: 0.03em;
  }

  .print-table th span { display: none !important; }

  .print-table tbody tr:nth-child(even) td {
    background: #f8fafc !important;
  }

  .print-table tr.finished td {
    font-weight: 600 !important;
  }

  .print-table tr.finished .col-time {
    color: #0f172a !important;
    font-weight: 800 !important;
  }

  .print-table tr.finished .col-rank {
    color: #1e40af !important;
  }

  .print-table .bib-badge,
  .print-table .gender-badge,
  .print-table .time-badge {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    color: inherit !important;
    font-size: inherit !important;
  }

  .col-club {
    max-width: none !important;
    overflow: visible !important;
    text-overflow: unset !important;
  }

  .highlight-m td,
  .highlight-f td {
    background: #fff !important;
  }
}

@media (min-width: 600px) {
  .brand-title { display: inline; }

  body.page-live {
    --live-gap-sm: 14px;
    --live-gap-md: 18px;
  }
}

@media (min-width: 720px) {
  .live-toolbar-sticky {
    grid-template-columns: minmax(260px, 400px) minmax(0, 1fr);
    gap: var(--live-gap-md);
    align-items: stretch;
  }

  .live-race-switch {
    gap: var(--live-gap-md);
    height: 100%;
  }

  .live-race-switch .race-filter-btn {
    min-height: 100%;
  }
}

@media (min-width: 900px) {
  body.page-live {
    --live-gap-lg: 24px;
    --live-gap-xl: 28px;
  }

  .live-toolbar-sticky {
    grid-template-columns: minmax(300px, 420px) minmax(0, 1fr);
    gap: var(--live-gap-lg);
  }
}

@media (max-width: 900px) {
  .live-stats { grid-template-columns: repeat(2, 1fr); }
  .stats-bar { grid-template-columns: repeat(3, 1fr); }
  .podium-dual { grid-template-columns: 1fr; }
  .podium { grid-template-columns: 1fr; }
  .podium-card.second, .podium-card.third { margin-top: 0; }
}

@media (max-width: 640px) {
  :root { --header-height: 112px; }

  .site-header-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .brand { justify-content: center; }
  .header-actions {
    justify-content: center;
    width: 100%;
  }

  .race-controls {
    grid-template-columns: 1fr;
  }

  .race-control-group {
    width: 100%;
    justify-content: center;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-divider { display: none; }

  #searchInput { width: 100% !important; min-width: 0 !important; }

  .timing-panel {
    flex-direction: column;
    align-items: stretch;
  }

  #timer-display {
    margin-left: 0;
    width: 100%;
  }

  #bibInput, #recordBtn { width: 100%; }

  .stats-bar { grid-template-columns: 1fr; }
  .live-stats { grid-template-columns: 1fr 1fr; }

  .live-section-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .live-hero { flex-direction: column; align-items: flex-start; }

  .live-hero--premium {
    padding: clamp(14px, 4vw, 18px);
  }

  .live-hero-progress {
    width: 100%;
    max-width: none;
  }

  .live-toolbar-sticky {
    top: var(--header-height);
    gap: var(--live-gap-sm);
  }

  .live-race-switch {
    gap: var(--live-gap-sm);
  }

  .live-search {
    width: 100%;
  }

  .table-scroll .live-table {
    min-width: 0;
  }

  .live-table thead {
    display: none;
  }

  .live-table tbody tr[data-search] {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--brand-border);
    background: var(--brand-panel);
  }

  .live-table tbody tr[data-search]:nth-child(even) {
    background: var(--brand-panel-2);
  }

  .live-table tbody tr[data-search] td {
    border: none;
    padding: 2px 0;
    background: transparent !important;
  }

  .live-table tbody tr[data-search] td::before {
    content: attr(data-label);
    display: block;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--brand-muted);
    margin-bottom: 2px;
    font-weight: 600;
  }

  .live-table tbody tr[data-search] td.rank {
    grid-column: 1 / -1;
    text-align: left;
    font-size: 1.1rem;
    padding-bottom: 6px;
    border-bottom: 1px dashed var(--brand-border);
    margin-bottom: 4px;
  }

  .live-table tbody tr[data-search] td.time-cell {
    grid-column: 1 / -1;
    font-size: 1.15rem;
    padding-top: 6px;
  }

  .live-table tbody tr[data-search] td[data-label="Κατάσταση"] {
    grid-column: 1 / -1;
  }

  .form-group {
    flex-direction: column;
    align-items: stretch;
  }

  .form-group select, .form-group input { width: 100%; }

  .user-pill { max-width: 100%; text-align: center; }

  .data-table th { top: var(--header-height); }
  .athletes-table-scroll .data-table th { top: 0; }

  .header-actions .btn {
    flex: 1 1 calc(50% - 4px);
    min-width: 0;
    padding: 8px 10px;
    font-size: 0.82rem;
  }
}

@media (max-width: 380px) {
  .live-stats { grid-template-columns: 1fr; }
  .logo-wrap img { height: 34px; }

  body.page-live {
    --live-gap-sm: 10px;
    --live-page-pad-x: 10px;
  }

  .live-race-switch .race-filter-name {
    font-size: 0.68rem;
  }

  .live-search-input {
    font-size: 0.88rem;
  }

  .live-search-input::placeholder {
    font-size: 0.82rem;
  }
}
