:root {
    --topbar-sticky-offset: 76px;
    --bg: #f3f5f9;
    --card: #ffffff;
    --text: #18212f;
    --muted: #667085;
    --primary: #2557d6;
    --primary-dark: #193fa2;
    --line: #dfe4ee;
    --success: #0f7b4f;
    --error: #b42318;
    --warning: #9a6700;
    --shadow: 0 16px 40px rgba(16, 24, 40, .08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: radial-gradient(circle at top left, #e4ebff 0, transparent 34%), var(--bg);
    color: var(--text);
}

a {
    color: var(--primary);
    text-decoration: none;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;

    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;

    padding: 16px 28px;
    background: rgba(255, 255, 255, .9);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(12px);
}

.brand {
    font-weight: 800;
    color: var(--text);
    font-size: 18px;
}

.tz {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-top: 2px;
}

nav {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
}

nav a {
    color: var(--text);
    font-weight: 650;
}

.container {
    width: min(1180px, calc(100% - 32px));
    margin: 28px auto 56px;
}

.narrow {
    max-width: 720px;
}

.hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}

h1 {
    margin: 0 0 8px;
    font-size: clamp(28px, 4vw, 44px);
    letter-spacing: -.04em;
}

h2 {
    margin: 0 0 10px;
    letter-spacing: -.02em;
}

p {
    line-height: 1.55;
}

.muted {
    color: var(--muted);
}

.card,
.auth-card,
.match-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 22px;
    box-shadow: var(--shadow);
}

.card {
    padding: 22px;
    margin-bottom: 18px;
}

.auth-card {
    max-width: 460px;
    margin: 48px auto;
    padding: 30px;
}

.form {
    display: grid;
    gap: 14px;
}

.form label,
.prediction-form label {
    display: grid;
    gap: 7px;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    color: var(--text);
    font: inherit;
}

textarea {
    resize: vertical;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;

    border: 0;
    border-radius: 12px;
    padding: 12px 16px;

    background: var(--primary);
    color: white;
    font-weight: 800;
    cursor: pointer;

    box-shadow: 0 8px 20px rgba(37, 87, 214, .22);
}

.btn:hover {
    background: var(--primary-dark);
}

.btn.secondary {
    background: #101828;
}

.btn.small {
    padding: 9px 12px;
    font-size: 14px;
}

.flash {
    padding: 12px 14px;
    border-radius: 14px;
    margin-bottom: 12px;
    font-weight: 700;
}

.flash-success {
    background: #e8fff4;
    color: var(--success);
    border: 1px solid #b6f2d3;
}

.flash-error {
    background: #fff0ee;
    color: var(--error);
    border: 1px solid #ffd0ca;
}

/* MENU DE FILTROS FIXO AO ROLAR */
.filters {
    position: sticky;
    top: var(--topbar-sticky-offset);
    z-index: 19;

    display: flex;
    gap: 8px;
    flex-wrap: wrap;

    margin: 0 0 20px;
    padding: 12px;

    background: rgba(243, 245, 249, .94);
    border: 1px solid rgba(223, 228, 238, .9);
    border-radius: 18px;
    box-shadow: 0 10px 28px rgba(16, 24, 40, .08);
    backdrop-filter: blur(12px);
}

.chip {
    padding: 9px 12px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--text);
    font-weight: 700;
}

.chip.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.matches-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 16px;
}

.match-card {
    padding: 18px;
    position: relative;
    overflow: hidden;
}

.match-card.locked {
    opacity: .82;
}

.match-head {
    display: flex;
    justify-content: space-between;
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 8px;
}

.match-card h2 {
    font-size: 21px;
}

.match-card h2 span {
    color: var(--muted);
}

.score-final {
    background: #f0f7ff;
    border: 1px solid #d6e9ff;
    border-radius: 14px;
    padding: 10px;
    margin: 12px 0;
}

.prediction-form {
    display: grid;
    gap: 12px;
    margin-top: 14px;
}

.score-inputs {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 10px;
    align-items: end;
}

.score-inputs input {
    text-align: center;
    font-size: 20px;
    font-weight: 800;
}

.full {
    grid-column: 1 / -1;
}

.locked-msg {
    padding: 10px;
    border-radius: 12px;
    background: #fff8e6;
    color: var(--warning);
    font-weight: 700;
}

.points-box {
    margin-top: 12px;
    background: #f7f8fb;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 10px;
}

.points-box small {
    display: block;
    color: var(--muted);
    margin-top: 4px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.stat {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 18px;
    box-shadow: var(--shadow);
}

.stat strong {
    display: block;
    font-size: 32px;
}

.stat span {
    color: var(--muted);
    font-weight: 700;
}

.table-card {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 760px;
}

th,
td {
    padding: 13px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}

th {
    font-size: 13px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .05em;
}

.admin-result-form {
    display: contents;
}

.admin-result-form input {
    width: 68px;
    display: inline-block;
    text-align: center;
}

.admin-result-form select {
    min-width: 130px;
    margin-top: 6px;
}

.inline-form {
    margin: 12px 0;
}

.import-details {
    margin-top: 14px;
}

.import-details summary {
    cursor: pointer;
    font-weight: 800;
}

.rules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 12px;
}

