/* ============ Tokens ============ */
:root {
    color-scheme: light;
    --bg: #f3f4f1;
    --surface: #ffffff;
    --surface-2: #f8f9f6;
    --text: #1b2220;
    --muted: #68726e;
    --line: #e2e5df;
    --line-strong: #cdd2ca;
    --accent: #0f766e;
    --accent-hover: #0c625b;
    --accent-ink: #ffffff;
    --accent-soft: #e3f3ef;
    --abs: #b42318;
    --abs-soft: #fdeceb;
    --skip: #4d5761;
    --skip-soft: #eceff2;
    --ok: #067647;
    --ok-soft: #e4f5ea;
    --warn: #a15c07;
    --warn-soft: #fdf2dc;
    --today: #fff8e1;
    --shadow: 0 1px 2px rgba(20, 30, 25, 0.05), 0 4px 16px rgba(20, 30, 25, 0.05);
    --shadow-pop: 0 8px 30px rgba(20, 30, 25, 0.16);
    --radius: 12px;
    --radius-sm: 8px;
    --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2368726e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");

    --cat-budget: #0f766e;
    --cat-paid: #b45309;
    --cat-lowincome: #7c3aed;
    --cat-vpo: #2563eb;
    --cat-ubd: #be123c;
}

/* Dark theme — chosen with the toggle in the header (light is the default). */
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0f1412;
    --surface: #171d1b;
    --surface-2: #1c2421;
    --text: #e4eae7;
    --muted: #95a19c;
    --line: #28312d;
    --line-strong: #36413c;
    --accent: #2fb3a3;
    --accent-hover: #46c4b5;
    --accent-ink: #06201c;
    --accent-soft: #15302b;
    --abs: #f47c70;
    --abs-soft: #3a1e1b;
    --skip: #b9c2cc;
    --skip-soft: #262d33;
    --ok: #5fd08f;
    --ok-soft: #173025;
    --warn: #f0b04a;
    --warn-soft: #34280f;
    --today: #2a2715;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-pop: 0 10px 34px rgba(0, 0, 0, 0.5);
    --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2395a19c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");

    --cat-budget: #2fb3a3;
    --cat-paid: #f0a24a;
    --cat-lowincome: #a78bfa;
    --cat-vpo: #6ea8fe;
    --cat-ubd: #fb7185;
}

/* ============ Base ============ */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font:
        14px / 1.45 system-ui,
        -apple-system,
        "Segoe UI",
        Roboto,
        sans-serif;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--accent);
}
h1,
h2,
h3 {
    margin: 0;
    letter-spacing: -0.01em;
}
h2 {
    font-size: 15px;
    font-weight: 650;
}
.icon {
    flex: none;
    display: block;
}
.muted {
    color: var(--muted);
    font-size: 13px;
}
.small {
    font-size: 12px;
}
.center {
    text-align: center;
}
/* A negative balance must stay red whatever muted colour its context sets. */
.neg {
    /* biome-ignore lint/complexity/noImportantStyles: see above */
    color: var(--abs) !important;
}

input,
select,
textarea,
button {
    font: inherit;
    color: inherit;
}

input:not([type]),
input[type="text"],
input[type="password"],
input[type="date"],
select,
textarea {
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    padding: 7px 10px;
    transition:
        border-color 0.15s,
        box-shadow 0.15s;
}
/* Own arrow instead of the native one: same spacing in every browser and both themes. */
select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 34px;
    background: var(--surface) var(--chevron) no-repeat right 10px center / 16px 16px;
    cursor: pointer;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
