@font-face {
    font-family: 'Overpass';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('../fonts/overpass-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
    font-family: 'Overpass';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('../fonts/overpass-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
    --umg-blue: #134A84;
    --umg-blue-dark: #0d3157;
    --umg-navy: #203151;
    --umg-lime: #D7D700;
    --umg-steel: #6c8ca9;
    --umg-orange: #f1a400;
    --grey-text: #4d4d4d;
    --grey-border: #dedede;
    --grey-line: #e6e6e6;
    --grey-surface: #f4f5f6;
    --danger: #a32d2d;
    --font-body: 'Overpass', 'Helvetica Neue', Arial, sans-serif;
    --card-shadow: 0 10px 20px -10px rgba(0, 0, 0, 0.2);
}

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

html {
    height: 100%;
}

body {
    width: 100%;
    min-height: 100vh;
    background-color: var(--grey-surface);
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 16px;
    line-height: 1.375;
    color: var(--umg-navy);
    display: flex;
}

button, input, select, textarea {
    font-family: inherit;
}

h1, h2, h3, h4 {
    font-family: var(--font-body);
    font-weight: 700;
    color: var(--umg-navy);
}

a {
    color: var(--umg-blue);
}

:focus-visible {
    outline: 2px solid var(--umg-navy);
    outline-offset: 2px;
}

.sidebar {
    width: 260px;
    min-width: 260px;
    height: 100vh;
    position: sticky;
    top: 0;
    align-self: flex-start;
    overflow-y: auto;
    background-color: #fff;
    border-right: 1px solid var(--grey-border);
    box-shadow: 5px 0 10px -5px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-logo {
    width: 100%;
    height: auto;
    display: block;
    padding: 14px 16px;
    border-bottom: 4px solid var(--umg-lime);
}

.sidebar-section-label {
    color: var(--umg-steel);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    padding: 24px 20px 8px;
    flex-shrink: 0;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0;
    flex: 1;
}

.btn-wrapper {
    border-left: 4px solid transparent;
    transition: background-color 0.2s, border-color 0.2s;
}

.btn-wrapper:hover {
    background-color: var(--grey-surface);
    border-left-color: var(--umg-lime);
}

.btn-sidebar {
    width: 100%;
    height: 46px;
    padding: 0 16px;
    justify-content: flex-start;
    align-items: center;
    gap: 12px;
    display: inline-flex;
    background: none;
    border: none;
    cursor: pointer;
}

.btn-sidebar-dot {
    width: 7px;
    height: 7px;
    background: var(--umg-steel);
    flex-shrink: 0;
    transition: background 0.2s;
}

.btn-wrapper:hover .btn-sidebar-dot {
    background: var(--umg-blue);
}

.btn-sidebar-text {
    color: var(--umg-navy);
    font-size: 16px;
    font-weight: 400;
    word-wrap: break-word;
    text-align: left;
    transition: color 0.2s;
}

.btn-wrapper:hover .btn-sidebar-text {
    color: var(--umg-blue);
}

.sidebar-account {
    margin-top: auto;
    padding: 16px;
    border-top: 1px solid var(--grey-border);
    background: var(--grey-surface);
    flex-shrink: 0;
}

.account-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 -8px 10px;
    padding: 6px 8px;
    color: inherit;
    text-decoration: none;
    transition: background 0.2s ease-in-out;
}

.account-info:hover,
.account-info[aria-current="page"] {
    background: #fff;
}

.account-info:hover .account-name {
    color: var(--umg-blue);
}

.profile-icon {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--umg-blue);
    color: #fff;
    font-size: 18px;
    font-weight: 700;
    line-height: 1;
    padding-top: 0.24em;
    box-shadow: 0 0 0 3px #fff;
}

.account-text {
    min-width: 0;
}

.account-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--umg-navy);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.account-detail {
    font-size: 12px;
    color: var(--umg-steel);
}

.btn-logout {
    background: #fff;
}

.sidebar-upload {
    padding: 14px 16px 0;
    flex-shrink: 0;
}

.sidebar-upload-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 0.7rem 1rem 0.5rem;
    border: 1px solid var(--umg-navy);
    background: transparent;
    color: var(--umg-navy);
    font-size: 14px;
    font-weight: 400;
    cursor: pointer;
    transition: all 0.3s ease-in-out;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-upload-label:hover {
    background: var(--umg-blue);
    border-color: var(--umg-blue);
    color: #fff;
}

.sidebar-upload-label path {
    stroke: currentColor;
}

.page-content {
    flex: 1;
    min-width: 0;
    padding: 40px 32px 32px 32px;
}

.page-title {
    color: var(--umg-navy);
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 28px;
}

.page-title::after {
    content: "";
    display: block;
    width: 56px;
    height: 4px;
    margin-top: 10px;
    background: var(--umg-lime);
}

.content-card {
    background: #fff;
    border: 1px solid var(--grey-border);
    box-shadow: var(--card-shadow);
    padding: 28px 32px;
    margin-bottom: 20px;
}

.content-card h4 {
    font-size: 16px;
    font-weight: 700;
    color: var(--umg-navy);
    margin-bottom: 14px;
}

.btn-action {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0.7rem 1rem 0.5rem;
    font-size: 14px;
    font-weight: 400;
    cursor: pointer;
    border: 1px solid var(--umg-navy);
    background: transparent;
    color: var(--umg-navy);
    text-decoration: none;
    transition: all 0.3s ease-in-out;
}

.btn-action:hover {
    background: var(--umg-blue);
    border-color: var(--umg-blue);
    color: #fff;
}

.btn-action.primary {
    background: var(--umg-blue);
    border-color: var(--umg-blue);
    color: #fff;
}

.btn-action.primary:hover {
    background: var(--umg-blue-dark);
    border-color: var(--umg-blue-dark);
}

.btn-action.secondary {
    background: transparent;
    color: var(--umg-navy);
    border-color: var(--umg-navy);
}

.btn-action.secondary:hover {
    background: var(--umg-blue);
    border-color: var(--umg-blue);
    color: #fff;
}

.btn-action.danger {
    background: transparent;
    color: var(--danger);
    border-color: var(--danger);
}

.btn-action.danger:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

.btn-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 6px;
}

