* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: #f5f7fb;
    color: #1f2937;
}

a {
    color: inherit;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 24px;
    background: #111827;
    color: #ffffff;
}

.brand a {
    font-weight: 700;
    font-size: 20px;
    text-decoration: none;
}

.nav {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.nav a {
    color: #ffffff;
    text-decoration: none;
    font-size: 14px;
}

.container {
    max-width: 1300px;
    margin: 0 auto;
    padding: 24px;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 20px;
}

.page-header h1 {
    margin: 0 0 6px;
    font-size: 28px;
}

.page-header p {
    margin: 0;
    color: #6b7280;
}

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

.card {
    background: #ffffff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
    margin-bottom: 18px;
}

.card h2 {
    margin-top: 0;
}

.button {
    display: inline-block;
    background: #2563eb;
    color: #ffffff;
    border: 0;
    padding: 10px 14px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 14px;
    cursor: pointer;
    white-space: nowrap;
}

.button.secondary {
    background: #6b7280;
}

.button.small {
    padding: 6px 10px;
    font-size: 12px;
}

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

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

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

th {
    color: #374151;
    background: #f9fafb;
}

.status {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 999px;
    background: #e5e7eb;
    color: #374151;
    font-size: 12px;
}

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

.full-span,
.form-section-heading {
    grid-column: 1 / -1;
}

.form-section-heading {
    margin: 10px 0 0;
    padding-top: 10px;
    border-top: 1px solid #e5e7eb;
}

label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-weight: 600;
    font-size: 14px;
}

input,
select,
textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font: inherit;
}

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

.checkbox-row input {
    width: auto;
}

.form-actions {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 10px;
}

.alert {
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 18px;
}

.alert.error {
    background: #fee2e2;
    color: #991b1b;
}

.alert.success {
    background: #dcfce7;
    color: #166534;
}

.footer {
    text-align: center;
    color: #6b7280;
    font-size: 13px;
    padding: 30px;
}

/* Batch/listing shell UI */
.listing-shell-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}

.listing-shell-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.listing-shell-card {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 14px;
    background: #ffffff;
}

.listing-title-first {
    font-weight: 700;
    font-size: 16px;
    margin-bottom: 4px;
}

.listing-sku-secondary {
    color: #6b7280;
    font-size: 13px;
    margin-bottom: 10px;
}

.listing-thumb-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(54px, 1fr));
    gap: 8px;
    margin-top: 10px;
}

.listing-thumb {
    position: relative;
    width: 54px;
    height: 54px;
    border-radius: 8px;
    overflow: hidden;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
}

.listing-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.listing-thumb span {
    position: absolute;
    left: 3px;
    bottom: 3px;
    background: rgba(17, 24, 39, 0.75);
    color: #ffffff;
    border-radius: 999px;
    padding: 1px 5px;
    font-size: 10px;
}

/* Manual photo grid */
.manual-photo-grid,
.unassigned-photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(105px, 1fr));
    gap: 10px;
    max-height: 520px;
    overflow-y: auto;
}

.manual-photo-card,
.unassigned-photo-card {
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 8px;
    background: #ffffff;
}

.manual-photo-card img,
.unassigned-photo-card img {
    width: 100%;
    height: 90px;
    object-fit: cover;
    border-radius: 8px;
    background: #f3f4f6;
}

/* Listing editor */
.editor-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 18px;
    align-items: start;
}

.editor-main {
    min-width: 0;
}

.editor-sidebar {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.profile-apply-panel {
    border: 1px solid #dbeafe;
    background: #eff6ff;
    padding: 14px;
    border-radius: 12px;
    margin-bottom: 16px;
}

.profile-summary {
    border: 1px solid #e5e7eb;
    background: #f9fafb;
    padding: 12px;
    border-radius: 10px;
    margin-bottom: 18px;
}

.summary-grid {
    display: grid;
    grid-template-columns: 160px minmax(0, 1fr);
    gap: 6px 12px;
    margin-top: 10px;
    font-size: 14px;
}

.summary-grid span:nth-child(odd) {
    color: #6b7280;
}

.help-text {
    color: #6b7280;
    font-size: 13px;
    line-height: 1.45;
}

.char-counter {
    color: #6b7280;
    font-size: 12px;
}

.char-counter.over-limit {
    color: #b91c1c;
    font-weight: 700;
}

.specifics-table {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.specifics-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 110px;
    gap: 8px;
    align-items: center;
}

.specifics-header {
    font-weight: 700;
    color: #374151;
    font-size: 13px;
}

.specific-required {
    flex-direction: row;
    align-items: center;
    font-weight: 400;
}

.specific-required input {
    width: auto;
}

.edit-photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(82px, 1fr));
    gap: 8px;
}

.edit-photo-card {
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 6px;
    background: #ffffff;
    font-size: 11px;
    color: #6b7280;
}

.edit-photo-card img {
    width: 100%;
    height: 76px;
    object-fit: cover;
    border-radius: 8px;
    background: #f3f4f6;
}

.validation-card ul {
    margin: 0;
    padding-left: 18px;
}

.validation-card li {
    margin-bottom: 6px;
}

.validation-card li.ok {
    color: #166534;
}

.validation-card li.warn {
    color: #b45309;
}

/* Working overlay */
.upload-working-overlay {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.86);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    color: #ffffff;
}

.upload-working-overlay.is-visible {
    display: flex;
}

.upload-working-card {
    background: #111827;
    border: 1px solid #374151;
    border-radius: 16px;
    padding: 24px;
    width: min(420px, calc(100% - 32px));
    text-align: center;
    box-shadow: 0 20px 50px rgba(0,0,0,.35);
}

.spinner {
    width: 42px;
    height: 42px;
    margin: 0 auto 14px;
    border: 4px solid #4b5563;
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

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

    .editor-sidebar {
        order: -1;
    }
}

@media (max-width: 760px) {
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

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

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

    .topbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
}


/* Package 4.5 Item Specifics UI */
.specifics-helper-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
    gap: 16px;
    align-items: start;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 14px;
}

.specific-template-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.enhanced-specifics {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
}

.enhanced-specifics .specifics-row {
    display: grid;
    grid-template-columns: minmax(170px, 1fr) minmax(220px, 1.4fr) 120px 90px;
    gap: 8px;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid #e5e7eb;
    background: #ffffff;
}

.enhanced-specifics .specifics-row:last-child {
    border-bottom: 0;
}

.enhanced-specifics .specifics-header {
    font-weight: 700;
    background: #f3f4f6;
    color: #374151;
}

.enhanced-specifics .specific-required {
    flex-direction: row;
    align-items: center;
    font-weight: 500;
}

@media (max-width: 900px) {
    .specifics-helper-panel {
        grid-template-columns: 1fr;
    }

    .specific-template-buttons {
        justify-content: flex-start;
    }

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

    .enhanced-specifics .specifics-header {
        display: none;
    }
}