button:focus-visible,
a:focus-visible,
summary:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ============ App bar ============ */
.appbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 16px;
    height: 60px;
    padding: 0 20px;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: saturate(1.4) blur(10px);
    border-bottom: 1px solid var(--line);
}
.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    text-decoration: none;
    min-width: 0;
}
.logo-mark {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: var(--accent);
    color: var(--accent-ink);
}
.logo-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    min-width: 0;
}
.logo-text b {
    font-size: 15px;
}
.logo-text small {
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.saving {
    margin-left: auto;
    font-size: 12px;
    color: var(--muted);
    opacity: 0;
    transition: opacity 0.2s;
}
.saving.htmx-request {
    opacity: 1;
}

.tabs {
    display: flex;
    gap: 4px;
}

.theme-toggle {
    flex: none;
}
.theme-toggle .icon-sun,
:root[data-theme="dark"] .theme-toggle .icon-moon {
    display: none;
}
:root[data-theme="dark"] .theme-toggle .icon-sun {
    display: block;
}
.tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    color: var(--muted);
    text-decoration: none;
    font-weight: 550;
}
.tab:hover {
    background: var(--surface-2);
    color: var(--text);
}
.tab.active {
    background: var(--accent-soft);
    color: var(--accent);
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
}

/* ============ Buttons ============ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 38px;
    padding: 0 14px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
    font-weight: 550;
    cursor: pointer;
    white-space: nowrap;
    transition:
        background 0.15s,
        border-color 0.15s;
}
.btn:hover {
    border-color: var(--muted);
}
.btn.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-ink);
}
.btn.primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.icon-btn {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    text-decoration: none;
}
.icon-btn:hover {
    border-color: var(--line-strong);
    background: var(--surface-2);
}
.icon-btn:disabled {
    opacity: 0.35;
    cursor: default;
}
.icon-btn.lg {
    width: 44px;
    height: 44px;
}
.icon-btn.danger {
    color: var(--muted);
    border-color: transparent;
    background: none;
}
.icon-btn.danger:hover {
    color: var(--abs);
    background: var(--abs-soft);
}

/* ============ Page head, popovers ============ */
.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}
.page-head .title {
    font-size: 24px;
}
.month-switch {
    display: flex;
    align-items: center;
    gap: 6px;
}

details.popover {
    position: relative;
}
details.popover > summary {
    list-style: none;
    cursor: pointer;
}
details.popover > summary::-webkit-details-marker {
    display: none;
}
.popover-body {
    position: absolute;
    z-index: 30;
    top: calc(100% + 6px);
    min-width: 200px;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-pop);
}
.print-menu .popover-body {
    right: 0;
}
.menu a {
    display: block;
    padding: 8px 12px;
    border-radius: 6px;
    color: var(--text);
    text-decoration: none;
}
.menu a:hover {
    background: var(--surface-2);
}
.menu a:first-child {
    font-weight: 600;
    border-bottom: 1px solid var(--line);
    border-radius: 6px 6px 0 0;
    margin-bottom: 4px;
}

.month-title {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
}
.month-title:hover {
    background: var(--surface);
}
.month-title h1 {
    font-size: 24px;
    font-weight: 700;
    white-space: nowrap;
}
.month-title h1 span {
    color: var(--muted);
    font-weight: 500;
}
.month-picker .popover-body {
    left: 0;
    width: 260px;
    padding: 12px;
}
.year-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}
.month-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
}
.month-grid a::first-letter {
    text-transform: uppercase;
}
.month-grid a {
    padding: 8px 0;
    text-align: center;
    border-radius: 6px;
    color: var(--text);
    text-decoration: none;
}
.month-grid a:hover {
    background: var(--surface-2);
}
.month-grid a.current {
    background: var(--accent);
    color: var(--accent-ink);
    font-weight: 600;
}

/* ============ Cards & stats ============ */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    margin-bottom: 16px;
}
.card.flush {
    padding: 0;
    overflow: hidden;
}
.card-head {
    display: flex;
    align-items: baseline;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.card-head.pad {
    padding: 14px 16px 12px;
    margin: 0;
    border-bottom: 1px solid var(--line);
}

.stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}
.stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.stat span {
    color: var(--muted);
    font-size: 13px;
}
.stat b {
    font-size: 24px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}
.stat b small {
    font-size: 14px;
    color: var(--muted);
    font-weight: 500;
}
.stat em {
    font-style: normal;
    font-size: 12px;
    color: var(--muted);
}
.stat em.warn {
    color: var(--warn);
}
.stat.accent {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-ink);
}
.stat.accent span,
.stat.accent b small {
    color: inherit;
    opacity: 0.8;
}

