.hidden {
    display: none !important;
}

:root {
    font-family: Arial, sans-serif;
    color: #172033;
    background: #f4f6f9;
}
* { box-sizing: border-box; }
body { margin: 0; }
body.mobile-only,
body.interface-tsd {
    touch-action: manipulation;
    overscroll-behavior: none;
}
@media (hover: none) and (pointer: coarse) {
    body { touch-action: manipulation; }
}
@media (hover: hover) and (pointer: fine) {
    body:not(.mobile-only) { min-width: 1180px; }
}
body > header {
    background: #172033;
    color: white;
    padding: 16px 24px;
    display: flex;
    gap: 24px;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}
.brand { font-size: 20px; font-weight: 700; }
nav { display: flex; gap: 14px; flex-wrap: wrap; }
nav a { color: white; text-decoration: none; }
main { max-width: 1280px; margin: 0 auto; padding: 24px; }
footer { text-align: center; padding: 24px; color: #657087; }
footer a, footer a:visited { color: var(--primary, #168fe5); font-weight: 700; text-decoration: none; }
footer a:hover { text-decoration: underline; }
.footer-separator { margin: 0 8px; opacity: .55; }
h1 { margin-top: 0; }
.panel {
    background: white;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 12px rgba(23, 32, 51, .08);
}
.narrow { max-width: 720px; }
.stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}
.stat {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 12px rgba(23, 32, 51, .08);
}
.stat strong { display: block; font-size: 32px; }
.stat span { color: #657087; }
.actions { display: flex; gap: 12px; margin-bottom: 24px; flex-wrap: wrap; }
.button {
    display: inline-block;
    background: #2458d3;
    color: white;
    border: 0;
    border-radius: 8px;
    padding: 11px 16px;
    text-decoration: none;
    cursor: pointer;
    font-size: 15px;
}
.button.secondary { background: #526078; }
.grid-form {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}
.stack-form { display: grid; gap: 14px; }
label { display: grid; gap: 6px; font-weight: 600; }
input, select, textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #c9d0db;
    border-radius: 7px;
    font: inherit;
    background: white;
}
textarea { min-height: 80px; resize: vertical; }
.wide { grid-column: 1 / -1; }
.search { display: flex; gap: 10px; margin-bottom: 16px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px; border-bottom: 1px solid #e2e6ed; text-align: left; vertical-align: top; }
table thead th { background: #f7f8fb; text-align: center !important; vertical-align: middle; }
table tbody td { text-align: center; vertical-align: middle; }
table .table-actions { justify-content: center; }
.badge {
    display: inline-block;
    background: #e8eefc;
    padding: 5px 9px;
    border-radius: 999px;
    white-space: nowrap;
}
.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; }
.flash.success { background: #dff5e8; }
.flash.error { background: #ffe2e2; }
.detail-grid { display: grid; grid-template-columns: minmax(280px, 420px) 1fr; gap: 20px; }
dl { display: grid; grid-template-columns: 150px 1fr; gap: 9px 12px; }
dt { font-weight: 700; }
dd { margin: 0; }

@media (max-width: 800px) {
    .stats, .grid-form, .detail-grid { grid-template-columns: 1fr; }
    main { padding: 14px; }
    body > header { padding: 14px; }
    .search { flex-direction: column; }
    dl { grid-template-columns: 1fr; }
}


.button.danger {
    background: #b42318;
}

.delete-form {
    margin-top: 12px;
}
.archive-reason-form { display: flex; align-items: end; gap: 12px; flex-wrap: wrap; }
.archive-reason-form label { min-width: 260px; }
.movement-undone { opacity: .62; text-decoration-color: var(--muted); }


.form-actions,
.table-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.table-actions form {
    margin: 0;
}

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

.danger-text {
    color: #b42318;
}


.stage-badge {
    white-space: nowrap;
}

.vip-contact-form {
    display: grid;
    grid-template-columns: minmax(240px, 520px) max-content;
    align-items: end;
    gap: 12px;
    margin: 18px 0;
}
.vip-contact-form label { min-width: 0; }
.vip-contact-form .button { margin: 0; white-space: nowrap; }
@media (max-width: 650px) {
    .vip-contact-form { grid-template-columns: 1fr; }
    .vip-contact-form .button { width: 100%; }
}


/* Structured sample interface */
.page-header{display:flex;justify-content:space-between;align-items:flex-start;gap:20px;margin-bottom:20px;flex-wrap:wrap}.page-header h1{margin-bottom:4px}.page-subtitle{margin:0;color:#657087}.registration-disclosure>summary{cursor:pointer;font-size:18px;font-weight:700;list-style:none}.registration-disclosure>summary::-webkit-details-marker{display:none}.registration-disclosure>summary::before{content:"+";display:inline-grid;place-items:center;width:26px;height:26px;margin-right:10px;border-radius:50%;background:#e8eefc;color:#2458d3}.registration-disclosure[open]>summary::before{content:"−"}.structured-form{display:grid;gap:22px;margin-top:20px}.form-section,.record-section{border-top:1px solid #e2e6ed;padding-top:18px}.form-section:first-child,.record-section:first-child{border-top:0;padding-top:0}.form-section h3,.record-section h2{margin:0 0 14px;font-size:17px}.form-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:14px}.field-wide,.record-item-wide{grid-column:span 2}.transfer-list{display:grid;gap:10px}.transfer-row{display:grid;grid-template-columns:130px minmax(220px,1fr) 190px;align-items:end;gap:14px;padding:14px;border:1px solid #e2e6ed;border-radius:10px;background:#fafbfc}.transfer-title{align-self:center;font-weight:700;color:#26344f}.form-actions-separated{padding-top:18px;border-top:1px solid #e2e6ed}.detail-layout{display:grid;grid-template-columns:minmax(0,1fr);gap:20px}.record-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px}.record-item{padding:13px 14px;border:1px solid #e2e6ed;border-radius:9px;background:#fafbfc}.record-item span,.status-strip span{display:block;margin-bottom:5px;color:#657087;font-size:13px}.transfer-view{border:1px solid #e2e6ed;border-radius:10px;overflow:hidden}.transfer-view-row{display:grid;grid-template-columns:120px minmax(180px,1fr) 130px;gap:14px;padding:13px 15px;border-bottom:1px solid #e2e6ed;align-items:center}.transfer-view-row:last-child{border-bottom:0}.transfer-view-row>span{font-weight:700}.transfer-view-row time{color:#657087;text-align:right}.status-strip{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px}.status-strip>div{padding:13px 14px;border-radius:9px;background:#f4f6f9}.comment-box{padding:15px;border:1px solid #e2e6ed;border-radius:9px;background:#fafbfc;white-space:pre-wrap;min-height:56px}@media(max-width:900px){.form-grid,.record-grid,.status-strip{grid-template-columns:1fr 1fr}.transfer-row{grid-template-columns:100px 1fr 170px}}@media(max-width:650px){.form-grid,.record-grid,.status-strip,.transfer-row,.transfer-view-row{grid-template-columns:1fr}.field-wide,.record-item-wide{grid-column:auto}.transfer-view-row time{text-align:left}}


/* Three-stage storage lists */
.storage-stage-lists {
    display: grid;
    gap: 20px;
}

.storage-stage-panel {
    padding: 0;
    overflow: hidden;
}

.storage-stage-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 20px 22px;
    border-bottom: 1px solid #e2e6ed;
    background: #f7f9fc;
}

.storage-stage-header h2,
.storage-stage-header p {
    margin: 0;
}

.storage-stage-header p {
    margin-top: 3px;
    color: #657087;
    font-size: 13px;
}

.stage-total {
    padding: 7px 11px;
    border-radius: 999px;
    background: #e8eefc;
    color: #2458d3;
    font-weight: 700;
    white-space: nowrap;
}

.shelf-list {
    display: grid;
}

.shelf-card {
    border-bottom: 1px solid #e2e6ed;
}

.shelf-card:last-child {
    border-bottom: 0;
}

.shelf-main {
    display: grid;
    grid-template-columns: 44px minmax(190px, 1fr) 110px;
    gap: 14px;
    align-items: center;
    padding: 17px 22px;
    color: inherit;
    text-decoration: none;
}

.shelf-main:hover {
    background: #f8faff;
}

.shelf-icon {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 9px;
    background: #edf2ff;
    color: #2458d3;
    font-size: 20px;
}

.shelf-name,
.shelf-count {
    display: grid;
    gap: 3px;
}

.shelf-name span,
.shelf-count span,
.shelf-capacity {
    color: #657087;
    font-size: 13px;
}

.shelf-count strong {
    font-size: 20px;
}

.shelf-actions {
    display: flex;
    gap: 14px;
    align-items: center;
    justify-content: flex-end;
    padding: 0 22px 14px;
}

.shelf-actions form {
    margin: 0;
}

.shelf-inactive {
    opacity: .62;
}

.empty-stage {
    padding: 24px 22px;
    color: #657087;
}

.back-link {
    display: inline-block;
    margin-bottom: 10px;
}

.location-note {
    margin-top: 16px;
}

@media (max-width: 760px) {
    .shelf-main {
        grid-template-columns: 40px 1fr auto;
    }

    .shelf-capacity {
        grid-column: 2 / -1;
    }
}

@media (max-width: 520px) {
    .shelf-main {
        grid-template-columns: 36px 1fr;
    }

    .shelf-count,
    .shelf-capacity {
        grid-column: 2;
    }

    .shelf-actions {
        justify-content: flex-start;
        flex-wrap: wrap;
        padding-left: 76px;
    }
}

.field-hint { margin: 7px 0 0; color: #657087; font-size: 13px; }


.readonly-state {
    display: grid;
    gap: 6px;
    padding: 14px 16px;
    border: 1px solid #dfe5ee;
    border-radius: 10px;
    background: #f7f9fc;
}
.readonly-state span {
    color: #657087;
    font-size: 13px;
}
.employee-form {
    margin-top: 18px;
}
.table-actions form {
    display: inline;
    margin: 0;
}


.account-menu {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
    font-size: 13px;
}
.account-menu > div {
    display: grid;
    line-height: 1.2;
}
.account-menu span {
    color: #cbd3e3;
    font-size: 12px;
}
.account-dropdown { position: relative; }
.account-dropdown > summary {
    position: relative;
    display: grid;
    min-width: 145px;
    padding: 2px 24px 2px 2px;
    line-height: 1.2;
    list-style: none;
    cursor: pointer;
}
.account-dropdown > summary::-webkit-details-marker { display: none; }
.account-dropdown > summary::after {
    content: "▾";
    position: absolute;
    top: 50%;
    right: 5px;
    color: #9fb1c5;
    transform: translateY(-50%);
}
.account-dropdown[open] > summary::after { content: "▴"; }
.account-dropdown > summary span { color: #cbd3e3; font-size: 12px; }
.account-dropdown-menu {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    z-index: 150;
    width: 250px;
    padding: 10px;
    border: 1px solid #d8e2ec;
    border-radius: 12px;
    background: #fff;
    color: #172033;
    box-shadow: 0 14px 36px rgba(3, 13, 34, .22);
}
.account-dropdown-menu .account-dropdown-title { display: block; padding: 5px 8px 8px; color: #64748b; font-size: 12px; font-weight: 700; }
.role-test-form { display: grid; gap: 4px; margin: 0; }
.role-option {
    display: flex;
    justify-content: space-between;
    width: 100%;
    padding: 9px 10px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.role-option:hover { background: #edf6fd; }
.role-option.active { color: #0872bd; background: #e8f5ff; font-weight: 700; }
.account-dropdown-menu .role-option span { color: inherit; font-size: inherit; }
html[data-theme="dark"] .account-dropdown-menu { border-color: #34475d; background: #111d2b; color: #e7edf6; }
html[data-theme="dark"] .account-dropdown-menu .account-dropdown-title { color: #9baabd; }
html[data-theme="dark"] .role-option:hover { background: #172d43; }
html[data-theme="dark"] .role-option.active { color: #82cef9; background: #153550; }
.account-menu a,
.account-menu .link-button {
    color: inherit;
}
.auth-main {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}
.auth-card {
    width: min(420px, 100%);
    padding: 32px;
    border: 1px solid #dfe5ee;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 16px 50px rgba(24, 39, 75, 0.12);
}
.auth-card h1 {
    margin: 8px 0;
}
.auth-card > p {
    color: #657087;
    margin-bottom: 24px;
}
.auth-logo {
    display: inline-grid;
    place-items: center;
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: #2458d3;
    color: #fff;
    font-weight: 800;
}
.permissions-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}
.permissions-grid article {
    padding: 16px;
    border: 1px solid #dfe5ee;
    border-radius: 10px;
    background: #f8fafc;
}
.permissions-grid h3 {
    margin-top: 0;
}
.permissions-grid p {
    margin-bottom: 0;
    color: #657087;
}
@media (max-width: 900px) {
    body > header {
        flex-wrap: wrap;
    }
    .account-menu {
        width: 100%;
        margin-left: 0;
    }
    .permissions-grid {
        grid-template-columns: 1fr;
    }
}


.brand-with-logo {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: inherit;
    text-decoration: none;
    white-space: nowrap;
}
.touch-nav-toggle { display: none !important; }

.company-logo {
    display: block;
    object-fit: contain;
    border-radius: 50%;
    background: #fff;
}

.company-logo-header {
    width: 44px;
    height: 34px;
    padding: 2px;
    flex: 0 0 auto;
}

.company-logo-login {
    width: 100px;
    height: 100px;
    margin: 0 auto;
    padding: 7px;
    border: 1px solid #dbe5ef;
    border-radius: 16px;
}

.company-logo-fallback {
    display: none;
}

.brand-with-logo .company-logo-fallback {
    width: 44px;
    height: 34px;
    place-items: center;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.14);
    font-size: 13px;
    font-weight: 800;
}

.brand-title {
    color: #f5f9ff;
    font-weight: 700;
}
.brand-csm {
    color: #38a9f5;
    font-family: "Bahnschrift Condensed", "Arial Narrow", "Segoe UI", sans-serif;
    font-size: calc(1em + 2px);
    font-weight: 700;
    letter-spacing: .025em;
    text-shadow: 0 0 12px rgba(56, 169, 245, .24);
}
.brand-divider {
    margin: 0 3px;
    color: #7bc8fa;
}

.auth-company-logo {
    min-height: 90px;
    display: grid;
    place-items: center;
    margin-bottom: 12px;
}

.auth-company-logo .company-logo-fallback {
    margin: 0 auto;
}

@media (max-width: 700px) {
    .company-logo-header {
        width: 38px;
        height: 30px;
    }

    .brand-with-logo {
        gap: 8px;
    }
}


.audit-filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    align-items: end;
}

.filter-actions {
    display: flex;
    gap: 8px;
    align-items: end;
    flex-wrap: wrap;
    min-width: 0;
}

.audit-filters .filter-actions .button {
    flex: 1 1 100px;
    box-sizing: border-box;
    text-align: center;
}

.audit-value {
    max-width: 260px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.nowrap {
    white-space: nowrap;
}

.small {
    font-size: 0.85em;
}

.pagination,
.bulk-toolbar,
.sample-filters {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin: 14px 0;
}

.pagination span { margin-right: auto; color: #657087; }
.sample-filters input { flex: 2 1 240px; }
.sample-filters select { flex: 1 1 170px; }
.auto-filter-status { flex: 1 1 100%; color: var(--muted); font-size: .82rem; }
.sample-filter-heading { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.sample-filter-heading > div { display: flex; align-items: baseline; gap: 10px; }
.sample-filter-heading strong { font-size: 1.05rem; }
.sample-filter-heading span { color: var(--muted); font-size: .86rem; }
.sample-search-field { position: relative; display: flex; flex: 2 1 280px; align-items: center; min-width: 220px; }
.sample-search-field > span { position: absolute; left: 12px; z-index: 1; color: var(--muted); font-size: 22px; line-height: 1; pointer-events: none; }
.sample-search-field input { width: 100%; padding-left: 38px; }
.active-filter-chips { display: flex; gap: 7px; flex-wrap: wrap; margin: -2px 0 14px; }
.active-filter-chips a, .active-filter-chips a:visited { display: inline-flex; gap: 7px; align-items: center; padding: 6px 9px; border-radius: 999px; color: var(--primary-dark); background: var(--primary-soft); font-size: .84rem; font-weight: 700; text-decoration: none; }
.active-filter-chips a:hover { color: #fff; background: var(--primary); }
.active-filter-chips span { font-size: 1rem; line-height: 1; }
.samples-table tbody tr:nth-child(even) { background: rgba(22, 143, 229, .025); }
.samples-table { width: 100%; table-layout: auto; font-size: 13px; }
.samples-table th, .samples-table td { padding-right: 7px; padding-left: 7px; overflow-wrap: normal; word-break: normal; }
.samples-table th { white-space: nowrap; }
.sample-number-value { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
@media (hover: hover) and (pointer: fine) {
    .samples-panel {
        position: relative;
        left: 50%;
        width: min(1500px, calc(100vw - 32px));
        min-width: 1148px;
        transform: translateX(-50%);
    }
}
.samples-table tbody tr:hover { background: var(--primary-soft); }
.sample-row-new td:first-child { box-shadow: inset 3px 0 0 var(--primary); }
.new-sample-mark { display: inline-block; margin-left: 7px; padding: 2px 6px; border-radius: 999px; color: #fff; background: var(--primary); font-size: .66rem; font-weight: 800; vertical-align: middle; }
.sample-status.status-stored { color: #146c43; background: #e3f5eb; }
.sample-status.status-issued { color: #865400; background: #fff1cc; }
.sample-status.status-complete { color: #4b5563; background: #e8edf2; }
.sample-status.status-waiting { color: #075f9f; background: #e8f5ff; }
.samples-table th:nth-child(9),
.samples-table .sample-status-cell { text-align: center; }
.page-header-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.sample-number-cell, .sample-number-cell a { white-space: nowrap; }
.sample-number-cell { min-width: 112px; }
.sample-mark-cell { width: 76px; white-space: nowrap; }
.sample-mark-cell .new-sample-mark { margin-left: 0; }
.accounts-table .account-name-cell { min-width: 190px; text-align: center; white-space: nowrap; }
.accounts-table .account-mark-cell { width: 72px; white-space: nowrap; }
.accounts-table .table-actions {
    display: grid;
    grid-template-columns: 110px 72px;
    justify-content: center;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
}
.accounts-table .table-actions > a,
.accounts-table .table-actions > form {
    width: 100%;
    text-align: center;
}
.accounts-table .table-actions > a {
    justify-content: center;
}
.accounts-table .table-actions .link-button { text-align: center; }
.archive-link { border-color: #b8c8d6 !important; background: transparent !important; color: var(--muted) !important; box-shadow: none !important; }
.archive-link::before { content: "▣"; margin-right: 7px; }
.archive-link:hover { border-color: var(--primary) !important; color: var(--primary-dark) !important; background: var(--primary-soft) !important; }
.bulk-toolbar select, .bulk-toolbar input { width: auto; min-width: 170px; flex: 1 1 170px; }
.inline-check { display: flex; grid-auto-flow: column; align-items: center; white-space: nowrap; }
.inline-check input { width: auto; }
.capacity-bar, .chart-bar {
    height: 7px;
    margin-top: 6px;
    overflow: hidden;
    border-radius: 999px;
    background: #e2e6ed;
}
.capacity-bar i, .chart-bar i {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: #2458d3;
}
.stage-chart { display: grid; gap: 12px; }
.stage-chart > div { display: grid; grid-template-columns: minmax(140px, 1fr) 60px 3fr; gap: 12px; align-items: center; }
.stage-chart strong { text-align: right; }
.alert-panel { border-left: 5px solid #e3a008; }
.backup-list { display: grid; gap: 8px; margin-top: 12px; }
.saved-filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 10px 0; }
.saved-filters > a { padding: 7px 10px; border-radius: 999px; background: #e8eefc; text-decoration: none; }
.saved-filters form, .import-box form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.saved-filters input { width: auto; }
.import-box { margin: 12px 0; }
.import-box summary { cursor: pointer; font-weight: 600; margin-bottom: 8px; }


.scan-shell {
    max-width: 760px;
    margin: 0 auto;
    display: grid;
    gap: 16px;
}

.scan-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.scan-header h1,
.scan-header p {
    margin: 0;
}

.scan-card,
.scan-success {
    background: var(--panel, #fff);
    border: 1px solid var(--border, #d9dee7);
    border-radius: 18px;
    padding: 18px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
}

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

.operation-button {
    min-height: 108px;
    border: 1px solid var(--border, #d9dee7);
    border-radius: 16px;
    background: var(--panel, #fff);
    font-size: 2rem;
    cursor: pointer;
}

.operation-button span {
    display: block;
    margin-top: 8px;
    font-size: 1rem;
    font-weight: 700;
}

.step-heading {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
}

.step-label {
    font-weight: 700;
    opacity: 0.72;
}

.scan-status {
    font-size: 0.85rem;
    white-space: nowrap;
}

.camera-frame {
    position: relative;
    overflow: hidden;
    background: #111;
    border-radius: 16px;
    aspect-ratio: 4 / 3;
    margin: 14px 0;
}

.camera-frame video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.camera-guide {
    position: absolute;
    inset: 18%;
    border: 3px solid rgba(255, 255, 255, 0.9);
    border-radius: 14px;
    box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.28);
}

.camera-actions,
.manual-row,
.filter-actions {
    display: flex;
    gap: 10px;
}

.manual-entry {
    margin-top: 18px;
}

.manual-row input {
    flex: 1;
}

.scan-result-row {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border, #d9dee7);
}

.scan-confirm {
    width: 100%;
    min-height: 54px;
    margin-top: 16px;
    font-size: 1.05rem;
}

.scan-message {
    margin-top: 12px;
    padding: 12px;
    border-radius: 10px;
}

.scan-message.error {
    background: rgba(180, 30, 30, 0.1);
    border: 1px solid rgba(180, 30, 30, 0.25);
}

.scan-success {
    text-align: center;
    padding: 34px 18px;
}

.success-icon {
    width: 84px;
    height: 84px;
    border-radius: 50%;
    margin: 0 auto 16px;
    display: grid;
    place-items: center;
    font-size: 3rem;
    background: rgba(40, 160, 90, 0.14);
}

.compact {
    padding: 8px 12px;
}

@media (max-width: 640px) {
    .scan-shell {
        margin: -8px;
    }

    .scan-card,
    .scan-success {
        border-radius: 14px;
        padding: 14px;
    }

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

    .operation-button {
        min-height: 96px;
    }

    .manual-row {
        flex-direction: column;
    }

    .scan-result-row {
        grid-template-columns: 1fr;
        gap: 4px;
    }
}

.file-scan-button {
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

.file-scan-button input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}


/* Dedicated mobile scanner mode */
body.mobile-only {
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    overscroll-behavior: none;
    touch-action: manipulation;
    -webkit-text-size-adjust: 100%;
}
.mobile-app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 58px;
    padding: max(10px, env(safe-area-inset-top)) 14px 10px;
    background: #172033;
    color: #fff;
}
.mobile-app-brand { display: grid; gap: 2px; min-width: 0; }
.mobile-app-brand strong { font-size: 18px; }
.mobile-app-brand span {
    overflow: hidden;
    color: #c9d2e3;
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.mobile-app-header form { margin: 0; }
.mobile-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}
.mobile-install { border: 1px solid rgba(255,255,255,.28); border-radius: 8px; padding: 7px 9px; color: #fff; background: rgba(255,255,255,.1); font: inherit; font-size: .8rem; cursor: pointer; }
.mobile-logout {
    border: 1px solid rgba(255,255,255,.45);
    border-radius: 8px;
    padding: 8px 11px;
    background: transparent;
    color: #fff;
    font: inherit;
}
.mobile-main {
    width: 100%;
    max-width: none;
    min-height: calc(100dvh - 58px);
    margin: 0;
    padding: 12px 12px calc(18px + env(safe-area-inset-bottom));
}
.mobile-only .scan-shell { width: 100%; max-width: none; margin: 0; }
.mobile-only .scan-header { margin-bottom: 12px; align-items: center; }
.mobile-only .scan-header h1 { margin: 0; font-size: 22px; }
.mobile-only .scan-card { margin-bottom: 12px; padding: 15px; border-radius: 12px; }
.mobile-only .operation-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.mobile-only .operation-button { min-height: 112px; padding: 14px 8px; font-size: 30px; }
.mobile-only .operation-button span { font-size: 16px; }
.mobile-only,
.mobile-only main,
.mobile-only .scan-shell,
.mobile-only .scan-card,
.mobile-only #scannerCard,
.mobile-only .step-heading {
    min-width: 0;
    max-width: 100%;
}
.mobile-only #scannerCard {
    overflow: hidden;
}
.mobile-only .camera-frame {
    width: min(100%, 390px);
    height: auto;
    aspect-ratio: 3 / 4;
    margin: 14px auto;
    max-width: 100%;
    min-width: 0;
    contain: strict;
    touch-action: pan-y;
    overscroll-behavior: contain;
    -webkit-user-select: none;
    user-select: none;
}
.mobile-only .camera-frame video {
    position: absolute !important;
    inset: 0 !important;
    display: block;
    width: 100% !important;
    height: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    min-height: 0 !important;
    max-height: 100% !important;
    object-fit: cover;
    object-position: center;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    pointer-events: none;
}
.mobile-only .camera-guide { pointer-events: none; }
.mobile-only input,
.mobile-only select,
.mobile-only textarea,
.mobile-only button { font-size: 16px; }
.mobile-only .camera-actions,
.mobile-only .manual-row { display: grid; grid-template-columns: 1fr; width: 100%; }
.mobile-only .camera-actions .button,
.mobile-only .manual-row .button,
.mobile-only .scan-confirm { width: 100%; text-align: center; }
.mobile-only .scan-success { min-height: 55dvh; display: grid; place-content: center; text-align: center; }
@media (max-width: 390px) {
    .mobile-only .operation-button { min-height: 98px; }
    .mobile-only .scan-card { padding: 12px; }
}

/* Prevent camera metadata from widening the mobile document */
.mobile-only html,
body.mobile-only {
    width: 100%;
    max-width: 100vw;
    overflow-x: clip;
}
.mobile-only .step-heading > * { min-width: 0; }
.mobile-only .step-heading h2 { overflow-wrap: anywhere; }
.mobile-only .step-heading .scan-status {
    flex: 0 0 100%;
    width: 100%;
    white-space: normal;
    text-align: right;
    line-height: 1.25;
}
.mobile-only .step-heading { flex-wrap: wrap; }

.interface-tsd .camera-frame,
.interface-tsd .camera-actions {
    display: none !important;
}
.interface-tsd .scan-header h1 {
    font-size: 21px;
}
.interface-tsd .operation-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}
.interface-tsd .tsd-entry {
    margin-top: 14px;
    padding: 16px;
    border: 2px solid #50627f;
    border-radius: 12px;
    background: #f7f9fc;
}
.interface-tsd .tsd-entry label {
    font-size: 18px;
    font-weight: 700;
}
.interface-tsd .tsd-entry input {
    min-height: 58px;
    border-width: 2px;
    font-size: 20px;
}
.interface-tsd .tsd-entry input:focus {
    outline: 3px solid rgba(45, 108, 223, .24);
}
.interface-tsd .tsd-entry .button {
    min-height: 54px;
}
.interface-tsd .scan-card,
.interface-tsd .scan-success {
    max-width: 760px;
    margin-right: auto;
    margin-left: auto;
}
.interface-tsd #operationCard {
    width: 100%;
    max-width: none;
}

.recent-operation-list { display: grid; gap: 9px; }
.undo-reason { margin-bottom: 12px; }
.scan-progress { display: flex; align-items: center; gap: 12px; margin: 0 auto 12px; max-width: 760px; color: var(--muted); }
.scan-progress > strong { white-space: nowrap; font-size: .86rem; }
.scan-progress > span { height: 7px; flex: 1; overflow: hidden; border-radius: 99px; background: var(--line); }
.scan-progress i { display: block; width: 33%; height: 100%; border-radius: inherit; background: var(--primary); transition: width .2s ease; }
.recent-operation { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--canvas); }
.recent-operation > div { display: grid; gap: 4px; min-width: 0; }
.recent-operation strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-operation span { color: var(--muted); font-size: .84rem; }
.recent-operation.is-undone { opacity: .62; }
.mobile-only .recent-operations { margin-top: 14px; }
.diagnostic-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.diagnostic-item { display: flex; gap: 10px; align-items: center; padding: 13px; border: 1px solid var(--line); border-radius: 10px; }
.diagnostic-item > span { display: grid; width: 28px; height: 28px; place-items: center; border-radius: 50%; color: #fff; font-weight: 900; }
.diagnostic-item div, .diagnostic-item small { display: grid; gap: 3px; }
.diagnostic-item small { color: var(--muted); }
.diagnostic-ok > span { background: #16845b; }
.diagnostic-error > span { background: var(--danger); }
.reason-form { display: grid; grid-template-columns: 1fr 280px auto; gap: 12px; align-items: end; }
.reason-list { display: grid; gap: 8px; margin-top: 18px; }
.reason-list > div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; }
.reason-list span, .reason-list small { display: grid; gap: 3px; }
.reason-list small { color: var(--muted); }
.audit-periods { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.audit-periods .active { background: var(--primary); color: #fff; }
.audit-row td:first-child { border-left: 3px solid transparent; }
.audit-row[class*="архивирование"] td:first-child, .audit-row[class*="удаление"] td:first-child { border-left-color: var(--danger); }
.audit-row[class*="восстановление"] td:first-child, .audit-row[class*="размещение"] td:first-child { border-left-color: #16845b; }
.audit-row[class*="выдача"] td:first-child, .audit-row[class*="возврат"] td:first-child { border-left-color: var(--primary); }
@media (max-width: 800px) { .diagnostic-grid { grid-template-columns: 1fr; } .reason-form { grid-template-columns: 1fr; } }

.auth-password-note {
    margin: 14px 0 0;
    font-size: 0.82rem;
    line-height: 1.35;
    opacity: 0.68;
    text-align: center;
}
.temporary-password-note {
    align-self: end;
    margin: 0;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--muted);
    background: var(--primary-soft);
    font-size: .86rem;
    line-height: 1.35;
}

.login-remember {
    display: flex;
    align-items: center;
    gap: 10px;
    width: fit-content;
    color: var(--ink, #172033);
    font-size: 0.92rem;
    cursor: pointer;
}
.login-remember input {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: #1595e7;
    cursor: pointer;
}

/* v15: unified desktop visual language */
:root {
    --ink: #172033;
    --muted: #64748b;
    --line: #dce3ec;
    --surface: #ffffff;
    --canvas: #f3f6fa;
    --primary: #168fe5;
    --primary-dark: #0872bd;
    --primary-soft: #e8f5ff;
    --nav: #071a3b;
    --nav-deep: #030d22;
    --danger: #b42318;
    --shadow: 0 8px 24px rgba(18, 37, 56, .07);
}

html { background: var(--canvas); }
body { color: var(--ink); background: var(--canvas); }
a, a:visited { color: var(--primary); }
a:hover { color: var(--primary-dark); }

body:not(.mobile-only) > header {
    position: sticky;
    top: 0;
    z-index: 100;
    min-height: 72px;
    padding: 10px 24px;
    gap: 18px;
    flex-wrap: nowrap;
    background: linear-gradient(110deg, var(--nav-deep) 0%, var(--nav) 68%, #0a2852 100%);
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    box-shadow: 0 8px 28px rgba(13, 29, 44, .18);
    display: grid;
    grid-template-columns: minmax(260px, 1fr) auto minmax(260px, 1fr);
}
body:not(.mobile-only) > header .brand,
body:not(.mobile-only) > header .brand:visited {
    color: #fff;
    letter-spacing: -.02em;
    justify-self: start;
}
body:not(.mobile-only) > header .brand-with-logo { gap: 12px; }
body:not(.mobile-only) > header .company-logo-header {
    width: 52px;
    height: 52px;
    padding: 6px;
    border: 1px solid rgba(255, 255, 255, .86);
    border-radius: 13px;
    background: #fff;
    box-shadow: 0 5px 16px rgba(0, 8, 27, .28);
}
body:not(.mobile-only) > header nav {
    justify-self: center;
    justify-content: center;
    gap: 4px;
}
body:not(.mobile-only) > header nav a,
body:not(.mobile-only) > header nav a:visited {
    position: relative;
    padding: 9px 11px;
    border-radius: 8px;
    color: #cbd8e3;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    transition: color .16s ease, background-color .16s ease, transform .16s ease;
}
body:not(.mobile-only) > header nav a:hover {
    color: #fff;
    background: rgba(255, 255, 255, .09);
    transform: translateY(-1px);
}
body:not(.mobile-only) > header nav a.active {
    color: #fff;
    background: rgba(22, 143, 229, .24);
    box-shadow: inset 0 0 0 1px rgba(78, 175, 243, .26);
}
body:not(.mobile-only) > header nav a.active::after {
    content: "";
    position: absolute;
    right: 11px;
    bottom: 4px;
    left: 11px;
    height: 2px;
    border-radius: 2px;
    background: #38a9f5;
}
body:not(.mobile-only) > header .account-menu {
    flex: 0 0 auto;
    justify-self: end;
    padding: 7px 8px 7px 12px;
    gap: 8px;
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: 12px;
    background: rgba(255, 255, 255, .06);
}
body:not(.mobile-only) > header .account-menu a,
body:not(.mobile-only) > header .account-menu a:visited,
body:not(.mobile-only) > header .account-menu .link-button {
    padding: 6px 8px;
    border-radius: 7px;
    color: #dce7ef;
    text-decoration: none;
}
body:not(.mobile-only) > header .account-menu a:hover,
body:not(.mobile-only) > header .account-menu .link-button:hover {
    color: #fff;
    background: rgba(255, 255, 255, .1);
}

.panel, .stat {
    border: 1px solid rgba(220, 227, 236, .9);
    border-radius: 14px;
    box-shadow: var(--shadow);
}
.stat { position: relative; overflow: hidden; }
.stat::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: var(--primary);
}
.stat strong { color: var(--nav); letter-spacing: -.04em; }

.button, .button:visited {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    border: 1px solid transparent;
    border-radius: 9px;
    background: var(--primary);
    color: #fff;
    font-weight: 650;
    line-height: 1.15;
    box-shadow: 0 3px 8px rgba(23, 107, 135, .16);
    transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.button:hover {
    color: #fff;
    background: var(--primary-dark);
    box-shadow: 0 5px 14px rgba(23, 107, 135, .22);
    transform: translateY(-1px);
}
.button:active { transform: translateY(0); }
.button.secondary, .button.secondary:visited {
    border-color: #cbd5e1;
    background: #fff;
    color: #334155;
    box-shadow: none;
}
.button.secondary:hover { border-color: #94a3b8; background: #f8fafc; color: #172033; }
.button.danger, .button.danger:visited { background: var(--danger); color: #fff; }

.table-actions a, .table-actions a:visited,
.shelf-actions > a, .shelf-actions > a:visited {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 5px 9px;
    border: 1px solid #cbd9e2;
    border-radius: 7px;
    background: #f8fbfc;
    color: var(--primary-dark);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
}
.table-actions a:hover, .shelf-actions > a:hover { background: var(--primary-soft); border-color: #9bc7d2; }
.table-actions .restore-button {
    min-height: 30px;
    padding: 5px 10px;
    border: 1px solid #8cc9a2;
    border-radius: 7px;
    background: #edf9f1;
    color: #176b36;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
}
.table-actions .restore-button:hover { background: #dff3e6; border-color: #62ad7d; }
.table-actions .purge-button {
    min-height: 30px;
    padding: 5px 10px;
    border: 1px solid #d29a96;
    border-radius: 7px;
    background: #fff1f0;
    color: #a12820;
    font-size: 13px;
    font-weight: 700;
}
.table-actions .purge-button:hover { background: #ffe2df; border-color: #bd6e68; }
html[data-theme="dark"] .table-actions .purge-button { border-color: #78423f; background: #3d2224; color: #ffaaa5; }

input, select, textarea { border-color: #cbd5e1; background: #fff; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #168fe5;
    box-shadow: 0 0 0 3px rgba(22, 143, 229, .15);
}
th { color: #475569; background: #f5f8fb; font-size: 13px; letter-spacing: .01em; }
tbody tr:hover { background: #f8fbfc; }
.badge { color: #075f9f; background: var(--primary-soft); font-weight: 600; }
.flash { border: 1px solid transparent; box-shadow: 0 5px 16px rgba(18, 37, 56, .06); }
.flash.success { color: #166534; border-color: #bbdfc5; }
.flash.error { color: #991b1b; border-color: #f3b9b9; }
.saved-filters > a, .saved-filters > a:visited { color: var(--primary-dark); background: var(--primary-soft); }
.registration-disclosure > summary::before { color: var(--primary); background: var(--primary-soft); }
.capacity-bar i, .chart-bar i { background: var(--primary); }
.auth-logo { background: var(--primary); }
.link-button:not(.danger-text) { color: var(--primary-dark); }

@media (max-width: 1500px) {
    body:not(.mobile-only) > header {
        grid-template-columns: minmax(0, 1fr) auto;
    }
    body:not(.mobile-only) > header nav {
        grid-column: 1 / -1;
        grid-row: 2;
        width: 100%;
        justify-content: center;
        overflow-x: auto;
        padding-bottom: 2px;
    }
    body:not(.mobile-only) > header .account-menu {
        margin-left: 0;
        width: auto;
    }
}

@media (max-width: 650px) {
    body:not(.mobile-only) > header { position: static; padding: 10px 14px; }
    body:not(.mobile-only) > header .brand { font-size: 17px; }
    body:not(.mobile-only) > header .account-menu > div { display: none; }
    body:not(.mobile-only) > header nav { justify-content: flex-start; }
    .stage-chart > div { grid-template-columns: 1fr 44px; }
    .stage-chart .chart-bar { grid-column: 1 / -1; }
}

.operations-page {
    width: 100%;
    max-width: 760px;
    margin: 10px auto 40px;
}

.help-heading { align-items: center; }
.help-start h2 { margin-top: 0; }
.help-steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin: 18px 0 0; padding: 0; list-style: none; counter-reset: help-step; }
.help-steps li { position: relative; min-height: 120px; padding: 18px 18px 18px 58px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); counter-increment: help-step; }
.help-steps li::before { content: counter(help-step); position: absolute; top: 17px; left: 17px; display: grid; width: 28px; height: 28px; place-items: center; border-radius: 50%; color: #fff; background: var(--primary); font-weight: 800; }
.help-steps strong, .help-steps span { display: block; }
.help-steps span { margin-top: 7px; color: var(--muted); line-height: 1.5; }
.help-sections { display: grid; gap: 12px; }
.help-item { margin-bottom: 0; padding: 0; overflow: hidden; }
.help-item > summary { position: relative; padding: 18px 54px 18px 20px; cursor: pointer; list-style: none; font-size: 17px; font-weight: 750; }
.help-item > summary::-webkit-details-marker { display: none; }
.help-item > summary::after { content: "+"; position: absolute; top: 50%; right: 20px; color: var(--primary); font-size: 24px; transform: translateY(-50%); }
.help-item[open] > summary::after { content: "−"; }
.help-item[open] > summary { border-bottom: 1px solid var(--line); }
.help-content { padding: 4px 20px 18px; color: var(--ink); line-height: 1.6; }
.help-content p, .help-content ul { margin: 14px 0 0; }
.help-content li + li { margin-top: 7px; }
.help-content kbd { padding: 2px 6px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; background: var(--canvas); font: inherit; font-size: .88em; }
@media (max-width: 1100px) { .help-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 650px) { .help-steps { grid-template-columns: 1fr; } }

/* Responsive layout for the regular site. /mobile and /tsd remain dedicated scanners. */
@media (max-width: 800px) {
    main { width: 100%; padding: 12px; }
    .panel { padding: 14px; margin-bottom: 14px; border-radius: 11px; }
    .page-header { gap: 12px; margin-bottom: 14px; }
    .page-header h1 { font-size: 1.65rem; }
    .page-header-actions { width: 100%; }
    .page-header-actions .button { flex: 1 1 140px; justify-content: center; text-align: center; }
    .sample-filters, .bulk-toolbar { display: grid; grid-template-columns: 1fr; align-items: stretch; }
    .sample-filters input, .sample-filters select,
    .bulk-toolbar input, .bulk-toolbar select { width: 100%; min-width: 0; }
    .sample-filters .button, .bulk-toolbar .button { width: 100%; justify-content: center; }
    .filter-actions { width: 100%; }
    .saved-filters form { width: 100%; }
    .table-wrap { margin-right: -14px; margin-left: -14px; padding: 0 14px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .table-wrap table { min-width: 760px; }
    th, td { padding: 10px 9px; }
    .pagination { align-items: stretch; }
    .pagination span { width: 100%; margin: 0; }
    .pagination .button { flex: 1; justify-content: center; }
    .storage-stage-header { align-items: flex-start; gap: 10px; }
    .stage-total { white-space: nowrap; }
    .button { min-height: 42px; }
    footer { display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; padding: 18px 12px; }
}

@media (max-width: 800px) and (hover: none) and (pointer: coarse) {
    .sample-filter-heading > div { width: 100%; justify-content: space-between; }
    .sample-search-field { min-width: 0; width: 100%; }
    .samples-table-wrap { max-height: none; margin: 0; padding: 0; overflow: visible; }
    .samples-table { display: block; min-width: 0 !important; }
    .samples-table thead { display: none; }
    .samples-table tbody { display: grid; gap: 12px; }
    .samples-table tr { position: relative; display: grid; grid-template-columns: 1fr; padding: 13px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface) !important; box-shadow: var(--shadow); }
    .samples-table td { display: grid; grid-template-columns: minmax(110px, .7fr) minmax(0, 1.3fr); gap: 10px; align-items: center; padding: 7px 0; border: 0; }
    .samples-table td { text-align: left; }
    .samples-table td::before { content: attr(data-label); color: var(--muted); font-size: .78rem; font-weight: 700; }
    .samples-table .sample-select-cell { display: block; position: absolute; top: 13px; right: 13px; z-index: 2; padding: 0; }
    .samples-table .sample-select-cell::before { display: none; }
    .samples-table .sample-row-new .sample-select-cell { box-shadow: none; }
    .samples-table td[data-label="Этап"] { padding-right: 42px; }
    .samples-table .sample-number-cell { padding-right: 34px; font-size: 1.05rem; }
    .samples-table .sample-number-value { justify-content: flex-start; gap: 7px; }
    .samples-table .table-actions { grid-column: 1 / -1; }
    .samples-table td[data-label="Действия"] { grid-template-columns: 1fr; }
    .samples-table td[data-label="Действия"]::before { display: none; }
    .sample-row-new { border-color: rgba(22,143,229,.5) !important; box-shadow: inset 3px 0 0 var(--primary), var(--shadow) !important; }
}

@media (max-width: 420px) {
    .page-header-actions { display: grid; grid-template-columns: 1fr; }
    .storage-stage-header { display: grid; grid-template-columns: 1fr; }
}

@media (max-width: 800px) and (hover: none) and (pointer: coarse) {
    body:not(.mobile-only) > header {
        position: sticky;
        grid-template-columns: minmax(0, 1fr);
        gap: 8px;
        padding: 9px 12px;
    }
    body:not(.mobile-only) > header .brand {
        min-width: 0;
        max-width: calc(100% - 82px);
        font-size: 16px;
    }
    body:not(.mobile-only) > header .brand-title {
        overflow: hidden;
        text-overflow: ellipsis;
    }
    body:not(.mobile-only) > header .touch-nav-toggle {
        position: absolute;
        top: 14px;
        right: 12px;
        z-index: 3;
        display: inline-flex !important;
        min-height: 40px;
        align-items: center;
        justify-content: center;
        padding: 8px 12px;
        border: 1px solid rgba(255,255,255,.24);
        border-radius: 9px;
        color: #fff;
        background: rgba(255,255,255,.1);
        font: inherit;
        font-weight: 700;
    }
    body:not(.mobile-only) > header nav {
        display: none;
        grid-column: 1;
        grid-row: 3;
        width: 100%;
        padding: 6px;
        overflow: visible;
        flex-direction: column;
        align-items: stretch;
        border: 1px solid rgba(255,255,255,.1);
        border-radius: 11px;
        background: rgba(0,0,0,.14);
    }
    body:not(.mobile-only) > header.touch-nav-open nav { display: flex; }
    body:not(.mobile-only) > header nav a { width: 100%; padding: 11px 12px; }
    body:not(.mobile-only) > header .account-menu {
        grid-column: 1;
        grid-row: 2;
        justify-self: stretch;
        justify-content: flex-start;
        width: 100%;
        margin: 0;
        padding: 6px 8px;
        overflow: visible;
        flex-wrap: wrap;
    }
    body:not(.mobile-only) > header .account-dropdown {
        position: static;
        flex: 1 1 100%;
        width: 100%;
    }
    body:not(.mobile-only) > header .account-dropdown > summary { width: 100%; }
    body:not(.mobile-only) > header .account-dropdown-menu {
        position: static;
        width: 100%;
        margin-top: 8px;
        box-shadow: inset 0 0 0 1px rgba(255,255,255,.04);
    }
}
.operations-heading {
    margin-bottom: 18px;
    text-align: center;
}
.operations-heading h1 { margin-bottom: 6px; }
.operations-heading p { margin: 0; color: var(--muted); }
.operations-window {
    padding: 28px;
    border-top: 4px solid var(--primary);
    box-shadow: 0 14px 38px rgba(7, 26, 59, .1);
}
.operations-window .stack-form { gap: 18px; }
.operations-window .button[type="submit"] { margin-top: 4px; }

@media (max-width: 650px) {
    .operations-page { margin-top: 0; }
    .operations-window { padding: 18px; }
}

/* v16: mobile and TSD workflow aligned with the main product */
.mobile-app-header {
    min-height: 66px;
    background: linear-gradient(110deg, var(--nav-deep), var(--nav) 72%, #0a2852);
    border-bottom: 1px solid rgba(255, 255, 255, .1);
    box-shadow: 0 7px 22px rgba(3, 13, 34, .2);
}
.mobile-app-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}
.mobile-app-brand > div { display: grid; gap: 2px; min-width: 0; }
.mobile-app-logo {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    padding: 4px;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 4px 12px rgba(0, 8, 27, .25);
}
.mobile-logout {
    border-color: rgba(255, 255, 255, .25);
    background: rgba(255, 255, 255, .07);
    font-weight: 650;
}
.mobile-only { background: #f2f6fb; }
.mobile-only .scan-header {
    padding: 4px 2px;
    border: 0;
    background: transparent;
    color: var(--ink);
    box-shadow: none;
}
.mobile-only .scan-header h1 { color: var(--nav); letter-spacing: -.025em; }
.mobile-only .scan-card,
.mobile-only .scan-success {
    border: 1px solid #dbe5ef;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 9px 26px rgba(7, 26, 59, .08);
}
.mobile-step-kicker {
    margin-bottom: 4px;
    color: var(--primary-dark);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}
.mobile-only #operationCard h2 { margin: 0 0 14px; color: var(--nav); font-size: 22px; }
.scan-object-summary {
    display: grid;
    gap: 3px;
    margin-bottom: 14px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--primary-soft);
}
.scan-object-summary strong { font-size: 18px; }
.scan-object-summary span { overflow-wrap: anywhere; }
.scan-object-summary small { color: var(--muted); font-weight: 700; }
.scan-object-details {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin: 14px 0;
}
.scan-object-details > div {
    display: grid;
    gap: 4px;
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--primary-soft);
}
.scan-object-details span { color: var(--muted); font-size: 12px; }
.scan-info-link { width: 100%; text-align: center; }
.object-info-button { text-decoration: none; }
.object-info-button .operation-icon {
    background: #eef0ff !important;
    color: #4f5fc7 !important;
}
.scan-notes {
    margin: 0 0 14px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--primary-soft);
}
.scan-notes span { color: var(--muted); font-size: 12px; font-weight: 700; }
.scan-notes p { margin: 5px 0 0; white-space: pre-wrap; }
.unit-selection {
    margin: 14px 0;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
}
.unit-selection legend { padding: 0 5px; font-weight: 800; }
.unit-selection-actions { display: flex; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.unit-checkbox-list { display: grid; gap: 8px; }
.unit-checkbox {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    padding: 10px 11px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--primary-soft);
}
.unit-checkbox input { width: 20px; height: 20px; margin: 0; }
.unit-checkbox span { display: grid; gap: 2px; }
.unit-checkbox small { color: var(--muted); }
.location-samples-title { margin: 18px 0 10px; }
.location-sample-list { display: grid; gap: 9px; margin-bottom: 14px; }
.location-sample-item {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: var(--surface);
}
.location-sample-item summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    cursor: pointer;
    list-style: none;
}
.location-sample-item summary::-webkit-details-marker { display: none; }
.location-sample-item summary::after {
    content: "⌄";
    color: var(--primary);
    font-size: 18px;
}
.location-sample-item[open] summary::after { transform: rotate(180deg); }
.location-sample-item summary > span { display: grid; min-width: 0; gap: 3px; }
.location-sample-item summary strong,
.location-sample-item summary span { overflow-wrap: anywhere; }
.location-sample-item summary small { margin-left: auto; color: var(--muted); white-space: nowrap; }
.location-sample-details {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
    padding: 0 14px 14px;
}
.location-sample-details > div { display: grid; gap: 3px; padding-top: 9px; border-top: 1px solid var(--line); }
.location-sample-details span { color: var(--muted); font-size: 12px; }
.location-sample-details .wide { grid-column: 1 / -1; }
.mobile-only .operation-grid,
.interface-tsd .operation-grid {
    grid-template-columns: 1fr;
    gap: 10px;
}
.mobile-only .operation-button,
.interface-tsd .operation-button {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr);
    grid-template-rows: auto auto;
    column-gap: 13px;
    align-items: center;
    min-height: 86px;
    padding: 13px 15px;
    border: 1px solid #d5e1ec;
    border-radius: 13px;
    background: #fff;
    color: var(--nav);
    text-align: left;
    box-shadow: 0 3px 10px rgba(7, 26, 59, .04);
    transition: border-color .15s, background-color .15s, transform .15s, box-shadow .15s;
}
.mobile-only .operation-button:hover,
.interface-tsd .operation-button:hover {
    border-color: #8ec7ef;
    background: var(--primary-soft);
    box-shadow: 0 7px 18px rgba(22, 143, 229, .12);
    transform: translateY(-1px);
}
.mobile-only .operation-button .operation-icon,
.interface-tsd .operation-button .operation-icon {
    grid-row: 1 / 3;
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    margin: 0;
    border-radius: 12px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 25px;
    font-weight: 800;
}
.mobile-only .operation-button > span:not(.operation-icon),
.interface-tsd .operation-button > span:not(.operation-icon) {
    align-self: end;
    margin: 0;
    font-size: 17px;
    line-height: 1.2;
}
.mobile-only .operation-button small,
.interface-tsd .operation-button small {
    align-self: start;
    margin-top: 3px;
    color: #64748b;
    font-size: 12px;
    line-height: 1.25;
}
.operation-test .operation-icon { background: #e8f5ff !important; color: #0872bd !important; }
.operation-customer .operation-icon { background: #eaf7ef !important; color: #1d7a43 !important; }
.mobile-only .step-label { color: var(--primary-dark); opacity: 1; font-size: 13px; }
.mobile-only .camera-guide { border-color: #fff; box-shadow: 0 0 0 999px rgba(3, 13, 34, .38); }
.mobile-only .scan-confirm { background: var(--primary); box-shadow: 0 5px 14px rgba(22, 143, 229, .22); }
.interface-tsd .tsd-entry {
    border-color: #a8cce5;
    background: #f4f9fd;
}
.interface-tsd .tsd-entry input:focus {
    outline: 3px solid rgba(22, 143, 229, .18);
    border-color: var(--primary);
}

@media (min-width: 700px) {
    .interface-tsd .operation-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .interface-tsd .operation-button {
        grid-template-columns: 1fr;
        grid-template-rows: 52px auto auto;
        min-height: 170px;
        text-align: center;
    }
    .interface-tsd .operation-button .operation-icon { grid-row: auto; margin: 0 auto; }
}
@media (max-width: 420px) {
    .scan-object-details,
    .location-sample-details { grid-template-columns: 1fr; }
    .location-sample-details .wide { grid-column: auto; }
    .location-sample-item summary { align-items: flex-start; flex-wrap: wrap; }
}

/* v17: persistent dark theme */
.theme-toggle {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, .16);
    border-radius: 8px;
    background: rgba(255, 255, 255, .07);
    color: #fff;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}
.theme-toggle:hover { background: rgba(255, 255, 255, .14); }
.theme-toggle svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.auth-theme-toggle {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 10;
    border-color: #cbd8e5;
    background: #fff;
    color: #071a3b;
    box-shadow: 0 5px 16px rgba(7, 26, 59, .12);
}
.auth-theme-toggle:hover { background: #edf6fd; }
html[data-theme="dark"] .auth-theme-toggle {
    border-color: #3a4d63;
    background: #172538;
    color: #fff;
}

html[data-theme="dark"] {
    color-scheme: dark;
    --ink: #e7edf6;
    --muted: #9baabd;
    --line: #2a3a4d;
    --surface: #111d2b;
    --canvas: #091321;
    --primary: #32a8f5;
    --primary-dark: #62bdf8;
    --primary-soft: #112f49;
    --nav: #081a37;
    --nav-deep: #030b19;
    --shadow: 0 10px 28px rgba(0, 5, 14, .28);
    background: var(--canvas);
}
html[data-theme="dark"] body,
html[data-theme="dark"] body.mobile-only { color: var(--ink); background: var(--canvas); }
html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] .stat strong,
html[data-theme="dark"] .mobile-only .scan-header h1,
html[data-theme="dark"] .mobile-only #operationCard h2 { color: #edf4fc; }
html[data-theme="dark"] .page-subtitle,
html[data-theme="dark"] .muted,
html[data-theme="dark"] .field-hint,
html[data-theme="dark"] .stat span,
html[data-theme="dark"] footer { color: var(--muted); }
html[data-theme="dark"] .panel,
html[data-theme="dark"] .stat,
html[data-theme="dark"] .auth-card,
html[data-theme="dark"] .mobile-only .scan-card,
html[data-theme="dark"] .mobile-only .scan-success,
html[data-theme="dark"] .scan-card,
html[data-theme="dark"] .scan-success {
    border-color: var(--line);
    background: var(--surface);
    box-shadow: var(--shadow);
}
html[data-theme="dark"] .company-logo-login {
    border-color: #34475d;
    background: #f8fbff;
}
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
    border-color: #34475d;
    background: #0c1726;
    color: var(--ink);
}
html[data-theme="dark"] input[readonly] { background: #142235; color: #b8c5d5; }
html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder { color: #708299; }
html[data-theme="dark"] th { color: #b5c2d2; background: #142235; }
html[data-theme="dark"] th,
html[data-theme="dark"] td { border-color: #29394c; }
html[data-theme="dark"] tbody tr:hover { background: #132235; }
html[data-theme="dark"] .button.secondary,
html[data-theme="dark"] .button.secondary:visited {
    border-color: #3a4d63;
    background: #172538;
    color: #dbe5f0;
}
html[data-theme="dark"] .button.secondary:hover { border-color: #587089; background: #1c2d43; color: #fff; }
html[data-theme="dark"] .table-actions a,
html[data-theme="dark"] .table-actions a:visited,
html[data-theme="dark"] .shelf-actions > a,
html[data-theme="dark"] .shelf-actions > a:visited {
    border-color: #385169;
    background: #132438;
    color: #77c8fa;
}
html[data-theme="dark"] .table-actions a:hover,
html[data-theme="dark"] .shelf-actions > a:hover { border-color: #3979a4; background: #17344d; }
html[data-theme="dark"] .record-item,
html[data-theme="dark"] .status-strip > div,
html[data-theme="dark"] .transfer-row,
html[data-theme="dark"] .comment-box,
html[data-theme="dark"] .readonly-state,
html[data-theme="dark"] .permissions-grid article,
html[data-theme="dark"] .interface-tsd .tsd-entry {
    border-color: var(--line);
    background: #142235;
}
html[data-theme="dark"] .transfer-title { color: #edf4fc; }
html[data-theme="dark"] .transfer-row label { color: #c7d3e2; }
html[data-theme="dark"] .transfer-row input { color: #f2f6fb; }
html[data-theme="dark"] .transfer-row input[readonly] { color: #b8c8d9; }
html[data-theme="dark"] .transfer-view-row > span { color: #dce6f2; }
html[data-theme="dark"] .transfer-view-row time { color: #a9b9cb; }
html[data-theme="dark"] .transfer-view { border-color: var(--line); }
html[data-theme="dark"] .transfer-view-row { border-color: var(--line); }
html[data-theme="dark"] .shelf-card { border-color: var(--line); background: #111d2b; }
html[data-theme="dark"] .shelf-card:hover { border-color: #386b8e; background: #13263a; }
html[data-theme="dark"] .shelf-main,
html[data-theme="dark"] .shelf-main:visited { color: var(--ink); }
html[data-theme="dark"] .mobile-only .operation-button,
html[data-theme="dark"] .interface-tsd .operation-button {
    border-color: #30445a;
    background: #142235;
    color: var(--ink);
}
html[data-theme="dark"] .mobile-only .operation-button:hover,
html[data-theme="dark"] .interface-tsd .operation-button:hover { border-color: #397fae; background: #17334b; }
html[data-theme="dark"] .mobile-only .operation-button small,
html[data-theme="dark"] .interface-tsd .operation-button small { color: #9aacbf; }
html[data-theme="dark"] .badge { color: #82cef9; background: #153550; }
html[data-theme="dark"] .sample-status.status-stored {
    color: #9be3b3;
    background: #183825;
}
html[data-theme="dark"] .sample-status.status-issued {
    color: #ffd482;
    background: #473516;
}
html[data-theme="dark"] .sample-status.status-complete {
    color: #c0cad7;
    background: #303b49;
}
html[data-theme="dark"] .sample-status.status-waiting {
    color: #82cef9;
    background: #153550;
}
html[data-theme="dark"] .capacity-bar,
html[data-theme="dark"] .chart-bar { background: #27384b; }
html[data-theme="dark"] .saved-filters > a,
html[data-theme="dark"] .saved-filters > a:visited { color: #82cef9; background: #153550; }
html[data-theme="dark"] .registration-disclosure > summary::before { color: #73c8fb; background: #153550; }
html[data-theme="dark"] .alert-panel { border-left-color: #d69b2d; }
html[data-theme="dark"] .flash.success { color: #9ee6b5; border-color: #285f3d; background: #153724; }
html[data-theme="dark"] .flash.error { color: #ffb1b1; border-color: #713737; background: #421f24; }
html[data-theme="dark"] .table-actions .restore-button { border-color: #347951; background: #183825; color: #9be3b3; }
html[data-theme="dark"] .storage-stage-header {
    border-color: var(--line);
    background: #142235;
}
html[data-theme="dark"] .storage-stage-header p,
html[data-theme="dark"] .shelf-name span,
html[data-theme="dark"] .shelf-count span,
html[data-theme="dark"] .shelf-capacity,
html[data-theme="dark"] .empty-stage { color: var(--muted); }
html[data-theme="dark"] .stage-total {
    background: #153550;
    color: #82cef9;
}
html[data-theme="dark"] .shelf-card { border-bottom-color: var(--line); }
html[data-theme="dark"] .shelf-main:hover { background: #13263a; }
html[data-theme="dark"] .shelf-icon {
    background: #153550;
    color: #72c9fb;
}
html[data-theme="dark"] .operation-test .operation-icon {
    background: #153550 !important;
    color: #72c9fb !important;
}
html[data-theme="dark"] .operation-customer .operation-icon {
    background: #183b29 !important;
    color: #91dfad !important;
}
.service-warning { border-left: 5px solid #d69b2d; }
.service-log-list { display: grid; gap: 8px; margin-bottom: 16px; }
.service-log-row {
    display: grid;
    grid-template-columns: auto minmax(160px, 1fr) auto auto;
    gap: 14px;
    align-items: center;
    padding: 11px 13px;
    border: 1px solid var(--line);
    border-radius: 9px;
}
.service-log-row input { width: auto; }
.service-log-row span, .service-log-row time { color: var(--muted); font-weight: 400; }
.service-bulk-actions { display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin: 18px 0 12px; }
@media (max-width: 650px) {
    .service-log-row { grid-template-columns: auto 1fr; }
    .service-log-row span, .service-log-row time { grid-column: 2; }
}
