:root {
    color-scheme: light;
    --bg: #f4f6f8;
    --surface: #ffffff;
    --ink: #1d2526;
    --muted: #64706f;
    --line: #dbe3e6;
    --accent: #d52f45;
    --accent-dark: #a62234;
    --green: #1f7a5b;
    --blue: #245e96;
    --gold: #d49a27;
    --shadow: 0 18px 45px rgba(31, 43, 48, .08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        linear-gradient(180deg, #ffffff 0, var(--bg) 320px),
        var(--bg);
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
}

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

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 22px;
    padding: 16px 0 6px;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--accent);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.eyebrow.small {
    margin-bottom: 8px;
    font-size: 11px;
}

.subtitle {
    max-width: 640px;
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 15px;
    line-height: 1.5;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0;
    font-size: 52px;
    line-height: 1;
}

.brand-title {
    position: relative;
    display: inline-grid;
    gap: 2px;
    margin-bottom: 0;
    padding-bottom: 7px;
    line-height: .95;
}

.brand-title::after {
    content: "";
    position: absolute;
    left: 4px;
    right: 12px;
    bottom: 0;
    height: 4px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--accent), rgba(213, 47, 69, 0), var(--gold));
    opacity: .28;
}

.brand-title-main {
    color: var(--ink);
    font-size: clamp(24px, 2.8vw, 34px);
    font-weight: 900;
    letter-spacing: -.06em;
    text-transform: uppercase;
}

.brand-title-name {
    justify-self: start;
    border-radius: 999px;
    padding: 3px 12px 5px;
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    color: #fff;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: clamp(18px, 1.9vw, 24px);
    font-style: italic;
    font-weight: 800;
    letter-spacing: .01em;
    box-shadow: 0 8px 18px rgba(213, 47, 69, .18);
}

h2 {
    margin-bottom: 0;
    font-size: 24px;
}

button,
select,
input {
    min-height: 48px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0 16px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
}

button {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 10px 24px rgba(213, 47, 69, .22);
}

button:hover {
    background: var(--accent-dark);
}

.button-secondary {
    border-color: var(--line);
    background: #fff;
    color: var(--ink);
    box-shadow: none;
}

.button-secondary:hover {
    border-color: var(--accent);
    background: #fff5f6;
    color: var(--accent-dark);
}

.topbar-actions {
    display: grid;
    justify-items: end;
    gap: 10px;
}

.topbar-actions form {
    margin: 0;
}