/* ============ Category labels ============ */
.cat {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-weight: 650;
}
.cat::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--c, var(--accent));
}
.cat-budget {
    --c: var(--cat-budget);
}
.cat-paid {
    --c: var(--cat-paid);
}
.cat-lowincome {
    --c: var(--cat-lowincome);
}
.cat-vpo {
    --c: var(--cat-vpo);
}
.cat-ubd {
    --c: var(--cat-ubd);
}

/* ============ Days picker ============ */
.days-picker {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
    gap: 6px;
}
.chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 5px 0 4px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--muted);
    font-weight: 600;
    line-height: 1.15;
    cursor: pointer;
    transition:
        background 0.12s,
        border-color 0.12s,
        color 0.12s;
}
.chip small {
    font-size: 10px;
    font-weight: 500;
}
.chip:hover {
    border-color: var(--line-strong);
    color: var(--text);
}
.chip.weekend:not(.on) {
    background: transparent;
    border-style: dashed;
    opacity: 0.7;
}
.chip.on {
    background: var(--accent-soft);
    border-color: color-mix(in srgb, var(--accent) 45%, transparent);
    color: var(--accent);
}
.chip.is-today {
    box-shadow: inset 0 -3px 0 var(--warn);
}

/* ============ Grid ============ */
.legend {
    color: var(--muted);
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.legend i {
    font-style: normal;
    display: inline-grid;
    place-items: center;
}
.lg-abs {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    background: var(--abs-soft);
    color: var(--abs);
    font-weight: 700;
}
.lg-skip {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    background: var(--skip-soft);
    color: var(--skip);
    font-weight: 700;
}
.lg-warn {
    width: 18px;
    height: 3px;
    border-radius: 2px;
    background: var(--warn);
    margin-left: 8px;
}

.grid-wrap {
    overflow: auto;
    max-height: calc(100vh - 140px);
}
table.grid {
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    min-width: 100%;
}
table.grid th,
table.grid td {
    padding: 0 6px;
    height: 34px;
    text-align: center;
    white-space: nowrap;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}
table.grid thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    background: var(--surface-2);
    font-weight: 600;
    color: var(--muted);
    font-size: 12px;
}
table.grid thead tr.prices th {
    top: 44px;
    height: 40px;
    background: var(--surface);
}
table.grid thead tr:first-child th {
    height: 44px;
}
table.grid th.day {
    color: var(--text);
    font-size: 13px;
    line-height: 1.1;
}
table.grid th.day small {
    display: block;
    color: var(--muted);
    font-weight: 500;
    font-size: 11px;
}
table.grid thead tr:first-child th.no-price {
    box-shadow: inset 0 -2px 0 var(--warn);
}
table.grid .ate-mark {
    color: var(--line-strong);
    font-weight: 600;
}
table.grid .today {
    background-color: var(--today);
}
table.grid thead th.today {
    background-color: var(--today);
}

