/* One – Redesigned UI */
@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;500;600;700;800;900&display=swap');

:root {
    --bg:           #f7f6f3;
    --bg2:          #edecea;
    --bg3:          #ffffff;
    --bg4:          #e4e2dc;
    --border:       #e2dfd8;
    --border-focus: #3b82f6;

    --primary:      #3b82f6;
    --primary-dark: #2563eb;
    --primary-light:#eff6ff;
    --primary-glow: rgba(59,130,246,0.12);

    --success:      #16a34a;
    --success-bg:   rgba(22,163,74,0.08);
    --warning:      #d97706;
    --warning-bg:   rgba(217,119,6,0.08);
    --danger:       #dc2626;
    --danger-bg:    rgba(220,38,38,0.08);
    --info:         #0891b2;
    --info-bg:      rgba(8,145,178,0.08);

    --text:         #1a1714;
    --text-muted:   #6b6560;
    --text-light:   #a8a29e;

    --sidebar-w:    260px;
    --header-h:     60px;
    --radius:       8px;
    --radius-sm:    6px;
    --radius-lg:    10px;
    --radius-xl:    12px;
    --shadow-sm:    0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
    --shadow:       0 2px 10px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.05);
    --shadow-lg:    0 8px 24px rgba(0,0,0,0.10), 0 2px 8px rgba(0,0,0,0.06);
    --transition:   0.18s ease;

    --btn-h:        38px;
    --btn-h-sm:     30px;
    --btn-h-lg:     46px;
}

/* ===== DARK MODE ===== */
[data-theme="dark"] {
    --bg:           #1c1c1e;
    --bg2:          #242426;
    --bg3:          #2c2c2e;
    --bg4:          #323234;
    --border:       #3a3a3c;
    --border-focus: #60a5fa;

    --primary-light:#1e3a5f;
    --primary-glow: rgba(59,130,246,0.18);

    --success-bg:   rgba(22,163,74,0.15);
    --warning-bg:   rgba(217,119,6,0.15);
    --danger-bg:    rgba(220,38,38,0.15);
    --info-bg:      rgba(8,145,178,0.15);

    --text:         #f0efed;
    --text-muted:   #9a9590;
    --text-light:   #6b6560;

    --shadow-sm:    0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
    --shadow:       0 2px 10px rgba(0,0,0,0.35), 0 1px 3px rgba(0,0,0,0.2);
    --shadow-lg:    0 8px 24px rgba(0,0,0,0.4), 0 2px 8px rgba(0,0,0,0.25);
}

[data-theme="dark"] .af-logo img { filter: invert(1); }

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

body {
    font-family: 'Syne', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.55;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* ===== HEADER ===== */
.af-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--header-h);
    background: var(--bg3);
    border-bottom: 1px solid rgba(0,0,0,0.07);
    display: flex;
    align-items: center;
    padding: 0 22px;
    z-index: 100;
    gap: 16px;
    box-shadow: 0 1px 6px rgba(0,0,0,0.04);
}

.af-logo {
    font-size: 18px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.6px;
    white-space: nowrap;
}
.af-logo span { color: var(--primary); }

.af-header-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
}
.af-header-right { margin-left: auto; }

.af-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.af-top-nav {
    display: flex;
    align-items: center;
    gap: 4px;
}
.af-nav-toggle { display: none !important; }
.af-nav-tournament-info {
    display: flex;
    align-items: center;
    gap: 6px;
}
.af-nav-items {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    gap: 4px;
}

.af-top-nav-item {
    padding: 6px 14px;
    border-radius: 100px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    transition: var(--transition);
}
.af-top-nav-item:hover { color: var(--text); background: var(--bg2); }
.af-top-nav-item.active { color: var(--primary); background: var(--primary-light); font-weight: 600; }

.af-avatar-wrap {
    position: relative;
}
.af-avatar-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}
.af-avatar-btn:hover { background: var(--primary-dark); }
.af-user-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    min-width: 160px;
    overflow: hidden;
    z-index: 200;
}
.af-user-dropdown.open { display: block; }
[data-theme="dark"] .af-user-dropdown { background: var(--bg3); border-color: var(--border); }
.af-user-dropdown-name {
    padding: 10px 14px 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    border-bottom: 1px solid var(--border);
}
.af-user-dropdown-logout {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    font-size: 13px;
    color: var(--text-muted);
    text-decoration: none;
    transition: var(--transition);
}
.af-user-dropdown-logout:hover { background: var(--bg2); color: var(--text); }

/* ===== SIDEBAR ===== */
.af-sidebar-hidden { display: none !important; }

.af-sidebar {
    position: fixed;
    top: var(--header-h); left: 0;
    height: calc(100vh - var(--header-h));
    display: flex; flex-direction: row;
    z-index: 90;
    overflow: visible;
}

