:root {
    color-scheme: light;
    --bg: #f3f5f1;
    --bg-accent: linear-gradient(180deg, rgba(255, 255, 255, 0.8), rgba(243, 245, 241, 0.2));
    --surface: #ffffff;
    --surface-muted: #eef2ea;
    --surface-2: #eef2ea;
    --border: #d9ded3;
    --text: #20251f;
    --muted: #66705f;
    --accent: #285f4d;
    --accent-dark: #1f4a3d;
    --accent-strong: #173a30;
    --surface-inset: #ffffff;
    --input-bg: #ffffff;
    --header-bg: rgba(255, 255, 255, 0.96);
    --header-shadow: 0 2px 14px rgba(32, 37, 31, 0.05);
    --focus-ring: #5d8f7d;
    --danger-bg: #f8dedb;
    --danger-text: #8f2d24;
    --success-bg: #dceee3;
    --success-text: #24543d;
    --warning-bg: #f8eed8;
    --warning-text: #76521d;
    --shadow: 0 8px 24px rgba(32, 37, 31, 0.08);
}

[data-theme="dark"] {
    color-scheme: dark;
    --bg: #111614;
    --bg-accent: linear-gradient(180deg, rgba(23, 29, 26, 0.95), rgba(17, 22, 20, 0.85));
    --surface: #181f1c;
    --surface-muted: #202823;
    --surface-2: #202823;
    --border: #32403a;
    --text: #edf3ed;
    --muted: #a7b2a9;
    --accent: #7fc5a8;
    --accent-dark: #b2e2c9;
    --accent-strong: #d2f2df;
    --surface-inset: #101512;
    --input-bg: #141a17;
    --header-bg: rgba(17, 22, 20, 0.98);
    --header-shadow: 0 2px 14px rgba(0, 0, 0, 0.35);
    --focus-ring: #98d4b9;
    --danger-bg: #3a2321;
    --danger-text: #ffb7b0;
    --success-bg: #203325;
    --success-text: #a7e0b7;
    --warning-bg: #3b3121;
    --warning-text: #f0cc8d;
    --shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    background-image: var(--bg-accent);
    color: var(--text);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}

body.has-lightbox {
    overflow: hidden;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    color: var(--accent-dark);
    text-decoration: underline;
}

button,
input,
select {
    font: inherit;
}

img {
    max-width: 100%;
    height: auto;
}

td,
dd,
.list-row,
.scan-result {
    overflow-wrap: anywhere;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 14px clamp(16px, 4vw, 40px);
    background: var(--header-bg);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--header-shadow);
}

.header-brandrow {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-shell {
    display: flex;
    align-items: center;
    gap: 18px;
    margin-left: auto;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.menu-toggle {
    display: none;
    min-height: 40px;
    padding: 8px 12px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-weight: 750;
    cursor: pointer;
}

.brand {
    color: var(--text);
    font-weight: 800;
    font-size: 1.1rem;
    white-space: nowrap;
    display: grid;
    gap: 1px;
    line-height: 1.05;
}

.brand-main {
    font-size: 1.05rem;
}

.brand-subtitle {
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 650;
}

.main-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}

.public-nav {
    margin-left: auto;
}

.main-nav a,
.nav-link,
.nav-group-toggle,
.logout-form button,
.primary-button,
.secondary-button,
.danger-button,
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid transparent;
    font-weight: 650;
}

.main-nav a {
    color: var(--text);
}

.main-nav a:hover,
.nav-group-toggle:hover {
    background: var(--surface-muted);
    text-decoration: none;
}

.nav-group {
    position: relative;
}

.nav-group-toggle {
    color: var(--text);
    cursor: pointer;
    background: transparent;
}

.nav-group-toggle::after {
    content: "▾";
    margin-left: 6px;
    color: var(--muted);
    font-size: 0.75rem;
}

.nav-group-toggle[aria-expanded="true"] {
    background: var(--surface-muted);
}

.nav-group-menu {
    display: none;
    gap: 6px;
    padding: 8px;
    margin-top: 6px;
    min-width: 220px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow);
}

