/* Product Page Styles */

.product-main {
    display: grid;
    grid-template-columns: minmax(320px, 1.1fr) minmax(300px, 0.9fr);
    grid-template-rows: auto auto auto auto auto;
    grid-template-areas:
        "title title"
        "images sections"
        "details sections"
        "links store"
        "notes retailers";
    gap: 14px;
    padding: 12px;
    overflow: auto;
    min-width: 0;
    height: 100%;
    font-size: 13px;
    box-sizing: border-box;
    background: #f5f6f8;
    color: #111111;
}

.product-title-row {
    grid-area: title;
    grid-column: 1 / -1;
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 16px;
    padding: 4px 2px 2px;
}

.product-title-row h2 {
    font-size: clamp(20px, 2vw, 30px);
    line-height: 1.15;
    color: #111111;
    overflow-wrap: anywhere;
}

.product-eyebrow {
    margin-bottom: 5px;
    color: #6b7280;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.product-title-row .inventory-action {
    flex-shrink: 0;
    margin: 0;
}

@media (max-width: 1200px) {
    .product-main {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto auto auto auto auto auto;
        grid-template-areas:
            "title"
            "images"
            "details"
            "notes"
            "sections"
            "links"
            "store"
            "retailers";
        padding: 16px;
    }
}

@media (max-width: 800px) {
    .product-main {
        margin-top: 0;
        height: 100%;
        gap: 10px;
        padding: 10px;
    }
}

.product-section {
    min-width: 0;
    min-height: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
    overflow: hidden;
}

.images-section,
.sections-grid,
.details-grid,
.links-section,
.notes-block,
.store-manager-section,
.retailers-section {
    background: #ffffff;
    border: 1px solid #e4e7ec;
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

.retailers-grid {
    min-width: 0;
}


/* Remove any remaining color blocks */
.product-section {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
}

.product-section h3,
.links-section h3,
.retailers-section h3 {
    font-size: 14px;
    font-weight: 700;
    margin-top: 0;
    margin-bottom: 14px;
    color: #111111;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    border-bottom: 1px solid #e6e6e6;
    padding-bottom: 8px;
}

/* Images & Basic Info */
.images-section {
    display: grid;
    grid-template-columns: 140px minmax(0, 1fr);
    gap: 14px;
    grid-area: images;
    background: #ffffff;
    padding: 16px;
    border: 1px solid #e4e7ec;
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
    align-items: start;
}

.image-gallery {
    display: flex;
    flex-direction: column;
    gap: 0;
    justify-content: flex-start;
}

.main-image {
    width: 140px;
    height: 140px;
    background: #f6f6f6;
    border: 1px solid #e6e6e6;
    border-radius: 8px;
    object-fit: cover;
    cursor: pointer;
}

.image-thumbs {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.image-thumbs img {
    width: 30px;
    height: 30px;
    background: #f6f6f6;
    border: 1px solid #e6e6e6;
    border-radius: 8px;
    cursor: pointer;
    object-fit: cover;
}

.basic-info-box {
    display: flex;
    flex-direction: column;
    gap: 8px;
    justify-content: flex-start;
    align-items: flex-start;
}

.field-row {
    display: grid;
    grid-template-columns: 150px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    font-size: 12px;
    line-height: 1.4;
    margin-bottom: 8px;
    width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
    padding: 0 0 10px 0;
    border-bottom: 1px solid #f2f2f2;
}

.field-row label {
    font-weight: 700;
    color: #4c4c4c;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
    padding-right: 8px;
    line-height: 1.4;
    padding-top: 1px;
}

.field-row span,
.field-row code {
    display: block;
    min-width: 0;
    overflow-wrap: anywhere;
    white-space: normal;
    word-break: break-word;
    line-height: 1.4;
    padding: 0;
    color: #111111;
}

.copy-field {
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 2px;
    transition: background 0.1s ease;
}

.copy-field:hover {
    color: #846de7 !important;
    background: transparent;
}

/* Sections Grid (2 column layout for Pricing & Selling) */
.sections-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    grid-area: sections;
    min-height: 0;
    overflow: visible;
    align-content: start;
}

/* Details Grid (3 column layout) */
.details-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    grid-area: details;
    min-height: 0;
    overflow: visible;
    padding-right: 4px;
    align-content: start;
}