.af-rail {
    width: var(--header-h); flex-shrink: 0;
    display: flex; flex-direction: column;
    align-items: center;
    padding: 8px 0; gap: 8px;
    background: var(--primary);
    border-right: none;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
    position: relative; z-index: 2;
}
.af-rail::-webkit-scrollbar { display: none; }

.af-rail-btn {
    width: 44px; height: 44px;
    display: flex; align-items: center; justify-content: center;
    border: none; background: none; cursor: pointer;
    border-radius: var(--radius);
    color: #fff;
    transition: var(--transition);
    position: relative; flex-shrink: 0;
}
.af-rail-btn:hover { background: rgba(255,255,255,0.15); color: #fff; }
.af-rail-btn.active { background: rgba(0,0,0,0.18); color: #fff; }
.af-rail-btn.active:hover { background: rgba(0,0,0,0.24); color: #fff; }

.af-rail-tooltip {
    position: absolute;
    left: calc(100% + 10px); top: 50%;
    transform: translateY(-50%);
    background: var(--text); color: var(--bg3);
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    font-size: 12px; font-weight: 600;
    white-space: nowrap; pointer-events: none;
    opacity: 0; transition: opacity 0.12s;
    z-index: 500;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.af-rail-btn:hover .af-rail-tooltip { opacity: 1; }

/* Rail spacer + separator + edit button */
.af-rail-spacer { flex: 1; }
.af-rail-sep-line {
    width: 32px;
    height: 1px;
    background: rgba(255,255,255,0.25);
    margin: 4px 0;
    flex-shrink: 0;
}
.af-rail-edit-btn:hover { background: rgba(255,255,255,0.15); }

/* More (···) button */
.af-rail-more-wrap { position: relative; }
.af-rail-more-btn svg { display: block; }
.af-rail-more-flyout {
    display: none;
    position: fixed;
    background: var(--bg3);
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 20px rgba(0,0,0,0.12);
    min-width: 180px;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    padding: 6px;
    z-index: 1100;
    flex-direction: column;
    gap: 2px;
}
.af-rail-more-flyout.open { display: flex; }
.af-rail-flyout-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: var(--radius);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    width: 100%;
    text-align: left;
    transition: var(--transition);
}
.af-rail-flyout-btn:hover { background: var(--bg2); color: var(--text); }
.af-rail-flyout-btn.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }

/* Nav editor modal */
.nav-editor-body { overflow-y: auto; flex: 1; }
.nav-editor-hint {
    font-size: 11px; color: var(--text-muted);
    margin: 0 0 10px; text-align: center;
}
.nav-editor-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.nav-editor-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 10px;
    background: var(--bg);
    border-radius: var(--radius);
    cursor: default;
    border: 1px solid transparent;
    transition: var(--transition);
    user-select: none;
}
.nav-editor-item.dragging { opacity: 0.35; background: var(--bg2); }
.nav-editor-item.nav-editor-hidden { opacity: 0.45; }
.nav-editor-placeholder { height: 40px; border: 2px dashed var(--primary); border-radius: var(--radius); background: var(--primary-light); margin: 2px 0; }
.nav-editor-handle { cursor: grab; color: var(--text-muted); flex-shrink: 0; }
.nav-editor-handle:active { cursor: grabbing; }
.nav-editor-icon { color: var(--primary); flex-shrink: 0; }
.nav-editor-item.nav-editor-hidden .nav-editor-icon { color: var(--text-muted); }
.nav-editor-label { font-size: 13px; font-weight: 500; color: var(--text); flex: 1; }
.nav-editor-item.nav-editor-hidden .nav-editor-label { color: var(--text-muted); text-decoration: line-through; }
.nav-editor-eye {
    width: 28px; height: 28px;
    display: flex; align-items: center; justify-content: center;
    border: none; background: none; cursor: pointer;
    color: var(--text-muted); border-radius: var(--radius);
    flex-shrink: 0; transition: var(--transition);
}
.nav-editor-eye:hover { background: var(--bg2); color: var(--text); }


/* Subpanel */
.af-subpanel {
    width: 0; overflow: hidden;
    background: var(--bg3);
    box-shadow: 2px 0 8px rgba(0,0,0,0.06);
    height: 100%;
    transition: width 0.2s ease;
    display: flex; flex-direction: column;
    z-index: 1;
}
.af-subpanel.open { width: 200px; overflow-y: auto; }

.af-subpanel-inner {
    width: 200px; padding: 10px 8px;
    flex-shrink: 0;
}
.af-subpanel-title {
    font-size: 10px; font-weight: 700;
    color: var(--primary);
    text-transform: uppercase; letter-spacing: 0.8px;
    padding: 6px 10px 8px; opacity: 0.75;
}

.af-nav-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 12px;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    transition: var(--transition);
    text-decoration: none;
    border-radius: var(--radius-sm);
    margin-bottom: 1px;
}
.af-nav-item svg { opacity: 0.75; flex-shrink: 0; }
.af-nav-item:hover {
    background: var(--bg2);
    color: var(--text);
    text-decoration: none;
}
.af-nav-item:hover svg { opacity: 1; }
.af-nav-item.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}
.af-nav-item.active svg { opacity: 1; }

