:root {
    color-scheme: light;
    --bg: #f7f8fa;
    --panel: #ffffff;
    --text: #172033;
    --muted: #64748b;
    --line: #d9e0ea;
    --primary: #0f766e;
    --primary-dark: #115e59;
    --danger: #b91c1c;
    --success: #166534;
}

* {
    box-sizing: border-box;
}

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

a {
    color: var(--primary-dark);
}

.topbar {
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 14px;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    position: sticky;
    top: 0;
    z-index: 2;
}

.brand {
    color: var(--text);
    font-size: 18px;
    font-weight: 750;
    text-decoration: none;
}

nav {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

nav a {
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: #334155;
    font-size: 14px;
    font-weight: 700;
    min-height: 34px;
    padding: 7px 10px;
    text-decoration: none;
}

nav a:hover,
nav a:focus {
    background: #eef7f6;
    border-color: #99d5ce;
    color: var(--primary-dark);
}

.menu-toggle {
    display: none;
}

.page {
    margin: 0 auto;
    max-width: 980px;
    padding: 18px 14px 48px;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 14px;
}

.login-panel {
    margin: 32px auto;
    max-width: 430px;
}

h1 {
    font-size: 28px;
    line-height: 1.15;
    margin: 0 0 8px;
}

h2 {
    font-size: 18px;
    margin: 0 0 12px;
}

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

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

.action {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    display: block;
    font-weight: 700;
    min-height: 76px;
    padding: 16px;
    text-decoration: none;
}

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

.stat {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
}

.stat strong {
    display: block;
    font-size: 26px;
}

label {
    display: block;
    font-weight: 700;
    margin: 12px 0 6px;
}

input,
select,
textarea {
    border: 1px solid var(--line);
    border-radius: 8px;
    display: block;
    font: inherit;
    padding: 12px;
    width: 100%;
}

button,
.button {
    background: var(--primary);
    border: 0;
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-weight: 750;
    justify-content: center;
    min-height: 44px;
    padding: 10px 14px;
    text-decoration: none;
}

.button.secondary,
button.secondary {
    background: #334155;
}

.button.danger,
button.danger {
    background: var(--danger);
}

.button.compact,
button.compact {
    font-size: 14px;
    min-height: 36px;
    padding: 8px 10px;
}

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

.list {
    display: grid;
    gap: 10px;
}

.list-item {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
}

.bin-row {
    align-items: flex-start;
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 12px;
    justify-content: space-between;
    padding: 12px 0;
}

.bin-row:first-of-type {
    padding-top: 0;
}

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

.item-title {
    display: flex;
    gap: 8px;
    justify-content: space-between;
    align-items: flex-start;
}

.item-link {
    color: var(--text);
    text-decoration: none;
}

.item-link:hover,
.item-link:focus {
    color: var(--primary-dark);
    text-decoration: underline;
}

.pill {
    border-radius: 999px;
    color: #fff;
    display: inline-flex;
    font-size: 12px;
    font-weight: 750;
    padding: 4px 8px;
}

.category-picker {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    margin-top: 6px;
}

.category-option {
    align-items: center;
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: flex;
    gap: 8px;
    margin: 0;
    min-height: 44px;
    padding: 8px 10px;
}

.category-option input {
    flex: 0 0 auto;
    margin: 0;
    width: auto;
}

.inline-add-panel {
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-top: 12px;
    padding: 12px;
}

.inline-add-panel h3 {
    font-size: 16px;
    margin: 0 0 8px;
}

.status-badge {
    border-radius: 999px;
    display: inline-flex;
    font-size: 12px;
    font-weight: 800;
    margin-right: 6px;
    padding: 4px 8px;
}

.review-badge {
    background: #ffedd5;
    border-radius: 999px;
    color: #9a3412;
    display: inline-flex;
    font-size: 12px;
    font-weight: 800;
    margin-right: 6px;
    padding: 4px 8px;
}

.review-button {
    background: #ea580c;
}

.status-active {
    background: #dcfce7;
    color: #166534;
}

.status-reserved {
    background: #fef3c7;
    color: #92400e;
}

.status-retired {
    background: #e5e7eb;
    color: #374151;
}

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

.notice {
    border-radius: 8px;
    margin-bottom: 14px;
    padding: 12px 14px;
}

.notice.success {
    background: #dcfce7;
    color: var(--success);
}

.notice.error {
    background: #fee2e2;
    color: var(--danger);
}

.notice.warning {
    background: #ffedd5;
    color: #9a3412;
}

.bin-note {
    background: #f8fafc;
    border: 1px solid var(--line);
    color: var(--text);
}

.quantity-controls {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 12px;
}

.quantity-controls button {
    min-width: 46px;
}

.quantity-controls .button {
    align-items: center;
}

.quantity-button {
    font-size: 18px;
    font-weight: 850;
    min-width: 56px;
}

.quantity-badge {
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 18px;
    font-weight: 850;
    padding: 8px 10px;
    text-align: center;
    white-space: nowrap;
}

.search-box {
    margin-bottom: 14px;
}

.checkbox-row {
    align-items: center;
    display: flex;
    gap: 8px;
}

.checkbox-row input {
    width: auto;
}

.bin-result-list {
    display: grid;
    gap: 7px;
    margin-top: 10px;
}

.bin-result-link {
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    display: block;
    font-weight: 700;
    padding: 9px 10px;
    text-decoration: none;
}

.bin-result-link:hover,
.bin-result-link:focus {
    background: #eef7f6;
    border-color: #99d5ce;
}

.contents-toggle {
    margin-top: 10px;
}

.contents-toggle summary {
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    font-weight: 800;
    padding: 8px 10px;
}

.contents-list {
    border-top: 1px solid var(--line);
    display: grid;
    gap: 8px;
    margin-top: 10px;
    padding-top: 10px;
}

.contents-row {
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 9px 10px;
}

.contents-row span {
    color: var(--muted);
    float: right;
}

.history-row {
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
}

.history-panel summary {
    cursor: pointer;
    font-size: 18px;
    font-weight: 800;
}

.history-panel[open] summary {
    margin-bottom: 12px;
}

.suggestions {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
    display: grid;
    gap: 4px;
    margin-top: 6px;
    max-height: 280px;
    overflow-y: auto;
    padding: 6px;
}

.suggestion {
    background: #fff;
    border: 0;
    border-radius: 6px;
    color: var(--text);
    display: block;
    min-height: 0;
    padding: 10px;
    text-align: left;
    width: 100%;
}

.suggestion:hover,
.suggestion:focus {
    background: #eef7f6;
}

.suggestion span {
    color: var(--muted);
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-top: 2px;
}

.unit-row {
    display: grid;
    grid-template-columns: minmax(160px, 1fr) 110px auto auto;
    gap: 10px;
    align-items: end;
}

.unit-row label {
    margin-top: 0;
}

.unit-active {
    margin-bottom: 10px;
}

.bin-type-row {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) 145px 145px 90px auto auto;
    gap: 10px;
    align-items: end;
}