/* Links Section */
.links-section {
    background: #ffffff;
    border: 1px solid #e4e7ec;
    border-radius: 8px;
    padding: 16px;
    grid-area: links;
    min-height: 0;
    overflow: visible;
}

.store-manager-section {
    background: #ffffff;
    border: 1px solid #e4e7ec;
    border-radius: 8px;
    padding: 16px;
    grid-area: store;
    min-height: 0;
    display: grid;
    grid-template-rows: auto 1fr;
    gap: 10px;
    overflow: visible;
}

.store-manager-body {
    display: grid;
    gap: 12px;
    min-height: 0;
    overflow: hidden;
}

.store-form {
    display: grid;
    grid-template-columns: 1fr 1.2fr 1fr auto;
    gap: 8px;
    align-items: end;
    min-height: 0;
}

.store-form label {
    display: grid;
    gap: 4px;
    font-size: 10px;
    color: #7a7a7a;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.store-form input {
    width: 100%;
    background: #ffffff;
    border: 1px solid #e6e6e6;
    border-radius: 10px;
    color: #111111;
    padding: 12px;
    font-size: 12px;
}

.store-table-wrapper {
    max-height: 210px;
    overflow: auto;
    background: transparent;
    border: none;
}

.store-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 0;
}

.store-table th,
.store-table td {
    padding: 10px 8px;
    border-bottom: 1px solid #e6e6e6;
    font-size: 12px;
    color: #111111;
    word-break: break-word;
}

.store-table th {
    color: #666;
    font-weight: 700;
    text-transform: uppercase;
}

.store-table tbody tr:hover {
    background: #fafafa;
}

.store-table a {
    color: #88ccff;
    text-decoration: none;
}

.store-table button {
    background: #f4f4f4;
    border: 1px solid #dcdcdc;
    border-radius: 4px;
    color: #111111;
    padding: 6px 8px;
    font-size: 11px;
    cursor: pointer;
}

.notes-block {
    background: #ffffff;
    border: 1px solid #e4e7ec;
    border-radius: 8px;
    padding: 16px;
    grid-area: notes;
    min-height: 0;
    overflow: hidden;
}

.notes-block h4 {
    font-size: 12px;
    color: #111111;
    margin: 0 0 10px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.notes-field {
    width: 100%;
    height: 110px;
    background: #fafafa;
    color: #111111;
    border: 1px solid #dcdcdc;
    border-radius: 6px;
    padding: 10px;
    font-family: 'Open Sans', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
    font-size: 12px;
    resize: none;
}

.links-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    align-items: stretch;
    overflow: visible;
}

@media (max-width: 1100px) {
    .links-grid {
        grid-template-columns: repeat(5, minmax(120px, 1fr));
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
    }

    .link-item {
        min-width: 110px;
        scroll-snap-align: start;
    }
}

@media (max-width: 800px) {
    .links-grid {
        grid-auto-flow: column;
        grid-auto-columns: minmax(100px, 1fr);
        grid-template-columns: none;
        gap: 8px;
        overflow-x: auto;
        padding-bottom: 4px;
    }

    .link-item {
        min-width: 95px;
    }
}

.link-item {
    background: transparent;
    border: none;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.link-item label {
    font-size: 10px;
    color: #aaa;
    text-transform: uppercase;
}

.link-item {
    display: grid;
    grid-template-rows: auto auto;
    gap: 6px;
    padding: 8px 0;
}

.link-item label {
    font-weight: 600;
    color: #aaa;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.link-btn, .quick-link {
    background: #ffffff;
    color: #111111;
    border: 1px solid #e6e6e6;
    padding: 10px 12px;
    border-radius: 999px;
    font-size: 12px;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    font-weight: 600;
}

.link-btn:hover, .quick-link:hover {
    background: #f0f0f0;
    border-color: #dcdcdc;
}

.link-btn {
    display: inline-block;
}

/* Notes */
.notes-field {
    width: 100%;
    height: 60px;
    background: #ffffff;
    color: #111111;
    border: 1px solid #e6e6e6;
    border-radius: 12px;
    padding: 12px;
    font-family: 'Open Sans', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
    font-size: 12px;
    resize: none;
    line-height: 1.4;
}

/* Retailers Section */
.retailers-section {
    background: #ffffff;
    border: 1px solid #e4e7ec;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 0;
    grid-area: retailers;
    overflow: visible;
}

.retailers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
}