table.grid .num {
    width: 36px;
    min-width: 36px;
    max-width: 36px;
    padding: 0;
    color: var(--muted);
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--surface);
}
table.grid .name {
    position: sticky;
    left: 36px;
    z-index: 2;
    min-width: 210px;
    text-align: left;
    background: var(--surface);
    box-shadow: 1px 0 0 var(--line-strong);
}
table.grid thead .num,
table.grid thead .name {
    z-index: 4;
    background: var(--surface-2);
}
table.grid thead tr.prices .num,
table.grid thead tr.prices .name {
    background: var(--surface);
}
table.grid thead tr.prices .name {
    color: var(--muted);
    font-weight: 500;
}
.name-wrap {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

table.grid tbody tr:hover td {
    background-color: var(--surface-2);
}
table.grid td.cell {
    min-width: 52px;
    cursor: pointer;
    user-select: none;
    color: var(--muted);
}
table.grid td.cell:hover {
    box-shadow: inset 0 0 0 2px var(--accent);
    color: var(--text);
}
table.grid td.abs,
table.grid tbody tr:hover td.abs {
    background: var(--abs-soft);
    color: var(--abs);
    font-weight: 700;
}
table.grid td.skip,
table.grid tbody tr:hover td.skip {
    background: var(--skip-soft);
    color: var(--skip);
    font-weight: 700;
}
table.grid td.sum {
    font-weight: 650;
}
.pending {
    opacity: 0.45;
    pointer-events: none;
}

table.grid tr.group td {
    height: 38px;
    background: var(--surface-2);
    text-align: left;
    padding: 0;
}
/* The cell spans the whole table, so the label (not the cell) sticks to the left edge. */
table.grid tr.group .group-label {
    position: sticky;
    left: 0;
    display: inline-flex;
    align-items: center;
    padding: 0 12px;
}
table.grid tr.group .count {
    color: var(--muted);
    font-size: 12px;
    margin-left: 10px;
}
table.grid tr.subtotal td {
    font-weight: 650;
    background: var(--surface);
    border-bottom: 2px solid var(--line-strong);
}
table.grid tr.subtotal td.name {
    color: var(--muted);
    font-weight: 600;
}

input.money {
    width: 64px;
    text-align: right;
    padding: 5px 6px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 6px;
    font-variant-numeric: tabular-nums;
}
input.money::placeholder {
    color: var(--muted);
    opacity: 0.6;
}
input.money:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
th.no-price input.money {
    border-color: color-mix(in srgb, var(--warn) 45%, var(--line));
}

.row-btn {
    opacity: 0;
    border: 1px solid var(--line-strong);
    background: var(--surface);
    border-radius: 5px;
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
    cursor: pointer;
    padding: 1px 6px;
    transition: opacity 0.12s;
}
tr:hover .row-btn,
.row-btn:focus-visible {
    opacity: 1;
}
.row-btn:hover {
    color: var(--abs);
    border-color: var(--abs);
}

.empty-state {
    display: grid;
    justify-items: center;
    gap: 10px;
    padding: 40px 16px;
    color: var(--muted);
    text-align: center;
}
.empty-state p {
    margin: 0;
}

/* ============ Forms (students, settings) ============ */
.split {
    display: grid;
    grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}
.split > .card {
    margin: 0;
}
.field {
    display: grid;
    gap: 6px;
    margin-bottom: 14px;
}
.field > span {
    font-size: 13px;
    color: var(--muted);
    font-weight: 550;
}
.field input,
.field select,
.field textarea {
    width: 100%;
}
textarea {
    resize: vertical;
    line-height: 1.5;
}
fieldset {
    border: 0;
    padding: 0;
    margin: 0 0 8px;
    min-width: 0;
}
legend {
    float: left;
    width: 100%;
    padding: 0;
    font-weight: 650;
    font-size: 15px;
    margin-bottom: 12px;
}
legend + * {
    clear: both;
}
fieldset + fieldset {
    border-top: 1px solid var(--line);
    padding-top: 16px;
}
.notice {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    margin: 0 0 14px;
    font-weight: 550;
}
.notice.ok {
    background: var(--ok-soft);
    color: var(--ok);
}

.list-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    margin: 18px 0 8px;
}
.list-head:first-of-type {
    margin-top: 4px;
}
#students {
    container-type: inline-size;
}
ul.students {
    list-style: none;
    margin: 0;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
}
.student {
    display: grid;
    grid-template-columns: 28px minmax(180px, 1fr) minmax(160px, 220px) auto;
    gap: 8px;
    align-items: center;
    padding: 6px 8px;
}
.student + .student {
    border-top: 1px solid var(--line);
}
.student .num {
    color: var(--muted);
    font-size: 12px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}
.student .name-field {
    display: block;
    width: 100%;
    min-height: 36px;
    resize: none;
    line-height: 1.4;
    border-color: transparent;
    background: transparent;
}
@supports (field-sizing: content) {
    .student .name-field {
        field-sizing: content;
        overflow: hidden;
    }
}
.student .name-field:hover {
    border-color: var(--line);
}
.student select {
    width: 100%;
}

/* The row follows the width of its card, not of the window: in a narrow card the category goes under the name. */
@container (max-width: 720px) {
    .student {
        grid-template-columns: 24px minmax(0, 1fr) 36px;
        row-gap: 4px;
        padding: 8px;
    }
    .student select {
        grid-column: 2;
        grid-row: 2;
    }
    .student .row-actions {
        grid-column: 3;
        grid-row: 1 / span 2;
        flex-direction: column;
    }
}