.bin-type-row label {
    margin-top: 0;
}

.category-row {
    display: grid;
    grid-template-columns: minmax(160px, 1fr) 80px auto auto auto;
    gap: 10px;
    align-items: end;
}

.category-row label {
    margin-top: 0;
}

.category-preview {
    margin-bottom: 10px;
}

.category-choice {
    margin: 0;
}

.item-meta {
    color: var(--muted);
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    margin-top: 10px;
}

.table-wrap {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow-x: auto;
}

.data-table {
    border-collapse: collapse;
    min-width: 760px;
    width: 100%;
}

.data-table th,
.data-table td {
    border-bottom: 1px solid var(--line);
    padding: 10px 12px;
    text-align: left;
    vertical-align: top;
}

.data-table th {
    background: #f1f5f9;
    color: #334155;
    font-size: 13px;
    font-weight: 800;
}

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

.small-text {
    font-size: 13px;
    margin-top: 2px;
}

.pagination {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: space-between;
    margin: 4px 0 18px;
}

.pagination-prev,
.pagination-next {
    flex: 0 0 auto;
}

.pagination [aria-disabled="true"] {
    background: #cbd5e1;
    color: #94a3b8;
    cursor: default;
    pointer-events: none;
}

.pagination-status {
    text-align: center;
}