.retailer-card {
    background: transparent;
    border: none;
    padding: 10px 0;
    font-size: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: none;
}

.retailer-card:hover {
    background: #fafafa;
}

body.light-mode .product-main {
    background: #f5f6f8;
}

body:not(.light-mode) .product-main {
    background: #131722;
    color: #f3f4f6;
}

body:not(.light-mode) .product-title-row h2 {
    color: #f3f4f6;
}

body:not(.light-mode) .product-eyebrow {
    color: #9ca3af;
}

.inventory-action:disabled {
    cursor: default;
    opacity: 0.65;
}

body:not(.light-mode) .images-section,
body:not(.light-mode) .sections-grid,
body:not(.light-mode) .details-grid,
body:not(.light-mode) .links-section,
body:not(.light-mode) .notes-block,
body:not(.light-mode) .store-manager-section,
body:not(.light-mode) .retailers-section {
    background: #0f0f0f;
    border-color: #242936;
}

body:not(.light-mode) .product-section h3,
body:not(.light-mode) .links-section h3,
body:not(.light-mode) .retailers-section h3,
body:not(.light-mode) .notes-block h4,
body:not(.light-mode) .field-row label,
body:not(.light-mode) .field-row span,
body:not(.light-mode) .field-row code,
body:not(.light-mode) .retailer-header h4,
body:not(.light-mode) .store-table td {
    color: #f3f4f6;
}

body:not(.light-mode) .field-row,
body:not(.light-mode) .retailer-header,
body:not(.light-mode) .store-table th,
body:not(.light-mode) .store-table td {
    border-color: #242936;
}

body:not(.light-mode) .store-form input,
body:not(.light-mode) .notes-field,
body:not(.light-mode) .link-btn {
    background: #171b24;
    border-color: #303746;
    color: #f3f4f6;
}

body.light-mode .images-section,
body.light-mode .sections-grid,
body.light-mode .details-grid,
body.light-mode .links-section,
body.light-mode .notes-block,
body.light-mode .store-manager-section,
body.light-mode .retailers-section {
    background: #ffffff;
    border-color: #e1e5eb;
}

/* Product detail layout */
.product-main {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 20px;
    overflow: auto;
    background: #131722;
}

.product-title-row,
.images-section,
.sections-grid,
.details-grid,
.links-section,
.notes-block,
.store-manager-section,
.retailers-section {
    width: 100%;
    flex: 0 0 auto;
}

.product-title-row {
    align-items: center;
    padding: 2px 4px;
}

.images-section {
    display: grid;
    grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
    gap: 24px;
    padding: 20px;
}

.image-gallery {
    align-items: center;
}

.main-image {
    width: min(100%, 260px);
    height: 260px;
    object-fit: contain;
}

.basic-info-box {
    width: 100%;
}

.sections-grid,
.details-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    padding: 20px;
}

.details-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.sections-grid > .product-section,
.details-grid > .product-section {
    min-width: 0;
    padding: 0;
}

.more-info-heading {
    margin: 4px 4px -2px;
    color: #f3f4f6;
    font-size: 14px;
    letter-spacing: .6px;
    text-transform: uppercase;
}

.field-row {
    grid-template-columns: minmax(110px, 150px) minmax(0, 1fr);
}

.links-section,
.notes-block,
.store-manager-section,
.retailers-section {
    padding: 20px;
}

html.light-mode .more-info-heading {
    color: #18202b;
}

html.light-mode body .product-main {
    background: #f5f6f8;
}

@media (max-width: 800px) {
    .product-main {
        padding: 12px;
        gap: 12px;
    }

    .product-title-row {
        align-items: flex-start;
        flex-direction: column;
        padding: 0;
    }

    .product-title-row .inventory-action {
        width: 100%;
    }

    .images-section,
    .sections-grid,
    .details-grid,
    .links-section,
    .notes-block,
    .store-manager-section,
    .retailers-section {
        padding: 14px;
    }

    .images-section,
    .sections-grid,
    .details-grid {
        grid-template-columns: 1fr;
    }

    .main-image {
        width: 220px;
        height: 220px;
    }
}

.retailer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: 8px;
}

.retailer-header h4 {
    font-size: 12px;
    font-weight: 700;
    color: #111111;
    margin: 0;
}

.retailer-link {
    color: #1a73e8;
    border: none;
    padding: 0;
    font-size: 12px;
    text-decoration: none;
    transition: color 0.1s ease;
    white-space: nowrap;
}