.login-page {
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.login-card {
    width: 100%;
    max-width: 380px;
    padding: 2.5rem;
    background: #fff;
    border: 1px solid var(--grey-border);
    border-top: 4px solid var(--umg-lime);
    box-shadow: var(--card-shadow);
}

.login-card img {
    display: block;
    width: 100%;
    height: auto;
    margin-bottom: 1.5rem;
}

.login-card h2 {
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    color: var(--umg-blue);
}

.form-label {
    display: block;
    margin-bottom: 4px;
    font-size: 0.85rem;
    color: var(--grey-text);
}

.form-input {
    width: 100%;
    padding: 10px 12px;
    margin-bottom: 1rem;
    border: 1px solid var(--grey-border);
    background: #fff;
    font-size: 1rem;
    color: var(--umg-navy);
}

.form-input:focus {
    border-color: var(--umg-blue);
}

.btn-block {
    width: 100%;
    justify-content: center;
    margin-top: 0.5rem;
}

.alert-error {
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    border-left: 4px solid var(--danger);
    background: #fdf0ef;
    color: var(--danger);
    font-size: 0.9rem;
}

.sort-header {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 0;
    border: none;
    background: none;
    font: inherit;
    color: inherit;
    text-align: left;
    cursor: pointer;
}

.sort-header:hover {
    color: var(--umg-blue);
}

.sort-label {
    flex: 1;
}

.sort-header[data-key="Pflichtkurse"] .sort-label {
    border-bottom: 1px dotted var(--umg-blue);
    cursor: help;
    flex: 0 1 auto;
}

.sort-icon {
    position: relative;
    flex-shrink: 0;
    width: 9px;
    height: 14px;
}

.sort-icon::before,
.sort-icon::after {
    content: "";
    position: absolute;
    left: 0;
    width: 9px;
    height: 6px;
    background: #c5bfb6;
    transition: background 0.2s;
}

.sort-icon::before {
    top: 0;
    clip-path: polygon(50% 0, 0 100%, 100% 100%);
}

.sort-icon::after {
    bottom: 0;
    clip-path: polygon(0 0, 100% 0, 50% 100%);
}

.sort-header:hover .sort-icon::before,
.sort-header:hover .sort-icon::after {
    background: var(--umg-steel);
}

th[aria-sort="ascending"],
th[aria-sort="descending"] {
    background: #e7edf3;
    color: var(--umg-blue);
}

th[aria-sort="ascending"] .sort-icon::before,
th[aria-sort="descending"] .sort-icon::after {
    background: var(--umg-blue);
}

[hidden] {
    display: none !important;
}

.picker {
    position: relative;
    display: inline-block;
}

.picker-badge {
    min-width: 22px;
    padding: 1px 6px 0;
    background: #fff;
    color: var(--umg-blue);
    font-size: 12px;
    font-weight: 700;
    text-align: center;
}

.picker-panel {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 30;
    width: min(520px, 90vw);
    background: #fff;
    border: 1px solid var(--grey-border);
    border-top: 4px solid var(--umg-lime);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}

.picker-panel form {
    display: flex;
    flex-direction: column;
    max-height: min(560px, 70vh);
}

.picker-head {
    padding: 14px 16px 10px;
    border-bottom: 1px solid var(--grey-line);
}

.picker-search {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--grey-border);
    font-size: 14px;
    color: var(--umg-navy);
}

.picker-search:focus {
    border-color: var(--umg-blue);
}

.picker-tools {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 10px;
    font-size: 13px;
}

.picker-link {
    padding: 0;
    border: none;
    background: none;
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    color: var(--umg-blue);
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.picker-link:hover {
    color: var(--umg-navy);
}

.picker-count {
    margin-left: auto;
    color: var(--grey-text);
}

.picker-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px 0;
}

.picker-group + .picker-group {
    border-top: 1px solid var(--grey-line);
}

.picker-heading {
    padding: 10px 16px 4px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--umg-steel);
}

.picker-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 7px 16px;
    font-size: 14px;
    line-height: 1.35;
    cursor: pointer;
}

.picker-item:hover {
    background: var(--grey-surface);
}

.picker-item input {
    flex-shrink: 0;
    margin-top: 3px;
    accent-color: var(--umg-blue);
}

.picker-parent {
    font-weight: 600;
}

.picker-child {
    padding-left: 38px;
    font-size: 13px;
    color: var(--grey-text);
}

.picker-empty {
    padding: 20px 16px;
    font-size: 14px;
    color: var(--grey-text);
}

.picker-foot {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 12px 16px;
    border-top: 1px solid var(--grey-border);
    background: var(--grey-surface);
}

.chip-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 1rem;
}

.chip-label {
    font-size: 13px;
    font-weight: 700;
    color: var(--umg-steel);
}

.chip-hint {
    font-size: 14px;
    color: var(--grey-text);
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: 320px;
    padding: 5px 10px;
    border: 1px solid var(--umg-steel);
    background: #fff;
    font: inherit;
    font-size: 13px;
    color: var(--umg-navy);
    cursor: pointer;
    transition: all 0.2s;
}

.chip-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chip-x {
    font-size: 10px;
    color: var(--umg-steel);
}

.chip:hover {
    background: var(--umg-blue);
    border-color: var(--umg-blue);
    color: #fff;
}

.chip:hover .chip-x {
    color: #fff;
}

.resident-link {
    color: inherit;
    text-decoration: none;
}

.resident-link:hover {
    color: var(--umg-blue);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.btn-action svg,
.sidebar-upload-label svg {
    flex-shrink: 0;
    transform: translateY(-1px);
}

a.btn-sidebar {
    text-decoration: none;
}

.btn-wrapper.is-active {
    background-color: var(--grey-surface);
    border-left-color: var(--umg-lime);
}

.btn-wrapper.is-active .btn-sidebar-text {
    color: var(--umg-blue);
    font-weight: 700;
}

.btn-wrapper.is-active .btn-sidebar-dot {
    background: var(--umg-blue);
}

/* ── Toasts ──────────────────────────────────────────────── */

.toast-stack {
    position: fixed;
    top: 20px;
    right: 24px;
    z-index: 60;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(420px, calc(100vw - 48px));
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px 12px 16px;
    background: #fff;
    border: 1px solid var(--grey-border);
    border-left: 4px solid var(--umg-blue);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
    font-size: 0.9rem;
}

.toast.success {
    border-left-color: #22a05a;
}

.toast.error {
    border-left-color: var(--danger);
    background: #fdf0ef;
}

.toast-text {
    flex: 1;
}

.toast-close {
    padding: 0 2px;
    border: none;
    background: none;
    font-size: 12px;
    color: var(--umg-steel);
    cursor: pointer;
}

.toast-close:hover {
    color: var(--umg-navy);
}

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

/* ── Data entry ──────────────────────────────────────────── */

.resident-search {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}

.resident-search-input {
    flex: 1;
    min-width: 260px;
    padding: 0.7rem 1rem 0.5rem;
    border: 1px solid var(--umg-navy);
    background: #fff;
    font-size: 15px;
    color: var(--umg-navy);
}

.resident-search-input:focus {
    border-color: var(--umg-blue);
}

.resident-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.profile-icon-large {
    width: 52px;
    height: 52px;
    font-size: 22px;
}

.resident-heading {
    flex: 1;
    min-width: 0;
}

.resident-name {
    font-size: 24px;
    font-weight: 700;
    color: var(--umg-navy);
}

.resident-meta {
    font-size: 13px;
    color: var(--grey-text);
}

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    border-bottom: 1px solid var(--grey-border);
}

.tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px 10px;
    margin-bottom: -1px;
    border: 1px solid transparent;
    border-bottom: none;
    color: var(--umg-navy);
    text-decoration: none;
    font-size: 15px;
    transition: background 0.2s, color 0.2s;
}

.tab:hover {
    background: #fff;
    color: var(--umg-blue);
}

.tab.is-active {
    background: #fff;
    border-color: var(--grey-border);
    border-top: 3px solid var(--umg-lime);
    padding-top: 10px;
    font-weight: 700;
    color: var(--umg-blue);
}

.tab-badge {
    min-width: 22px;
    padding: 1px 7px 0;
    background: var(--grey-surface);
    border: 1px solid var(--grey-border);
    font-size: 12px;
    font-weight: 700;
    text-align: center;
    color: var(--grey-text);
}

.tab.is-active .tab-badge {
    background: var(--umg-blue);
    border-color: var(--umg-blue);
    color: #fff;
}

.tab-panel {
    margin-top: 0;
    padding: 24px 28px;
    border-top: none;
}

.panel-title {
    margin-bottom: 4px;
    font-size: 18px;
}

.panel-hint {
    margin-bottom: 16px;
    font-size: 13px;
    color: var(--grey-text);
}

.panel-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

/* A button in the top right corner of a panel; on narrow screens it moves below the title, still on the right */
.panel-head-action {
    flex-shrink: 0;
    margin-left: auto;
}

/* A short note in the top right corner of a panel, next to its title */
.panel-head .panel-meta {
    margin: 4px 0 0;
    font-size: 12px;
    text-align: right;
}

.save-bar {
    position: sticky;
    bottom: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    margin: 20px -28px -24px;
    padding: 14px 28px;
    background: #fff;
    border-top: 1px solid var(--grey-border);
    box-shadow: 0 -8px 16px -12px rgba(0, 0, 0, 0.25);
}

/* A form followed by more content in the same card (master data): the button sits in the last cell of the field
   grid, level with the inputs, instead of a footer that sticks to the bottom edge of the card */
.save-bar.save-bar-inline {
    position: static;
    flex-wrap: wrap;
    align-self: end;
    margin: 0;
    padding: 0;
    background: none;
    border-top: 0;
    box-shadow: none;
}

.save-status {
    margin-right: auto;
    font-size: 13px;
    font-weight: 700;
    color: var(--umg-orange);
}

.entry-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px 20px;
}

.entry-grid label {
    display: block;
    margin-bottom: 4px;
    font-size: 13px;
    color: var(--grey-text);
}

.entry-grid input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--grey-border);
    background: #fff;
    font-size: 14px;
}

.entry-grid input:focus,
.edit-input:focus {
    border-color: var(--umg-blue);
}

.edit-input {
    padding: 7px 9px;
    border: 1px solid var(--grey-border);
    background: #fff;
    font-size: 14px;
}

.edit-input.num {
    width: 90px;
}

.field-error {
    margin-top: 3px;
    font-size: 12px;
    color: var(--danger);
}

.table-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
    margin-bottom: 12px;
}

.table-filter {
    width: 280px;
    max-width: 100%;
}

.table-count {
    font-size: 13px;
    color: var(--grey-text);
}

.table-empty {
    padding: 16px 0;
    font-size: 14px;
    color: var(--grey-text);
}

.edit-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.edit-table th {
    position: sticky;
    top: 0;
    padding: 10px 12px;
    background: var(--grey-surface);
    border-bottom: 2px solid var(--grey-border);
    text-align: left;
    font-weight: 700;
    color: var(--umg-navy);
}

.edit-table td {
    padding: 6px 12px;
    border-bottom: 1px solid var(--grey-line);
    color: var(--umg-navy);
}

.edit-table tbody tr:nth-child(even) {
    background: #fafafa;
}

.edit-table tbody tr:hover {
    background: #eef3f8;
}

.edit-table .num-col {
    width: 110px;
    text-align: right;
}

.edit-table .todo {
    color: var(--umg-steel);
    font-weight: 700;
}

.unit {
    margin-left: 6px;
    font-size: 13px;
    color: var(--umg-steel);
}

.rot-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 7px 0;
    border-bottom: 1px solid var(--grey-line);
}

.rot-group {
    margin-bottom: 18px;
    border: 1px solid var(--grey-line);
}

.rot-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px 16px;
    padding: 10px 14px;
    background: var(--grey-surface);
    border-bottom: 1px solid var(--grey-line);
}

.rot-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--umg-navy);
}

.rot-total {
    font-size: 14px;
    font-weight: 700;
    color: var(--umg-blue);
}

.rot-count,
.rot-planned {
    font-size: 13px;
    color: var(--umg-steel);
}

.rot-group .rot-row {
    padding: 7px 14px;
}

.rot-group .rot-row:last-child {
    border-bottom: none;
}

.rot-add {
    background: #fafafa;
}

.rot-label {
    min-width: 130px;
    font-size: 13px;
    color: var(--grey-text);
}

.rot-months {
    min-width: 150px;
    font-size: 13px;
    font-weight: 700;
    color: var(--umg-navy);
}

.rot-new {
    margin-top: 22px;
    padding-top: 18px;
    border-top: 2px solid var(--grey-line);
}

.rot-new .rot-row {
    padding-left: 0;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-top: 16px;
    font-size: 14px;
}

.pagination-status {
    color: var(--grey-text);
}

.picker-panel-narrow {
    width: min(340px, 90vw);
}

.picker-tools-plain {
    margin-top: 0;
}

.resident-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.picker-badge-light {
    background: var(--grey-surface);
    border: 1px solid var(--grey-border);
    color: var(--umg-navy);
}

.danger-panel {
    border-top: 3px solid var(--danger);
}

.reason-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 4px 0 18px;
    border: none;
}

.reason-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border: 1px solid var(--grey-border);
    background: #fff;
    cursor: pointer;
    font-size: 15px;
}

.reason-item:hover {
    background: var(--grey-surface);
}

.reason-item input {
    accent-color: var(--umg-blue);
}

.consequences {
    padding: 14px 18px;
    background: var(--grey-surface);
    border-left: 4px solid var(--umg-steel);
    font-size: 14px;
}

.consequences ul {
    margin: 8px 0 0 18px;
}

.consequences li {
    margin-bottom: 4px;
}