.quantity-saved-badge {
    background: #dcfce7;
    border-radius: 999px;
    color: var(--success);
    display: inline-flex;
    font-size: 13px;
    font-weight: 800;
    opacity: 0;
    padding: 4px 10px;
    transition: opacity 0.2s ease;
    vertical-align: middle;
    white-space: nowrap;
}

.quantity-saved-badge.is-visible {
    opacity: 1;
}

.quantity-saved-badge.is-error {
    background: #fee2e2;
    color: var(--danger);
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

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

.quantity-stepper {
    display: grid;
    gap: 8px;
    grid-template-columns: 60px minmax(90px, 1fr) 60px;
}

.quantity-stepper input {
    font-size: 18px;
    font-weight: 800;
    text-align: center;
}

.details-panel {
    border-top: 1px solid var(--line);
    margin-top: 16px;
    padding-top: 12px;
}

.details-panel summary {
    cursor: pointer;
    font-weight: 800;
    margin-bottom: 8px;
}

.bin-photo-link {
    display: inline-block;
    margin: 12px 0;
}

.bin-photo {
    border: 1px solid var(--line);
    border-radius: 8px;
    display: block;
    height: 150px;
    object-fit: cover;
    width: 150px;
}

.bin-photo-actions {
    margin-top: 10px;
}

.bin-photo-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.bin-photo-row .bin-photo-link {
    margin: 12px 0 4px;
}

.bin-photo-block p {
    margin: 0;
}

.bin-type-reference {
    align-items: center;
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: flex;
    gap: 12px;
    margin-top: 12px;
    padding: 12px;
}

.bin-type-reference[hidden] {
    display: none;
}

.bin-type-reference-photo {
    border: 1px solid var(--line);
    border-radius: 8px;
    flex: 0 0 auto;
    height: 120px;
    object-fit: cover;
    width: 120px;
}

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

.bin-type-edit-bin-form {
    align-items: center;
    border-top: 1px dashed var(--line);
    margin-top: 12px;
    padding-top: 12px;
}

.item-photo-link {
    display: inline-block;
    margin: 12px 0;
}

.item-photo {
    border: 1px solid var(--line);
    border-radius: 8px;
    display: block;
    height: 150px;
    object-fit: cover;
    width: 150px;
}

.item-photo-actions {
    margin-top: 10px;
}

.item-photo-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin: 12px 0;
}

.item-photo-thumb {
    text-align: center;
}

.item-photo-thumb .item-photo-link {
    margin: 0;
}

.item-photo-thumb.is-pinned .item-photo {
    border-color: var(--primary);
    border-width: 2px;
}

.item-photo-pinned-badge {
    color: var(--primary);
    display: block;
    font-size: 12px;
    font-weight: 700;
    margin-top: 4px;
}

.item-photo-thumb-action {
    display: inline-block;
    margin-top: 4px;
}

.item-photo-thumb-action .compact {
    min-height: 30px;
    padding: 4px 8px;
}

.item-table-title {
    align-items: center;
    display: flex;
    gap: 10px;
}

.bin-content-item-title {
    align-items: center;
    display: flex;
    gap: 10px;
}

.bin-content-card {
    padding: 0;
}

.bin-contents-header {
    justify-content: space-between;
    margin-bottom: 12px;
}