.retailer-link:hover {
    color: #174ea6;
}

.retailer-field {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 6px;
    min-height: 18px;
    flex-wrap: wrap;
}

.retailer-field label {
    font-weight: 600;
    color: #888;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.2px;
    min-width: 70px;
    margin-right: 8px;
    white-space: nowrap;
}

.retailer-field code {
    background: transparent;
    color: #111111;
    padding: 0;
    border-radius: 0;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    cursor: pointer;
    flex: 1;
    overflow-wrap: anywhere;
    word-break: break-all;
    white-space: normal;
    transition: none;
}

.retailer-field code:hover {
    background: #f6f6f6;
}

.retailer-footer {
    border-top: 1px solid #e6e6e6;
    padding-top: 6px;
    text-align: center;
    color: #666;
    font-size: 10px;
}

/* Responsive adjustments */
@media (max-width: 1600px) {
    .links-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .details-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .retailers-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    }
}

@media (max-width: 1400px) {
    .links-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .details-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .retailers-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }

    .product-section h3 {
        font-size: 12px;
    }

    .field-row {
        font-size: 12px;
    }

    .field-row label {
        font-size: 11px;
    }
}

@media (max-width: 1200px) {
    .links-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .details-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .retailers-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }

    .product-main {
        padding: 10px;
        gap: 10px;
    }

    .product-section {
        padding: 10px;
    }

    .images-section,
    .sections-grid,
    .details-grid,
    .links-section,
    .notes-block,
    .store-manager-section,
    .retailers-section {
        padding: 12px;
    }

    .sections-grid,
    .details-grid {
        grid-template-columns: 1fr;
    }

    .images-section {
        grid-template-columns: 110px 1fr;
        gap: 8px;
        padding: 8px;
        align-items: center;
    }

    .main-image {
        width: 110px;
        height: 110px;
        flex-shrink: 0;
    }

    .basic-info-box {
        gap: 8px;
        justify-content: flex-start;
        align-items: flex-start;
    }

    .field-row {
        font-size: 11px;
        gap: 6px;
        line-height: 1.4;
        grid-template-columns: 190px minmax(0, 1fr);
    }

    .field-row label {
        font-size: 10px;
    }

    .sections-grid {
        gap: 10px;
    }

    .details-grid {
        gap: 10px;
    }

    .links-section {
        padding: 10px;
    }

    .links-grid {
        gap: 6px;
    }

    .link-item label {
        font-size: 10px;
    }

    .link-btn, .quick-link {
        font-size: 10px;
        padding: 5px 6px;
    }

    .notes-field {
        height: 55px;
        font-size: 11px;
        padding: 6px;
    }

    .retailers-section {
        padding: 10px;
    }

    .retailers-grid {
        gap: 8px;
    }

    .retailer-card {
        padding: 8px;
        gap: 6px;
    }

    .retailer-header h4 {
        font-size: 11px;
    }

    .retailer-link {
        font-size: 9px;
        padding: 2px 5px;
    }

    .retailer-field label {
        font-size: 10px;
        min-width: 65px;
    }

    .retailer-field code {
        font-size: 10px;
        padding: 2px 5px;
    }

    .retailer-footer {
        font-size: 9px;
    }
}

@media (max-width: 1000px) {
    .sections-grid {
        grid-template-columns: 1fr;
    }

    .details-grid {
        grid-template-columns: 1fr;
    }

    .links-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .retailers-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }

    .product-main {
        padding: 8px;
        gap: 8px;
    }

    .product-section {
        padding: 8px;
    }

    .images-section {
        grid-template-columns: 90px 1fr;
        gap: 6px;
        padding: 6px;
        align-items: center;
    }

    .main-image {
        width: 90px;
        height: 90px;
        flex-shrink: 0;
    }

    .basic-info-box {
        gap: 8px;
        justify-content: flex-start;
        align-items: flex-start;
    }

    .field-row {
        font-size: 10px;
        gap: 4px;
        line-height: 1.4;
        grid-template-columns: 160px minmax(0, 1fr);
        min-height: 18px;
    }

    .field-row label {
        font-size: 9px;
    }

    .sections-grid {
        gap: 8px;
    }

    .details-grid {
        gap: 8px;
    }

    .links-section {
        padding: 8px;
    }

    .links-grid {
        gap: 5px;
    }

    .link-item label {
        font-size: 9px;
    }

    .link-btn, .quick-link {
        font-size: 9px;
        padding: 4px 5px;
    }

    .notes-field {
        height: 50px;
        font-size: 10px;
        padding: 5px;
    }

    .retailers-section {
        padding: 8px;
    }

    .retailers-grid {
        gap: 6px;
    }

    .retailer-card {
        padding: 6px;
        gap: 5px;
    }

    .retailer-header h4 {
        font-size: 10px;
    }

    .retailer-link {
        font-size: 8px;
        padding: 2px 4px;
    }

    .retailer-field label {
        font-size: 9px;
        min-width: 60px;
    }

    .retailer-field code {
        font-size: 9px;
        padding: 2px 4px;
    }

    .retailer-footer {
        font-size: 8px;
    }
}