.btn-action.danger-solid {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

.btn-action.danger-solid:hover {
    background: #7f2020;
    border-color: #7f2020;
}

.archive-actions {
    width: auto;
    white-space: nowrap;
}

.archive-actions form {
    display: inline-block;
    margin-left: 8px;
}

.archive-search {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.log-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.log-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px 4px;
    border: 1px solid var(--umg-steel);
    background: #fff;
    font-size: 14px;
    color: var(--umg-navy);
    text-decoration: none;
    transition: all 0.2s;
}

.log-chip:hover {
    background: var(--grey-surface);
    border-color: var(--umg-blue);
}

.log-chip.is-active {
    background: var(--umg-blue);
    border-color: var(--umg-blue);
    color: #fff;
    font-weight: 700;
}

.log-chip.is-empty {
    border-color: var(--grey-border);
    color: var(--umg-steel);
}

.log-chip-count {
    font-size: 12px;
    font-weight: 700;
    opacity: 0.8;
}

.log-time {
    white-space: nowrap;
    color: var(--grey-text);
}

.log-badge {
    display: inline-block;
    padding: 1px 8px 0;
    background: var(--grey-surface);
    border: 1px solid var(--grey-border);
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.log-details summary {
    cursor: pointer;
}

.log-details summary::marker {
    color: var(--umg-blue);
}

.log-details ul {
    margin: 8px 0 4px 18px;
    font-size: 13px;
    color: var(--grey-text);
}

.log-table td {
    vertical-align: top;
}

.log-card {
    margin-top: 20px;
    padding: 24px 28px;
}

.log-summary {
    font-weight: 700;
}

.change-list {
    margin: 6px 0 0;
    padding: 0;
    list-style: none;
    font-size: 13px;
}

.change-list li {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 8px;
    padding: 2px 0;
}

.change-label {
    color: var(--grey-text);
}

.change-label::after {
    content: ":";
}

.change-old {
    padding: 0 6px;
    background: #fdf0ef;
    color: var(--danger);
    text-decoration: line-through;
    text-decoration-color: rgba(163, 45, 45, 0.45);
}

.change-arrow {
    color: var(--umg-steel);
    font-weight: 700;
}

.change-new {
    padding: 0 6px;
    background: #eaf6ef;
    color: #1c7a45;
    font-weight: 700;
}

.log-details summary {
    cursor: pointer;
}

/* ── Administration ──────────────────────────────────────── */

.admin-card {
    padding: 24px 28px;
}

.staff-table td {
    vertical-align: middle;
}

.staff-name {
    font-weight: 700;
}

.staff-tag {
    margin-left: 8px;
    padding: 1px 8px 0;
    background: var(--grey-surface);
    border: 1px solid var(--grey-border);
    font-size: 12px;
    font-weight: 700;
    color: var(--umg-steel);
}

.staff-tag-admin {
    border-color: var(--umg-lime);
    color: var(--umg-navy);
}

.status-pill {
    display: inline-block;
    padding: 1px 10px 0;
    font-size: 12px;
    font-weight: 700;
}

.status-active {
    background: #eaf6ef;
    color: #1c7a45;
}

.status-locked {
    background: #fdf0ef;
    color: var(--danger);
}

.staff-actions {
    width: auto;
    white-space: nowrap;
}

.staff-actions > * {
    margin-left: 16px;
}

.action-danger {
    color: var(--danger);
}

.action-disabled {
    font-size: 13px;
    color: var(--umg-steel);
    cursor: not-allowed;
    border-bottom: 1px dotted var(--umg-steel);
}

.admin-subsection {
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid var(--grey-line);
}

.subsection-title {
    margin-bottom: 4px;
    font-size: 16px;
}

.field-hint {
    margin-top: 4px;
    font-size: 12px;
    color: var(--umg-steel);
}

.switch-field {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.switch-label {
    display: flex !important;
    align-items: center;
    gap: 10px;
    margin: 0 !important;
    padding: 9px 0;
    font-size: 15px !important;
    color: var(--umg-navy) !important;
    cursor: pointer;
}

.entry-grid .switch-label input {
    width: auto;
    accent-color: var(--umg-blue);
}

.import-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

.file-name {
    flex: 1;
    min-width: 180px;
    font-size: 14px;
    color: var(--umg-steel);
}

.file-name.is-set {
    color: var(--umg-navy);
    font-weight: 700;
}

.import-form input:focus-visible + .file-button {
    outline: 2px solid var(--umg-navy);
    outline-offset: 2px;
}

.import-last {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--grey-line);
    font-size: 14px;
    color: var(--grey-text);
}

.password-grid {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    max-width: 900px;
}

.password-help ul {
    margin: 6px 0 0 16px;
}

.form-actions {
    margin-top: 16px;
}

.import-form {
    position: relative;
}

.table-scroll {
    max-width: 100%;
    overflow-x: auto;
}

.break-anywhere {
    overflow-wrap: anywhere;
    min-width: 8ch;
}

.staff-table .status-pill,
.staff-tag {
    white-space: nowrap;
}

#procedure-table td:first-child {
    overflow-wrap: anywhere;
}

.edit-table .num-col {
    width: 1%;
    white-space: nowrap;
}

/* Observer role: read-only data entry */
.read-only-note {
    margin: -0.25rem 0 1rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.82rem;
    color: #203151;
    background: #eef3f9;
    border-left: 4px solid #134A84;
}
.read-only-fieldset {
    border: 0;
    margin: 0;
    padding: 0;
    min-width: 0;
}
.read-only-fieldset input,
.read-only-fieldset select,
.read-only-fieldset textarea {
    background: #f1f2f3;
    color: #7a7f87;
    border-color: #dedede;
    cursor: not-allowed;
}

/* Profile page */
.profile-data {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px 24px;
    margin: 0;
}

.profile-data dt {
    font-size: 0.75rem;
    color: var(--umg-steel);
    margin-bottom: 2px;
}

.profile-data dd {
    margin: 0;
    font-size: 0.9rem;
    color: var(--umg-navy);
    overflow-wrap: anywhere;
}

/* Administration tab of a resident: one row per action, the button always on the right */
.admin-action {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 16px 0;
    border-top: 1px solid var(--grey-border);
}

.admin-action-text {
    min-width: 0;
}

.admin-action-text .subsection-title,
.admin-action-text .panel-hint {
    margin: 0 0 4px;
}

.admin-action .btn-action {
    flex-shrink: 0;
    white-space: nowrap;
}

@media (max-width: 700px) {
    .admin-action {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* Resident header meta: items separated by a dot, independent of whitespace */
.resident-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0 14px;
}

.resident-meta > span + span::before {
    content: "·";
    margin-right: 14px;
}

/* Administration tab: first row without a rule, equal button widths, danger row set apart */
.tab-panel > .admin-action:first-child {
    border-top: 0;
    padding-top: 4px;
}

.admin-action .btn-action {
    min-width: 200px;
    justify-content: center;
    text-align: center;
}

.admin-action-danger {
    margin-top: 8px;
    padding: 16px;
    border: 1px solid #e3c4c4;
    background: #fbf5f5;
}

.tab-panel > .admin-action-danger:first-child {
    padding-top: 16px;
}

/* Administration tab: both rows share the same inner padding so the buttons line up */
.tab-panel > .admin-action {
    padding: 16px;
}

.tab-panel > .admin-action:first-child {
    padding-top: 16px;
}

.resident-meta {
    gap: 0 10px;
}

.resident-meta > span + span::before {
    margin-right: 10px;
}

.tab-panel > .admin-action-danger {
    margin-top: 24px;
}

/* A button inside a table row that looks like the surrounding links */
.inline-form {
    display: inline;
    margin: 0;
}

.link-button {
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    cursor: pointer;
}

.resident-back {
    margin-left: auto;
    white-space: nowrap;
}

/* Archived residents inside the search results and on their read-only profile */
.archived-tag {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 8px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--umg-steel);
    background: var(--grey-surface);
    border: 1px solid var(--grey-border);
    vertical-align: middle;
}

.edit-table tr.is-archived td {
    color: var(--umg-steel);
}

.archive-search .table-filter {
    width: 100%;
    max-width: 380px;
}

/* Protocol tab: the count and the page links are shown above the list as well */
.log-summary-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 8px;
    font-size: 0.8rem;
    color: var(--umg-steel);
}