.af-nav-disabled {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 12px;
    color: var(--border);
    font-size: 13px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: not-allowed;
    margin-bottom: 1px;
    user-select: none;
    opacity: 0.4;
}

/* Legacy */
.af-nav-section { padding: 0; margin-bottom: 4px; }
.af-nav-section-title {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 8px 12px 3px;
}

/* ===== MAIN CONTENT ===== */
.af-page-bar {
    position: fixed;
    top: var(--header-h);
    left: var(--header-h);
    right: 0;
    height: var(--header-h);
    background: var(--primary);
    display: flex;
    align-items: center;
    padding: 0 28px;
    z-index: 89;
    transition: left 0.2s ease;
}
.af-page-bar-title {
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.2px;
}
body.subpanel-open .af-page-bar { left: calc(var(--header-h) + 200px); }
.af-page-bar-no-sidebar { left: 0 !important; }

.af-content {
    margin-left: var(--header-h);
    padding: calc(var(--header-h) * 2 + 28px) 28px 28px;
    transition: margin-left 0.2s ease;
}
.af-content.no-sidebar { margin-left: 0 !important; padding-top: calc(var(--header-h) + 28px); }
/* ===== PAGE HEADER ===== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 14px;
}
.page-title { font-size: 22px; font-weight: 800; color: var(--text); letter-spacing: -0.5px; line-height: 1.2; }
.page-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 3px; }

/* ===== CARDS ===== */
.card {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.card-header {
    padding: 13px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: var(--bg3);
}

.card-title { font-size: 14px; font-weight: 700; color: var(--text); letter-spacing: -0.1px; }
.card-body { padding: 20px; }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: var(--btn-h);
    padding: 0 18px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: 1.5px solid transparent;
    border-radius: var(--radius);
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
    font-family: inherit;
    line-height: 1;
    letter-spacing: -0.1px;
}
.btn:hover { text-decoration: none; }
.btn:active { opacity: 0.88; }

.btn svg { flex-shrink: 0; }

.btn-primary {
    background: var(--primary); color: #fff; border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(37,99,235,0.25);
}
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; box-shadow: 0 4px 14px rgba(37,99,235,0.35); }