@media (max-width: 800px) {
    .product-main {
        padding: 6px;
        gap: 6px;
    }

    .product-section {
        padding: 6px;
    }

    .images-section {
        grid-template-columns: 80px 1fr;
        gap: 5px;
        padding: 5px;
        align-items: center;
    }

    .main-image {
        width: 80px;
        height: 80px;
        flex-shrink: 0;
    }

    .basic-info-box {
        gap: 6px;
        justify-content: flex-start;
        align-items: flex-start;
    }

    .field-row {
        grid-template-columns: 140px 1fr;
        gap: 3px;
        font-size: 9px;
        line-height: 1.4;
        min-height: 17px;
    }

    .field-row label {
        font-size: 8px;
    }

    .sections-grid {
        gap: 6px;
    }

    .details-grid {
        gap: 6px;
    }

    .links-section {
        padding: 6px;
    }

    .links-grid {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .link-item {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .link-item label {
        font-size: 8px;
        margin-bottom: 0;
    }

    .link-btn, .quick-link {
        font-size: 8px;
        padding: 3px 4px;
        min-width: 60px;
    }

    .notes-field {
        height: 45px;
        font-size: 9px;
        padding: 4px;
    }

    .retailers-section {
        padding: 6px;
    }

    .retailers-grid {
        grid-template-columns: 1fr;
        gap: 5px;
    }

    .retailer-card {
        padding: 5px;
        gap: 4px;
    }

    .retailer-header {
        padding-bottom: 6px;
    }

    .retailer-header h4 {
        font-size: 9px;
    }

    .retailer-link {
        font-size: 7px;
        padding: 1px 3px;
    }

    .retailer-field {
        gap: 4px;
    }

    .retailer-field label {
        font-size: 8px;
        min-width: 55px;
    }

    .retailer-field code {
        font-size: 8px;
        padding: 1px 3px;
    }

    .retailer-footer {
        font-size: 7px;
        padding-top: 4px;
    }
}

@media (max-width: 600px) {
    .product-main {
        padding: 4px;
        gap: 4px;
    }

    .product-section {
        padding: 4px;
    }

    .images-section {
        grid-template-columns: 70px 1fr;
        gap: 4px;
        padding: 4px;
        align-items: center;
    }

    .main-image {
        width: 70px;
        height: 70px;
        flex-shrink: 0;
    }

    .basic-info-box {
        gap: 4px;
        justify-content: flex-start;
        align-items: flex-start;
    }

    .field-row {
        grid-template-columns: 130px 1fr;
        gap: 2px;
        font-size: 8px;
        line-height: 1.4;
        min-height: 16px;
    }

    .field-row label {
        font-size: 7px;
    }

    .sections-grid {
        gap: 4px;
    }

    .details-grid {
        gap: 4px;
    }

    .links-section {
        padding: 4px;
    }

    .links-grid {
        gap: 3px;
    }

    .link-item label {
        font-size: 7px;
    }

    .link-btn, .quick-link {
        font-size: 7px;
        padding: 2px 3px;
        min-width: 50px;
    }

    .notes-field {
        height: 40px;
        font-size: 8px;
        padding: 3px;
    }

    .retailers-section {
        padding: 4px;
    }

    .retailers-grid {
        gap: 4px;
    }

    .retailer-card {
        padding: 4px;
        gap: 3px;
    }

    .retailer-header h4 {
        font-size: 8px;
    }

    .retailer-link {
        font-size: 6px;
        padding: 1px 2px;
    }

    .retailer-field label {
        font-size: 7px;
        min-width: 50px;
    }

    .retailer-field code {
        font-size: 7px;
        padding: 1px 2px;
    }

    .retailer-footer {
        font-size: 6px;
        padding-top: 3px;
    }
}

@media (max-width: 400px) {
    .product-main {
        padding: 3px;
        gap: 3px;
    }

    .product-section {
        padding: 3px;
    }

    .images-section {
        grid-template-columns: 60px 1fr;
        gap: 3px;
        padding: 3px;
        align-items: center;
    }

    .main-image {
        width: 60px;
        height: 60px;
        flex-shrink: 0;
    }

    .basic-info-box {
        gap: 3px;
        justify-content: flex-start;
        align-items: flex-start;
    }

    .field-row {
        grid-template-columns: 120px 1fr;
        gap: 2px;
        font-size: 7px;
        line-height: 1.4;
        min-height: 15px;
    }

    .field-row label {
        font-size: 6px;
    }

    .sections-grid {
        gap: 3px;
    }

    .details-grid {
        gap: 3px;
    }

    .links-section {
        padding: 3px;
    }

    .links-grid {
        gap: 2px;
    }

    .link-item label {
        font-size: 6px;
    }

    .link-btn, .quick-link {
        font-size: 6px;
        padding: 1px 2px;
        min-width: 40px;
    }

    .notes-field {
        height: 35px;
        font-size: 7px;
        padding: 2px;
    }

    .retailers-section {
        padding: 3px;
    }

    .retailers-grid {
        gap: 3px;
    }

    .retailer-card {
        padding: 3px;
        gap: 2px;
    }

    .retailer-header h4 {
        font-size: 7px;
    }

    .retailer-link {
        font-size: 5px;
        padding: 1px 2px;
    }

    .retailer-field label {
        font-size: 6px;
        min-width: 45px;
    }

    .retailer-field code {
        font-size: 6px;
        padding: 1px 2px;
    }

    .retailer-footer {
        font-size: 5px;
        padding-top: 2px;
    }
}

/* Keep product data readable on short inventory screens. */
.product-main {
    max-height: none;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.product-main .field-row,
.product-main .field-row label,
.product-main .field-row span,
.product-main .field-row code {
    font-size: 12px;
    line-height: 1.35;
}

.product-main .field-row {
    grid-template-columns: minmax(110px, 150px) minmax(0, 1fr);
    margin-bottom: 5px;
    padding-bottom: 6px;
}

.product-main .product-data-box {
    min-width: 0;
}

@media (max-width: 800px) {
    .product-main .field-row {
        grid-template-columns: minmax(90px, 120px) minmax(0, 1fr);
    }
}

/* Final product layout override */
.product-main {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 20px;
    overflow: auto;
}

.product-main > * {
    flex: 0 0 auto;
    width: 100%;
}

.product-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 2px 4px;
}

.images-section {
    display: grid;
    grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
    gap: 24px;
    padding: 20px;
}

.main-image {
    width: min(100%, 260px);
    height: 260px;
    object-fit: contain;
}

.sections-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    padding: 20px;
}

.details-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    padding: 20px;
}

