h1:focus {
    outline: none;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #e50000;
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.darker-border-checkbox.form-check-input {
    border-color: #929292;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

:root {
    --touch-min: 44px;
    --input-height: 48px;
    --radius: 12px;
    --safe-l: env(safe-area-inset-left, 0px);
    --safe-r: env(safe-area-inset-right, 0px);
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    line-height: 1.5;
    -webkit-tap-highlight-color: rgba(61, 126, 239, 0.15);
    text-transform: capitalize;
}

/* Preserve literals, ids, and user entry (capitalize is word-wise on surrounding copy only) */
input,
textarea,
select,
option,
code,
pre,
kbd,
samp,
.file-input,
.nav-user {
    text-transform: none;
}

a {
    color: #7eb8ff;
}

.page-head {
    margin-bottom: 1.1rem;
}

.page-head h1 {
    margin: 0 0 0.35rem;
    font-size: 1.4rem;
    letter-spacing: -0.03em;
    line-height: 1.2;
}

@media (min-width: 641px) {
    .page-head {
        margin-bottom: 1.5rem;
    }

    .page-head h1 {
        font-size: 1.75rem;
    }
}

.muted {
    color: #8a9bb0;
    margin: 0;
}

.muted.small {
    font-size: 0.85rem;
}

.empty-state {
    padding: 2rem 1.25rem;
    text-align: center;
    background: rgba(255, 255, 255, 0.04);
    border: 1px dashed rgba(255, 255, 255, 0.12);
    border-radius: 12px;
}

.card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius);
    padding: 1rem 1rem;
    margin-bottom: 1rem;
}

@media (min-width: 641px) {
    .card {
        padding: 1.25rem 1.35rem;
        margin-bottom: 1.25rem;
    }
}

.card h2 {
    margin: 0 0 1rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: #c5d4e8;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 640px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
}

.form-grid .span-2 {
    grid-column: 1 / -1;
}

.field-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: #9eb0c4;
    margin-bottom: 0.35rem;
}

.input-block,
.input-grow,
.input-inline,
.input-narrow {
    width: 100%;
    max-width: 100%;
    padding: 0.65rem 0.75rem;
    min-height: var(--input-height);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(0, 0, 0, 0.25);
    color: #e8edf4;
    font: inherit;
    font-size: 1rem;
}

/* 16px+ avoids iOS zoom-on-focus */
.input-touch {
    font-size: 1rem;
}

@media (min-width: 641px) {
    .input-block,
    .input-grow,
    .input-inline,
    .input-narrow {
        padding: 0.5rem 0.65rem;
        min-height: auto;
        border-radius: 8px;
    }
}

.input-inline {
    width: auto;
    min-width: 8rem;
}

.input-inline.narrow {
    min-width: 4rem;
    width: 5rem;
}

.input-narrow {
    max-width: 6rem;
}

/* Request-access code: wider field + larger placeholder so e.g. KFT6EK fits clearly */
.input-narrow.input-request-code {
    max-width: none;
    min-width: 13.5rem;
    width: auto;
    flex: 1 1 13.5rem;
    font-size: 1.125rem;
}

.input-narrow.input-request-code::placeholder {
    font-size: 1.125rem;
    letter-spacing: 0.04em;
    opacity: 0.72;
}

.input-block:focus,
.input-grow:focus,
.input-inline:focus,
.input-narrow:focus {
    outline: 2px solid rgba(61, 126, 239, 0.45);
    border-color: #3d7eef;
}

.btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    margin-top: 1.1rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.65rem 1rem;
    min-height: var(--touch-min);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.06);
    color: #e8edf4;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.btn-touch {
    min-height: var(--touch-min);
}

.btn:active:not(:disabled) {
    filter: brightness(0.92);
    transform: scale(0.99);
}

