:root {
    --bg: #f5f7fa;
    --surface: #ffffff;
    --ink: #15202b;
    --muted: #657786;
    --line: #d9e2ec;
    --brand: #0f766e;
    --brand-ink: #ffffff;
    --danger: #b42318;
    --ok: #067647;
    --warn: #b54708;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--ink);
}

a {
    color: inherit;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 14px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    font-weight: 800;
    text-decoration: none;
}

.brand img {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    flex: 0 0 auto;
}

.topbar nav {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
}

.shell {
    width: min(1120px, 100%);
    margin: 0 auto;
    padding: 18px 14px 56px;
}

.panel, .match, .stat, .login-box {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.panel, .login-box {
    padding: 18px;
}

.hero {
    margin: 0 0 18px;
}

.hero h1 {
    margin: 0 0 8px;
    font-size: clamp(1.6rem, 7vw, 2.6rem);
    line-height: 1.05;
}

.hero p, .muted {
    color: var(--muted);
}

.public-hero {
    display: grid;
    align-items: end;
    min-height: 220px;
    margin: -18px -14px 18px;
    padding: 28px 14px;
    background:
        linear-gradient(135deg, rgba(15, 118, 110, 0.92), rgba(21, 32, 43, 0.88)),
        url("https://digitalhub.fifa.com/transform/79c870d2-d8a9-450d-8a01-260f8a1f0c9e/FIFA-World-Cup-2026-Host-Cities") center / cover;
    color: #fff;
}

.public-hero h1 {
    max-width: 780px;
    margin: 8px 0;
    font-size: clamp(2.2rem, 12vw, 4.4rem);
    line-height: 0.96;
}

.public-hero p {
    max-width: 620px;
    margin: 0 0 14px;
    color: rgba(255, 255, 255, 0.86);
    font-size: 1.08rem;
    line-height: 1.45;
}

.eyebrow {
    display: inline-block;
    font-weight: 800;
    text-transform: uppercase;
    font-size: 0.78rem;
}

.public-grid {
    display: grid;
    grid-template-columns: minmax(280px, 380px) 1fr;
    gap: 14px;
    align-items: start;
    margin-bottom: 14px;
}

.public-grid.login-only {
    grid-template-columns: minmax(280px, 420px);
}

.public-login {
    width: 100%;
    margin: 0;
}

.public-login h2,
.live-panel h2,
.schedule-preview h2 {
    margin: 0 0 6px;
}

.leaderboard-list {
    display: grid;
    gap: 8px;
}

.leaderboard-row {
    display: grid;
    grid-template-columns: 34px 1fr auto;
    gap: 10px;
    align-items: center;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.leaderboard-row span {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 999px;
    background: #e6fffb;
    color: var(--brand);
    font-weight: 900;
}

.leaderboard-row strong {
    min-width: 0;
    overflow-wrap: anywhere;
}

.leaderboard-row em {
    color: var(--ink);
    font-style: normal;
    font-weight: 900;
}

.fixture-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 10px;
}

.fixture-preview-card {
    display: grid;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.fixture-date {
    display: grid;
    gap: 2px;
}

.fixture-date span,
.fixture-preview-card p {
    margin: 0;
    color: var(--muted);
    font-size: 0.86rem;
}

.fixture-line {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 8px;
    align-items: center;
}

.fixture-line span:last-child {
    text-align: right;
}

.fixture-line b {
    min-width: 48px;
    text-align: center;
}

.grid {
    display: grid;
    gap: 12px;
}

.grid.two {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    margin: 16px 0;
}

.stat {
    padding: 14px;
}

.stat strong {
    display: block;
    font-size: 1.5rem;
}

.tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 4px 0 12px;
    margin: 0 -2px 10px;
}

.tabs a {
    flex: 0 0 auto;
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    text-decoration: none;
    font-size: 0.9rem;
}

.tabs a.active {
    background: var(--brand);
    color: var(--brand-ink);
    border-color: var(--brand);
}

.match {
    padding: 14px;
    margin-bottom: 10px;
}

.match-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: var(--muted);
    font-size: 0.86rem;
    margin-bottom: 12px;
}

.teams {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 10px;
}

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

.score-inputs {
    display: grid;
    grid-template-columns: 54px 20px 54px;
    align-items: center;
    gap: 6px;
}

input, button, select {
    font: inherit;
}

input[type="text"], input[type="password"], input[type="number"], select {
    width: 100%;
    min-height: 44px;
    padding: 9px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
}

input[type="number"] {
    text-align: center;
}

.btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-height: 44px;
    padding: 9px 14px;
    border: 1px solid var(--brand);
    border-radius: 8px;
    background: var(--brand);
    color: var(--brand-ink);
    text-decoration: none;
    font-weight: 700;
    cursor: pointer;
}

