/*
 * FaulWalter UI
 * A small, dependency-free design system for the Django templates.
 */

:root {
    --color-background: #f3f5f7;
    --color-surface: #ffffff;
    --color-surface-muted: #f8fafb;
    --color-text: #1c2734;
    --color-text-muted: #607080;
    --color-border: #dce3e8;
    --color-border-strong: #c5d0d8;
    /* Palette: Cobalt, Congress Blue, French Pass, Malibu, Pigment Indigo, Paua, Melrose, Pizazz */
    --color-primary: #0052bd;
    --color-primary-hover: #003a84;
    --color-primary-soft: #eaf3ff;
    --color-header: #003a84;
    --color-header-text: #ffffff;
    --color-header-muted: #bfdbff;
    --color-accent: #ff8a00;
    --color-danger: #b23a45;
    --color-danger-hover: #902d37;
    --color-danger-soft: #fae9eb;
    --color-success: #237a57;
    --color-success-soft: #e2f3eb;
    --color-warning: #94650a;
    --color-warning-soft: #fff3d6;
    --color-info: #380099;
    --color-info-soft: #f3edff;
    --shadow-color: 0 35 85;
    --shadow-small: 0 1px 2px rgb(var(--shadow-color) / 8%);
    --shadow-medium: 0 12px 30px rgb(var(--shadow-color) / 8%);
    /* One corner radius for everything. */
    --radius: 0.75rem;
    --content-width: 74rem;
    --sidebar-width: 16rem;
    --sidebar-rail-width: 3.5rem;
    /* The notch of phones in landscape; 0 elsewhere. */
    --safe-left: env(safe-area-inset-left, 0px);
    --tab-bar-offset: calc(4.25rem + env(safe-area-inset-bottom, 0px));
    --transition: 150ms ease;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    min-width: 20rem;
    color-scheme: light;
    font-family:
        Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
        sans-serif;
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
}

body {
    min-height: 100vh;
    margin: 0;
    display: flex;
    flex-direction: column;
    background: var(--color-background);
    color: var(--color-text);
    font-size: 1rem;
}

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

h1,
h2,
h3,
legend {
    color: var(--color-text);
    font-weight: 700;
    line-height: 1.2;
    text-wrap: balance;
}

h1 {
    margin-bottom: 0.65rem;
    font-size: clamp(1.8rem, 4vw, 2.55rem);
    letter-spacing: -0.035em;
}

h2 {
    margin-bottom: 1.25rem;
    font-size: clamp(1.25rem, 2vw, 1.5rem);
    letter-spacing: -0.015em;
}

h3 {
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

p:last-child {
    margin-bottom: 0;
}

a {
    color: var(--color-primary);
    font-weight: 600;
    text-decoration-thickness: 0.08em;
    text-underline-offset: 0.18em;
    transition: color var(--transition);
}

a:hover {
    color: var(--color-primary-hover);
}

:focus-visible {
    outline: 3px solid var(--color-accent);
    outline-offset: 3px;
}

::selection {
    background: var(--color-header-muted);
    color: var(--color-text);
}

/* Sidebar */

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 10;
    width: calc(var(--sidebar-width) + var(--safe-left));
    padding: 1.25rem 1rem 1.25rem calc(1rem + var(--safe-left));
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background: var(--color-header);
    color: var(--color-header-text);
}

.sidebar__header {
    padding: 0.5rem 0.25rem 1.25rem 0.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    border-bottom: 1px solid rgb(255 255 255 / 15%);
}

.brand {
    color: var(--color-header-text);
    font-size: 1.3rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    text-decoration: none;
}

a.brand:hover {
    color: var(--color-header-muted);
}