.connected-user {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.admin-shortcut {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    border: 1px solid #f0c4ca;
    border-radius: 999px;
    padding: 0 14px;
    background: #fff5f6;
    color: var(--accent-dark);
    font-size: 13px;
    font-weight: 800;
    text-decoration: none;
}

.admin-shortcut:hover {
    border-color: var(--accent);
    color: var(--accent);
    text-decoration: underline;
}

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

.alert {
    margin-bottom: 18px;
    padding: 14px 16px;
}

.alert-error {
    border-color: #e3a0a7;
    background: #fff5f6;
}

.alert-success {
    border-color: #99d0bd;
    background: #f1fbf7;
}

.login-panel {
    position: relative;
    max-width: 560px;
    margin: 36px auto 22px;
    border: 0;
    padding: 0;
    overflow: hidden;
    background:
        radial-gradient(circle at 88% 10%, rgba(213, 47, 69, .18), transparent 28%),
        radial-gradient(circle at 8% 90%, rgba(36, 94, 150, .16), transparent 30%),
        #fff;
}

.login-panel::before {
    content: "";
    display: block;
    height: 9px;
    background: linear-gradient(90deg, #009ad6, #24489c 45%, #fff 45%, #fff 52%, var(--accent) 52%, var(--accent));
}

.login-hero,
.login-form {
    margin-left: 34px;
    margin-right: 34px;
}

.login-hero {
    display: flex;
    align-items: center;
    gap: 18px;
    padding-top: 30px;
}

.login-fdj-mark {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 72px;
    height: 72px;
    border-radius: 24px;
    background:
        linear-gradient(135deg, #009ad6 0%, #24489c 58%, var(--accent) 59%, var(--accent) 100%);
    color: #fff;
    font-size: 20px;
    font-weight: 900;
    letter-spacing: -.08em;
    box-shadow: 0 16px 32px rgba(36, 72, 156, .24);
    transform: rotate(-4deg);
}

.login-panel h2 {
    font-size: 34px;
}

.login-form {
    display: grid;
    gap: 14px;
    margin-top: 26px;
    padding-bottom: 34px;
}

.login-form label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.login-form input,
.login-form select {
    width: 100%;
    border-color: #cddae1;
    background: rgba(255, 255, 255, .92);
    color: var(--ink);
    font-size: 16px;
    font-weight: 400;
}

.login-form input:focus,
.login-form select:focus {
    border-color: var(--accent);
    outline: 3px solid rgba(213, 47, 69, .16);
}

.login-form button {
    min-height: 54px;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    font-size: 17px;
}

.admin-panel {
    display: grid;
    gap: 18px;
    scroll-margin-top: 18px;
}

.admin-panel[hidden] {
    display: none;
}

.admin-reset-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.admin-reset-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    background: #fbfcfd;
}

.admin-reset-card strong,
.password-status {
    display: block;
}

.password-status {
    margin-top: 4px;
    font-size: 12px;
    font-weight: 700;
}

.password-status.is-set {
    color: var(--green);
}

.password-status.is-empty {
    color: var(--accent-dark);
}

.metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 22px;
}

.metrics article {
    position: relative;
    min-height: 118px;
    padding: 22px;
    overflow: hidden;
}

.metrics article::after {
    content: "";
    position: absolute;
    right: -24px;
    bottom: -28px;
    width: 82px;
    height: 82px;
    border-radius: 50%;
    background: rgba(213, 47, 69, .08);
}

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

.metrics strong {
    display: block;
    margin-top: 8px;
    font-size: 34px;
    line-height: 1.1;
}

.panel {
    margin-bottom: 22px;
    padding: 28px;
}

.annual-stats-panel {
    width: 100%;
    scroll-margin-top: 18px;
}

.generator-panel {
    scroll-margin-top: 18px;
}

.section-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
}

.section-heading > p {
    max-width: 620px;
    margin: 0;
    color: var(--muted);
    line-height: 1.5;
}

.section-heading.compact {
    display: block;
    margin-bottom: 18px;
}

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

.year-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 22px 0 14px;
}

.year-tabs a {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0 16px;
    color: var(--ink);
    font-weight: 700;
    text-decoration: none;
}

.year-tabs a.active {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
}

.year-tabs .export-xlsx-link {
    margin-left: auto;
    border-color: #9ac9b7;
    background: #f1fbf7;
    color: var(--green);
}

.year-tabs .export-xlsx-link:hover {
    border-color: var(--green);
    background: #e5f6ef;
}

.table-explanation {
    margin: 18px 0 16px;
    border: 1px solid #d7e4ef;
    border-radius: 8px;
    padding: 14px 16px;
    background: #f8fbfd;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.45;
}

.table-explanation p {
    margin-bottom: 8px;
    color: var(--ink);
}

.table-explanation ul {
    margin: 0;
    padding-left: 20px;
}

.table-explanation li + li {
    margin-top: 4px;
}

.generator {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 22px 0;
}

.strategy-label {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    margin: 0 0 12px;
    border-radius: 999px;
    padding: 0 12px;
    background: #f8edf0;
    color: var(--accent-dark);
    font-size: 13px;
    font-weight: 700;
}

