/* =====================================================
   FestScorePro – Design System
   Stack: Django + Bootstrap 5 + Bootstrap Icons
   Font:  Inter (Google Fonts)
   ===================================================== */

/* ── Design Tokens ─────────────────────────────────── */
:root {
    --primary:          #4361ee;
    --primary-dark:     #2d46c9;
    --primary-light:    #eef1fd;
    --secondary:        #7209b7;
    --success:          #06d6a0;
    --success-dark:     #0ab08d;
    --warning:          #ffd166;
    --warning-dark:     #e8a317;
    --danger:           #ef476f;
    --danger-dark:      #c9194e;
    --info:             #118ab2;
    --info-dark:        #0c6a8c;
    --purple:           #7209b7;
    --orange:           #fb8500;
    --teal:             #0cb0a9;

    --text-primary:     #1a1a2e;
    --text-secondary:   #6c757d;
    --text-muted:       #9ca3af;
    --border-color:     #e9ecef;
    --bg-page:          #f0f2f5;
    --bg-card:          #ffffff;

    --sidebar-bg:       #0d1117;
    --sidebar-width:    260px;
    --sidebar-collapsed:70px;
    --topbar-height:    60px;

    --radius-sm:        6px;
    --radius-md:        10px;
    --radius-lg:        14px;
    --radius-xl:        20px;

    --shadow-xs:        0 1px 3px rgba(0,0,0,.06);
    --shadow-sm:        0 2px 8px rgba(0,0,0,.08);
    --shadow-md:        0 4px 20px rgba(0,0,0,.12);
    --shadow-lg:        0 8px 40px rgba(0,0,0,.18);

    --transition:       all .2s ease;
    --transition-fast:  all .15s ease;

    /* Spacing scale (8pt grid) */
    --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
    --sp-5: 20px; --sp-6: 24px; --sp-7: 32px; --sp-8: 48px;

    /* Touch target minimum */
    --touch-min: 44px;
}

/* ── Dark Mode Tokens ──────────────────────────────── */
[data-theme="dark"] {
    --text-primary:     #e2e8f0;
    --text-secondary:   #94a3b8;
    --text-muted:       #64748b;
    --border-color:     #2d3748;
    --bg-page:          #0f1117;
    --bg-card:          #1a1f2e;

    --shadow-xs:        0 1px 3px rgba(0,0,0,.3);
    --shadow-sm:        0 2px 8px rgba(0,0,0,.4);
    --shadow-md:        0 4px 20px rgba(0,0,0,.5);
    --shadow-lg:        0 8px 40px rgba(0,0,0,.6);

    --primary-light:    rgba(67,97,238,.15);
}

/* ── Reset & Base ──────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

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

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 15px;
    line-height: 1.6;
    background: var(--bg-page);
    color: var(--text-primary);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* All interactive elements — remove 300ms tap delay */
a, button, [role="button"], input, select, textarea, label {
    touch-action: manipulation;
}

/* Focus rings — accessibility */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ── Scrollbar ──────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c1c8d0; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* ── Reduced Motion ─────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}

/* ══════════════════════════════════════════════════════
   SIDEBAR
   ══════════════════════════════════════════════════════ */
.sidebar-wrapper {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    position: fixed;
    top: 0; left: 0;
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: width .25s ease, transform .25s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,.28);
    overflow: hidden;
}

.sidebar-wrapper.collapsed { width: var(--sidebar-collapsed); }
.sidebar-wrapper.collapsed .sidebar-brand-text,
.sidebar-wrapper.collapsed .sidebar-menu span,
.sidebar-wrapper.collapsed .sidebar-section-title,
.sidebar-wrapper.collapsed .sidebar-sub { display: none; }
.sidebar-wrapper.collapsed .sidebar-link { justify-content: center; padding: .75rem; }