/* The menu fills the sidebar, the footer sits at its bottom. */
.sidebar__menu,
.sidebar__menu::details-content,
.sidebar__body {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Closes the whole sidebar on wide screens. */
.sidebar__collapse {
    padding: 0.4rem;
    display: inline-flex;
    border: 0;
    border-radius: var(--radius);
    background: none;
    color: var(--color-header-muted);
    cursor: pointer;
    transition:
        color var(--transition),
        background-color var(--transition);
}

.sidebar__collapse[hidden] {
    display: none;
}

.sidebar__collapse:hover {
    background: rgb(255 255 255 / 11%);
    color: #ffffff;
}

/* The menu button for narrow screens. */
.sidebar__toggle {
    padding: 0.45rem 0.75rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    border-radius: var(--radius);
    color: var(--color-header-muted);
    font-weight: 600;
    list-style: none;
    cursor: pointer;
    transition:
        color var(--transition),
        background-color var(--transition);
}

.sidebar__toggle::-webkit-details-marker {
    display: none;
}

.sidebar__toggle:hover,
.sidebar__menu[open] > .sidebar__toggle {
    background: rgb(255 255 255 / 11%);
    color: #ffffff;
}

.sidebar__collapse svg,
.sidebar__toggle svg,
.sidebar__logout svg {
    width: 1.2rem;
    height: 1.2rem;
    flex: none;
}

.sidebar__nav {
    padding-top: 1rem;
}

.sidebar__list,
.sidebar__sublist {
    margin: 0;
    padding: 0;
    list-style: none;
}

.sidebar__list > li + li {
    margin-top: 0.15rem;
}

.sidebar__list a,
.sidebar__group-title,
.sidebar__footer > a {
    padding: 0.55rem 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-radius: var(--radius);
    color: var(--color-header-muted);
    text-decoration: none;
    overflow-wrap: anywhere;
    transition:
        color var(--transition),
        background-color var(--transition);
}

.sidebar__list a:hover,
.sidebar__group-title:hover,
.sidebar__group--active > .sidebar__group-title,
.sidebar__footer > a:hover,
.sidebar a[aria-current],
.tab-menu a[aria-current] {
    color: #ffffff;
}

.sidebar__list a:hover,
.sidebar__group-title:hover,
.sidebar__footer > a:hover,
.sidebar a[aria-current="page"],
.tab-menu a[aria-current="page"] {
    background: rgb(255 255 255 / 11%);
}

/* An app: its name opens and closes the list of its pages. */
.sidebar__group-title {
    font-weight: 600;
    list-style: none;
    cursor: pointer;
}

.sidebar__group-title::-webkit-details-marker {
    display: none;
}

.sidebar__group-title::after {
    content: "";
    width: 0.45rem;
    height: 0.45rem;
    margin-left: auto;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    rotate: -45deg;
    transition: rotate var(--transition);
}

.sidebar__group[open] > .sidebar__group-title::after {
    rotate: 45deg;
}

.sidebar__sublist {
    margin: 0.15rem 0 0.5rem 1.25rem;
    padding-left: 0.5rem;
    border-left: 1px solid rgb(255 255 255 / 15%);
}

.sidebar__sublist a {
    padding-block: 0.4rem;
    font-size: 0.925rem;
    font-weight: 500;
}

.sidebar__footer {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid rgb(255 255 255 / 15%);
}

/* Room for the sidebar next to the content. */
.main-content {
    min-width: 0;
    margin-left: calc(var(--sidebar-width) + var(--safe-left));
    padding-right: env(safe-area-inset-right, 0px);
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
}

/* Wide screens show the menu always; browsers without ::details-content keep the button. */
@media screen and (min-width: 48.01rem) {
    @supports selector(::details-content) {
        .sidebar__toggle {
            display: none;
        }

        .sidebar__menu::details-content {
            content-visibility: visible;
        }
    }

    /* Closed sidebar: a narrow bar with the button to open it again. */
    [data-sidebar="closed"] .sidebar {
        width: calc(var(--sidebar-rail-width) + var(--safe-left));
        padding-inline: calc(0.5rem + var(--safe-left)) 0.5rem;
    }

    [data-sidebar="closed"] .sidebar__header {
        padding-inline: 0;
        justify-content: center;
        border-bottom: 0;
    }

    [data-sidebar="closed"] .sidebar .brand,
    [data-sidebar="closed"] .sidebar__menu {
        display: none;
    }

    [data-sidebar="closed"] .main-content {
        margin-left: calc(var(--sidebar-rail-width) + var(--safe-left));
    }
}

/* Narrow screens: a bar on top, the menu opens below it. */
@media (max-width: 48rem) {
    .sidebar {
        position: relative;
        width: auto;
        padding: 0.75rem 1rem;
        overflow: visible;
    }

    .sidebar__header {
        padding: 0.4rem 0;
        border-bottom: 0;
    }

    .sidebar__collapse {
        display: none;
    }

    .sidebar__toggle {
        position: absolute;
        top: 0.75rem;
        right: 1rem;
    }

    .sidebar__nav {
        padding-top: 0.75rem;
    }

    .sidebar__footer {
        margin-top: 0.75rem;
        padding-bottom: 0.25rem;
    }

    .main-content {
        margin-left: 0;
    }
}

/* Tab bar: on phones the main apps at the bottom, like a messenger; who sees more apps gets
   the whole navigation as a sheet behind "Menü". */

.tab-bar,
.subnav,
.button.profile-logout {
    display: none;
}

@media (max-width: 48rem) {
    /* The tab bar replaces the menu of the sidebar; signed out the menu stays. */
    body:has(.tab-bar) .sidebar__menu {
        display: none;
    }

    body:has(.tab-bar) .main-content {
        padding-bottom: var(--tab-bar-offset);
    }

    .tab-bar {
        position: fixed;
        inset: auto 0 0;
        z-index: 20;
        display: block;
        padding: 0.25rem 0.25rem env(safe-area-inset-bottom, 0px);
        border-top: 1px solid var(--color-border);
        background: rgb(255 255 255 / 92%);
        box-shadow: 0 -8px 24px rgb(var(--shadow-color) / 7%);
        -webkit-backdrop-filter: saturate(180%) blur(14px);
        backdrop-filter: saturate(180%) blur(14px);
    }

    .tab-bar__list {
        max-width: 32rem;
        margin: 0 auto;
        padding: 0;
        display: flex;
        list-style: none;
    }

    .tab-bar__list > li {
        min-width: 0;
        flex: 1 1 0;
    }

    .tab-bar__link {
        width: 100%;
        min-height: 4rem;
        padding: 0.3rem 0 0.45rem;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0.2rem;
        border: 0;
        background: none;
        color: var(--color-text-muted);
        font: inherit;
        font-size: 0.7rem;
        font-weight: 600;
        line-height: 1.1;
        text-decoration: none;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        transition: color var(--transition);
    }

    .tab-bar__icon {
        width: 3.5rem;
        max-width: 100%;
        height: 2rem;
        display: grid;
        place-items: center;
        border-radius: var(--radius);
        transition:
            background-color var(--transition),
            transform var(--transition);
    }

    .tab-bar__icon svg {
        width: 1.45rem;
        height: 1.45rem;
    }

    .tab-bar__label {
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .tab-bar__link:active .tab-bar__icon {
        transform: scale(0.9);
    }

    .tab-bar__link[aria-current="page"],
    .tab-bar__link--active,
    body:has(.tab-menu:popover-open) .tab-bar button {
        color: var(--color-primary);
    }

    .tab-bar__link[aria-current="page"] .tab-bar__icon,
    .tab-bar__link--active .tab-bar__icon,
    body:has(.tab-menu:popover-open) .tab-bar button .tab-bar__icon {
        background: var(--color-primary-soft);
    }

    .tab-bar__link[aria-current="page"] svg,
    .tab-bar__link--active svg {
        stroke-width: 2.4;
    }

    /* The profile shows the initials, like the avatar in a messenger. */
    .tab-bar__avatar {
        width: 1.65rem;
        height: 1.65rem;
        display: grid;
        place-items: center;
        border-radius: var(--radius);
        background: var(--color-header);
        color: var(--color-header-text);
        font-size: 0.62rem;
        font-weight: 800;
        letter-spacing: 0.03em;
    }

    .tab-bar__link[aria-current="page"] .tab-bar__avatar {
        background: var(--color-primary);
    }

    /* The menu: a sheet above the tab bar, dark like the sidebar. */
    .tab-menu {
        inset: auto 0 var(--tab-bar-offset);
        width: auto;
        max-height: calc(100dvh - var(--tab-bar-offset) - 3rem);
        margin: 0;
        padding: 0.75rem 1rem 1rem;
        overflow-y: auto;
        overscroll-behavior: contain;
        border: 0;
        border-radius: var(--radius) var(--radius) 0 0;
        background: var(--color-header);
        color: var(--color-header-text);
        box-shadow: 0 -12px 30px rgb(var(--shadow-color) / 25%);
        opacity: 0;
        translate: 0 1.5rem;
        transition:
            opacity 200ms ease,
            translate 200ms ease,
            overlay 200ms allow-discrete,
            display 200ms allow-discrete;
    }

    .tab-menu:popover-open {
        opacity: 1;
        translate: 0 0;
    }

    @starting-style {
        .tab-menu:popover-open {
            opacity: 0;
            translate: 0 1.5rem;
        }
    }

    /* The handle of the sheet. */
    .tab-menu::before {
        content: "";
        width: 2.5rem;
        height: 0.25rem;
        margin: 0 auto 0.75rem;
        display: block;
        border-radius: var(--radius);
        background: rgb(255 255 255 / 25%);
    }

    /* Dims the page, not the tab bar: its button closes the menu again. */
    .tab-menu::backdrop {
        bottom: calc(4.25rem + env(safe-area-inset-bottom, 0px));
        background: rgb(var(--shadow-color) / 35%);
    }

    /* The pages of the current app as chips above the content. */
    .subnav {
        margin: -0.75rem 0 1.5rem;
        padding-bottom: 0.15rem;
        display: flex;
        gap: 0.5rem;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .subnav::-webkit-scrollbar {
        display: none;
    }

    .subnav__link {
        padding: 0.4rem 0.95rem;
        flex: none;
        border: 1px solid var(--color-border-strong);
        border-radius: var(--radius);
        background: var(--color-surface);
        color: var(--color-text-muted);
        font-size: 0.875rem;
        text-decoration: none;
        white-space: nowrap;
        transition:
            color var(--transition),
            background-color var(--transition),
            border-color var(--transition);
    }

    .subnav__link:hover {
        border-color: var(--color-primary);
        color: var(--color-primary);
    }

    .subnav__link[aria-current="page"] {
        border-color: var(--color-primary);
        background: var(--color-primary);
        color: #ffffff;
    }

    .button.profile-logout {
        width: 100%;
        margin-top: 1.5rem;
        display: flex;
    }
}

/* Page layout */

main {
    width: min(var(--content-width), calc(100% - 2rem));
    margin-inline: auto;
    padding-block: clamp(2rem, 5vw, 4rem);
    flex: 1 0 auto;
}

.page-header {
    margin-bottom: 1.75rem;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 2rem;
}

.page-header > div {
    max-width: 48rem;
}

.page-header p {
    margin-bottom: 0;
    color: var(--color-text-muted);
    font-size: 1.05rem;
}

/* Two buttons: right-aligned, below each other if they do not fit in one row.
   The smaller gaps let the longest labels fit next to the longest heading. */
.page-header:has(> .page-actions) {
    gap: 1rem;
}

.page-header > .page-actions {
    max-width: none;
    margin: 0;
    justify-content: flex-end;
    gap: 0.5rem;
}

.back-link {
    width: fit-content;
    margin-bottom: 1.25rem;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    color: var(--color-text-muted);
    font-size: 0.9rem;
    text-decoration: none;
}

.back-link:hover {
    color: var(--color-primary);
}

.back-link__icon {
    font-size: 1.15em;
    transition: transform var(--transition);
}

.back-link:hover .back-link__icon {
    transform: translateX(-0.2rem);
}

.panel,
.form-card {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    box-shadow: var(--shadow-small);
}

.panel {
    padding: clamp(1.25rem, 3vw, 2rem);
    overflow-x: auto;
}

.panel + .panel {
    margin-top: 1.25rem;
}

.section-intro {
    max-width: 48rem;
    margin-top: -0.65rem;
    margin-bottom: 1.5rem;
    color: var(--color-text-muted);
}

.page-actions {
    margin: 1.5rem 0 0;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
}

/* Reusable list filters */

.filter-bar {
    margin-bottom: 1.5rem;
    padding: 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface-muted);
}

/* The fields wrap into as many rows as the width needs; the first one (the search) is twice as wide. */
.filter-bar__fields {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 1rem;
}

.filter-bar__fields > * {
    min-width: 0;
    flex: 1 1 12rem;
}

.filter-bar__fields > :first-child {
    flex: 2 1 16rem;
}

.filter-field > label,
.filter-field__label {
    margin-bottom: 0.4rem;
    display: inline-block;
    font-size: 0.85rem;
    font-weight: 700;
}

.filter-field__control input,
.filter-field__control select {
    width: 100%;
    min-height: 2.75rem;
    padding: 0.6rem 0.7rem;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius);
    background-color: var(--color-surface);
    color: var(--color-text);
    font: inherit;
    box-shadow: inset 0 1px 2px rgb(var(--shadow-color) / 4%);
    transition:
        border-color var(--transition),
        box-shadow var(--transition);
}

.filter-field__control select {
    -webkit-appearance: none;
    appearance: none;
    height: 2.75rem;
    padding-right: 2.5rem;
    background-image:
        linear-gradient(45deg, transparent 50%, #607080 50%),
        linear-gradient(135deg, #607080 50%, transparent 50%);
    background-position:
        calc(100% - 1rem) 50%,
        calc(100% - 0.7rem) 50%;
    background-repeat: no-repeat;
    background-size: 0.35rem 0.35rem, 0.35rem 0.35rem;
}

.filter-field__control input:hover,
.filter-field__control select:hover {
    border-color: #9cabae;
}

.filter-field__control input:focus,
.filter-field__control select:focus {
    border-color: var(--color-primary);
    outline: 0;
    box-shadow: 0 0 0 3px var(--color-primary-soft);
}

.filter-field__help {
    margin-top: 0.35rem;
    display: block;
    color: var(--color-text-muted);
    font-size: 0.75rem;
}

.filter-field__errors {
    margin: 0.35rem 0 0;
    padding: 0;
    color: var(--color-danger);
    font-size: 0.8rem;
    font-weight: 600;
    list-style: none;
}

.filter-multiselect {
    position: relative;
}

.filter-multiselect summary {
    min-height: 2.75rem;
    padding: 0.6rem 0.7rem;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--color-surface);
    cursor: pointer;
    list-style: none;
}

.filter-multiselect summary::-webkit-details-marker {
    display: none;
}

.filter-multiselect summary::after {
    content: "⌄";
    margin-left: auto;
}

.filter-multiselect__menu {
    position: absolute;
    z-index: 5;
    top: calc(100% + 0.35rem);
    width: 100%;
    max-height: 18rem;
    overflow-y: auto;
    padding: 0.5rem;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius);
    background: var(--color-surface);
    box-shadow: var(--shadow-medium);
}

.filter-multiselect__menu label {
    padding: 0.4rem;
    display: flex;
    align-items: center;
    gap: 0.55rem;
    border-radius: var(--radius);
    cursor: pointer;
}

.filter-multiselect__menu label:hover {
    background: var(--color-primary-soft);
}

.filter-multiselect__menu input {
    accent-color: var(--color-primary);
}

.filter-bar__actions {
    margin-top: 1rem;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.65rem;
}

.filter-results__summary {
    margin-bottom: 0.75rem;
    color: var(--color-text-muted);
    font-size: 0.85rem;
    font-weight: 700;
}

.list-toolbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0 1rem;
}

