:root {
    --court: #1e4d3a;
    --court-dark: #143528;
    --court-mid: #2f6b4f;
    --court-light: #3d8b64;
    --clay: #c4654a;
    --clay-deep: #8c4332;
    --clay-soft: #f4d7c8;
    --line-gold: #c4a574;
    --cream: #f6f1e7;
    --cream-2: #fbf7f0;
    --ink: #1f2421;
    --muted: #6d645c;
    --line: #e4dcd0;
    --white: #fffdf9;
    --danger: #a33b32;
    --shadow: 0 10px 30px rgba(20, 53, 40, 0.12);
    --radius: 14px;
    --sidebar: 260px;
    --field-bg: #fffdf9;
    --font: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--font);
    color: var(--ink);
    background: var(--cream);
    line-height: 1.5;
    font-size: 16px;
}
a { color: var(--court-mid); }
img { max-width: 100%; }

.app { display: flex; min-height: 100vh; }
.sidebar {
    width: var(--sidebar);
    background: var(--court-dark);
    color: #f6f1e7;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    flex-shrink: 0;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.1rem 1rem 0.6rem;
}
.sidebar-brand strong { font-size: 1.05rem; letter-spacing: 0.01em; }
.crest {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--court);
    color: var(--clay-soft);
    border: 2px solid var(--line-gold);
    font-weight: 800;
    flex-shrink: 0;
}
.sidebar-toggle {
    margin-left: auto;
    background: transparent;
    color: var(--clay-soft);
    border: 1px solid rgba(244, 215, 200, 0.35);
    border-radius: 999px;
    width: 32px;
    height: 32px;
    cursor: pointer;
}
.sidebar-nav { overflow: auto; padding: 0.4rem 0.75rem 1rem; flex: 1; }
.nav { list-style: none; margin: 0; padding: 0; }
.nav a, .nav button.linkish {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    color: #f6f1e7;
    text-decoration: none;
    padding: 0.45rem 0.7rem;
    border-radius: 999px;
    border-left: 3px solid transparent;
    font-size: 0.94rem;
}
.nav a:hover { background: rgba(255, 253, 249, 0.06); }
.nav a.active {
    background: rgba(196, 165, 116, 0.16);
    border-left-color: var(--line-gold);
}
.nav-short { display: none; width: 1.4rem; text-align: center; font-weight: 700; }
.nav-group-label {
    margin: 0.9rem 0.7rem 0.25rem;
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--line-gold);
    font-weight: 700;
}
.nav-sub { list-style: none; margin: 0; padding: 0 0 0 0.35rem; }
.sidebar-foot { padding: 0.8rem; }
.sidebar-version { color: rgba(246, 241, 231, 0.55); font-size: 0.75rem; margin: 0 0.4rem 0.6rem; }
.signout button {
    width: 100%;
    background: transparent;
    color: #f6f1e7;
    border: 1px solid rgba(246, 241, 231, 0.35);
    border-radius: 999px;
    padding: 0.55rem 0.8rem;
    cursor: pointer;
    font-weight: 600;
}
.test-badge, .badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    border-radius: 999px;
    padding: 0.15rem 0.55rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.test-badge { background: #f4d7c8; color: #6a2e22; margin: 0 0.8rem 0.4rem; }
.badge-pending { background: #fff4dd; color: #8a6a00; }
.badge-ok { background: #e6f4ea; color: #157347; }
.badge-off { background: #fde8ea; color: #9b1c2f; }
.badge-sim { background: var(--clay-soft); color: var(--clay-deep); }
.badge-live { background: #e7f3ec; color: var(--court); }

.content { flex: 1; padding: 1.6rem 2rem 3rem; max-width: 1100px; }
.content--full { max-width: none; }
.page-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-end; margin-bottom: 1rem; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 1.6rem; color: var(--court-dark); }
.page-head p { margin: 0.2rem 0 0; color: var(--muted); }

.panel {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem 1.1rem 1.15rem;
    margin-bottom: 1rem;
}
.panel-head {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    align-items: center;
    border-bottom: 1px solid var(--line);
    margin: -0.2rem 0 0.8rem;
    padding-bottom: 0.6rem;
}
.panel h2 { margin: 0; font-size: 1.05rem; color: var(--court-dark); }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.8rem; margin-bottom: 1rem; }
.stat {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 0.9rem 1rem 1rem;
    border-top: 4px solid var(--line-gold);
}
.stat span { display: block; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-size: 0.72rem; font-weight: 700; }
.stat strong { display: block; font-size: 1.55rem; color: var(--court-dark); margin-top: 0.2rem; }

.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
table.table th {
    text-align: left;
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    background: var(--clay-soft);
    color: var(--clay-deep);
    padding: 0.55rem 0.6rem;
}
table.table td { padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.table tr:hover td { background: #faf7f1; }
.amount-pos { color: var(--court-mid); font-variant-numeric: tabular-nums; font-weight: 700; }
.amount-neg { color: var(--clay-deep); font-variant-numeric: tabular-nums; font-weight: 700; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    border-radius: 999px;
    border: 1px solid transparent;
    background: var(--court);
    color: white;
    padding: 0.65rem 1.15rem;
    font-weight: 650;
    text-decoration: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.95rem;
}
.btn:hover { background: var(--court-light); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; color: var(--court); border-color: var(--line); }
.btn.ghost:hover { background: var(--cream); }
.btn.danger { background: var(--danger); }
.btn.small { padding: 0.35rem 0.75rem; font-size: 0.85rem; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.45; pointer-events: none; }

label { display: block; font-weight: 700; font-size: 0.9rem; margin-bottom: 0.25rem; }
.hint, .muted { color: var(--muted); }
.tiny { font-size: 0.8rem; }
.input, select.input, textarea.input {
    width: 100%;
    background: var(--field-bg);
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0.65rem 0.75rem;
    font: inherit;
    margin-bottom: 0.8rem;
}
textarea.input { min-height: 110px; }
.code-input { text-align: center; font-size: 1.6rem; letter-spacing: 0.35em; font-weight: 800; }
.input:focus, select.input:focus, textarea.input:focus {
    outline: 2px solid rgba(47, 107, 79, 0.35);
    border-color: var(--court-light);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
.choice-row { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.8rem; }
.choice {
    position: relative;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0.35rem 0.75rem;
    background: white;
    cursor: pointer;
    font-size: 0.9rem;
}
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice:has(input:checked) { background: var(--court); color: white; border-color: var(--court); }
.choice:has(input:disabled) { opacity: 0.45; }

.alert { border-radius: 10px; padding: 0.7rem 0.85rem; margin-bottom: 0.8rem; }
.alert-success { background: #e7f3ec; border: 1px solid #b8dcc6; }
.alert-error { background: #fbe9eb; border: 1px solid #f0c2c7; }
.notice { background: var(--clay-soft); border-radius: 10px; padding: 0.75rem 0.9rem; margin-bottom: 0.8rem; }

.player-chip { display: inline-flex; align-items: center; gap: 0.45rem; text-decoration: none; color: inherit; font-weight: 650; }
.player-chip img, .avatar {
    width: 32px; height: 32px; border-radius: 50%; object-fit: cover; background: var(--court-dark);
}
.avatar.lg { width: 96px; height: 96px; }
.hero-player { display: flex; gap: 1rem; align-items: center; }
.move-up { color: var(--court-mid); font-weight: 800; }
.move-down { color: var(--clay); font-weight: 800; }
.move-same { color: var(--muted); font-weight: 700; }
.form-pips { display: flex; gap: 0.2rem; }
.pip { width: 1.15rem; height: 1.15rem; border-radius: 999px; display: grid; place-items: center; font-size: 0.68rem; font-weight: 800; color: white; }
.pip.W { background: var(--court-mid); }
.pip.L { background: var(--clay); }

.calendar { min-width: 720px; }
.slot-grid { display: grid; gap: 0.45rem; }
.slot {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0.55rem 0.7rem;
    cursor: pointer;
    background: white;
}
.slot:has(input:checked) { border-color: var(--court); background: #e7f3ec; }
.slot-taken { opacity: 0.5; cursor: not-allowed; }

.public-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.9rem 1.4rem;
    background: var(--court-dark);
    color: #f6f1e7;
}
.public-bar a { color: #f6f1e7; text-decoration: none; margin-right: 0.9rem; font-weight: 650; }
.public-wrap { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1.2rem 3rem; }
.hero {
    background:
        radial-gradient(600px 180px at 10% 0%, rgba(196, 101, 74, 0.18), transparent 60%),
        linear-gradient(160deg, #1e4d3a, #143528);
    color: #f6f1e7;
    border-radius: var(--radius);
    padding: 1.6rem 1.5rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}
.hero h1 { margin: 0 0 0.35rem; font-size: 2rem; }
.hero p { margin: 0; max-width: 42rem; color: #f4d7c8; }

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background:
        radial-gradient(500px 200px at 80% 0%, rgba(196, 165, 116, 0.25), transparent 50%),
        linear-gradient(165deg, #2f6b4f, #143528);
    padding: 1.5rem;
}
.auth-card {
    width: min(440px, 100%);
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.4rem 1.3rem 1.5rem;
}
.auth-card h1 { margin: 0.4rem 0 0.2rem; color: var(--court-dark); }

.modal[hidden] { display: none; }
.modal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 1rem; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(20, 37, 28, 0.55); }
.modal-card {
    position: relative;
    background: white;
    border-radius: var(--radius);
    padding: 1.2rem 1.2rem 1rem;
    width: min(460px, 100%);
    box-shadow: var(--shadow);
}
.modal-card h2 { margin: 0 0 0.4rem; color: var(--court-dark); }
.row-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1rem; }
body.modal-open { overflow: hidden; }

.dl { display: grid; grid-template-columns: 140px 1fr; gap: 0.35rem 0.8rem; }
.dl dt { color: var(--muted); font-size: 0.85rem; }
.receipt { max-width: 720px; }
.receipt-line { display: flex; justify-content: space-between; gap: 1rem; padding: 0.35rem 0; border-bottom: 1px solid var(--line); }

.pager { display: flex; gap: 0.6rem; align-items: center; margin-top: 0.8rem; }
.check-list { list-style: none; padding: 0; margin: 0; }
.check-list li { margin: 0.2rem 0; }

html.sidebar-collapsed .sidebar { width: 72px; }
html.sidebar-collapsed .sidebar-brand strong,
html.sidebar-collapsed .nav-label,
html.sidebar-collapsed .nav-group-label,
html.sidebar-collapsed .sidebar-version,
html.sidebar-collapsed .test-badge,
html.sidebar-collapsed .signout span { display: none; }
html.sidebar-collapsed .nav-short { display: inline; }
html.sidebar-collapsed .sidebar-brand { padding-left: 0.7rem; padding-right: 0.4rem; }
html.sidebar-collapsed .nav a { justify-content: center; padding-left: 0.4rem; padding-right: 0.4rem; }

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
textarea:-webkit-autofill,
textarea:-webkit-autofill:hover,
textarea:-webkit-autofill:focus,
select:-webkit-autofill,
select:-webkit-autofill:hover,
select:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--ink) !important;
    caret-color: var(--ink);
    transition: background-color 99999s ease-out 0s;
    -webkit-box-shadow: 0 0 0 1000px var(--field-bg, #fffdf9) inset !important;
    box-shadow: 0 0 0 1000px var(--field-bg, #fffdf9) inset !important;
}

@media (max-width: 900px) {
    .stat-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 720px) {
    .app { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: relative; }
    html.sidebar-collapsed .sidebar { width: 100%; }
    html.sidebar-collapsed .sidebar-nav { display: none; }
    .content { padding: 1.1rem; }
    .form-row, .stat-grid, .dl { grid-template-columns: 1fr; }
    .public-bar { flex-wrap: wrap; gap: 0.4rem; }
}

@media print {
    .sidebar, .public-bar, .no-print, .signout, .test-badge { display: none !important; }
    .app { display: block; }
    .content, .public-wrap { max-width: none; padding: 0; }
    .panel, .stat { box-shadow: none; }
    body { background: white; }
}
