/* ============================================================
   DARTVINCI - Dart Tournament Management System
   Modern CSS Design
   ============================================================ */

:root {
    --primary: #1a1a2e;
    --primary-light: #16213e;
    --accent: #e94560;
    --accent-hover: #c83650;
    --success: #00b894;
    --warning: #fdcb6e;
    --danger: #d63031;
    --info: #0984e3;
    --bg: #0f3460;
    --bg-light: #162447;
    --bg-card: #1a1a2e;
    --text: #f5f5f5;
    --text-muted: #a0a0b8;
    --border: #2a2a4a;
    --shadow: rgba(0, 0, 0, 0.3);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.3s ease;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--primary) 0%, var(--bg) 50%, var(--primary-light) 100%);
    color: var(--text);
    min-height: 100vh;
}

/* ---- HEADER ---- */
.app-header {
    background: var(--bg-card);
    border-bottom: 2px solid var(--accent);
    padding: 0.5rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 20px var(--shadow);
}

.app-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.app-logo svg {
    width: 40px;
    height: 40px;
}

.app-logo h1 {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: 3px;
    color: var(--accent);
}

.app-logo .version {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ---- NAVIGATION ---- */
.main-nav {
    display: flex;
    gap: 4px;
    align-items: center;
}

/* Nav dropdown menus */
.nav-dropdown {
    position: relative;
}

.nav-dropdown-trigger {
    position: relative;
}

.nav-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: 0 8px 24px var(--shadow);
    z-index: 1000;
    min-width: 200px;
    padding: 4px;
    padding-top: 8px;
    /* Invisible bridge to close the gap between trigger and menu */
    margin-top: 0;
}

/* Extend hover zone with invisible pseudo-element bridging the gap */
.nav-dropdown-trigger::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -10px;
    height: 10px;
}

.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown.open .nav-dropdown-menu {
    display: block;
}

.nav-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 14px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: 6px;
    transition: var(--transition);
    text-align: left;
}

.nav-dropdown-item:hover {
    background: var(--bg-light);
    color: var(--text);
}

.nav-dropdown-item.active {
    color: var(--accent);
    background: rgba(233, 69, 96, 0.1);
}

.nav-btn {
    background: transparent;
    border: 2px solid transparent;
    color: var(--text-muted);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
}

.nav-btn:hover {
    color: var(--text);
    border-color: var(--border);
    background: var(--bg-light);
}

.nav-btn.active {
    color: var(--accent);
    border-color: var(--accent);
    background: rgba(233, 69, 96, 0.1);
}

.nav-btn .badge {
    background: var(--accent);
    color: white;
    font-size: 0.7rem;
    padding: 1px 6px;
    border-radius: 10px;
    font-weight: 600;
}

/* ---- TOURNAMENT SWITCHER ---- */
.tournament-switcher {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-light);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--accent);
    cursor: pointer;
    user-select: none;
    transition: var(--transition);
    min-width: 200px;
}
.tournament-switcher:hover {
    background: rgba(233, 69, 96, 0.15);
    border-color: var(--accent-hover);
}
.switcher-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
}
.tournament-switcher strong {
    color: var(--accent);
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}
.switcher-arrow {
    font-size: 0.6rem;
    color: var(--text-muted);
    margin-left: auto;
    transition: transform 0.2s;
}
.tournament-switcher.open .switcher-arrow {
    transform: rotate(180deg);
}
.tournament-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 320px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    z-index: 200;
    max-height: 400px;
    overflow-y: auto;
}
.tournament-switcher.open .tournament-dropdown {
    display: block;
}
.dropdown-section-label {
    padding: 8px 14px 4px;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    font-weight: 600;
}
.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}
.dropdown-item:hover {
    background: rgba(233, 69, 96, 0.12);
}
.dropdown-item.active {
    background: rgba(233, 69, 96, 0.2);
    border-left: 3px solid var(--accent);
}
.dropdown-item .di-name {
    font-weight: 600;
    font-size: 0.9rem;
}
.dropdown-item .di-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}
.dropdown-item .di-status {
    margin-left: auto;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}