.log-summary-line .pagination {
    margin: 0;
}

.panel-head-text {
    flex: 1;
    min-width: 0;
}

/* Table card header: title and search on the left, the actions of the table on the right */
.table-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px 16px;
    padding: 1rem 1.25rem 0.75rem;
    border-bottom: 1px solid var(--grey-line);
}

.table-head-text {
    flex: 1 1 280px;
    min-width: 0;
}

.table-head-text h4 {
    margin: 0 0 0.75rem;
}

.table-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.table-actions .picker-panel {
    left: auto;
    right: 0;
}

/* Export menu */
.export-menu {
    position: relative;
}

.export-menu > summary {
    list-style: none;
    cursor: pointer;
    gap: 8px;
}

.export-menu > summary::-webkit-details-marker {
    display: none;
}

.export-chevron {
    transition: transform 0.2s ease-in-out;
}

.export-menu[open] > summary {
    background: var(--grey-surface);
    border-color: var(--umg-blue);
}

.export-menu[open] .export-chevron {
    transform: rotate(180deg);
}

.export-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 30;
    width: 300px;
    padding: 6px;
    background: #fff;
    border: 1px solid var(--grey-border);
    border-top: 4px solid var(--umg-lime);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}

.export-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    color: var(--umg-navy);
    text-decoration: none;
}

.export-item:hover,
.export-item:focus-visible {
    background: var(--grey-surface);
}

.export-badge {
    flex-shrink: 0;
    width: 40px;
    padding: 6px 0 4px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-align: center;
    color: #fff;
}

.export-badge-pdf {
    background: var(--umg-blue);
}

.export-badge-csv {
    background: var(--umg-navy);
}

.export-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.export-text small {
    font-size: 0.75rem;
    color: var(--umg-steel);
}

.export-note {
    margin: 4px 10px 8px;
    padding-top: 8px;
    border-top: 1px solid var(--grey-line);
    font-size: 0.72rem;
    color: var(--umg-steel);
}

/* The logo leads to the start page */
.sidebar-logo-link {
    display: block;
    flex-shrink: 0;
    color: inherit;
}

.sidebar-logo-link:hover .sidebar-logo {
    background: var(--grey-surface);
}

.sidebar-logo {
    transition: background 0.2s ease-in-out;
}

/* Resident view: the tabs on the left, the protocol of the active tab on the right below the search bar */
.resident-layout {
    display: block;
}

.resident-layout.has-aside {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 20px;
    align-items: start;
}

.resident-main {
    min-width: 0;
}

.resident-aside {
    position: sticky;
    top: 16px;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
}

.resident-aside .log-card {
    margin: 0;
    padding: 16px;
}

.log-timeline {
    list-style: none;
    margin: 12px 0 0;
    padding: 0 0 0 14px;
    border-left: 2px solid var(--grey-line);
}

.log-item {
    position: relative;
    padding: 0 0 16px;
}

.log-item::before {
    content: "";
    position: absolute;
    left: -20px;
    top: 5px;
    width: 8px;
    height: 8px;
    background: var(--umg-blue);
}

.log-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px 8px;
    margin-bottom: 2px;
    font-size: 0.72rem;
    color: var(--umg-steel);
}

.log-actor {
    font-weight: 600;
}

@media (max-width: 1250px) {
    .resident-layout.has-aside {
        grid-template-columns: minmax(0, 1fr);
    }

    .resident-aside {
        position: static;
        max-height: none;
    }
}

.resident-aside .log-summary {
    font-size: 0.85rem;
}

.resident-aside .change-list {
    font-size: 0.78rem;
}

/* "Verwalten" in the resident header leads to the administration of this resident */
.resident-manage {
    margin-left: auto;
    gap: 8px;
    align-self: flex-start;
    text-decoration: none;
    white-space: nowrap;
}

/* Sorting of the procedure table by count, share or difference */
.table-head-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 16px;
}

.sort-metric {
    display: inline-flex;
    align-items: center;
    gap: 0;
}

.sort-metric-label {
    margin-right: 10px;
    font-size: 0.75rem;
    color: var(--umg-steel);
}

.sort-metric-btn {
    padding: 7px 12px;
    font: inherit;
    font-size: 0.78rem;
    color: var(--umg-navy);
    background: #fff;
    border: 1px solid var(--grey-border);
    margin-left: -1px;
    cursor: pointer;
}

.sort-metric-btn:hover {
    background: var(--grey-surface);
}

.sort-metric-btn.is-active {
    position: relative;
    color: #fff;
    background: var(--umg-blue);
    border-color: var(--umg-blue);
    font-weight: 600;
}

/* Header of a procedure column: the name on top, the three ways to sort right below it */
.op-table th.op-head {
    vertical-align: top;
}

.op-head-title {
    display: block;
    min-height: 2.4em;
}

.op-sort {
    display: flex;
    gap: 4px;
    margin-top: 6px;
}

.op-sort-btn {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 3px 8px;
    font: inherit;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--umg-steel);
    background: #fff;
    border: 1px solid var(--grey-border);
    cursor: pointer;
}

.op-sort-btn:hover {
    color: var(--umg-blue);
    border-color: var(--umg-blue);
}

.op-sort-btn.is-active {
    color: #fff;
    background: var(--umg-blue);
    border-color: var(--umg-blue);
}

.op-sort-arrow {
    font-size: 0.55rem;
}

/* Procedure header, second version: titles always take two lines so the sort buttons line up in every column,
   the three buttons form one joined control, the name header sits on the same line as the buttons */
.op-head-title {
    height: 2.7em;
    min-height: 0;
    overflow: hidden;
}

.op-sort {
    display: inline-flex;
    gap: 0;
    margin-top: 4px;
}

.op-sort-btn {
    margin-left: -1px;
    padding: 4px 10px;
}

.op-sort-btn:first-child {
    margin-left: 0;
}

.op-sort-btn.is-active {
    position: relative;
    z-index: 1;
}

.op-table th.op-name-col {
    vertical-align: bottom;
    padding-bottom: 0.65rem;
}

/* Procedure header, third version: the three ways to sort are quiet text tabs, the active one is underlined */
.op-sort {
    display: flex;
    gap: 14px;
    margin-top: 6px;
}