.field-row {
    grid-template-columns: minmax(110px, 150px) minmax(0, 1fr);
}

@media (max-width: 800px) {
    .product-main { padding: 12px; gap: 12px; }
    .product-title-row { align-items: flex-start; flex-direction: column; padding: 0; }
    .product-title-row .inventory-action { width: 100%; }
    .images-section,
    .sections-grid,
    .details-grid { grid-template-columns: 1fr; padding: 14px; }
    .main-image { width: 220px; height: 220px; }
}

/* Compact imported-product view */
.product-main {
    gap: 10px;
    padding: 12px;
    overflow: hidden;
}

.product-title-row {
    min-height: 42px;
}

.product-title-row h2 {
    font-size: 22px;
}

.images-section {
    grid-template-columns: 190px minmax(0, 1fr);
    gap: 16px;
    padding: 12px;
}

.main-image {
    width: 180px;
    height: 180px;
}

.field-row {
    gap: 8px;
    margin-bottom: 4px;
    padding-bottom: 5px;
    font-size: 11px;
}

.field-row label {
    font-size: 10px;
}

.sections-grid,
.details-grid,
.links-section,
.notes-block {
    padding: 12px;
    gap: 10px;
}

.store-manager-section,
.retailers-section,
.is-empty-section {
    display: none;
}