.bin-content-summary {
    align-items: center;
    cursor: pointer;
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(0, 1fr) auto auto;
    list-style: none;
    padding: 14px;
}

.bin-content-summary::-webkit-details-marker {
    display: none;
}

.bin-content-summary::after {
    background: #eef2f7;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: #334155;
    content: "+";
    display: inline-flex;
    font-weight: 900;
    height: 26px;
    justify-content: center;
    line-height: 1;
    margin-left: 4px;
    padding-top: 1px;
    width: 26px;
}

.bin-content-card[open] .bin-content-summary::after {
    content: "-";
}

.bin-content-details {
    border-top: 1px solid var(--line);
    padding: 0 14px 14px;
}

.bin-content-links {
    margin-top: 10px;
}

.search-item-title {
    align-items: center;
    display: flex;
    gap: 10px;
}

.item-photo-tiny {
    border: 1px solid var(--line);
    border-radius: 6px;
    height: 42px;
    object-fit: cover;
    width: 42px;
}

.bin-row-photos {
    display: flex;
    flex-shrink: 0;
    gap: 6px;
}

.bin-row-photo {
    border: 1px solid var(--line);
    border-radius: 6px;
    flex-shrink: 0;
    height: 56px;
    object-fit: cover;
    width: 56px;
}

.photo-preview {
    border: 1px solid var(--line);
    border-radius: 6px;
    display: block;
    height: 90px;
    margin-top: 8px;
    object-fit: cover;
    width: 90px;
}

.photo-preview[hidden] {
    display: none;
}