.column-picker {
    width: 12rem;
    margin-bottom: 0.75rem;
}

.list-exports {
    margin-bottom: 0.75rem;
    margin-left: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
}

.list-exports__group {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--color-text-muted);
    font-size: 0.875rem;
    font-weight: 600;
}

.list-exports .button {
    min-height: 2.25rem;
    padding: 0.4rem 0.7rem;
    font-size: 0.875rem;
}

.list-exports svg {
    width: 1rem;
    height: 1rem;
}

/* Auf der Höhe des Wählers, auch wenn sein Menü offen ist. */
.list-toolbar:has(.column-picker:not([hidden])) .filter-results__summary {
    line-height: 2.75rem;
}

/* Im Fluss statt darüber: .panel scrollt waagrecht und schnitte das Menü sonst ab. */
.column-picker .filter-multiselect__menu {
    position: static;
    margin-top: 0.35rem;
    max-height: none;
}

.pagination {
    margin-top: 1.25rem;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 1rem;
}

.pagination > div:last-child {
    justify-self: end;
}

.pagination > span {
    color: var(--color-text-muted);
    font-size: 0.875rem;
    font-weight: 600;
}

/* Buttons and inline actions */

.button {
    min-height: 2.75rem;
    padding: 0.65rem 1rem;
    border: 1px solid var(--color-primary);
    border-radius: var(--radius);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    background: var(--color-primary);
    color: #ffffff;
    font: inherit;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    box-shadow: var(--shadow-small);
    transition:
        background-color var(--transition),
        border-color var(--transition),
        box-shadow var(--transition),
        transform var(--transition);
}

.button:hover {
    border-color: var(--color-primary-hover);
    background: var(--color-primary-hover);
    color: #ffffff;
    box-shadow: 0 5px 12px rgb(var(--shadow-color) / 15%);
    transform: translateY(-1px);
}

.button:active {
    box-shadow: none;
    transform: translateY(0);
}

.button--secondary {
    border-color: var(--color-border-strong);
    background: var(--color-surface);
    color: var(--color-text);
}

.button--secondary:hover {
    border-color: var(--color-primary);
    background: var(--color-primary-soft);
    color: var(--color-primary-hover);
}

.button--danger {
    border-color: var(--color-danger);
    background: var(--color-danger);
}

.button--danger:hover {
    border-color: var(--color-danger-hover);
    background: var(--color-danger-hover);
}

.inline-form {
    display: inline;
}

.link-button {
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--color-primary);
    font: inherit;
    font-weight: 600;
    text-decoration: underline;
    text-decoration-thickness: 0.08em;
    text-underline-offset: 0.18em;
    cursor: pointer;
}