.notes-field {
    height: 42px;
}

@media (max-width: 800px) {
    .product-main {
        gap: 8px;
        padding: 8px;
    }

    .product-title-row h2 {
        font-size: 18px;
    }

    .images-section {
        grid-template-columns: 132px minmax(0, 1fr);
        gap: 10px;
        padding: 10px;
    }

    .main-image {
        width: 124px;
        height: 124px;
    }

    .field-row {
        grid-template-columns: 88px minmax(0, 1fr);
        font-size: 10px;
    }

    .field-row label {
        font-size: 8px;
    }

    .sections-grid,
    .details-grid,
    .links-section,
    .notes-block {
        padding: 9px;
    }

    .sections-grid,
    .details-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-height: 700px) {
    .product-main { gap: 6px; padding: 8px; }
    .product-title-row { min-height: 32px; }
    .product-title-row h2 { font-size: 17px; }
    .images-section { grid-template-columns: 110px minmax(0, 1fr); padding: 8px; }
    .main-image { width: 102px; height: 102px; }
    .field-row { margin-bottom: 2px; padding-bottom: 3px; }
}

.product-data-box {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 16px;
    width: 100%;
    padding: 16px;
    background: #0f0f0f;
    border: 1px solid #242936;
    border-radius: 8px;
}

html.light-mode .product-data-box,
body.light-mode .product-data-box {
    background: #ffffff;
    border-color: #e1e5eb;
}

.product-data-box .sections-grid,
.product-data-box .details-grid {
    display: contents;
}

.product-data-box > .sections-grid > .product-section,
.product-data-box > .details-grid > .product-section {
    min-width: 0;
    align-self: start;
    padding: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
}

.identifier-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.identifier-field {
    min-width: 0;
}

.identifier-field label,
.identifier-field span {
    display: block;
}

.images-section .field-row {
    margin-bottom: 2px;
    padding-bottom: 0;
    border-bottom: 0;
}

.duplicate-ean-row { display: none; }

@media (max-width: 800px) {
    .product-data-box {
        grid-template-columns: 1fr;
        gap: 10px;
        padding: 10px;
    }

    .product-data-box .sections-grid,
    .product-data-box .details-grid {
        grid-column: 1;
    }
}

/* Desktop product layout with a usable right column */
.product-main {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(300px, .85fr);
    grid-template-rows: auto auto auto auto;
    grid-template-areas:
        "title title"
        "images sections"
        "details sections"
        "links notes";
    align-content: start;
    gap: 12px;
    overflow: auto;
}

.product-main > * {
    width: auto;
}

.product-title-row { grid-area: title; }
.images-section { grid-area: images; }
.sections-grid { grid-area: sections; }
.details-grid { grid-area: details; }
.links-section { grid-area: links; }
.notes-block { grid-area: notes; }

.sections-grid,
.details-grid {
    align-self: start;
}

@media (max-width: 1100px) {
    .product-main {
        grid-template-columns: minmax(0, 1fr) minmax(260px, .8fr);
    }

    .images-section {
        grid-template-columns: 150px minmax(0, 1fr);
    }

    .main-image {
        width: 140px;
        height: 140px;
    }
}

@media (max-width: 800px) {
    .product-main {
        display: flex;
        flex-direction: column;
        overflow: auto;
    }

    .product-main > * {
        width: 100%;
    }

    .images-section,
    .sections-grid,
    .details-grid {
        grid-template-columns: 1fr;
    }
}

/* Very large screens */
@media (min-width: 1800px) {
    .product-main {
        padding: 16px;
        gap: 14px;
    }

    .product-section {
        padding: 14px;
    }

    .images-section {
        grid-template-columns: 140px 1fr;
        gap: 14px;
    }

    .main-image {
        width: 140px;
        height: 140px;
    }

    .basic-info-box {
        gap: 8px;
        justify-content: flex-start;
        align-items: flex-start;
    }

    .field-row {
        font-size: 14px;
        gap: 8px;
        line-height: 1.4;
        grid-template-columns: 200px minmax(0, 1fr);
    }

    .field-row label {
        font-size: 13px;
    }

    .sections-grid {
        gap: 14px;
    }

    .details-grid {
        gap: 14px;
    }

    .links-section {
        padding: 14px;
    }

    .links-grid {
        gap: 8px;
    }

    .link-item label {
        font-size: 12px;
    }

    .link-btn, .quick-link {
        font-size: 12px;
        padding: 7px 9px;
    }

    .notes-field {
        height: 70px;
        font-size: 13px;
        padding: 9px;
    }

    .retailers-section {
        padding: 14px;
    }

    .retailers-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 12px;
    }

    .retailer-card {
        padding: 11px;
        gap: 8px;
    }

    .retailer-header h4 {
        font-size: 13px;
    }

    .retailer-link {
        font-size: 11px;
        padding: 3px 7px;
    }

    .retailer-field label {
        font-size: 12px;
        min-width: 75px;
    }

    .retailer-field code {
        font-size: 12px;
        padding: 3px 7px;
    }

    .retailer-footer {
        font-size: 11px;
    }
}