.strategy-label.strategy-flash {
    background: linear-gradient(135deg, #1d2526, var(--blue));
    color: #fff;
    letter-spacing: .08em;
}

.grid-result {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 14px 0;
}

.generated-options {
    display: grid;
    gap: 14px;
    margin-top: 4px;
}

.generated-grid-card {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 14px 16px;
    background: #fbfcfd;
}

.generated-grid-card .grid-result {
    margin-bottom: 0;
}

.generated-grid-title {
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .06em;
}

.latest-draw-panel {
    display: block;
}

.latest-draw-heading {
    margin-bottom: 18px;
}

.official-result-link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    width: fit-content;
    margin-top: 18px;
    border: 1px solid #d7e4ef;
    border-radius: 999px;
    padding: 9px 16px 9px 10px;
    background: #f8fbfd;
    color: var(--ink);
    font-weight: 700;
    text-decoration: none;
}

.official-result-link:hover {
    border-color: var(--accent);
    color: var(--accent-dark);
}

.fdj-icon {
    display: inline-grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #008fd3 0%, #28489c 54%, #e93b52 55%, #e93b52 100%);
    color: #fff;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: -.04em;
    box-shadow: inset 0 2px 5px rgba(255, 255, 255, .35), 0 8px 18px rgba(36, 72, 156, .18);
}

.latest-draw-panel h2 {
    margin-top: 0;
    margin-bottom: 0;
    font-size: 24px;
}

.latest-draw-list {
    display: grid;
    gap: 18px;
}

.latest-draw-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    border-bottom: 1px solid var(--line);
    padding-bottom: 18px;
}