.btn-success { background: var(--success); color: #fff; border-color: var(--success); box-shadow: 0 2px 8px rgba(22,163,74,0.25); }
.btn-success:hover { background: #15803d; color: #fff; box-shadow: 0 4px 12px rgba(22,163,74,0.35); }

.btn-warning { background: var(--warning); color: #fff; border-color: var(--warning); box-shadow: 0 2px 8px rgba(217,119,6,0.25); }
.btn-warning:hover { background: #b45309; color: #fff; }

.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); box-shadow: 0 2px 8px rgba(220,38,38,0.25); }
.btn-danger:hover { background: #b91c1c; color: #fff; box-shadow: 0 4px 12px rgba(220,38,38,0.35); }

.btn-info { background: var(--info); color: #fff; border-color: var(--info); }
.btn-info:hover { background: #0e7490; color: #fff; }

.btn-ghost {
    background: var(--bg3);
    color: var(--text-muted);
    border-color: var(--border);
}
.btn-ghost:hover { background: var(--bg2); color: var(--text); border-color: var(--bg4); }

.btn-sm  { height: var(--btn-h-sm); padding: 0 12px; font-size: 12px; border-radius: var(--radius-sm); gap: 5px; }
.btn-lg  { height: var(--btn-h-lg); padding: 0 24px; font-size: 15px; border-radius: var(--radius-lg); }
.btn-icon { width: var(--btn-h); height: var(--btn-h); padding: 0; border-radius: var(--radius); }
.btn-icon.btn-sm { width: var(--btn-h-sm); height: var(--btn-h-sm); border-radius: var(--radius-sm); }

/* ===== FORMS ===== */
.form-group { margin-bottom: 18px; }
.form-label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 6px;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}
.form-control {
    width: 100%;
    height: var(--btn-h);
    background: var(--bg3);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    padding: 0 14px;
    font-size: 14px;
    transition: var(--transition);
    font-family: inherit;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
    background: var(--bg3);
}
.form-control::placeholder { color: var(--text-light); }
select.form-control { cursor: pointer; }
textarea.form-control {
    height: auto;
    padding: 11px 14px;
    min-height: 90px;
    resize: vertical;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    height: var(--btn-h);
}
.form-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary);
    border-radius: 5px;
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row.col3 { grid-template-columns: 1fr 1fr 1fr; }

/* ===== TABLES ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
    background: var(--bg);
    padding: 10px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--bg2); transition: var(--transition); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg); }
tbody td { padding: 11px 16px; color: var(--text); vertical-align: middle; }

.standings-table .rank { font-weight: 800; color: var(--primary); width: 40px; text-align: center; }
.standings-table .team-name { font-weight: 600; }
.standings-table th { text-align: center; }
.standings-table th:nth-child(2) { text-align: left; }
.standings-table td { text-align: center; }
.standings-table td:nth-child(2) { text-align: left; }
.standings-rank-1 td { background: rgba(212,175,55,0.06); }
.standings-rank-2 td { background: rgba(150,150,150,0.04); }
.standings-rank-3 td { background: rgba(176,124,67,0.04); }

/* ===== ALERTS ===== */
.alert {
    padding: 12px 16px;
    margin-bottom: 16px;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    border-radius: var(--radius-sm);
    border: 1.5px solid;
}
.alert-success { background: var(--success-bg); border-color: rgba(22,163,74,0.25); color: #15803d; }
.alert-danger   { background: var(--danger-bg);  border-color: rgba(220,38,38,0.25); color: #b91c1c; }
.alert-warning  { background: var(--warning-bg); border-color: rgba(217,119,6,0.25); color: #92400e; }
.alert-info     { background: var(--info-bg);    border-color: rgba(8,145,178,0.25); color: #0e7490; }

/* ===== BADGES ===== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 700;
    border-radius: 100px;
    border: 1.5px solid;
    white-space: nowrap;
    letter-spacing: 0.2px;
}
.badge-primary { background: var(--primary-light); color: var(--primary); border-color: rgba(37,99,235,0.2); }
.badge-success { background: var(--success-bg); color: var(--success); border-color: rgba(22,163,74,0.2); }
.badge-warning { background: var(--warning-bg); color: var(--warning); border-color: rgba(217,119,6,0.2); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger);  border-color: rgba(220,38,38,0.2); }
.badge-info    { background: var(--info-bg);     color: var(--info);    border-color: rgba(8,145,178,0.2); }
.badge-muted   { background: var(--bg2); color: var(--text-muted); border-color: var(--border); }
.badge-live    { background: var(--danger); color: #fff; border-color: var(--danger); animation: pulse 1.2s infinite; }

@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.55} }

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10,8,6,0.4);
    backdrop-filter: blur(4px);
    z-index: 400;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-overlay.hidden { display: none; }

.modal-box {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 540px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}
.modal-box.wide { max-width: 740px; }

.modal-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: var(--bg3);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}
.modal-title { font-size: 16px; font-weight: 700; letter-spacing: -0.2px; }
.modal-close {
    background: var(--bg2);
    border: 1.5px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    width: var(--btn-h);
    height: var(--btn-h);
    flex-shrink: 0;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}
.modal-close:hover { background: var(--danger-bg); color: var(--danger); border-color: rgba(220,38,38,0.3); }
.modal-close-red {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}
.modal-close-red:hover { background: #b91c1c; border-color: #b91c1c; color: #fff; }
.modal-body { padding: 24px; }
.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background: var(--bg3);
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

/* ===== GRID ===== */
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ===== STAT CARDS ===== */
.stat-card {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow); }
.stat-card .stat-label { font-size: 11px; color: var(--text-muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; }
.stat-card .stat-value { font-size: 30px; font-weight: 800; color: var(--primary); letter-spacing: -1px; line-height: 1.1; }
.stat-card .stat-sub   { font-size: 12px; color: var(--text-muted); }

/* ===== TOURNAMENT CARD ===== */
.tournament-card {
    background: var(--bg3);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.tournament-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow);
}
.tournament-card .tc-color-bar {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.tournament-card .tc-logo {
    width: 48px; height: 48px;
    object-fit: cover;
    border-radius: 10px;
    background: var(--bg4);
}
.tournament-card .tc-logo-placeholder {
    width: 48px; height: 48px;
    background: var(--primary-light);
    border: 1.5px solid rgba(37,99,235,0.2);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
}
.tournament-card .tc-name   { font-size: 16px; font-weight: 700; margin-top: 14px; letter-spacing: -0.3px; }
.tournament-card .tc-dates  { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.tournament-card .tc-actions { margin-top: 16px; display: flex; gap: 8px; flex-wrap: wrap; }

/* ===== DASHBOARD WELCOME ===== */
.db-welcome {
    padding: 4px 0 0;
}
.db-welcome-title {
    font-size: 22px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.5px;
    margin-bottom: 8px;
}
.db-intro-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 20px 0 20px;
}
.db-intro-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    color: var(--text);
}
.db-intro-list li svg { flex-shrink: 0; color: var(--primary); }
.db-new-section { margin-top: 40px; }
.db-two-col { margin-top: 64px; }
.db-archive-section { margin-top: 64px; }
.db-welcome-sub {
    font-size: 14px;
    color: var(--text-muted);
    max-width: 520px;
    line-height: 1.6;
    margin-bottom: 20px;
}

.db-two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
    align-items: start;
}
@media (max-width: 768px) {
    .db-two-col { grid-template-columns: 1fr; }
}
.db-archive-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    color: var(--text);
    font-family: inherit;
}
.db-archive-toggle:hover { color: var(--primary); }
.db-archive-chevron {
    transition: transform .2s;
    color: var(--text-muted);
}
.db-archive-toggle[aria-expanded="true"] .db-archive-chevron {
    transform: rotate(180deg);
}

.t-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.t-section-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

/* ===== TOURNAMENT LIST (dashboard) ===== */
.t-list {
    background: var(--bg3);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: grid;
    grid-template-columns: 1fr auto;
    width: 100%;
}
.t-list-header,
.t-list-row {
    display: contents;
}
.t-list-header > *,
.t-list-row > * {
    display: flex;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.t-list-header > * {
    height: 38px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    background: var(--bg);
    border-bottom: 1.5px solid var(--border);
}
.t-list-row > * {
    height: 52px;
    background: var(--bg3);
    transition: background var(--transition);
}
.t-list-row:hover > * { background: var(--bg2); }
.t-list-row > *:last-child { justify-content: flex-end; }
.t-list-row:last-child > * { border-bottom: none; }
.tl-name { font-size: 14px; font-weight: 600; color: var(--text); }
.tl-dates { font-size: 13px; color: var(--text-muted); }
.tl-status {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 12px;
    font-weight: 600;
}
.tl-status-planned { background: var(--primary-light); color: var(--primary); }
.tl-status-live    { background: var(--success-bg);    color: var(--success); }
.tl-status-past    { background: var(--bg2);           color: var(--text-muted); }
.tl-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ===== GAME CARD ===== */
.game-card {
    background: var(--bg3);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    min-height: 68px;
    gap: 14px;
    transition: all var(--transition);
}
.game-card:hover { background: var(--bg); box-shadow: var(--shadow-sm); }
.game-card.live { border-left: 3px solid var(--danger); background: rgba(220,38,38,0.02); }
.game-card .game-teams {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 12px;
    text-align: center;
}
.game-card .team-name { font-weight: 600; font-size: 14px; }
.game-card .team-name.right { text-align: right; }
.game-card .team-name.left  { text-align: left; }
.game-card .score {
    font-size: 22px;
    font-weight: 800;
    color: var(--primary);
    white-space: nowrap;
    min-width: 64px;
}
.game-card .game-meta    { font-size: 11px; color: var(--text-muted); }
.game-card .game-actions { display: flex; gap: 6px; }
.game-card .gc-time-col  { width: 62px; flex-shrink: 0; text-align: center; }
.game-card .gc-meta-col  { width: 130px; flex-shrink: 0; text-align: center; }

/* ===== DROPDOWN ===== */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
    position: absolute;
    right: 0; top: calc(100% + 6px);
    background: var(--bg3);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    min-width: 174px;
    z-index: 150;
    display: none;
    box-shadow: var(--shadow);
    overflow: hidden;
    padding: 6px;
}
.dropdown-menu.show { display: block; }
.dropdown-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}
.dropdown-item:hover { background: var(--bg2); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-divider { border-top: 1px solid var(--border); margin: 4px 0; }

/* ===== LIVESTREAM ===== */
.livestream-board {
    background: var(--bg3);
    border: 2px solid var(--danger);
    border-radius: var(--radius-xl);
    padding: 36px;
    text-align: center;
    box-shadow: 0 0 30px rgba(220,38,38,0.08);
}
.livestream-live-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--danger);
    color: white;
    padding: 6px 18px;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    border-radius: 100px;
    animation: pulse 1.2s infinite;
    margin-bottom: 24px;
}
.livestream-teams {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 20px;
    margin-bottom: 28px;
}
.livestream-team-name { font-size: 28px; font-weight: 800; line-height: 1.2; letter-spacing: -0.5px; }
.livestream-score {
    font-size: 72px;
    font-weight: 900;
    color: var(--primary);
    line-height: 1;
    padding: 0 24px;
    min-width: 190px;
    text-align: center;
    font-variant-numeric: tabular-nums;
    letter-spacing: -2px;
}
.score-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
}
.score-btn {
    width: 64px;
    height: 46px;
    border: none;
    border-radius: var(--radius);
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
}
.score-btn.plus  { background: var(--success); color: white; box-shadow: 0 2px 8px rgba(22,163,74,0.3); }
.score-btn.plus2 { background: var(--info); color: white; font-size: 13px; }
.score-btn.minus { background: var(--bg2); color: var(--danger); border: 1.5px solid rgba(220,38,38,0.3); font-size: 13px; }
.score-btn:hover { opacity: 0.85; transform: scale(0.97); }

.timer-display {
    font-size: 50px;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
    color: var(--warning);
    margin: 16px 0;
    letter-spacing: -2px;
}
.timer-controls { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ===== KO BRACKET ===== */
.ko-bracket { overflow-x: auto; padding: 14px 0; }
.ko-round { display: flex; flex-direction: column; justify-content: space-around; flex: 1; }
.ko-match {
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    margin: 5px 0;
    min-width: 190px;
    transition: var(--transition);
}
.ko-match:hover { border-color: var(--primary); }
.ko-match .ko-team { padding: 4px 0; font-size: 13px; font-weight: 600; }
.ko-match .ko-team.winner { color: var(--success); }
.ko-bracket-wrap { display: flex; gap: 0; align-items: stretch; }
.ko-round-col { display: flex; flex-direction: column; gap: 8px; min-width: 210px; padding: 0 10px; }
.ko-round-title {
    font-size: 10px; font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.6px;
    margin-bottom: 6px; text-align: center;
}

/* ===== PERMISSIONS ===== */
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.perm-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: var(--transition);
}
.perm-item:hover { border-color: var(--primary); background: var(--primary-light); }
.perm-item input { accent-color: var(--primary); }

/* ===== SECTION BADGES (user roles) ===== */
.sec-badge-0 { display:inline-block;padding:2px 8px;border-radius:100px;font-size:10px;font-weight:700;background:var(--bg2);color:var(--text-light);border:1px solid var(--border); }
.sec-badge-1 { display:inline-block;padding:2px 8px;border-radius:100px;font-size:10px;font-weight:700;background:var(--warning-bg);color:var(--warning);border:1px solid rgba(217,119,6,0.2); }
.sec-badge-2 { display:inline-block;padding:2px 8px;border-radius:100px;font-size:10px;font-weight:700;background:var(--success-bg);color:var(--success);border:1px solid rgba(22,163,74,0.2); }

/* ===== SLOT PLANNER ===== */
.slot-item {
    background: var(--bg3);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: var(--transition);
}
.slot-item:hover { box-shadow: var(--shadow-sm); }
.slot-item.pause { border-left: 3px solid var(--warning); background: rgba(217,119,6,0.02); }
.slot-time { font-size: 17px; font-weight: 700; color: var(--primary); min-width: 58px; font-variant-numeric: tabular-nums; }
.slot-info { flex: 1; }
.slot-actions { display: flex; gap: 6px; }

/* ===== COLOR INPUT ===== */
input[type="color"] {
    -webkit-appearance: none;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    width: 46px;
    height: var(--btn-h);
    cursor: pointer;
    background: none;
    padding: 3px;
    transition: var(--transition);
}
input[type="color"]:hover { border-color: var(--primary); }
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 6px; }