.nav-group-toggle[aria-expanded="true"] + .nav-group-menu {
    display: grid;
}

.nav-group-menu a {
    width: 100%;
    justify-content: flex-start;
}

.nav-group-menu a:hover,
.nav-group-menu a:focus-visible {
    background: var(--surface-muted);
    text-decoration: none;
}

.logout-form {
    margin: 0;
}

.logout-form button {
    background: transparent;
    color: var(--text);
    border-color: var(--border);
    cursor: pointer;
}

.theme-toggle {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
    cursor: pointer;
}

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

.site-footer {
    display: flex;
    justify-content: center;
    gap: 12px;
    padding: 18px 16px 28px;
    color: var(--muted);
    font-size: 0.9rem;
}

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--accent);
    font-size: 0.82rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0;
}

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

h1 {
    margin-bottom: 0;
    font-size: clamp(2rem, 4vw, 3rem);
    line-height: 1.05;
}

h2 {
    font-size: 1.25rem;
    margin-bottom: 14px;
}

h3 {
    font-size: 1rem;
    margin: 18px 0 8px;
}

.stats-grid,
.card-grid,
.detail-grid,
.two-column {
    display: grid;
    gap: 16px;
}

.stats-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 20px;
}

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

.card-grid {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

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

.stat-card {
    padding: 18px;
}

.stat-card span {
    display: block;
    color: var(--muted);
    font-weight: 650;
}

.stat-card strong {
    display: block;
    margin-top: 8px;
    font-size: 2.15rem;
    line-height: 1;
}

.panel {
    padding: 18px;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.panel-head h2 {
    margin-bottom: 0;
}

.item-list {
    display: grid;
    gap: 8px;
}

.item-list.compact {
    gap: 6px;
}

.list-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

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

.list-row small {
    display: block;
    color: var(--muted);
}

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

.filter-bar {
    display: grid;
    grid-template-columns: 2fr repeat(4, minmax(140px, 1fr)) auto auto;
    gap: 12px;
    align-items: end;
    padding: 16px;
    margin-bottom: 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}

label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 650;
}

input,
select {
    width: 100%;
    min-height: 40px;
    padding: 8px 10px;
    color: var(--text);
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
}

input::placeholder,
select::placeholder,
textarea::placeholder {
    color: var(--muted);
}

input:focus-visible,
select:focus-visible,
button:focus-visible,
a:focus-visible,
.nav-group-toggle:focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: 2px;
}

.primary-button {
    background: var(--accent);
    color: #ffffff;
    border-color: var(--accent);
    cursor: pointer;
}

.primary-button:hover {
    background: var(--accent-dark);
    color: #ffffff;
    text-decoration: none;
}

.danger-button {
    background: #a23a2f;
    color: #ffffff;
    border-color: #a23a2f;
    cursor: pointer;
}

.danger-button:hover {
    background: #842d25;
    color: #ffffff;
    text-decoration: none;
}

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

.secondary-button:hover {
    background: var(--surface-muted);
    text-decoration: none;
}

.action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.workflow-grid,
.quick-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
}

.workflow-card,
.quick-card {
    display: grid;
    gap: 10px;
    padding: 18px;
}

.messages {
    display: grid;
    gap: 8px;
    margin-bottom: 18px;
}

.responsive-table {
    width: 100%;
    overflow-x: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

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

th,
td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 0.86rem;
}

tr:last-child td {
    border-bottom: 0;
}

.detail-list {
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: 10px 16px;
    margin: 0;
}

.detail-list dt {
    color: var(--muted);
    font-weight: 700;
}

.detail-list dd {
    line-height: 1.45;
    margin: 0;
    min-width: 0;
}

.detail-list__block-value {
    white-space: normal;
}

.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    max-width: 960px;
}

.main-photo {
    max-width: 760px;
    margin-bottom: 18px;
}

.photo-button {
    display: block;
    width: 100%;
    padding: 0;
    cursor: zoom-in;
    background: transparent;
    border: 0;
    border-radius: 8px;
    text-align: inherit;
}

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

.main-photo .photo-button {
    background: var(--surface-muted);
    border: 1px solid var(--border);
}

