/* ===================================================
   Running Hellas — Main Stylesheet
   Dark/Light mode | Left sidebar | Custom UI
   =================================================== */

/* ---------- CSS Variables ---------- */
:root {
    --sidebar-w: 240px;
    --sidebar-collapsed-w: 68px;
    --transition: 0.25s ease;

    /* Light mode */
    --bg: #f0f4f8;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --border: #e2e8f0;
    --text: #1a202c;
    --text-muted: #64748b;
    --text-sidebar: #e2e8f0;
    --sidebar-bg: #1a1f2e;
    --sidebar-active: #f97316;
    --sidebar-hover: rgba(249, 115, 22, 0.1);
    --accent: #f97316;
    --accent-hover: #ea6c0a;
    --accent-light: rgba(249, 115, 22, 0.12);
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --bg-hover: rgba(0,0,0,0.05);
    --card-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --card-shadow-hover: 0 10px 25px rgba(0,0,0,0.12), 0 4px 8px rgba(0,0,0,0.06);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
}

[data-theme="dark"] {
    --bg: #0d1117;
    --surface: #161b22;
    --surface-2: #1c2333;
    --border: #30363d;
    --text: #e6edf3;
    --text-muted: #8b949e;
    --text-sidebar: #e2e8f0;
    --sidebar-bg: #0d1117;
    --bg-hover: rgba(255,255,255,0.07);
    --card-shadow: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
    --card-shadow-hover: 0 10px 25px rgba(0,0,0,0.5), 0 4px 8px rgba(0,0,0,0.3);
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    transition: background var(--transition), color var(--transition);
    line-height: 1.6;
    overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; }

/* ---------- Layout ---------- */
.layout {
    display: flex;
    min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transition: width var(--transition);
    overflow: hidden;
    border-right: 1px solid rgba(255,255,255,0.06);
}

.sidebar.collapsed { width: var(--sidebar-collapsed-w); }

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px 20px 20px;
    min-height: 72px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-logo .logo-icon {
    width: 32px; height: 32px;
    background: var(--accent);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    font-size: 18px;
}

.sidebar-logo .logo-text {
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.3px;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity var(--transition), width var(--transition);
}

.sidebar-logo .logo-sub {
    font-size: 10px;
    color: var(--accent);
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    display: block;
    line-height: 1;
    margin-top: 1px;
}

.sidebar.collapsed .logo-text { opacity: 0; width: 0; }

/* Nav */
.sidebar-nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.nav-section-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: rgba(255,255,255,0.3);
    padding: 12px 20px 4px;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity var(--transition);
}

.sidebar.collapsed .nav-section-label { opacity: 0; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 20px;
    color: rgba(255,255,255,0.65);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    border-radius: 0;
    white-space: nowrap;
    position: relative;
}

.nav-item:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

.nav-item.active {
    background: var(--accent-light);
    color: var(--accent);
    font-weight: 600;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--accent);
    border-radius: 0 2px 2px 0;
}

.nav-item svg {
    width: 18px; height: 18px;
    flex-shrink: 0;
    opacity: 0.9;
}

.nav-item span { overflow: hidden; transition: opacity var(--transition); }
.sidebar.collapsed .nav-item span { opacity: 0; width: 0; }

/* Sidebar bottom */
.sidebar-bottom {
    padding: 12px 0;
    border-top: 1px solid rgba(255,255,255,0.06);
}

/* Lang switcher */
.lang-switcher {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
}

.lang-btn {
    background: none;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 6px;
    color: rgba(255,255,255,0.6);
    font-size: 11px;
    font-weight: 600;
    padding: 4px 8px;
    cursor: pointer;
    transition: all var(--transition);
    letter-spacing: 0.5px;
}

.lang-btn:hover, .lang-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.lang-label {
    color: rgba(255,255,255,0.3);
    font-size: 10px;
    margin-right: 4px;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity var(--transition);
}

.sidebar.collapsed .lang-label, .sidebar.collapsed .lang-switcher {
    padding-left: 16px;
}
.sidebar.collapsed .lang-label { opacity: 0; width: 0; overflow: hidden; }

/* Theme toggle */
.theme-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    cursor: pointer;
    color: rgba(255,255,255,0.5);
    font-size: 13px;
    transition: color var(--transition);
}

.theme-toggle:hover { color: rgba(255,255,255,0.9); }

.toggle-track {
    width: 36px; height: 20px;
    background: rgba(255,255,255,0.15);
    border-radius: 10px;
    position: relative;
    flex-shrink: 0;
    transition: background var(--transition);
}

.toggle-track.on { background: var(--accent); }

.toggle-thumb {
    width: 14px; height: 14px;
    background: white;
    border-radius: 50%;
    position: absolute;
    top: 3px; left: 3px;
    transition: transform var(--transition);
}

.toggle-track.on .toggle-thumb { transform: translateX(16px); }

.theme-toggle-label { white-space: nowrap; overflow: hidden; transition: opacity var(--transition); }
.sidebar.collapsed .theme-toggle-label { opacity: 0; width: 0; }

/* Collapse button */
.sidebar-collapse-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    cursor: pointer;
    color: rgba(255,255,255,0.3);
    transition: color var(--transition);
    border-top: 1px solid rgba(255,255,255,0.06);
}

