:root {
    --dark: #071017;
    --dark-2: #0b1720;
    --dark-3: #101b25;
    --light: #f5f8fa;
    --text-dark: #111827;
    --text-light: #f9fafb;
    --muted-dark: #64748b;
    --muted-light: #cbd5e1;
    --line-dark: rgba(255, 255, 255, 0.13);
    --line-light: rgba(15, 23, 42, 0.10);
    --green: #34d399;
    --green-dark: #059669;
    --green-soft: rgba(52, 211, 153, 0.13);
    --danger: #fb7185;
    --panel: rgba(13, 23, 32, 0.74);
    --panel-strong: rgba(10, 19, 28, 0.92);
    --glass: rgba(255, 255, 255, 0.065);
    --shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    color: var(--text-light);
    background:
        radial-gradient(circle at 82% 8%, rgba(52, 211, 153, 0.20), transparent 31%),
        radial-gradient(circle at 18% 6%, rgba(52, 211, 153, 0.10), transparent 26%),
        linear-gradient(180deg, #061018 0%, #07131c 34%, #142230 62%, #edf3f6 100%);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-image:
        radial-gradient(circle, rgba(255, 255, 255, 0.35) 0 0.8px, transparent 1.7px),
        radial-gradient(circle, rgba(52, 211, 153, 0.42) 0 0.9px, transparent 1.8px);
    background-size: 520px 420px, 610px 480px;
    background-position: 80% 18%, 92% 28%;
    opacity: 0.44;
    mask-image: radial-gradient(ellipse at 84% 20%, black 0%, rgba(0,0,0,0.7) 28%, transparent 57%);
}

a {
    color: inherit;
    text-decoration: none;
}

.dashboard-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    height: 76px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 0 clamp(20px, 5vw, 72px);
    background: rgba(7, 16, 23, 0.82);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(18px);
}

.topbar-brand {
    color: var(--text-light);
    font-size: 18px;
    font-weight: 900;
    letter-spacing: -0.04em;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: clamp(16px, 3vw, 34px);
}

.topbar-actions a {
    position: relative;
    color: #e2e8f0;
    font-size: 14px;
    font-weight: 850;
}

.topbar-actions a::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -10px;
    height: 2px;
    transform: scaleX(0);
    transform-origin: left;
    background: var(--green);
    transition: transform 0.18s ease;
}

.topbar-actions a:hover::after {
    transform: scaleX(1);
}

.dashboard-shell {
    width: min(1520px, calc(100% - 72px));
    margin: 0 auto;
    padding: 130px 0 74px;
}

.dashboard-hero {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(360px, 0.55fr);
    gap: 28px;
    align-items: stretch;
    margin-bottom: 24px;
}

.hero-copy {
    min-height: 370px;
    padding: clamp(30px, 5vw, 58px);
    border: 1px solid rgba(226, 232, 240, 0.14);
    border-radius: 30px;
    background:
        linear-gradient(135deg, rgba(255,255,255,0.075), rgba(255,255,255,0.025)),
        rgba(7, 16, 23, 0.58);
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
}

.eyebrow,
.card-kicker {
    margin: 0 0 12px;
    color: var(--green);
    text-transform: uppercase;
    letter-spacing: 0.13em;
    font-size: 12px;
    font-weight: 950;
}

.hero-copy h1 {
    max-width: 900px;
    margin: 0;
    color: var(--text-light);
    font-size: clamp(48px, 7vw, 92px);
    line-height: 0.92;
    letter-spacing: -0.078em;
}

.hero-copy p:not(.eyebrow) {
    max-width: 760px;
    margin: 24px 0 0;
    color: #e2e8f0;
    font-size: clamp(16px, 1.15vw, 20px);
    line-height: 1.65;
}

.dataset-chip {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    max-width: 100%;
    margin-top: 30px;
    padding: 10px 14px;
    border: 1px solid rgba(52, 211, 153, 0.25);
    border-radius: 999px;
    background: rgba(52, 211, 153, 0.10);
    color: var(--muted-light);
    font-size: 13px;
    font-weight: 850;
}

.dataset-chip strong {
    color: var(--green);
    word-break: break-all;
}

.hero-panel {
    display: grid;
    gap: 14px;
}

.metric-tile {
    padding: 24px;
    border: 1px solid rgba(226, 232, 240, 0.14);
    border-radius: 24px;
    background:
        linear-gradient(135deg, rgba(255,255,255,0.08), rgba(255,255,255,0.025)),
        rgba(13, 23, 32, 0.72);
    box-shadow: 0 18px 58px rgba(0, 0, 0, 0.21);
    backdrop-filter: blur(10px);
}

.metric-tile span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    margin-bottom: 16px;
    border-radius: 999px;
    background: var(--green-soft);
    color: var(--green);
    font-weight: 950;
}

.metric-tile strong {
    display: block;
    color: var(--text-light);
    font-size: 22px;
    letter-spacing: -0.045em;
}