.paper-preview {
    margin: 0;
    aspect-ratio: 297 / 210;
    background: #fff;
    color: #111;
    border: 1px solid var(--line);
    border-radius: 6px;
    max-width: 620px;
    padding: 5% 6%;
    font:
        11px / 1.5 "Times New Roman",
        Times,
        serif;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.pp-approve {
    text-align: right;
}
.pp-title {
    text-align: center;
}
.pp-table {
    flex: 1;
    border: 1px solid #333;
    background: repeating-linear-gradient(#fff 0 15px, #d4d4d4 15px 16px), #fff;
    border-color: #999;
}
.pp-signs {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* ============ Mobile day view ============ */
.mob {
    display: none;
}

.day-card {
    padding: 12px;
}
.day-nav {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
}
.day-select {
    position: relative;
    display: block;
}
.day-select select {
    width: 100%;
    height: 44px;
    padding: 0 34px 0 12px;
    appearance: none;
    font-weight: 650;
    font-size: 16px;
    text-align: center;
    border-color: var(--line);
    background: var(--surface-2) none;
}
.day-select .icon {
    position: absolute;
    right: 12px;
    top: 14px;
    pointer-events: none;
    color: var(--muted);
}

.price-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 10px;
    padding: 8px 8px 8px 12px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    font-weight: 550;
}
.price-line.warn {
    background: var(--warn-soft);
    color: var(--warn);
}
.money-field {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
}
.price-line input.money {
    width: 100px;
    height: 38px;
    font-size: 16px;
    font-weight: 650;
}

.day-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 10px;
}
.day-stats div {
    display: flex;
    flex-direction: column;
    padding: 4px 4px 0;
}
.day-stats b {
    font-size: 22px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}
.day-stats span {
    color: var(--muted);
    font-size: 12px;
}

ul.att {
    list-style: none;
    margin: 0 0 8px;
    padding: 0;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}
ul.att li + li {
    border-top: 1px solid var(--line);
}
.att-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 58px;
    padding: 8px 8px 8px 14px;
    transition: background 0.12s;
}
.who {
    font-weight: 550;
    min-width: 0;
}
.who small {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 400;
    margin-top: 1px;
}
.att-row.abs {
    background: var(--abs-soft);
}
.att-row.abs .who {
    color: var(--abs);
}
.att-row.skip {
    background: var(--skip-soft);
}

.segs {
    flex: none;
    display: flex;
    padding: 3px;
    gap: 2px;
    border-radius: 999px;
    background: var(--surface-2);
    border: 1px solid var(--line);
}
.seg {
    display: grid;
    place-items: center;
    width: 40px;
    height: 36px;
    border: 0;
    border-radius: 999px;
    background: none;
    color: var(--muted);
    font-weight: 750;
    font-size: 16px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition:
        background 0.12s,
        color 0.12s,
        transform 0.12s;
}
.seg.on.ate {
    background: var(--ok-soft);
    color: var(--ok);
}
.seg.on.abs {
    background: var(--abs);
    color: var(--surface);
}
.seg.on.skip {
    background: var(--skip);
    color: var(--surface);
}
.seg.htmx-request {
    transform: scale(0.88);
}

details.fold {
    padding: 0;
}
details.fold > summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    font-weight: 650;
    cursor: pointer;
    list-style: none;
}
details.fold > summary::-webkit-details-marker {
    display: none;
}
details.fold > summary::after {
    content: "›";
    font-size: 20px;
    color: var(--muted);
    transition: transform 0.15s;
    margin-left: 8px;
}
details.fold[open] > summary::after {
    transform: rotate(90deg);
}
details.fold > summary .muted {
    margin-left: auto;
}
details.fold .days-picker {
    padding: 0 12px 14px;
    grid-template-columns: repeat(7, minmax(0, 1fr));
}
details.fold .days-picker .chip:first-child {
    grid-column-start: var(--start, 1);
}

.pay-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 92px 92px;
    gap: 8px;
    align-items: end;
    padding: 10px 14px;
    border-top: 1px solid var(--line);
}
.pay-row label {
    display: grid;
    gap: 3px;
    font-size: 11px;
    color: var(--muted);
}
.pay-row input.money {
    width: 100%;
    height: 36px;
}

