* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    background: #f3f6f8;
    color: #1f2933;
    font-family: Arial, sans-serif;
}

header {
    align-items: center;
    background: #17212b;
    color: #fff;
    display: flex;
    gap: 18px;
    justify-content: space-between;
    padding: 14px 22px;
}

.brand-link {
    color: #fff;
    font-size: 17px;
    font-weight: 700;
    text-decoration: none;
}

.session-block {
    align-items: center;
    display: flex;
    gap: 14px;
}

.session-block button {
    margin: 0;
}

main {
    margin: 0 auto;
    max-width: 1180px;
    padding: 18px;
}

h1 {
    font-size: 24px;
    margin: 0;
}

a {
    color: #0b6aa2;
}

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

.panel {
    background: #fff;
    border: 1px solid #d8e0e7;
    border-radius: 8px;
    padding: 16px;
}

.workspace-tabs {
    border-bottom: 1px solid #cbd5df;
    display: flex;
    gap: 2px;
    margin-bottom: 18px;
    overflow-x: auto;
    white-space: nowrap;
}

.workspace-tabs a {
    border-bottom: 3px solid transparent;
    color: #435466;
    font-size: 14px;
    font-weight: 700;
    padding: 10px 12px 9px;
    text-decoration: none;
}

.workspace-tabs a.active {
    border-bottom-color: #1f6feb;
    color: #174ea6;
}

.workspace-heading {
    align-items: end;
    display: flex;
    justify-content: space-between;
    margin-bottom: 14px;
}

.workspace-heading p {
    color: #5d6b78;
    margin: 5px 0 0;
}

.section-heading {
    border-top: 1px solid #cfd8e1;
    margin-top: 28px;
    padding-top: 20px;
}

.section-heading h2 {
    margin: 0;
}

.section-heading p {
    color: #5d6b78;
    margin: 5px 0 12px;
}

.workspace-grid {
    display: grid;
    gap: 14px;
    margin-bottom: 14px;
}

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

.narrow-panel {
    max-width: 720px;
}

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

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

.form-grid-4 {
    align-items: end;
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.form-grid label {
    margin-top: 0;
}

.form-actions {
    grid-column: 1 / -1;
}

.check-field {
    align-items: center;
    display: flex;
    font-weight: 700;
    gap: 8px;
    min-height: 40px;
}

.check-field input {
    height: 18px;
    margin: 0;
    width: 18px;
}

.panel h2,
.panel h3 {
    margin: 0 0 12px;
}

label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    margin: 10px 0 4px;
}

input,
select,
button {
    font: inherit;
}

input,
select,
textarea {
    border: 1px solid #b8c4cf;
    border-radius: 6px;
    padding: 9px 10px;
    width: 100%;
}

textarea {
    font-family: Consolas, monospace;
    min-height: 220px;
    resize: vertical;
}

button,
.button {
    background: #1f6feb;
    border: 0;
    border-radius: 6px;
    color: #fff;
    cursor: pointer;
    display: inline-block;
    margin-top: 10px;
    padding: 10px 14px;
    text-decoration: none;
}

button.secondary {
    background: #607080;
}

button.danger {
    background: #b42318;
}

button.warning {
    background: #b76e00;
}

button.compact,
.button.compact {
    font-size: 13px;
    margin: 0;
    padding: 7px 10px;
}

button:disabled {
    cursor: not-allowed;
    opacity: .5;
}

.button.secondary-link {
    background: #607080;
}

.operator-error {
    background: #991b1b;
    border-radius: 8px;
    color: #fff;
    margin-bottom: 14px;
    padding: 22px;
}

.operator-error h2 {
    margin: 0 0 10px;
}

.operator-error-code {
    font-size: 34px;
    font-weight: 700;
    margin: 8px 0;
}

.error-shot {
    border: 1px solid #d8e0e7;
    border-radius: 8px;
    max-width: 360px;
    width: 100%;
}

.reference-list {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    margin-bottom: 14px;
}

.reference-item {
    border: 1px solid #d8e0e7;
    border-radius: 8px;
    padding: 8px;
    position: relative;
}

.reference-item img,
.reference-thumb {
    background: #e8eef3;
    border: 1px solid #b8c4cf;
    border-radius: 6px;
    display: block;
    height: 72px;
    object-fit: contain;
    width: 100%;
}