.dropdown-item .di-status.live { background: var(--success); color: #fff; }
.dropdown-item .di-status.setup { background: var(--info); color: #fff; }
.dropdown-item .di-status.done { background: var(--text-muted); color: #fff; }

/* Live screen picker popup */
.live-picker {
    position: fixed;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    z-index: 9999;
    min-width: 280px;
    max-height: 400px;
    overflow-y: auto;
}
.live-picker .dropdown-item {
    padding: 12px 16px;
}
.live-picker .dropdown-item .di-name {
    flex: 1;
}
.live-picker .lp-open-btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 4px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
.live-picker .lp-open-btn:hover {
    background: var(--accent-hover);
}

/* ---- MAIN CONTENT ---- */
.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

.page-title {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 12px;
}

.page-title .icon {
    font-size: 2rem;
}

/* ---- CARDS ---- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 15px var(--shadow);
    transition: var(--transition);
}

.card:hover {
    border-color: var(--accent);
    box-shadow: 0 6px 25px var(--shadow);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.card-header h3 {
    font-size: 1.2rem;
    font-weight: 600;
}

/* ---- BUTTONS ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #00a884;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #b52828;
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--border);
    color: var(--text);
}

.btn-outline:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 1.05rem;
}

.btn-icon {
    padding: 8px;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ---- FORMS ---- */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-light);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.95rem;
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(233, 69, 96, 0.2);
}

.form-control::placeholder {
    color: var(--text-muted);
}

select.form-control {
    cursor: pointer;
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.form-inline {
    display: flex;
    gap: 8px;
    align-items: end;
}

/* ---- TABLES ---- */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-sm);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background: var(--bg-light);
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    position: sticky;
    top: 0;
}

tr:hover {
    background: rgba(233, 69, 96, 0.05);
}

tr.winner {
    background: rgba(0, 184, 148, 0.1);
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

/* ---- BRACKET VISUALIZATION ---- */
.bracket-container {
    overflow-x: auto;
    padding: 2rem 1rem;
}

.bracket {
    display: flex;
    align-items: stretch;
    min-width: max-content;
}

.bracket-round {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 230px;
    position: relative;
}

.bracket-round-title {
    text-align: center;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    margin-bottom: 16px;
    letter-spacing: 1px;
    flex-shrink: 0;
}

/* Connector gap between rounds */
.bracket-round-connector {
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: 40px;
    position: relative;
}

.bracket-match-wrapper {
    display: flex;
    align-items: center;
    position: relative;
    flex: 1;
}

.bracket-match {
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: visible;
    transition: var(--transition);
    cursor: pointer;
    flex: 1;
    position: relative;
}

.bracket-match:hover {
    border-color: var(--accent);
    box-shadow: 0 0 10px rgba(233, 69, 96, 0.2);
}

.bracket-match.completed {
    border-left: 3px solid var(--success);
}

.bracket-match.pending {
    border-left: 3px solid var(--border);
}

.bracket-match.bye {
    opacity: 0.5;
    border-left: 3px solid var(--warning);
}

.bracket-match.deferred {
    opacity: 0.6;
    border-left: 3px solid #f39c12;
    background: repeating-linear-gradient(
        -45deg,
        var(--bg-light),
        var(--bg-light) 5px,
        rgba(243, 156, 18, 0.05) 5px,
        rgba(243, 156, 18, 0.05) 10px
    );
}

.empty.freilos {
    color: var(--warning);
    font-style: italic;
}

/* Match toolbar (board + defer) */
.match-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 3px 8px;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid var(--border);
    font-size: 0.75rem;
}

.match-board-select {
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: 700;
    color: var(--accent);
    font-size: 0.7rem;
    letter-spacing: 0.5px;
    transition: var(--transition);
}