.main-photo img {
    display: block;
    width: 100%;
    max-height: min(52vh, 480px);
    object-fit: contain;
    border-radius: 8px;
}

.thumb {
    width: 64px;
    height: 48px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--border);
}

figure {
    margin: 0;
}

.photo-grid figure img {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--border);
}

figcaption {
    margin-top: 6px;
    color: var(--muted);
    font-size: 0.9rem;
}

.lightbox {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    grid-template-columns: minmax(44px, 1fr) minmax(0, 1100px) minmax(44px, 1fr);
    align-items: center;
    gap: 12px;
    padding: 24px;
    background: rgba(0, 0, 0, 0.88);
}

.lightbox[hidden] {
    display: none;
}

.lightbox__figure {
    display: grid;
    justify-items: center;
    gap: 10px;
    min-width: 0;
}

.lightbox__figure img {
    display: block;
    max-width: 100%;
    max-height: 82vh;
    width: auto;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 20px 70px rgba(0, 0, 0, 0.45);
}

.lightbox__figure figcaption {
    color: #fff;
    text-align: center;
}

.lightbox__close,
.lightbox__nav {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 999px;
}

.lightbox__close {
    position: absolute;
    top: 18px;
    right: 18px;
    width: 42px;
    height: 42px;
    font-size: 2rem;
    line-height: 1;
}

.lightbox__nav {
    width: 48px;
    height: 48px;
    font-size: 2.4rem;
}

.lightbox__nav--previous {
    justify-self: end;
}

.lightbox__nav--next {
    justify-self: start;
}

.lightbox__close:hover,
.lightbox__nav:hover,
.lightbox__close:focus-visible,
.lightbox__nav:focus-visible {
    background: rgba(255, 255, 255, 0.22);
    outline: none;
}

.auth-panel {
    width: min(420px, 100%);
    margin: 70px auto;
}

.landing-hero {
    min-height: calc(100vh - 150px);
    display: grid;
    align-items: center;
    padding: clamp(36px, 8vw, 92px) 0;
}

.landing-copy {
    width: min(780px, 100%);
}

.landing-copy h2 {
    margin: 16px 0;
    color: var(--muted);
    font-size: clamp(1.25rem, 3vw, 2rem);
    font-weight: 650;
    line-height: 1.2;
}

.landing-copy p {
    max-width: 620px;
    font-size: 1.1rem;
}

.profile-card {
    text-align: center;
}

.profile-image,
.profile-initials {
    width: 132px;
    height: 132px;
    margin: 0 auto 16px;
    border-radius: 50%;
}

.profile-image {
    display: block;
    object-fit: cover;
    border: 1px solid var(--border);
}

.profile-initials {
    display: grid;
    place-items: center;
    background: var(--surface-muted);
    color: var(--accent-dark);
    font-size: 2.4rem;
    font-weight: 800;
}

.scan-panel {
    display: grid;
    gap: 18px;
}

.scan-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.scan-tabs a {
    display: inline-flex;
    min-height: 40px;
    align-items: center;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-weight: 700;
}

.scan-tabs a.active,
.scan-tabs a:hover {
    background: var(--accent);
    color: #ffffff;
    text-decoration: none;
}

.scanner {
    display: grid;
    gap: 12px;
    width: 100%;
    max-width: 520px;
    margin-top: 10px;
}

#scan-video,
#barcode-video {
    display: none;
    width: 100%;
    max-width: 520px;
    max-height: 260px;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    background: #101510;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.scanner.is-active #scan-video,
.scanner.is-active #barcode-video {
    display: block;
}

.scan-form {
    width: min(640px, 100%);
    box-shadow: none;
}

.form-card {
    display: grid;
    gap: 12px;
    padding: 20px;
}

.teil-form {
    gap: 16px;
}