.reference-item span {
    display: block;
    font-size: 13px;
    font-weight: 700;
    margin-top: 6px;
}

.reference-thumb {
    max-width: 120px;
}

.delete-cross-form {
    display: inline-block;
    margin: 0;
}

.reference-item .delete-cross-form {
    position: absolute;
    right: 6px;
    top: 6px;
}

button.delete-cross {
    align-items: center;
    background: #b42318;
    border-radius: 50%;
    display: inline-flex;
    font-size: 17px;
    font-weight: 700;
    height: 24px;
    justify-content: center;
    line-height: 1;
    margin: 0;
    padding: 0;
    width: 24px;
}

button.delete-cross:hover {
    background: #7f1d1d;
}

button.icon-action {
    align-items: center;
    background: #2563eb;
    border-radius: 50%;
    display: inline-flex;
    font-size: 15px;
    font-weight: 700;
    height: 24px;
    justify-content: center;
    line-height: 1;
    margin: 0 4px 0 0;
    padding: 0;
    width: 24px;
}

button.icon-action:hover {
    background: #1d4ed8;
}

.tab-attention-badge {
    align-items: center;
    background: #c62828;
    border-radius: 10px;
    color: #fff;
    display: inline-flex;
    font-size: 11px;
    font-weight: 700;
    height: 18px;
    justify-content: center;
    line-height: 1;
    margin-left: 6px;
    min-width: 18px;
    padding: 0 5px;
}

.message {
    background: #d1fae5;
    border: 1px solid #6ee7b7;
    border-radius: 8px;
    margin-bottom: 14px;
    padding: 12px;
}

.error {
    background: #fee2e2;
    border: 1px solid #fca5a5;
    border-radius: 8px;
    margin-bottom: 14px;
    padding: 12px;
}

.status {
    background: #e8eef3;
    border-radius: 8px;
    font-size: 18px;
    font-weight: 700;
    padding: 16px;
}

.status.ok {
    background: #d1fae5;
    color: #065f46;
}

.status.bad {
    background: #fee2e2;
    color: #991b1b;
}

.status.wait {
    background: #fff7d6;
    color: #7a4b00;
}

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

.table-panel {
    margin-top: 14px;
    overflow-x: auto;
}

.packer-job-search {
    align-items: flex-end;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 6px;
}

.packer-job-search label {
    flex: 1 1 420px;
    margin: 0;
    max-width: 720px;
}

.packer-job-search label span {
    display: block;
    font-weight: 700;
    margin-bottom: 5px;
}

.packer-job-search input {
    width: 100%;
}

.packer-job-search button,
.packer-job-search .button {
    margin: 0;
}

.packer-job-search-help {
    margin: 0 0 12px;
}

.qr-search-code {
    max-width: 260px;
}

.qr-search-code code {
    overflow-wrap: anywhere;
    white-space: normal;
}

.table-toolbar {
    align-items: center;
    display: flex;
    gap: 16px;
    justify-content: space-between;
    margin-bottom: 10px;
}

.table-toolbar h2 {
    margin: 0;
}

.table-toolbar select {
    max-width: 340px;
}

.inline-form {
    align-items: center;
    display: flex;
    gap: 6px;
    margin: 0;
}

.inline-form input,
.inline-form select {
    min-width: 150px;
}

.status-badge {
    border-radius: 4px;
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    padding: 5px 7px;
}