/* Ultra-wide screens */
@media (min-width: 2200px) {
    .product-main {
        padding: 20px;
        gap: 16px;
    }

    .product-section {
        padding: 16px;
    }

    .images-section {
        grid-template-columns: 160px 1fr;
        gap: 16px;
    }

    .main-image {
        width: 160px;
        height: 160px;
    }

    .basic-info-box {
        gap: 8px;
        justify-content: flex-start;
        align-items: flex-start;
    }

    .field-row {
        font-size: 15px;
        gap: 10px;
        line-height: 1.4;
        grid-template-columns: 220px minmax(0, 1fr);
    }

    .field-row label {
        font-size: 14px;
    }

    .sections-grid {
        gap: 16px;
    }

    .details-grid {
        gap: 16px;
    }

    .links-section {
        padding: 16px;
    }

    .links-grid {
        gap: 10px;
    }

    .link-item label {
        font-size: 13px;
    }

    .link-btn, .quick-link {
        font-size: 13px;
        padding: 8px 10px;
    }

    .notes-field {
        height: 80px;
        font-size: 14px;
        padding: 10px;
    }

    .retailers-section {
        padding: 16px;
    }

    .retailers-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 14px;
    }

    .retailer-card {
        padding: 12px;
        gap: 9px;
    }

    .retailer-header h4 {
        font-size: 14px;
    }

    .retailer-link {
        font-size: 12px;
        padding: 4px 8px;
    }

    .retailer-field label {
        font-size: 13px;
        min-width: 80px;
    }

    .retailer-field code {
        font-size: 13px;
        padding: 4px 8px;
    }

    .retailer-footer {
        font-size: 12px;
    }
}

/* High DPI screens */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .product-section {
        border-width: 1px;
    }

    .main-image {
        border-width: 1px;
    }

    .retailer-card {
        border-width: 1px;
    }

    .link-btn, .quick-link {
        border-width: 1px;
    }

    .notes-field {
        border-width: 1px;
    }
}

/* Landscape orientation on small screens */
@media (max-height: 500px) and (orientation: landscape) {
    .product-main {
        padding: 3px;
        gap: 3px;
    }

    .product-section {
        padding: 3px;
    }

    .images-section {
        grid-template-columns: 60px 1fr;
        gap: 3px;
    }

    .main-image {
        width: 60px;
        height: 60px;
    }

    .basic-info-box {
        gap: 1px;
    }

    .field-row {
        grid-template-columns: 60px 1fr;
        gap: 2px;
        font-size: 6px;
    }

    .field-row label {
        font-size: 5px;
    }

    .sections-grid {
        gap: 3px;
    }

    .details-grid {
        gap: 3px;
    }

    .links-section {
        padding: 3px;
    }

    .links-grid {
        gap: 2px;
    }

    .link-item label {
        font-size: 5px;
    }

    .link-btn, .quick-link {
        font-size: 5px;
        padding: 1px 2px;
        min-width: 35px;
    }

    .notes-field {
        height: 30px;
        font-size: 6px;
        padding: 2px;
    }

    .retailers-section {
        padding: 3px;
    }

    .retailers-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 3px;
    }

    .retailer-card {
        padding: 2px;
        gap: 2px;
    }

    .retailer-header h4 {
        font-size: 6px;
    }

    .retailer-link {
        font-size: 5px;
        padding: 1px 2px;
    }

    .retailer-field label {
        font-size: 5px;
        min-width: 35px;
    }

    .retailer-field code {
        font-size: 5px;
        padding: 1px 2px;
    }

    .retailer-footer {
        font-size: 5px;
        padding-top: 2px;
    }
}