.rule {
    padding: 14px;
    background: #f7f8fb;
    border: 1px solid var(--line);
    border-radius: 16px;
    display: grid;
    gap: 5px;
}

.rule strong {
    margin-bottom: 5px;
}

.footer {
    color: var(--muted);
    text-align: center;
    padding: 24px;
    border-top: 1px solid var(--line);
}

code {
    background: #f1f3f9;
    padding: 2px 6px;
    border-radius: 8px;
}

.admin-result-form-box {
    display: grid;
    gap: 8px;
    min-width: 290px;
}

.result-line {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.result-line input {
    width: 64px;
    text-align: center;
}

.result-line select {
    width: auto;
    min-width: 128px;
}

.admin-result-form-box > select {
    max-width: 280px;
}

/* MENU SUPERIOR FIXO */
.topbar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 10000 !important;
}

/* ESPAÇO PARA O CONTEÚDO NÃO FICAR ATRÁS DO MENU */
body {
    padding-top: 76px !important;
}

/* FILTROS DOS JOGOS FIXOS ABAIXO DO MENU */
.filters {
    position: fixed !important;
    top: 76px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;

    width: min(1180px, calc(100% - 32px)) !important;

    z-index: 9999 !important;

    display: flex !important;
    gap: 8px !important;
    flex-wrap: wrap !important;

    margin: 0 !important;
    padding: 12px !important;

    background: rgba(243, 245, 249, 0.98) !important;
    border: 1px solid var(--line) !important;
    border-radius: 18px !important;
    box-shadow: 0 10px 28px rgba(16, 24, 40, 0.14) !important;
    backdrop-filter: blur(12px) !important;
}

/* ESPAÇO PARA OS JOGOS NÃO FICAREM ESCONDIDOS ATRÁS DOS FILTROS */
.matches-grid {
    padding-top: 90px !important;
}



/* AJUSTE FINAL DO MENU E FILTROS FIXOS */
body {
    padding-top: 76px !important;
}

.topbar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 10000 !important;
}

.dashboard-page {
    padding-top: 104px !important;
}

.dashboard-page .filters {
    position: fixed !important;
    top: 76px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;

    width: min(1180px, calc(100% - 32px)) !important;

    z-index: 9999 !important;

    display: grid !important;
    grid-template-columns: 1fr 280px;
    gap: 12px !important;
    align-items: center;

    margin: 0 !important;
    padding: 12px !important;

    background: rgba(243, 245, 249, 0.98) !important;
    border: 1px solid var(--line) !important;
    border-radius: 18px !important;
    box-shadow: 0 10px 28px rgba(16, 24, 40, 0.14) !important;
    backdrop-filter: blur(12px) !important;
}

.stage-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.team-filter {
    display: flex;
    gap: 8px;
    align-items: center;
}

.team-filter input {
    height: 42px;
    min-width: 0;
}

.clear-filter {
    cursor: pointer;
    white-space: nowrap;
}

.dashboard-page .matches-grid {
    padding-top: 0 !important;
}

.match-card {
    padding: 20px !important;
}

.match-meta {
    margin-bottom: 14px;
}

.match-block {
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 14px;
    margin-top: 14px;
    background: #f9fafc;
}

.block-title {
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .08em;
    color: var(--muted);
    text-transform: uppercase;
    margin-bottom: 10px;
}

.prediction-block {
    background: #ffffff;
}

.result-block {
    background: #f7f8fb;
}

.score-final {
    margin: 0 !important;
    font-size: 20px;
    text-align: center;
}

.result-pending {
    padding: 12px;
    border-radius: 12px;
    background: #fff8e6;
    color: var(--warning);
    font-weight: 800;
    text-align: center;
}

.no-filter-results {
    margin-top: 0;
}

@media (max-width: 720px) {
    body {
        padding-top: 118px !important;
    }

    .dashboard-page {
        padding-top: 178px !important;
    }

    .dashboard-page .filters {
        top: 118px !important;
        width: calc(100% - 20px) !important;
        grid-template-columns: 1fr !important;
        max-height: 170px !important;
        overflow-y: auto !important;
    }

    .team-filter {
        width: 100%;
    }

    .team-filter input {
        flex: 1;
    }
}




/* AJUSTE PARA CELULAR */
@media (max-width: 720px) {
    body {
        padding-top: 118px !important;
    }

    .filters {
        top: 118px !important;
        width: calc(100% - 20px) !important;
        max-height: 38vh !important;
        overflow-y: auto !important;
    }

    .matches-grid {
        padding-top: 145px !important;
    }
}

@media (max-width: 720px) {
    :root {
        --topbar-sticky-offset: 118px;
    }

    .topbar,
    .hero {
        align-items: flex-start;
        flex-direction: column;
    }

    .container {
        width: min(100% - 20px, 1180px);
        margin-top: 18px;
    }

    .matches-grid {
        grid-template-columns: 1fr;
    }

    .filters {
        top: var(--topbar-sticky-offset);
        max-height: 45vh;
        overflow-y: auto;
    }
}