.latest-draw-row:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.latest-draw-balls {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

.latest-draw-balls span,
.grid-result span {
    display: inline-grid;
    place-items: center;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 28%, #6fa0cf, var(--blue));
    color: #fff;
    font-weight: 800;
    box-shadow: inset 0 2px 4px rgba(255, 255, 255, .25), 0 8px 18px rgba(36, 94, 150, .22);
}

.latest-draw-balls .chance,
.grid-result .chance {
    background: radial-gradient(circle at 35% 28%, #f0c15a, var(--gold));
}

.second-draw-balls span {
    border: 4px solid #f03148;
    background: radial-gradient(circle at 35% 28%, #5562ae, #253583);
}

.latest-draw-unavailable {
    align-items: flex-start;
}

.latest-draw-unavailable p {
    max-width: 560px;
    margin: 0;
    text-align: right;
}

.generator-note {
    margin: 16px 0 0;
}

table {
    width: 100%;
    border-collapse: collapse;
}

.excel-table-wrap {
    margin-top: 18px;
    overflow-x: auto;
    border: 1px solid #1f1f1f;
    background: #fff;
}

.excel-year-table {
    width: 100%;
    min-width: 0;
    border-collapse: collapse;
    font-size: 10px;
    table-layout: fixed;
}

.excel-year-table th,
.excel-year-table td {
    min-width: 0;
    border: 1px solid #1f1f1f;
    padding: 3px 2px;
    text-align: center;
    white-space: nowrap;
}

.excel-year-table .excel-title-row th {
    height: 30px;
    border: 0;
    background: #fff;
    color: #222;
    font-size: 15px;
    font-weight: 800;
    text-align: left;
}

.excel-year-table .month-heading {
    background: #d9eaf7;
    color: #111;
    font-size: 12px;
    font-weight: 900;
}

.excel-year-table .excel-group-heading-row th {
    height: 22px;
    border-top-width: 2px;
    background: #d9eaf7;
}

.excel-year-table .excel-group-heading-row .number-col {
    background: #fff;
    font-size: 15px;
    vertical-align: middle;
}

.excel-year-table .excel-group-heading-row .grand-total-col {
    background: #fff;
    color: #d00000;
    font-size: 15px;
    vertical-align: middle;
}

.excel-year-table .draw-type-row th {
    height: 20px;
    border-bottom-width: 2px;
    background: #d9d9d9;
    font-size: 11px;
    font-style: italic;
    font-weight: 400;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.excel-year-table .number-col {
    position: sticky;
    left: 0;
    z-index: 1;
    width: 34px;
    background: #fff;
    color: #111;
    font-weight: 800;
}

.excel-year-table .grand-total-col,
.excel-year-table .row-total {
    width: 42px;
    color: #d00000;
    font-size: 10px;
    font-weight: 800;
}

.excel-year-table .main-count {
    color: #111;
    width: 32px;
}

.excel-year-table .second-count {
    color: #d00000;
    font-weight: 700;
    width: 32px;
}

.excel-year-table tbody tr:nth-child(odd):not(.excel-subtotal-row):not(.excel-total-row):not(.excel-gap-row) td,
.excel-year-table tbody tr:nth-child(odd):not(.excel-subtotal-row):not(.excel-total-row):not(.excel-gap-row) th {
    background: #f2f2f2;
}

.excel-year-table .excel-subtotal-row th,
.excel-year-table .excel-subtotal-row td {
    border-top-width: 3px;
    border-bottom-width: 3px;
    background: #e6e6e6;
    color: #1d5d8f;
    font-size: 10px;
    font-weight: 800;
}

.excel-year-table .excel-subtotal-row .second-count,
.excel-year-table .excel-total-row td,
.excel-year-table .excel-total-row .row-total {
    color: #d00000;
}

.excel-year-table .excel-total-row th,
.excel-year-table .excel-total-row td {
    border-bottom-width: 3px;
    background: #d9d9d9;
    font-size: 11px;
    font-weight: 900;
}

.excel-year-table .excel-gap-row td {
    height: 13px;
    border: 0;
    background: #fff;
    padding: 0;
}

.excel-year-table tfoot th,
.excel-year-table tfoot td {
    border-top-width: 3px;
    background: #d9eaf7;
    color: #d00000;
    font-weight: 900;
}

table:not(.excel-year-table) th,
table:not(.excel-year-table) td {
    border-bottom: 1px solid var(--line);
    padding: 12px 8px;
    text-align: left;
    white-space: nowrap;
}

table:not(.excel-year-table) th {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.scores-table-wrap {
    max-height: 490px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.scores-table-wrap table {
    display: table;
    margin: 0;
}

.scores-table-wrap thead {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--surface);
}

.sort-button {
    appearance: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border: 0;
    padding: 0;
    color: inherit;
    background: transparent;
    font: inherit;
    font-weight: inherit;
    cursor: pointer;
}

.sort-button::after {
    content: '↕';
    color: var(--muted);
    font-size: 12px;
}

th[aria-sort='ascending'] .sort-button::after {
    content: '↑';
}

th[aria-sort='descending'] .sort-button::after {
    content: '↓';
}

.sort-button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

.recent-draws-wrap {
    overflow-x: auto;
}

.recent-draws-table {
    min-width: 920px;
}

.recent-draws-table td {
    vertical-align: middle;
}

.table-balls {
    display: flex;
    align-items: center;
    gap: 7px;
}

.table-balls span,
.table-ball {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 28%, #6fa0cf, var(--blue));
    color: #fff;
    font-size: 14px;
    font-weight: 800;
    line-height: 1;
    box-shadow: inset 0 2px 4px rgba(255, 255, 255, .25), 0 6px 14px rgba(36, 94, 150, .18);
}

.table-ball.chance {
    background: radial-gradient(circle at 35% 28%, #f0c15a, var(--gold));
}

.second-draw-table-balls span {
    border: 3px solid #f03148;
    background: radial-gradient(circle at 35% 28%, #5562ae, #253583);
}

.site-footer {
    padding: 10px 0 0;
    color: var(--muted);
    font-size: 14px;
    text-align: center;
}

@media (max-width: 800px) {
    .topbar,
    .columns,
    .section-heading {
        display: block;
    }

    .topbar form {
        margin-top: 18px;
    }

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

    .section-heading > p {
        margin-top: 12px;
    }
}

@media (max-width: 520px) {
    .shell {
        width: min(100% - 20px, 1180px);
        padding-top: 20px;
    }

    h1 {
        font-size: 38px;
    }

    .login-hero {
        display: block;
    }

    .login-fdj-mark {
        margin-bottom: 18px;
    }

    .login-hero,
    .login-form {
        margin-left: 22px;
        margin-right: 22px;
    }

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

    table {
        display: block;
        overflow-x: auto;
    }
}