.link-button:hover {
    color: var(--color-primary-hover);
}

.danger-link,
.danger-link:hover {
    color: var(--color-danger);
}

/* Tables and definition lists */

/* Only the table scrolls sideways; the search and the toolbar above it stay in place. */
.table-scroll {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    min-width: 44rem;
    border-spacing: 0;
    border-collapse: collapse;
    font-size: 0.925rem;
    text-align: left;
}

.data-table th,
.data-table td {
    padding: 0.9rem 0.85rem;
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
}

.data-table th {
    background: var(--color-surface-muted);
    color: var(--color-text-muted);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.055em;
    text-transform: uppercase;
}

.data-table th:first-child {
    border-radius: var(--radius) 0 0 var(--radius);
}

.data-table th:last-child {
    border-radius: 0 var(--radius) var(--radius) 0;
}

/* Eine sortierbare Überschrift ({% sort_header %}): der Pfeil zeigt die Richtung. */
.sort-link {
    color: inherit;
    font-weight: inherit;
    text-decoration: none;
}

.sort-link::after {
    content: "\00a0↕";
    opacity: 0.4;
}

.sort-link:hover,
th[aria-sort] .sort-link {
    color: var(--color-text);
}

th[aria-sort="ascending"] .sort-link::after {
    content: "\00a0▲";
    opacity: 1;
}

th[aria-sort="descending"] .sort-link::after {
    content: "\00a0▼";
    opacity: 1;
}

.data-table tbody tr {
    transition: background-color var(--transition);
}

.data-table tbody tr:hover {
    background: var(--color-surface-muted);
}

.data-table tbody tr:last-child td {
    border-bottom: 0;
}

.table-actions {
    white-space: nowrap;
}

.table-actions > * {
    margin-right: 0.75rem;
}

.table-actions > *:last-child {
    margin-right: 0;
}

/* The icons of a row: as narrow as they are, the other columns get the space. While the table
   scrolls sideways, they stay at its right edge. */
.data-table td.table-actions,
.data-table:has(td.table-actions:last-child) th:last-child {
    width: 1%;
    position: sticky;
    right: 0;
    background: var(--color-surface);
    box-shadow: -0.75rem 0 0.75rem -0.75rem rgb(var(--shadow-color) / 18%);
}

.data-table:has(td.table-actions:last-child) th:last-child {
    background: var(--color-surface-muted);
}

.data-table tbody tr:hover td.table-actions {
    background: var(--color-surface-muted);
}

/* Centred, the tooltip of the last icon would stick out of the table and make it scroll. */
.table-actions .icon-button__tooltip,
.table-actions .icon-button:hover .icon-button__tooltip,
.table-actions .icon-button:focus-visible .icon-button__tooltip {
    left: auto;
    right: 0;
    transform: none;
}

.icon-actions {
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.icon-actions > * {
    margin-right: 0;
}

.icon-button {
    position: relative;
    width: 2.75rem;
    height: 2.75rem;
    padding: 0;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--color-surface);
    color: var(--color-primary);
    font: inherit;
    text-decoration: none;
    cursor: pointer;
    box-shadow: var(--shadow-small);
    transition:
        background-color var(--transition),
        border-color var(--transition),
        box-shadow var(--transition),
        transform var(--transition);
}

.icon-button svg {
    width: 1.4rem;
    height: 1.4rem;
}

.icon-button svg,
.list-exports svg {
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.icon-button:hover {
    border-color: var(--color-primary);
    background: var(--color-primary-soft);
    color: var(--color-primary-hover);
    box-shadow: 0 5px 12px rgb(var(--shadow-color) / 12%);
    transform: translateY(-1px);
}

.icon-button:focus-visible {
    outline: 3px solid var(--color-primary-soft);
    outline-offset: 2px;
}

.icon-button__tooltip {
    position: absolute;
    z-index: 10;
    bottom: calc(100% + 0.5rem);
    left: 50%;
    padding: 0.35rem 0.55rem;
    border-radius: var(--radius);
    visibility: hidden;
    background: var(--color-text);
    color: var(--color-surface);
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transform: translate(-50%, 0.2rem);
    transition:
        opacity var(--transition),
        transform var(--transition),
        visibility var(--transition);
}

.icon-button:hover .icon-button__tooltip,
.icon-button:focus-visible .icon-button__tooltip {
    visibility: visible;
    opacity: 1;
    transform: translate(-50%, 0);
}

.icon-button--danger {
    color: var(--color-danger);
}

.icon-button--danger:hover {
    border-color: var(--color-danger);
    background: var(--color-danger-soft);
    color: var(--color-danger-hover);
}

dl {
    margin-bottom: 0;
    display: grid;
    grid-template-columns: minmax(9rem, 0.35fr) minmax(0, 1fr);
}

dt,
dd {
    margin: 0;
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--color-border);
}

dt {
    padding-right: 1.5rem;
    color: var(--color-text-muted);
    font-size: 0.875rem;
    font-weight: 700;
}

dd {
    min-width: 0;
}

/* An on/off switch: a button that posts the other state. */
.switch {
    padding: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    border: 0;
    background: none;
    color: var(--color-text);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.switch__track {
    position: relative;
    width: 2.6rem;
    height: 1.5rem;
    flex: none;
    border-radius: var(--radius);
    background: var(--color-border-strong);
    transition: background var(--transition);
}

.switch__track::after {
    content: "";
    position: absolute;
    top: 0.2rem;
    left: 0.2rem;
    width: 1.1rem;
    height: 1.1rem;
    border-radius: var(--radius);
    background: var(--color-surface);
    box-shadow: var(--shadow-small);
    transition: transform var(--transition);
}

.switch[aria-checked="true"] .switch__track {
    background: var(--color-primary);
}

.switch[aria-checked="true"] .switch__track::after {
    transform: translateX(1.1rem);
}

.switch:hover:not(:disabled) .switch__track {
    background: var(--color-text-muted);
}

.switch[aria-checked="true"]:hover:not(:disabled) .switch__track {
    background: var(--color-primary-hover);
}

.switch:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 3px;
    border-radius: var(--radius);
}

.switch:disabled {
    cursor: default;
    opacity: 0.6;
}

/* Eine hohe Karte einer Detailseite (cards.js): zugeklappt zeigt sie nur ihre Überschrift. */
.card--collapsed > :not(.card-head) {
    display: none;
}

.card--collapsed > .card-head {
    margin-bottom: 0;
}

.card-toggle {
    padding: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    letter-spacing: inherit;
    text-align: left;
    cursor: pointer;
}

.card-toggle::after {
    content: "";
    width: 0.5rem;
    height: 0.5rem;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    rotate: 45deg;
    transition: rotate var(--transition);
}

.card--collapsed .card-toggle::after {
    rotate: -45deg;
}

.section-heading {
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.section-heading:last-child {
    margin-bottom: 0;
}

.section-heading h2 {
    margin: 0;
}

.section-heading .page-actions {
    margin: 0;
}

/* The logo of the masterdata on the page of its card. */
.masterdata-logo {
    display: block;
    max-width: 16rem;
    max-height: 8rem;
    margin-top: 0.75rem;
    padding: 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: #fff;
}

/* Product images: thumbnails in a panel, and one row per image in the image form. */
.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
    gap: 1.25rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.image-grid img,
.image-row img {
    display: block;
    width: 7rem;
    height: auto;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}

.image-grid strong,
.image-grid small {
    display: block;
}

.image-grid strong {
    margin-top: 0.5rem;
}

.image-grid small {
    color: var(--color-text-muted);
}

.image-row {
    display: grid;
    grid-template-columns: 7rem minmax(0, 1fr);
    gap: 1.5rem;
    margin-top: 1.25rem;
}

.image-row + .image-row {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-border);
}