.match-board-select:hover {
    background: rgba(233, 69, 96, 0.15);
}

.match-action-btn {
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.8rem;
    padding: 2px 5px;
    border-radius: 3px;
    transition: var(--transition);
}

.match-action-btn.defer {
    color: #f39c12;
}

.match-action-btn.defer:hover {
    background: rgba(243, 156, 18, 0.2);
}

.match-action-btn.undefer {
    color: var(--success);
}

.match-action-btn.undefer:hover {
    background: rgba(0, 184, 148, 0.2);
}

.deferred-label {
    text-align: center;
    font-size: 0.65rem;
    font-weight: 700;
    color: #f39c12;
    padding: 2px;
    letter-spacing: 0.5px;
}

/* Round matches container */
.bracket-round-matches {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    flex: 1;
    gap: 8px;
}

/* SVG connector lines */
.bracket-svg-lines {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 0;
}

/* Ensure matches are above SVG lines */
.bracket-round {
    z-index: 1;
}

.bracket-round-connector {
    z-index: 0;
}

/* Board checkboxes in tournament modal */
.board-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 4px 0;
}

.board-checkbox {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 4px 10px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: var(--transition);
    user-select: none;
}

.board-checkbox.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.board-checkbox:hover {
    border-color: var(--accent);
}

/* Board management on bracket page */
.board-mgmt-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.board-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--border);
    background: var(--bg-light);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: var(--transition);
    user-select: none;
}

.board-toggle.active {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

.board-toggle.finale {
    border-color: var(--accent);
}

.board-toggle.finale.active {
    background: var(--accent);
    border-color: var(--accent);
}

.board-toggle:hover {
    opacity: 0.85;
}

.match-player {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border);
}

.match-player:last-child {
    border-bottom: none;
}

.match-player.winner {
    background: rgba(0, 184, 148, 0.15);
    font-weight: 700;
}

.match-player .name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.match-player .score {
    font-weight: 700;
    min-width: 24px;
    text-align: center;
    padding-left: 8px;
}

.match-player .empty {
    color: var(--text-muted);
    font-style: italic;
}

/* Score picker (clickable score selector) */
.score-picker {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 28px;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 700;
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-muted);
    margin-left: 6px;
    flex-shrink: 0;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    user-select: none;
}

.score-picker:hover {
    border-color: var(--accent);
    background: rgba(233, 69, 96, 0.1);
}

.score-picker.score-set {
    color: var(--text);
    background: rgba(233, 69, 96, 0.15);
    border-color: var(--accent);
}

/* Score popup */
.score-popup {
    position: fixed;
    display: flex;
    gap: 4px;
    background: var(--bg-card);
    border: 2px solid var(--accent);
    border-radius: 6px;
    padding: 6px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
    z-index: 9999;
    white-space: nowrap;
}

.score-popup-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-light);
    color: var(--text);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
}

.score-popup-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    transform: scale(1.1);
}

/* Keep old score-input for modal */
.score-input {
    width: 40px;
    padding: 2px 4px;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 700;
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    margin-left: 6px;
    flex-shrink: 0;
}

.score-input:focus {
    border-color: var(--accent);
    outline: none;
    box-shadow: 0 0 0 2px rgba(233, 69, 96, 0.2);
}

.btn-save-score {
    display: block;
    width: 100%;
    padding: 3px;
    border: none;
    background: var(--success);
    color: white;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    transition: var(--transition);
}

.btn-save-score:hover {
    background: #00a381;
}

.bracket-match {
    position: relative;
}

/* ---- GROUP TABLE ---- */
.group-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.group-card .group-header {
    background: var(--accent);
    color: white;
    padding: 12px 16px;
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: 0.3px;
}

.group-card table {
    margin: 0;
}

.group-card table th,
.group-card table td {
    padding: 8px 10px;
    white-space: nowrap;
}