/* ============ Toast ============ */
.toast {
    position: fixed;
    z-index: 40;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    max-width: min(520px, calc(100vw - 24px));
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    background: var(--abs);
    color: #fff;
    font-weight: 550;
    box-shadow: var(--shadow-pop);
}
.toast[hidden] {
    display: none;
}

/* ============ Responsive ============ */
@media (min-width: 1101px) {
    .desk .days-picker {
        grid-template-columns: repeat(var(--days, 31), minmax(0, 1fr));
    }
}

@media (max-width: 1100px) {
    .stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .split {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 760px) {
    .desk {
        display: none;
    }
    .mob {
        display: block;
    }

    /* backdrop-filter would make the header the containing block of the fixed tab bar */
    .appbar {
        height: 54px;
        padding: 0 14px;
        backdrop-filter: none;
        background: var(--surface);
    }
    .tabs {
        position: fixed;
        z-index: 25;
        left: 0;
        right: 0;
        bottom: 0;
        justify-content: space-around;
        padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
        background: var(--surface);
        border-top: 1px solid var(--line);
        box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.04);
    }
    .tab {
        flex: 1;
        flex-direction: column;
        gap: 2px;
        padding: 6px 4px;
        font-size: 11px;
        justify-content: center;
    }
    .tab .icon {
        width: 22px;
        height: 22px;
    }
    .tab.active {
        background: none;
    }

    .container {
        padding: 12px 12px calc(84px + env(safe-area-inset-bottom));
    }
    .toast {
        bottom: calc(80px + env(safe-area-inset-bottom));
    }
    .page-head {
        margin-bottom: 12px;
    }
    .page-head .title {
        font-size: 22px;
    }
    .month-title h1 {
        font-size: 20px;
    }
    .month-title {
        padding: 4px 6px;
    }
    .add-form textarea {
        height: 7.5em;
    }
    .month-switch {
        gap: 2px;
    }
    .print-menu summary span {
        display: none;
    }
    .print-menu summary {
        padding: 0 10px;
    }

    /* iOS zooms into any field under 16px on focus. */
    input,
    select,
    textarea {
        /* biome-ignore lint/complexity/noImportantStyles: see above */
        font-size: 16px !important;
    }
}

@media (max-width: 380px) {
    .month-title h1 {
        font-size: 18px;
    }
    .month-switch .icon-btn {
        width: 32px;
    }
}

/* Touch screens keep :hover after a tap — don't leave highlights stuck on. */
@media (hover: none) {
    .tab:hover {
        background: none;
        color: var(--muted);
    }
    .tab.active:hover {
        color: var(--accent);
    }
    .icon-btn:hover,
    .btn:hover {
        border-color: var(--line);
    }
    .btn.primary:hover {
        background: var(--accent);
        border-color: var(--accent);
    }
    .month-title:hover {
        background: none;
    }
}

/* ============ Accounts, classes, journal, archive ============ */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.class-switch {
    max-width: 120px;
    height: 36px;
    font-weight: 650;
}

.user-menu .popover-body {
    right: 0;
    min-width: 220px;
}
.menu-who {
    padding: 8px 12px 10px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 4px;
}
.menu-who small {
    display: block;
    color: var(--muted);
    font-size: 12px;
}
.menu .menu-item {
    display: block;
    width: 100%;
    padding: 8px 12px;
    border: 0;
    border-radius: 6px;
    background: none;
    text-align: left;
    cursor: pointer;
}
.menu .menu-item:hover {
    background: var(--surface-2);
}
.menu form {
    margin: 0;
}

.head-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.subtabs {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}
.subtabs a {
    padding: 7px 12px;
    border-radius: 999px;
    color: var(--muted);
    text-decoration: none;
    font-weight: 550;
}
.subtabs a:hover {
    background: var(--surface);
    color: var(--text);
}
.subtabs a.active {
    background: var(--accent-soft);
    color: var(--accent);
}

.notice.err {
    background: var(--abs-soft);
    color: var(--abs);
}
.btn.danger {
    color: var(--abs);
}
.btn.wide {
    width: 100%;
    justify-content: center;
}