.image-row .form-field:first-child {
    margin-top: 0;
}

@media (max-width: 640px) {
    .image-row {
        grid-template-columns: 1fr;
    }
}

dt:last-of-type,
dd:last-of-type {
    border-bottom: 0;
}

pre,
code {
    border-radius: var(--radius);
    background: #eff3f4;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.875em;
}

code {
    padding: 0.15em 0.35em;
    color: var(--color-primary-hover);
}

pre {
    max-width: 100%;
    margin-bottom: 0;
    padding: 1rem;
    overflow: auto;
    color: var(--color-text);
    line-height: 1.6;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* Status labels */

.badge,
.priority {
    width: fit-content;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    border-radius: var(--radius);
    font-size: 0.75rem;
    font-weight: 800;
    line-height: 1;
    white-space: nowrap;
}

.badge {
    padding: 0.42rem 0.65rem;
    background: #e9edef;
    color: #4d5b67;
}

.badge--success {
    background: var(--color-success-soft);
    color: var(--color-success);
}

.badge--danger {
    background: var(--color-danger-soft);
    color: var(--color-danger);
}

.badge--pending {
    background: var(--color-warning-soft);
    color: var(--color-warning);
}

.priority::before {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: var(--radius);
    background: #82909b;
    content: "";
}

.priority--low::before {
    background: #6f8796;
}

.priority--medium::before {
    background: var(--color-info);
}

.priority--high::before {
    background: #d17a22;
}

.priority--now::before {
    background: var(--color-danger);
    box-shadow: 0 0 0 3px var(--color-danger-soft);
}

/* Forms */

.form-card {
    width: 100%;
    max-width: none;
    margin-inline: auto;
    padding: clamp(1.25rem, 3vw, 2rem);
}

.form-card fieldset {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.form-card fieldset + fieldset {
    margin-top: 2rem;
}

/* The legend covers the top border of its fieldset, so it draws the divider itself. */
.form-card fieldset + fieldset legend {
    padding-top: 2rem;
    border-top: 1px solid var(--color-border);
}

.form-card legend {
    width: 100%;
    margin-bottom: 0.55rem;
    padding: 0;
    font-size: 1.25rem;
}

.form-card fieldset > p {
    margin-bottom: 1.25rem;
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

.form-field {
    margin-top: 1.25rem;
}

.form-field > label,
.form-field__checkbox label {
    display: inline-block;
    margin-bottom: 0.4rem;
    color: var(--color-text);
    font-size: 0.9rem;
    font-weight: 700;
}

.form-field__required {
    margin-left: 0.25rem;
    color: var(--color-danger);
    font-size: 0.75rem;
    font-weight: 600;
}

.form-field__control input,
.form-field__control select,
.form-field__control textarea {
    width: 100%;
    max-width: 100%;
    min-height: 2.8rem;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius);
    background: var(--color-surface);
    color: var(--color-text);
    font: inherit;
    box-shadow: inset 0 1px 2px rgb(var(--shadow-color) / 4%);
    transition:
        border-color var(--transition),
        box-shadow var(--transition);
}

.form-field__control textarea {
    min-height: 7rem;
    line-height: 1.55;
    resize: vertical;
}

.form-field__control select {
    appearance: none;
    padding-right: 2.5rem;
    background-image:
        linear-gradient(45deg, transparent 50%, #607080 50%),
        linear-gradient(135deg, #607080 50%, transparent 50%);
    background-position:
        calc(100% - 1rem) 50%,
        calc(100% - 0.7rem) 50%;
    background-repeat: no-repeat;
    background-size: 0.35rem 0.35rem, 0.35rem 0.35rem;
}

/* A list of entries, as below a search field, instead of a dropdown. */
.form-field__control select[size] {
    margin-top: 0.5rem;
    padding: 0.35rem;
    background-image: none;
}

.form-field__control select[size] option {
    padding: 0.4rem 0.5rem;
    border-radius: var(--radius);
}

.form-field__control input:hover,
.form-field__control select:hover,
.form-field__control textarea:hover {
    border-color: #9cabae;
}

.form-field__control input:focus,
.form-field__control select:focus,
.form-field__control textarea:focus {
    border-color: var(--color-primary);
    outline: 0;
    box-shadow: 0 0 0 3px var(--color-primary-soft);
}

.form-field--invalid .form-field__control input,
.form-field--invalid .form-field__control select,
.form-field--invalid .form-field__control textarea {
    border-color: var(--color-danger);
}

.form-field__checkbox {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
}

.form-field__checkbox input {
    width: 1.15rem;
    height: 1.15rem;
    margin: 0.15rem 0 0;
    accent-color: var(--color-primary);
}

.form-field__checkbox label {
    margin: 0;
}

.form-field__help {
    margin-top: 0.4rem;
    display: block;
    color: var(--color-text-muted);
    font-size: 0.8rem;
}

.form-field__errors {
    margin: 0.4rem 0 0;
    padding: 0;
    color: var(--color-danger);
    font-size: 0.825rem;
    font-weight: 600;
    list-style: none;
}

.form-errors {
    margin-bottom: 1.25rem;
    padding: 0.9rem 1rem;
    border: 1px solid #ecc0c5;
    border-left: 4px solid var(--color-danger);
    border-radius: var(--radius);
    background: var(--color-danger-soft);
    color: #7f2630;
}

.form-errors p {
    margin-bottom: 0.35rem;
}

.form-errors p:last-child {
    margin-bottom: 0;
}

.form-actions {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.confirmation {
    max-width: 46rem;
    border-left: 4px solid var(--color-danger);
}

/* Empty states and feedback messages */

.empty-state {
    min-height: 17rem;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.empty-state > span {
    width: 3.5rem;
    height: 3.5rem;
    margin-bottom: 1rem;
    border-radius: var(--radius);
    display: grid;
    place-items: center;
    background: var(--color-primary-soft);
    color: var(--color-primary);
    font-size: 1.6rem;
}

.empty-state p {
    max-width: 32rem;
    margin-bottom: 1.25rem;
    color: var(--color-text-muted);
}

.messages {
    margin: 0 0 1.5rem;
    padding: 0;
    display: grid;
    gap: 0.65rem;
    list-style: none;
}

.message {
    padding: 0.85rem 1rem;
    border: 1px solid var(--color-border-strong);
    border-left: 4px solid var(--color-info);
    border-radius: var(--radius);
    background: var(--color-info-soft);
    color: #27006b;
    font-weight: 600;
    box-shadow: var(--shadow-small);
}

.message--success {
    border-color: #abd5c1;
    border-left-color: var(--color-success);
    background: var(--color-success-soft);
    color: #1d6449;
}

.message--warning {
    border-color: #e9cb83;
    border-left-color: var(--color-warning);
    background: var(--color-warning-soft);
    color: #775107;
}

.message--error {
    border-color: #ecc0c5;
    border-left-color: var(--color-danger);
    background: var(--color-danger-soft);
    color: #7f2630;
}

/* Permission groups and permissions */

.form-card--wide {
    max-width: none;
}

.permission-sections {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(18rem, 100%), 1fr));
    gap: 1rem;
}

.permission-section__actions {
    margin-bottom: 1rem;
    display: flex;
    justify-content: flex-end;
}

.permission-section {
    padding: 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface-muted);
}

.permission-section h3 {
    margin-bottom: 0.85rem;
    color: var(--color-primary-hover);
}

.permission-section--collapsible {
    padding: 0;
    align-self: start;
}

.permission-section--collapsible summary {
    min-height: 3.5rem;
    padding: 0.9rem 1rem;
    border-radius: inherit;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--color-primary-hover);
    cursor: pointer;
    list-style: none;
    transition: background-color var(--transition);
}

.permission-section--collapsible summary::-webkit-details-marker {
    display: none;
}

.permission-section--collapsible summary:hover {
    background: var(--color-primary-soft);
}

.permission-section--collapsible summary:focus-visible {
    outline-offset: -3px;
}

.permission-section--collapsible summary::after {
    width: 0.5rem;
    height: 0.5rem;
    margin: -0.25rem 0.15rem 0 0.1rem;
    flex: none;
    border-right: 2px solid currentcolor;
    border-bottom: 2px solid currentcolor;
    content: "";
    transform: rotate(45deg);
    transition: transform var(--transition);
}

.permission-section--collapsible[open] summary {
    border-bottom: 1px solid var(--color-border);
    border-radius: var(--radius) var(--radius) 0 0;
}

.permission-section--collapsible[open] summary::after {
    margin-top: 0.25rem;
    transform: rotate(225deg);
}

.permission-section__title {
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1.2;
}

.permission-section__count {
    margin-left: auto;
    color: var(--color-text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.permission-section__content {
    padding: 1rem;
}

.permission-options,
.permission-list,
.simple-list {
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.55rem;
    list-style: none;
}

.permission-option,
.permission-list li,
.simple-list li {
    padding: 0.7rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
}

.permission-option {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    cursor: pointer;
    transition: border-color var(--transition), background-color var(--transition);
}

.permission-option:hover {
    border-color: var(--color-primary);
    background: var(--color-primary-soft);
}

.permission-option input {
    width: 1.1rem;
    height: 1.1rem;
    margin: 0.15rem 0 0;
    flex: none;
    accent-color: var(--color-primary);
}

.permission-option strong,
.permission-list strong,
.simple-list strong,
.permission-option small,
.permission-list small,
.simple-list small {
    display: block;
}

.permission-option small,
.permission-list small,
.simple-list small {
    margin-top: 0.2rem;
    color: var(--color-text-muted);
    font-size: 0.75rem;
}

.simple-list {
    grid-template-columns: repeat(auto-fit, minmax(min(15rem, 100%), 1fr));
}

.perm-group-assignment {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.perm-group-assignment > span {
    min-width: 0;
}

/* Footer */

.site-footer {
    width: min(var(--content-width), calc(100% - 2rem));
    margin-inline: auto;
    padding-block: 1.5rem 2rem;
    border-top: 1px solid var(--color-border);
    color: var(--color-text-muted);
    font-size: 0.825rem;
}

.site-footer p {
    margin: 0;
}

@media (max-width: 42rem) {
    main {
        padding-block: 2rem;
    }

    .page-header {
        align-items: stretch;
        flex-direction: column;
        gap: 1rem;
    }

    .page-header > .button,
    .page-header > .page-actions > .button {
        width: 100%;
    }

    .filter-bar__actions .button {
        width: 100%;
    }

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

    .pagination > span {
        grid-column: 1 / -1;
        grid-row: 1;
        text-align: center;
    }

    .panel,
    .form-card {
        border-radius: var(--radius);
    }

    dl {
        grid-template-columns: 1fr;
    }

    dt {
        padding-bottom: 0.2rem;
        border-bottom: 0;
    }

    dd {
        padding-top: 0;
    }

    .form-actions .button {
        width: 100%;
    }

    .permission-section__actions .button {
        width: 100%;
    }
}

/* Calendar of the scheduling app (FullCalendar, colored through its variables) */

.calendar {
    --fc-border-color: var(--color-border);
    --fc-page-bg-color: var(--color-surface);
    --fc-neutral-bg-color: var(--color-surface-muted);
    --fc-today-bg-color: var(--color-primary-soft);
    --fc-now-indicator-color: var(--color-danger);
    --fc-button-bg-color: var(--color-primary);
    --fc-button-border-color: var(--color-primary);
    --fc-button-hover-bg-color: var(--color-primary-hover);
    --fc-button-hover-border-color: var(--color-primary-hover);
    --fc-button-active-bg-color: var(--color-header);
    --fc-button-active-border-color: var(--color-header);
    --fc-event-bg-color: var(--color-primary);
    --fc-event-border-color: var(--color-primary);
    margin-top: 1rem;
    font-size: 0.875rem;
}

.calendar .fc-toolbar-title {
    font-size: 1.15rem;
}

.calendar a {
    color: inherit;
}

/* An hour of 3.5rem: a lesson of an hour shows its title and its students. */
.calendar .fc-timegrid-slot {
    height: 1.75rem;
}

/* A session that does not take place in the chosen calendar, whoever's it is. */
.calendar-event--elsewhere {
    --fc-event-bg-color: var(--color-info-soft);
    --fc-event-border-color: #d7bfff;
    --fc-event-text-color: var(--color-info);
}

/* Someone else's session in the chosen calendar: only the time and the teacher. */
.calendar-event--foreign {
    --fc-event-bg-color: #e9edef;
    --fc-event-border-color: var(--color-border-strong);
    --fc-event-text-color: var(--color-text-muted);
}

.calendar__error {
    margin: 0 0 1rem;
}

/* Statistics: the filter, key figures as tiles, the chart (Chart.js) and its table */

.stats-filter__period {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 1rem;
}

.stats-filter__period .filter-field {
    min-width: 0;
    flex: 1 1 8rem;
}

.stats-filter__period .filter-field:has(input[type="month"]) {
    flex-basis: 9.5rem;
}

.stats-filter__period .filter-field:has(input[type="search"]) {
    flex: 2 1 9rem;
}

@media (max-width: 42rem) {
    .stats-filter__period .filter-bar__actions {
        flex-basis: 100%;
    }
}

/* Chrome draws a month field higher than a select: the row would not line up. */
.stats-filter__period input[type="month"] {
    height: 2.75rem;
}

.stats-filter__period .filter-bar__actions {
    margin-top: 0;
}

.stats-filter__types {
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--color-border);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
    gap: 1rem;
}

.stats-type {
    display: grid;
    gap: 0.6rem;
}

/* A switch in a form: the checkbox itself is invisible, the track shows its state. */
.switch__input {
    position: absolute;
    width: 0;
    height: 0;
    margin: 0;
    appearance: none;
}

.switch__input:checked + .switch__track {
    background: var(--color-primary);
}

.switch__input:checked + .switch__track::after {
    transform: translateX(1.1rem);
}

.switch__input:focus-visible + .switch__track {
    outline: 2px solid var(--color-primary);
    outline-offset: 3px;
}

.filter-multiselect[inert] {
    opacity: 0.45;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
    gap: 1rem;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(19rem, 100%), 1fr));
    align-items: start;
    gap: 1rem;
}

.dashboard-card {
    min-height: 13rem;
    padding: 1.5rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    box-shadow: var(--shadow-small);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    transition: box-shadow var(--transition), transform var(--transition);
}

.dashboard-card:hover {
    box-shadow: var(--shadow-medium);
    transform: translateY(-2px);
}

.dashboard-card h2 {
    margin-bottom: 0.5rem;
}

.dashboard-card p {
    color: var(--color-text-muted);
}

.dashboard-card__value {
    margin-bottom: 0.65rem;
    color: var(--color-primary) !important;
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
}

.dashboard-card .button {
    margin-top: auto;
}

/* A card with its own list: one entry per row, each with its buttons. */
.dashboard-card__list {
    width: 100%;
    margin-bottom: 1rem;
    grid-template-columns: 1fr;
}

.dashboard-card__actions {
    margin-top: 0.6rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.dashboard-card__actions .button {
    min-height: 2.25rem;
    margin-top: 0;
    padding: 0.4rem 0.75rem;
    font-size: 0.875rem;
}

/* The menu of a product type opens over the panel's edge instead of scrolling it. */
.stats-types {
    overflow: visible;
}

.stat-card {
    padding: 1rem 1.1rem;
    border: 2px solid var(--color-primary);
    border-radius: var(--radius);
    background: var(--color-surface);
    display: grid;
    align-content: start;
    gap: 0.75rem;
}

.stat-card h3 {
    margin: 0;
}

.stat-card--off {
    border-color: var(--color-border);
}

.stat-card--off .stat-rows,
.stat-card--off .stat-profit {
    opacity: 0.45;
}

.stat-rows {
    grid-template-columns: 1fr auto;
}

.stat-rows dt,
.stat-rows dd {
    padding: 0.3rem 0;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.9rem;
}

.stat-rows dt:last-of-type,
.stat-rows dd:last-of-type {
    border-bottom: 0;
}

.stat-rows dd {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.stat-profit {
    margin: 0;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
    color: var(--color-primary);
    font-weight: 700;
}

.stat-profit strong {
    font-size: 1.6rem;
    font-variant-numeric: tabular-nums;
}

.stat-profit--negative {
    color: var(--color-danger);
}

/* On the page of a person the statistics are one card: the panels inside lose their frame. */
.stats-embedded {
    overflow: visible;
}

.stats-embedded .panel {
    margin-top: 1.5rem;
    padding: 0;
    border: 0;
    /* Without padding the rounded corners would cut the first letters off. */
    border-radius: 0;
    box-shadow: none;
}

.stats-embedded .panel h2 {
    margin-bottom: 0.75rem;
    font-size: 1.1rem;
}

/* The totals: highlighted below the cards. */
.stat-total {
    margin-top: 1.25rem;
    padding: clamp(1.25rem, 3vw, 2rem);
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--color-primary), var(--color-header));
    color: var(--color-header-text);
    box-shadow: var(--shadow-medium);
}

.stat-total h2 {
    color: inherit;
}

.stat-total__values {
    grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
    align-items: end;
    gap: 1rem;
}

.stat-total__values dt,
.stat-total__values dd {
    padding: 0;
    border: 0;
    color: inherit;
}

.stat-total__values dt {
    opacity: 0.8;
}

.stat-total__values dd {
    font-size: 1.5rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.stat-total__profit dd {
    font-size: 2.25rem;
}

.stat-total__note {
    margin: 1rem 0 0;
    opacity: 0.8;
    font-size: 0.85rem;
}

.stat-total__note span + span::before {
    content: " · ";
}

.stats-chart {
    position: relative;
    height: 22rem;
}

/* Die Spalten der Kulanz in der Monatstabelle: Kunde und Lehrkraft unter einer Überschrift, abgesetzt. */
.stats-table .stats-table__group {
    border-left: 2px solid var(--color-border-strong);
}

.stats-table th[colspan] {
    text-align: center;
}

.stats-table thead tr + tr th {
    border-radius: 0;
}

.stats-table {
    margin-top: 1rem;
}

/* The same chevron as the other collapsible parts instead of the marker of the browser. */
.stats-table summary {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    cursor: pointer;
    font-weight: 700;
    list-style: none;
}

.stats-table summary::-webkit-details-marker {
    display: none;
}

.stats-table summary::after {
    width: 0.45rem;
    height: 0.45rem;
    margin-top: -0.25rem;
    border-right: 2px solid currentcolor;
    border-bottom: 2px solid currentcolor;
    content: "";
    transform: rotate(45deg);
    transition: transform var(--transition);
}

.stats-table[open] summary::after {
    margin-top: 0.25rem;
    transform: rotate(225deg);
}

.data-table .number {
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

/* The second line of a value: a time, a count, a unit. */
.detail-note {
    display: block;
    color: var(--color-text-muted);
    font-size: 0.8rem;
}

/* Small grey line at the bottom of a card, for data that only informs. */
.panel-footnote {
    margin: 1rem 0 0;
    color: var(--color-text-muted);
    font-size: 0.8rem;
}

/* The scripts of the session and booking forms hide what does not fit or is not ticked. */
.session-form [hidden],
.booking-form [hidden],
.product-form [hidden] {
    display: none;
}

/* The products of a teacher or a student: each one a box, its pay or price inside. */
.product-choices {
    display: grid;
    gap: 0.55rem;
}

.product-choice {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
}

.product-choice .permission-option {
    border: 0;
    background: transparent;
}

/* Below the name, in line with it: past the checkbox and its gap. */
.product-choice__tariff {
    padding: 0 0.75rem 0.75rem 2.5rem;
}

.product-choice__tariff .form-field {
    margin-top: 0;
}

.product-choice__tariff .form-field + .form-field {
    margin-top: 0.75rem;
}

.session-form .permission-options {
    grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
}

.permission-option:has(input:disabled) {
    cursor: default;
}

/* A student whose product ended before the day of the session. */
.permission-option--ended {
    opacity: 0.55;
}

/* The warning of the booking form: which follow-up sessions move, and the button to confirm. */
.booking-form .message {
    margin-bottom: 1.5rem;
}

.booking-form .message ul {
    margin: 0.5rem 0 0.85rem;
}

/* The attendance of a booking: one row of three choices per student. */
.attendance-options {
    grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
}

/* The extra costs of a session: description, quantity, unit price and a button to remove the row. */
/* One extra cost as a small card: the inputs in a row, the shares folded below them. */
.extra-costs__row {
    margin-bottom: 0.6rem;
    padding: 0.6rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface-muted);
}

.extra-costs__main {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 6.5rem 8.5rem auto;
    align-items: center;
    gap: 0.5rem;
}

.extra-costs__shares {
    margin-top: 0.5rem;
    font-size: 0.875rem;
}

.extra-costs__shares summary {
    width: fit-content;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    list-style: none;
}

.extra-costs__shares summary::-webkit-details-marker {
    display: none;
}

.extra-costs__chip {
    padding: 0.15rem 0.6rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    color: var(--color-text-muted);
}

/* A share other than 100 %: the one thing worth noticing. */
.extra-costs__chip--changed {
    border-color: transparent;
    background: var(--color-primary-soft);
    color: var(--color-primary-hover);
}

.extra-costs__toggle {
    color: var(--color-primary);
    font-weight: 600;
}

.extra-costs__toggle::after {
    content: " ▾";
}

.extra-costs__shares[open] .extra-costs__toggle::after {
    content: " ▴";
}

.extra-costs__share-fields {
    margin-top: 0.6rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
}

.extra-costs__share-fields label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 400;
    white-space: nowrap;
}

.form-field__control .extra-costs__share-fields input {
    width: 4.5rem;
    min-height: 2.3rem;
    padding: 0.4rem 0.6rem;
    text-align: right;
}

/* The extra costs of earlier bookings in a box of their own: one button per name, a menu where a name has several variants. */
.extra-costs__suggestion-box {
    margin-bottom: 0.75rem;
    padding: 0.85rem 1rem;
    border: 1px solid var(--color-primary);
    border-left-width: 4px;
    border-radius: var(--radius);
    background: var(--color-primary-soft);
}

.extra-costs__suggestion-title {
    margin: 0 0 0.6rem;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem 0.75rem;
    color: var(--color-primary-hover);
    font-weight: 700;
}

.extra-costs__suggestion-title small {
    font-weight: 400;
}

.extra-costs__suggestion-list {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.extra-costs__suggestion {
    display: inline-flex;
    gap: 0.35rem;
}

.extra-costs__add {
    margin-top: 0.25rem;
}

/* The form of a session: until a product is chosen only the product shows, everything else depends on it. */
.session-form--no-product .form-field:not(:has([name=product])) {
    display: none;
}

/* Start and end side by side; the further times of a course below them in the same columns, the last one for the button that removes a row. */
.session-form fieldset {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 2.75rem;
    column-gap: 0.75rem;
}

.session-form fieldset > * {
    grid-column: 1 / -1;
}

.session-form fieldset > .form-field:has([name=start]) {
    grid-column: 1;
}

.session-form fieldset > .form-field:has([name=end]) {
    grid-column: 2;
}

.session-times__row {
    margin-bottom: 0.5rem;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 2.75rem;
    align-items: center;
    gap: 0.75rem;
}

.extra-costs-table td:not(:first-child),
.extra-costs-table th:not(:first-child) {
    text-align: right;
    white-space: nowrap;
}

@media (max-width: 36rem) {
    .session-form fieldset > .form-field:has([name=start]),
    .session-form fieldset > .form-field:has([name=end]) {
        grid-column: 1 / -1;
    }

    /* A further time: start above end, the button beside both, like start and end above it. */
    .session-times__row {
        margin-bottom: 1rem;
        grid-template-columns: minmax(0, 1fr) 2.75rem;
        gap: 0.5rem 0.75rem;
    }

    .session-times__row .session-times__remove {
        grid-column: 2;
        grid-row: 1 / 3;
    }

    /* The description gets its own line; quantity, price and the button share the next one. */
    .extra-costs__main {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    }

    .extra-costs__main input:first-child {
        grid-column: 1 / -1;
    }
}

@media (max-width: 48rem) {
    .calendar .fc-header-toolbar {
        flex-direction: column;
        gap: 0.5rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}

/* Document templates: settings or source on the left, the live preview on the right; the
   payment import: the rows to assign by hand on the left, the invoices on the right */

.document-editor,
.split-view {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 1.5rem;
    align-items: start;
}

.split-view {
    margin-block: 1.25rem;
}

.split-view > .panel + .panel {
    margin-top: 0;
}

.split-view .data-table {
    min-width: 0;
}

.split-view .filter-bar__fields > * {
    flex-basis: 0;
}

/* The rows stay in sight while the list of invoices scrolls. */
.split-view__rows {
    position: sticky;
    top: 1.25rem;
    max-height: calc(100vh - 2.5rem);
    overflow-y: auto;
}

.split-view__rows tbody tr:has(input:checked) {
    background: var(--color-primary-soft);
}

.split-view__rows tbody tr:has(input:checked) td:first-child {
    box-shadow: inset 3px 0 var(--color-primary);
}

/* A click anywhere on the row picks it: the label of its radio button covers the row. */
.split-view__rows tbody tr {
    position: relative;
    cursor: pointer;
}

.split-view__rows .choice-label::after {
    position: absolute;
    inset: 0;
    content: "";
}

.split-view__rows .icon-button {
    z-index: 1;
}

.choice-label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    cursor: pointer;
}

.choice-label input {
    accent-color: var(--color-primary);
}

@media (max-width: 80rem) {
    .split-view {
        grid-template-columns: 1fr;
    }

    .split-view__rows {
        position: static;
        max-height: none;
    }
}

/* The invoices a row of the payment import goes to, each with its share. */
.import-shares {
    margin: 0.5rem 0 0;
    padding: 0;
    display: grid;
    gap: 0.4rem;
    list-style: none;
}

.import-shares li {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.import-shares .icon-button {
    width: 2rem;
    height: 2rem;
    border-radius: var(--radius);
}

.import-shares .icon-button svg {
    width: 1.1rem;
    height: 1.1rem;
}

/* Old in the shop: a session changed since it was sent, as a row of the list and as its card "Shop". */
.data-table__row--outdated td {
    background: var(--color-warning-soft);
}

.data-table__row--outdated td:first-child {
    box-shadow: inset 4px 0 0 var(--color-warning);
}

.shop-changes {
    margin: 0;
    padding-left: 1.1rem;
}

.panel--outdated {
    border-color: #e9cb83;
    box-shadow: inset 4px 0 0 var(--color-warning);
    background: var(--color-warning-soft);
}

/* An invoice of the payment import that is already paid. */
.data-table__row--paid {
    opacity: 0.55;
}

/* The figures of a payment import: one tile each, the total highlighted. */
.import-summary {
    margin-bottom: 1.5rem;
    grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
    gap: 0.75rem;
}

.import-summary > div {
    padding: 0.85rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface-muted);
}

.import-summary dt,
.import-summary dd {
    padding: 0;
    border: 0;
}

.import-summary dd {
    margin-top: 0.25rem;
    font-size: 1.5rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.import-summary > .import-summary__total {
    grid-column: span 2;
    border-color: var(--color-primary);
    background: var(--color-primary-soft);
}

.import-summary__total dd {
    color: var(--color-primary);
}

/* A tab is a radio button: hidden, but still reachable with the keyboard. */
.tabs__toggle {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.tabs__label {
    display: inline-block;
    margin: 0 0.25rem 1.25rem 0;
    padding: 0.45rem 0.9rem;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius);
    background: var(--color-surface);
    cursor: pointer;
    font-weight: 600;
}

.tabs__toggle:checked + .tabs__label {
    border-color: var(--color-primary);
    background: var(--color-primary-soft);
    color: var(--color-primary);
}

.tabs__toggle:focus-visible + .tabs__label {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.tabs__panel {
    display: none;
}

#tab-settings:checked ~ .tabs__panel--settings,
#tab-source:checked ~ .tabs__panel--source {
    display: block;
}

.form-field__control .code-input {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.85rem;
    white-space: pre;
}

.document-preview {
    position: sticky;
    top: 1rem;
    display: grid;
    gap: 1rem;
}

.document-preview__pages {
    display: grid;
    gap: 1rem;
}

.document-preview__page {
    width: 100%;
    height: auto;
    border: 1px solid var(--color-border);
    background: #ffffff;
    box-shadow: var(--shadow-small);
}

@media (max-width: 64rem) {
    .document-editor {
        grid-template-columns: 1fr;
    }

    .document-preview {
        position: static;
    }
}

@media print {
    body {
        background: #ffffff;
    }

    .sidebar,
    .site-footer,
    .tab-bar,
    .subnav,
    .profile-logout,
    .back-link,
    .page-actions,
    .form-actions,
    .page-header > .button,
    .table-actions {
        display: none;
    }

    .main-content {
        margin-left: 0;
    }

    main {
        width: 100%;
        padding: 0;
    }

    .panel,
    .form-card {
        border-color: #bbbbbb;
        box-shadow: none;
    }
}

