:root {
    --blue: #002f6c;
    --deep: #07182f;
    --cyan: #00a3e0;
    --green: #00a859;
    --gold: #f7c948;
    --paper: #f6f8fb;
    --text: #132033;
    --muted: #64748b;
    --line: #dbe3ef;
}
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    color: var(--text);
    background: var(--paper);
}
a { color: var(--blue); text-decoration: none; font-weight: 700; }
.topbar {
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    background: var(--blue);
    color: white;
}
.topbar a, .topbar button { color: white; }
.brand { font-size: 20px; }
nav, .actions, .inline { display: flex; align-items: center; gap: 12px; }
.container { width: min(1180px, calc(100% - 32px)); margin: 28px auto; }
.hero {
    min-height: 360px;
    display: flex;
    align-items: center;
    padding: 48px;
    color: white;
    background: linear-gradient(135deg, var(--blue), #0057a8 55%, var(--green));
    border-radius: 8px;
}
.hero h1 { max-width: 760px; font-size: clamp(34px, 5vw, 62px); line-height: 1; margin: 0 0 16px; }
.hero p { max-width: 680px; font-size: 18px; }
.eyebrow { text-transform: uppercase; letter-spacing: 0; color: var(--cyan); font-weight: 800; margin: 0 0 6px; }
.panel, .auth-card, .mini-panel, .card {
    background: white;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 22px;
    margin-bottom: 18px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, .06);
}
.auth-card { max-width: 520px; margin: 48px auto; }
.button, button {
    border: 0;
    border-radius: 6px;
    background: var(--gold);
    color: var(--deep);
    padding: 11px 16px;
    font-weight: 800;
    cursor: pointer;
}
.button.ghost, .topbar .button.small {
    background: rgba(255,255,255,.14);
    color: inherit;
    border: 1px solid rgba(255,255,255,.25);
}
.button.ghost.dark { color: var(--blue); border-color: var(--line); }
.flag-icon {
    width: 24px;
    height: 18px;
    object-fit: cover;
    border-radius: 2px;
    box-shadow: 0 0 0 1px rgba(15, 23, 42, .12);
    vertical-align: -3px;
    margin-right: 6px;
}
.topbar form button { background: transparent; padding: 0; }
label { display: grid; gap: 6px; font-weight: 700; margin-bottom: 14px; }
input, select {
    width: 100%;
    min-height: 40px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 8px 10px;
    font: inherit;
}
.grid { display: grid; gap: 16px; }
.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.page-head {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: center;
    margin-bottom: 20px;
}
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.card { display: grid; gap: 8px; margin: 0; color: inherit; }
.muted { color: var(--muted); }
.rules { columns: 2; line-height: 1.8; }
.row-form { display: flex; gap: 10px; align-items: end; }
.admin-row-form { margin: 14px 0; }
.admin-row-form label { min-width: 260px; margin-bottom: 0; }
.admin-assign-form {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr) auto;
    gap: 12px;
    align-items: end;
}
.admin-assign-form label { margin-bottom: 0; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px; border-bottom: 1px solid var(--line); text-align: left; }
th { color: var(--muted); font-size: 13px; text-transform: uppercase; }
.badge { display: inline-block; padding: 4px 8px; border-radius: 999px; background: #e9f2ff; color: var(--blue); font-weight: 700; }
.alert { padding: 12px 14px; border-radius: 6px; margin-bottom: 16px; font-weight: 700; }
.success { background: #e6f8ee; color: #05603a; }
.error { background: #feeceb; color: #b42318; }
.sync-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}
.sync-panel h2 { margin-top: 0; }
.sync-panel form { flex: 0 0 auto; }
.sync-panel button:disabled { opacity: .55; cursor: not-allowed; }
.sync-status { margin-bottom: 0; }
.result-source {
    width: max-content;
    padding: 2px 7px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
}
.result-source.api { background: #e9f2ff; color: var(--blue); }
.result-source.manual { background: #fff8df; color: #7a5700; }
.match-row {
    display: grid;
    grid-template-columns: 170px 1fr 64px 20px 64px 1fr auto auto;
    gap: 10px;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}
.match-meta { display: grid; gap: 4px; color: var(--muted); font-size: 13px; }
.team-name { min-width: 0; font-weight: 700; }
.score-input { text-align: center; }
.versus { text-align: center; color: var(--muted); }
.standings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.qualified td { background: #e6f8ee; }
.third td { background: #fff8df; }
.team-select { margin-bottom: 8px; }
.phase-panel {
    border-top: 1px solid var(--line);
    padding-top: 16px;
    margin-top: 16px;
}
.phase-panel h3 { margin: 0 0 12px; color: var(--blue); }
.knockout-choice, .readonly-pick {
    display: grid;
    grid-template-columns: 1fr 42px 1fr;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
}
.pick-card {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
}
.pick-card.selected {
    border-color: var(--green);
    background: #e6f8ee;
}
.pick-card input { width: auto; min-height: auto; }
.bonus-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.bonus-item {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--line);
}
.bonus-item strong { color: var(--muted); }
.bonus-item .hit, .hit { color: var(--green); }
.readonly-pick {
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}
.readonly-pick strong { text-align: center; color: var(--blue); }
.readonly-pick-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 36px minmax(0, 1fr) minmax(220px, .8fr);
    gap: 12px;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}
.readonly-team {
    min-width: 0;
    font-weight: 700;
    overflow-wrap: anywhere;
}
.readonly-vs {
    text-align: center;
    color: var(--muted);
    font-weight: 700;
}
.readonly-winner {
    min-width: 0;
    color: var(--blue);
    overflow-wrap: anywhere;
}
.readonly-winner strong { display: block; }
.sticky-actions {
    position: sticky;
    bottom: 0;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px;
    background: rgba(246,248,251,.94);
    border-top: 1px solid var(--line);
}
.check { display: flex; grid-auto-flow: column; align-items: center; gap: 6px; margin: 0; }
.check input { width: auto; min-height: auto; }
.inline-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 3px 4px 3px 0;
    padding: 4px 6px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #f8fafc;
}
.inline-chip button {
    padding: 3px 6px;
    background: #feeceb;
    color: #b42318;
    font-size: 12px;
}
@media (max-width: 850px) {
    .two, .three { grid-template-columns: 1fr; }
    .page-head, .row-form { flex-direction: column; align-items: stretch; }
    .admin-assign-form { grid-template-columns: 1fr; }
    .rules { columns: 1; }
    .match-row { grid-template-columns: 1fr 54px 16px 54px 1fr; }
    .match-meta { grid-column: 1 / -1; }
    .knockout-choice, .readonly-pick { grid-template-columns: 1fr; }
    .knockout-choice .versus { display: none; }
    .readonly-pick-card { grid-template-columns: 1fr; }
    .readonly-vs { text-align: left; }
    .sync-panel { align-items: stretch; flex-direction: column; }
}