.group-card table th {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.group-card .group-matches {
    padding: 16px;
    border-top: 1px solid var(--border);
}

.group-card .group-matches h4 {
    margin-bottom: 12px;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.group-match-row {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    margin-bottom: 4px;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.02);
    font-size: 0.95rem;
    transition: background 0.15s;
}

.group-match-row:hover {
    background: rgba(255,255,255,0.05);
}

.group-match-row .gm-name {
    flex: 1;
    font-weight: 600;
}

.group-match-row .gm-name-left {
    text-align: right;
    padding-right: 12px;
}

.group-match-row .gm-name-right {
    text-align: left;
    padding-left: 12px;
}

.group-match-row .gm-result {
    font-weight: 800;
    font-size: 1.1rem;
    min-width: 50px;
    text-align: center;
    color: var(--accent);
}

.group-match-row .gm-result-pending {
    display: flex;
    align-items: center;
    gap: 4px;
}

.group-match-row .gm-score-picker {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    font-size: 1.1rem;
    font-weight: 700;
    background: var(--bg-light);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
}

.group-match-row .gm-score-picker:hover {
    border-color: var(--accent);
    color: var(--text);
}

.group-match-row .gm-score-picker.score-set {
    color: var(--accent);
    border-color: var(--accent);
    font-weight: 800;
}

.group-match-row .btn-save-score {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--success);
    color: white;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    cursor: pointer;
    margin-left: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.15s;
}

.group-match-row .btn-save-score:hover {
    opacity: 0.85;
}

.group-match-row .gm-board {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--accent);
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: var(--radius-sm);
    padding: 2px 8px;
    margin-right: 10px;
    flex-shrink: 0;
    min-width: 36px;
    text-align: center;
    letter-spacing: 0.5px;
}

.group-match-row.gm-completed {
    opacity: 0.6;
}

.groups-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 1rem;
}

/* ---- MODAL ---- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 200;
    justify-content: center;
    align-items: flex-start;
    padding: 2vh 0;
    overflow-y: auto;
    backdrop-filter: blur(4px);
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    max-width: 560px;
    width: 92%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px var(--shadow);
}

.modal h2 {
    margin-bottom: 1.5rem;
    font-size: 1.4rem;
    color: var(--accent);
}

.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

/* ---- GROUP KO MODAL ---- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 200;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 4vh 1rem;
    overflow-y: auto;
    backdrop-filter: blur(4px);
}
.modal-backdrop .modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px var(--shadow);
}
.modal-backdrop .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.2rem 1.5rem;
    border-bottom: 1px solid var(--border);
}
.modal-backdrop .modal-header h3 {
    font-size: 1.2rem;
    color: var(--accent);
}
.modal-backdrop .modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.6rem;
    cursor: pointer;
    line-height: 1;
}
.modal-backdrop .modal-close:hover { color: var(--danger); }
.modal-backdrop .modal-body {
    padding: 1.5rem;
}
.modal-backdrop .modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
}

/* Group KO option cards */
.group-ko-option {
    padding: 14px 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}
.group-ko-option:hover {
    border-color: var(--accent);
    background: rgba(99, 102, 241, 0.06);
}
.group-ko-option.selected {
    border-color: var(--accent);
    background: rgba(99, 102, 241, 0.12);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.3);
}

/* Undo button in schedule */
.btn-undo-schedule {
    font-size: 0.75rem;
    padding: 3px 10px;
    border-radius: 4px;
    border: 1px solid #ff9800;
    background: rgba(255, 152, 0, 0.1);
    color: #ff9800;
    cursor: pointer;
    font-weight: 600;
    white-space: nowrap;
    transition: all 0.15s;
}
.btn-undo-schedule:hover {
    background: rgba(255, 152, 0, 0.25);
    border-color: #f57c00;
}

/* ---- TOAST ---- */
.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    color: white;
    font-weight: 500;
    font-size: 0.9rem;
    animation: slideIn 0.3s ease;
    max-width: 400px;
    box-shadow: 0 4px 15px var(--shadow);
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--danger);
}