.sidebar-collapse-btn:hover { color: rgba(255,255,255,0.7); }
.sidebar-collapse-btn svg { transition: transform var(--transition); }
.sidebar.collapsed .sidebar-collapse-btn svg { transform: rotate(180deg); }

/* ---------- Main Content ---------- */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-width: 0;
    transition: margin-left var(--transition);
}

.sidebar.collapsed ~ .main-content { margin-left: var(--sidebar-collapsed-w); }

/* Top bar */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 32px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
    transition: background var(--transition), border-color var(--transition);
}

.topbar-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.topbar-breadcrumb {
    font-size: 13px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.topbar-breadcrumb a:hover { color: var(--accent); }

/* Page content */
.page-content {
    padding: 32px;
    max-width: 1400px;
}

/* ---------- Cards ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--card-shadow);
    overflow: hidden;
    transition: all var(--transition);
}

/* ---------- Race Cards Grid ---------- */
.races-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.race-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--card-shadow);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    cursor: pointer;
}

.race-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--card-shadow-hover);
    border-color: var(--accent);
}

.race-card-image {
    height: 180px;
    position: relative;
    overflow: hidden;
    background: var(--surface-2);
}

.race-card-image img {
    width: 100%; height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.race-card:hover .race-card-image img { transform: scale(1.05); }

.race-card-image-placeholder {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    font-size: 48px;
    background: linear-gradient(135deg, var(--surface-2) 0%, var(--border) 100%);
}

/* Type badge overlay */
.race-type-badge {
    position: absolute;
    top: 12px; left: 12px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    backdrop-filter: blur(8px);
}

.race-status-badge {
    position: absolute;
    top: 12px; right: 12px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

/* Card body */
.race-card-body {
    padding: 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.race-card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
    flex-wrap: wrap;
}

.race-card-meta .meta-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.race-card-meta svg { width: 13px; height: 13px; }

.race-card-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.3;
}

.race-card-description {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Distance chips */
.race-distances {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.distance-chip {
    padding: 3px 10px;
    background: var(--accent-light);
    color: var(--accent);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

/* Card footer */
.race-card-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.race-price {
    font-size: 16px;
    font-weight: 700;
    color: var(--accent);
}

.race-price-label {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 400;
}

/* Badges */
.badge-row {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.badge-road { background: #dbeafe; color: #1d4ed8; }
.badge-trail { background: #dcfce7; color: #15803d; }
.badge-ultra { background: #fce7f3; color: #9d174d; }
.badge-vertical { background: #f3e8ff; color: #7e22ce; }
.badge-ocr { background: #ffedd5; color: #c2410c; }
.badge-kids { background: #fef9c3; color: #a16207; }
.badge-triathlon { background: #e0f2fe; color: #0369a1; }
.badge-bicycle { background: #ecfdf5; color: #065f46; }
.badge-swimming { background: #eff6ff; color: #1e40af; }
.badge-awaiting-news { background: #fff7ed; color: #c2410c; font-size: 11px; }

[data-theme="dark"] .badge-road { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .badge-trail { background: #14532d; color: #86efac; }
[data-theme="dark"] .badge-ultra { background: #500724; color: #f9a8d4; }
[data-theme="dark"] .badge-vertical { background: #3b0764; color: #d8b4fe; }
[data-theme="dark"] .badge-ocr { background: #431407; color: #fdba74; }
[data-theme="dark"] .badge-kids { background: #422006; color: #fde68a; }
[data-theme="dark"] .badge-triathlon { background: #0c4a6e; color: #7dd3fc; }
[data-theme="dark"] .badge-bicycle { background: #064e3b; color: #6ee7b7; }
[data-theme="dark"] .badge-swimming { background: #1e3a8a; color: #93c5fd; }
[data-theme="dark"] .badge-awaiting-news { background: #431407; color: #fdba74; }

.badge-certified { background: #dcfce7; color: #15803d; }
.badge-night { background: #1e1b4b; color: #a5b4fc; }
.badge-eco { background: #dcfce7; color: #15803d; }
[data-theme="dark"] .badge-certified { background: #14532d; color: #86efac; }
[data-theme="dark"] .badge-night { background: #1e1b4b; color: #a5b4fc; }

.badge-easy { background: #dcfce7; color: #15803d; }
.badge-moderate { background: #fef9c3; color: #a16207; }
.badge-hard { background: #ffedd5; color: #c2410c; }
.badge-expert { background: #fce7f3; color: #9d174d; }
[data-theme="dark"] .badge-easy { background: #14532d; color: #86efac; }
[data-theme="dark"] .badge-moderate { background: #422006; color: #fde68a; }
[data-theme="dark"] .badge-hard { background: #431407; color: #fdba74; }
[data-theme="dark"] .badge-expert { background: #500724; color: #f9a8d4; }

.badge-status-scheduled { background: #dcfce7; color: #15803d; }
.badge-status-postponed { background: #fef9c3; color: #a16207; }
.badge-status-cancelled { background: #fee2e2; color: #dc2626; }
[data-theme="dark"] .badge-status-scheduled { background: #14532d; color: #86efac; }
[data-theme="dark"] .badge-status-postponed { background: #422006; color: #fde68a; }
[data-theme="dark"] .badge-status-cancelled { background: #450a0a; color: #fca5a5; }
.badge-status-draft { background: #e0e7ff; color: #4338ca; }
[data-theme="dark"] .badge-status-draft { background: #1e1b4b; color: #a5b4fc; }
.badge-status-announced { background: #ede9fe; color: #6d28d9; }
[data-theme="dark"] .badge-status-announced { background: #2e1065; color: #c4b5fd; }
.cal-event-announced { opacity: .7; cursor: default; pointer-events: none; }
.map-popup-announced { font-size: 11px; color: #6d28d9; font-weight: 600; margin-bottom: 4px; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-outline:hover { border-color: var(--accent); color: var(--accent); }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }

.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; transform: translateY(-1px); }

/* ---------- Filters Panel ---------- */
.filters-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 24px;
}

.filters-grid {
    display: grid;
    grid-template-columns: 2fr repeat(3, 1fr) auto;
    gap: 12px;
    align-items: end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.filter-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--text-muted);
}

.filter-input, .filter-select {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text);
    padding: 9px 12px;
    font-size: 13px;
    width: 100%;
    transition: border-color var(--transition), background var(--transition);
    appearance: none;
    -webkit-appearance: none;
}

.filter-input:focus, .filter-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.filter-select-wrapper {
    position: relative;
}

.filter-select-wrapper::after {
    content: '';
    position: absolute;
    right: 10px; top: 50%; transform: translateY(-50%);
    border: 4px solid transparent;
    border-top-color: var(--text-muted);
    pointer-events: none;
}

.filters-actions {
    display: flex;
    gap: 8px;
    align-items: end;
    padding-bottom: 1px;
}

.filters-row2 {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.filter-check {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 20px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    transition: all var(--transition);
}

.filter-check:hover { border-color: var(--accent); color: var(--accent); }
.filter-check input { display: none; }
.filter-check.checked { background: var(--accent-light); border-color: var(--accent); color: var(--accent); }

/* ---------- Multi-select dropdown ---------- */
.filter-multiselect {
    position: relative;
}

.filter-multiselect-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    width: 100%;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text);
    padding: 9px 12px;
    font-size: 13px;
    cursor: pointer;
    text-align: left;
    transition: border-color var(--transition), background var(--transition);
}

.filter-multiselect-trigger:hover,
.filter-multiselect.open .filter-multiselect-trigger {
    border-color: var(--accent);
}

.filter-multiselect.open .filter-multiselect-trigger svg {
    transform: rotate(180deg);
}

.filter-multiselect-trigger svg {
    flex-shrink: 0;
    color: var(--text-muted);
    transition: transform 0.15s ease;
}

.filter-multiselect-trigger .ms-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-muted);
}

.filter-multiselect-trigger .ms-label.has-selection {
    color: var(--text);
    font-weight: 500;
}

.filter-multiselect-panel {
    display: none;
    position: absolute;
    z-index: 200;
    top: calc(100% + 2px);
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    max-height: 220px;
    overflow-y: auto;
    padding: 4px 0;
}

.filter-multiselect.open .filter-multiselect-panel {
    display: block;
}

.ms-search-wrap {
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--surface);
    z-index: 1;
}

.ms-search {
    width: 100%;
    padding: 5px 10px;
    font-size: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background: var(--surface-2);
    color: var(--text);
    outline: none;
    box-sizing: border-box;
}

.ms-search:focus {
    border-color: var(--accent);
}

.ms-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text);
    transition: background var(--transition);
}

.ms-option:hover {
    background: var(--surface-2);
}

.ms-option input[type="checkbox"] {
    width: 15px;
    height: 15px;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
}

/* ---------- Range filters row ---------- */
.filters-ranges {
    display: flex;
    gap: 16px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.range-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    min-width: 180px;
}

.range-inputs {
    display: flex;
    align-items: center;
    gap: 6px;
}

.range-input {
    flex: 1;
    min-width: 0;
}

.range-sep {
    color: var(--text-muted);
    font-size: 14px;
    flex-shrink: 0;
}

/* date inputs theming */
input[type="date"].filter-input {
    color-scheme: light dark;
}

[data-theme="dark"] input[type="date"].filter-input {
    color-scheme: dark;
}

/* ---------- Results header ---------- */
.results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.results-count {
    font-size: 13px;
    color: var(--text-muted);
}

.results-count strong { color: var(--text); font-weight: 600; }

/* ---------- Pagination ---------- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 32px;
}

.page-btn {
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-xs);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.page-btn:hover { border-color: var(--accent); color: var(--accent); }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: white; }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------- Hero Section ---------- */
.hero {
    background: linear-gradient(150deg, #1a1f2e 0%, #252d3d 55%, #1a202c 100%);
    padding: 88px 40px 80px;
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23f97316' fill-opacity='0.04'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E") repeat;
    pointer-events: none;
    z-index: 2;
}

.hero::after {
    content: '';
    position: absolute;
    bottom: -180px;
    left: -120px;
    width: 640px;
    height: 640px;
    background: radial-gradient(circle, rgba(249,115,22,0.13) 0%, transparent 65%);
    pointer-events: none;
    z-index: 1;
}

.hero-content {
    max-width: 660px;
    position: relative;
    z-index: 3;
}

/* ── Hero Slideshow ── */
.hero-slideshow {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    user-select: none;
}

.hero-slide {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0;
    transition: opacity 1.5s ease-in-out;
}

.hero-slide.active {
    opacity: 1;
}

.hero-slideshow-overlay {
    position: absolute;
    inset: 0;
    background: rgba(10, 14, 28, 0.65);
}

.hero-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--accent);
    background: rgba(249,115,22,0.1);
    border: 1px solid rgba(249,115,22,0.22);
    padding: 6px 14px;
    border-radius: 100px;
    margin-bottom: 24px;
}

.hero-title {
    font-size: clamp(30px, 4.5vw, 54px);
    font-weight: 800;
    color: white;
    line-height: 1.12;
    margin-bottom: 18px;
    letter-spacing: -0.5px;
}

.hero-title span { color: var(--accent); }

.hero-subtitle {
    font-size: 16px;
    color: rgba(255,255,255,0.62);
    margin-bottom: 36px;
    line-height: 1.75;
    max-width: 480px;
}

.hero-stats {
    display: flex;
    width: fit-content;
    gap: 0;
    margin-top: 48px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.09);
    border-radius: 16px;
    overflow: hidden;
}

.hero-stat {
    text-align: center;
    padding: 18px 32px;
    position: relative;
}

.hero-stat + .hero-stat {
    border-left: 1px solid rgba(255,255,255,0.09);
}

.hero-stat-value {
    font-size: 30px;
    font-weight: 800;
    color: var(--accent);
    line-height: 1;
}

.hero-stat-label {
    font-size: 11px;
    color: rgba(255,255,255,0.45);
    margin-top: 5px;
    font-weight: 600;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

/* ---------- Home category chips ---------- */
.home-categories {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 18px 40px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.home-categories-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-right: 4px;
}

.category-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 100px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
    transition: all var(--transition);
}

.category-chip:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light);
    transform: translateY(-1px);
}

.category-chip-icon { font-size: 15px; line-height: 1; }

/* ---------- Race Detail ---------- */
.detail-hero {
    height: 340px;
    position: relative;
    overflow: hidden;
    border-radius: var(--radius) var(--radius) 0 0;
}

.detail-hero img {
    width: 100%; height: 100%;
    object-fit: cover;
}

.detail-hero-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.75) 0%, rgba(0,0,0,0.1) 60%);
}

.detail-hero-content {
    position: absolute;
    bottom: 24px; left: 24px; right: 24px;
}

.detail-title {
    font-size: clamp(22px, 3vw, 36px);
    font-weight: 800;
    color: white;
    line-height: 1.2;
    margin-bottom: 8px;
    letter-spacing: -0.3px;
}

.detail-meta-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.detail-layout {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 24px;
    margin-top: 24px;
}

.detail-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
}

.detail-section-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 16px;
    letter-spacing: -0.2px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.detail-section-title svg { color: var(--accent); }

/* Categories table */
.categories-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.categories-table th {
    text-align: left;
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}

.categories-table td {
    padding: 12px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: middle;
}

.categories-table tr:last-child td { border-bottom: none; }
.categories-table tr:hover td { background: var(--surface-2); }

/* Info grid */
.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.info-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.info-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Tags/Flags */
.flags-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.flag-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    background: var(--accent-light);
    color: var(--accent);
}

/* Sidebar card */
.sidebar-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    position: sticky;
    top: 80px;
}

/* Race detail info disclaimer */
.race-info-disclaimer {
    display: flex;
    gap: 7px;
    align-items: flex-start;
    padding: 10px 12px;
    margin-bottom: 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    font-size: 11.5px;
    line-height: 1.5;
    color: var(--text-muted);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-muted);
}

.empty-state svg { width: 64px; height: 64px; opacity: 0.3; margin-bottom: 16px; }
.empty-state h3 { font-size: 18px; color: var(--text); margin-bottom: 8px; }
.empty-state p { font-size: 14px; }

/* ---------- Section title ---------- */
.section-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.3px;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-left: 14px;
    border-left: 3px solid var(--accent);
}

/* ---------- Skeleton loader ---------- */
.skeleton {
    background: linear-gradient(90deg, var(--border) 25%, var(--surface-2) 50%, var(--border) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: var(--radius-xs);
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
    .filters-grid { grid-template-columns: 1fr 1fr 1fr; }
    .filters-ranges { flex-direction: column; }
    .range-group { min-width: unset; }
    .detail-layout { grid-template-columns: 1fr; }
    .sidebar-card { position: static; }
}

@media (max-width: 768px) {
    :root { --sidebar-w: 0px; }

    .sidebar {
        transform: translateX(-100%);
        transition: transform var(--transition), width var(--transition);
        width: 240px;
    }

    .sidebar.mobile-open { transform: translateX(0); }

    .main-content { margin-left: 0; }
    .sidebar.collapsed ~ .main-content { margin-left: 0; }

    .topbar { padding: 0 16px; }
    .page-content { padding: 16px; }

    .filters-grid { grid-template-columns: 1fr; }
    .races-grid { grid-template-columns: 1fr; }
    .hero { padding: 48px 20px; }
    .hero-stats { display: flex; }
    .hero-stat { padding: 14px 20px; }
    .home-categories { padding: 14px 16px; }
    .info-grid { grid-template-columns: 1fr; }

    .mobile-menu-btn { display: flex !important; }
}

.mobile-menu-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px; height: 36px;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    cursor: pointer;
    color: var(--text);
}

.overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
}

.overlay.show { display: block; }

/* ---------- Tooltip ---------- */
[data-tooltip] {
    position: relative;
}

[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 8px);
    top: 50%; transform: translateY(-50%);
    background: #1a202c;
    color: white;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 200;
    pointer-events: none;
}

.sidebar.collapsed [data-tooltip]:hover::after { display: block; }

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ---------- List View ---------- */
.races-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.races-list .race-card {
    flex-direction: row;
    min-height: 90px;
}

.races-list .race-card-image {
    width: 130px;
    height: 90px;
    flex-shrink: 0;
    border-radius: 0;
}

/* Body: horizontal strip — title | meta | distances | badges */
.races-list .race-card-body {
    padding: 10px 14px;
    flex-direction: row;
    align-items: center;
    gap: 14px;
    flex-wrap: nowrap;
    flex: 1;
    min-width: 0;
}

.races-list .race-card-title {
    font-size: 14px;
    font-weight: 700;
    min-width: 150px;
    max-width: 220px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
}

.races-list .race-card-description { display: none; }

.races-list .race-card-meta {
    flex-wrap: nowrap;
    white-space: nowrap;
    overflow: hidden;
    min-width: 160px;
    flex-shrink: 1;
}

.races-list .race-distances {
    flex-wrap: nowrap;
    white-space: nowrap;
    flex-shrink: 0;
}

.races-list .badge-row {
    flex-wrap: nowrap;
    flex-shrink: 0;
}

/* Footer: fixed-width right column */
.races-list .race-card-footer {
    border-top: none;
    border-left: 1px solid var(--border);
    padding: 10px 14px;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
    width: 190px;
    flex-shrink: 0;
    align-items: stretch;
}

/* Hide "από" suffix — saves space */
.races-list .race-price-label { display: none; }

/* Price: single line, no overflow */
.races-list .race-price {
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Actions: buttons wrap when 3 are present (favorite + site + more-info) */
.races-list .race-card-footer > div:last-child {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-content: center;
    gap: 4px;
    width: 100%;
}

.races-list .race-card-footer > div:last-child .btn {
    flex: 1 0 auto;
    justify-content: center;
    font-size: 11px;
    padding: 5px 4px;
}

@media (max-width: 768px) {
    .races-list .race-card { flex-direction: column; height: auto; }
    .races-list .race-card-image { width: 100%; height: 160px; }
    .races-list .race-card-body { flex-wrap: wrap; }
    .races-list .race-card-footer { border-left: none; border-top: 1px solid var(--border); width: 100%; flex-direction: row; justify-content: space-between; }
    .races-list .race-price-label { display: inline; }
}

/* ---------- View toggle button ---------- */
.view-toggle {
    display: flex;
    gap: 4px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    padding: 3px;
}

.view-btn {
    width: 30px; height: 28px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 4px;
    cursor: pointer;
    border: none;
    background: transparent;
    color: var(--text-muted);
    transition: all var(--transition);
}

.view-btn:hover { color: var(--text); }
.view-btn.active { background: var(--surface); color: var(--accent); box-shadow: 0 1px 3px rgba(0,0,0,0.1); }

/* ---------- Sort dropdown ---------- */
.sort-select {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text);
    padding: 6px 28px 6px 10px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    transition: border-color var(--transition);
}

.sort-select:focus { outline: none; border-color: var(--accent); }

/* ---------- Calendar View ---------- */
.races-calendar {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cal-day {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.cal-day:hover { border-color: var(--accent); }
.cal-day.open  { border-color: var(--accent); box-shadow: 0 2px 10px rgba(249,115,22,.12); }

.cal-day.cal-day-today .cal-day-date-block { background: var(--accent); color: #fff; }
.cal-day-today > .cal-day-header { background: rgba(249,115,22,.04); }

.cal-day.cal-day-past .cal-day-date-block { opacity: .55; }
.cal-day.cal-day-past .cal-day-name       { color: var(--text-muted); }

.cal-day-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
}

.cal-day-header:hover { background: var(--surface-2); }

/* Mini calendar-page date block */
.cal-day-date-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 44px;
    min-width: 44px;
    height: 44px;
    border-radius: 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    line-height: 1;
    gap: 2px;
    transition: background 0.2s, border-color 0.2s;
}

.cal-day-num {
    font-size: 18px;
    font-weight: 800;
    color: var(--text);
    line-height: 1;
}

.cal-day-month {
    font-size: 9px;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: .05em;
    text-transform: uppercase;
}

.cal-day-today .cal-day-num,
.cal-day-today .cal-day-month { color: #fff; }

/* Middle info section */
.cal-day-info {
    flex: 1;
    min-width: 0;
}

.cal-day-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    text-transform: capitalize;
    line-height: 1.2;
}

.cal-day-summary {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 5px;
}

.cal-race-count {
    background: var(--accent);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    border-radius: 20px;
    padding: 2px 9px;
    white-space: nowrap;
}

.cal-day-chevron {
    color: var(--text-muted);
    transition: transform 0.25s;
    flex-shrink: 0;
}

.cal-day.open .cal-day-chevron { transform: rotate(180deg); }

/* Expanded body */
.cal-day-body {
    display: none;
    flex-direction: column;
    gap: 6px;
    padding: 0 12px 12px;
}

.cal-day.open .cal-day-body { display: flex; }

/* Separator between header and body */
.cal-day.open .cal-day-header {
    border-bottom: 1px solid var(--border);
    margin-bottom: 0;
}

/* Race row inside an expanded day */
.cal-race-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
    text-decoration: none;
    color: inherit;
}

.cal-race-row:hover { background: var(--surface-2); }

.cal-race-thumb {
    width: 52px;
    min-width: 52px;
    height: 52px;
    border-radius: 7px;
    overflow: hidden;
    background: var(--surface-2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

.cal-race-thumb img { width: 100%; height: 100%; object-fit: cover; }

.cal-race-info { flex: 1; min-width: 0; }

.cal-race-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.cal-race-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 5px;
}

.cal-race-location {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}

.cal-race-action { flex-shrink: 0; }

@media (max-width: 640px) {
    .cal-race-action { display: none; }
    .cal-race-title  { white-space: normal; }
}

/* Distance from user chip */
.distance-from-user {
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 2px 0;
}

/* ══════════════════════════════════════════════════
   Admin Form Styles
   ══════════════════════════════════════════════════ */

/* ── Sections ──────────────────────────────────── */
.form-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 16px;
}

.form-section-title {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--accent);
    padding-bottom: 16px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

/* ── Layout grids ──────────────────────────────── */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-group      { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }

/* ── Labels & inputs ───────────────────────────── */
.form-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
}

.form-label .req { color: var(--accent); margin-left: 2px; }

.form-input,
.form-select,
.form-textarea {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text);
    padding: 9px 12px;
    font-size: 13px;
    font-family: inherit;
    width: 100%;
    box-sizing: border-box;
    transition: border-color .15s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.form-textarea { resize: vertical; min-height: 80px; }

.form-select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 32px;
}

.form-input-sm { padding: 6px 10px; font-size: 12px; }

.form-error      { font-size: 11px; color: #ef4444; }
.form-error-list { list-style: none; padding: 0; margin: 0; }

/* ── Validation alert ──────────────────────────── */
.form-alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 13px;
}

.form-alert-error {
    background: rgba(239,68,68,.08);
    border: 1px solid rgba(239,68,68,.3);
    color: #ef4444;
}

/* ── Location toggle ───────────────────────────── */
.form-loc-toggle {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
}

.form-loc-btn {
    padding: 7px 16px;
    font-size: 13px;
    font-weight: 600;
    border-radius: var(--radius-xs);
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-muted);
    cursor: pointer;
    transition: all .15s;
}

.form-loc-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.form-loc-btn:hover:not(.active) { border-color: var(--accent); color: var(--accent); }

/* ── Flags (checkbox pills) ────────────────────── */
.form-flags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.form-flag {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 8px 16px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    user-select: none;
    transition: all .15s;
}

.form-flag input { display: none; }
.form-flag.checked { background: var(--accent); border-color: var(--accent); color: #fff; }
.form-flag:hover:not(.checked) { border-color: var(--accent); color: var(--accent); }

/* ── Categories table ──────────────────────────── */
.cat-wrapper { overflow-x: auto; }

.cat-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    min-width: 640px;
}

.cat-table th {
    text-align: left;
    padding: 8px 10px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.cat-table td {
    padding: 6px 6px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.cat-table tr:last-child td { border-bottom: none; }
.cat-table tr:hover td { background: var(--surface-2); }

/* ── Category cards ─────────────────────────────── */
.cat-cards { display: flex; flex-direction: column; gap: 10px; }

.cat-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 14px;
    background: var(--surface-2);
}

.cat-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.cat-name-input { flex: 1; min-width: 180px; }

.cat-card-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.cat-field { display: flex; flex-direction: column; gap: 3px; }
.cat-field-lbl { font-size: 11px; color: var(--text-muted); font-weight: 500; white-space: nowrap; }
.cat-field .form-input-sm,
.cat-field .form-select { width: 100%; }

/* ── Organizer tags ────────────────────────────── */
#orgList {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 4px;
}

.org-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--accent);
    color: #fff;
    border-radius: 20px;
    padding: 4px 10px 4px 12px;
    font-size: 13px;
    font-weight: 500;
}

.org-tag-remove {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    color: #fff;
    opacity: .75;
    line-height: 1;
    display: flex;
    align-items: center;
}
.org-tag-remove:hover { opacity: 1; }

.org-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 200;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,.12);
    min-width: 280px;
    max-height: 220px;
    overflow-y: auto;
}

.org-dropdown-item {
    padding: 8px 14px;
    font-size: 13px;
    cursor: pointer;
    color: var(--text);
}
.org-dropdown-item:hover { background: var(--surface-2); }

/* ── Form actions bar ──────────────────────────── */
.form-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 0 32px;
}

/* ── Admin toast ───────────────────────────────── */
.admin-toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 13px;
    font-weight: 500;
}

.admin-toast-success {
    background: rgba(34,197,94,.1);
    border: 1px solid rgba(34,197,94,.3);
    color: #16a34a;
}

[data-theme="dark"] .admin-toast-success { color: #4ade80; }

/* ── Announcement banner ───────────────────────── */
.announcement-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    font-size: 13px;
    font-weight: 500;
}
.announcement-info    { background: rgba(59,130,246,.1); border-bottom: 1px solid rgba(59,130,246,.2); color: #1d4ed8; }
.announcement-warning { background: rgba(249,115,22,.1);  border-bottom: 1px solid rgba(249,115,22,.2);  color: #c2410c; }
.announcement-success { background: rgba(34,197,94,.1);   border-bottom: 1px solid rgba(34,197,94,.2);   color: #15803d; }
[data-theme="dark"] .announcement-info    { color: #93c5fd; }
[data-theme="dark"] .announcement-warning { color: #fdba74; }
[data-theme="dark"] .announcement-success { color: #86efac; }

/* ── Featured race rows (Manager Panel) ────────── */
.featured-race-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    background: var(--surface-alt);
}
.featured-race-row--active {
    background: rgba(249, 115, 22, 0.08);
}
[data-theme="dark"] .featured-race-row--active {
    background: rgba(249, 115, 22, 0.12);
}

/* ── Toggle switch ─────────────────────────────── */
.toggle-switch { position: relative; display: inline-flex; align-items: center; cursor: pointer; }
.toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-slider {
    width: 40px; height: 22px;
    background: var(--border);
    border-radius: 11px;
    transition: background .2s;
    position: relative;
}
.toggle-slider::after {
    content: '';
    position: absolute;
    top: 3px; left: 3px;
    width: 16px; height: 16px;
    background: #fff;
    border-radius: 50%;
    transition: transform .2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--accent); }
.toggle-switch input:checked + .toggle-slider::after { transform: translateX(18px); }

/* ── Delete confirm modal ──────────────────────── */
.delete-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn .15s ease;
}

.delete-modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 32px;
    max-width: 420px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
}

.delete-modal-icon {
    width: 48px; height: 48px;
    background: rgba(239,68,68,.1);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #ef4444;
    margin-bottom: 16px;
}

.delete-modal h3 { font-size: 16px; font-weight: 700; margin: 0 0 8px; }
.delete-modal p  { font-size: 13px; color: var(--text-muted); margin: 0 0 22px; line-height: 1.5; }

.delete-modal-actions { display: flex; gap: 10px; }

@media (max-width: 768px) {
    .form-grid { grid-template-columns: 1fr; }
    .form-group.full { grid-column: unset; }
}

/* ═══════════════════════════════════════════════════════════════
   AUTH PAGES
   ═══════════════════════════════════════════════════════════════ */

.auth-body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    font-family: 'Inter', sans-serif;
    padding: 24px;
}

.auth-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 16px;
    padding: 12px 24px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    z-index: 10;
}

/* Override sidebar-specific white colors for auth topbar context */
.auth-topbar .lang-switcher { padding: 0; }
.auth-topbar .lang-label { color: var(--text-muted); }
.auth-topbar .lang-btn {
    border-color: var(--border);
    color: var(--text-muted);
}
.auth-topbar .lang-btn:hover,
.auth-topbar .lang-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.auth-topbar .theme-toggle {
    padding: 0;
    color: var(--text-muted);
}
.auth-topbar .theme-toggle:hover { color: var(--text); }
.auth-topbar .toggle-track { background: var(--border); }

.auth-container {
    width: 100%;
    max-width: 420px;
}

.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 36px 32px;
    box-shadow: 0 4px 24px rgba(0,0,0,.08);
}

.auth-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 24px;
}

.auth-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 6px;
}

.auth-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin: 0 0 22px;
    line-height: 1.5;
}

.btn-google {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s, border-color .15s;
    font-family: 'Inter', sans-serif;
}
.btn-google:hover { background: var(--bg-hover); border-color: var(--text-muted); }

.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 18px 0;
    color: var(--text-muted);
    font-size: 12px;
}
.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.auth-field {
    margin-bottom: 14px;
}

.auth-field-error {
    display: block;
    font-size: 11px;
    color: #ef4444;
    margin-top: 3px;
}

.auth-error {
    background: rgba(239,68,68,.08);
    border: 1px solid rgba(239,68,68,.2);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    color: #ef4444;
    margin-bottom: 14px;
}
.auth-error:empty { display: none; }

.auth-remember {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
    color: var(--text-muted);
}

.auth-switch {
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
    margin: 18px 0 0;
}
.auth-switch a { color: var(--accent); font-weight: 500; text-decoration: none; }
.auth-switch a:hover { text-decoration: underline; }

/* ═══════════════════════════════════════════════════════════════
   USER MENU (topbar)
   ═══════════════════════════════════════════════════════════════ */

.user-menu { position: relative; }

.user-menu-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px 5px 5px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 999px;
    cursor: pointer;
    color: var(--text);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 500;
    transition: background .15s, border-color .15s;
}
.user-menu-trigger:hover { background: var(--bg-hover); }

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.user-avatar-initials {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
}

.user-name {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-menu-panel {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 220px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,.12);
    z-index: 200;
    overflow: hidden;
}
.user-menu-panel.open { display: block; }

.user-menu-header {
    padding: 14px 16px 12px;
}
.user-menu-name  { font-size: 13px; font-weight: 600; color: var(--text); }
.user-menu-email { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.user-menu-divider { height: 1px; background: var(--border); }

.user-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 16px;
    font-size: 13px;
    color: var(--text);
    text-decoration: none;
    background: transparent;
    border: none;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    transition: background .12s;
    text-align: left;
}
.user-menu-item:hover { background: var(--bg-hover); }
.user-menu-logout { color: #ef4444; }
.user-menu-logout:hover { background: rgba(239,68,68,.08); }

/* ═══════════════════════════════════════════════════════════
   Monthly Calendar
   ═══════════════════════════════════════════════════════════ */

.cal-month-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

/* 7-column grid */
.cal-month-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 20px;
}

/* Day-of-week headers */
.cal-month-day-hdr {
    background: var(--surface-2);
    padding: 8px 6px;
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .05em;
}

/* Each day cell */
.cal-month-cell {
    background: var(--surface);
    padding: 8px 6px;
    min-height: 96px;
    vertical-align: top;
    transition: background .12s;
}

.cal-month-cell.cal-empty {
    background: var(--bg-secondary);
}

.cal-month-cell.cal-past {
    opacity: .65;
}

.cal-month-cell.cal-today {
    background: color-mix(in srgb, var(--accent) 6%, var(--surface));
}

.cal-month-cell.cal-has-races {
    cursor: default;
}

/* Day number */
.cal-cell-num {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 5px;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.cal-cell-num-today {
    background: var(--accent);
    color: #fff;
}

/* Event chips */
.cal-event {
    display: block;
    padding: 2px 5px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 500;
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-decoration: none;
    transition: opacity .15s;
    cursor: pointer;
}

.cal-event:hover { opacity: .78; }

.cal-event-cancelled {
    text-decoration: line-through;
    opacity: .55;
}

/* Use same palette as the badges */
.cal-event-road     { background: #dbeafe; color: #1d4ed8; }
.cal-event-trail    { background: #dcfce7; color: #15803d; }
.cal-event-ultra    { background: #fce7f3; color: #9d174d; }
.cal-event-vertical { background: #f3e8ff; color: #7e22ce; }
.cal-event-ocr      { background: #ffedd5; color: #c2410c; }
.cal-event-kids     { background: #fef9c3; color: #a16207; }

[data-theme="dark"] .cal-event-road     { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .cal-event-trail    { background: #14532d; color: #86efac; }
[data-theme="dark"] .cal-event-ultra    { background: #500724; color: #f9a8d4; }
[data-theme="dark"] .cal-event-vertical { background: #3b0764; color: #d8b4fe; }
[data-theme="dark"] .cal-event-ocr      { background: #431407; color: #fdba74; }
[data-theme="dark"] .cal-event-kids     { background: #422006; color: #fde68a; }

/* "+N more" indicator */
.cal-event-more {
    font-size: 11px;
    color: var(--text-muted);
    padding: 1px 4px;
    font-weight: 500;
}

/* Legend row */
.cal-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 20px;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.cal-legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Mobile: compress cells */
@media (max-width: 640px) {
    .cal-month-cell { min-height: 60px; padding: 4px 3px; }
    .cal-event { font-size: 10px; padding: 1px 3px; }
    .cal-cell-num { font-size: 11px; width: 18px; height: 18px; }
    .cal-month-day-hdr { font-size: 10px; padding: 6px 2px; }
}

/* ═══════════════════════════════════════
   Map View
   ═══════════════════════════════════════ */

.map-page {
    padding: 20px 32px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow: hidden;
}

.map-header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    flex-shrink: 0;
}

.map-filter-bar {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
    flex-shrink: 0;
}

.map-filter-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border-radius: 20px;
    border: 1.5px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
}

.map-filter-btn:hover:not(.active) {
    border-color: var(--dot-color, var(--accent));
    color: var(--text);
}

.map-filter-btn.active {
    background: var(--dot-color, var(--accent));
    border-color: var(--dot-color, var(--accent));
    color: #fff;
}

.map-filter-btn.active .map-filter-dot {
    background: rgba(255,255,255,0.55) !important;
}

.map-filter-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.map-container {
    flex: 1;
    min-height: 0; /* required so flex child can shrink */
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
    box-shadow: var(--card-shadow);
}

/* Leaflet popup override */
.leaflet-popup-content-wrapper {
    border-radius: var(--radius-sm) !important;
    box-shadow: var(--card-shadow-hover) !important;
    border: 1px solid var(--border);
    font-family: 'Inter', sans-serif;
    padding: 0 !important;
    overflow: hidden;
}

.leaflet-popup-content {
    margin: 0 !important;
    width: auto !important;
    min-width: 200px;
}

.leaflet-popup-tip-container { display: none; }

.map-popup {
    padding: 14px 16px;
}

.map-popup-type {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.map-popup-title {
    font-size: 14px;
    font-weight: 700;
    color: #1a202c;
    margin-bottom: 6px;
    line-height: 1.3;
}

.map-popup-meta {
    font-size: 12px;
    color: #64748b;
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 10px;
}

.map-popup-link {
    display: inline-block;
    font-size: 12px;
    font-weight: 600;
    color: #f97316;
    text-decoration: none;
}

.map-popup-link:hover { text-decoration: underline; }

.map-popup-cancelled {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: #ef4444;
    margin-bottom: 4px;
}

/* Custom marker */
.map-marker-div {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2.5px solid rgba(255,255,255,0.95);
    box-shadow: 0 1px 5px rgba(0,0,0,0.35);
    cursor: pointer;
    transition: transform 0.1s;
}

.map-marker-div:hover { transform: scale(1.35); }

.map-count-label {
    font-size: 13px;
    color: var(--text-muted);
}

@media (max-width: 768px) {
    .map-page { padding: 12px 16px 8px; gap: 8px; }
    .map-filter-bar { gap: 4px; }
    .map-filter-btn { padding: 4px 10px; font-size: 11px; }
}