.form-section,
.subsection-card {
    display: grid;
    gap: 12px;
    padding: 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.section-head {
    display: grid;
    gap: 2px;
}

.section-head--tight {
    gap: 0;
}

.section-kicker {
    margin: 0;
    color: var(--accent);
    font-size: 0.8rem;
    font-weight: 800;
    text-transform: uppercase;
}

.section-head h2,
.section-head h3 {
    margin: 0;
}

.section-action {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.form-actions,
.scan-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

.form-actions .primary-button,
.form-actions .secondary-button,
.scan-actions .primary-button,
.scan-actions .secondary-button {
    flex: 1 1 auto;
}

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

.kv-card {
    display: grid;
    gap: 4px;
    padding: 12px;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.kv-card span {
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 700;
}

.kv-card strong {
    min-width: 0;
    overflow-wrap: anywhere;
}

.kv-card--wide {
    grid-column: span 2;
}

.scan-block {
    display: grid;
    gap: 14px;
}

.teil-form fieldset {
    display: grid;
    gap: 12px;
    margin: 0;
    padding: 0 0 18px;
    border: 0;
    border-bottom: 1px solid var(--border);
}

.teil-form fieldset:last-child {
    border-bottom: 0;
}

.teil-form legend {
    padding: 0;
    color: var(--text);
    font-size: 1.08rem;
    font-weight: 800;
}

.compact-scanner {
    width: 100%;
}

.compact-scanner video {
    width: 100%;
    max-height: 260px;
}

.scan-result {
    margin: 0;
    padding: 8px 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--accent-dark);
    font-weight: 700;
}

.scan-result.subtle {
    color: var(--muted);
    font-weight: 650;
}

.scan-result.success {
    background: var(--success-bg);
    color: var(--success-text);
}

.scan-result.error {
    background: var(--danger-bg);
    color: var(--danger-text);
}

.detected-code-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.detected-code-row:first-of-type {
    border-top: 0;
}

.compact-form {
    margin-top: 8px;
}

.compact-form .secondary-button {
    min-height: 34px;
    padding: 6px 10px;
    font-size: 0.9rem;
}

.hidden {
    display: none;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--surface-muted);
    color: var(--accent-dark);
    font-weight: 700;
}

.status-row,
.tab-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tab-nav {
    margin: 0 0 18px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.tab-nav a {
    min-height: 36px;
    padding: 6px 10px;
    border-radius: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    font-weight: 700;
}

.status-pill.success {
    background: var(--success-bg);
    color: var(--success-text);
}

.status-pill.danger {
    background: var(--danger-bg);
    color: var(--danger-text);
}

.form-grid,
.checkbox-grid {
    display: grid;
    gap: 12px;
}

.form-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.checkbox-grid {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.check-card {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}

.check-card input {
    margin-top: 4px;
}

.check-card small {
    display: block;
    color: var(--muted);
}

.wide-form,
.narrow-panel {
    width: min(760px, 100%);
}

.inline-form {
    display: grid;
    gap: 10px;
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.inline-form p {
    display: grid;
    gap: 6px;
    margin: 0;
}

.message {
    padding: 10px 12px;
    border-radius: 8px;
}

.message.error,
.field-error {
    background: var(--danger-bg);
    color: var(--danger-text);
}

.message.success {
    background: var(--success-bg);
    color: var(--success-text);
}

.message.info {
    background: var(--surface-muted);
    color: var(--accent-dark);
}

.message.warning {
    background: var(--warning-bg);
    color: var(--warning-text);
}

.field-error {
    display: block;
    padding: 8px 10px;
    border-radius: 8px;
}

@media (max-width: 900px) {
    .site-header {
        align-items: flex-start;
        flex-direction: column;
        gap: 10px;
    }

    .header-actions {
        margin-left: 0;
        width: 100%;
        flex-wrap: wrap;
    }

    .main-nav {
        margin-left: 0;
        width: 100%;
    }

    .main-nav a,
    .nav-group-toggle {
        flex: 1 1 auto;
    }

    .stats-grid,
    .two-column,
    .detail-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

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

@media print {
    :root,
    [data-theme="dark"] {
        color-scheme: light;
        --bg: #fff;
        --bg-accent: none;
        --surface: #fff;
        --surface-muted: #fff;
        --surface-2: #fff;
        --border: #bbb;
        --text: #000;
        --muted: #333;
        --accent: #000;
        --accent-dark: #000;
        --accent-strong: #000;
        --danger-bg: #fff;
        --danger-text: #000;
        --success-bg: #fff;
        --success-text: #000;
        --warning-bg: #fff;
        --warning-text: #000;
        --shadow: none;
    }

    .site-header,
    .site-footer,
    .menu-toggle,
    .theme-toggle,
    .action-row,
    button,
    .logout-form,
    .no-print {
        display: none !important;
    }

    .panel,
    .form-card,
    .stat-card {
        box-shadow: none;
    }

    .nav-group-menu {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .form-actions,
    .scan-actions,
    .section-action {
        flex-direction: column;
        align-items: stretch;
    }

    .form-actions .primary-button,
    .form-actions .secondary-button,
    .scan-actions .primary-button,
    .scan-actions .secondary-button,
    .section-action .secondary-button {
        width: 100%;
    }

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

    .kv-card--wide {
        grid-column: auto;
    }

    .form-section,
    .subsection-card {
        padding: 14px;
    }
}

@media (max-width: 900px) {
    .site-header {
        align-items: stretch;
        gap: 10px;
    }

    .header-top {
        width: 100%;
        justify-content: space-between;
    }

    .menu-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .nav-shell {
        display: none;
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        gap: 10px;
        margin-left: 0;
        overflow: hidden;
    }

    .nav-shell.is-open {
        display: flex;
        padding-top: 4px;
    }

    .main-nav {
        display: grid;
        grid-template-columns: 1fr;
        width: 100%;
        margin-left: 0;
    }

    .main-nav a,
    .nav-group-toggle,
    .logout-form button {
        width: 100%;
        min-height: 46px;
        justify-content: flex-start;
    }

    .nav-group {
        width: 100%;
    }

    .nav-group-menu {
        min-width: 0;
        width: 100%;
    }

    .nav-group-menu[hidden] {
        display: none;
    }

    .logout-form {
        width: 100%;
    }
}

@media (max-width: 640px) {
    .page {
        width: min(100% - 20px, 1180px);
        margin-top: 18px;
    }

    .page-head {
        align-items: flex-start;
        flex-direction: column;
    }

    h1 {
        font-size: 2rem;
    }

    .stats-grid,
    .two-column,
    .detail-grid,
    .filter-bar {
        grid-template-columns: 1fr;
    }

    .site-header {
        padding: 12px 10px;
    }

    .logout-form,
    .logout-form button {
        width: 100%;
    }

    .responsive-table {
        border: 0;
        box-shadow: none;
        background: transparent;
    }

    table,
    thead,
    tbody,
    tr,
    th,
    td {
        display: block;
    }

    thead {
        display: none;
    }

    tr {
        margin-bottom: 12px;
        padding: 12px;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: 8px;
        box-shadow: var(--shadow);
    }

    td {
        display: grid;
        grid-template-columns: 115px 1fr;
        gap: 10px;
        padding: 8px 0;
        border-bottom: 1px solid var(--border);
    }

    td:last-child {
        border-bottom: 0;
    }

    td::before {
        content: attr(data-label);
        color: var(--muted);
        font-weight: 700;
    }

    td[colspan] {
        grid-template-columns: 1fr;
    }

    td[colspan]::before {
        content: "";
        display: none;
    }

    .detail-list {
        grid-template-columns: 1fr;
        gap: 5px;
    }

    .detail-list dt {
        margin-top: 8px;
    }

    .detail-list dt:first-child {
        margin-top: 0;
    }

    .lightbox {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: 1fr auto;
        gap: 12px;
        padding: 56px 14px 18px;
    }

    .lightbox__figure {
        grid-column: 1 / -1;
        grid-row: 1;
    }

    .lightbox__figure img {
        max-height: 72vh;
    }

    .lightbox__nav {
        grid-row: 2;
        width: 44px;
        height: 44px;
        font-size: 2rem;
    }

    .lightbox__nav--previous {
        justify-self: start;
    }

    .lightbox__nav--next {
        justify-self: end;
    }

    .scanner,
    #scan-video,
    #barcode-video {
        width: 100%;
        max-height: 220px;
    }
}