.op-sort-btn {
    gap: 3px;
    margin: 0;
    padding: 3px 0 2px;
    font-size: 0.72rem;
    font-weight: 500;
    color: #8a93a3;
    background: none;
    border: 0;
    border-bottom: 2px solid transparent;
}

.op-sort-btn:hover {
    color: var(--umg-blue);
    background: none;
    border-bottom-color: var(--grey-border);
}

.op-sort-btn.is-active {
    color: var(--umg-blue);
    background: none;
    font-weight: 700;
    border-bottom-color: var(--umg-blue);
}

.op-sort-arrow {
    font-size: 0.5rem;
}

/* The sort tabs sit on the right of the column, above the value they sort (the right side of the cells) */
.op-sort {
    justify-content: flex-end;
}

/* Legend menu: looks and behaves like the export menu next to it */
.legend-panel {
    width: 380px;
    padding: 14px 16px 10px;
}

.legend-title {
    margin: 0 0 8px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--umg-steel);
}

.legend-example {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--grey-line);
    font-size: 0.82rem;
    color: var(--umg-navy);
}

.legend-chip {
    flex-shrink: 0;
    padding: 3px 9px;
    font-size: 0.78rem;
    color: var(--umg-navy);
    background: var(--grey-surface);
    border: 1px solid var(--grey-border);
    white-space: nowrap;
}

.legend-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.legend-list li {
    padding: 6px 0 6px 10px;
    border-left: 3px solid var(--umg-lime);
    margin-bottom: 4px;
    font-size: 0.82rem;
    line-height: 1.4;
    color: var(--umg-navy);
}

.legend-list li strong {
    color: var(--umg-blue);
}

/* "Bearbeiten" tag on the menu entry of the residents: only the Verwaltung can change data there */
.btn-sidebar-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-left: auto;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    color: var(--umg-blue);
    background: #e8eff8;
    border: 1px solid #cfdcee;
    white-space: nowrap;
}

.btn-wrapper:hover .btn-sidebar-tag,
.btn-wrapper.is-active .btn-sidebar-tag {
    color: #fff;
    background: var(--umg-blue);
    border-color: var(--umg-blue);
}

.resident-manage-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-left: auto;
}

.log-resident {
    margin-bottom: 2px;
    font-size: 0.78rem;
    font-weight: 600;
}

/* In the narrower main column the buttons of a card head stay on the right, the hint text wraps */
.panel-head > .table-actions,
.panel-head > .btn-action {
    flex-shrink: 0;
}

/* Konten table in the narrower main column: role under the name, e-mail cut with a tooltip, actions stacked */
.staff-role {
    margin-top: 2px;
    font-size: 0.74rem;
    color: var(--umg-steel);
}

.staff-email {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.staff-table .log-time {
    white-space: nowrap;
}

.staff-table .staff-actions {
    text-align: right;
}

.staff-table .staff-actions > * {
    display: block;
    margin: 0 0 4px;
}

.staff-table th,
.staff-table td {
    padding-left: 0.6rem;
    padding-right: 0.6rem;
}

.staff-email {
    max-width: 130px;
}

.staff-table th,
.staff-table td {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

.staff-email {
    max-width: 105px;
}

/* The notice that asks for an own password at the first login */
.notice-card {
    border-left: 4px solid var(--umg-lime);
    background: #fbfbe6;
}

.notice-card .panel-hint {
    margin-bottom: 0;
}

/* At the first login the form for the own password comes before the profile data */
.profile-stack {
    display: flex;
    flex-direction: column;
}

.profile-stack.is-forced #passwort {
    order: -1;
}

/* "Name und Rolle" never makes the column wider: long names break, tags and role sit below the name */
.staff-table th:first-child,
.staff-table td:first-child {
    width: 30%;
    max-width: 200px;
}

.staff-table td:first-child .staff-name {
    display: block;
    overflow-wrap: anywhere;
}

.staff-table td:first-child .staff-tag {
    margin-left: 0;
    margin-right: 6px;
}

/* Row actions of the Mitarbeitende: three small icon buttons in one row, with tooltips */
.staff-table .staff-actions > .row-actions,
.row-actions {
    display: flex;
    justify-content: flex-end;
    gap: 4px;
    margin: 0;
}

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

.staff-table .staff-actions .icon-btn {
    margin: 0;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    color: var(--umg-navy);
    background: #fff;
    border: 1px solid var(--grey-border);
    text-decoration: none;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.icon-btn:hover,
.icon-btn:focus-visible {
    color: var(--umg-blue);
    border-color: var(--umg-blue);
    background: var(--grey-surface);
}

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

.icon-btn.is-danger:hover,
.icon-btn.is-danger:focus-visible {
    color: #fff;
    background: var(--danger);
    border-color: var(--danger);
}

.icon-btn.is-disabled {
    color: #b4bac4;
    background: var(--grey-surface);
    border-color: var(--grey-line);
    cursor: not-allowed;
}

/* Start page of a resident: macro statistics in the style of umg.eu (white cards, thin lines, blue numbers, lime accent) */
.stat-section {
    margin-top: 28px;
}

.stat-heading {
    margin-bottom: 18px;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--umg-navy);
}

.stat-heading::after {
    content: "";
    display: block;
    width: 40px;
    height: 4px;
    margin-top: 8px;
    background: var(--umg-lime);
}

.stat-eyebrow {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--umg-steel);
}

.stat-hero,
.stat-card {
    margin-bottom: 20px;
    padding: 24px 28px;
    background: #fff;
    border: 1px solid var(--grey-border);
    box-shadow: var(--card-shadow);
}

.stat-hero {
    border-top: 4px solid var(--umg-blue);
}

.stat-hero-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 20px;
}

.stat-hero-title {
    margin-top: 4px;
    font-size: 1.9rem;
    font-weight: 700;
    line-height: 1.15;
    color: var(--umg-blue);
}

.stat-hero-sub {
    margin-top: 4px;
    font-size: 0.85rem;
    color: var(--grey-text);
}

.stat-pace {
    flex-shrink: 0;
    padding: 5px 12px;
    font-size: 0.78rem;
    font-weight: 700;
    border: 1px solid transparent;
}

.stat-pace-ahead {
    color: #136b3a;
    background: #e3f4ea;
    border-color: #bfe3cd;
}

.stat-pace-on_track {
    color: var(--umg-blue);
    background: #e8eff8;
    border-color: #cfdcee;
}

.stat-pace-behind {
    color: #8a5b00;
    background: #fff4d6;
    border-color: #f1dc9c;
}

.stat-meter {
    margin-top: 16px;
}

.stat-meter-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 6px;
    font-size: 0.88rem;
}

.stat-meter-label {
    font-weight: 600;
    color: var(--umg-navy);
}

.stat-meter-value {
    font-weight: 700;
    color: var(--umg-blue);
}

.stat-track {
    height: 12px;
    background: var(--grey-surface);
    border: 1px solid var(--grey-border);
    overflow: hidden;
}

