* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100vh;
    margin: 0;
    font-family: Arial, sans-serif;
    color: #1f2522;
    background: #f1f3ee;
}

body.modal-open {
    overflow: hidden;
}

a {
    color: inherit;
}

.top {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: #24322d;
    color: #fff;
}

.brand-link {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: #fff;
    text-decoration: none;
}

.brand-mark {
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
    border-radius: 8px;
}

.brand-name {
    font-size: 17px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0;
}

.top-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
}

.top-nav a {
    color: #fff;
    text-decoration: none;
    font-weight: 700;
}

.storage-pill {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    max-width: min(56vw, 620px);
    padding: 6px 9px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 12px;
    line-height: 1.25;
}

.storage-pill-detail {
    color: rgba(255, 255, 255, 0.78);
}

.task-import-files {
    margin: 12px 0;
}

.task-import-files ul {
    display: grid;
    gap: 6px;
    margin: 8px 0 0;
    padding-left: 20px;
}

.task-import-files li {
    line-height: 1.4;
}

.wrap {
    padding: 20px;
}

body.page-auth .wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 32px 20px;
}

.card {
    padding: 20px;
    border: 1px solid #d9e1db;
    border-radius: 6px;
    background: #fff;
    box-shadow: 0 12px 32px rgba(31, 37, 34, 0.08);
}

.form-card {
    max-width: 780px;
}

.login-card {
    width: min(100%, 420px);
    padding: 32px;
}

.login-brand {
    display: flex;
    justify-content: center;
    margin: 0 0 24px;
}

.login-brand img {
    display: block;
    width: min(100%, 220px);
    height: auto;
}

.login-title {
    margin: 0 0 24px;
    font-size: 30px;
    line-height: 1.1;
}

.alert {
    margin: 0 0 16px;
    padding: 12px 14px;
    border: 1px solid #e7b4b4;
    border-radius: 6px;
    background: #fff3f2;
    color: #982f2f;
}

.form-error {
    margin: 0 0 16px;
    color: #b00;
}

.form-stack {
    display: grid;
    gap: 16px;
}

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

.form-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.form-submit {
    margin-top: 12px;
}

.choice-list {
    display: grid;
    gap: 8px;
}

.choice-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 10px 12px;
    border: 1px solid #d9e1db;
    border-radius: 6px;
    background: #f8faf7;
    font-weight: 700;
}

.choice-item input[type="checkbox"] {
    width: auto;
    margin: 0;
}

.stack-top {
    margin-top: 10px;
}

.grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.task-view-header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px 14px;
    margin-bottom: 12px;
}

.task-view-header h2 {
    margin: 0;
}

.minor-link {
    color: #55645d;
    font-size: 13px;
    text-decoration: none;
}

.minor-link:hover {
    color: #24322d;
    text-decoration: underline;
}

label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 700;
    color: #32403a;
}

textarea,
input,
select {
    display: block;
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #c7d1cb;
    border-radius: 6px;
    background: #fff;
    color: #1f2522;
    font: inherit;
}

textarea {
    min-height: 120px;
    resize: vertical;
}

textarea:focus,
input:focus,
select:focus {
    outline: none;
    border-color: #2d6a57;
    box-shadow: 0 0 0 3px rgba(45, 106, 87, 0.16);
}

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

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

.toolbar-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

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

.inline-form label {
    margin: 0;
}

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

.table-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.table-filter-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0 0 0 10px;
    font-size: 13px;
}

.row-counts {
    margin-left: 10px;
}

.sku-search-input {
    width: 160px;
    padding: 4px 6px;
}

.compact-select {
    width: auto;
    min-width: 0;
    padding: 4px 6px;
}

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

th,
td {
    padding: 8px 10px;
    border-bottom: 1px solid #ddd;
    text-align: left;
    font-size: 14px;
}

.align-right {
    text-align: right;
}

.nowrap {
    white-space: nowrap;
}

.status {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
}

.status.pending {
    background: #ffe8a1;
    color: #5c4802;
}

.status.processing {
    background: #bfe3ff;
    color: #184f78;
}

.status.paused {
    background: #dfe6e2;
    color: #3d4b44;
}

.status.success,
.status.done {
    background: #c7f3c2;
    color: #225a2d;
}

.status.failed {
    background: #f8c2c2;
    color: #8a2222;
}

.status.expired {
    background: #e9d6c4;
    color: #7a4518;
}

.status.deleting {
    background: #d8d8d8;
    color: #4c4c4c;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 14px;
    border: 0;
    border-radius: 6px;
    background: #2d6a57;
    color: #fff;
    cursor: pointer;
    text-decoration: none;
    font: inherit;
    font-weight: 700;
    line-height: 1.2;
    appearance: none;
}

.btn:hover {
    background: #245645;
}

.btn-secondary {
    background: #4b5852;
}

.btn-secondary:hover {
    background: #3f4a45;
}

.btn-danger {
    background: #a63d3d;
}

.btn-danger:hover {
    background: #8d3232;
}

.btn-compact {
    padding: 6px 8px;
    font-size: 12px;
}

.row-actions-cell {
    width: 1%;
}

.task-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.task-row-link {
    cursor: pointer;
}

.task-row-link:hover td {
    background: #f7faf8;
}

.task-row-link:focus-visible td {
    outline: 2px solid #2d6a57;
    outline-offset: -2px;
    background: #f7faf8;
}