.metric-tile p {
    margin: 7px 0 0;
    color: var(--muted-light);
    line-height: 1.5;
}

.status-banner {
    margin: 0 0 18px;
    padding: 14px 16px;
    border: 1px solid rgba(52, 211, 153, 0.26);
    border-radius: 16px;
    background: rgba(52, 211, 153, 0.11);
    color: #dcfce7;
    font-size: 14px;
    font-weight: 850;
    box-shadow: 0 16px 50px rgba(0, 0, 0, 0.13);
}

.control-grid,
.workspace-grid {
    display: grid;
    gap: 18px;
    margin-bottom: 18px;
}

.control-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.workspace-grid {
    grid-template-columns: minmax(0, 1.05fr) minmax(340px, 0.95fr);
}

.wide-control {
    grid-column: span 2;
}

.control-card,
.results-panel {
    border: 1px solid rgba(226, 232, 240, 0.16);
    border-radius: 24px;
    background:
        linear-gradient(135deg, rgba(255,255,255,0.08), rgba(255,255,255,0.03)),
        var(--panel);
    box-shadow: 0 18px 54px rgba(0, 0, 0, 0.20);
    backdrop-filter: blur(10px);
}

.control-card {
    padding: 24px;
}

.card-heading {
    margin-bottom: 18px;
}

.card-heading h2,
.results-header h2 {
    margin: 0;
    color: var(--text-light);
    font-size: 22px;
    line-height: 1.1;
    letter-spacing: -0.04em;
}

.card-heading .card-kicker,
.results-header .card-kicker {
    display: block;
    margin-bottom: 8px;
}

.inline-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.form-grid {
    display: grid;
    grid-template-columns: minmax(130px, 0.6fr) minmax(170px, 0.9fr) minmax(260px, 1.5fr);
    gap: 12px;
}

.formula-field {
    min-width: 0;
}

label {
    display: block;
    margin: 0 0 7px;
    color: #e2e8f0;
    font-size: 13px;
    font-weight: 900;
}

.helper-text {
    margin: 12px 0 0;
    color: var(--muted-light);
    font-size: 13px;
    line-height: 1.55;
}

input,
select {
    width: 100%;
    min-height: 46px;
    padding: 11px 12px;
    border: 1px solid rgba(226, 232, 240, 0.18);
    border-radius: 12px;
    outline: none;
    background: rgba(7, 16, 23, 0.70);
    color: var(--text-light);
    font: inherit;
    transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

input[type="file"] {
    padding: 9px 12px;
}

input::placeholder {
    color: rgba(203, 213, 225, 0.55);
}

input:focus,
select:focus {
    border-color: var(--green);
    background: rgba(7, 16, 23, 0.86);
    box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.13);
}

button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 17px;
    border: 1px solid var(--green);
    border-radius: 12px;
    background: var(--green);
    color: #062015;
    font: inherit;
    font-size: 14px;
    font-weight: 950;
    cursor: pointer;
    transition: transform 0.18s ease, filter 0.18s ease, border-color 0.18s ease, color 0.18s ease, background 0.18s ease;
}

button:hover {
    transform: translateY(-1px);
    filter: brightness(1.04);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.52;
    transform: none;
}

.secondary-button {
    border-color: rgba(226, 232, 240, 0.20);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-light);
}

.secondary-button:hover {
    border-color: var(--green);
    color: var(--green);
    filter: none;
}

.danger-button {
    border-color: rgba(251, 113, 133, 0.40);
    background: rgba(251, 113, 133, 0.10);
    color: #fecdd3;
}

.danger-button:hover {
    border-color: var(--danger);
    color: #ffe4e6;
    filter: none;
}

.button-row,
.button-stack,
.column-control-actions,
.active-filters,
.column-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
}

.button-stack {
    flex-direction: column;
}

.button-stack button {
    width: 100%;
}

.filter-row {
    display: grid;
    grid-template-columns: minmax(180px, 1.1fr) minmax(88px, 0.35fr) minmax(110px, 0.55fr) auto auto;
    gap: 10px;
    align-items: center;
}

.filter-row button,
.column-control-actions button,
.pagination-controls button {
    min-height: 46px;
}

.filter-pill,
.column-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    padding: 7px 12px;
    border: 1px solid rgba(226, 232, 240, 0.16);
    border-radius: 999px;
    background: rgba(7, 16, 23, 0.58);
    color: var(--muted-light);
    font-size: 13px;
    font-weight: 850;
}

.column-toggle {
    border-radius: 12px;
    cursor: pointer;
    transition: border-color 0.16s ease, background 0.16s ease;
}

.column-toggle:hover {
    border-color: rgba(52, 211, 153, 0.42);
    background: rgba(52, 211, 153, 0.08);
}

.column-toggle input {
    width: auto;
    min-height: auto;
    margin: 0;
    accent-color: var(--green-dark);
}