/* ===== TABS ===== */
.tabs { display: flex; border-bottom: 1.5px solid var(--border); margin-bottom: 22px; gap: 2px; }
.tab {
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    border: none;
    background: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1.5px;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    transition: var(--transition);
    font-family: inherit;
}
.tab:hover { color: var(--text); background: var(--bg2); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); background: var(--primary-light); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===== GROUP FILTER (tables.php) ===== */
.group-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
    align-items: center;
}
.group-filter-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-right: 4px;
}
.group-filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 14px;
    font-size: 12px;
    font-weight: 600;
    border: 1.5px solid var(--border);
    border-radius: 100px;
    background: var(--bg3);
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}
.group-filter-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.group-filter-btn.active { border-color: var(--primary); color: var(--primary); background: var(--primary-light); font-weight: 700; }

/* ===== MISC ===== */
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.text-muted   { color: var(--text-muted); }
.text-danger  { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-primary { color: var(--primary); }
.fw-bold { font-weight: 700; }
.mt-0  { margin-top: 0; }
.mb-0  { margin-bottom: 0; }
.mb-4  { margin-bottom: 16px; }
.mb-6  { margin-bottom: 24px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }

.empty-state {
    text-align: center;
    padding: 64px 20px;
    color: var(--text-muted);
}
.empty-state .empty-icon {
    font-size: 40px;
    margin-bottom: 16px;
    opacity: 0.25;
    display: block;
    color: var(--primary);
}
.empty-state h3 { font-size: 18px; font-weight: 700; color: var(--text); margin-bottom: 8px; letter-spacing: -0.3px; }
.empty-state p { font-size: 14px; color: var(--text-muted); }

/* ===== LOCKED BANNER ===== */
.locked-banner {
    background: var(--warning-bg);
    border: 1.5px solid rgba(217,119,6,0.25);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 20px;
    color: #92400e;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    font-weight: 500;
}

/* ===== TABLE.PHP ===== */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table thead th {
    background: var(--bg);
    padding: 10px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    border-bottom: 1px solid var(--border);
}
.table tbody tr { border-bottom: 1px solid var(--bg2); transition: var(--transition); }
.table tbody tr:last-child { border-bottom: none; }
.table tbody tr:hover { background: var(--bg); }
.table tbody td { padding: 11px 16px; vertical-align: middle; }

/* ===== RESPONSIVE ===== */

/* Sidebar overlay backdrop */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    left: 44px;
    background: rgba(0,0,0,0.25);
    z-index: 200;
}

