@font-face {
    font-family: Manrope;
    font-weight: 400 800;
    font-display: swap;
    src: url('fonts/manrope-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+2000-206F, U+2191, U+2193, U+2212;
}
@font-face {
    font-family: Manrope;
    font-weight: 400 800;
    font-display: swap;
    src: url('fonts/manrope-cyrillic.woff2') format('woff2');
    unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
    font-family: 'Press Start 2P';
    font-display: swap;
    src: url('fonts/press-start-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+2000-206F;
}
@font-face {
    font-family: 'Press Start 2P';
    font-display: swap;
    src: url('fonts/press-start-cyrillic.woff2') format('woff2');
    unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

:root {
    color-scheme: dark;
    --base: #12090d;
    --panel: #211318;
    --surface: #2d1a23;
    --border: #442b36;
    --text: #f3e7d4;
    --muted: #c7ac93;
    --gold: #e2a93a;
    --gold-hover: #f3bd57;
    --ink: #2a1608;
    --green: #c5deb0;
    --red: #ffaaa1;
    --display: 'Press Start 2P', Cambria, Georgia, serif;
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --gutter: clamp(16px, 4vw, 32px);
    --control-height: 40px;
    --action-size: 28px;
    --cell-inline: var(--space-4);
    --selection-clearance: 64px;
    font-family: Manrope, 'Segoe UI', system-ui, sans-serif;
    font-size: 15px;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--base); color: var(--text); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .65; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
h1 { font: 400 clamp(1rem, 2.5vw, 1.2rem)/1.5 var(--display); }
h2 { font-size: 1rem; font-weight: 800; }
small { font-size: .82rem; }
a, .accent { color: var(--gold); }
.muted { color: var(--muted); }
.visually-hidden { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; white-space: nowrap; }

.site-header { border-bottom: 1px solid var(--border); background: #170c11; }
.header-inner, .content { max-width: 1200px; margin-inline: auto; padding-inline: var(--gutter); }
.header-inner {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: var(--space-2) var(--space-4);
    min-height: 64px;
}
.brand { display: block; height: auto; }
.site-header nav { display: flex; justify-content: center; flex-wrap: wrap; gap: var(--space-1); }
.nav-item, .quiet, .text-button {
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--muted);
    font-weight: 700;
}
.nav-item { padding: var(--space-2) var(--space-3); font-size: .83rem; white-space: nowrap; text-decoration: none; }
.nav-item[aria-disabled="true"] { opacity: .65; }
.nav-item:hover, .quiet:hover, .text-button:hover { color: var(--text); background: var(--surface); }
.nav-item[aria-current="page"] { color: var(--gold); background: var(--surface); }
.identity { display: flex; align-items: center; justify-self: end; gap: var(--space-2); font-size: .83rem; }
.identity span { max-width: 11ch; overflow: hidden; text-overflow: ellipsis; }

.content { padding-block: clamp(24px, 4vw, 40px) 40px; }
.heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-3);
    min-height: var(--control-height);
    margin-block-end: var(--space-5);
}
.roster-heading {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
}
.roster-heading > .primary { justify-self: end; }
.roster-heading .day-controls { justify-content: center; }
.primary, .secondary, .icon-button {
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    font-weight: 750;
}
.primary { min-height: var(--control-height); padding: var(--space-2) var(--space-4); background: var(--gold); color: var(--ink); border-color: var(--gold); }
.primary:hover { background: var(--gold-hover); border-color: var(--gold-hover); }
.secondary, .icon-button { background: var(--surface); }
.secondary, .quiet { padding: var(--space-1) var(--space-3); font-size: .84rem; }
.secondary { min-height: var(--control-height); }
.secondary:hover, .icon-button:hover { background: #3e2530; border-color: #70505d; }
.icon-button { width: 32px; height: 32px; padding: 0; font-size: 1.2rem; line-height: 1; }
.text-button { color: var(--text); padding: .1rem .2rem; margin-inline: -.2rem; text-align: left; overflow-wrap: anywhere; }
.text-button:hover { color: var(--gold); text-decoration: underline; }
.pay-button { display: inline-grid; place-items: center; width: var(--action-size); height: var(--action-size); color: var(--muted); }
.pay-icon {
    width: 13px;
    height: 13px;
    border: 1.5px solid currentColor;
    border-radius: 50%;
    background: linear-gradient(currentColor, currentColor) center / 4px 1px no-repeat;
}
.paid .pay-icon {
    width: 7px;
    height: 12px;
    border-width: 0 2px 2px 0;
    border-radius: 0;
    background: none;
    transform: translateY(-1px) rotate(45deg);
}
.pay-button.paid { color: var(--green); background: #26301f; border-color: #45553c; }
.pay-button.paid:hover { background: #35422c; }
.payment-cell, .payment-amounts { display: flex; align-items: center; justify-content: end; }
.payment-cell { gap: var(--space-3); }
.payment-amounts { gap: var(--space-2); }
.bonus-button { flex: 0 0 var(--action-size); width: var(--action-size); height: var(--action-size); color: var(--gold); }
.bonus-total { color: var(--gold); }

.panel { margin-block-end: var(--space-4); border: 1px solid var(--border); border-radius: 8px; background: var(--panel); }
.content > .panel:last-child { margin-block-end: 0; }
.day-controls { display: flex; align-items: center; gap: var(--space-2); }
.day-picker { display: grid; gap: var(--space-1); }
.day-step { width: var(--control-height); padding-inline: 0; font-size: 1.1rem; }
.calendar-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    min-height: var(--control-height);
    padding: var(--space-1) var(--space-3);
    border: 1px solid #644254;
    border-radius: 4px;
    background: var(--base);
    color: var(--text);
    font-weight: 750;
    font-variant-numeric: tabular-nums;
}
.calendar-trigger:hover, .calendar-trigger[aria-expanded="true"] { border-color: var(--gold); }
.calendar-icon {
    width: .9rem;
    height: .85rem;
    border: 1px solid currentColor;
    border-radius: 2px;
    background: linear-gradient(currentColor, currentColor) 0 .22rem / 100% 1px no-repeat;
    color: var(--gold);
}
.calendar {
    width: min(336px, calc(100vw - 2 * var(--gutter)));
    max-height: calc(100dvh - 2 * var(--gutter));
    overflow: auto;
    padding: var(--space-3);
    border: 1px solid #644254;
    border-radius: 8px;
    background: var(--panel);
    color: var(--text);
    box-shadow: 0 .6rem 1.5rem #0008;
}
@supports (position-area: bottom) {
    .calendar { inset: auto; margin: var(--space-2) 0; position-area: bottom; position-try-fallbacks: flip-block; }
}
.calendar-header, .calendar-footer { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.calendar-header strong { text-align: center; text-transform: capitalize; font-size: .9rem; }
.calendar-grid { width: 100%; margin-block: var(--space-2); table-layout: fixed; border-spacing: 4px; border-collapse: separate; }
.calendar-grid th, .calendar-grid td { padding: 0; border: 0; background: transparent; text-align: center; }
.calendar-grid th { padding-block: .3rem; }
.calendar-day {
    width: 100%;
    min-height: 36px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 4px;
    background: transparent;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}
.calendar-day.other-month { color: var(--muted); }
.calendar-day:not(:disabled):hover { background: var(--surface); }
.calendar-day[aria-current="date"] { border-color: var(--gold); }
.calendar-day[aria-pressed="true"], .calendar-day[aria-pressed="true"]:hover {
    background: var(--gold);
    color: var(--ink);
    font-weight: 800;
}
.calendar-day:disabled, .day-step:disabled { cursor: default; opacity: .4; }
.calendar-footer { padding-block-start: var(--space-2); border-top: 1px solid var(--border); }
.selection {
    position: fixed;
    z-index: 1000;
    bottom: max(var(--space-4), env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: var(--space-3);
    width: max-content;
    max-width: calc(100% - 2 * var(--gutter));
    padding: var(--space-2) var(--space-3);
    border: 1px solid #644254;
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 .6rem 1.5rem #0008;
}
.selection-count { color: var(--gold); font-size: .85rem; white-space: nowrap; }
.selection-actions { display: flex; align-items: center; gap: var(--space-2); }
.selection .points-controls > span { padding-inline-end: var(--space-1); color: var(--muted); font-size: .8rem; }
.selection-actions > .points-controls + .points-controls { padding-inline-start: var(--space-2); border-inline-start: 1px solid var(--border); }
.selection > .quiet { min-height: var(--action-size); white-space: nowrap; }
.content:has(.selection) { padding-block-end: calc(var(--selection-clearance) + var(--space-6)); }
.content:has(.selection) ~ .snackbar { bottom: calc(max(var(--space-4), env(safe-area-inset-bottom)) + var(--selection-clearance)); }
input:not([type=checkbox]), select, textarea {
    min-width: 0;
    max-width: 100%;
    border: 1px solid #644254;
    border-radius: 4px;
    background: var(--base);
    color: var(--text);
    padding: var(--space-2) var(--space-3);
}
input:not([type=checkbox]), select { min-height: var(--control-height); }
input::placeholder { color: var(--muted); }
input[type=checkbox] { accent-color: var(--gold); width: 16px; height: 16px; margin: 0; vertical-align: middle; cursor: pointer; }
textarea { resize: vertical; }

.table-wrap { position: relative; overflow-x: auto; overscroll-behavior-inline: contain; border-radius: inherit; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; text-align: left; }
th { color: var(--muted); font-size: .79rem; font-weight: 800; background: var(--surface); white-space: nowrap; }
.data-table :is(td, th) { padding: 10px var(--cell-inline); border-top: 1px solid var(--border); vertical-align: middle; }
.data-table th { padding-block: var(--space-2); border-top: 0; }
.data-table tr > :is(th, td) + :is(th, td) { border-left: 1px solid var(--border); }
.data-table .compact-cell { width: 1%; padding-inline: var(--space-3); text-align: center; white-space: nowrap; }
.data-table .compact-cell > button { vertical-align: middle; }
.table-wrap:has(+ .pagination) { border-end-start-radius: 0; border-end-end-radius: 0; }
tr:hover td { background: #291820; }
.data-table .check { width: 44px; padding-inline: var(--space-3); text-align: center; }
.guard-toggle { display: inline-flex; align-items: center; gap: var(--space-3); min-width: 8.75rem; max-width: 18rem; }
.table-edit { width: var(--action-size); height: var(--action-size); color: var(--muted); }
.table-edit:hover { color: var(--gold); }
.guard-actions { display: inline-flex; align-items: center; gap: var(--space-1); vertical-align: middle; }
.stats-link { display: inline-grid; place-items: center; text-decoration: none; }
.stats-icon {
    width: 14px;
    height: 13px;
    background: linear-gradient(currentColor, currentColor) left bottom / 3px 5px no-repeat,
        linear-gradient(currentColor, currentColor) center bottom / 3px 9px no-repeat,
        linear-gradient(currentColor, currentColor) right bottom / 3px 13px no-repeat;
}
.data-table .dismissed-row > td { background: #222023; color: #b5adb2; }
.dismissed-row .guard-toggle, .dismissed-row .rank-cell > span { color: inherit; }
.dismissed-row .guard-chevron { border-color: currentColor; }
.dismissed-label { display: block; margin-left: 1.35rem; color: #b5adb2; }
.dismiss-action { margin-inline-end: auto; color: var(--red); }
.danger-button { background: var(--red); border-color: var(--red); }
.danger-button:hover { background: #ffc9c2; border-color: #ffc9c2; }
.stats-back { display: inline-block; margin-block-end: var(--space-3); }
.stats-heading { align-items: end; }
.stats-title { display: grid; gap: var(--space-2); min-width: 0; }
.stats-name { font-size: clamp(1.05rem, 3vw, 1.55rem); overflow-wrap: anywhere; }
.stats-period-controls { display: flex; align-items: end; flex-wrap: wrap; gap: var(--space-3) var(--space-4); }
.stats-period-options { display: flex; gap: var(--space-1); }
.stats-period-options [aria-pressed="true"] { color: var(--gold); border-color: #947040; background: #3b291e; }
.stats-range { font-size: .85rem; font-variant-numeric: tabular-nums; }
.service-timeline { display: flex; margin: var(--space-4) 0 0; padding: 0; list-style: none; }
.service-timeline li { position: relative; flex: 1; padding-top: var(--space-5); }
.service-timeline li::before {
    position: absolute; top: 0; left: 0; z-index: 1;
    width: .65rem; height: .65rem; border-radius: 50%; background: var(--gold); content: "";
}
.service-timeline li:not(:last-child)::after {
    position: absolute; top: .28rem; left: .65rem; right: 0; height: 1px; background: var(--border); content: "";
}
.service-timeline .service-ended::before { background: var(--red); }
.service-timeline li span { display: block; margin-top: var(--space-1); color: var(--muted); font-size: .84rem; }
.career-heading { padding: var(--space-3) var(--cell-inline); border-bottom: 1px solid var(--border); }
.career-heading + .table-wrap { border-start-start-radius: 0; border-start-end-radius: 0; }
.guard-chevron {
    flex: 0 0 .45rem;
    width: .45rem;
    height: .45rem;
    border-right: 1.5px solid var(--gold);
    border-bottom: 1.5px solid var(--gold);
    transform: rotate(-45deg);
}
.guard-toggle[aria-expanded="true"] .guard-chevron { transform: rotate(45deg); }
.data-table .guard-detail-row > td { background: var(--base); padding: 0; }
.guard-details { max-width: calc(100vw - 2 * var(--gutter) - 2px); padding: var(--cell-inline); }
.note-source { display: block; width: 100%; min-height: 8rem; font-family: Consolas, monospace; }
.rank-cell, .points-cell, .points-controls { display: flex; align-items: center; gap: var(--space-3); }
.rank-cell, .points-cell { justify-content: space-between; }
.points-controls { gap: var(--space-1); }
.points-controls .icon-button, .rank-adjust { width: var(--action-size); height: var(--action-size); }
.rank-adjust { display: grid; place-items: center; }
.rank-adjust.up.recommended { color: var(--gold); border-color: #947040; background: #3b291e; }
.rank-adjust.down.recommended { color: var(--red); border-color: #8b5361; background: #3a232b; }
.rank-adjust:not(:disabled):hover { filter: brightness(1.25); }
.rank-adjust:disabled { cursor: default; opacity: .4; }
.rank-promoted { color: var(--gold); font-weight: 800; }
.rank-demoted { color: var(--red); font-weight: 800; }
.rank-adjust span {
    width: 8px;
    height: 8px;
    border: solid currentColor;
    border-width: 2px 2px 0 0;
    transform: translateY(2px) rotate(-45deg);
}
.rank-adjust.down span { transform: translateY(-2px) rotate(135deg); }
.numeric { font-variant-numeric: tabular-nums; white-space: nowrap; }
.long-text { min-width: 12rem; max-width: 38rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.empty { min-height: 160px; padding: var(--space-6) var(--cell-inline); display: grid; align-content: center; justify-items: center; text-align: center; gap: var(--space-2); }
.empty p { color: var(--muted); font-size: .9rem; }

.chart-panel { padding: var(--space-4) var(--cell-inline); }
.chart-summary { display: flex; align-items: baseline; gap: var(--space-3); margin-top: var(--space-2); font-variant-numeric: tabular-nums; }
.chart-summary strong { font-size: 2rem; line-height: 1.2; }
.chart-positive { color: var(--green); }
.chart-negative { color: var(--red); }
.chart-scroll { overflow-x: auto; padding: var(--space-5) var(--space-4) var(--space-6) max(36px, calc(var(--chart-axis-width) + var(--space-3))); }
.points-plot { position: relative; height: clamp(160px, 25vw, 230px); }
.points-plot canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.chart-gridline { position: absolute; inset-inline: 0; border-top: 1px dashed #64425480; pointer-events: none; }
.chart-gridline:first-of-type { border-top-style: solid; }
.chart-gridline span, .chart-x-tick { position: absolute; color: var(--muted); font-size: .74rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.chart-gridline span { right: calc(100% + .6rem); transform: translateY(-50%); }
.chart-x-tick { top: calc(100% + .65rem); transform: translateX(-50%); }
.chart-x-tick:first-of-type { transform: none; }
.chart-focus-guide { position: absolute; inset-block: 0; border-left: 1px dashed #e2a93a75; pointer-events: none; }
.chart-point {
    position: absolute;
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    transform: translate(-50%, -50%);
}
.chart-point span { width: 9px; height: 9px; border: 2px solid var(--gold); border-radius: 50%; background: var(--panel); }
.chart-point.active span { width: 12px; height: 12px; background: var(--gold); box-shadow: 0 0 0 4px #e2a93a29; }
.chart-tooltip {
    --tooltip-width: min(9.5rem, 100%);
    position: absolute;
    top: calc(var(--point-y) + .8rem);
    left: clamp(0px, calc(var(--point-x) - var(--tooltip-width) / 2), calc(100% - var(--tooltip-width)));
    width: var(--tooltip-width);
    padding: .5rem .65rem;
    border: 1px solid #6a4936;
    border-radius: 6px;
    background: #1a1014;
    box-shadow: 0 .35rem 1rem #0006;
    pointer-events: none;
    font-size: .75rem;
    font-variant-numeric: tabular-nums;
}
.chart-tooltip.above { top: calc(var(--point-y) - .8rem); transform: translateY(-100%); }
.chart-tooltip > div { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0 .55rem; }
.chart-tooltip strong { font-size: 1.15rem; }
.pagination { padding: var(--space-3) var(--cell-inline); text-align: center; border-top: 1px solid var(--border); }
.snackbar {
    position: fixed;
    right: max(var(--space-4), env(safe-area-inset-right));
    bottom: max(var(--space-4), env(safe-area-inset-bottom));
    z-index: 1100;
    display: flex;
    align-items: center;
    gap: var(--space-3);
    width: max-content;
    max-width: min(26rem, calc(100vw - 2rem));
    padding: var(--space-2) var(--space-3);
    border: 1px solid;
    border-radius: 6px;
    box-shadow: 0 .6rem 1.5rem #0008;
    font-size: .9rem;
    overflow-wrap: anywhere;
}
.snackbar .quiet { flex: none; color: inherit; font-size: 1.15rem; line-height: 1; }
.snackbar-error { background: #3d2026; color: var(--red); border-color: #805052; }
.snackbar-success { background: #232e20; color: var(--green); border-color: #495c40; }

.gate {
    min-height: calc(100dvh - 65px);
    display: grid;
    place-items: start center;
    padding: clamp(32px, 5vw, 48px) var(--gutter);
    background: radial-gradient(ellipse at 50% 0%, #3e211a75, transparent 62%);
}
.login-card, .dialog {
    width: min(100%, 430px);
    padding: clamp(16px, 5vw, 24px);
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel);
    color: var(--text);
}
.login-card h1 { text-align: center; font-size: 1.15rem; margin-block-end: var(--space-5); }
form, label { display: grid; gap: var(--space-1); }
form { gap: var(--space-4); }
label { font-size: .84rem; font-weight: 700; color: var(--muted); }
.full { width: 100%; font: 400 .75rem/1.5 var(--display); }
.dialog { width: min(calc(100% - 2 * var(--gutter)), 450px); max-height: calc(100dvh - 2 * var(--gutter)); overflow: auto; }
.dialog::backdrop { background: #0e050bc9; }
.dialog header, .dialog footer { display: flex; justify-content: space-between; align-items: center; gap: var(--space-2); }
.dialog header { margin-block-end: var(--space-4); }
.dialog header h2 { overflow-wrap: anywhere; }
.dialog header .icon-button { flex-shrink: 0; }
.dialog footer { justify-content: end; flex-wrap: wrap; margin-block-start: var(--space-1); }
.field-with-hint { display: grid; gap: var(--space-1); }
.coin-input { min-width: 0; margin: 0; padding: 0; border: 0; }
.coin-input legend { margin-block-end: var(--space-2); padding: 0; font-size: .84rem; font-weight: 700; }
.coin-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-2); }

@media (min-width: 881px) {
    :root { scrollbar-gutter: stable both-edges; }
}
@media (max-width: 880px) {
    .header-inner { grid-template-columns: minmax(0, 1fr) auto; padding-block: var(--space-3); }
    .site-header nav { grid-column: 1 / -1; grid-row: 2; justify-content: start; }
}
@media (max-width: 700px) {
    :root { --cell-inline: var(--space-3); --selection-clearance: 136px; }
    .roster-heading { grid-template-columns: minmax(0, 1fr) auto; }
    .roster-heading .day-picker { grid-column: 1 / -1; grid-row: 2; }
    .selection { grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-2); width: min(360px, calc(100% - 2 * var(--gutter))); }
    .selection-actions { grid-column: 1 / -1; grid-row: 2; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2) var(--space-4); }
    .selection-actions > .points-controls + .points-controls { padding-inline-start: 0; border-inline-start: 0; }
    .selection .points-controls > span { margin-inline-end: auto; padding: 0; }
    .selection > .quiet { grid-column: 2; grid-row: 1; padding-inline: var(--space-1); }
}
@media (max-width: 480px) {
    .brand { width: 104px; }
    .site-header nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); text-align: center; }
    .identity { gap: var(--space-1); }
    .identity span { max-width: 7ch; }
    .roster-heading > .primary { font-size: .84rem; padding-inline: var(--space-3); }
}
@media (max-width: 360px) {
    .roster-heading { grid-template-columns: 1fr; }
    .roster-heading .day-picker { grid-row: auto; }
    .roster-heading > .primary { justify-self: stretch; }
}
