:root {
    --bg: #f6f7f2;
    --surface: #ffffff;
    --surface-alt: #eef2ef;
    --text: #18201c;
    --muted: #66736c;
    --line: #d9ded8;
    --primary: #116c5d;
    --primary-strong: #0a4f44;
    --danger: #b42318;
    --warning: #a15c07;
    --shadow: 0 12px 30px rgba(24, 32, 28, 0.08);
}

* {
    box-sizing: border-box;
}

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

a {
    color: var(--primary);
    text-decoration: none;
}

input,
select,
button {
    font: inherit;
}

input,
select {
    width: 100%;
    min-height: 38px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    padding: 8px 10px;
}

input:focus,
select:focus {
    border-color: var(--primary);
    outline: 2px solid rgba(17, 108, 93, 0.14);
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 16px 28px;
    background: rgba(255, 255, 255, 0.94);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(10px);
}

.account-nav {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-size: 13px;
    white-space: nowrap;
}

.account-nav form {
    display: inline-flex;
}

.brand {
    display: block;
    color: var(--text);
    font-size: 20px;
    font-weight: 800;
}

.subtitle {
    color: var(--muted);
    font-size: 13px;
}

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

.nav-link,
.tabs a {
    border-radius: 6px;
    color: var(--text);
    font-weight: 650;
    padding: 9px 12px;
}

.nav-link.active,
.tabs a.active {
    background: var(--primary);
    color: #fff;
}

.page {
    width: min(1240px, calc(100% - 32px));
    margin: 0 auto;
    padding: 28px 0 56px;
}

.page-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 18px;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--primary);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1,
h2 {
    margin: 0;
    line-height: 1.15;
}

h1 {
    font-size: 34px;
}

h2 {
    font-size: 18px;
}

.panel,
.metric-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.panel {
    margin-bottom: 18px;
    padding: 18px;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.metric-card {
    padding: 16px;
}

.metric-card span {
    display: block;
    min-height: 38px;
    color: var(--muted);
    font-weight: 650;
}

.metric-card strong {
    display: block;
    font-size: 32px;
    line-height: 1;
}

.split-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.leader {
    display: grid;
    gap: 5px;
}

.leader strong {
    font-size: 24px;
}

.leader b {
    color: var(--primary-strong);
    font-size: 20px;
}

.inline-form,
.row-form,
.team-row-form,
.match-row-form,
.score-form {
    display: flex;
    align-items: end;
    gap: 10px;
}

.inline-form {
    flex-wrap: wrap;
}

.inline-form label {
    min-width: 220px;
    flex: 1;
}

label span {
    display: block;
    margin-bottom: 5px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    border: 0;
    border-radius: 6px;
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    font-weight: 750;
    padding: 8px 14px;
    white-space: nowrap;
}

.button:hover {
    background: var(--primary-strong);
}

.button.small {
    min-height: 34px;
    padding: 7px 10px;
}

.button.danger {
    background: var(--danger);
}

.link-button {
    border: 0;
    background: transparent;
    color: var(--primary);
    cursor: pointer;
    font-weight: 750;
    padding: 0;
}

.auth-shell {
    display: grid;
    min-height: calc(100vh - 170px);
    place-items: center;
}

.auth-panel {
    width: min(100%, 430px);
}

.stack-form {
    display: grid;
    gap: 14px;
    margin-top: 18px;
}

.stack-form.constrained {
    max-width: 560px;
}

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--line);
    padding-bottom: 10px;
}

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

table {
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
}

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

th {
    background: var(--surface-alt);
    color: #39433e;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

tr:last-child td {
    border-bottom: 0;
}

.actions {
    width: 1%;
    text-align: right;
}

.actions form {
    display: inline-flex;
}

.pill,
.status {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 750;
    padding: 4px 10px;
}

.pill {
    background: var(--surface-alt);
    color: var(--muted);
}

.status.pending {
    background: #fff4db;
    color: var(--warning);
}

.status.played {
    background: #dff5ed;
    color: var(--primary-strong);
}

.flash {
    border-radius: 8px;
    font-weight: 700;
    margin-bottom: 14px;
    padding: 12px 14px;
}

.flash.success {
    background: #dff5ed;
    color: var(--primary-strong);
}

.flash.error {
    background: #ffe5e0;
    color: var(--danger);
}

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

.muted {
    display: block;
    margin-top: 6px;
    font-size: 13px;
}

.rank {
    color: var(--primary-strong);
    font-weight: 850;
}

.score-input {
    width: 72px;
}

.versus {
    color: var(--muted);
    font-weight: 800;
}

@media (max-width: 960px) {
    .topbar,
    .page-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .account-nav {
        align-items: flex-start;
        flex-direction: column;
    }

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

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

@media (max-width: 680px) {
    .page {
        width: min(100% - 20px, 1240px);
        padding-top: 18px;
    }

    .topbar {
        padding: 14px 16px;
    }

    h1 {
        font-size: 28px;
    }

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

    .inline-form,
    .row-form,
    .team-row-form,
    .match-row-form,
    .score-form {
        align-items: stretch;
        flex-direction: column;
    }

    .inline-form label {
        min-width: 100%;
    }

    .score-input {
        width: 100%;
    }
}