.toast.info {
    background: var(--info);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ---- DASHBOARD ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.2rem;
    text-align: center;
    transition: var(--transition);
}

.stat-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.stat-value {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--accent);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 4px;
}

/* ---- SCORE INPUT ---- */
.score-input {
    display: flex;
    align-items: center;
    gap: 8px;
}

.score-input input {
    width: 50px;
    text-align: center;
    font-size: 1.2rem;
    font-weight: 700;
    padding: 8px;
    background: var(--bg-light);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
}

.score-input input:focus {
    border-color: var(--accent);
    outline: none;
}

.score-input .vs {
    font-weight: 700;
    color: var(--text-muted);
}

/* ---- TABS ---- */
.tabs {
    display: flex;
    gap: 2px;
    border-bottom: 2px solid var(--border);
    margin-bottom: 1.5rem;
}

.tab {
    padding: 10px 20px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
}

.tab:hover {
    color: var(--text);
}

.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ---- EMPTY STATE ---- */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-state .icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state h3 {
    margin-bottom: 0.5rem;
}

/* ---- LOADING ---- */
.loading {
    display: flex;
    justify-content: center;
    padding: 2rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.3); }
}

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
    .app-header {
        flex-direction: column;
        gap: 12px;
        padding: 1rem;
    }

    .main-nav {
        flex-wrap: wrap;
        justify-content: center;
    }

    .nav-btn {
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    .main-content {
        padding: 1rem;
    }

    .groups-grid {
        grid-template-columns: 1fr;
    }

    .bracket {
        gap: 20px;
    }

    .bracket-round {
        min-width: 180px;
    }
}

/* ---- PRINT ---- */
@media print {
    .app-header, .main-nav, .btn, .modal-overlay, .toast-container {
        display: none !important;
    }

    body {
        background: white;
        color: black;
    }

    .card, .group-card, .bracket-match {
        border-color: #ccc;
        background: white;
    }

    .bracket-match .match-player.winner {
        background: #e8f5e9;
    }
}

/* ============================================================
   SCHEDULE - Bracket Type Badges
   ============================================================ */

.badge-bracket {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-winners {
    background: rgba(0, 184, 148, 0.2);
    color: #00b894;
}

.badge-losers, .badge-losers2 {
    background: rgba(253, 203, 110, 0.2);
    color: #fdcb6e;
}

.badge-finals {
    background: rgba(233, 69, 96, 0.2);
    color: #e94560;
}

/* ============================================================ */
/* LOGIN OVERLAY                                                 */
/* ============================================================ */
.login-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(135deg, #0a0a1a 0%, #1a1a2e 50%, #16213e 100%);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-box {
    background: var(--card-bg, #1e1e2e);
    border: 1px solid var(--border, #2d2d3d);
    border-radius: 16px;
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.login-box h2 {
    color: var(--text, #e0e0e0);
}

.login-box .form-group {
    text-align: left;
    margin-bottom: 1rem;
}

.login-box .form-group label {
    font-size: 0.85rem;
    color: var(--text-muted, #888);
    margin-bottom: 0.3rem;
    display: block;
}

.login-box .form-control {
    width: 100%;
    box-sizing: border-box;
}

/* User info in header */
.user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.user-info .user-name {
    color: var(--text);
    font-weight: 600;
}

.user-info .user-role {
    background: var(--primary);
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    text-transform: uppercase;
}

.user-menu-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text);
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
}
.user-menu-btn:hover {
    background: var(--hover-bg, #2d2d3d);
}

/* User management table */
.users-table {
    width: 100%;
    border-collapse: collapse;
}
.users-table th, .users-table td {
    padding: 0.6rem 0.8rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.users-table th {
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
}

.status-active { color: #00b894; }
.status-pending { color: #fdcb6e; }
.status-blocked { color: #e94560; }