.btn.secondary {
    background: var(--surface);
    color: var(--brand);
}

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

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
}

.flash {
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 14px;
    background: #ecfdf3;
    color: var(--ok);
    border: 1px solid #abefc6;
}

.flash.error {
    background: #fef3f2;
    color: var(--danger);
    border-color: #fecdca;
}

.flash.warn {
    background: #fffaeb;
    color: var(--warn);
    border-color: #fedf89;
}

.sync-status {
    display: grid;
    gap: 4px;
    margin: 12px 0;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
}

.sync-status p {
    margin: 0;
    color: var(--muted);
}

.sync-status.success {
    border-color: #abefc6;
    background: #ecfdf3;
}

.sync-status.failed {
    border-color: #fecdca;
    background: #fef3f2;
}

.sync-status.running {
    border-color: #fedf89;
    background: #fffaeb;
}

.btn:disabled {
    cursor: progress;
    opacity: 0.72;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}

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

th {
    color: var(--muted);
    font-size: 0.85rem;
}

.login-box {
    width: min(460px, 100%);
    margin: 48px auto;
}

.login-box h1 {
    margin-top: 0;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 3px 8px;
    border-radius: 999px;
    background: #eef4ff;
    color: #3538cd;
    font-size: 0.8rem;
    font-weight: 700;
}

.section-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
    margin-bottom: 12px;
}

.section-head h2 {
    margin: 0 0 4px;
    font-size: 1.15rem;
}

.section-head p {
    margin: 0;
}

.schedule-groups {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 12px;
}

.group-panel {
    padding: 14px;
}

.schedule-list {
    display: grid;
    gap: 10px;
}

.schedule-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 12px;
}

.schedule-card-top {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
    color: var(--muted);
    font-size: 0.84rem;
    margin-bottom: 10px;
}

.status-chip {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 800;
}

.status-chip.open {
    color: #3538cd;
    background: #eef4ff;
}

.status-chip.done {
    color: var(--ok);
    background: #ecfdf3;
}

.schedule-teams {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 10px;
    align-items: center;
}

.schedule-teams strong:last-child {
    text-align: right;
}

.schedule-teams span {
    min-width: 56px;
    text-align: center;
    font-weight: 800;
}

.path-line {
    margin-top: 10px;
    color: var(--muted);
    font-size: 0.88rem;
}

.meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
    margin: 12px 0 0;
}

.meta-grid div {
    min-width: 0;
}

.meta-grid dt {
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 700;
}

.meta-grid dd {
    margin: 2px 0 0;
    overflow-wrap: anywhere;
    font-size: 0.88rem;
}

.bracket-strip {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(300px, 380px);
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 8px;
}

.bracket-card {
    min-width: 0;
}

.print-sheet {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.print-code-card {
    min-height: 180px;
    display: grid;
    align-content: space-between;
    gap: 10px;
    padding: 18px;
    border: 1px dashed #94a3b8;
    border-radius: 8px;
    background: #fff;
    break-inside: avoid;
}

.print-code-card h2,
.print-code-card p {
    margin: 0;
}

.print-code-card h2 {
    font-size: 1.15rem;
}

.print-code-card strong {
    display: block;
    padding: 12px;
    border-radius: 8px;
    background: var(--ink);
    color: #fff;
    text-align: center;
    font-size: 2rem;
    letter-spacing: 0;
}

@media (max-width: 620px) {
    .public-hero {
        min-height: 250px;
    }

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

    .fixture-line {
        grid-template-columns: 1fr;
        align-items: start;
    }

    .fixture-line span:last-child,
    .fixture-line b {
        text-align: left;
    }

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

    .team.away {
        text-align: left;
    }

    .score-inputs {
        width: 100%;
        grid-template-columns: 1fr 20px 1fr;
    }

    .match-head {
        display: block;
    }

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

    .schedule-teams {
        grid-template-columns: 1fr;
        align-items: start;
    }

    .schedule-teams strong:last-child,
    .schedule-teams span {
        text-align: left;
    }

    .bracket-strip {
        grid-auto-columns: minmax(280px, 86vw);
    }
}

@media print {
    body {
        background: #fff;
    }

    .topbar,
    .no-print,
    .flash,
    .tabs {
        display: none !important;
    }

    .shell {
        width: 100%;
        padding: 0;
        margin: 0;
    }

    .print-sheet {
        grid-template-columns: repeat(2, 1fr);
        gap: 10mm;
        margin: 0;
    }

    .print-code-card {
        min-height: 62mm;
        border: 1px solid #222;
        page-break-inside: avoid;
    }
}