.admin-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.admin-list > li {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 10px 0;
    border-top: 1px solid var(--line);
}
.admin-list > li:first-child {
    border-top: 0;
}
.admin-list .who {
    flex: 1;
    min-width: 180px;
}
.inline-form {
    display: flex;
    gap: 8px;
    flex: 1;
    min-width: 220px;
}
.inline-form input {
    flex: 1;
    min-width: 0;
}
.admin-list form {
    margin: 0;
}
.user-edit .popover-body {
    right: 0;
    width: min(320px, calc(100vw - 32px));
    padding: 14px;
}
.user-edit .popover-body form + form {
    border-top: 1px solid var(--line);
    margin-top: 12px;
    padding-top: 12px;
}

.checks {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
    margin-bottom: 14px;
}
.checks legend {
    float: none;
    width: 100%;
    font-size: 13px;
    font-weight: 550;
    color: var(--muted);
    margin-bottom: 6px;
}
.checks label {
    display: flex;
    gap: 6px;
    align-items: center;
}
.checks small {
    width: 100%;
}

details.help summary {
    cursor: pointer;
    color: var(--accent);
    margin: 14px 0 6px;
}
.card > .btn + .btn,
.card form + .btn {
    margin-top: 8px;
}

/* sign-in pages */
body.bare {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
.bare-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
}
.bare-main {
    flex: 1;
    display: grid;
    place-items: start center;
    padding: 4vh 16px 40px;
}
.auth-card {
    width: min(400px, 100%);
}
.auth-card h1 {
    font-size: 22px;
    margin-bottom: 12px;
}