@media (max-width: 768px) {
    /* --- Sidebar: kleines Rail immer sichtbar --- */
    .af-sidebar {
        width: 44px;
        overflow: visible;
        z-index: 300; /* Rail über Backdrop (200) */
    }
    .af-rail {
        width: 44px !important;
        overflow-y: auto;
        overflow-x: hidden;
        scrollbar-width: none;
    }
    .af-rail::-webkit-scrollbar { display: none; }
    .af-rail-btn { width: 34px !important; height: 34px !important; }
    .af-rail-sep-line { width: 24px !important; }
    .af-rail-tooltip { display: none !important; }

    /* Offenes Subpanel: über Backdrop, aber Backdrop deckt Inhalt ab */
    .af-subpanel.open {
        position: fixed !important;
        left: 44px !important;
        top: var(--header-h) !important;
        width: 200px !important;
        height: calc(100vh - var(--header-h)) !important;
        overflow-y: auto !important;
        z-index: 250 !important; /* Backdrop 200 < Subpanel 250 < Rail 300 */
        box-shadow: 4px 0 20px rgba(0,0,0,0.12) !important;
    }
    body.subpanel-open .sidebar-backdrop { display: block; }

    /* --- Layout --- */
    .af-page-bar { left: 0; height: 44px; padding: 0 16px 0 58px; }
    body.subpanel-open .af-page-bar { left: 0; }
    .af-content { margin-left: 44px !important; padding: calc(var(--header-h) + 44px + 12px) 14px 32px; }
    .af-content.no-sidebar { margin-left: 0 !important; }
    .af-content.no-sidebar ~ .af-page-bar,
    body:not(.has-tournament) .af-page-bar { left: 0; }
    body.subpanel-open .af-content { margin-left: 44px !important; }

    /* --- Header --- */
    .af-header { padding: 0 14px; gap: 10px; }
    .af-header-center:not(.af-top-nav) { display: none; }
    .af-top-nav { gap: 2px; }
    .af-top-nav-item { padding: 6px 10px; font-size: 13px; }

    /* --- Mobile top nav toggle --- */
    .af-nav-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 38px;
        height: 38px;
        background: none;
        border: none;
        cursor: pointer;
        color: var(--text);
        border-radius: var(--radius);
        transition: background var(--transition);
    }
    .af-nav-toggle:hover { background: var(--bg2); }
    .af-nav-toggle svg { transition: transform .2s; }
    .af-nav-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
    .af-nav-items {
        position: absolute;
        top: var(--header-h);
        left: 0; right: 0;
        transform: none;
        display: none;
        flex-direction: column;
        padding: 8px;
        gap: 4px;
        background: var(--bg3);
        border-bottom: 1.5px solid var(--border);
        box-shadow: 0 4px 16px rgba(0,0,0,0.08);
        z-index: 300;
    }
    .af-nav-items.open { display: flex; }
    .af-nav-items .af-top-nav-item {
        padding: 12px 16px;
        border-radius: var(--radius);
        font-size: 15px;
        width: 100%;
    }
    .af-nav-items .af-nav-tournament-info {
        padding: 10px 16px;
        border-top: 1px solid var(--border);
        width: 100%;
        font-size: 14px;
    }

    /* --- Page header --- */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        margin-bottom: 18px;
    }
    .page-header > a.btn,
    .page-header > button.btn { width: 100%; justify-content: center; }
    .page-title { font-size: 19px; }

    /* --- Cards --- */
    .card-header {
        flex-wrap: wrap;
        gap: 8px;
        padding: 11px 14px;
    }
    .card-body { padding: 14px; }

    /* --- Grids --- */
    .form-row { grid-template-columns: 1fr; }
    .form-row.col3 { grid-template-columns: 1fr; }
    .grid-2 { grid-template-columns: 1fr; }
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
    .grid-4 { grid-template-columns: repeat(2, 1fr); }

    /* --- Buttons --- */
    .btn { height: 40px; }
    .btn-lg { height: 44px; }

    /* --- Tables --- */
    .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    table { min-width: 480px; }
    thead th { padding: 8px 10px; }
    tbody td { padding: 9px 10px; }
    .table thead th { padding: 8px 10px; }
    .table tbody td { padding: 9px 10px; }

    /* --- Tabs --- */
    .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
        gap: 0;
        scrollbar-width: none;
    }
    .tabs::-webkit-scrollbar { display: none; }
    .tab { white-space: nowrap; padding: 10px 13px; flex-shrink: 0; }

    /* --- Modal --- */
    .modal-overlay { padding: 0; align-items: flex-end; }
    .modal-box {
        max-width: 100%;
        width: 100%;
        max-height: 92vh;
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    }
    .modal-header { border-radius: var(--radius-xl) var(--radius-xl) 0 0; }
    .modal-footer { border-radius: 0; }
    .modal-body { padding: 16px; }

    /* --- Stat cards --- */
    .stat-card .stat-value { font-size: 24px; }

    /* --- Tournament cards --- */
    .tournament-card .tc-actions { flex-wrap: wrap; }
    .tournament-card .tc-actions .btn { flex: 1; min-width: 0; justify-content: center; }

    /* --- Game card --- */
    .game-card {
        flex-wrap: wrap;
        gap: 10px;
        padding: 12px;
    }
    .game-card .game-teams {
        grid-template-columns: 1fr auto 1fr;
        gap: 6px;
        width: 100%;
    }
    .game-card .team-name { font-size: 13px; }
    .game-card .score { font-size: 18px; min-width: 50px; }
    .game-card .game-actions { width: 100%; justify-content: flex-end; }
    .game-card .gc-time-col { width: auto; min-width: 50px; }
    .game-card .gc-meta-col { width: auto; min-width: 90px; }

    /* --- Livestream board --- */
    .livestream-board { padding: 20px 14px; }
    .livestream-teams {
        grid-template-columns: 1fr auto 1fr;
        gap: 8px;
    }
    .livestream-team-name { font-size: 16px; }
    .livestream-score { font-size: 44px; min-width: 110px; padding: 0 10px; letter-spacing: -1px; }
    .score-btn { width: 52px; height: 40px; font-size: 16px; }
    .score-btn.plus2, .score-btn.minus { font-size: 11px; }
    .timer-display { font-size: 38px; }
    .timer-controls { gap: 7px; }
    .timer-controls .btn { padding: 0 12px; font-size: 13px; }

    /* --- Slot planner --- */
    .slot-item { flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
    .slot-actions { width: 100%; justify-content: flex-end; }

    /* --- KO bracket --- */
    .ko-bracket { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .ko-bracket-wrap { min-width: 480px; }

    /* --- Group filter --- */
    .group-filter { gap: 6px; }
    .group-filter-btn { height: 30px; padding: 0 11px; font-size: 11px; }

    /* --- Permissions grid --- */
    .perm-grid { grid-template-columns: 1fr; }

    /* --- Misc --- */
    .empty-state { padding: 40px 16px; }
    .locked-banner { font-size: 12px; }
    .alert { font-size: 12px; }

    /* --- Utility overrides --- */
    .d-flex.gap-2, .d-flex.gap-3 { flex-wrap: wrap; }

    /* --- Dashboard --- */
    .db-welcome { padding: 16px 0 0; }
    .db-welcome-title { font-size: 18px; }
    .db-intro-list { margin: 10px 0; gap: 8px; }
    .db-intro-list li { font-size: 13px; }
    .db-new-section { margin-top: 16px; padding-top: 16px; }
    .db-two-col { margin-top: 24px !important; gap: 16px; }
    .db-archive-section { margin-top: 20px; }
    .db-archive-toggle { padding: 4px 0; }
    .t-list-header > *, .t-list-row > * { padding: 0 10px; }
    .tl-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .tl-dates { font-size: 11px; white-space: nowrap; }

}


/* Intermediate breakpoint: 600px */
@media (max-width: 600px) {
    /* --- Page header: action buttons full width --- */
    .page-header { gap: 8px; }

    /* --- Search bars --- */
    .page-header input[type="text"],
    .page-header .form-control { max-width: 100% !important; width: 100%; }

    /* --- Card header wraps --- */
    .card-header { flex-wrap: wrap; }

    /* --- Modal wider on small screens --- */
    .modal-body .form-row { grid-template-columns: 1fr; }

    /* --- Stat cards: 2 columns min --- */
    .grid-3.stat-grid { grid-template-columns: repeat(2, 1fr); }

    /* --- Dropdown menus: full width on mobile --- */
    .dropdown-menu { right: auto; left: 0; min-width: 100%; }

    /* --- Tabs scroll --- */
    .tabs { gap: 0; }

    /* --- Badge wrapping in card headers --- */
    .card-header .d-flex { flex-wrap: wrap; gap: 6px; }

    /* --- Filter bars scroll horizontally --- */
    .group-filter { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
    .group-filter::-webkit-scrollbar { display: none; }
    .group-filter-btn { flex-shrink: 0; }
}

/* Extra small screens */
@media (max-width: 420px) {
    .af-content { padding: calc(var(--header-h) * 2 + 10px) 10px 28px; }
    .page-title { font-size: 17px; }
    .livestream-score { font-size: 36px; min-width: 90px; }
    .livestream-team-name { font-size: 14px; }
    .score-btn { width: 44px; height: 36px; }
    .timer-display { font-size: 32px; }
    .perm-grid { grid-template-columns: 1fr; }
    .modal-body { padding: 12px; }
    .card-body { padding: 12px; }
    .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-light); }
