:root {
    --green-950: #102a22;
    --green-900: #173b2e;
    --green-800: #23513d;
    --green-700: #2f6b4d;
    --green-100: #e5eee8;
    --cream: #f4f0e5;
    --paper: #fffdf7;
    --gold: #c6a15b;
    --ink: #17211c;
    --muted: #6a756f;
    --line: #d9dfd9;
    --danger: #a33d35;
    --shadow: 0 18px 45px rgba(16, 42, 34, .11);
}

* { box-sizing: border-box; }
html { color-scheme: light; scroll-behavior: smooth; }
body {
    margin: 0;
    background: var(--cream);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.site-header {
    min-height: 84px;
    padding: 16px clamp(20px, 5vw, 76px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--green-950);
    color: white;
    border-bottom: 3px solid var(--gold);
}
.brand, .brand span, .site-header nav { display: flex; align-items: center; }
.brand { gap: 12px; }
.brand > span:last-child { align-items: flex-start; flex-direction: column; }
.brand strong { font-family: Georgia, serif; font-size: 1.25rem; letter-spacing: .03em; }
.brand small { color: #c6d5cd; }
.brand-mark { width: 46px; height: 46px; }
.brand-mark svg { width: 100%; fill: none; stroke: var(--gold); stroke-width: 2; }
.site-header nav { gap: 24px; font-size: .94rem; font-weight: 650; }
.site-header nav form { margin: 0; }
.link-button { padding: 0; border: 0; background: none; color: white; font-weight: 650; }
main { min-height: calc(100vh - 155px); }
.hero {
    min-height: 420px;
    padding: 72px clamp(20px, 8vw, 120px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 60px;
    overflow: hidden;
    color: white;
    background:
        radial-gradient(circle at 78% 50%, rgba(198,161,91,.16) 0 3px, transparent 4px 36px, rgba(198,161,91,.12) 37px 39px, transparent 40px 74px, rgba(198,161,91,.1) 75px 77px, transparent 78px),
        linear-gradient(120deg, var(--green-950), var(--green-800));
}
.eyebrow {
    margin: 0 0 10px;
    color: var(--gold);
    font-size: .76rem;
    font-weight: 800;
    letter-spacing: .16em;
    text-transform: uppercase;
}
h1, h2, p { margin-top: 0; }
h1, h2 { font-family: Georgia, "Times New Roman", serif; }
h1 { margin-bottom: 20px; font-size: clamp(2.45rem, 5vw, 5.4rem); line-height: .98; font-weight: 500; }
.hero-copy { max-width: 650px; color: #d5e1db; font-size: 1.05rem; line-height: 1.7; }
.hero-target {
    width: 250px;
    aspect-ratio: 1;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    border: 1px solid rgba(198,161,91,.58);
    border-radius: 50%;
    box-shadow: inset 0 0 0 28px rgba(255,255,255,.03), inset 0 0 0 29px rgba(198,161,91,.35), inset 0 0 0 64px rgba(255,255,255,.02), inset 0 0 0 65px rgba(198,161,91,.26);
}
.hero-target span { font-family: Georgia, serif; color: var(--gold); font-size: 2.2rem; }
.ranking-shell { padding: 56px clamp(16px, 5vw, 76px) 72px; }
.ranking-toolbar, .admin-heading {
    margin-bottom: 28px;
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 24px;
}
.ranking-toolbar h2, .admin-heading h1 { margin: 0; font-size: clamp(2rem, 4vw, 3.4rem); font-weight: 500; }
.live-status { display: grid; grid-template-columns: auto auto; align-items: center; gap: 3px 8px; color: var(--green-800); font-weight: 700; }
.live-status small { grid-column: 2; color: var(--muted); font-weight: 500; }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: #36a166; box-shadow: 0 0 0 6px rgba(54,161,102,.12); }
.ranking-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.junior-grid { margin-top: 18px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.ranking-card, .panel, .stats-grid > div {
    background: var(--paper);
    border: 1px solid rgba(35,81,61,.13);
    border-radius: 4px;
    box-shadow: var(--shadow);
}
.card-heading {
    padding: 18px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--line);
    color: var(--green-900);
    font-family: Georgia, serif;
    font-size: 1.35rem;
}
.card-heading small { color: var(--muted); font: 700 .68rem Inter, sans-serif; letter-spacing: .11em; text-transform: uppercase; }
.ranking-list { min-height: 250px; }
.ranking-row {
    min-height: 72px;
    padding: 12px 16px;
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--line);
}
.ranking-row:last-child { border-bottom: 0; }
.ranking-row-updated {
    animation: ranking-update 1.1s ease-out;
}
@keyframes ranking-update {
    0% {
        opacity: .25;
        transform: translateY(-8px);
        background: rgba(198, 161, 91, .3);
    }
    45% { opacity: 1; }
    100% {
        transform: translateY(0);
        background: transparent;
    }
}
.rank { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; background: var(--green-100); color: var(--green-800); font-weight: 800; }
.rank-1 { background: var(--gold); color: var(--green-950); }
.competitor, .score { display: flex; flex-direction: column; min-width: 0; }
.competitor strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.competitor small, .score small { margin-top: 4px; color: var(--muted); font-size: .72rem; }
.score { align-items: end; }
.score strong { color: var(--green-800); font-family: Georgia, serif; font-size: 1.35rem; }
.empty-state { padding: 48px 20px; color: var(--muted); text-align: center; }
.score-note { margin: 20px 0 0; color: var(--muted); font-size: .82rem; }
.mobile-filter { display: none; }
.button {
    min-height: 44px;
    padding: 11px 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--green-800);
    border-radius: 3px;
    background: var(--green-800);
    color: white;
    font-weight: 750;
}
.button:hover { background: var(--green-950); color: white; }
.button-small { min-height: 36px; padding: 8px 14px; background: var(--gold); border-color: var(--gold); color: var(--green-950); }
.site-header .button-small:hover { color: var(--gold); }
.button-outline { background: transparent; color: var(--green-800); }
.login-layout {
    padding: 80px clamp(20px, 10vw, 150px);
    display: grid;
    grid-template-columns: 1.1fr minmax(320px, 480px);
    gap: 80px;
    align-items: center;
}
.login-layout h1 { color: var(--green-950); font-size: clamp(2.5rem, 5vw, 4.7rem); }
.panel { padding: 24px; }
.login-panel { display: grid; gap: 18px; }
.login-panel h2 { margin: 0; color: var(--green-900); font-size: 2rem; }
label { display: grid; gap: 7px; color: var(--green-900); font-size: .8rem; font-weight: 750; }
label small { color: var(--muted); font-weight: 500; }
input, select, textarea {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid #b8c3bc;
    border-radius: 3px;
    background: white;
    color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(47,107,77,.16); border-color: var(--green-700); }
.checkbox { display: flex; align-items: center; gap: 8px; }
.checkbox input { width: auto; min-height: 0; }
.form-error { padding: 12px; border-left: 4px solid var(--danger); background: #f8e8e5; color: #752b26; }
.flash { margin: 20px auto -20px; max-width: 900px; padding: 13px 18px; background: #dcebdd; color: var(--green-900); border-left: 4px solid var(--green-700); }
.admin-body { overflow-x: hidden; background: #edf1ec; }
.admin-shell {
    width: 100%;
    min-height: 100vh;
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
}
.admin-sidebar {
    min-height: 100vh;
    padding: 28px 18px 20px;
    position: sticky;
    top: 0;
    align-self: start;
    display: flex;
    flex-direction: column;
    background: var(--green-950);
    color: white;
    border-right: 3px solid var(--gold);
}
.admin-brand {
    padding: 0 10px 28px;
    display: flex;
    align-items: center;
    gap: 11px;
    border-bottom: 1px solid rgba(255, 255, 255, .12);
}
.admin-brand > span:last-child { display: flex; align-items: flex-start; flex-direction: column; }
.admin-brand strong { font-family: Georgia, serif; font-size: 1.18rem; }
.admin-brand small { color: #aebfb6; font-size: .72rem; }
.admin-nav { margin-top: 24px; display: grid; gap: 6px; }
.admin-nav a {
    min-height: 48px;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-radius: 4px;
    color: #c6d5cd;
    font-size: .9rem;
    font-weight: 700;
}
.admin-nav a span {
    width: 26px;
    height: 26px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(198, 161, 91, .45);
    border-radius: 50%;
    color: var(--gold);
    font-size: .62rem;
}
.admin-nav a:hover, .admin-nav a.active {
    background: rgba(255, 255, 255, .09);
    color: white;
}
.admin-nav a.active { box-shadow: inset 3px 0 var(--gold); }
.admin-sidebar-footer {
    margin-top: auto;
    padding: 24px 10px 0;
    display: grid;
    gap: 13px;
    border-top: 1px solid rgba(255, 255, 255, .12);
    color: #c6d5cd;
    font-size: .82rem;
    font-weight: 650;
}
.admin-sidebar-footer form { margin: 0; }
.admin-logout { padding: 0; border: 0; background: none; color: #c6d5cd; font-weight: 650; }
.admin-main { min-width: 0; min-height: 100vh; }
.admin-topbar {
    min-height: 126px;
    padding: 34px clamp(22px, 4vw, 56px) 28px;
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 24px;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
}
.admin-topbar h1 {
    margin: 0;
    color: var(--green-950);
    font-size: clamp(2rem, 4vw, 3.25rem);
    font-weight: 500;
}
.admin-topbar .eyebrow { margin-bottom: 6px; }
.admin-content { padding: 28px clamp(22px, 4vw, 56px) 56px; }
.admin-flash { margin: 20px clamp(22px, 4vw, 56px) 0; max-width: none; }
.admin-page-error { margin: 20px clamp(22px, 4vw, 56px) 0; }
.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 15px;
}
.dashboard-stats a {
    min-height: 170px;
    padding: 22px;
    display: flex;
    flex-direction: column;
    background: var(--paper);
    border: 1px solid rgba(35, 81, 61, .13);
    border-radius: 4px;
    box-shadow: var(--shadow);
    transition: transform .18s ease, border-color .18s ease;
}
.dashboard-stats a:hover { transform: translateY(-3px); border-color: var(--green-700); }
.dashboard-stats .stat-number { color: var(--green-800); font: 2.7rem Georgia, serif; }
.dashboard-stats strong { margin-top: auto; color: var(--green-950); }
.dashboard-stats small { margin-top: 5px; color: var(--muted); font-size: .75rem; }
.dashboard-welcome {
    margin-top: 20px;
    min-height: 210px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 36px;
    background:
        radial-gradient(circle at 88% 50%, rgba(198,161,91,.1) 0 3px, transparent 4px 35px, rgba(198,161,91,.08) 36px 38px, transparent 39px),
        var(--paper);
}
.dashboard-welcome h2 {
    margin-bottom: 10px;
    overflow-wrap: anywhere;
    color: var(--green-950);
    font-size: clamp(1.55rem, 7vw, 2rem);
}
.dashboard-welcome p:not(.eyebrow) { max-width: 680px; margin-bottom: 0; color: var(--muted); line-height: 1.65; }
.dashboard-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.admin-page-grid { display: grid; grid-template-columns: minmax(340px, .8fr) minmax(0, 1.2fr); gap: 20px; align-items: start; }
.admin-form-panel { max-width: 1050px; }
.admin-list-panel { margin-top: 20px; }
.form-grid-wide { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.panel-heading { margin-bottom: 22px; display: flex; gap: 12px; align-items: flex-start; }
.panel-heading > span { width: 34px; height: 34px; display: grid; place-items: center; background: var(--green-900); color: var(--gold); border-radius: 50%; font-size: .7rem; font-weight: 800; }
.panel-heading h2 { margin: 0 0 3px; color: var(--green-900); font-size: 1.55rem; }
.panel-heading p { margin: 0; color: var(--muted); font-size: .8rem; }
.form-grid { margin-bottom: 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .86rem; }
th, td { padding: 12px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--green-800); font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; }
.badge { padding: 4px 8px; border-radius: 20px; font-size: .68rem; font-weight: 800; }
.badge-paid { background: #dcebdd; color: #235f3d; }
.badge-open { background: #f4e7c8; color: #795b1f; }
.badge-invoice { background: #dce5ef; color: #31536f; }
.table-actions { display: flex; align-items: center; gap: 8px; }
.table-actions form { margin: 0; }
.table-action {
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--green-800);
    font: inherit;
    font-weight: 750;
    cursor: pointer;
}
.table-action:hover { text-decoration: underline; }
.table-action-danger { color: var(--danger); }
.edit-result-heading { margin-top: 30px; }
.payment-summary {
    margin-bottom: 20px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 260px));
    gap: 14px;
}
.payment-summary > div {
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    background: var(--paper);
    border: 1px solid rgba(35,81,61,.13);
    border-radius: 4px;
    box-shadow: var(--shadow);
}
.payment-summary strong { color: var(--green-800); font: 2rem Georgia, serif; }
.payment-summary span { color: var(--muted); font-size: .78rem; }
.pagination {
    padding-top: 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    color: var(--muted);
    font-size: .8rem;
}
.pagination-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.pagination-link {
    min-width: 36px;
    min-height: 36px;
    padding: 7px 10px;
    display: inline-grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 3px;
    background: white;
    color: var(--green-800);
    font-weight: 750;
}
.pagination-link:hover, .pagination-link.active {
    border-color: var(--green-800);
    background: var(--green-800);
    color: white;
}
.pagination-link.disabled { opacity: .45; cursor: not-allowed; }
footer {
    min-height: 70px;
    padding: 20px clamp(20px, 5vw, 76px);
    display: flex;
    justify-content: space-between;
    gap: 20px;
    background: var(--green-950);
    color: #b9c9c1;
    font-size: .8rem;
}

@media (max-width: 1000px) {
    .ranking-grid { grid-template-columns: 1fr; }
    .ranking-card { display: none; }
    .ranking-card.mobile-active { display: block; }
    .junior-grid { display: contents; }
    .mobile-filter { display: grid; min-width: 220px; }
    .live-status { display: none; }
    .admin-shell { min-width: 0; grid-template-columns: minmax(0, 1fr); }
    .admin-sidebar {
        width: 100%;
        min-width: 0;
        min-height: 0;
        padding: 14px 18px;
        position: static;
        border-right: 0;
        border-bottom: 3px solid var(--gold);
    }
    .admin-brand { padding: 0 0 13px; }
    .admin-brand .brand-mark { width: 38px; height: 38px; }
    .admin-nav {
        width: 100%;
        min-width: 0;
        margin-top: 12px;
        display: flex;
        overflow-x: auto;
        scrollbar-width: none;
    }
    .admin-nav::-webkit-scrollbar { display: none; }
    .admin-nav a { min-width: max-content; }
    .admin-sidebar-footer { display: none; }
    .dashboard-stats { grid-template-columns: 1fr 1fr; }
    .admin-page-grid { grid-template-columns: 1fr; }
    .form-grid-wide { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 720px) {
    .site-header { min-height: 72px; padding: 12px 16px; }
    .brand small, .site-header nav > a:not(.button) { display: none; }
    .site-header nav { gap: 10px; }
    .hero { min-height: 360px; padding: 54px 20px; }
    .hero-target { display: none; }
    .ranking-toolbar, .admin-topbar { align-items: stretch; flex-direction: column; }
    .mobile-filter { min-width: 0; }
    .login-layout { padding: 48px 16px; grid-template-columns: 1fr; gap: 26px; }
    .admin-topbar { min-height: 0; padding: 24px 16px 20px; }
    .admin-content { padding: 18px 16px 42px; }
    .admin-flash, .admin-page-error { margin-right: 16px; margin-left: 16px; }
    .dashboard-stats { grid-template-columns: 1fr 1fr; }
    .dashboard-stats a { min-height: 145px; padding: 17px; }
    .dashboard-welcome { align-items: stretch; flex-direction: column; }
    .dashboard-actions { flex-direction: column; }
    .form-grid-wide { grid-template-columns: 1fr; }
    .payment-summary { grid-template-columns: 1fr 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .form-grid .full { grid-column: auto; }
    .pagination { align-items: flex-start; flex-direction: column; }
    footer { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
    .ranking-row-updated { animation: none; }
    .dashboard-stats a { transition: none; }
}