@media (min-width: 641px) {
    .btn {
        padding: 0.5rem 1rem;
        min-height: auto;
        border-radius: 8px;
    }

    .btn:active:not(:disabled) {
        transform: none;
    }
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn.primary {
    background: linear-gradient(135deg, #3d7eef 0%, #2563c9 100%);
    border-color: transparent;
    color: #fff;
}

.btn.danger.ghost {
    border-color: rgba(255, 100, 100, 0.35);
    color: #ff9a9a;
    background: rgba(180, 40, 40, 0.15);
}

.btn.link {
    border: none;
    background: none;
    padding: 0.15rem 0.4rem;
    font-weight: 500;
    color: #7eb8ff;
}

.btn.link.danger {
    color: #ff8a8a;
}

.btn:hover:not(:disabled) {
    filter: brightness(1.06);
}

.table-wrap {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.data-table th,
.data-table td {
    padding: 0.65rem 0.85rem;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.data-table thead th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #8a9bb0;
    background: rgba(0, 0, 0, 0.2);
}

.data-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.data-table .table-empty-msg {
    padding: 0.85rem 0.85rem;
    font-size: 0.95rem;
    line-height: 1.45;
}

.data-table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.data-table .actions {
    text-align: right;
    white-space: nowrap;
}

code.box-id {
    font-size: 0.88em;
    padding: 0.15rem 0.4rem;
    border-radius: 6px;
    background: rgba(61, 126, 239, 0.15);
    color: #b8d4ff;
}

.banner {
    padding: 0.65rem 0.9rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.banner-error {
    background: rgba(200, 60, 60, 0.2);
    border: 1px solid rgba(255, 120, 120, 0.25);
    color: #ffc8c8;
}

.banner-ok {
    background: rgba(40, 140, 80, 0.2);
    border: 1px solid rgba(100, 200, 140, 0.25);
    color: #b8f0d0;
}

.banner-warn {
    background: rgba(200, 150, 40, 0.15);
    border: 1px solid rgba(255, 200, 100, 0.25);
    color: #ffe4b0;
}

.qrcode-hint {
    margin: 0.85rem 0 0;
    line-height: 1.45;
}

.qrcode-hint strong {
    color: #c5d4e8;
    font-weight: 600;
}

.qr-new-box-hint {
    margin-top: 0.5rem;
}

.qr-new-box-scan-row {
    margin-top: 0.35rem;
}

.qrcode-row {
    margin-top: 0.5rem;
}

.qr-reader-wrap {
    width: 100%;
    max-width: 420px;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: #0a0e12;
}

.qr-reader-wrap .qr-scan-video {
    display: block;
    width: 100%;
    height: auto;
    min-height: 220px;
    vertical-align: middle;
}

.scan-panel {
    max-width: none;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius);
    padding: 1rem;
}

@media (min-width: 641px) {
    .scan-panel {
        max-width: 640px;
        padding: 1.25rem;
    }
}

.scan-row {
    display: flex;
    gap: 0.65rem;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 0.35rem;
}

.scan-row .input-grow {
    flex: 1 1 200px;
}

.inline-form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    align-items: center;
    margin-top: 1rem;
}

.inline-form .input-grow {
    flex: 1 1 180px;
}

.group-picker-select {
    font-variant-numeric: tabular-nums;
}

.data-table--groups .col-group-code {
    width: 1%;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.data-table--groups .col-group-role {
    width: 1%;
    white-space: nowrap;
}

.speech-inventory-block {
    margin-bottom: 1.25rem;
}

.speech-textarea {
    min-height: 6rem;
    resize: vertical;
}

.speech-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    align-items: center;
    margin-top: 0.65rem;
}

.box-contents-intro strong {
    font-weight: 600;
}

.no-capitalize {
    text-transform: none;
}

.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.photo-card {
    margin: 0;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.photo-card img {
    display: block;
    width: 100%;
    height: 140px;
    object-fit: cover;
}

.photo-card figcaption {
    padding: 0.5rem 0.65rem;
}

.photo-camera-panel {
    margin-top: 1rem;
}

.photo-camera-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    align-items: center;
}

.photo-camera-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    align-items: center;
    margin-top: 0.75rem;
}

.photo-camera-wrap {
    margin-top: 0.35rem;
}

.upload-row {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.file-input {
    font-size: 0.9rem;
    color: #a8b8cc;
}

#blazor-error-ui {
    background: #3a1414;
    color: #fff;
    padding: 0.5rem 1rem;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    display: none;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    float: right;
}

/* ——— Mobile-first: scan ——— */
.scan-row--stack {
    flex-direction: column;
    align-items: stretch;
}

@media (min-width: 641px) {
    .scan-row--stack {
        flex-direction: row;
        align-items: center;
    }
}

.scan-row--stack .input-grow {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
}

.btn-block-sm {
    width: 100%;
}

@media (min-width: 641px) {
    .btn-block-sm {
        width: auto;
    }
}

/* ——— Responsive tables → stacked cards (narrow viewports) ——— */
.table-wrap--mobile-cards {
    margin: 0 -0.25rem;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 640px) {
    .data-table--responsive thead {
        display: none;
    }

    .data-table--responsive tbody tr {
        display: block;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: var(--radius);
        margin-bottom: 0.75rem;
        padding: 0.25rem 0;
        background: rgba(0, 0, 0, 0.22);
        overflow: hidden;
    }

    .data-table--responsive tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 0.75rem;
        padding: 0.6rem 1rem;
        border: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.06);
        text-align: right;
        font-size: 0.95rem;
    }

    .data-table--responsive tbody td:last-child {
        border-bottom: none;
    }

    .data-table--responsive tbody td::before {
        content: attr(data-label);
        font-size: 0.68rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: #8a9bb0;
        text-align: left;
        flex-shrink: 0;
        max-width: 38%;
    }

    .data-table--responsive .num {
        font-variant-numeric: tabular-nums;
    }

    .data-table--items .actions {
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    .data-table--items .actions::before {
        align-self: flex-start;
        padding-top: 0.2rem;
    }

    .data-table--items .actions .btn {
        min-height: 40px;
        padding: 0.4rem 0.65rem;
    }
}