/* Tooltip on collapsed hover */
.sidebar-wrapper.collapsed .sidebar-item { position: relative; }
.sidebar-wrapper.collapsed .sidebar-item:hover::after {
    content: attr(data-label);
    position: absolute;
    left: calc(var(--sidebar-collapsed) + 8px);
    top: 50%; transform: translateY(-50%);
    background: #1e293b; color: #fff;
    padding: .3rem .65rem; border-radius: var(--radius-sm);
    font-size: .78rem; white-space: nowrap; z-index: 1050;
    pointer-events: none;
}

/* Brand */
.sidebar-brand {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1rem 1.2rem;
    border-bottom: 1px solid rgba(255,255,255,.07);
    min-height: 70px; flex-shrink: 0;
}
.sidebar-brand-link {
    display: flex; align-items: center; gap: .75rem;
    text-decoration: none; color: #fff; min-width: 0;
}
.sidebar-logo { width: 40px; height: 40px; border-radius: 10px; object-fit: cover; flex-shrink: 0; }
.sidebar-logo-placeholder {
    width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; color: #fff;
}
.brand-name { font-size: 1rem; font-weight: 700; color: #fff; letter-spacing: -.2px; display: block; white-space: nowrap; }
.brand-sub  { font-size: .7rem; color: rgba(255,255,255,.45); display: block; letter-spacing: .5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-toggle-btn {
    background: none; border: none; color: rgba(255,255,255,.5);
    font-size: 1.1rem; cursor: pointer; padding: .4rem;
    min-width: var(--touch-min); min-height: var(--touch-min);
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
}
.sidebar-toggle-btn:hover { color: #fff; background: rgba(255,255,255,.08); }

/* Sidebar scroll area */
.sidebar-content {
    flex: 1; overflow-y: auto; overflow-x: hidden; padding: .5rem 0; min-height: 0;
}
.sidebar-content::-webkit-scrollbar { width: 3px; }
.sidebar-content::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 2px; }

.sidebar-menu { list-style: none; padding: 0; margin: 0; }

.sidebar-section-title {
    font-size: .62rem; font-weight: 700; letter-spacing: 1.4px;
    text-transform: uppercase; color: rgba(255,255,255,.25);
    padding: 1.1rem 1.4rem .35rem;
}

.sidebar-item { margin: 1px 8px; border-radius: var(--radius-md); }
.sidebar-item.active { background: rgba(67,97,238,.22); }
.sidebar-item.active .sidebar-link { color: #8ba3ff; }
.sidebar-item.active .sidebar-link i { color: var(--primary); }

.sidebar-link {
    display: flex; align-items: center; gap: .7rem;
    padding: .6rem 1rem;
    border-radius: var(--radius-md);
    color: rgba(255,255,255,.6); text-decoration: none;
    font-size: .855rem; font-weight: 500;
    transition: var(--transition-fast);
    min-height: var(--touch-min);
}
.sidebar-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-link i { font-size: 1rem; width: 20px; text-align: center; flex-shrink: 0; }

/* Badge in sidebar */
.sidebar-link .badge { margin-left: auto; }

/* Sub-menu */
.sidebar-sub { list-style: none; padding: 2px 0 4px 36px; margin: 0; }
.sidebar-sub li { display: flex; align-items: center; border-radius: var(--radius-sm); overflow: hidden; }
.sidebar-sub li:hover { background: rgba(255,255,255,.07); }
.sidebar-sub-link {
    display: flex; align-items: center; gap: 6px; flex: 1;
    padding: 5px 8px; border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    font-size: .8rem; color: rgba(255,255,255,.55);
    text-decoration: none; transition: color .15s;
    min-height: 36px;
}
.sidebar-sub-link:hover { color: #fff; }
.sidebar-sub li.active .sidebar-sub-link { color: #8ba3ff; }
.sidebar-sub-link i { font-size: .85rem; width: 16px; text-align: center; flex-shrink: 0; }
.sidebar-sub-add {
    display: flex; align-items: center; justify-content: center;
    width: 28px; height: 36px; flex-shrink: 0;
    color: rgba(255,255,255,.35); text-decoration: none;
    border-left: 1px solid rgba(255,255,255,.07);
    transition: var(--transition-fast); font-size: .8rem;
}
.sidebar-sub-add:hover { color: #8ba3ff; background: rgba(255,255,255,.1); }
.sidebar-wrapper.collapsed .sidebar-sub { display: none; }

/* Mobile sidebar overlay */
.sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.5); z-index: 1039;
    backdrop-filter: blur(2px);
}
.sidebar-overlay.show { display: block; }

/* ══════════════════════════════════════════════════════
   TOPBAR
   ══════════════════════════════════════════════════════ */
.topbar {
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-xs);
    position: sticky; top: 0; z-index: 900;
    padding: 0 1.25rem;
}
.topbar-fest-badge { font-size: .85rem; font-weight: 600; color: #333; }
.topbar-icon-btn {
    width: 38px; height: 38px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-md); border: 1px solid var(--border-color);
    color: #555; transition: var(--transition-fast);
    text-decoration: none; flex-shrink: 0;
}
.topbar-icon-btn:hover { background: var(--bg-page); color: var(--primary); border-color: var(--primary); }
.topbar-avatar {
    width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-size: .75rem; font-weight: 700;
}
.topbar-user-btn {
    border: 1px solid var(--border-color); border-radius: var(--radius-md);
    background: #fff; color: #333; font-weight: 500;
    height: 40px; padding: .4rem .9rem;
    transition: var(--transition-fast);
    min-height: var(--touch-min);
}
.topbar-user-btn:hover { background: var(--bg-page); border-color: var(--primary); }
.sidebar-toggle-desktop {
    color: #555; padding: .3rem .5rem; border-radius: var(--radius-sm);
    min-width: 38px; min-height: 38px;
    display: inline-flex; align-items: center; justify-content: center;
}
.sidebar-toggle-desktop:hover { background: var(--bg-page); color: var(--primary); }

/* ══════════════════════════════════════════════════════
   PAGE CONTENT WRAPPER
   ══════════════════════════════════════════════════════ */
#page-content-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left .25s ease;
}
#page-content-wrapper.expanded { margin-left: var(--sidebar-collapsed); }

/* Content padding */
.page-body { padding: 1.5rem; }

/* ══════════════════════════════════════════════════════
   PAGE HEADER
   ══════════════════════════════════════════════════════ */
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 1.5rem; flex-wrap: wrap; gap: .75rem;
}
.page-header h1 {
    font-size: 1.35rem; font-weight: 700; color: var(--text-primary);
    margin: 0; display: flex; align-items: center; gap: .5rem;
}
.page-header h1 i { color: var(--primary); }

/* ══════════════════════════════════════════════════════
   CARDS
   ══════════════════════════════════════════════════════ */
.card {
    border: none; border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: box-shadow .2s ease;
    background: var(--bg-card);
}
.card:hover { box-shadow: var(--shadow-md); }
.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600; padding: 1rem 1.25rem;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0 !important;
}
.card-footer {
    background: transparent;
    border-top: 1px solid var(--border-color);
    padding: .75rem 1.25rem;
}

