.login-wrap {
    min-height: calc(100vh - 80px);
    display: grid;
    place-items: center;
}

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

.field {
    display: grid;
    gap: 8px;
}

.field label {
    font-size: 14px;
    color: var(--muted);
}

.field input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
    font: inherit;
}

.error {
    margin: 0 0 14px;
    padding: 12px 14px;
    border-radius: 8px;
    background: #ece1e1;
    color: #6d2e2e;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.summary-card {
    padding: 18px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.4), transparent),
        var(--panel);
}

.summary-card span {
    display: block;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 12px;
}

.summary-card strong {
    display: block;
    margin-top: 10px;
    font-size: 28px;
    line-height: 1.1;
}

.summary-card small {
    display: block;
    margin-top: 8px;
    color: var(--muted);
    font-size: 13px;
}

.section {
    padding: 18px;
    margin-bottom: 18px;
}

.section-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 18px;
}

.section h2 {
    margin: 0 0 8px;
    font-size: 24px;
}

.section p,
.item-subline,
.results-summary,
.page-indicator {
    color: var(--muted);
}

.inventory-meta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.meta-pill,
.code-pill,
.quantity-pill,
.category-badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    font-size: 12px;
    line-height: 1;
    white-space: nowrap;
}

.meta-pill {
    padding: 10px 12px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.8);
}

.control-panel {
    display: grid;
    grid-template-columns: minmax(220px, 1.3fr) repeat(4, minmax(140px, 1fr)) minmax(100px, 0.7fr) minmax(90px, 0.6fr) auto;
    gap: 12px;
    margin-bottom: 16px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.52), rgba(247, 234, 212, 0.46));
}

.control {
    display: grid;
    gap: 8px;
    align-content: start;
}

.control label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
}

.control input,
.control select,
.control button {
    width: 100%;
    min-height: 44px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.96);
    padding: 11px 13px;
    font: inherit;
    color: var(--ink);
}

.control-search input {
    font-size: 15px;
}

.control-actions {
    align-self: end;
}

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

.toolbar-sort {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.sort-chip,
.sort-direction,
.page-btn {
    appearance: none;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.88);
    font: inherit;
    cursor: pointer;
}

.sort-chip.is-active,
.sort-direction.is-desc,
.page-btn:hover {
    color: white;
    border-color: transparent;
    background: var(--accent);
}

.table-shell {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.72);
}

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

.inventory-table thead {
    position: sticky;
    top: 0;
    z-index: 3;
    backdrop-filter: blur(8px);
}

.inventory-table th {
    padding: 14px 12px;
    background: rgba(247, 234, 212, 0.96);
    border-bottom: 1px solid var(--line);
    text-align: left;
}

.inventory-table td {
    padding: 14px 12px;
    border-bottom: 1px solid rgba(217, 206, 185, 0.8);
    vertical-align: top;
    background: rgba(255, 255, 255, 0.68);
}

.inventory-table tbody tr:hover td {
    background: rgba(215, 239, 232, 0.42);
}

.column-sort {
    appearance: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 0;
    background: transparent;
    padding: 0;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.column-sort::after {
    content: '\2195';
    font-size: 11px;
    color: var(--muted);
}

.column-sort.is-active::after {
    content: '\2191';
    color: var(--accent);
}

.column-sort.is-active.is-desc::after {
    content: '\2193';
}

.category-badge {
    padding: 7px 11px;
    background: rgba(15, 118, 110, 0.12);
    color: var(--accent);
    font-weight: 700;
}

.code-pill {
    padding: 7px 10px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.82);
    font-weight: 700;
}

.quantity-pill {
    min-width: 44px;
    justify-content: center;
    padding: 8px 12px;
    background: #231f17;
    color: #fff8ee;
    font-weight: 700;
}

.item-name {
    font-weight: 700;
    margin-bottom: 4px;
}

.numeric-emphasis {
    font-weight: 700;
}

.image-gallery {
    display: grid;
    gap: 10px;
    width: min(240px, 100%);
}

.gallery-thumb,
.gallery-open-link,
.modal-nav {
    appearance: none;
    border: 0;
    background: transparent;
    padding: 0;
    font: inherit;
}

.gallery-footer {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
}

.gallery-count {
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
}

.gallery-open-link {
    color: var(--accent);
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
}

.gallery-strip {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: thin;
}

.gallery-thumb {
    flex: 0 0 auto;
    width: 60px;
    height: 60px;
    border: 1px solid transparent;
    border-radius: 8px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.88);
    cursor: pointer;
}

.gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.gallery-thumb.is-active {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(62, 81, 76, 0.14);
}

.search-link {
    color: var(--accent);
    font-weight: 700;
    text-decoration: none;
}

.pagination-bar {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin-top: 16px;
}

.page-btn[disabled] {
    opacity: 0.4;
    cursor: default;
}

.page-indicator {
    text-align: center;
}

.empty-row td {
    text-align: center;
    color: var(--muted);
    padding: 28px 14px;
}

.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 100;
    padding: 30px 20px 20px;
    background: rgba(17, 17, 17, 0.88);
}

.modal.is-open {
    display: grid;
    place-items: center;
}

.modal-dialog {
    width: min(1180px, 100%);
    display: grid;
    gap: 14px;
}

.modal-stage {
    display: grid;
    grid-template-columns: 52px minmax(0, 1fr) 52px;
    gap: 16px;
    align-items: center;
}

.modal-content {
    display: block;
    width: 100%;
    max-height: 82vh;
    object-fit: contain;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
}

.modal-nav {
    width: 52px;
    height: 52px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 999px;
    color: white;
    background: rgba(255, 255, 255, 0.08);
    font-size: 30px;
    cursor: pointer;
}

.modal-nav:disabled {
    opacity: 0.35;
    cursor: default;
}

.modal-meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    color: rgba(255, 255, 255, 0.82);
    font-size: 14px;
}

.close {
    justify-self: end;
    font-size: 42px;
    color: white;
    cursor: pointer;
    background: transparent;
    border: 0;
    line-height: 1;
}

body.modal-open {
    overflow: hidden;
}

@media (max-width: 1260px) {
    .control-panel {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    .summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .section-head,
    .table-toolbar,
    .pagination-bar {
        flex-direction: column;
        align-items: flex-start;
    }

    .control-panel {
        grid-template-columns: 1fr;
    }

    .table-shell {
        overflow-x: auto;
    }

    .inventory-table {
        min-width: 980px;
    }

    .image-gallery {
        width: 220px;
    }

    .modal-stage {
        grid-template-columns: 42px minmax(0, 1fr) 42px;
        gap: 10px;
    }

    .modal-nav {
        width: 42px;
        height: 42px;
        font-size: 24px;
    }
}

@media (max-width: 640px) {
    .summary-grid {
        grid-template-columns: 1fr;
    }

    .gallery-thumb {
        width: 52px;
        height: 52px;
    }

    .modal-meta {
        flex-direction: column;
        align-items: flex-start;
    }
}
