:root {
    color-scheme: light;
    --bg: #f3f6fa;
    --surface: #ffffff;
    --text: #142033;
    --muted: #667085;
    --border: #d9e2ee;
    --primary: #1668dc;
    --primary-dark: #0f52b5;
    --success: #087443;
    --warning: #9a6700;
    --quiet: #596579;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
body { min-width: 320px; margin: 0; background: var(--bg); color: var(--text); line-height: 1.5; }
a { color: var(--primary); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 3px solid rgb(22 104 220 / 28%); outline-offset: 2px; }
.shell { width: min(1240px, calc(100% - 40px)); margin-inline: auto; }
.site-header { position: sticky; top: 0; z-index: 50; background: #10233f; color: #fff; box-shadow: 0 2px 14px rgb(20 32 51 / 15%); }
.header-inner { min-height: 64px; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px; padding-block: 8px; }
.brand { padding: 7px 10px; border-radius: 9px; color: #fff; font-size: 1.12rem; font-weight: 850; letter-spacing: -.02em; text-decoration: none; white-space: nowrap; }
.brand:hover { background: rgb(255 255 255 / 9%); }
.site-header nav { display: flex; align-items: center; min-width: 0; }
.site-header nav a, .account a { color: #dce9fb; text-decoration: none; }
.site-header nav > a { padding: 8px 12px; border: 1px solid transparent; border-radius: 9px; color: #dce9fb; font-size: .88rem; font-weight: 750; white-space: nowrap; }
.site-header nav > a:hover, .account a:hover { border-color: rgb(255 255 255 / 20%); background: rgb(255 255 255 / 10%); color: #fff; }
.nav-menu { position: relative; }
.nav-menu summary, .account-menu summary, .page-menu summary { padding: 8px 12px; border: 1px solid transparent; border-radius: 9px; color: #dce9fb; cursor: pointer; font-size: .88rem; font-weight: 750; list-style: none; white-space: nowrap; }
.nav-menu summary::-webkit-details-marker, .account-menu summary::-webkit-details-marker, .page-menu summary::-webkit-details-marker { display: none; }
.nav-menu[open] summary, .nav-menu summary:hover, .account-menu[open] summary, .account-menu summary:hover { border-color: rgb(255 255 255 / 20%); background: rgb(255 255 255 / 10%); color: #fff; }
.nav-dropdown { position: absolute; top: calc(100% + 10px); left: 0; z-index: 60; min-width: 230px; padding: 8px; border: 1px solid #294769; border-radius: 14px; background: #173555; box-shadow: 0 16px 34px rgb(8 20 38 / 32%); }
.nav-dropdown section { display: grid; align-content: start; gap: 3px; }
.nav-dropdown section p { margin: 0 0 4px; color: #91b7e6; font-size: .72rem; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.site-header nav .nav-dropdown a { padding: 8px 9px; border-radius: 8px; color: #e8f1ff; font-size: .88rem; font-weight: 650; }
.site-header nav .nav-dropdown a:hover { background: rgb(255 255 255 / 10%); }
.account { color: #dce9fb; font-size: .86rem; white-space: nowrap; }
.account-menu { position: relative; }
.account-dropdown { position: absolute; top: calc(100% + 10px); right: 0; z-index: 60; display: grid; gap: 8px; min-width: 190px; padding: 14px; border: 1px solid #294769; border-radius: 12px; background: #173555; box-shadow: 0 16px 34px rgb(8 20 38 / 32%); }
.account-dropdown strong { color: #fff; font-size: .86rem; }
.account-dropdown a { padding-top: 8px; border-top: 1px solid rgb(255 255 255 / 14%); font-weight: 700; }
.page-content { padding-block: 32px 72px; }
.hero { max-width: 760px; padding: clamp(28px, 6vw, 72px) 0; }
.hero h1, .page-heading h1 { margin: 0; font-size: clamp(1.85rem, 4vw, 2.7rem); line-height: 1.12; letter-spacing: -.035em; }
.hero > p:not(.eyebrow) { color: var(--muted); font-size: 1.18rem; }
.eyebrow { margin: 0 0 8px; color: var(--primary); font-size: .78rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 26px; }
.button { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; padding: 8px 14px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text); font: inherit; font-size: .92rem; font-weight: 750; text-decoration: none; cursor: pointer; transition: border-color .16s ease, background .16s ease, transform .16s ease; }
.button:hover { border-color: #aab8ca; transform: translateY(-1px); }
.button-primary { border-color: var(--primary); background: var(--primary); color: #fff; }
.button-primary:hover { border-color: var(--primary-dark); background: var(--primary-dark); }
.button-warning { border-color: #d99a16; background: #f6b936; color: #3b2a00; }
.button-warning:hover { border-color: #bd7e00; background: #e8a91d; }
.button-quiet { background: transparent; color: var(--quiet); }
.button-danger { border-color: var(--danger); background: transparent; color: var(--danger); box-shadow: none; }
.button-danger:hover { border-color: var(--danger); background: var(--danger); color: #fff; box-shadow: none; }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.heading-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 12px; }
.heading-actions .button { flex: 0 0 auto; white-space: nowrap; }
.page-menu { position: relative; }
.page-menu summary { display: inline-flex; align-items: center; min-height: 40px; border-color: var(--border); background: var(--surface); color: var(--text); font-size: .92rem; }
.page-menu[open] summary, .page-menu summary:hover { border-color: #aab8ca; background: #f8fafc; color: var(--text); }
.page-dropdown { position: absolute; top: calc(100% + 8px); right: 0; z-index: 30; display: grid; min-width: 230px; padding: 8px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: 0 14px 30px rgb(20 32 51 / 18%); }
.page-dropdown a { padding: 9px 10px; border-radius: 8px; color: var(--text); font-size: .88rem; font-weight: 650; text-decoration: none; }
.page-dropdown a:hover { background: #f1f5fa; color: var(--primary); }
.page-tabs { display: flex; gap: 4px; margin: -8px 0 22px; padding: 4px; width: fit-content; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.page-tabs a { padding: 8px 12px; border-radius: 7px; color: var(--quiet); font-size: .88rem; font-weight: 750; text-decoration: none; }
.page-tabs a:hover { color: var(--primary); background: #f1f5fa; }
.page-tabs a.is-active { background: var(--primary); color: #fff; }
.result-count { color: var(--muted); font-weight: 700; }
.messages { display: grid; gap: 8px; margin-bottom: 20px; }
.message { padding: 12px 14px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); }
.message-success { border-color: #8ed2ae; background: #e8f8ef; color: var(--success); }
.message-error { border-color: #e5a3a3; background: #fff0f0; color: #9f2525; }
.message-warning { border-color: #e5c267; background: #fff8df; color: #765600; }
.message-with-action { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.account-dropdown form { margin: 0; border-top: 1px solid rgb(255 255 255 / 14%); }
.account-logout { width: 100%; border: 0; padding: 9px 10px; border-radius: 8px; background: transparent; color: #dce9fb; font: inherit; font-weight: 700; text-align: left; cursor: pointer; }
.account-logout:hover, .account-logout:focus-visible { background: rgb(255 255 255 / 10%); color: #fff; outline: 0; }
.filter-panel { display: grid; grid-template-columns: minmax(260px, 2fr) minmax(150px, 1fr) minmax(180px, 1fr) minmax(180px, 1fr) auto auto; align-items: end; gap: 12px; margin-bottom: 22px; padding: 16px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); box-shadow: 0 1px 2px rgb(20 32 51 / 3%); }
.filter-panel label { display: grid; gap: 6px; color: var(--muted); font-size: .82rem; font-weight: 700; }
.catalog-filter-panel, .compact-filter-panel { display: block; padding: 12px 14px; }
.catalog-filter-primary, .compact-filter-primary { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 12px; }
.catalog-filter-primary .search-field, .compact-filter-primary .search-field { grid-column: auto; }
.catalog-filter-primary .button, .compact-filter-primary .button { min-width: 126px; }
.product-store-filter-primary { grid-template-columns: minmax(220px, 1.25fr) minmax(180px, .7fr) auto; }
.product-store-filter-primary > label:not(.search-field) { min-width: 0; }
.catalog-autocomplete { position: relative; min-width: 0; }
.catalog-search-suggestions { position: absolute; top: calc(100% + 5px); right: 0; left: 0; z-index: 25; max-height: 320px; overflow-y: auto; padding: 5px; border: 1px solid #cbd8ea; border-radius: 10px; background: #fff; box-shadow: 0 14px 28px rgb(26 46 77 / 18%); }
.catalog-search-suggestion { display: grid; gap: 2px; padding: 9px 10px; border-radius: 7px; color: var(--text); text-decoration: none; }
.catalog-search-suggestion:hover, .catalog-search-suggestion:focus-visible { background: #edf4ff; color: var(--primary-dark); outline: 0; }
.catalog-search-suggestion span, .catalog-search-empty { color: var(--muted); font-size: .78rem; }
.catalog-search-empty { margin: 0; padding: 9px 10px; }
.catalog-filter-disclosure, .compact-filter-disclosure { margin-top: 10px; border-top: 1px solid var(--border); }
.catalog-filter-disclosure summary, .compact-filter-disclosure summary { display: flex; align-items: center; gap: 8px; width: fit-content; padding: 10px 2px 0; color: var(--primary); font-size: .88rem; font-weight: 750; cursor: pointer; user-select: none; }
.catalog-filter-disclosure summary::marker, .compact-filter-disclosure summary::marker { color: var(--muted); }
.catalog-filter-disclosure[open] summary, .compact-filter-disclosure[open] summary { padding-bottom: 10px; }
.catalog-filter-options, .compact-filter-options { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) auto; align-items: end; gap: 12px; padding-top: 2px; }
.catalog-filter-reset, .compact-filter-reset { min-height: 42px; white-space: nowrap; }
.compact-search-panel .compact-filter-primary { grid-template-columns: minmax(0, 1fr) auto auto; }
.finance-filter-primary { grid-template-columns: minmax(190px, .9fr) minmax(220px, 1.1fr) auto; }
.filter-form { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; margin-bottom: 22px; padding: 16px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); box-shadow: 0 1px 2px rgb(20 32 51 / 3%); }
.filter-form label { display: grid; flex: 1 1 240px; gap: 6px; color: var(--muted); font-size: .82rem; font-weight: 700; }
.filter-form.compact-filter-panel { display: block; }
.sku-quick-link-form { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr) 86px auto auto; gap: 7px; align-items: center; min-width: 900px; }
.sku-quick-link-form input { min-height: 36px; padding: 6px 8px; font-size: .82rem; }
.sku-quick-link-form .button { min-height: 36px; padding: 6px 10px; font-size: .82rem; }
input, select { width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid #bac6d5; border-radius: 8px; background: #fff; color: var(--text); font: inherit; }
input:focus, select:focus { outline: 3px solid rgb(22 104 220 / 18%); border-color: var(--primary); }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); box-shadow: 0 1px 2px rgb(20 32 51 / 3%); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 15px 16px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { background: #f7f9fc; color: var(--muted); font-size: .76rem; letter-spacing: .045em; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f9fbff; }
.product-link { color: var(--text); font-weight: 750; text-decoration: none; }
.product-link:hover { color: var(--primary); }
.product-with-thumbnail { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.product-with-thumbnail > span:last-child { min-width: 0; }
.product-thumbnail { width: 46px; height: 46px; flex: 0 0 46px; display: block; overflow: hidden; border: 1px solid #d6e0ec; border-radius: 9px; background: #eef3f9; object-fit: cover; }
.product-thumbnail-small { width: 34px; height: 34px; flex-basis: 34px; border-radius: 7px; }
.product-thumbnail-empty { display: grid; place-items: center; color: var(--muted); font-size: .62rem; font-weight: 800; line-height: 1; }
.product-thumbnail-list { display: grid; gap: 8px; }
.status { display: inline-flex; padding: 4px 9px; border-radius: 999px; background: #edf1f6; color: var(--quiet); font-size: .78rem; font-weight: 800; white-space: nowrap; }
.status-active { background: #dcf7e9; color: var(--success); }
.status-draft { background: #fff2c7; color: var(--warning); }
.status-archived { background: #e8ebef; color: #515967; }
.status-pending { background: #fff2c7; color: var(--warning); }
.status-error { background: #fff0f0; color: #9f2525; }
.status-synced { background: #dcf7e9; color: var(--success); }
.status-approved { background: #dcf7e9; color: var(--success); }
.status-rejected { background: #fff0f0; color: #9f2525; }
.pagination { display: flex; justify-content: center; align-items: center; gap: 18px; margin-top: 22px; }
.pagination a { font-weight: 700; }
.empty-state { padding: 54px 24px; border: 1px dashed #b9c6d6; border-radius: 14px; background: var(--surface); text-align: center; }
.empty-state h2 { margin-top: 0; }
.empty-state p, .muted { color: var(--muted); }
.back-link { display: inline-block; margin-bottom: 18px; text-decoration: none; font-weight: 700; }
.product-heading { align-items: center; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.card { padding: 20px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); box-shadow: 0 1px 2px rgb(20 32 51 / 3%); }
.card-wide { grid-column: 1 / -1; }
.card h2 { margin: 0 0 18px; font-size: 1.05rem; }
.card-subheading { margin: 16px 0 10px; padding-top: 14px; border-top: 1px solid var(--section-divider); color: var(--quiet); font-size: .72rem; font-weight: 750; letter-spacing: .04em; text-transform: uppercase; }
.definition-list { margin: 0; }
.definition-list div { display: grid; grid-template-columns: minmax(130px, .7fr) 1.3fr; gap: 16px; padding: 9px 0; border-bottom: 1px solid #edf1f5; }
.definition-list div:last-child { border-bottom: 0; }
.definition-list dt { color: var(--muted); }
.definition-list dd { margin: 0; font-weight: 650; }
.record-list { margin: 0; padding: 0; list-style: none; }
.record-list li { display: flex; justify-content: space-between; gap: 18px; padding: 10px 0; border-bottom: 1px solid #edf1f5; }
.record-list li:last-child { border-bottom: 0; }
.record-list span { color: var(--muted); text-align: right; }
.base-unit-note { margin-top: 0; padding: 10px 12px; border-radius: 8px; background: #f1f5fa; }
.conversion-list li { align-items: center; }
.notes { margin: 16px 0 0; padding-top: 16px; border-top: 1px solid var(--border); }
.image-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.product-image { position: relative; margin: 0; overflow: hidden; border: 1px solid var(--border); border-radius: 11px; background: #f6f8fb; }
.product-image-primary { border: 2px solid var(--primary); }
.product-image img { width: 100%; aspect-ratio: 1; display: block; object-fit: contain; background: inherit; }
.product-image figcaption { padding: 8px 10px; color: var(--muted); font-size: .8rem; }
.image-actions { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.image-actions form { margin: 0; }
.image-actions .button { min-height: 28px; padding: 4px 7px; font-size: .72rem; }
.image-replace { margin-top: 8px; }
.image-replace summary { cursor: pointer; font-weight: 700; }
.image-replace form { display: grid; gap: 7px; margin-top: 7px; }
.image-replace input[type="file"] { max-width: 100%; font-size: .72rem; }
.catalog-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(345px, 1fr)); gap: 16px; }
.catalog-card { overflow: hidden; display: grid; grid-template-columns: 122px minmax(0, 1fr); min-width: 0; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); box-shadow: 0 1px 2px rgb(20 32 51 / 4%); transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease; }
.catalog-card:hover { border-color: #b7c9e2; box-shadow: 0 9px 24px rgb(20 32 51 / 10%); transform: translateY(-2px); }
.catalog-card-photo { display: flex; align-items: center; align-self: stretch; min-height: 142px; overflow: hidden; background: #eef3f9; }
.catalog-card-photo img { width: 100%; height: auto; display: block; object-fit: contain; object-position: center; }
.catalog-card-photo-empty { width: 100%; height: 100%; display: grid; place-items: center; color: var(--muted); background: linear-gradient(135deg, #f1f5fa, #e5ebf3); font-size: .86rem; font-weight: 700; }
.catalog-card-content { display: grid; min-width: 0; align-content: start; gap: 7px; padding: 14px 16px; }
.catalog-card-topline { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 10px; }
.catalog-card-stock { color: var(--success); font-size: .78rem; font-weight: 800; white-space: nowrap; }
.catalog-card-stock-low, .low-stock-text { color: #b42318; }
.catalog-card-title { display: -webkit-box; overflow: hidden; font-size: 1rem; line-height: 1.35; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.catalog-card-characteristic { margin: 0; overflow: hidden; color: var(--quiet); font-size: .84rem; text-overflow: ellipsis; white-space: nowrap; }
.common-stock-badge { justify-self: start; padding: 4px 7px; border: 1px solid var(--border-strong); border-radius: 5px; color: var(--primary-dark); background: var(--primary-soft); font-size: .7rem; font-weight: 800; line-height: 1.2; }
.common-stock-note { display: grid; gap: 3px; margin: 0 0 12px; padding: 11px 12px; border: 1px solid var(--border-strong); border-radius: 7px; background: var(--primary-soft); }
.common-stock-note strong { color: var(--primary-dark); }
.common-stock-note span { color: var(--quiet); font-size: .84rem; line-height: 1.45; }
.stock-card-marketplace { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--section-divider); }
.stock-card-subheading { margin: 0 0 12px; color: var(--text); font-size: 1rem; line-height: 1.35; }
.marketplace-position-list .marketplace-position-identity { display: grid; min-width: 0; gap: 3px; }
.marketplace-position-list .marketplace-position-identity span { overflow-wrap: anywhere; text-align: left; }
.marketplace-position-controls { display: flex; flex: 0 0 auto; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 10px; }
.marketplace-position-controls > span { white-space: nowrap; }
.marketplace-position-controls > span strong { color: var(--text); font-variant-numeric: tabular-nums; }
.marketplace-position-controls .button { min-height: 34px; padding: 6px 10px; font-size: .78rem; }
.stock-card-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 14px; padding-bottom: 9px; border-bottom: 1px solid var(--section-divider); }
.detail-grid-product .stock-overview-card > .stock-card-heading h2 { margin: 0; padding: 0; border: 0; font-size: .92rem; }
.stock-data-freshness { color: var(--muted); font-size: .72rem; font-weight: 650; white-space: nowrap; }
.detail-grid-product .stock-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; overflow: hidden; margin-bottom: 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--border); }
.detail-grid-product .stock-kpi { position: relative; min-height: 92px; align-content: start; gap: 3px; padding: 13px 14px 12px; border: 0; border-radius: 0; background: var(--surface-subtle); }
.detail-grid-product .stock-kpi::before { position: absolute; top: 0; right: 0; left: 0; height: 2px; background: var(--border-strong); content: ""; }
.detail-grid-product .stock-kpi-available::before { background: var(--primary); }
.detail-grid-product .stock-kpi-sold::before { background: var(--success); }
.detail-grid-product .stock-kpi-return::before { background: var(--warning); }
.detail-grid-product .stock-kpi-low::before { background: var(--warning); }
.detail-grid-product .stock-kpi-negative::before { background: var(--danger); }
.detail-grid-product .stock-kpi > span { color: var(--quiet); font-size: .74rem; font-weight: 700; }
.detail-grid-product .stock-kpi > strong { color: var(--text); font-size: 1.38rem; font-variant-numeric: tabular-nums; letter-spacing: -.025em; }
.detail-grid-product .stock-kpi > small { margin-top: auto; color: var(--muted); font-size: .7rem; line-height: 1.35; }
.stock-location-section { margin-top: 16px; }
.our-stock-actions { margin-top: 12px; }
.stock-subsection-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.stock-subsection-heading .stock-card-subheading { margin: 0; }
.stock-subsection-heading > span { min-width: 38px; padding: 2px 7px; border: 1px solid var(--border); border-radius: 5px; background: var(--surface-subtle); color: var(--muted); font-size: .7rem; font-weight: 750; text-align: center; }
.stock-location-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 7px; }
.detail-grid-product .stock-location-list li { min-width: 0; align-items: center; padding: 10px 11px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface-subtle); }
.stock-location-identity { display: grid; min-width: 0; gap: 2px; }
.stock-location-identity strong { overflow: hidden; font-size: .82rem; text-overflow: ellipsis; white-space: nowrap; }
.record-list .stock-location-identity span { color: var(--muted); font-size: .72rem; line-height: 1.35; text-align: left; }
.stock-location-quantity { flex: 0 0 auto; color: var(--text); font-size: 1.12rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stock-location-quantity small { color: var(--muted); font-size: .68em; }
.detail-grid-product .stock-location-list .warehouse-balance-negative { align-items: center; justify-content: space-between !important; padding: 10px 11px !important; }
.detail-grid-product .stock-location-list .warehouse-balance-low { border-color: var(--warning-border); background: var(--warning-soft); }
.detail-grid-product .stock-location-list .warehouse-balance-low .low-stock-text,
.detail-grid-product .stock-location-list .warehouse-balance-low .stock-location-identity span { color: var(--warning-text); }
html[data-theme="dark"] .detail-grid-product .stock-location-list .warehouse-balance-low .low-stock-text,
html[data-theme="dark"] .detail-grid-product .stock-location-list .warehouse-balance-low .stock-location-identity span { color: var(--warning-text); }
.stock-empty-state { margin: 0; padding: 14px; border: 1px dashed var(--border-strong); border-radius: 7px; background: var(--surface-subtle); color: var(--muted); font-size: .82rem; text-align: center; }
.stock-cost { display: flex; justify-content: space-between; gap: 16px; margin: 8px 0 0; padding-top: 9px; border-top: 1px solid var(--section-divider); color: var(--muted); font-size: .76rem; }
.stock-cost strong { color: var(--text); font-variant-numeric: tabular-nums; text-align: right; }
.stock-card-actions { justify-content: flex-end; gap: 7px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--section-divider); }
.stock-card-actions .button { min-height: 36px; }
.catalog-card-category { margin: 0; overflow: hidden; color: var(--muted); font-size: .83rem; text-overflow: ellipsis; white-space: nowrap; }
.catalog-card-marketplace { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); overflow: hidden; margin: 3px 0 0; border: 1px solid var(--border); border-radius: 7px; background: var(--section-divider); font-variant-numeric: tabular-nums; }
.catalog-card-marketplace > div { min-width: 0; padding: 7px 8px; background: var(--surface-subtle); }
.catalog-card-marketplace > div:nth-child(2n) { border-left: 1px solid var(--section-divider); }
.catalog-card-marketplace > div:nth-child(n + 3) { border-top: 1px solid var(--section-divider); }
.catalog-card-marketplace dt { overflow: hidden; margin: 0 0 2px; color: var(--muted); font-size: .66rem; font-weight: 650; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }
.catalog-card-marketplace dd { margin: 0; color: var(--text); font-size: .88rem; font-weight: 800; line-height: 1.2; }
.catalog-card-marketplace dd small { color: var(--quiet); font-size: .68rem; font-weight: 650; }
.catalog-card-marketplace-single > div { border-top: 0; }
.warehouse-balance-negative { justify-content: flex-start !important; padding: 9px 11px !important; border: 1px solid var(--danger-border); border-radius: 7px; background: var(--danger-soft); }
.record-list .warehouse-balance-negative > span { color: var(--danger-text); text-align: left; }
.warehouse-balance-negative strong { font-variant-numeric: tabular-nums; }
.product-characteristic-heading { margin: 8px 0 0; color: var(--muted); font-size: 1.08rem; font-weight: 650; }
.catalog-load-sentinel { display: grid; place-items: center; min-height: 72px; }
.catalog-load-sentinel.is-loading::after { content: "Загружаем ещё товары…"; color: var(--muted); font-size: .88rem; }
.catalog-load-sentinel.catalog-load-error::after { content: "Не удалось загрузить товары. Используйте кнопку «Далее»."; color: var(--warning); font-size: .88rem; }
.inline-form { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.inline-form summary { color: var(--primary); font-weight: 750; cursor: pointer; }
.inline-form form, .edit-form { display: grid; gap: 16px; }
.inline-form form { margin-top: 16px; }
.inline-form form > div, .edit-form > div:not(.actions):not(.form-errors) { display: grid; gap: 6px; }
.inline-form label, .edit-form label { font-weight: 700; }
.inline-form textarea, .edit-form textarea { width: 100%; padding: 9px 11px; border: 1px solid #bac6d5; border-radius: 8px; font: inherit; resize: vertical; }
.inline-form input[type="checkbox"] { width: auto; min-height: auto; }
.edit-form { max-width: 760px; }
.edit-form .helptext { color: var(--muted); font-size: .82rem; }
.edit-form .errorlist, .form-errors .errorlist { margin: 0; padding: 10px 14px 10px 32px; border-radius: 8px; background: #fff0f0; color: #9f2525; }
.duplicate-warning { padding: 16px; border: 1px solid #e5c267; border-radius: 10px; background: #fff8df; }
.duplicate-warning h2 { margin: 0 0 6px; font-size: 1.05rem; }
.duplicate-warning p { margin: 0 0 12px; color: #765600; }
.duplicate-warning ul { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.duplicate-warning li { display: flex; justify-content: space-between; gap: 14px; padding-top: 8px; border-top: 1px solid #efd990; }
.duplicate-warning li span { color: var(--muted); text-align: right; }
.component-rows { display: grid; gap: 10px; }
.component-row { display: grid; grid-template-columns: 3fr 1fr; gap: 12px; padding: 12px; border: 1px solid var(--border); border-radius: 9px; background: #f8fafc; }
.component-row > div { display: grid; gap: 5px; }
.version-heading { display: flex; justify-content: space-between; gap: 18px; align-items: center; }
.version-heading > div { display: flex; align-items: center; gap: 12px; }
.version-heading h2 { margin: 0; }
.carton-version-current { border-color: #6ba6ef; box-shadow: 0 0 0 2px rgb(22 104 220 / 8%); }
.compact-table th, .compact-table td { padding-block: 10px; }
.finance-product-row { cursor: pointer; }
.finance-product-row:focus-visible { outline: 3px solid rgb(22 104 220 / 28%); outline-offset: -3px; }
.finance-product-row[aria-expanded="true"] { background: #edf4ff; }
.finance-profit-card { border-color: #b8d0ef; background: linear-gradient(135deg, #f5f9ff, #e8f2ff); }
.finance-profit-card strong { color: #155bad; }
.finance-profit-card.finance-profit-negative { border-color: #e7b5bc; background: linear-gradient(135deg, #fff6f6, #ffeaed); }
.finance-profit-card.finance-profit-negative strong { color: #ae3140; }
.finance-formula { margin: -10px 0 22px; }
.finance-row-hint { display: block; margin-top: 3px; color: var(--primary); font-size: .75rem; font-weight: 700; }
.finance-product-detail > td { padding: 0; background: #f7faff; }
.finance-product-detail-content { padding: 15px 16px 18px; }
.finance-product-fragment h3 { margin: 0 0 10px; font-size: 1rem; }
.finance-product-detail .table-wrap { max-height: none; }
.store-contact { display: grid; gap: 3px; }
.store-contact > a { width: fit-content; color: var(--muted); font-size: .86rem; }
.store-contact details { margin-top: 3px; }
.store-contact summary { color: var(--primary); font-size: .82rem; font-weight: 700; cursor: pointer; }
.inline-email-form { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin-top: 8px; }
.inline-email-form input { width: min(250px, 100%); min-height: 36px; }
.inline-email-form .button { min-height: 36px; }
.missing-email { color: #b54708; font-weight: 700; }
.account-store-list { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.account-store-list a { padding: 3px 6px; border-radius: 999px; background: #edf3fb; color: #315b91; font-size: .72rem; font-weight: 700; text-decoration: none; }
.account-store-list a:hover { background: #dceafa; color: var(--primary); }
.stores-count-link { display: inline-block; font-weight: 800; text-decoration: none; }
.sync-switch { display: inline-flex; align-items: center; gap: 7px; min-height: 32px; padding: 5px 9px; border: 1px solid #dcc17d; border-radius: 999px; background: #fff8df; color: #765600; font: inherit; font-size: .78rem; font-weight: 800; cursor: pointer; }
.sync-switch span { width: 14px; height: 14px; border: 2px solid currentColor; border-radius: 4px; background: transparent; }
.sync-switch.is-active { border-color: #8ed2ae; background: #e8f8ef; color: var(--success); }
.sync-switch.is-active span { border-color: var(--success); background: var(--success); box-shadow: inset 0 0 0 2px #e8f8ef; }
.sync-switch-action { min-height: 40px; padding-inline: 14px; font-size: .86rem; }
.sync-checkbox-form label { display: inline-flex; align-items: center; gap: 8px; color: var(--text); font-weight: 750; cursor: pointer; }
.sync-checkbox-form input { width: 19px; min-height: 19px; accent-color: var(--success); cursor: pointer; }
.balance-filter { grid-template-columns: minmax(210px, 1fr) minmax(260px, 1.4fr) minmax(180px, 1fr) auto auto; }
.document-filter { grid-template-columns: minmax(230px, 1.5fr) minmax(180px, 1fr) minmax(210px, 1fr) auto auto; }
.audit-filter { grid-template-columns: minmax(260px, 2fr) minmax(220px, 1fr) auto auto; }
.negative-row { background: #fff4f4; }
.negative-row:hover { background: #ffeaea; }
.low-stock-row { background: #fff7f5; }
.low-stock-row:hover { background: #ffefeb; }
.recent-documents { margin-top: 22px; }
.inline-edit-form { margin-top: 22px; padding-top: 22px; border-top: 1px solid var(--border); }
.batch-document-form { display: grid; gap: 18px; }
.batch-header-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.batch-header-grid > div { display: grid; gap: 6px; }
.batch-header-grid label, .batch-line label { font-weight: 700; }
.batch-header-grid textarea { width: 100%; padding: 9px 11px; border: 1px solid #bac6d5; border-radius: 8px; font: inherit; resize: vertical; }
.batch-line-list { display: grid; gap: 12px; }
.batch-line { position: relative; display: grid; grid-template-columns: minmax(240px, 2fr) minmax(100px, .7fr) minmax(150px, 1fr) minmax(150px, 1fr); gap: 12px; padding: 16px 16px 12px 42px; border: 1px solid var(--border); border-radius: 11px; background: #f8fafc; }
.batch-line > div { display: grid; gap: 5px; align-content: start; }
.batch-line [data-product-search] { min-height: 34px; }
.product-picker-control { position: relative; display: block; }
.product-autocomplete { position: relative; display: block; }
.product-autocomplete [data-product-search] { width: 100%; }
.product-picker-control [data-product-search] { padding-left: 48px; }
.selected-product-visual { position: absolute; z-index: 2; top: 5px; left: 6px; display: grid; width: 32px; height: 32px; overflow: hidden; place-items: center; border: 1px solid #cbd8ea; border-radius: 7px; background: #fff; pointer-events: none; }
.selected-product-visual img { display: block; width: 100%; height: 100%; object-fit: contain; }
.selected-product-visual img[hidden], .product-photo-placeholder[hidden] { display: none; }
.product-photo-placeholder { width: 18px; height: 18px; stroke: var(--muted); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.product-select-native { display: none; }
.product-suggestions { position: absolute; top: calc(100% + 5px); right: 0; left: 0; z-index: 25; display: grid; max-height: 260px; overflow-y: auto; padding: 5px; border: 1px solid #cbd8ea; border-radius: 10px; background: #fff; box-shadow: 0 14px 28px rgb(26 46 77 / 18%); }
.product-suggestions[hidden] { display: none; }
.product-suggestion { display: grid; grid-template-columns: 42px minmax(0, 1fr); gap: 9px; align-items: center; width: 100%; padding: 7px 8px; border: 0; border-radius: 7px; background: transparent; color: var(--text); font: inherit; font-size: .84rem; text-align: left; cursor: pointer; }
.product-suggestion-photo { display: grid; width: 42px; height: 42px; overflow: hidden; place-items: center; border: 1px solid #d5dfec; border-radius: 8px; background: #fff; }
.product-suggestion-photo img { display: block; width: 100%; height: 100%; object-fit: contain; }
.product-suggestion-photo-empty { padding: 3px; color: var(--muted); font-size: .56rem; font-weight: 700; line-height: 1.05; text-align: center; }
.product-suggestion-title { min-width: 0; line-height: 1.3; overflow-wrap: anywhere; }
.product-suggestion:hover, .product-suggestion:focus-visible { background: #edf4ff; color: var(--primary-dark); outline: 0; }
.product-suggestion-empty { padding: 9px 10px; color: var(--muted); font-size: .82rem; }
.line-remove { justify-self: start; grid-column: 1 / -1; padding: 0; border: 0; background: transparent; color: #b42318; font: inherit; font-size: .82rem; font-weight: 700; cursor: pointer; }
.batch-line > .line-cost[hidden] { display: none; }
.line-number { position: absolute; top: 24px; left: 15px; color: var(--muted); font-weight: 800; }
.line-formula { grid-column: 1 / -1; margin: 0; }
.negative-text { color: #b42318; }
.positive-text { color: var(--success); }
.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 22px; }
.summary-card { display: grid; gap: 5px; padding: 16px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface); }
.summary-card span, .summary-card small { color: var(--muted); }
.summary-card strong { font-size: 1.35rem; }
.summary-card-warning { border-color: #e5a3a3; background: #fff4f4; }
.sync-progress { margin-bottom: 20px; padding: 22px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); }
.sync-progress-compact { margin-top: -8px; }
.sync-progress-heading { display: flex; align-items: start; justify-content: space-between; gap: 18px; margin-bottom: 12px; }
.sync-progress-heading h2 { margin: 0; font-size: 1.05rem; }
.sync-progress-heading p { margin: 4px 0 0; }
.sync-progress-heading .eyebrow { margin: 0 0 4px; }
.sync-progress-percent { display: grid; min-width: 72px; min-height: 52px; place-items: center; padding: 4px 10px; border-radius: 12px; background: #eaf2ff; color: var(--primary); font-size: 1.35rem; }
.sync-progress-counters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 18px 0 14px; }
.sync-progress-counters > div { display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: 3px 9px; min-height: 72px; padding: 12px; border: 1px solid var(--border); border-radius: 11px; background: #f7f9fc; }
.sync-progress-counters span, .sync-progress-counters small { color: var(--muted); font-size: .78rem; }
.sync-progress-counters strong { font-size: 1.35rem; }
.sync-progress-counters small { grid-column: 1 / -1; }
.sync-counter-error { border-color: #e7b3b3 !important; background: #fff7f7 !important; }
.sync-counter-error strong { color: #b42318; }
.progress-track { display: flex; height: 13px; overflow: hidden; border-radius: 999px; background: #dce4ef; box-shadow: inset 0 1px 2px rgb(31 55 91 / 15%); }
.progress-track span { display: block; height: 100%; min-width: 0; transition: width .35s ease; }
.progress-track .progress-loaded { background: linear-gradient(90deg, #3174c9, #6398e8); }
.progress-track .progress-errors { background: repeating-linear-gradient(135deg, #cf4b4b 0 7px, #e76e6e 7px 14px); }
.sync-progress-meta { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 10px; color: var(--muted); font-size: .9rem; }
.sync-errors { margin: 0 0 22px; border: 1px solid #e6c996; border-radius: 14px; background: #fffaf1; }
.sync-errors > summary { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 15px 17px; cursor: pointer; list-style: none; }
.sync-errors > summary::-webkit-details-marker { display: none; }
.sync-errors summary span:first-child { display: grid; gap: 3px; }
.sync-errors summary small { color: var(--muted); }
.sync-errors-content { padding: 0 17px 17px; }
.error-store-filter { display: flex; align-items: end; gap: 10px; margin: 14px 0; }
.error-store-filter label { display: grid; gap: 5px; min-width: min(100%, 330px); color: var(--muted); font-size: .84rem; font-weight: 700; }
.raw-api-error { margin-top: 5px; color: var(--muted); font-size: .82rem; }
.raw-api-error summary { cursor: pointer; }
.raw-api-error code { display: block; max-width: 420px; max-height: 100px; overflow: auto; margin-top: 7px; padding: 8px; border-radius: 7px; background: #f3f5f8; color: #344054; white-space: pre-wrap; word-break: break-word; }
.dashboard-links { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.dashboard-link { display: grid; gap: 6px; min-height: 132px; padding: 20px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); box-shadow: 0 1px 2px rgb(20 32 51 / 3%); color: var(--text); text-decoration: none; transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease; }
.dashboard-link:hover { border-color: #9ec0ed; box-shadow: 0 10px 24px rgb(20 32 51 / 9%); transform: translateY(-2px); color: var(--text); }
.dashboard-link strong { font-size: 1rem; }
.dashboard-link span { color: var(--muted); font-size: .88rem; }
.section-heading { display: flex; align-items: start; justify-content: space-between; gap: 18px; margin-bottom: 16px; }
.section-heading h2 { margin-bottom: 6px; }
.section-heading p { margin: 0; }
.section-heading code { max-width: 430px; overflow-x: auto; padding: 8px 10px; border-radius: 8px; background: #edf3fb; color: #21406b; font-size: .78rem; white-space: nowrap; }
.empty-queue { margin: 0; color: var(--muted); }
.command-card { margin-top: 22px; }
.command-card code { display: block; overflow-x: auto; padding: 12px; border-radius: 8px; background: #10233f; color: #e8f1ff; }
.packaging-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; }
.packaging-card { align-self: start; }
.scroll-top { position: fixed; right: 22px; bottom: 22px; z-index: 10; width: 46px; height: 46px; border: 1px solid #0f52b5; border-radius: 50%; background: var(--primary); color: #fff; box-shadow: 0 7px 18px rgb(20 32 51 / 20%); font: inherit; font-size: 1.35rem; font-weight: 800; cursor: pointer; }
.scroll-top:hover { background: var(--primary-dark); }
.scroll-top[hidden] { display: none; }

/* Visual system v2: calmer hierarchy, denser data screens, and clear actions. */
:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --text: #172033;
    --muted: #68748a;
    --border: #e1e7f0;
    --primary: #2864dc;
    --primary-dark: #1d4fb6;
    --success: #067647;
    --quiet: #4d5c72;
}
body {
    background:
        radial-gradient(900px 380px at 100% -100px, rgb(65 118 225 / 10%), transparent 70%),
        var(--bg);
    font-size: 15px;
}
.shell { width: min(1400px, calc(100% - 48px)); }
.site-header { background: rgb(14 28 52 / 96%); border-bottom: 1px solid rgb(147 180 230 / 19%); box-shadow: 0 8px 24px rgb(14 28 52 / 18%); backdrop-filter: blur(14px); }
.header-inner { min-height: 70px; gap: 20px; }
.brand { display: inline-flex; align-items: center; gap: 9px; padding: 7px 8px; font-size: 1.04rem; letter-spacing: -.025em; }
.brand-logo { width: 29px; height: 29px; object-fit: contain; filter: drop-shadow(0 3px 8px rgb(40 100 220 / 35%)); }
.site-header nav { gap: 3px; }
.site-header nav > a, .nav-menu summary, .account-menu summary { min-height: 38px; padding: 8px 11px; color: #d8e4f7; }
.nav-menu summary::after, .account-menu summary::after { content: "⌄"; display: inline-block; margin-left: 7px; color: #8fa9ce; font-size: .95em; transition: transform .16s ease; }
.nav-menu[open] summary::after, .account-menu[open] summary::after { transform: rotate(180deg); }
.nav-dropdown, .account-dropdown { border-color: rgb(164 194 235 / 20%); background: #122a4a; box-shadow: 0 20px 42px rgb(7 18 35 / 34%); }
.nav-dropdown { min-width: 248px; padding: 9px; }
.nav-dropdown section { gap: 4px; }
.site-header nav .nav-dropdown a { padding: 10px; border-radius: 9px; }
.page-content { padding-block: 36px 76px; }
.page-heading { margin-bottom: 26px; }
.hero h1, .page-heading h1 { font-size: clamp(1.9rem, 3.2vw, 2.55rem); letter-spacing: -.045em; }
.eyebrow { color: #3d73d8; font-size: .7rem; letter-spacing: .11em; }
.breadcrumb { display: flex; align-items: center; gap: 6px; }
.breadcrumb a { color: inherit; text-decoration: none; }
.breadcrumb a:hover, .breadcrumb a:focus-visible { color: var(--primary-dark); text-decoration: underline; text-underline-offset: 3px; }
.button { min-height: 42px; border-color: #d9e1ec; border-radius: 10px; box-shadow: 0 1px 1px rgb(17 35 63 / 3%); }
.button:hover { border-color: #a9bddb; box-shadow: 0 5px 13px rgb(17 35 63 / 9%); }
.button-primary { box-shadow: 0 5px 13px rgb(40 100 220 / 20%); }
.button-quiet { box-shadow: none; }
.filter-panel, .filter-form { gap: 14px; padding: 18px; border-radius: 16px; border-color: #e0e7f1; box-shadow: 0 8px 22px rgb(26 46 77 / 5%); }
.filter-panel label, .filter-form label { font-size: .76rem; letter-spacing: .01em; }
input, select { min-height: 43px; border-color: #d4deeb; border-radius: 10px; background: #fcfdff; }
input:hover, select:hover { border-color: #aebed3; }
.card, .table-wrap { border-color: #e0e7f1; border-radius: 16px; box-shadow: 0 8px 22px rgb(26 46 77 / 5%); }
.card { padding: 22px; }
.table-wrap { background: #fff; }
th, td { padding: 14px 16px; border-color: #edf1f6; }
th { background: #f8faff; color: #718096; font-size: .72rem; }
tbody tr { transition: background .14s ease; }
tbody tr:hover { background: #f5f8ff; }
.status { padding: 4px 9px; border: 1px solid transparent; font-size: .72rem; letter-spacing: .01em; }
.status-active, .status-approved, .status-synced { border-color: #bcebd0; }
.status-pending, .status-draft { border-color: #f3da8e; }
.status-rejected, .status-error { border-color: #f3c4c4; }
.summary-grid { gap: 14px; }
.summary-card { min-height: 112px; padding: 18px; border-color: #e0e7f1; border-radius: 15px; box-shadow: 0 6px 16px rgb(26 46 77 / 4%); }
.summary-card strong { font-size: 1.55rem; letter-spacing: -.035em; }
.shipment-statistics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 0 0 16px; }
.shipment-statistic { display: grid; gap: 2px; margin: 0; padding: 12px 14px; border: 1px solid #cfe0fb; border-radius: 11px; background: #f5f9ff; }
.shipment-statistic span, .shipment-statistic small { color: var(--muted); font-size: .78rem; }
.shipment-statistic strong { color: var(--primary-dark); font-size: 1.35rem; letter-spacing: -.025em; }
.dashboard-link { min-height: 144px; border-color: #e0e7f1; border-radius: 16px; box-shadow: 0 7px 18px rgb(26 46 77 / 5%); }
.catalog-grid { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px; }
.catalog-card { grid-template-columns: 116px minmax(0, 1fr); border-color: #e0e7f1; border-radius: 16px; box-shadow: 0 7px 18px rgb(26 46 77 / 5%); }
.catalog-card-content { padding: 15px 16px; }
.catalog-card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; padding-top: 4px; }
.catalog-card-actions .button { min-height: 32px; padding: 6px 10px; font-size: .78rem; }
.catalog-card-title { font-size: 1rem; }
.product-thumbnail { border-color: #dbe4ef; border-radius: 10px; }
.hero { position: relative; overflow: hidden; max-width: none; margin-top: 8px; padding: clamp(34px, 6vw, 76px); border: 1px solid #dce6f5; border-radius: 22px; background: linear-gradient(135deg, #ffffff 0%, #f2f6ff 100%); box-shadow: 0 15px 34px rgb(26 46 77 / 7%); }
.hero::after { content: ""; position: absolute; right: -90px; bottom: -160px; width: 420px; height: 420px; border-radius: 50%; background: radial-gradient(circle, rgb(54 112 224 / 22%), rgb(54 112 224 / 0%) 68%); pointer-events: none; }
.hero > * { position: relative; z-index: 1; }
.hero > p:not(.eyebrow) { max-width: 620px; font-size: 1.1rem; }

/* Keep SKU linking compact: package quantity has its own table column. */
.sku-quick-link-form { display: flex; flex-wrap: wrap; align-items: center; min-width: 0; width: 100%; gap: 8px; }
.sku-product-autocomplete { position: relative; flex: 1 0 100%; min-width: 0; }
.sku-product-autocomplete .sku-product-search { width: 100%; }
.sku-product-suggestions { position: absolute; top: calc(100% + 5px); right: 0; left: 0; z-index: 20; max-height: 236px; overflow-y: auto; padding: 5px; border: 1px solid #cbd8ea; border-radius: 10px; background: #fff; box-shadow: 0 14px 28px rgb(26 46 77 / 18%); }
.sku-product-suggestion { display: grid; width: 100%; gap: 2px; padding: 9px 10px; border: 0; border-radius: 7px; background: transparent; color: var(--text); font: inherit; font-size: .8rem; text-align: left; cursor: pointer; }
.sku-product-suggestion strong { font-size: .82rem; }
.sku-product-suggestion span { color: var(--muted); font-size: .72rem; }
.sku-product-suggestion:hover, .sku-product-suggestion:focus-visible { background: #edf4ff; color: var(--primary-dark); outline: 0; }
.sku-product-suggestion-empty { margin: 0; padding: 9px 10px; color: var(--muted); font-size: .8rem; }
.sku-quick-link-form .button { white-space: nowrap; }
.sku-pack-quantity { width: 76px; min-height: 36px; padding: 6px 8px; font-size: .82rem; text-align: center; }
.sku-link-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.sku-created-state { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.sku-created-undo { min-height: 32px; padding: 5px 9px; font-size: .76rem; }
.marketplace-sku-filter-autocomplete { position: relative; min-width: 0; }
.marketplace-sku-filter-autocomplete .search-field { width: 100%; }
.marketplace-sku-filter-suggestions { position: absolute; z-index: 35; top: calc(100% + 6px); right: 0; left: 0; max-height: min(360px, 60vh); overflow-y: auto; padding: 6px; border: 1px solid #cbd8ea; border-radius: 12px; background: #fff; box-shadow: 0 16px 32px rgb(26 46 77 / 18%); }
.marketplace-sku-filter-suggestion { display: grid; width: 100%; gap: 3px; padding: 10px 12px; border: 0; border-radius: 8px; background: transparent; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.marketplace-sku-filter-suggestion strong { overflow-wrap: anywhere; font-size: .86rem; }
.marketplace-sku-filter-suggestion span { overflow-wrap: anywhere; color: var(--muted); font-size: .76rem; }
.marketplace-sku-filter-suggestion:hover,
.marketplace-sku-filter-suggestion:focus-visible { background: #edf4ff; color: var(--primary-dark); outline: 2px solid var(--primary); outline-offset: -2px; }

/* Colour themes: the default stays light; the chosen theme is saved in the browser. */
.header-tools { display: flex; align-items: center; justify-content: end; gap: 6px; }
.theme-toggle { min-height: 38px; display: inline-flex; align-items: center; gap: 6px; padding: 7px 10px; border: 1px solid transparent; border-radius: 9px; background: transparent; color: #d8e4f7; font: inherit; font-size: .8rem; font-weight: 750; cursor: pointer; }
.theme-toggle:hover, .theme-toggle:focus-visible { border-color: rgb(255 255 255 / 20%); background: rgb(255 255 255 / 10%); color: #fff; outline: 0; }
.theme-toggle > span:first-child { font-size: 1.05rem; line-height: 1; }
.brand > span { color: #edf4ff; }
.brand > span b { color: #90b7e9; font-weight: 850; }
.brand-logo { filter: drop-shadow(0 3px 8px rgb(3 11 25 / 45%)); }

html[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0a1424;
    --surface: #13233a;
    --text: #e7edf8;
    --muted: #a7b6cd;
    --quiet: #c1cce0;
    --border: #2b4261;
    --primary: #78aaf4;
    --primary-dark: #a7c7fb;
    --success: #5dd69c;
    --warning: #f5c568;
}
html[data-theme="dark"] body { background: radial-gradient(900px 380px at 100% -100px, rgb(86 136 224 / 13%), transparent 70%), var(--bg); }
html[data-theme="dark"] .site-header { background: rgb(7 17 31 / 96%); border-bottom-color: rgb(161 190 232 / 16%); box-shadow: 0 8px 24px rgb(0 0 0 / 30%); }
html[data-theme="dark"] .nav-dropdown,
html[data-theme="dark"] .account-dropdown { background: #10223a; border-color: #304b6e; }
html[data-theme="dark"] .button { border-color: #385271; background: #182b45; color: var(--text); box-shadow: 0 1px 1px rgb(0 0 0 / 18%); }
html[data-theme="dark"] .button:hover { border-color: #6588b8; background: #203956; }
html[data-theme="dark"] .button-primary { border-color: #6097e8; background: #4f87d7; color: #061221; }
html[data-theme="dark"] .button-primary:hover { border-color: #91b8f2; background: #76a7ed; }
html[data-theme="dark"] .button-quiet { background: transparent; color: var(--quiet); }
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea { border-color: #385271; background: #0e1c30; color: var(--text); }
html[data-theme="dark"] input:hover,
html[data-theme="dark"] select:hover { border-color: #6688b5; }
html[data-theme="dark"] th { background: #192d47; color: #b6c6dd; }
html[data-theme="dark"] tbody tr:hover { background: #192d47; }
html[data-theme="dark"] .card,
html[data-theme="dark"] .table-wrap,
html[data-theme="dark"] .filter-panel,
html[data-theme="dark"] .filter-form,
html[data-theme="dark"] .summary-card,
html[data-theme="dark"] .dashboard-link { border-color: #2b4261; box-shadow: 0 8px 22px rgb(0 0 0 / 16%); }
html[data-theme="dark"] .table-wrap,
html[data-theme="dark"] .table-wrap table,
html[data-theme="dark"] .table-wrap tbody,
html[data-theme="dark"] .table-wrap tr,
html[data-theme="dark"] .table-wrap td { background: var(--surface); color: var(--text); }
html[data-theme="dark"] .shipment-statistic { border-color: #385271; background: #182b45; }
html[data-theme="dark"] .shipment-statistic strong { color: #a7c7fb; }
html[data-theme="dark"] .page-menu summary,
html[data-theme="dark"] .page-dropdown,
html[data-theme="dark"] .page-tabs { border-color: #385271; background: #13233a; color: var(--text); }
html[data-theme="dark"] .page-menu[open] summary,
html[data-theme="dark"] .page-menu summary:hover { background: #1a2e48; color: var(--text); }
html[data-theme="dark"] .page-dropdown a { color: var(--text); }
html[data-theme="dark"] .page-dropdown a:hover,
html[data-theme="dark"] .page-tabs a:hover { background: #1b314e; }
html[data-theme="dark"] .base-unit-note,
html[data-theme="dark"] .component-row,
html[data-theme="dark"] .batch-line { border-color: #314967; background: #182b45; }
html[data-theme="dark"] .definition-list div,
html[data-theme="dark"] .record-list li { border-color: #29415f; }
html[data-theme="dark"] .catalog-card,
html[data-theme="dark"] .product-image { border-color: #2b4261; background: #13233a; box-shadow: 0 7px 18px rgb(0 0 0 / 16%); }
html[data-theme="dark"] .catalog-card:hover { border-color: #587cab; }
html[data-theme="dark"] .catalog-card-photo,
html[data-theme="dark"] .product-thumbnail { border-color: #314967; background: #192d47; }
html[data-theme="dark"] .catalog-card-photo-empty { background: linear-gradient(135deg, #1a2d47, #102039); }
html[data-theme="dark"] .product-suggestions,
html[data-theme="dark"] .sku-product-suggestions,
html[data-theme="dark"] .marketplace-sku-filter-suggestions { border-color: #3a5578; background: #102039; box-shadow: 0 14px 28px rgb(0 0 0 / 32%); }
html[data-theme="dark"] .catalog-search-suggestions { border-color: #3a5578; background: #102039; box-shadow: 0 14px 28px rgb(0 0 0 / 32%); }
html[data-theme="dark"] .selected-product-visual,
html[data-theme="dark"] .product-suggestion-photo { border-color: #3a5578; background: #182b45; }

.shared-stock-builder { display: grid; gap: 18px; }
.shared-stock-builder-grid { display: grid; grid-template-columns: minmax(280px, .82fr) minmax(420px, 1.18fr); gap: 18px; align-items: start; }
.shared-stock-master-fields, .shared-stock-variant-picker { display: grid; gap: 16px; }
.shared-stock-master-fields label { display: grid; gap: 7px; }
.shared-stock-master-fields label:not(.shared-stock-image-picker) > span, .shared-stock-field-label, .shared-stock-search > label, .shared-stock-category-picker > label { color: var(--muted); font-size: .83rem; font-weight: 750; }
.shared-stock-field-label small { font-weight: 600; }
.shared-stock-image-field { display: grid; gap: 7px; }
.shared-stock-master-fields .shared-stock-image-picker { display: grid; grid-template-columns: 108px minmax(0, 1fr); gap: 12px; align-items: center; padding: 10px; border: 1px dashed var(--border-strong); border-radius: 14px; background: var(--surface-subtle); cursor: pointer; transition: border-color .16s ease, background-color .16s ease; }
.shared-stock-image-picker:hover, .shared-stock-image-picker:focus-within { border-color: var(--primary); background: var(--surface); }
.shared-stock-image-preview { display: grid; place-items: center; width: 108px; height: 82px; overflow: hidden; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--muted); text-align: center; }
.shared-stock-image-preview img { width: 100%; height: 100%; object-fit: contain; }
.shared-stock-image-preview > span { display: grid; gap: 3px; padding: 8px; }
.shared-stock-image-preview strong { color: var(--text); font-size: .82rem; }
.shared-stock-image-preview small { font-size: .7rem; }
.shared-stock-image-picker input[type="file"] { min-width: 0; max-width: 100%; font-size: .82rem; }
.shared-stock-image-picker input[type="file"]::file-selector-button { margin-right: 10px; padding: 8px 11px; border: 1px solid var(--border-strong); border-radius: 9px; background: var(--surface); color: var(--text); font: inherit; font-weight: 700; cursor: pointer; }
.section-heading { display: grid; gap: 5px; }
.section-heading h2 { margin: 0; }
.section-heading p { margin: 0; color: var(--muted); }
.shared-stock-search { position: relative; display: grid; gap: 7px; }
.shared-stock-search-results { top: 100%; }
.shared-stock-search-result { width: 100%; border: 0; text-align: left; cursor: pointer; }
.shared-stock-category-picker { position: relative; display: grid; gap: 7px; }
.shared-stock-category-results { top: 100%; }
.shared-stock-category-result { width: 100%; border: 0; background: transparent; text-align: left; cursor: pointer; font: inherit; }
.shared-stock-selection-heading { display: flex; justify-content: space-between; gap: 14px; align-items: baseline; padding-top: 4px; }
.shared-stock-selection-heading > span { color: var(--muted); font-size: .84rem; }
.shared-stock-selection { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.shared-stock-selection > li:not(.shared-stock-selection-empty) { display: flex; justify-content: space-between; gap: 14px; align-items: center; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-subtle); }
.shared-stock-selection li > div { display: grid; gap: 3px; min-width: 0; }
.shared-stock-selection li > div strong, .shared-stock-selection li > div span { overflow-wrap: anywhere; }
.shared-stock-selection li > div span { color: var(--muted); font-size: .84rem; }
.shared-stock-selection-empty { padding: 24px 16px; border: 1px dashed var(--border); border-radius: 12px; color: var(--muted); text-align: center; }
.shared-stock-confirmation { display: flex; justify-content: space-between; gap: 24px; align-items: center; }
.shared-stock-confirmation p { max-width: 72ch; margin: 5px 0 0; color: var(--muted); }
.field-error { color: var(--danger); font-weight: 700; }

@media (max-width: 860px) {
    .shared-stock-builder-grid { grid-template-columns: 1fr; }
    .shared-stock-confirmation { align-items: stretch; flex-direction: column; }
}

@media (max-width: 560px) {
    .shared-stock-master-fields .shared-stock-image-picker { grid-template-columns: 82px minmax(0, 1fr); }
    .shared-stock-image-preview { width: 82px; height: 72px; }
    .shared-stock-selection-heading { align-items: flex-start; flex-direction: column; }
    .shared-stock-selection > li:not(.shared-stock-selection-empty) { align-items: stretch; flex-direction: column; }
    .shared-stock-selection .button { width: 100%; }
}
html[data-theme="dark"] .product-suggestion,
html[data-theme="dark"] .sku-product-suggestion,
html[data-theme="dark"] .marketplace-sku-filter-suggestion { color: var(--text); }
html[data-theme="dark"] .product-suggestion:hover,
html[data-theme="dark"] .sku-product-suggestion:hover,
html[data-theme="dark"] .marketplace-sku-filter-suggestion:hover,
html[data-theme="dark"] .marketplace-sku-filter-suggestion:focus-visible { background: #1b3455; color: #dce9ff; }
html[data-theme="dark"] .catalog-search-suggestion:hover { background: #1b3455; color: #dce9ff; }
html[data-theme="dark"] .status { border-color: #3a506e; background: #1c304a; color: #c6d2e2; }
html[data-theme="dark"] .status-active,
html[data-theme="dark"] .status-approved,
html[data-theme="dark"] .status-synced { border-color: #36795a; background: #143e31; color: #7ee1ad; }
html[data-theme="dark"] .status-pending,
html[data-theme="dark"] .status-draft { border-color: #846523; background: #433718; color: #f5d77d; }
html[data-theme="dark"] .status-error,
html[data-theme="dark"] .status-rejected,
html[data-theme="dark"] .negative-row { border-color: #7b3e47; background: #3d2028; color: #ffd4d8; }
html[data-theme="dark"] .negative-row:hover { background: #4a2630; }
html[data-theme="dark"] .low-stock-row { background: #3d2724; color: #ffe1da; }
html[data-theme="dark"] .low-stock-row:hover { background: #4a302c; }
html[data-theme="dark"] .catalog-card-stock-low, html[data-theme="dark"] .low-stock-text { color: #ffaaa1; }
html[data-theme="dark"] .common-stock-badge,
html[data-theme="dark"] .common-stock-note { border-color: #365b87; background: #183252; }
html[data-theme="dark"] .common-stock-badge,
html[data-theme="dark"] .common-stock-note strong { color: #a9cbff; }
html[data-theme="dark"] .summary-card-warning { border-color: #804651; background: #39212a; }
html[data-theme="dark"] .sync-progress { border-color: #2b4261; background: var(--surface); }
html[data-theme="dark"] .sync-progress-counters > div { border-color: #314967; background: #182b45; }
html[data-theme="dark"] .sync-counter-error { border-color: #7b3e47 !important; background: #3d2028 !important; }
html[data-theme="dark"] .sync-counter-error strong { color: #ffaaa1; }
html[data-theme="dark"] .sync-progress-percent { background: #1b3455; color: #a7c7fb; }
html[data-theme="dark"] .progress-track { background: #0e1c30; }
html[data-theme="dark"] .sync-errors { border-color: #846523; background: #2e2819; }
html[data-theme="dark"] .raw-api-error code { background: #0e1c30; color: #c6d2e2; }
html[data-theme="dark"] .message-success { border-color: #36795a; background: #143e31; color: #7ee1ad; }
html[data-theme="dark"] .message-error { border-color: #7b3e47; background: #3d2028; color: #ffd4d8; }
html[data-theme="dark"] .message-warning { border-color: #846523; background: #433718; color: #f5d77d; }
html[data-theme="dark"] .finance-product-row[aria-expanded="true"],
html[data-theme="dark"] .finance-product-detail > td { background: #192d47; }
html[data-theme="dark"] .finance-profit-card { border-color: #3d6190; background: linear-gradient(135deg, #162b47, #1d3a60); }
html[data-theme="dark"] .finance-profit-card strong { color: #9fc5ff; }
html[data-theme="dark"] .finance-profit-card.finance-profit-negative { border-color: #7b3e47; background: linear-gradient(135deg, #39212a, #4a2630); }
html[data-theme="dark"] .finance-profit-card.finance-profit-negative strong { color: #ffb8c0; }
html[data-theme="dark"] .account-store-list a { background: #1c3453; color: #bcd6f8; }
html[data-theme="dark"] .account-store-list a:hover { background: #294a73; }
html[data-theme="dark"] .sync-switch { border-color: #846523; background: #433718; color: #f5d77d; }
html[data-theme="dark"] .sync-switch.is-active { border-color: #36795a; background: #143e31; color: #7ee1ad; }
html[data-theme="dark"] .sync-switch.is-active span { border-color: #7ee1ad; background: #7ee1ad; box-shadow: inset 0 0 0 2px #143e31; }
html[data-theme="dark"] .hero { border-color: #2d4668; background: linear-gradient(135deg, #152944 0%, #0e1c31 100%); box-shadow: 0 15px 34px rgb(0 0 0 / 22%); }
html[data-theme="dark"] .hero::after { background: radial-gradient(circle, rgb(84 144 236 / 18%), rgb(54 112 224 / 0%) 68%); }

/* Table labels remain in view while working through a long list. */
@media (min-width: 641px) {
    .table-wrap { max-height: calc(100vh - 150px); overflow: auto; }
    .table-wrap thead th { position: sticky; top: 0; z-index: 8; box-shadow: 0 1px 0 var(--border), 0 7px 10px rgb(26 46 77 / 5%); }
}

@media (max-width: 1080px) {
    .catalog-grid { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
}

@media (max-width: 1180px) {
    .filter-panel { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .filter-panel .search-field { grid-column: 1 / -1; }
    .catalog-filter-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .compact-filter-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
    .page-heading { align-items: start; flex-direction: column; }
    .heading-actions { width: 100%; justify-content: flex-start; }
    .filter-panel { grid-template-columns: 1fr 1fr; }
    .search-field { grid-column: 1 / -1; }
    .detail-grid { grid-template-columns: 1fr; }
    .batch-line { grid-template-columns: 1fr 1fr; }
    .dashboard-links { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    .shell { width: min(100% - 24px, 1240px); }
    .header-inner { min-height: 92px; grid-template-columns: auto 1fr; gap: 4px 8px; padding-block: 7px; }
    .brand { padding-inline: 4px; font-size: 1.04rem; }
    .site-header nav { grid-column: 1 / -1; grid-row: 2; justify-self: start; flex-wrap: wrap; gap: 1px; }
    .site-header nav > a { padding: 7px 8px; font-size: .8rem; }
    .nav-menu summary, .account-menu summary { padding: 7px 9px; font-size: .8rem; }
    .header-tools { grid-column: 2; grid-row: 1; justify-self: end; gap: 2px; }
    .account { font-size: .78rem; }
    .theme-toggle { min-width: 34px; min-height: 34px; justify-content: center; padding: 7px; }
    .theme-toggle-label { display: none; }
    .nav-dropdown { position: fixed; top: 100px; left: 12px; right: 12px; min-width: 0; max-height: calc(100vh - 116px); overflow-y: auto; }
    .account-dropdown { top: calc(100% + 8px); right: 0; }
    .page-content { padding-top: 26px; }
    .page-heading { align-items: start; flex-direction: column; }
    .heading-actions { width: 100%; justify-content: space-between; }
    .filter-panel { grid-template-columns: 1fr; }
    .catalog-filter-primary { grid-template-columns: 1fr; }
    .catalog-filter-primary .search-field { grid-column: auto; }
    .catalog-filter-primary .button { width: 100%; }
    .catalog-filter-options { grid-template-columns: 1fr; }
    .compact-filter-primary, .compact-search-panel .compact-filter-primary, .finance-filter-primary, .product-store-filter-primary { grid-template-columns: 1fr; }
    .compact-filter-primary .search-field { grid-column: auto; }
    .compact-filter-primary .button { width: 100%; }
    .compact-filter-options { grid-template-columns: 1fr; }
    .sync-progress { padding: 16px; }
    .sync-progress-counters { grid-template-columns: 1fr; }
    .sync-progress-heading { gap: 10px; }
    .sync-progress-percent { min-width: 58px; min-height: 44px; font-size: 1.15rem; }
    .sync-errors-content { padding-inline: 12px; }
    .shipment-statistics { grid-template-columns: 1fr; }
    .stock-card-heading { align-items: flex-start; flex-direction: column; gap: 3px; }
    .stock-data-freshness { white-space: normal; }
    .detail-grid-product .stock-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .detail-grid-product .stock-kpi { min-height: 96px; padding: 12px; }
    .detail-grid-product .stock-kpi > strong { font-size: 1.24rem; }
    .stock-location-list { grid-template-columns: 1fr; }
    .stock-cost { align-items: flex-start; flex-direction: column; gap: 2px; }
    .stock-cost strong { text-align: left; }
    .marketplace-position-list li { align-items: stretch; flex-direction: column; }
    .marketplace-position-controls { justify-content: flex-start; }
    .marketplace-position-controls > span { flex: 1 1 100%; white-space: normal; }
    .marketplace-position-controls .button { flex: 1 1 100%; width: 100%; min-height: 44px; }
    .stock-card-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .stock-card-actions .button { width: 100%; min-height: 44px; }
    .filter-form { display: grid; grid-template-columns: 1fr; }
    .catalog-grid { grid-template-columns: 1fr; gap: 10px; }
    .catalog-card { grid-template-columns: 96px minmax(0, 1fr); border-radius: 11px; }
    .catalog-card-photo { min-height: 132px; }
    .catalog-card-content { gap: 7px; padding: 10px; }
    .catalog-card-title { min-height: 3.15em; font-size: .86rem; line-height: 1.55; }
    .catalog-card-category { font-size: .74rem; }
    .catalog-card-marketplace > div { padding: 6px 7px; }
    .catalog-card-marketplace dt { font-size: .62rem; }
    .catalog-card-marketplace dd { font-size: .8rem; }
    .catalog-card-stock { font-size: .68rem; }
    .catalog-card-characteristic { font-size: .76rem; }
    .catalog-card .status { padding: 3px 7px; font-size: .68rem; }
    .product-thumbnail { width: 40px; height: 40px; flex-basis: 40px; }
    .product-thumbnail-small { width: 32px; height: 32px; flex-basis: 32px; }
    .scroll-top { right: 14px; bottom: 14px; width: 42px; height: 42px; }
    .message-with-action { align-items: stretch; flex-direction: column; }
    .message-with-action .button { width: 100%; }
    .section-heading { align-items: stretch; flex-direction: column; }
    .section-heading code { max-width: 100%; white-space: normal; }
    .balance-filter { grid-template-columns: 1fr; }
    .search-field { grid-column: auto; }
    .table-wrap { border: 0; overflow: visible; background: transparent; }
    table, thead, tbody, tr, th, td { display: block; }
    thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    tbody { display: grid; gap: 12px; }
    tr { padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
    td { display: grid; grid-template-columns: 110px 1fr; gap: 12px; padding: 6px 0; border: 0; }
    td::before { content: attr(data-label); color: var(--muted); font-size: .78rem; font-weight: 700; }
    .definition-list div { grid-template-columns: 1fr; gap: 2px; }
    .component-row { grid-template-columns: 1fr; }
    .version-heading { align-items: start; flex-direction: column; }
    .batch-header-grid, .batch-line { grid-template-columns: 1fr; }
    .line-formula { grid-column: auto; }
}

/* Warehouse Control Desk refresh: compact, token-led and task-first. */
:root {
    --bg: #f4f6f9;
    --surface: #ffffff;
    --surface-subtle: #f8fafc;
    --surface-raised: #ffffff;
    --text: #152033;
    --muted: #647187;
    --quiet: #49566b;
    --border: #dce2ea;
    --border-strong: #c3ccd8;
    --primary: #1f63d3;
    --primary-dark: #174ca2;
    --primary-soft: #edf4ff;
    --success: #087443;
    --success-soft: #edf9f2;
    --success-border: #abd9c2;
    --warning: #8a6100;
    --danger: #a52a32;
    --header-bg: #101b2c;
    --header-surface: #17263a;
    --header-border: #263a55;
    --header-muted: #9aacca;
    --active-soft: #e3eeff;
    --focus-ring: rgb(31 99 211 / 30%);
    --shadow-sm: 0 1px 2px rgb(21 32 51 / 5%);
    --shadow-md: 0 8px 24px rgb(21 32 51 / 8%);
}

body { font-size: 15px; background: var(--bg); }
.shell { width: min(1440px, calc(100% - 40px)); }
.skip-link { position: fixed; top: 8px; left: 8px; z-index: 100; padding: 9px 12px; border-radius: 6px; background: var(--primary); color: #fff; font-weight: 750; transform: translateY(-150%); }
.skip-link:focus { transform: translateY(0); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
.site-header { border-bottom: 1px solid var(--header-border); background: var(--header-bg); box-shadow: 0 3px 12px rgb(7 17 31 / 18%); }
.header-inner { min-height: 58px; gap: 10px; padding-block: 6px; }
.brand { display: inline-flex; align-items: center; gap: 8px; min-height: 42px; padding: 5px 8px; border-radius: 7px; }
.brand-logo { width: 27px; height: 27px; }
.brand > span { font-size: 1rem; letter-spacing: .015em; }
.primary-nav { gap: 1px; }
.site-header nav > a, .nav-menu summary, .account-menu summary { min-height: 38px; display: inline-flex; align-items: center; padding: 7px 9px; border-radius: 6px; font-size: .82rem; }
.nav-menu summary::after { content: ""; width: 6px; height: 6px; margin: -3px 1px 0 8px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg); }
.nav-menu[open] summary::after { margin-top: 3px; transform: rotate(225deg); }
.nav-dropdown, .account-dropdown { top: calc(100% + 7px); border-radius: 8px; background: var(--header-surface); box-shadow: 0 14px 32px rgb(5 12 23 / 34%); }
.site-header nav .nav-dropdown a { min-height: 36px; display: flex; align-items: center; border-radius: 5px; }
.theme-toggle { min-height: 38px; border-radius: 6px; }
.account-menu summary { gap: 7px; max-width: 180px; }
.account-summary-label { overflow: hidden; text-overflow: ellipsis; }
.account-status { width: 7px; height: 7px; flex: 0 0 7px; border-radius: 50%; background: #47c98a; box-shadow: 0 0 0 3px rgb(71 201 138 / 13%); }
.account-dropdown-label { color: var(--header-muted); font-size: .68rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.page-content { padding-block: 24px 64px; }
.page-heading { margin-bottom: 18px; }
.hero h1, .page-heading h1, .workspace-heading h1, .login-card h1 { font-size: clamp(1.65rem, 2.6vw, 2.25rem); letter-spacing: -.035em; }
.button { min-height: 38px; padding: 7px 12px; border-color: var(--border-strong); border-radius: 7px; box-shadow: var(--shadow-sm); font-size: .86rem; }
.button:hover { border-color: #8fa1b8; box-shadow: var(--shadow-sm); transform: none; }
.button:active { transform: translateY(1px); }
.button-primary { box-shadow: none; }
input, select { min-height: 40px; padding: 8px 10px; border-color: var(--border-strong); border-radius: 7px; background: var(--surface); }
.filter-panel, .filter-form { gap: 10px; margin-bottom: 18px; padding: 12px; border-color: var(--border); border-radius: 9px; box-shadow: var(--shadow-sm); }
.card, .table-wrap { border-color: var(--border); border-radius: 9px; box-shadow: var(--shadow-sm); }
.card { padding: 16px; }
th, td { padding: 10px 12px; }
th { background: var(--surface-subtle); color: var(--quiet); font-size: .69rem; letter-spacing: .055em; }
tbody tr:hover { background: var(--primary-soft); }
.status { border-radius: 5px; }
.empty-state { padding: 40px 20px; border-radius: 9px; }
.summary-card { min-height: 92px; padding: 14px; border-radius: 9px; box-shadow: var(--shadow-sm); }
.dashboard-link, .catalog-card { border-radius: 9px; box-shadow: var(--shadow-sm); }
.dashboard-link:hover, .catalog-card:hover { box-shadow: var(--shadow-md); transform: none; }

.workspace-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 28px; padding: 4px 0 20px; border-bottom: 1px solid var(--border); }
.workspace-heading h1 { margin: 0; }
.workspace-heading p:not(.eyebrow) { margin: 6px 0 0; color: var(--muted); }
.workspace-state { display: inline-flex; align-items: center; gap: 8px; min-height: 32px; padding: 6px 9px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-subtle); color: var(--quiet); font-size: .76rem; font-weight: 800; white-space: nowrap; }
.workspace-state > span { width: 7px; height: 7px; border-radius: 50%; background: var(--primary); }
.workspace-section + .workspace-section { margin-top: 28px; }
.workspace-section-heading { margin-bottom: 12px; }
.workspace-section-heading h2 { margin: 0; font-size: 1.05rem; }
.workspace-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--border); border-left: 1px solid var(--border); background: var(--surface); }
.workspace-link { min-height: 176px; display: grid; grid-template-rows: auto auto 1fr auto; gap: 7px; padding: 17px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); color: var(--text); text-decoration: none; }
.workspace-link:hover { position: relative; z-index: 1; background: var(--primary-soft); box-shadow: inset 3px 0 0 var(--primary); }
.workspace-link:active { background: var(--active-soft); }
.workspace-link-index { color: var(--muted); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .7rem; font-weight: 800; }
.workspace-link strong { font-size: 1.05rem; }
.workspace-link > span:nth-child(3) { max-width: 32ch; color: var(--muted); font-size: .84rem; }
.workspace-link-action { align-self: end; color: var(--primary); font-size: .78rem; font-weight: 800; }
.workspace-link-primary { box-shadow: inset 3px 0 0 var(--primary); }

.login-layout { min-height: calc(100dvh - 150px); display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 460px); align-items: center; gap: clamp(40px, 9vw, 140px); max-width: 1080px; margin-inline: auto; }
.login-context { padding-left: clamp(0px, 4vw, 50px); }
.login-context h1 { max-width: 650px; margin: 0; font-size: clamp(2.5rem, 6vw, 5.5rem); line-height: .98; letter-spacing: -.06em; }
.login-context > p:not(.eyebrow) { max-width: 520px; color: var(--muted); font-size: 1.05rem; }
.login-context-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 24px; }
.login-context-meta span { padding: 5px 8px; border-left: 2px solid var(--primary); background: var(--surface); color: var(--quiet); font-size: .72rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.form-card.login-card { width: 100%; max-width: none; margin: 0; padding: 28px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow-md); }
.login-card h1 { margin: 0; }
.login-intro { margin: 6px 0 22px; color: var(--muted); }
.login-card .stacked-form { display: grid; gap: 15px; }
.login-card .stacked-form p { display: grid; gap: 6px; margin: 0; }
.login-card label { color: var(--quiet); font-size: .78rem; font-weight: 800; }
.login-card .actions { margin-top: 3px; }
.login-card .button-primary { width: 100%; min-height: 42px; }

html[data-theme="dark"] {
    --bg: #0c1420;
    --surface: #121f30;
    --surface-subtle: #17263a;
    --surface-raised: #18283d;
    --text: #edf2f9;
    --muted: #9dacc1;
    --quiet: #c3cede;
    --border: #2a3b52;
    --border-strong: #3a506d;
    --primary: #73a7f5;
    --primary-dark: #a8c8f9;
    --primary-soft: #192e4b;
    --success-soft: #123829;
    --success-border: #2e7152;
    --danger: #ffadb3;
    --header-bg: #09111d;
    --header-surface: #10223a;
    --header-border: #263b56;
    --header-muted: #9fb1ca;
    --active-soft: #203a5e;
    --focus-ring: rgb(115 167 245 / 42%);
}
html[data-theme="dark"] body { background: var(--bg); }
html[data-theme="dark"] .workspace-grid { background: var(--surface); }
html[data-theme="dark"] .workspace-link:hover { background: var(--primary-soft); }
html[data-theme="dark"] .workspace-link:active { background: var(--active-soft); }
html[data-theme="dark"] tbody tr:hover td { background: var(--primary-soft); }
html[data-theme="dark"] .login-context-meta span { background: var(--surface); }
html[data-theme="dark"] .form-card.login-card { border-color: var(--border); background: var(--surface); box-shadow: 0 12px 30px rgb(0 0 0 / 24%); }

@media (max-width: 900px) {
    .workspace-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .login-layout { grid-template-columns: 1fr; gap: 28px; max-width: 560px; padding-block: 20px; }
    .login-context { padding-left: 0; }
    .login-context h1 { font-size: clamp(2.25rem, 10vw, 4rem); }
}

@media (max-width: 640px) {
    .shell { width: min(100% - 24px, 1440px); }
    .header-inner { min-height: 88px; }
    .workspace-heading { align-items: flex-start; flex-direction: column; gap: 12px; margin-bottom: 22px; }
    .workspace-grid { grid-template-columns: 1fr; }
    .workspace-link { min-height: 148px; }
    .login-layout { min-height: auto; padding-block: 8px 32px; }
    .login-context { display: none; }
    .form-card.login-card { padding: 22px 18px; }
    tr { border-radius: 8px; }
    td { grid-template-columns: minmax(88px, 34%) 1fr; overflow-wrap: anywhere; }
    td:not([data-label]) { grid-template-columns: 1fr; }
    td:not([data-label])::before { display: none; content: none; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* P1: shared information architecture for catalogue and inventory workflows. */
:root {
    --warning-soft: #fff8df;
    --warning-border: #e5c267;
    --warning-text: #765600;
    --danger-soft: #fff0f0;
    --danger-border: #e5a3a3;
    --danger-text: #9f2525;
    --table-row-hover: var(--primary-soft);
    --section-divider: var(--border);
    --sticky-surface: rgb(244 246 249 / 94%);
}

.page-heading-command { min-height: 66px; align-items: center; margin-bottom: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--section-divider); }
.page-heading-command h1 { line-height: 1.08; }
.page-heading-command .eyebrow { margin-bottom: 5px; }
.page-heading-command .result-count { padding-right: 3px; font-size: .78rem; }
.heading-actions form { margin: 0; }
.back-link { margin-bottom: 12px; color: var(--quiet); font-size: .8rem; }
.back-link:hover { color: var(--primary); }

.compact-filter-panel, .catalog-filter-panel { position: relative; margin-bottom: 14px; padding: 10px 12px; }
.compact-filter-primary, .catalog-filter-primary { gap: 8px; }
.compact-filter-disclosure, .catalog-filter-disclosure { margin-top: 7px; }
.compact-filter-disclosure summary, .catalog-filter-disclosure summary { padding-top: 8px; font-size: .78rem; }
.compact-filter-options, .catalog-filter-options { gap: 8px; }
.filter-panel label > span, .filter-form label > span { color: var(--quiet); font-size: .74rem; }

.data-table-shell { border-radius: 8px; }
.data-table { font-variant-numeric: tabular-nums; }
.data-table th { height: 38px; white-space: nowrap; }
.data-table td { height: 50px; }
.data-table tbody tr:hover td { background: var(--table-row-hover); }
.data-table .product-with-thumbnail { line-height: 1.3; }
.data-table .product-thumbnail { width: 38px; height: 38px; flex-basis: 38px; }
.balance-product-copy { display: grid; gap: 2px; min-width: 0; }
.balance-product-copy strong { color: inherit; }
.balance-product-copy small { color: var(--quiet); font-size: .72rem; font-weight: 650; }
.compact-table { border-radius: 7px; box-shadow: none; }
.compact-table th, .compact-table td { height: auto; padding-block: 8px; }
.pagination { gap: 8px; margin-top: 14px; color: var(--muted); font-size: .8rem; }
.pagination a, .pagination span { min-height: 34px; display: inline-flex; align-items: center; padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); text-decoration: none; }
.pagination a:hover { border-color: var(--border-strong); background: var(--primary-soft); }

.control-card-grid { gap: 10px; }
.control-card-grid .catalog-card { min-height: 142px; }
.control-card-grid .catalog-card-content { gap: 5px; padding: 12px 14px; }
.control-card-grid .catalog-card-actions { gap: 6px; }
.detail-grid-product, .detail-grid-document { gap: 12px; }
.detail-grid-product .card, .detail-grid-document > .card { padding: 15px; }
.detail-grid-product .card > h2, .detail-grid-document > .card > h2 { margin-bottom: 12px; padding-bottom: 9px; border-bottom: 1px solid var(--section-divider); font-size: .92rem; }
.detail-grid-product .definition-list div, .detail-grid-document .definition-list div { padding: 7px 0; }
.detail-grid-product .record-list li, .detail-grid-document .record-list li { padding: 8px 0; }
.detail-grid-product .shipment-statistics { gap: 7px; }
.detail-grid-product .shipment-statistic { min-height: 78px; padding: 9px 11px; border-color: var(--border); border-radius: 7px; background: var(--surface-subtle); }
.detail-grid-product .shipment-statistic strong { font-size: 1.12rem; }
.marketplace-flow-panel { margin: 2px 0 16px; }
.marketplace-flow-heading { margin: 0 0 12px; padding-bottom: 10px; border-bottom: 2px solid var(--success-border); color: var(--text); font-size: .95rem; }
.marketplace-flow-panel.is-attention .marketplace-flow-heading { border-bottom-color: var(--warning-border); }
.marketplace-flow-table-wrap { overflow-x: auto; }
/* Reconciliation ledger: the element is still a real <table> (kept for screen readers
   and for the other product-flow page's unrelated reuse of the "marketplace-flow-table"
   class name on a div), but it renders as a stack of grouped cards, not a grid table. */
table.marketplace-flow-table { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; width: 100%; color: var(--quiet); font-size: .8rem; }
table.marketplace-flow-table thead { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
/* Each tbody is one compact, non-interactive panel: a plain heading line, then its
   rows as a flat list (no per-row border, so rows read as data, not as buttons). */
table.marketplace-flow-table tbody { display: block; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
table.marketplace-flow-table th, table.marketplace-flow-table td { display: block; padding: 0; border: 0; background: transparent; text-align: left; }
table.marketplace-flow-table tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; column-gap: 10px; padding: 6px 0; border: 0; border-radius: 0; background: transparent; }
table.marketplace-flow-table tr + tr { border-top: 1px solid var(--section-divider); }
table.marketplace-flow-table tbody tr:hover,
table.marketplace-flow-table tbody tr:hover td,
html[data-theme="dark"] table.marketplace-flow-table tbody tr:hover,
html[data-theme="dark"] table.marketplace-flow-table tbody tr:hover td { background: transparent; }
table.marketplace-flow-table tr.marketplace-flow-group { padding: 0 0 8px; border-top: 0; }
table.marketplace-flow-table tr.marketplace-flow-group + tr { border-top: 0; }
table.marketplace-flow-table tr.marketplace-flow-group th { color: var(--primary-dark); font-size: .72rem; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; }
table.marketplace-flow-table tr.marketplace-flow-total { font-weight: 750; }
table.marketplace-flow-table td:last-child { color: var(--text); text-align: right; font-variant-numeric: tabular-nums; font-weight: 650; white-space: nowrap; }
table.marketplace-flow-table tr.marketplace-flow-total td:last-child { font-weight: 800; }
table.marketplace-flow-table tr.marketplace-flow-control td:first-child { color: var(--warning-text); }
table.marketplace-flow-table tr.marketplace-flow-control td:last-child { color: var(--warning-text); font-weight: 800; }
/* "Разница" renders as an ordinary group card so it can sit paired next to any
   other group in the 2-column grid, not as a stretched, oversized closing bar. */
table.marketplace-flow-table tfoot { display: block; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
table.marketplace-flow-table tfoot tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; column-gap: 10px; padding: 0; border: 0; background: transparent; }
table.marketplace-flow-table tfoot th { color: var(--text); font-size: .8rem; font-weight: 750; }
table.marketplace-flow-table tfoot td { color: var(--success); font-size: 1rem; font-weight: 800; font-variant-numeric: tabular-nums; text-align: right; }
table.marketplace-flow-table tfoot.is-attention td { color: var(--warning-text); }
.marketplace-flow-note { margin: 10px 2px; color: var(--muted); font-size: .78rem; line-height: 1.5; }
.marketplace-flow-panel > .button { margin: 4px 0 6px; }
.marketplace-flow-summary { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 1px; overflow: hidden; margin-bottom: 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--border); }
.marketplace-flow-summary > div { display: grid; gap: 4px; padding: 13px 14px; background: var(--surface); }
.marketplace-flow-summary span { color: var(--muted); font-size: .75rem; }
.marketplace-flow-summary strong { font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.marketplace-flow-filter { display: grid; grid-template-columns: repeat(4, minmax(130px, 1fr)); gap: 10px; align-items: end; }
.marketplace-flow-filter label { min-width: 0; }
.marketplace-flow-search { grid-column: span 2; }
.marketplace-flow-table .table-cell-note { display: block; margin-top: 2px; color: var(--muted); font-size: .7rem; }
.detail-grid-document .card-wide > p { margin-block: 8px; }

.entity-form { max-width: 820px; }
.entity-form > div:not(.actions):not(.form-errors), .operation-form .batch-header-grid > div, .operation-form .batch-line > div { gap: 5px; }
.entity-form label, .operation-form label { color: var(--quiet); font-size: .78rem; }
.operation-form { gap: 12px; }
.operation-form > .card, .operation-form-shell { border-radius: 8px; }
.operation-form > .card > h2, .operation-form-shell h2 { margin-bottom: 5px; font-size: .95rem; }
.operation-notice { margin-bottom: 12px; border-color: var(--warning-border); background: var(--warning-soft); color: var(--warning-text); font-size: .82rem; }
.operation-form .batch-header-grid { gap: 10px; }
.operation-form .batch-line-list { gap: 8px; }
.operation-form .batch-line { gap: 9px; padding: 12px 12px 10px 38px; border-color: var(--border); border-radius: 7px; background: var(--surface-subtle); }
.operation-form .line-number { top: 18px; left: 12px; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .72rem; }
.operation-form .line-formula { min-height: 26px; padding-top: 7px; border-top: 1px dashed var(--border); font-size: .76rem; }
.operation-form .errorlist, .entity-form .errorlist { color: var(--danger-text); }
.form-submit-bar { position: sticky; bottom: 0; z-index: 12; justify-content: flex-end; margin: 0; padding: 12px 0; background: var(--sticky-surface); backdrop-filter: blur(8px); }
.form-submit-bar::before { content: ""; position: absolute; top: 0; right: 0; left: 0; border-top: 1px solid var(--border); }
.form-submit-bar .button-primary { min-width: 190px; }
.empty-state { max-width: 720px; margin-inline: auto; border-color: var(--border-strong); background: var(--surface); }
.empty-state h2 { margin-bottom: 5px; font-size: 1rem; }
.empty-state p { margin-top: 0; }
.message-error, .form-errors .errorlist { border-color: var(--danger-border); background: var(--danger-soft); color: var(--danger-text); }
.message-warning, .duplicate-warning { border-color: var(--warning-border); background: var(--warning-soft); color: var(--warning-text); }

html[data-theme="dark"] {
    --warning-soft: #3d3218;
    --warning-border: #806422;
    --warning-text: #f3d477;
    --danger-soft: #3d2028;
    --danger-border: #7b3e47;
    --danger-text: #ffd4d8;
    --sticky-surface: rgb(12 20 32 / 92%);
}
.button.button-danger { border-color: var(--danger-border); background: var(--danger-soft); color: var(--danger-text); box-shadow: none; }
.button.button-danger:hover { border-color: var(--danger-text); background: var(--danger-text); color: #fff; box-shadow: none; }
html[data-theme="dark"] .button.button-danger { border-color: var(--danger-border); background: var(--danger-soft); color: var(--danger-text); }
html[data-theme="dark"] .button.button-danger:hover { border-color: var(--danger-border); background: var(--danger-border); color: #fff; }
html[data-theme="dark"] .detail-grid-product .shipment-statistic { border-color: var(--border); background: var(--surface-subtle); }
html[data-theme="dark"] .operation-form .batch-line { border-color: var(--border); background: var(--surface-subtle); }
html[data-theme="dark"] .operation-notice { border-color: var(--warning-border); background: var(--warning-soft); color: var(--warning-text); }
html[data-theme="dark"] .pagination a, html[data-theme="dark"] .pagination span { background: var(--surface); }

@media (max-width: 860px) {
    .page-heading-command { align-items: flex-start; min-height: 0; }
    .detail-grid-product, .detail-grid-document { gap: 10px; }
    .marketplace-flow-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .marketplace-flow-filter { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
    .page-heading-command { padding-bottom: 12px; }
    .page-heading-command .heading-actions { gap: 7px; }
    .page-heading-command .heading-actions .button { flex: 1 1 auto; }
    .data-table td { height: auto; }
    .data-table .product-thumbnail { width: 36px; height: 36px; flex-basis: 36px; }
    .pagination { flex-wrap: wrap; }
    .pagination span { order: -1; width: 100%; justify-content: center; }
    .operation-form > .card, .operation-form-shell { padding: 13px; }
    .operation-form .batch-line { padding: 35px 10px 10px; }
    .operation-form .line-number { top: 10px; left: 10px; }
    .form-submit-bar { position: static; padding-top: 12px; background: transparent; backdrop-filter: none; }
    .form-submit-bar .button, .form-submit-bar .button-primary { width: 100%; }
    .marketplace-flow-summary, .marketplace-flow-filter { grid-template-columns: 1fr; }
    .marketplace-flow-search { grid-column: auto; }
}

/* Review fixes: semantic warning actions and inventory exception rows. */
:root {
    --warning-action-bg: #f3b82f;
    --warning-action-border: #c88a08;
    --warning-action-text: #332300;
    --warning-action-hover-bg: #dfa51f;
    --warning-action-hover-border: #a86f00;
    --warning-action-active-bg: #ca9213;
    --warning-action-focus: rgb(138 97 0 / 32%);
    --low-row-bg: #fff7f3;
    --low-row-hover: #ffebe3;
    --negative-row-bg: #fff0f1;
    --negative-row-hover: #ffe1e4;
    --exception-row-text: var(--text);
}

.button-warning {
    border-color: var(--warning-action-border);
    background: var(--warning-action-bg);
    color: var(--warning-action-text);
}
.button-warning:hover {
    border-color: var(--warning-action-hover-border);
    background: var(--warning-action-hover-bg);
    color: var(--warning-action-text);
}
.button-warning:active {
    border-color: var(--warning-action-hover-border);
    background: var(--warning-action-active-bg);
    color: var(--warning-action-text);
}
.button-warning:focus-visible {
    outline-color: var(--warning-action-focus);
    color: var(--warning-action-text);
}
.duplicate-warning h2,
.duplicate-warning p,
.duplicate-warning li,
.duplicate-warning li span { color: var(--warning-text); }
.duplicate-warning a { color: var(--primary-dark); }
.duplicate-warning a:hover { color: var(--primary); }

.low-stock-row > td { background: var(--low-row-bg); color: var(--exception-row-text); }
.low-stock-row:hover > td { background: var(--low-row-hover); color: var(--exception-row-text); }
.negative-row > td,
.low-stock-row.negative-row > td { background: var(--negative-row-bg); color: var(--exception-row-text); }
.negative-row:hover > td,
.low-stock-row.negative-row:hover > td { background: var(--negative-row-hover); color: var(--exception-row-text); }

html[data-theme="dark"] {
    --warning-action-bg: #d6a637;
    --warning-action-border: #f0c765;
    --warning-action-text: #171105;
    --warning-action-hover-bg: #e8ba4d;
    --warning-action-hover-border: #ffe092;
    --warning-action-active-bg: #c5962d;
    --warning-action-focus: rgb(245 197 104 / 42%);
    --low-row-bg: #352521;
    --low-row-hover: #44302a;
    --negative-row-bg: #392129;
    --negative-row-hover: #4a2933;
    --exception-row-text: #f4e9eb;
}
html[data-theme="dark"] .duplicate-warning h2,
html[data-theme="dark"] .duplicate-warning p,
html[data-theme="dark"] .duplicate-warning li,
html[data-theme="dark"] .duplicate-warning li span { color: var(--warning-text); }
html[data-theme="dark"] .duplicate-warning a { color: var(--primary); }
html[data-theme="dark"] .duplicate-warning a:hover { color: var(--primary-dark); }

/* These qualified overrides intentionally outrank the generic dark controls/table cells above. */
html[data-theme="dark"] .button-warning {
    border-color: var(--warning-action-border);
    background: var(--warning-action-bg);
    color: var(--warning-action-text);
}
html[data-theme="dark"] .button-warning:hover {
    border-color: var(--warning-action-hover-border);
    background: var(--warning-action-hover-bg);
    color: var(--warning-action-text);
}
html[data-theme="dark"] .button-warning:active {
    border-color: var(--warning-action-hover-border);
    background: var(--warning-action-active-bg);
    color: var(--warning-action-text);
}
html[data-theme="dark"] .button-warning:focus-visible {
    outline-color: var(--warning-action-focus);
    color: var(--warning-action-text);
}

.data-table tbody .low-stock-row > td { background: var(--low-row-bg); color: var(--exception-row-text); }
.data-table tbody .low-stock-row:hover > td { background: var(--low-row-hover); color: var(--exception-row-text); }
.data-table tbody .negative-row > td,
.data-table tbody .low-stock-row.negative-row > td { background: var(--negative-row-bg); color: var(--exception-row-text); }
.data-table tbody .negative-row:hover > td,
.data-table tbody .low-stock-row.negative-row:hover > td { background: var(--negative-row-hover); color: var(--exception-row-text); }
html[data-theme="dark"] .data-table tbody .low-stock-row > td { background: var(--low-row-bg); color: var(--exception-row-text); }
html[data-theme="dark"] .data-table tbody .low-stock-row:hover > td { background: var(--low-row-hover); color: var(--exception-row-text); }
html[data-theme="dark"] .data-table tbody .negative-row > td,
html[data-theme="dark"] .data-table tbody .low-stock-row.negative-row > td { background: var(--negative-row-bg); color: var(--exception-row-text); }
html[data-theme="dark"] .data-table tbody .negative-row:hover > td,
html[data-theme="dark"] .data-table tbody .low-stock-row.negative-row:hover > td { background: var(--negative-row-hover); color: var(--exception-row-text); }

/* P2: Marketplace control surfaces. */
:root {
    --marketplace-kpi-bg: var(--surface);
    --marketplace-kpi-accent: var(--primary);
    --marketplace-row-alert: var(--warning-soft);
    --marketplace-row-alert-hover: #fff0bd;
    --marketplace-danger-soft: var(--danger-soft);
    --marketplace-danger-border: var(--danger-border);
    --marketplace-danger-text: var(--danger-text);
    --marketplace-sticky-shadow: 7px 0 12px rgb(21 32 51 / 7%);
}

.marketplace-page { min-width: 0; }
.marketplace-page > .page-heading { min-height: 66px; align-items: center; margin-bottom: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.marketplace-page > .page-heading h1 { line-height: 1.08; }
.marketplace-page > .page-heading .muted { max-width: 72ch; margin: 5px 0 0; font-size: .84rem; }
.marketplace-page > .filter-form,
.marketplace-page > .filter-panel { margin-bottom: 14px; }
.marketplace-page .table-card,
.marketplace-page > .card { border-radius: 8px; }
.marketplace-page .card > h2:first-child { margin-bottom: 12px; padding-bottom: 9px; border-bottom: 1px solid var(--border); font-size: .95rem; }
.marketplace-page table { font-variant-numeric: tabular-nums; }
.marketplace-page th { height: 38px; padding: 8px 10px; white-space: nowrap; }
.marketplace-page td { padding: 9px 10px; }
.marketplace-page tbody tr:hover td { background: var(--primary-soft); }
.marketplace-page .summary-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; margin-bottom: 14px; }
.marketplace-page .summary-card { position: relative; min-height: 94px; gap: 3px; overflow: hidden; padding: 13px; background: var(--marketplace-kpi-bg); }
.marketplace-page .summary-card::before { content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 3px; background: var(--marketplace-kpi-accent); }
.marketplace-page .summary-card strong { font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.marketplace-page .summary-card-warning::before { background: var(--warning); }
.marketplace-page .section-heading { margin-bottom: 10px; }
.marketplace-page .section-heading h2 { font-size: .95rem; }
.marketplace-page .section-heading p { font-size: .8rem; }
.marketplace-page .status,
.marketplace-page .status-badge { min-height: 24px; align-items: center; border-radius: 5px; }
.marketplace-page .money-table th:not(:first-child),
.marketplace-page .money-table td:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }
.marketplace-page .money-table td:first-child { text-align: left; }
.marketplace-page .table-row-alert > td { background: var(--marketplace-row-alert); }
.marketplace-page .table-row-alert:hover > td { background: var(--marketplace-row-alert-hover); }

.marketplace-finance-page .table-wrap { max-width: 100%; overflow-x: auto; }
.marketplace-finance-page table { min-width: 860px; }
.marketplace-finance-page th:first-child,
.marketplace-finance-page td:first-child { position: sticky; left: 0; z-index: 2; background: var(--surface); box-shadow: var(--marketplace-sticky-shadow); }
.marketplace-finance-page th:first-child { z-index: 10; background: var(--surface-subtle); }
.marketplace-finance-page tbody tr:hover td:first-child { background: var(--primary-soft); }
.marketplace-finance-page .finance-product-detail > td { position: static; box-shadow: none; }
.marketplace-finance-page .finance-product-detail table td:first-child,
.marketplace-finance-page .finance-product-detail table th:first-child { position: sticky; }
.marketplace-finance-page tr[hidden] { display: none !important; }

.marketplace-sync-page .sync-progress { margin-bottom: 14px; padding: 16px; border-radius: 8px; }
.marketplace-sync-page .sync-progress-counters { gap: 7px; margin-block: 12px 10px; }
.marketplace-sync-page .sync-progress-counters > div { min-height: 64px; padding: 10px; border-radius: 7px; }
.marketplace-sync-page .sync-errors { border-color: var(--warning-border); border-radius: 8px; background: var(--warning-soft); }
.marketplace-sync-page .sync-errors > summary { min-height: 54px; }
.marketplace-sync-page .raw-api-error code { border: 1px solid var(--border); background: var(--surface-subtle); }
.marketplace-sync-page [data-progress-state] { min-height: 1.4em; }
.marketplace-sync-page .dashboard-links { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 8px; }
.marketplace-sync-page .dashboard-link { min-height: 112px; padding: 15px; }
.local-sync-control { display: grid; gap: 14px; }
.local-sync-heading { margin-bottom: 0; }
.local-sync-primary { display: flex; align-items: center; justify-content: space-between; gap: 22px; padding-block: 14px; border-block: 1px solid var(--border); }
.local-sync-primary > div { display: grid; gap: 4px; max-width: 68ch; }
.local-sync-primary span { color: var(--muted); font-size: .9rem; line-height: 1.5; }
.local-sync-primary .button { flex: 0 0 auto; min-width: 270px; }
.local-sync-secondary > summary, .local-sync-result > summary { width: fit-content; color: var(--primary); font-weight: 700; cursor: pointer; }
.local-sync-secondary-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; margin-top: 12px; }
.local-sync-secondary-actions form { margin: 0; }
.local-sync-secondary-actions p { flex-basis: 100%; margin: 0; }
.local-sync-running { display: flex; align-items: center; gap: 11px; min-height: 54px; padding: 13px 15px; border: 1px solid var(--primary); border-radius: 8px; background: var(--primary-soft); }
.local-sync-pulse { width: 10px; height: 10px; flex: 0 0 auto; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 5px color-mix(in srgb, var(--primary) 16%, transparent); }
.local-sync-last-run { margin: 0; color: var(--muted); }
.local-sync-result pre { max-height: 260px; margin: 10px 0 0; padding: 12px; overflow: auto; border: 1px solid var(--border); border-radius: 7px; background: var(--surface-subtle); color: var(--text); white-space: pre-wrap; }

.marketplace-accounts-page .filter-form { grid-template-columns: repeat(3, minmax(0, 1fr)) auto; }
.marketplace-accounts-page input[type="password"],
.marketplace-store-detail-page input[type="password"] { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.marketplace-page .inline-email-form { display: grid; grid-template-columns: minmax(150px, 1fr) auto; }
.marketplace-page .inline-email-form input { width: 100%; }
.marketplace-store-detail-page .detail-grid { gap: 10px; }
.marketplace-store-detail-page .detail-grid > .card { padding: 15px; }
.marketplace-store-detail-page input[name="action"][value="revoke"] + .button {
    border-color: var(--marketplace-danger-border);
    background: var(--marketplace-danger-soft);
    color: var(--marketplace-danger-text);
}
.marketplace-store-detail-page input[name="action"][value="revoke"] + .button:hover { filter: brightness(.97); }
.marketplace-page .sync-switch { border-radius: 6px; }
.marketplace-page .sync-checkbox-form label { min-height: 34px; }
.marketplace-page .empty-queue { padding: 24px; border: 1px dashed var(--border-strong); border-radius: 7px; background: var(--surface-subtle); text-align: center; }

html[data-theme="dark"] {
    --marketplace-row-alert: #3a3019;
    --marketplace-row-alert-hover: #493c1d;
    --marketplace-sticky-shadow: 7px 0 12px rgb(0 0 0 / 20%);
}
html[data-theme="dark"] .marketplace-page .table-row-alert > td { background: var(--marketplace-row-alert); }
html[data-theme="dark"] .marketplace-page .table-row-alert:hover > td { background: var(--marketplace-row-alert-hover); }
html[data-theme="dark"] .marketplace-finance-page th:first-child { background: var(--surface-subtle); }
html[data-theme="dark"] .marketplace-finance-page td:first-child { background: var(--surface); }
html[data-theme="dark"] .marketplace-finance-page tbody tr:hover td:first-child { background: var(--primary-soft); }
html[data-theme="dark"] .marketplace-sync-page .sync-errors { border-color: var(--warning-border); background: var(--warning-soft); }
html[data-theme="dark"] .marketplace-sync-page .raw-api-error code { background: var(--surface-subtle); color: var(--text); }
html[data-theme="dark"] .local-sync-running { border-color: #416fa8; background: #182e49; }

@media (max-width: 900px) {
    .marketplace-page > .page-heading { align-items: flex-start; min-height: 0; }
    .marketplace-accounts-page .filter-form { display: grid; grid-template-columns: 1fr 1fr; }
    .marketplace-accounts-page .filter-form label:first-child { grid-column: 1 / -1; }
}

@media (max-width: 640px) {
    .marketplace-page > .page-heading { padding-bottom: 12px; }
    .marketplace-page > .page-heading .heading-actions { gap: 7px; }
    .marketplace-page > .page-heading .heading-actions .button { flex: 1 1 auto; }
    .marketplace-operational-page .table-wrap { overflow: visible; }
    .marketplace-operational-page table,
    .marketplace-operational-page thead,
    .marketplace-operational-page tbody,
    .marketplace-operational-page tr,
    .marketplace-operational-page th,
    .marketplace-operational-page td { display: block; }
    .marketplace-operational-page thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    .marketplace-operational-page tbody { display: grid; gap: 8px; }
    .marketplace-operational-page tr { padding: 10px; }
    .marketplace-operational-page td { display: grid; grid-template-columns: minmax(92px, 34%) 1fr; gap: 9px; height: auto; padding: 6px 0; }
    .marketplace-operational-page td:not([data-label]) { grid-template-columns: 1fr; }
    .marketplace-operational-page td:not([data-label])::before { display: none; content: none; }
    .marketplace-finance-page .table-wrap { overflow-x: auto; border: 1px solid var(--border); background: var(--surface); }
    .marketplace-finance-page table { min-width: 860px; display: table; }
    .marketplace-finance-page thead { position: static; width: auto; height: auto; overflow: visible; clip: auto; display: table-header-group; }
    .marketplace-finance-page tbody { display: table-row-group; }
    .marketplace-finance-page tr { display: table-row; padding: 0; border: 0; border-radius: 0; }
    .marketplace-finance-page th,
    .marketplace-finance-page td { display: table-cell; height: auto; padding: 8px 10px; }
    .marketplace-finance-page td::before { display: none; content: none; }
    .marketplace-accounts-page .filter-form { grid-template-columns: 1fr; }
    .marketplace-accounts-page .filter-form label:first-child { grid-column: auto; }
    .marketplace-page .inline-email-form { grid-template-columns: 1fr; }
    .marketplace-sync-page .sync-progress-counters { grid-template-columns: 1fr; }
    .local-sync-primary { align-items: stretch; flex-direction: column; }
    .local-sync-primary .button { width: 100%; min-width: 0; }
}

/* P2 review: numeric columns and alert-sticky cells require scoped, late overrides. */
.marketplace-reconciliation-page table th:nth-child(n + 2),
.marketplace-reconciliation-page table td:nth-child(n + 2),
.marketplace-stock-page table th:nth-child(n + 4),
.marketplace-stock-page table td:nth-child(n + 4),
.marketplace-fragment table th:nth-child(n + 2),
.marketplace-fragment table td:nth-child(n + 2),
.marketplace-finance-page:not(.marketplace-reconciliation-page):not(.marketplace-stock-page):not(.marketplace-fragment) section:first-of-type table th:nth-child(n + 2),
.marketplace-finance-page:not(.marketplace-reconciliation-page):not(.marketplace-stock-page):not(.marketplace-fragment) section:first-of-type table td:nth-child(n + 2),
.marketplace-finance-page:not(.marketplace-reconciliation-page):not(.marketplace-stock-page):not(.marketplace-fragment) section:last-of-type table th:nth-child(n + 5),
.marketplace-finance-page:not(.marketplace-reconciliation-page):not(.marketplace-stock-page):not(.marketplace-fragment) section:last-of-type table td:nth-child(n + 5) {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.marketplace-stock-page .table-row-alert > th:first-child,
.marketplace-stock-page .table-row-alert > td:first-child {
    background: var(--marketplace-row-alert);
}
.marketplace-stock-page .table-row-alert:hover > th:first-child,
.marketplace-stock-page .table-row-alert:hover > td:first-child {
    background: var(--marketplace-row-alert-hover);
}
html[data-theme="dark"] .marketplace-stock-page .table-row-alert > th:first-child,
html[data-theme="dark"] .marketplace-stock-page .table-row-alert > td:first-child {
    background: var(--marketplace-row-alert);
}
html[data-theme="dark"] .marketplace-stock-page .table-row-alert:hover > th:first-child,
html[data-theme="dark"] .marketplace-stock-page .table-row-alert:hover > td:first-child {
    background: var(--marketplace-row-alert-hover);
}

/* P3: remaining operator-facing reference, list, detail and form screens. */
:root {
    --control-code-bg: #eef3f8;
    --control-code-text: #243b5a;
    --control-info-bg: #f1f6fc;
    --control-info-border: #cbd9ea;
}

.control-page { min-width: 0; }
.control-page > .page-heading { min-height: 66px; align-items: center; margin-bottom: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.control-page > .page-heading h1 { line-height: 1.08; }
.control-page > .page-heading .eyebrow { margin-bottom: 5px; }
.control-page > .filter-panel,
.control-page > .filter-form { margin-bottom: 14px; }
.control-page > .message { margin-bottom: 12px; border-color: var(--control-info-border); background: var(--control-info-bg); font-size: .82rem; }
.control-page > .message-warning { border-color: var(--warning-border); background: var(--warning-soft); color: var(--warning-text); }
.control-page > .card,
.control-page .detail-grid > .card { border-radius: 8px; }
.control-page .card > h2:first-child { margin-bottom: 12px; padding-bottom: 9px; border-bottom: 1px solid var(--border); font-size: .95rem; }
.control-page table { font-variant-numeric: tabular-nums; }
.control-page th { height: 38px; padding: 8px 10px; white-space: nowrap; }
.control-page td { padding: 9px 10px; }
.control-page tbody tr:hover td { background: var(--primary-soft); }
.control-page .summary-grid { gap: 8px; margin-bottom: 14px; }
.control-page .summary-card { min-height: 92px; padding: 13px; }
.control-page .summary-card strong { font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.control-page .detail-grid { gap: 10px; }
.control-page .detail-grid > .card { padding: 15px; }
.control-page .definition-list div { padding-block: 7px; }
.control-page .record-list li { padding-block: 8px; }
.control-page .empty-state { padding-block: 34px; }

.reference-page .card { padding: 16px; }
.reference-page code,
.audit-page code { padding: 2px 5px; border-radius: 4px; background: var(--control-code-bg); color: var(--control-code-text); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .8em; }
.reference-page td:nth-child(1) { width: 74px; color: var(--primary-dark); font-weight: 850; }
.reference-page td:nth-child(2) { min-width: 300px; }

.operation-page { max-width: 980px; margin-inline: auto; }
.operation-page > .page-heading { min-height: 58px; }
.operation-page > .card { padding: 16px; }
.operation-page .edit-form,
.operation-page .stacked-form { gap: 12px; }
.operation-page .edit-form > div:not(.actions),
.operation-page .stacked-form > p { gap: 5px; }
.operation-page label { color: var(--quiet); font-size: .78rem; font-weight: 750; }
.operation-page .actions { justify-content: flex-end; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.operation-page .actions .button-primary,
.operation-page .actions .button-warning { min-width: 190px; }
.inventory-operation-page .batch-document-form { gap: 10px; }
.inventory-operation-page .batch-line { border-color: var(--border); border-radius: 7px; background: var(--surface-subtle); }
.identity-operation-page { min-height: calc(100dvh - 150px); display: grid; place-items: center; }
.identity-operation-page .form-card { width: min(100%, 470px); margin: 0; padding: 26px; border-radius: 9px; box-shadow: var(--shadow-md); }
.identity-operation-page .form-card h1 { margin: 0; font-size: 1.8rem; }
.identity-operation-page .form-card > p:not(.eyebrow) { color: var(--muted); }
.identity-operation-page .stacked-form p { display: grid; margin: 0; }

.carton-page .component-rows { gap: 7px; }
.carton-page .component-row { gap: 9px; padding: 10px; border-color: var(--border); border-radius: 7px; background: var(--surface-subtle); }
.carton-page .version-heading { margin-bottom: 10px; }
.carton-page .carton-version-current { border-color: var(--primary); box-shadow: inset 3px 0 0 var(--primary); }
.packaging-page .packaging-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 10px; }
.packaging-page .packaging-card { padding: 14px; }
.packaging-page .packaging-card .actions { gap: 7px; margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--border); }
.movement-page td:nth-child(1),
.movement-page td:nth-child(5),
.movement-page td:nth-child(6),
.reconciliation-page td:nth-child(n + 3) { font-variant-numeric: tabular-nums; text-align: right; }
.supplier-page .image-gallery { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.supplier-page .product-image figcaption { padding: 10px; }
.supplier-page .inline-form { margin-top: 12px; }

html[data-theme="dark"] {
    --control-code-bg: #0e1c30;
    --control-code-text: #c7daf6;
    --control-info-bg: #14263d;
    --control-info-border: #334e70;
}
html[data-theme="dark"] .control-page > .message { border-color: var(--control-info-border); background: var(--control-info-bg); color: var(--text); }
html[data-theme="dark"] .control-page > .message-warning { border-color: var(--warning-border); background: var(--warning-soft); color: var(--warning-text); }
html[data-theme="dark"] .inventory-operation-page .batch-line,
html[data-theme="dark"] .carton-page .component-row { border-color: var(--border); background: var(--surface-subtle); }

@media (max-width: 860px) {
    .control-page > .page-heading { align-items: flex-start; min-height: 0; }
    .operation-page { max-width: none; }
}

@media (max-width: 640px) {
    .control-page > .page-heading { padding-bottom: 12px; }
    .control-page > .page-heading .heading-actions { gap: 7px; }
    .control-page > .page-heading .heading-actions .button { flex: 1 1 auto; }
    .reference-page td:nth-child(1),
    .reference-page td:nth-child(2) { width: auto; min-width: 0; }
    .operation-page > .card { padding: 13px; }
    .operation-page .actions { align-items: stretch; flex-direction: column; }
    .operation-page .actions .button { width: 100%; }
    .identity-operation-page { min-height: auto; }
    .identity-operation-page .form-card { padding: 21px 17px; }
    .packaging-page .packaging-grid { grid-template-columns: 1fr; }
    .supplier-page .image-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .movement-page td:nth-child(1),
    .movement-page td:nth-child(5),
    .movement-page td:nth-child(6),
    .reconciliation-page td:nth-child(n + 3) { text-align: left; }
}

/* P3 review: exception cells must outrank generic control-page and dark table fills. */
.reconciliation-page tbody .negative-row > td {
    background: var(--negative-row-bg);
    color: var(--exception-row-text);
}
.reconciliation-page tbody .negative-row:hover > td {
    background: var(--negative-row-hover);
    color: var(--exception-row-text);
}

/* Marketplace return receiving */
.return-workspace { min-width: 0; }
.return-scan-panel input[type="search"] { font-size: 1rem; font-weight: 700; }
.return-invoice-table td:first-child strong { font-variant-numeric: tabular-nums; }
.table-subline { display: block; margin-top: 3px; color: var(--muted); font-size: .75rem; font-weight: 600; line-height: 1.35; }
.return-invoice-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 14px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); box-shadow: var(--shadow-sm); }
.return-invoice-summary > div { min-width: 0; display: grid; gap: 3px; padding: 13px 14px; border-right: 1px solid var(--border); }
.return-invoice-summary > div:last-child { border-right: 0; }
.return-invoice-summary span { color: var(--muted); font-size: .72rem; font-weight: 750; }
.return-invoice-summary strong { overflow-wrap: anywhere; font-size: .9rem; }
.return-errors { margin-bottom: 14px; padding: 13px 15px; border: 1px solid var(--danger-border, #e5a3a3); border-radius: 8px; background: var(--danger-soft, #fff0f0); color: var(--danger, #9f2525); }
.return-errors ul { margin: 6px 0 0; padding-left: 20px; }
.return-receipt-form { display: grid; gap: 14px; }
.return-kind-panel { display: grid; grid-template-columns: minmax(220px, .8fr) minmax(0, 1.2fr); align-items: center; gap: 22px; }
.return-kind-panel h2 { margin-bottom: 4px; }
.return-kind-panel p { margin: 0; }
.return-kind-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.return-kind-options label { position: relative; min-width: 0; cursor: pointer; }
.return-kind-options input { position: absolute; inline-size: 1px; block-size: 1px; opacity: 0; }
.return-kind-options span { min-height: 70px; display: grid; align-content: center; gap: 3px; padding: 11px 13px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface-subtle); transition: border-color .16s ease, background-color .16s ease, box-shadow .16s ease; }
.return-kind-options small { color: var(--muted); }
.return-kind-options input:checked + span { border-color: var(--primary); background: var(--primary-soft); box-shadow: inset 0 0 0 1px var(--primary); }
.return-kind-options input:focus-visible + span { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
.return-lines-card { padding: 0; overflow: hidden; }
.return-lines-card > .section-heading { margin: 0; padding: 15px 16px 12px; border-bottom: 1px solid var(--border); }
.return-lines-card > .section-heading h2 { margin-bottom: 3px; }
.return-lines-card > .section-heading p { margin: 0; }
.return-receipt-table { border: 0; border-radius: 0; box-shadow: none; }
.return-receipt-table .quantity-input { width: 88px; min-height: 38px; font-weight: 800; font-variant-numeric: tabular-nums; text-align: right; }
.return-receipt-table input:disabled { opacity: .55; cursor: not-allowed; }
.return-confirm-bar { position: sticky; bottom: 12px; z-index: 8; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 18px; padding: 15px 16px; border: 1px solid var(--border-strong); border-radius: 9px; background: var(--surface-raised); box-shadow: var(--shadow-lg); }
.return-comment { display: grid; gap: 5px; color: var(--quiet); font-size: .74rem; font-weight: 750; }
.return-comment textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: 7px; background: var(--surface); color: var(--text); font: inherit; resize: vertical; }
.return-confirm-bar > div { max-width: 340px; display: grid; justify-items: end; gap: 8px; }
.return-confirm-bar p { margin: 0; color: var(--muted); font-size: .76rem; text-align: right; }
.return-result { display: grid; gap: 14px; }
.return-document-links { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-top: 12px; border-top: 1px solid var(--border); }
.return-document-links a { padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-subtle); font-size: .8rem; font-weight: 750; text-decoration: none; }

html[data-theme="dark"] .return-errors { border-color: #7d3e49; background: #321c25; color: #ffb5bf; }
html[data-theme="dark"] .return-kind-options input:checked + span { border-color: var(--primary); background: var(--primary-soft); }

@media (max-width: 860px) {
    .return-invoice-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .return-invoice-summary > div:nth-child(2) { border-right: 0; }
    .return-invoice-summary > div:nth-child(-n + 2) { border-bottom: 1px solid var(--border); }
    .return-kind-panel { grid-template-columns: 1fr; }
    .return-confirm-bar { position: static; grid-template-columns: 1fr; }
    .return-confirm-bar > div { max-width: none; justify-items: stretch; }
    .return-confirm-bar p { text-align: left; }
}

@media (max-width: 640px) {
    .return-invoice-summary, .return-kind-options { grid-template-columns: 1fr; }
    .return-invoice-summary > div { border-right: 0; border-bottom: 1px solid var(--border); }
    .return-invoice-summary > div:last-child { border-bottom: 0; }
    .return-receipt-table .quantity-input { width: 100%; text-align: left; }
}
html[data-theme="dark"] .reconciliation-page tbody .negative-row > td {
    background: var(--negative-row-bg);
    color: var(--exception-row-text);
}
html[data-theme="dark"] .reconciliation-page tbody .negative-row:hover > td {
    background: var(--negative-row-hover);
    color: var(--exception-row-text);
}

/* Outgoing Uzum dispatch desk */
.dispatch-workspace { max-width: 1160px; margin-inline: auto; }
.dispatch-scan-card { display: grid; grid-template-columns: minmax(220px, .65fr) minmax(320px, 1.35fr); gap: 18px 26px; align-items: end; }
.dispatch-scan-copy h2 { margin: 0 0 5px; }
.dispatch-scan-copy p { max-width: 52ch; margin: 0; color: var(--muted); }
.dispatch-scan-input { display: grid; gap: 6px; color: var(--quiet); font-size: .76rem; font-weight: 750; }
.dispatch-scan-input input { min-height: 50px; padding: 10px 13px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; font-size: 1rem; }
.dispatch-scan-input input:focus { border-color: var(--primary); outline: 3px solid var(--focus-ring); outline-offset: 1px; }
.dispatch-code-list { grid-column: 1 / -1; min-height: 82px; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 8px; padding: 12px; border: 1px dashed var(--border-strong); border-radius: 8px; background: var(--surface-subtle); }
.dispatch-code-list > .muted { margin: auto 0; }
.dispatch-code-chip { min-height: 34px; display: inline-flex; align-items: center; gap: 9px; padding: 6px 8px 6px 11px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-raised); color: var(--text); font: inherit; font-weight: 750; font-variant-numeric: tabular-nums; cursor: pointer; }
.dispatch-code-chip:hover { border-color: var(--primary); background: var(--primary-soft); }
.dispatch-code-chip b { color: var(--muted); font-size: 1.05rem; line-height: 1; }
.dispatch-scan-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; align-items: center; gap: 14px; }
.dispatch-scan-actions span { color: var(--muted); font-size: .82rem; font-weight: 750; }
.dispatch-overview { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-raised); overflow: hidden; }
.dispatch-overview > div { display: grid; gap: 3px; padding: 12px 14px; border-right: 1px solid var(--border); }
.dispatch-overview > div:last-child { border-right: 0; }
.dispatch-overview span { color: var(--muted); font-size: .72rem; font-weight: 750; }
.dispatch-overview strong { font-size: 1rem; font-variant-numeric: tabular-nums; }
.dispatch-pick-card { padding: 0; overflow: hidden; }
.dispatch-pick-card > .section-heading, .dispatch-invoices > .section-heading { margin: 0; padding: 14px 16px 11px; border-bottom: 1px solid var(--border); }
.dispatch-pick-card .section-heading p, .dispatch-invoices .section-heading p { margin: 3px 0 0; }
.dispatch-pick-list { display: grid; }
.dispatch-pick-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 16px; min-height: 62px; padding: 10px 16px; border-bottom: 1px solid var(--border); }
.dispatch-pick-row:last-child { border-bottom: 0; }
.dispatch-pick-row > div { display: grid; gap: 2px; }
.dispatch-pick-row small { color: var(--muted); }
.dispatch-pick-row > b { font-size: 1.08rem; font-variant-numeric: tabular-nums; }
.dispatch-invoices { margin-top: 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-raised); overflow: hidden; }
.dispatch-invoice-row { border-bottom: 1px solid var(--border); }
.dispatch-invoice-row:last-child { border-bottom: 0; }
.dispatch-invoice-row > summary { min-height: 58px; display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 10px 16px; cursor: pointer; list-style-position: inside; }
.dispatch-invoice-row > summary:hover { background: var(--table-row-hover); }
.dispatch-invoice-row > summary > span:first-of-type { flex: 1; display: grid; gap: 2px; }
.dispatch-invoice-row > summary small { color: var(--muted); }
.dispatch-invoice-detail { padding: 0 16px 14px; }
.dispatch-invoice-detail > p { margin: 0 0 10px; color: var(--muted); }
.dispatch-confirm-bar { position: sticky; bottom: 12px; z-index: 8; display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-top: 14px; padding: 14px 16px; border: 1px solid var(--border-strong); border-radius: 9px; background: var(--surface-raised); box-shadow: var(--shadow-lg); }
.dispatch-confirm-bar > div:first-child { display: grid; gap: 3px; }
.dispatch-confirm-bar p { margin: 0; color: var(--muted); font-size: .78rem; }
.dispatch-confirm-actions { display: flex; align-items: center; gap: 8px; }
.dispatch-confirm-actions form { margin: 0; }

@media (max-width: 760px) {
    .dispatch-scan-card { grid-template-columns: 1fr; }
    .dispatch-code-list, .dispatch-scan-actions { grid-column: auto; }
    .dispatch-overview { grid-template-columns: 1fr; }
    .dispatch-overview > div { border-right: 0; border-bottom: 1px solid var(--border); }
    .dispatch-overview > div:last-child { border-bottom: 0; }
    .dispatch-confirm-bar { position: static; align-items: stretch; flex-direction: column; }
    .dispatch-confirm-actions { align-items: stretch; flex-direction: column; }
    .dispatch-confirm-actions .button { width: 100%; }
}

/* Product detail redesign (2026-09-28): identity + main two-column layout,
   split "Наш склад" / "Uzum" panels, promoted reconciliation status, mobile fix. */
.detail-grid-product { grid-template-columns: minmax(260px, 320px) minmax(0, 1fr); align-items: start; }
.detail-identity, .detail-main { display: grid; align-content: start; gap: 18px; min-width: 0; }
.detail-identity .definition-list div { grid-template-columns: minmax(0, 1fr); gap: 2px; }
.detail-identity .definition-list dd { overflow-wrap: anywhere; }
.detail-main { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.detail-main > .stock-overview-card { grid-column: 1 / -1; }
.stock-panel + .stock-panel { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--section-divider); }
.stock-panel-uzum .stock-card-subheading { margin: 0 0 12px; }
.image-actions .button { min-width: 40px; min-height: 40px; }

@media (max-width: 1180px) {
    .detail-grid-product { grid-template-columns: minmax(240px, 280px) minmax(0, 1fr); }
}
@media (max-width: 860px) {
    .detail-grid-product { grid-template-columns: minmax(0, 1fr); }
    .detail-main { order: -1; }
}
@media (max-width: 600px) {
    table.marketplace-flow-table { grid-template-columns: 1fr; }
    .detail-main { grid-template-columns: 1fr; }
}
@media (max-width: 400px) {
    table.marketplace-flow-table tr,
    table.marketplace-flow-table tfoot tr { grid-template-columns: 1fr; row-gap: 2px; }
    table.marketplace-flow-table td:last-child,
    table.marketplace-flow-table tfoot td { text-align: left; }
}

/* Unified marketplace SKU workspace */
.sku-workspace { min-width: 0; }
.sku-workspace-heading { align-items: center; }
.sku-workspace-heading h1 { font-size: 2rem; }
.sku-workspace-heading p { max-width: 68ch; margin: 7px 0 0; }
.sku-state-tabs { display: flex; gap: 7px; margin: 0 0 16px; padding: 4px; overflow-x: auto; border: 1px solid var(--border); border-radius: 11px; background: var(--surface); scrollbar-width: thin; }
.sku-state-tab { min-height: 42px; display: inline-flex; flex: 0 0 auto; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid transparent; border-radius: 7px; color: var(--quiet); font-size: .79rem; font-weight: 750; text-decoration: none; white-space: nowrap; }
.sku-state-tab strong { min-width: 26px; padding: 2px 6px; border-radius: 999px; background: var(--bg); color: var(--muted); font-size: .72rem; font-variant-numeric: tabular-nums; text-align: center; }
.sku-state-tab:hover { border-color: var(--border); background: var(--bg); color: var(--text); }
.sku-state-tab.is-active { border-color: var(--primary); background: var(--primary); color: #fff; }
.sku-state-tab.is-active strong { background: rgb(255 255 255 / 20%); color: #fff; }
.sku-workspace-filters { padding: 13px 14px; }
.sku-filter-grid { display: grid; grid-template-columns: minmax(230px, 1.3fr) repeat(3, minmax(160px, .72fr)) auto; align-items: end; gap: 10px; }
.sku-filter-grid > label, .sku-filter-grid .search-field { display: grid; gap: 5px; color: var(--muted); font-size: .76rem; font-weight: 750; }
.sku-filter-search { position: relative; min-width: 0; }
.sku-filter-actions { display: flex; gap: 7px; }
.sku-filter-actions .button { min-width: 0; white-space: nowrap; }
.sku-workspace-table-card { padding: 0; overflow: hidden; }
.sku-results-heading { margin: 0; padding: 15px 16px 12px; border-bottom: 1px solid var(--border); }
.sku-results-heading h2 { margin-bottom: 2px; }
.sku-results-heading p { margin: 0; font-size: .78rem; }
.sku-workspace-table-wrap { border: 0; border-radius: 0; box-shadow: none; }
.sku-workspace-table { min-width: 1450px; }
.sku-workspace-table th { position: sticky; top: 64px; z-index: 4; padding: 10px 12px; }
.sku-workspace-table td { padding: 11px 12px; font-size: .84rem; }
.sku-workspace-table th:nth-child(1) { width: 23%; }
.sku-workspace-table th:nth-child(2) { width: 11%; }
.sku-workspace-table th:nth-child(3) { width: 8%; }
.sku-workspace-table th:nth-child(4) { width: 20%; }
.sku-workspace-table th:nth-child(5) { width: 6%; }
.sku-workspace-table th:nth-child(6) { width: 14%; }
.sku-workspace-table th:nth-child(7) { width: 8%; }
.sku-workspace-table th:nth-child(8) { width: 10%; }
.sku-cost-basis { display: grid; gap: 4px; min-width: 145px; overflow-wrap: anywhere; }
.sku-cost-amount { font-variant-numeric: tabular-nums; color: var(--text); }
.sku-cost-basis small, .sku-cost-basis time { color: var(--muted); font-size: .72rem; }
.sku-cost-status { color: var(--text); font-size: .76rem; line-height: 1.35; }
.sku-cost-status.is-pending { color: #765600; }
.sku-cost-status.is-conflict { color: #9f2525; }
html[data-theme="dark"] .sku-cost-status.is-pending { color: #f5d77d; }
html[data-theme="dark"] .sku-cost-status.is-conflict { color: #ffd4d8; }
.sku-remote-product { display: grid; grid-template-columns: 48px minmax(0, 1fr); align-items: center; gap: 10px; min-width: 0; }
.sku-remote-product > div, .sku-wms-product { min-width: 0; display: grid; gap: 2px; }
.sku-remote-product strong, .sku-remote-product span, .sku-remote-product small, .sku-wms-product strong, .sku-wms-product span, .sku-wms-product small { overflow-wrap: anywhere; }
.sku-code { color: var(--text); font-size: .88rem; }
.sku-remote-product span, .sku-wms-product span { color: var(--text); }
.sku-remote-product small, .sku-wms-product small { color: var(--muted); font-size: .72rem; }
.sku-wms-product { color: var(--text); text-decoration: none; }
.sku-wms-product:hover strong { color: var(--primary); text-decoration: underline; text-underline-offset: 3px; }
.sku-status-badge, .sku-state-badge { width: fit-content; display: inline-flex; margin-top: 5px; padding: 3px 7px; border: 1px solid var(--border); border-radius: 999px; background: var(--bg); color: var(--quiet); font-size: .68rem; font-weight: 800; line-height: 1.25; }
.sku-state-badge.is-linked { border-color: #8ed2ae; background: #e8f8ef; color: var(--success); }
.sku-state-badge.is-unlinked { border-color: #e5c267; background: #fff8df; color: #765600; }
.sku-state-badge.is-problem { border-color: #e5a3a3; background: #fff0f0; color: #9f2525; }
.sku-state-badge.is-hidden { color: var(--muted); }
.sku-stock-value { display: block; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sku-problem-quantity { display: block; margin-top: 4px; color: #9f2525; font-size: .72rem; font-weight: 800; line-height: 1.3; }
.sku-workspace-table .sku-quick-link-form { display: block; min-width: 210px; }
.sku-workspace-table .sku-product-search { min-height: 38px; }
.sku-workspace-table .sku-pack-quantity { width: 72px; min-height: 38px; text-align: center; }
.sku-actions-cell { min-width: 190px; }
.sku-actions-cell form { margin: 6px 0 0; }
.sku-actions-cell .text-link { padding: 0; border: 0; background: none; color: var(--muted); font: inherit; font-size: .75rem; font-weight: 750; cursor: pointer; }
.sku-actions-cell .text-link:hover { color: var(--primary); text-decoration: underline; text-underline-offset: 3px; }
.sku-actions-cell .sku-link-actions { display: grid; grid-template-columns: 1fr; gap: 6px; }
.sku-actions-cell .button { min-height: 34px; padding: 6px 9px; font-size: .76rem; }
.sku-row-problem > td { background: #fff8f8; }
.sku-row-warning > td { background: #fffdf5; }
.sku-row-hidden { opacity: .75; }
.sku-workspace-empty { padding: 52px 20px; text-align: center; }
.sku-workspace-empty h3 { margin: 0 0 5px; font-size: 1rem; }
.sku-workspace-empty p { margin: 0; }

html[data-theme="dark"] .sku-state-tab:hover { background: #1b314e; }
html[data-theme="dark"] .sku-state-tab.is-active { border-color: #6097e8; background: #4f87d7; color: #061221; }
html[data-theme="dark"] .sku-state-tab.is-active strong { background: rgb(6 18 33 / 18%); color: #061221; }
html[data-theme="dark"] .sku-state-badge.is-linked { border-color: #36795a; background: #143e31; color: #7ee1ad; }
html[data-theme="dark"] .sku-state-badge.is-unlinked { border-color: #846523; background: #433718; color: #f5d77d; }
html[data-theme="dark"] .sku-state-badge.is-problem { border-color: #7b3e47; background: #3d2028; color: #ffd4d8; }
html[data-theme="dark"] .sku-problem-quantity { color: #ffb5bf; }
html[data-theme="dark"] .sku-row-problem > td { background: #281b25; }
html[data-theme="dark"] .sku-row-warning > td { background: #272518; }

@media (max-width: 1100px) {
    .sku-filter-grid { grid-template-columns: minmax(0, 1fr) minmax(180px, .7fr); }
    .sku-filter-actions { align-self: end; }
}
@media (max-width: 620px) {
    .sku-workspace-heading { align-items: stretch; }
    .sku-workspace-heading h1 { font-size: 1.65rem; }
    .sku-filter-grid { grid-template-columns: 1fr; }
    .sku-filter-actions .button { flex: 1; }
    .sku-workspace-table th { top: 58px; }
}
@media (max-width: 640px) {
    .sku-workspace-table { min-width: 0; width: 100%; }
    .sku-workspace-table td { grid-template-columns: minmax(0, 100px) minmax(0, 1fr); gap: 8px; }
    .sku-workspace-table td > * { min-width: 0; }
    .sku-workspace-table .sku-quick-link-form { min-width: 0; }
    .sku-cost-basis { min-width: 0; }
}
.sku-cost-resolution { margin-top: .65rem; max-width: 340px; }
.sku-cost-resolution[open] { min-width: 260px; }
.sku-workspace-table tr:has(.sku-cost-resolution[open]) > td { vertical-align: top; }
.sku-cost-resolution summary { cursor: pointer; color: var(--primary, #568ae0); font-weight: 600; }
.sku-cost-context { margin: .75rem 0; }
.sku-cost-context p { overflow-wrap: anywhere; }
.sku-cost-context dl { display: grid; grid-template-columns: 1fr 1fr; gap: .35rem .65rem; font-size: .85rem; }
.sku-cost-context dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.sku-cost-resolution form { display: grid; gap: .65rem; }
.sku-cost-resolution label { display: grid; gap: .3rem; }
.sku-cost-resolution input:not([type=checkbox]), .sku-cost-resolution textarea { width: 100%; min-width: 0; }
.sku-cost-resolution .sku-cost-replace { display: flex; align-items: flex-start; gap: .5rem; font-size: .85rem; }
.sku-cost-feedback { margin: 0; font-size: .85rem; }
@media (max-width: 600px) {
    .sku-cost-resolution[open] { min-width: 0; }
    .sku-cost-context dl { grid-template-columns: 1fr; gap: .15rem; }
    .sku-cost-context dd { text-align: left; margin-bottom: .4rem; }
}