.photo-upload-form {
    display: inline-flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.photo-file-input {
    height: 1px;
    opacity: 0;
    overflow: hidden;
    position: absolute;
    width: 1px;
}

.photo-manual-button {
    display: inline-flex;
}

.label-sheet {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(2, 4in);
    justify-content: center;
}

.op-label {
    align-items: center;
    background: #fff;
    border: 1px dashed #94a3b8;
    display: grid;
    grid-template-columns: 1fr 1.35in;
    gap: 0.12in;
    height: 2in;
    padding: 0.14in;
    width: 4in;
}

.op-label-code {
    font-size: 34px;
    font-weight: 900;
    letter-spacing: 0;
    line-height: 1;
}

.op-label-location {
    font-size: 12px;
    font-weight: 700;
    margin-top: 0.12in;
}

.op-label-status {
    font-size: 12px;
    font-weight: 900;
    margin-top: 0.06in;
    text-transform: uppercase;
}

.op-label-qr {
    height: 1.3in;
    width: 1.3in;
}

.op-label-blank {
    background: transparent;
    border-color: #cbd5e1;
}

.label-checklist-row {
    align-items: flex-start;
    cursor: pointer;
    font-weight: 400;
    margin: 0;
}

.label-checklist-row input[type="checkbox"] {
    flex: 0 0 auto;
    margin-top: 4px;
}

.sub-bin-panel {
    margin-top: 12px;
}

.sub-bin-row {
    align-items: flex-start;
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 12px;
    justify-content: space-between;
    padding: 10px 0;
}

.sub-bin-row:first-of-type {
    padding-top: 0;
}

.sub-bin-row:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.contents-group {
    margin-top: 16px;
}

.contents-group-title {
    font-size: 15px;
    font-weight: 800;
    margin: 0 0 8px;
}

.qr-preview {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    height: 120px;
    width: 120px;
}

.color-control {
    align-items: center;
    display: flex;
    gap: 10px;
}

input[type="color"] {
    height: 44px;
    max-width: 72px;
    padding: 4px;
}

@media (max-width: 640px) {
    .topbar {
        align-items: center;
        flex-direction: row;
        flex-wrap: wrap;
        padding: 10px;
    }

    nav {
        display: none;
        justify-content: flex-start;
        order: 3;
        width: 100%;
    }

    nav.is-open {
        display: flex;
    }

    nav a {
        font-size: 13px;
        min-height: 38px;
        padding: 8px 9px;
    }

    .menu-toggle {
        background: #334155;
        display: inline-flex;
        margin-left: auto;
        min-height: 38px;
        padding: 8px 12px;
    }

    .page {
        padding: 12px 10px 36px;
    }

    .panel,
    .list-item {
        padding: 12px;
    }

    .pagination {
        flex-direction: column;
    }

    .pagination-prev,
    .pagination-next {
        width: 100%;
    }

    .quantity-controls .quantity-saved-badge {
        display: block;
        grid-column: 1 / -1;
        margin-left: 0;
        margin-top: 8px;
        text-align: center;
    }

    h1 {
        font-size: 25px;
    }

    h2 {
        font-size: 17px;
    }

    .item-title {
        display: block;
    }

    .item-title > span,
    .item-title > div:last-child {
        display: block;
        margin-top: 6px;
    }

    .row {
        align-items: stretch;
    }

    .row .button,
    .row button {
        align-items: center;
    }

    .quantity-controls {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .quantity-controls button,
    .quantity-controls .button {
        min-height: 52px;
    }

    .quantity-controls .button {
        font-size: 14px;
    }

    .quantity-button {
        font-size: 22px;
        min-width: 0;
    }

    .quantity-badge {
        display: inline-block;
        font-size: 20px;
        margin-top: 10px;
        min-width: 90px;
    }

    .quantity-stepper {
        grid-template-columns: 70px minmax(90px, 1fr) 70px;
    }

    .quantity-stepper button,
    .quantity-stepper input {
        min-height: 52px;
    }

    .photo-upload-form {
        display: grid;
        grid-template-columns: 1fr 1fr;
        width: 100%;
    }

    .photo-upload-form .small-text {
        grid-column: 1 / -1;
    }

    .bin-photo,
    .item-photo {
        height: 120px;
        width: 120px;
    }

    .bin-type-reference {
        align-items: flex-start;
    }

    .bin-type-reference-photo {
        height: 96px;
        width: 96px;
    }

    .item-photo-tiny {
        height: 48px;
        width: 48px;
    }

    .bin-content-item-title,
    .item-table-title,
    .search-item-title {
        align-items: flex-start;
    }

    .bin-content-summary {
        gap: 8px;
        padding: 10px;
    }

    .bin-content-details {
        padding: 0 10px 10px;
    }

    .bin-content-summary::after {
        height: 32px;
        width: 32px;
    }

    .bin-result-link {
        padding: 11px 10px;
    }

    .unit-row {
        grid-template-columns: 1fr;
    }

    .bin-type-row {
        grid-template-columns: 1fr;
    }

    .category-row {
        grid-template-columns: 1fr;
    }

    .category-picker {
        grid-template-columns: 1fr 1fr;
    }

    .category-option {
        align-items: flex-start;
        min-height: 48px;
    }

    .category-option .pill {
        overflow-wrap: anywhere;
        white-space: normal;
    }

    .label-sheet {
        grid-template-columns: 1fr;
    }

    .op-label {
        max-width: 100%;
        width: 100%;
    }
}

@media print {
    @page {
        margin: 0;
        size: letter;
    }

    body {
        background: #fff;
    }

    .topbar,
    .no-print {
        display: none !important;
    }

    .page {
        margin: 0;
        max-width: none;
        padding: 0;
    }

    .label-sheet {
        column-gap: 0.125in;
        display: grid;
        grid-template-columns: repeat(2, 4in);
        grid-auto-rows: 2in;
        justify-content: start;
        padding: 0.5in 0 0 0.1875in;
        row-gap: 0;
        width: 8.5in;
    }

    .op-label {
        border: 0;
        break-after: auto;
        height: 2in;
        page-break-after: auto;
        width: 4in;
    }

    .op-label-blank {
        visibility: hidden;
    }
}