.status-active { background: #d1fae5; color: #065f46; }
.status-completed { background: #e8eef3; color: #435466; }
.status-archived { background: #fff0d6; color: #7a4b00; }
.status-missing { background: #fee2e2; color: #991b1b; }

.empty-state {
    color: #667788;
    padding: 18px 8px;
    text-align: center;
}

.info-line {
    background: #e8f2ff;
    border-left: 3px solid #1f6feb;
    color: #30475e;
    margin: 12px 0;
    padding: 10px 12px;
}

.file-cell,
.code-cell {
    max-width: 360px;
    overflow-wrap: anywhere;
}

.returned-qr {
    background: #eef8f2;
    border-left: 3px solid #2f855a;
    display: grid;
    gap: 4px;
    margin-top: 6px;
    max-width: 340px;
    padding: 7px 9px;
}

.returned-qr code {
    overflow-wrap: anywhere;
    white-space: normal;
}

.archive-filters {
  display: grid;
  grid-template-columns: minmax(220px, 1.1fr) minmax(180px, .7fr) minmax(280px, 1.5fr);
  gap: 12px;
  align-items: end;
}

.archive-search { min-width: 0; }
.archive-filter-actions { display: flex; flex-wrap: wrap; gap: 8px; grid-column: 1 / -1; }
.table-heading-row { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.table-heading-row h2 { margin-bottom: 10px; }
.table-scroll { overflow-x: auto; }
.code-details { max-width: 330px; }
.code-details summary { cursor: pointer; color: #31516d; white-space: nowrap; }
.code-details code { display: block; margin-top: 8px; overflow-wrap: anywhere; white-space: normal; }
.archive-pagination { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 16px; }

@media (max-width: 900px) {
  .archive-filters { grid-template-columns: 1fr; }
  .archive-filter-actions { grid-column: auto; }
}

.datamatrix-thumb {
    border: 1px solid #b8c4cf;
    height: 64px;
    image-rendering: pixelated;
    object-fit: contain;
    width: 64px;
}

.template-preview {
    background: #f5f7f9;
    border: 1px solid #d8e0e7;
    max-height: 420px;
    overflow: auto;
    padding: 12px;
    white-space: pre-wrap;
}

td,
th {
    border-bottom: 1px solid #e2e8f0;
    padding: 8px;
    text-align: left;
    vertical-align: top;
}

video,
canvas,
.color-swatch {
    background: #e8eef3;
    border: 1px solid #b8c4cf;
    border-radius: 8px;
    max-width: 100%;
}

.color-swatch {
    display: block;
    height: 130px;
    object-fit: contain;
    width: 200px;
}

.row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.row-actions form {
    margin: 0;
}

.scan-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(2, minmax(180px, 1fr));
}

.small {
    color: #5d6b78;
    font-size: 13px;
}

.packer-layout {
    display: grid;
    gap: 14px;
    grid-template-columns: minmax(0, 1.5fr) minmax(240px, .8fr) minmax(190px, .5fr);
    margin-top: 14px;
}

.packer-selection h1 {
    margin-bottom: 12px;
}

.color-photo-frame {
    align-items: center;
    background: #eef2f5;
    border: 1px solid #c5d0d9;
    display: flex;
    justify-content: center;
    min-height: 190px;
    padding: 8px;
    position: relative;
}

.color-photo-frame .color-swatch {
    border: 0;
    height: 230px;
    object-fit: contain;
    width: 100%;
}

.color-photo-frame span {
    color: #667788;
    max-width: 210px;
    text-align: center;
}

.scanner-state {
    background: #fff7d6;
    border-left: 4px solid #d69e2e;
    display: grid;
    gap: 5px;
    margin-top: 12px;
    padding: 12px;
}

.scanner-state.is-ok {
    background: #e5f6ea;
    border-left-color: #238636;
}

.scanner-state.is-error {
    background: #fde8e6;
    border-left-color: #c72c22;
}

.scanner-state button {
    justify-self: start;
    margin-top: 4px;
}

.bridge-help {
    border-top: 1px solid #e7aaa4;
    display: grid;
    gap: 8px;
    margin-top: 6px;
    padding-top: 10px;
}

.bridge-help[hidden] {
    display: none;
}

.bridge-help .button {
    justify-self: start;
}

.metric {
    border-bottom: 1px solid #e2e8f0;
    display: grid;
    padding: 12px 0;
}

.metric strong {
    font-size: 32px;
}

.metric span {
    color: #5d6b78;
}

.scanner-panel {
    margin-top: 14px;
}

.verify-toolbar {
    max-width: 280px;
}

@media (max-width: 980px) {
    .packer-layout {
        grid-template-columns: 1fr 1fr;
    }

    .packer-selection {
        grid-column: 1 / -1;
    }
}

@media (max-width: 900px) {
    .workspace-grid.two-columns,
    .form-grid-4 {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 640px) {
    header,
    .session-block,
    .table-toolbar {
        align-items: flex-start;
        flex-direction: column;
    }

    main {
        padding: 12px;
    }

    .workspace-grid.two-columns,
    .form-grid-2,
    .form-grid-4,
    .scan-grid {
        grid-template-columns: 1fr;
    }

    .packer-layout {
        grid-template-columns: 1fr;
    }

    .packer-selection {
        grid-column: auto;
    }
}