.preview-row {
    cursor: pointer;
}

.preview-row td {
    transition: background 0.15s ease;
}

.preview-row:hover td,
.preview-row:focus-visible td {
    background: #f5f8f3;
}

.preview-row:focus-visible {
    outline: none;
}

.preview-row:focus-visible td:first-child {
    box-shadow: inset 3px 0 0 #2d6a57;
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 14px;
}

.pagination a,
.pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    padding: 8px 10px;
    border: 1px solid #c7d1cb;
    border-radius: 6px;
    background: #fff;
    color: #1f2522;
    text-decoration: none;
    font-size: 13px;
}

.pagination .current {
    border-color: #24322d;
    background: #24322d;
    color: #fff;
}

.pagination .ellipsis {
    min-width: 0;
    padding: 0 2px;
    border: 0;
    background: transparent;
}

.muted {
    color: #66746e;
    font-size: 12px;
}

.sku-import {
    margin-top: 14px;
    padding: 14px;
    border: 1px dashed #c7d1cb;
    border-radius: 6px;
    background: #f8faf7;
}

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

.sku-import-button {
    position: relative;
    overflow: hidden;
}

.sku-import-button input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.sku-import-button.is-busy {
    pointer-events: none;
    opacity: 0.72;
}

.sku-import-column {
    margin-top: 12px;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(31, 37, 34, 0.52);
}

.modal-backdrop.is-open {
    display: flex;
}

.modal-card {
    width: min(100%, 420px);
}

.modal-title {
    margin: 0 0 10px;
    font-size: 24px;
    line-height: 1.15;
}

.modal-text {
    margin: 0 0 20px;
    color: #4b5852;
    line-height: 1.5;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.task-notice {
    margin: 0 0 16px;
    padding: 12px 14px;
    border: 1px solid #d9e1db;
    border-radius: 6px;
    line-height: 1.45;
}

.task-notice.info {
    background: #eef5f2;
    border-color: #cddbd3;
    color: #2d4a3d;
}

.task-notice.success {
    background: #edf7ec;
    border-color: #b8ddb2;
    color: #215a2d;
}

.task-notice.warn {
    background: #fff7e3;
    border-color: #ead39a;
    color: #775403;
}

.task-notice.error {
    background: #fff3f2;
    border-color: #e7b4b4;
    color: #982f2f;
}

.add-skus-modal-card {
    width: min(100%, 560px);
}

.add-skus-help {
    margin: 0 0 16px;
    color: #4b5852;
    line-height: 1.5;
}

.add-skus-field {
    margin-bottom: 16px;
}

.image-preview-modal {
    padding: 24px;
}

.image-preview-card {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: min(100%, 980px);
    max-height: min(90vh, 920px);
    padding: 20px;
}

.image-preview-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.image-preview-meta {
    color: #66746e;
    font-size: 13px;
}

.image-preview-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.image-preview-close {
    width: 40px;
    min-width: 40px;
    height: 40px;
    padding: 0;
    font-size: 24px;
    line-height: 1;
}

.image-preview-gallery {
    overflow: auto;
}

.image-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.image-preview-figure {
    margin: 0;
    overflow: hidden;
    border: 1px solid #d9e1db;
    border-radius: 6px;
    background: #f8faf7;
}

.image-preview-link {
    display: block;
    background: #fff;
}

.image-preview-link img {
    display: block;
    width: 100%;
    height: 220px;
    object-fit: contain;
    background: #fff;
}

.image-preview-figure figcaption {
    padding: 10px;
    color: #4b5852;
    font-size: 12px;
    line-height: 1.4;
    word-break: break-word;
}

.image-preview-green-name,
.image-preview-alt-name {
    display: block;
    margin-top: 4px;
    color: #16883a;
    font-weight: 700;
}

.image-preview-green-name {
    margin-top: 0;
}

.image-preview-empty {
    padding: 24px;
    color: #66746e;
    text-align: center;
}

#sku-grid,
#logs-grid {
    scroll-margin-top: 14px;
}

@media (max-width: 720px) {
    .wrap {
        padding: 16px;
    }

    .top {
        padding: 12px 16px;
    }

    .top-nav {
        width: 100%;
        justify-content: flex-start;
    }

    .storage-pill {
        max-width: 100%;
    }

    body.page-auth .wrap {
        padding: 20px 16px;
    }

    .login-card {
        padding: 24px 20px;
    }

    .login-brand {
        margin-bottom: 20px;
    }

    .login-brand img {
        width: min(100%, 190px);
    }

    .login-title {
        font-size: 26px;
    }

    .table-controls {
        align-items: stretch;
    }

    .row-counts,
    .table-filter-label {
        margin-left: 0;
    }

    .table-filter-label {
        width: 100%;
        justify-content: space-between;
    }

    .sku-search-input,
    .compact-select {
        width: 100%;
    }

    .modal-actions {
        flex-direction: column-reverse;
    }

    .modal-actions .btn {
        width: 100%;
    }

    .image-preview-modal {
        padding: 16px;
    }

    .image-preview-card {
        width: 100%;
        padding: 16px;
    }

    .image-preview-head {
        align-items: center;
    }

    .image-preview-grid {
        grid-template-columns: 1fr;
    }

    .image-preview-link img {
        height: 200px;
    }
}