/* students who left */
table.grid td.out,
table.grid tbody tr:hover td.out {
    background: repeating-linear-gradient(135deg, var(--surface-2) 0 6px, transparent 6px 12px);
    cursor: default;
}
.att-row.out .who {
    color: var(--muted);
}
.left-note {
    color: var(--muted);
    font-size: 13px;
    padding-right: 8px;
}
.row-actions {
    display: flex;
    gap: 4px;
    align-items: center;
}
.leave .popover-body {
    right: 0;
    width: min(260px, calc(100vw - 32px));
    padding: 14px;
}
.fold-left {
    margin-top: 18px;
    border-top: 1px solid var(--line);
    padding-top: 10px;
}
.fold-left summary {
    cursor: pointer;
    font-weight: 650;
    padding: 6px 0;
}
.student.left {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.student.left .who {
    color: var(--muted);
}

/* journal */
.journal-entry.undone .who {
    color: var(--muted);
    text-decoration: line-through;
    text-decoration-color: var(--line-strong);
}

.toast.ok {
    background: var(--ok);
}
[data-theme="dark"] .toast.ok {
    color: #06201c;
}

@media (max-width: 760px) {
    .class-switch {
        max-width: 110px;
    }
    /* With a class switch the header has no room for the title; the switch names the class anyway. */
    .appbar:has(.class-switch) .logo-text {
        display: none;
    }
    /* Month switch on the first line, undo and print on the right; on the narrowest phones they wrap. */
    .page-head {
        flex-wrap: wrap;
        row-gap: 8px;
    }
    .head-actions {
        margin-left: auto;
    }
    .head-actions .btn {
        padding: 0 10px;
    }
    .head-actions .btn span {
        display: none;
    }
    /* Up to five tabs in the bottom bar must fit a 360px phone. */
    .tabs {
        gap: 0;
        padding-left: 4px;
        padding-right: 4px;
    }
    .tab {
        min-width: 0;
        padding: 6px 2px;
    }
    .tab span {
        font-size: 10px;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* ============ Administration ============ */
.admin-head {
    flex-wrap: wrap;
}
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 12px;
    color: var(--muted);
    text-decoration: none;
    font-weight: 550;
}
.back-link:hover {
    color: var(--accent);
}
.split.wide-left {
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
}
.stack {
    display: grid;
    gap: 16px;
    align-content: start;
}
.stack > .card {
    margin: 0;
}
.pad {
    padding: 14px 16px;
}

.admin-stats .stat.link {
    color: inherit;
    text-decoration: none;
    transition:
        border-color 0.15s,
        transform 0.15s;
}
.admin-stats .stat.link:hover {
    border-color: var(--accent);
}
.stat b.small-b {
    font-size: 16px;
    line-height: 1.3;
    margin: 6px 0 2px;
}
.warn-text {
    color: var(--warn);
    font-weight: 600;
}
.actions-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.actions-list form {
    margin: 0;
}
.actions-list.column {
    display: grid;
}
.actions-list.column .btn {
    width: 100%;
    justify-content: flex-start;
}
.attention {
    margin: 0;
    padding-left: 18px;
    display: grid;
    gap: 8px;
}
.ok-line {
    display: flex;
    gap: 8px;
    align-items: center;
    color: var(--ok);
    margin: 0;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
}
.admin-table th {
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    padding: 10px 16px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--line);
}
.admin-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}
.admin-table tr:last-child td {
    border-bottom: 0;
}
.admin-table tbody tr:hover td {
    background: var(--surface-2);
}
.admin-table .num-col {
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.admin-table .row-buttons {
    text-align: right;
    white-space: nowrap;
}
.admin-table .row-buttons .btn {
    vertical-align: middle;
}
.admin-table .row-buttons .btn + .btn,
.admin-table .row-buttons .btn + form {
    margin-left: 6px;
}
.admin-table .row-buttons form {
    display: inline;
}
.strong-link {
    font-weight: 650;
    color: var(--text);
    text-decoration: none;
}
.strong-link:hover {
    color: var(--accent);
    text-decoration: underline;
}
.role {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    background: var(--surface-2);
    color: var(--muted);
}
.role-admin {
    background: var(--accent-soft);
    color: var(--accent);
}

.danger-zone {
    border-color: color-mix(in srgb, var(--abs) 35%, var(--line));
}
.danger-zone h2 {
    color: var(--abs);
}
.danger-zone p {
    margin-top: 0;
}
.btn.danger-solid {
    background: var(--abs);
    border-color: var(--abs);
    color: var(--surface);
}
.btn.danger-solid:hover {
    filter: brightness(1.08);
}

@media (max-width: 1100px) {
    .split.wide-left {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* Tables become cards on a phone: each cell with its column name. */
@media (max-width: 760px) {
    .admin-table thead {
        display: none;
    }
    .admin-table,
    .admin-table tbody,
    .admin-table tr,
    .admin-table td {
        display: block;
        width: 100%;
    }
    .admin-table tr {
        padding: 10px 14px;
        border-bottom: 1px solid var(--line);
    }
    .admin-table td,
    .admin-table .num-col,
    .admin-table .row-buttons {
        border: 0;
        padding: 3px 0;
        text-align: left;
    }
    .admin-table td[data-label]::before {
        content: attr(data-label) ": ";
        color: var(--muted);
        font-size: 12px;
    }
    .admin-table td:first-child[data-label]::before {
        content: none;
    }
    .admin-table .row-buttons {
        padding-top: 8px;
    }
}

/* Import preview: a name field and a category per row. */
.import-table input {
    width: 100%;
    min-width: 180px;
}
.import-table small {
    display: block;
    margin-top: 3px;
}
.import-table tr.skipped input {
    opacity: 0.6;
}
input[type="file"] {
    max-width: 100%;
}

/* School summary: month switch and actions above a table of classes × categories. */
.summary-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}
.table-scroll {
    overflow-x: auto;
}
.summary-table .sum-cell {
    text-align: right;
    white-space: nowrap;
}
.summary-table .sum-cell small {
    display: block;
    color: var(--muted);
    font-size: 12px;
}
.summary-table tfoot td {
    padding: 12px 16px;
    font-weight: 650;
    border-top: 2px solid var(--line-strong);
    background: var(--surface-2);
}
@media (max-width: 760px) {
    .summary-table tfoot,
    .summary-table tfoot tr,
    .summary-table tfoot td {
        display: block;
        width: 100%;
    }
    .summary-table tfoot td {
        border: 0;
        padding: 3px 14px;
    }
    .summary-table .sum-cell {
        text-align: left;
    }
    .summary-table .sum-cell small {
        display: inline;
        margin-left: 6px;
    }
}