.stat-fill {
    height: 100%;
    max-width: 100%;
    background: var(--umg-blue);
}

.stat-fill-time {
    background: var(--umg-steel);
}

.stat-fill-done {
    background: #22a05a;
}

.stat-meter-note {
    margin-top: 5px;
    font-size: 0.78rem;
    color: var(--grey-text);
}

.stat-pace-text {
    margin: 18px 0 0;
    padding-top: 14px;
    border-top: 1px solid var(--grey-line);
    font-size: 0.88rem;
    color: var(--umg-navy);
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-tile {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 20px 22px;
    color: inherit;
    text-decoration: none;
    background: #fff;
    border: 1px solid var(--grey-border);
    border-left: 4px solid var(--umg-lime);
    transition: box-shadow 0.2s, border-color 0.2s;
}

a.stat-tile:hover,
a.stat-tile:focus-visible {
    border-color: var(--umg-blue);
    border-left-color: var(--umg-blue);
    box-shadow: var(--card-shadow);
}

.stat-number {
    font-size: 2.3rem;
    font-weight: 700;
    line-height: 1.1;
    color: var(--umg-blue);
}

.stat-of {
    font-size: 1.05rem;
    font-weight: 400;
    color: var(--umg-steel);
}

.stat-note {
    font-size: 0.8rem;
    color: var(--grey-text);
}

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

@media (max-width: 640px) {
    .stat-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .stat-hero-head {
        flex-direction: column;
    }
}

/* Procedures of a resident: summary, filter tabs and one row per procedure */
.proc-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.proc-kpi {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 18px 22px;
    background: #fff;
    border: 1px solid var(--grey-border);
    border-left: 4px solid var(--umg-lime);
}

.proc-kpi-wide {
    grid-column: span 2;
}

.proc-kpi .stat-number {
    font-size: 2rem;
}

.proc-card {
    padding: 0;
}

.proc-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 16px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--grey-line);
}

.proc-tabs {
    display: inline-flex;
}

.proc-tab {
    padding: 7px 14px;
    margin-left: -1px;
    font-size: 0.82rem;
    color: var(--umg-navy);
    text-decoration: none;
    background: #fff;
    border: 1px solid var(--grey-border);
}

.proc-tab:hover {
    background: var(--grey-surface);
}

.proc-tab.is-active {
    position: relative;
    color: #fff;
    background: var(--umg-blue);
    border-color: var(--umg-blue);
    font-weight: 600;
}

.proc-count {
    margin-left: 4px;
    font-size: 0.74rem;
    opacity: 0.8;
}

.proc-search {
    flex: 1 1 200px;
    max-width: 320px;
}

.proc-sort {
    margin-left: auto;
}

.proc-sort > summary strong {
    font-weight: 700;
    color: var(--umg-blue);
}

.proc-sort-label {
    color: var(--umg-steel);
}

/* On the blue hover background both texts take the white of the button */
.proc-sort > summary:hover strong,
.proc-sort > summary:hover .proc-sort-label,
.proc-sort > summary:focus-visible strong,
.proc-sort > summary:focus-visible .proc-sort-label {
    color: inherit;
}

.proc-sort .export-panel {
    width: 340px;
}

.sort-item {
    gap: 10px;
}

.sort-check {
    flex-shrink: 0;
    width: 16px;
    font-weight: 700;
    color: var(--umg-blue);
}

.sort-item.is-active {
    background: var(--grey-surface);
}

.proc-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.proc-heading {
    padding: 14px 20px 6px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--umg-steel);
    background: var(--grey-surface);
    border-bottom: 1px solid var(--grey-line);
}

.proc-row {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(180px, 1fr) 150px;
    align-items: center;
    gap: 8px 24px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--grey-line);
}

.proc-row:hover {
    background: #fafbfc;
}

.proc-row.is-child .proc-name {
    padding-left: 22px;
    font-weight: 400;
    border-left: 3px solid var(--grey-line);
}

.proc-name {
    font-size: 0.88rem;
    font-weight: 600;
    line-height: 1.35;
    color: var(--umg-navy);
}

.proc-figures {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 4px;
    font-size: 0.8rem;
}

.proc-count-text {
    font-weight: 600;
    color: var(--umg-navy);
}

.proc-percent {
    font-size: 0.74rem;
    color: #8a93a3;
}

.proc-progress .op-bar-track {
    height: 8px;
    background: rgba(220, 53, 53, 0.15);
    border: 1px solid rgba(220, 53, 53, 0.1);
    overflow: hidden;
}

.proc-progress .op-bar-fill {
    height: 100%;
    max-width: 100%;
    background: var(--umg-blue);
}

.proc-progress .op-bar-done {
    background: #22a05a;
}

.proc-progress .op-count-target {
    font-weight: 400;
    color: #6b7280;
}

.proc-progress .op-over-target {
    color: #136b3a;
}

.proc-open {
    text-align: right;
    line-height: 1.25;
}

.proc-open-main {
    display: block;
    font-size: 0.84rem;
    font-weight: 700;
    color: #8a93a3;
}

.proc-open.is-open .proc-open-main {
    color: #b3261e;
}

.proc-open.is-done .proc-open-main {
    color: #136b3a;
}

.proc-open-sub {
    display: block;
    font-size: 0.72rem;
    color: #8a93a3;
}

@media (max-width: 900px) {
    .proc-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .proc-row {
        grid-template-columns: minmax(0, 1fr) 120px;
    }

    .proc-name {
        grid-column: 1 / -1;
    }
}

/* Checklist pages of a resident (courses, meetings) */
.check-summary {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.check-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.check-row {
    display: grid;
    grid-template-columns: 32px minmax(0, 1.5fr) minmax(160px, 1fr) 90px;
    align-items: center;
    gap: 8px 20px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--grey-line);
}

.check-row:last-child {
    border-bottom: 0;
}

.check-row:hover {
    background: #fafbfc;
}

.check-mark {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--umg-steel);
    background: var(--grey-surface);
    border: 1px solid var(--grey-border);
    border-radius: 50%;
}

.check-row.is-done .check-mark {
    color: #fff;
    background: #22a05a;
    border-color: #22a05a;
}

.check-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--umg-navy);
}

.check-value {
    font-size: 0.85rem;
    color: #4d5565;
}

.check-row:not(.is-done) .check-value {
    color: #8a93a3;
}

.check-bar {
    margin-top: 5px;
}

.check-status {
    justify-self: end;
    padding: 3px 10px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #8a93a3;
    background: var(--grey-surface);
}

.check-row.is-done .check-status {
    color: #136b3a;
    background: #e6f4ec;
}

.check-bar.op-bar-track {
    height: 8px;
    background: rgba(220, 53, 53, 0.15);
    border: 1px solid rgba(220, 53, 53, 0.1);
    overflow: hidden;
}

.check-bar .op-bar-fill {
    height: 100%;
    max-width: 100%;
    background: var(--umg-blue);
}