.filter-pill button {
    min-height: 26px;
    margin: 0;
    padding: 0 8px;
    border-radius: 999px;
    font-size: 12px;
}

.results-panel {
    overflow: hidden;
    margin-top: 18px;
    background:
        linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.03)),
        rgba(13, 23, 32, 0.78);
}

.results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 24px 24px 18px;
    border-bottom: 1px solid rgba(226, 232, 240, 0.12);
}

.table-hint {
    color: var(--muted-light);
    font-size: 13px;
    font-weight: 850;
}

.table-card {
    overflow-x: auto;
    overflow-y: visible;
    max-height: none;
    border-radius: 0;
}

#statsTable {
    width: max-content;
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: auto;
}

#statsTable th,
#statsTable td {
    padding: 10px 11px;
    border-bottom: 1px solid rgba(226, 232, 240, 0.095);
    border-right: 1px solid rgba(226, 232, 240, 0.07);
    text-align: center;
    white-space: nowrap;
    overflow: visible;
    text-overflow: unset;
    font-size: clamp(12px, 0.76vw, 15px);
}

#statsTable th {
    position: sticky;
    top: 0;
    z-index: 3;
    background: #101923;
    color: #cbd5e1;
    text-transform: uppercase;
    letter-spacing: 0.055em;
    font-size: 12px;
    font-weight: 950;
}

#statsTable td {
    color: #e2e8f0;
    font-weight: 750;
    background: rgba(13, 23, 32, 0.52);
}

#statsTable tr:nth-child(even) td {
    background: rgba(17, 28, 38, 0.56);
}

#statsTable tr:hover td {
    background: rgba(52, 211, 153, 0.105);
}

.sortable-header {
    cursor: pointer;
    user-select: none;
}

.sortable-header:hover {
    color: var(--text-light);
    background: #14202b;
}

#statsTable th:first-child,
#statsTable td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    width: 1%;
    min-width: max-content;
    padding-left: 16px;
    padding-right: 22px;
    text-align: left;
    background: #111c26;
    box-shadow: 2px 0 0 rgba(226, 232, 240, 0.09);
}

#statsTable th:first-child {
    z-index: 4;
    background: #101923;
}

#statsTable tr:nth-child(even) td:first-child {
    background: #13202b;
}

#statsTable tr:hover td:first-child {
    background: #173024;
}

.player-cell {
    color: var(--text-light);
    font-weight: 950;
}

.pagination-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 18px 24px 24px;
    color: var(--muted-light);
    font-weight: 900;
}

#pageInfo {
    min-width: 118px;
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(226, 232, 240, 0.16);
    color: var(--text-light);
    text-align: center;
}

.empty-state {
    padding: 46px 20px;
    text-align: center;
}

.empty-state-title {
    margin-bottom: 8px;
    color: var(--text-light);
    font-size: 18px;
    font-weight: 950;
}

.empty-state-text {
    color: var(--muted-light);
    font-size: 14px;
}

@media (max-width: 1180px) {
    .dashboard-hero,
    .workspace-grid {
        grid-template-columns: 1fr;
    }

    .hero-panel {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .control-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .wide-control {
        grid-column: span 2;
    }
}

@media (max-width: 820px) {
    .dashboard-topbar {
        height: auto;
        min-height: 76px;
        padding: 18px 22px;
        align-items: flex-start;
        flex-direction: column;
    }

    .topbar-actions {
        width: 100%;
        justify-content: space-between;
    }

    .dashboard-shell {
        width: min(100% - 36px, 1520px);
        padding-top: 144px;
    }

    .dashboard-hero,
    .control-grid,
    .workspace-grid,
    .hero-panel,
    .form-grid,
    .filter-row {
        grid-template-columns: 1fr;
    }

    .wide-control {
        grid-column: span 1;
    }

    .hero-copy {
        min-height: auto;
        border-radius: 24px;
    }

    .button-row button,
    .column-control-actions button,
    .filter-row button,
    .pagination-controls button {
        width: 100%;
    }

    .results-header,
    .pagination-controls {
        align-items: stretch;
        flex-direction: column;
    }

    .table-hint {
        display: none;
    }
}

.column-toggle-header {
    align-items: center;
}

.column-toggle-header h3 {
    margin-bottom: 0;
}

.column-toggle-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.column-toggle-actions button {
    white-space: nowrap;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 2rem;
    flex-wrap: wrap;
}

.results-header-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.75rem;
}

.results-header .table-hint {
    margin: 0;
    text-align: right;
}

.dataset-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.column-heading-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
}

.column-heading-row .column-control-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.selected-file-name {
    margin: 0.65rem 0 0;
    font-size: 0.9rem;
    color: var(--muted-text);
}

.table-summary {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    text-align: right;
    font-size: 0.9rem;
    color: var(--muted-text);
}

#playerCountSummary {
    font-weight: 700;
    color: var(--text-main);
}

.pagination-controls.is-hidden {
    display: none;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}