/* Stat Cards */
.stat-card {
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.4rem;
    display: flex; align-items: center; gap: 1rem;
    box-shadow: var(--shadow-sm);
    transition: transform .2s ease, box-shadow .2s ease;
    border: none; overflow: hidden; position: relative;
    cursor: default;
}
.stat-card::after {
    content: ''; position: absolute; right: -20px; top: -20px;
    width: 90px; height: 90px; border-radius: 50%;
    background: rgba(255,255,255,.1); pointer-events: none;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card .stat-icon {
    width: 52px; height: 52px; border-radius: 13px; flex-shrink: 0;
    background: rgba(255,255,255,.2);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem; color: #fff;
}
.stat-card .stat-value { font-size: 1.9rem; font-weight: 800; color: #fff; line-height: 1; }
.stat-card .stat-label { font-size: .78rem; color: rgba(255,255,255,.8); font-weight: 500; margin-top: .2rem; }

.stat-primary   { background: linear-gradient(135deg, #4361ee, #2d46c9); }
.stat-secondary { background: linear-gradient(135deg, #6c757d, #495057); }
.stat-success   { background: linear-gradient(135deg, #06d6a0, #0ab08d); }
.stat-warning   { background: linear-gradient(135deg, #ffd166, #e8a317); }
.stat-danger    { background: linear-gradient(135deg, #ef476f, #c9194e); }
.stat-info      { background: linear-gradient(135deg, #118ab2, #0c6a8c); }
.stat-purple    { background: linear-gradient(135deg, #7209b7, #560990); }
.stat-orange    { background: linear-gradient(135deg, #fb8500, #d46e00); }
.stat-teal      { background: linear-gradient(135deg, #0cb0a9, #098b84); }

/* ══════════════════════════════════════════════════════
   TABLES
   ══════════════════════════════════════════════════════ */
.table-card { border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-sm); }

.table { margin-bottom: 0; font-size: .875rem; }
.table thead th {
    background: #f8f9fa; font-size: .74rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .6px;
    color: var(--text-secondary); border-bottom: 2px solid var(--border-color);
    padding: .85rem 1rem; white-space: nowrap;
}
.table td { padding: .8rem 1rem; vertical-align: middle; }
.table tbody tr { transition: background .12s ease; }
.table tbody tr:hover { background: #f8faff; }

/* Always wrap tables for mobile */
.table-responsive { -webkit-overflow-scrolling: touch; }

/* ══════════════════════════════════════════════════════
   FORMS
   ══════════════════════════════════════════════════════ */
.form-control, .form-select {
    border-radius: var(--radius-md);
    border: 1.5px solid #dee2e6;
    font-size: .875rem;
    padding: .6rem .9rem;
    min-height: var(--touch-min);
    transition: border-color .15s ease, box-shadow .15s ease;
    font-family: inherit;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67,97,238,.15);
    outline: none;
}
.form-label {
    font-size: .82rem; font-weight: 600; color: #444; margin-bottom: .4rem;
}
.form-text { font-size: .78rem; }
textarea.form-control { min-height: unset; }

/* ══════════════════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════════════════ */
.btn {
    border-radius: var(--radius-md);
    font-size: .855rem; font-weight: 600;
    padding: .55rem 1.1rem;
    min-height: var(--touch-min);
    transition: var(--transition-fast);
    display: inline-flex; align-items: center; justify-content: center;
    gap: .35rem; font-family: inherit;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-sm {
    padding: .35rem .75rem; font-size: .78rem;
    min-height: 34px; border-radius: var(--radius-sm);
}
.btn-lg { padding: .75rem 1.5rem; font-size: .95rem; min-height: 50px; }
.btn-icon {
    width: 36px; height: 36px; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
}

/* ══════════════════════════════════════════════════════
   BADGES
   ══════════════════════════════════════════════════════ */
.badge { border-radius: var(--radius-sm); font-weight: 600; font-size: .7rem; padding: .32em .6em; }

.badge-upcoming  { background: #e7f0ff; color: #2d46c9; }
.badge-running   { background: #d4f8ed; color: #0a8a6c; }
.badge-completed { background: #e9ecef; color: #555; }
.badge-cancelled { background: #ffe0e6; color: #b91c3e; }
.badge-postponed { background: #fff3cd; color: #856404; }
.badge-published { background: #d4f8ed; color: #0a8a6c; }
.badge-draft     { background: #f0e6ff; color: #6c10a8; }
.badge-locked    { background: #ffe0e6; color: #b91c3e; }

/* ══════════════════════════════════════════════════════
   SEARCH BAR
   ══════════════════════════════════════════════════════ */
.search-bar { position: relative; }
.search-bar input { padding-left: 2.4rem; }
.search-bar .search-icon {
    position: absolute; left: .75rem; top: 50%; transform: translateY(-50%);
    color: #999; pointer-events: none;
}

/* ══════════════════════════════════════════════════════
   EMPTY STATE
   ══════════════════════════════════════════════════════ */
.empty-state {
    text-align: center; padding: 3rem 1.5rem;
    color: var(--text-muted); font-size: .9rem;
}
.empty-state i { font-size: 2.8rem; display: block; margin-bottom: .75rem; opacity: .5; }

/* ══════════════════════════════════════════════════════
   ANIMATIONS
   ══════════════════════════════════════════════════════ */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}
.animate-in { animation: fadeInUp .3s ease both; }
.animate-delay-1 { animation-delay: .05s; }
.animate-delay-2 { animation-delay: .10s; }
.animate-delay-3 { animation-delay: .15s; }
.animate-delay-4 { animation-delay: .20s; }

/* ══════════════════════════════════════════════════════
   UTILITIES
   ══════════════════════════════════════════════════════ */
.color-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.section-divider { border: none; border-top: 1px solid var(--border-color); margin: 1.5rem 0; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.text-primary-color { color: var(--primary) !important; }

/* Progress bar */
.progress { border-radius: 20px; overflow: hidden; }
.progress-bar { border-radius: 20px; transition: width .4s ease; }

/* Team card */
.team-card { border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-sm); transition: var(--transition); }
.team-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.team-card-header { padding: 1rem 1.25rem; color: #fff; }
.team-card-body { padding: 1rem 1.25rem; background: #fff; }

/* ══════════════════════════════════════════════════════
   DROPDOWN IMPROVEMENTS
   ══════════════════════════════════════════════════════ */
.dropdown-menu {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: .4rem;
    font-size: .875rem;
}
.dropdown-item {
    border-radius: var(--radius-sm);
    padding: .5rem .85rem;
    min-height: 38px;
    display: flex; align-items: center;
    transition: var(--transition-fast);
}
.dropdown-item:hover { background: var(--primary-light); color: var(--primary); }
.dropdown-divider { margin: .35rem 0; }

/* ══════════════════════════════════════════════════════
   MODALS
   ══════════════════════════════════════════════════════ */
.modal-content { border: none; border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); }
.modal-header { border-bottom: 1px solid var(--border-color); padding: 1.25rem 1.5rem; }
.modal-footer { border-top: 1px solid var(--border-color); padding: 1rem 1.5rem; }

/* ══════════════════════════════════════════════════════
   ALERTS
   ══════════════════════════════════════════════════════ */
.alert { border-radius: var(--radius-md); border: none; font-size: .875rem; }
.alert-primary { background: var(--primary-light); color: var(--primary-dark); }

/* ══════════════════════════════════════════════════════
   TOAST (messages)
   ══════════════════════════════════════════════════════ */
.toast {
    border-radius: var(--radius-md) !important;
    box-shadow: var(--shadow-md) !important;
    min-width: 280px;
    font-size: .875rem;
}
.toast-body { padding: .75rem 1rem; }

/* ══════════════════════════════════════════════════════
   RESPONSIVE — Tablet (≤991px)
   ══════════════════════════════════════════════════════ */
@media (max-width: 991.98px) {
    .sidebar-wrapper {
        transform: translateX(-100%);
        z-index: 1045;
    }
    .sidebar-wrapper.mobile-open {
        transform: translateX(0);
        box-shadow: 8px 0 32px rgba(0,0,0,.4);
    }
    #page-content-wrapper {
        margin-left: 0 !important;
    }
    .topbar { padding: 0 1rem; }
    .page-body { padding: 1rem; }
    .page-header h1 { font-size: 1.2rem; }
}

/* ══════════════════════════════════════════════════════
   RESPONSIVE — Mobile (≤575px)
   ══════════════════════════════════════════════════════ */
@media (max-width: 575.98px) {
    body { font-size: 14px; }

    .page-body { padding: .6rem; }

    /* Tighten Bootstrap row gutter so 3-col layouts don't bleed past page edges */
    .row { --bs-gutter-x: .5rem; }

    /* Category/group pills strip — wrap and shrink on mobile */
    .group-pill-strip { gap: .35rem !important; }
    .group-pill-strip .card { min-width: 72px !important; padding: .35rem .6rem !important; }
    .group-pill-strip .fw-900 { font-size: 1rem !important; }

    .page-header { margin-bottom: 1rem; gap: .5rem; }
    .page-header h1 { font-size: 1.05rem; }

    /* Page header buttons — smaller, wrap naturally */
    .page-header .btn  { font-size: .72rem; padding: .35rem .65rem; min-height: 36px; }
    .page-header .btn-sm { font-size: .7rem; padding: .28rem .55rem; min-height: 32px; }
    .page-header .dropdown-toggle { font-size: .72rem; padding: .35rem .65rem; min-height: 36px; }

    /* Stat cards — compact on mobile */
    .stat-card { padding: .75rem .85rem; gap: .6rem; }
    .stat-card .stat-icon { width: 38px; height: 38px; font-size: 1.1rem; border-radius: 9px; }
    .stat-card .stat-value { font-size: 1.45rem; }
    .stat-card .stat-label { font-size: .67rem; }

    /* Result number in dashboard mini-cards */
    .result-num { font-size: 1.5rem; }

    /* Cards */
    .card-header { padding: .7rem .9rem; font-size: .85rem; }
    .card-body { padding: .85rem; }

    /* Tables — all pages */
    .table { font-size: .78rem; }
    .table thead th { padding: .55rem .6rem; font-size: .65rem; }
    .table td { padding: .55rem .6rem; }

    /* Wrap long text in table cells */
    .table td { word-break: break-word; }

    /* Forms — 16px prevents iOS auto-zoom */
    .form-control, .form-select { font-size: 16px; }

    /* Buttons — global */
    .btn { font-size: .78rem; }
    .btn-sm { font-size: .7rem; min-height: 32px; }
    .btn-icon { width: 32px; height: 32px; }

    /* Hide topbar fest name on very small screens */
    .topbar-fest-badge { display: none; }

    /* Toast — full width on mobile */
    .toast { min-width: calc(100vw - 2rem) !important; }

    /* Modal — full width on mobile */
    .modal-dialog { margin: .5rem; }

    /* Alert — tighter on mobile */
    .alert { font-size: .8rem; padding: .65rem .9rem; }

    /* Badge — readable size */
    .badge { font-size: .65rem; }

    /* Dropdown menu — full usable width */
    .dropdown-menu { min-width: 160px; font-size: .8rem; }

    /* Filter grids used across pages — 2 columns on mobile */
    .filter-grid { grid-template-columns: 1fr 1fr !important; gap: .4rem !important; }
    .filter-search-full { grid-column: 1 / -1; }

    /* Input groups in filter bars */
    .input-group .form-control { font-size: 16px; }

    /* Page-header — ensure title takes full row, buttons wrap below */
    .page-header { flex-wrap: wrap; }
    .page-header h1 { width: 100%; }

    /* Progress bars */
    .progress { height: 5px !important; }

    /* Schedule table: hide less-important columns */
    .sched-hide-mobile { display: none !important; }

    /* Form pages — remove excess padding */
    .card .card-body .row .col-md-6,
    .card .card-body .row .col-md-4,
    .card .card-body .row .col-md-8 { padding-left: .5rem; padding-right: .5rem; }
}

/* ══════════════════════════════════════════════════════
   RESPONSIVE — Large desktop (≥1400px)
   ══════════════════════════════════════════════════════ */
@media (min-width: 1400px) {
    .page-body { padding: 1.75rem 2rem; }
}

/* ══════════════════════════════════════════════════════
   DARK MODE — Component overrides
   ══════════════════════════════════════════════════════ */
[data-theme="dark"] body {
    background: var(--bg-page);
    color: var(--text-primary);
}

/* Topbar */
[data-theme="dark"] .topbar {
    background: #141824;
    border-bottom-color: var(--border-color);
}
[data-theme="dark"] .topbar-icon-btn {
    background: #1e2536;
    border-color: var(--border-color);
    color: var(--text-secondary);
}
[data-theme="dark"] .topbar-icon-btn:hover {
    background: #252d42;
    color: var(--primary);
    border-color: var(--primary);
}
[data-theme="dark"] .topbar-user-btn {
    background: #1e2536;
    border-color: var(--border-color);
    color: var(--text-primary);
}
[data-theme="dark"] .topbar-user-btn:hover { background: #252d42; }
[data-theme="dark"] .sidebar-toggle-desktop { color: var(--text-secondary); }
[data-theme="dark"] .sidebar-toggle-desktop:hover { background: #1e2536; color: var(--primary); }

/* Cards */
[data-theme="dark"] .card {
    background: var(--bg-card);
    border-color: var(--border-color);
}
[data-theme="dark"] .card-header {
    background: transparent;
    border-bottom-color: var(--border-color);
    color: var(--text-primary);
}
[data-theme="dark"] .card-footer {
    background: transparent;
    border-top-color: var(--border-color);
}

/* Tables — override Bootstrap's own --bs-table-* tokens */
[data-theme="dark"] .table {
    --bs-table-bg:            #1a1f2e;
    --bs-table-striped-bg:    rgba(255,255,255,.025);
    --bs-table-hover-bg:      rgba(255,255,255,.04);
    --bs-table-border-color:  #2d3748;
    --bs-table-color:         var(--text-primary);
    --bs-table-striped-color: var(--text-primary);
    --bs-table-hover-color:   var(--text-primary);
    color: var(--text-primary);
    border-color: var(--border-color);
}
[data-theme="dark"] .table thead th {
    background: #1e2536;
    color: var(--text-secondary);
    border-bottom-color: var(--border-color);
}
[data-theme="dark"] .table td,
[data-theme="dark"] .table th { border-color: var(--border-color); }

/* Forms */
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
    background: #1e2536;
    border-color: #374151;
    color: var(--text-primary);
}
[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
    background: #1e2536;
    border-color: var(--primary);
    color: var(--text-primary);
}
[data-theme="dark"] .form-control::placeholder { color: var(--text-muted); }
[data-theme="dark"] .form-label { color: #cbd5e1; }
[data-theme="dark"] .form-select option { background: #1e2536; }
[data-theme="dark"] .input-group-text {
    background: #252d42;
    border-color: #374151;
    color: var(--text-secondary);
}

/* Buttons */
[data-theme="dark"] .btn-light {
    background: #1e2536;
    border-color: var(--border-color);
    color: var(--text-primary);
}
[data-theme="dark"] .btn-light:hover {
    background: #252d42;
    color: var(--text-primary);
}
[data-theme="dark"] .btn-outline-secondary {
    border-color: #374151;
    color: var(--text-secondary);
}
[data-theme="dark"] .btn-outline-secondary:hover {
    background: #1e2536;
    color: var(--text-primary);
}

/* Dropdown */
[data-theme="dark"] .dropdown-menu {
    background: #1a1f2e;
    border-color: var(--border-color);
}
[data-theme="dark"] .dropdown-item { color: var(--text-primary); }
[data-theme="dark"] .dropdown-item:hover { background: rgba(255,255,255,.06); color: #fff; }
[data-theme="dark"] .dropdown-divider { border-color: var(--border-color); }
[data-theme="dark"] .dropdown-header { color: var(--text-muted); }

/* Modals */
[data-theme="dark"] .modal-content {
    background: #1a1f2e;
    color: var(--text-primary);
}
[data-theme="dark"] .modal-header { border-bottom-color: var(--border-color); }
[data-theme="dark"] .modal-footer { border-top-color: var(--border-color); }
[data-theme="dark"] .btn-close { filter: invert(1); }

/* Alerts */
[data-theme="dark"] .alert-primary { background: rgba(67,97,238,.2); color: #8ba3ff; }
[data-theme="dark"] .alert-success  { background: rgba(6,214,160,.15); color: #5ff5cc; }
[data-theme="dark"] .alert-warning  { background: rgba(255,209,102,.15); color: #ffd166; }
[data-theme="dark"] .alert-danger   { background: rgba(239,71,111,.15); color: #ff8fa7; }
[data-theme="dark"] .alert-info     { background: rgba(17,138,178,.15); color: #5ac8e8; }

/* Badges */
[data-theme="dark"] .badge-upcoming  { background: rgba(67,97,238,.25); color: #8ba3ff; }
[data-theme="dark"] .badge-running   { background: rgba(6,214,160,.2);  color: #5ff5cc; }
[data-theme="dark"] .badge-completed { background: rgba(255,255,255,.08); color: #94a3b8; }
[data-theme="dark"] .badge-published { background: rgba(6,214,160,.2);  color: #5ff5cc; }
[data-theme="dark"] .badge-draft     { background: rgba(114,9,183,.2);  color: #c084fc; }
[data-theme="dark"] .badge-locked    { background: rgba(239,71,111,.2); color: #ff8fa7; }

/* Page header */
[data-theme="dark"] .page-header h1 { color: var(--text-primary); }

/* Misc Bootstrap */
[data-theme="dark"] .text-muted { color: var(--text-muted) !important; }
[data-theme="dark"] .border      { border-color: var(--border-color) !important; }
[data-theme="dark"] .border-bottom { border-bottom-color: var(--border-color) !important; }
[data-theme="dark"] hr { border-color: var(--border-color); }
[data-theme="dark"] .nav-tabs { border-bottom-color: var(--border-color); }
[data-theme="dark"] .nav-tabs .nav-link { color: var(--text-secondary); }
[data-theme="dark"] .nav-tabs .nav-link.active {
    background: var(--bg-card); border-color: var(--border-color);
    border-bottom-color: var(--bg-card); color: var(--primary);
}
[data-theme="dark"] .list-group-item {
    background: var(--bg-card);
    border-color: var(--border-color);
    color: var(--text-primary);
}
[data-theme="dark"] .breadcrumb-item { color: var(--text-secondary); }
[data-theme="dark"] .breadcrumb-item.active { color: var(--text-muted); }
[data-theme="dark"] .pagination .page-link {
    background: var(--bg-card);
    border-color: var(--border-color);
    color: var(--text-primary);
}
[data-theme="dark"] .pagination .page-item.active .page-link { background: var(--primary); border-color: var(--primary); }

/* Dashboard-specific */
.live-banner {
    border-left: 4px solid var(--warning);
    background: #fffbf0;
}
.live-program-chip {
    background: #fff;
    border: 1px solid #ffe0a0;
}
.table-footer-row { background: #f8f9fa; }
.table-footer-row td { font-size: .8rem; font-weight: 700; }

[data-theme="dark"] .live-banner { background: rgba(255,209,102,.07); border-left-color: var(--warning); }
[data-theme="dark"] .live-program-chip { background: #1e2536; border-color: rgba(255,209,102,.25); }
[data-theme="dark"] .table-footer-row { background: #1e2536; }
[data-theme="dark"] .table-footer-row td { color: var(--text-primary); }

/* border-bottom in dark mode (top teams / recent results rows) */
[data-theme="dark"] .border-bottom { border-bottom-color: var(--border-color) !important; }

/* Theme toggle button */
.theme-toggle-btn {
    display: flex; align-items: center; justify-content: center;
    width: 38px; height: 38px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: transparent;
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition-fast);
    font-size: 1.05rem;
}
.theme-toggle-btn:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }
[data-theme="dark"] .theme-toggle-btn { background: #1e2536; border-color: var(--border-color); color: #fbbf24; }
[data-theme="dark"] .theme-toggle-btn:hover { background: #252d42; border-color: #fbbf24; color: #fbbf24; }