.table-open-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0.35rem 0.85rem;
    border-radius: 8px;
    background: rgba(61, 126, 239, 0.2);
    color: #b8d4ff !important;
    font-weight: 600;
    text-decoration: none;
}

.table-open-link:active {
    background: rgba(61, 126, 239, 0.35);
}

/* ——— Inline add row: stack on phone ——— */
@media (max-width: 640px) {
    .inline-form {
        flex-direction: column;
        align-items: stretch;
    }

    .inline-form .input-grow,
    .inline-form .input-narrow {
        width: 100%;
        max-width: none;
    }

    .inline-form .btn {
        width: 100%;
    }

    .speech-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .speech-actions .btn {
        width: 100%;
    }

    .btn-row {
        flex-direction: column;
    }

    .btn-row .btn {
        width: 100%;
    }
}

@media (max-width: 640px) {
    .empty-state {
        padding: 1.5rem 1rem;
    }

    .empty-state .btn.primary {
        margin-top: 0.5rem;
        width: 100%;
        max-width: 280px;
    }
}

@media (max-width: 480px) {
    .photo-grid {
        grid-template-columns: 1fr;
    }
}

/* ——— QR print labels (4 per row) ——— */
.qr-print-controls {
    margin-top: 0;
    align-items: flex-end;
}

.qr-print-qty-row {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: flex-end;
    gap: 0.65rem 1rem;
    flex: 1 1 auto;
    min-width: 0;
}

.qr-print-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1 1 0;
    min-width: 0;
}

.qr-print-field .field-label {
    margin-bottom: 0;
}

.qr-print-field .qr-print-select {
    width: 100%;
    min-width: 0;
}

@media (max-width: 640px) {
    .qr-print-qty-row {
        gap: 0.5rem;
    }

    .qr-print-field .field-label {
        white-space: nowrap;
    }

    .qr-print-field .qr-print-select {
        min-height: max(var(--touch-min, 44px), 3rem);
        padding: 0.65rem 0.85rem;
        font-size: 1.125rem;
        box-sizing: border-box;
    }
}

.qr-print-summary {
    margin: 0.75rem 0 0;
}

.qr-print-select {
    min-width: 5rem;
    min-height: var(--input-height);
    padding: 0.45rem 0.65rem;
    border-radius: var(--radius);
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(0, 0, 0, 0.25);
    color: #e8eef5;
    font-size: 1rem;
}

.qr-print-root {
    margin-top: 1rem;
}

.qr-print-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-flow: row;
    gap: 0.75rem;
    width: 100%;
}

.qr-print-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius);
    background: rgba(0, 0, 0, 0.2);
}

.qr-print-img {
    display: block;
    width: 100%;
    max-width: 200px;
    height: auto;
    margin: 0;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

@media (max-width: 900px) {
    .qr-print-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }
}

@media print {
    @page {
        margin: 0.35in;
    }

    html {
        background: #fff !important;
        color-scheme: light !important;
    }

    .print-hide,
    .app-header {
        display: none !important;
    }

    /* Shell / main: drop dark theme flex + full viewport height (avoids blank 2nd page on mobile). */
    .app-shell {
        display: block !important;
        min-height: 0 !important;
        height: auto !important;
        background: #fff !important;
        color: #111 !important;
    }

    .app-main {
        flex: none !important;
        min-height: 0 !important;
        padding: 0.15in !important;
        padding-bottom: 0 !important;
        max-width: none !important;
        margin: 0 !important;
        background: #fff !important;
    }

    body {
        background: #fff !important;
        color: #111 !important;
        margin: 0 !important;
        padding: 0 !important;
        -webkit-print-color-adjust: economy;
        print-color-adjust: economy;
    }

    .qr-print-root {
        margin: 0 !important;
        padding: 0 !important;
        background: #fff !important;
    }

    .qr-print-grid {
        gap: 0.12in;
        margin: 0 !important;
        padding: 0 !important;
    }

    .qr-print-cell {
        background: #fff !important;
        border-color: #ccc !important;
        break-inside: avoid;
        page-break-inside: avoid;
        padding: 0.08in !important;
    }

    .qr-print-img {
        max-width: 1.5in;
        height: auto !important;
    }
}

/* ——— Box list grouping & name emphasis ——— */
.page-head-title-emphasis {
    font-size: clamp(1.5rem, 4vw, 2rem);
    font-weight: 700;
    letter-spacing: -0.04em;
}

.box-group-title {
    margin: 1.25rem 0 0.5rem;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #8a9bb0;
}

.box-group-title:first-of-type {
    margin-top: 0;
}

.box-group-table {
    margin-bottom: 0.5rem;
}

.data-table .box-name-cell {
    font-size: 1.2rem;
    font-weight: 600;
    line-height: 1.35;
    color: #e8eef5;
}

.box-editor-cat-hint {
    margin-top: 0.35rem;
}