.check-bar .op-bar-done {
    background: #22a05a;
}

@media (max-width: 900px) {
    .check-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .check-row {
        grid-template-columns: 32px minmax(0, 1fr) auto;
    }

    .check-value {
        grid-column: 2 / 3;
    }
}

/* Layout shell: on wide screens the sidebar stands beside the page, on narrow ones it becomes a bar with a menu button */
.sidebar-top {
    display: block;
    flex-shrink: 0;
}

.sidebar-menu {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.nav-burger {
    display: none;
}

@media (max-width: 860px) {
    body {
        flex-direction: column;
    }

    .sidebar {
        position: sticky;
        top: 0;
        z-index: 60;
        width: 100%;
        min-width: 0;
        height: auto;
        max-height: 100vh;
        max-height: 100dvh;
        align-self: stretch;
        border-right: 0;
        border-bottom: 1px solid var(--grey-border);
        box-shadow: 0 3px 8px -4px rgba(0, 0, 0, 0.25);
    }

    .sidebar-top {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding-right: 8px;
        border-bottom: 4px solid var(--umg-lime);
    }

    .sidebar-logo-link {
        flex: 0 1 220px;
        min-width: 0;
    }

    .sidebar-logo {
        padding: 10px 16px;
        border-bottom: 0;
    }

    .nav-burger {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        width: 44px;
        height: 44px;
        padding: 0;
        cursor: pointer;
        background: transparent;
        border: 0;
        border-radius: 0;
        color: var(--umg-navy);
        -webkit-tap-highlight-color: transparent;
    }

    .nav-burger:hover,
    .sidebar.is-open .nav-burger {
        background: var(--grey-surface);
    }

    .nav-burger:focus {
        outline: none;
    }

    .nav-burger:focus-visible {
        outline: 2px solid var(--umg-blue);
        outline-offset: -2px;
    }

    .nav-burger-bar,
    .nav-burger-bar::before,
    .nav-burger-bar::after {
        display: block;
        width: 20px;
        height: 2px;
        background: currentColor;
        transition: transform 0.2s ease-in-out, background 0.2s ease-in-out;
    }

    .nav-burger-bar {
        position: relative;
    }

    .nav-burger-bar::before,
    .nav-burger-bar::after {
        content: "";
        position: absolute;
        left: 0;
    }

    .nav-burger-bar::before {
        top: -6px;
    }

    .nav-burger-bar::after {
        top: 6px;
    }

    .sidebar.is-open .nav-burger-bar {
        background: transparent;
    }

    .sidebar.is-open .nav-burger-bar::before {
        transform: translateY(6px) rotate(45deg);
    }

    .sidebar.is-open .nav-burger-bar::after {
        transform: translateY(-6px) rotate(-45deg);
    }

    .sidebar-menu {
        display: none;
        overflow-y: auto;
    }

    .sidebar.is-open .sidebar-menu {
        display: flex;
    }

    .sidebar-section-label {
        padding-top: 16px;
    }

    .btn-sidebar {
        height: 50px;
    }

    .page-content {
        width: 100%;
        padding: 20px 16px 28px;
    }

    .page-title {
        margin-bottom: 20px;
        font-size: 26px;
    }
}

/* Narrow screens: toolbars wrap, popups stay inside the screen, wide tables scroll sideways */
img, svg {
    max-width: 100%;
}

@media (max-width: 860px) {
    .panel-head-text,
    .table-head-text {
        flex: 1 1 100%;
    }

    .panel-head > .table-actions,
    .panel-head > .btn-action {
        flex-shrink: 1;
    }

    .table-head {
        padding: 0.9rem 1rem 0.75rem;
    }

    .table-actions {
        flex-wrap: wrap;
        justify-content: flex-end;
        width: 100%;
    }

    .export-panel,
    .legend-panel {
        width: min(340px, calc(100vw - 32px));
    }

    .picker-panel,
    .picker-panel-narrow {
        width: min(420px, calc(100vw - 32px));
    }

    .edit-table {
        display: block;
        max-width: 100%;
        overflow-x: auto;
    }

    .btn-action {
        min-height: 40px;
    }

    .login-card {
        padding: 1.75rem 1.25rem;
    }
}

@media (max-width: 480px) {
    .page-content {
        padding: 16px 12px 24px;
    }

    .proc-kpi {
        padding: 14px 16px;
    }

    .proc-kpi .stat-number {
        font-size: 1.7rem;
    }

    .tab {
        padding: 10px 12px 8px;
        font-size: 14px;
    }
}

/* Internal comments of the staff about a resident, laid out like the comments under a video */
.comment-compose,
.comment {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.comment-compose {
    margin: 8px 0 28px;
}

.comment-body {
    flex: 1;
    min-width: 0;
}

.compose-input {
    display: block;
    width: 100%;
    min-height: calc(1.45em + 12px); /* one line plus padding and the thicker border while focused */
    padding: 6px 0 4px;
    overflow: hidden;
    font: inherit;
    font-size: 14px;
    line-height: 1.45;
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--grey-border);
    border-radius: 0;
    resize: none;
    outline: none;
}

.compose-input:focus {
    padding-bottom: 3px;
    border-bottom: 2px solid var(--umg-navy);
}

.compose-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 8px;
}

/* With the script the buttons only appear once the field is used */
.comment-compose.is-enhanced:not(.is-active) .compose-actions {
    display: none;
}

.btn-text,
.btn-pill {
    padding: 8px 16px;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    border: 0;
    border-radius: 18px;
    cursor: pointer;
}

.btn-text {
    color: var(--umg-navy);
    background: transparent;
}

.btn-text:hover,
.btn-text:focus-visible {
    background: #eef1f5;
}

.btn-small {
    padding: 4px 10px;
    font-size: 12px;
}

.btn-pill {
    color: #fff;
    background: var(--umg-blue);
}

.btn-pill:hover {
    background: var(--umg-blue-dark);
}

.btn-pill:disabled {
    color: #8a8a8a;
    background: #ececec;
    cursor: default;
}

.comment-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.comment {
    margin-bottom: 20px;
}

.comment-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 6px;
    margin-bottom: 2px;
    font-size: 13px;
}

.comment-author {
    font-weight: 700;
    color: #0f0f0f;
}

.comment-time {
    color: #606060;
}

.comment-text {
    font-size: 14px;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.comment-tools {
    margin: 2px 0 0 -10px;
}

@media (hover: hover) {
    .comment .comment-tools {
        opacity: 0;
        transition: opacity 0.15s;
    }

    .comment:hover .comment-tools,
    .comment:focus-within .comment-tools {
        opacity: 1;
    }
}

.comment-empty {
    font-size: 14px;
    color: #606060;
}

@media (max-width: 600px) {
    .comment-compose,
    .comment {
        gap: 12px;
    }

    .comment-compose .profile-icon,
    .comment .profile-icon {
        width: 32px;
        height: 32px;
        font-size: 15px;
    }
}
