* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f5f5f7;
    color: #333;
    font-size: 16px;
}

body.catalog-body {
    margin: 0;
    background: #f3f4f8;
    color: #1f2937;
    padding-bottom: 110px;
}

h1, h2, h3 {
    color: #cc0000;
    text-align: center;
    text-transform: uppercase;
}

h4, h5, h6 {
    color: #cc0000;
}

h1 { font-size: 28px; }
h2 { font-size: 22px; }
h3 { font-size: 20px; }
h4 { font-size: 18px; }
h5 { font-size: 16px; }
h6 { font-size: 14px; }

a {
    text-decoration: none;
    color: #cc0000;
}

input,
select,
button,
textarea {
    font: inherit;
}

input,
select {
    padding: 10px;
    border-radius: 10px;
    border: 1px solid #d8d8d8;
    outline: none;
    box-sizing: border-box;
    background: #fff;
}

input:focus,
select:focus,
textarea:focus {
    border-color: #cc0000;
}

textarea {
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 8px;
    outline: none;
    box-sizing: border-box;
    resize: vertical;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.4em;
    background: #fff;
}

button[type],
.btn,
.logout,
.top-links a {
    background: #cc0000;
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    padding: 10px 14px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: background-color 0.2s, transform 0.15s;
}

button[type]:hover,
.btn:hover,
.logout:hover,
.top-links a:hover {
    background: #a40000;
}

.btn:active,
button[type]:active {
    transform: translateY(1px);
}

.btn.secondary {
    background: #f2f2f2;
    color: #333;
    border: 1px solid #ddd;
}

.btn.secondary:hover {
    background: #e7e7e7;
}

.btn:disabled {
    opacity: .45;
    cursor: not-allowed;
}

input[type="checkbox"] {
    accent-color: #cc0000;
}

/* INDEX */
.box {
    max-width: 760px;
    margin: 30px auto;
    background: #fff;
    border: 1px solid #dedede;
    border-radius: 14px;
    padding: 28px;
    box-shadow: 0 4px 14px rgba(0,0,0,.06);
}

.info {
    background: #fafafa;
    border: 1px solid #eee;
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 22px;
    line-height: 1.7;
}

ul {
    padding-left: 20px;
    line-height: 1.9;
}

.test-link {
    word-break: break-all;
}

.logout {
    margin-top: 18px;
}

/* LOGIN */
.wrap {
    max-width: 420px;
    margin: 60px auto;
    background: #fff;
    border-radius: 18px;
    padding: 28px;
    box-shadow: 0 10px 30px rgba(0,0,0,.08);
}

.muted {
    color: #666;
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 18px;
}

.row {
    margin-bottom: 14px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 700;
    font-size: 14px;
    color: #444;
}

.phone-box {
    display: flex;
    align-items: center;
    border: 1px solid #ccc;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}

.prefix {
    background: #f2f2f2;
    padding: 14px 12px;
    font-weight: 700;
    border-right: 1px solid #ccc;
    white-space: nowrap;
}

.phone-box input[type="text"] {
    width: 100%;
    border: 0;
    outline: none;
    padding: 14px 12px;
    font-size: 18px;
    letter-spacing: 1px;
    border-radius: 0;
}

.msg {
    padding: 12px 14px;
    border-radius: 10px;
    margin-bottom: 14px;
    font-size: 14px;
}

.error {
    background: #ffe9e9;
    color: #b10000;
    border: 1px solid #f3c2c2;
}

.success {
    background: #eaf9ea;
    color: #136c13;
    border: 1px solid #bfe3bf;
}

.small {
    font-size: 13px;
    color: #666;
    margin-top: 10px;
}

.top-link {
    display: inline-block;
    margin-top: 14px;
    color: #cc0000;
    text-decoration: none;
    font-size: 14px;
}

/* HEADER */
.topbar {
    width: calc(100% - 20px);
    margin: 10px;
    background: #fff;
    border: 1px solid #dedede;
    border-radius: 16px;
    padding: 16px 18px;
    box-shadow: 0 4px 14px rgba(0,0,0,.06);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.topbar h1 {
    margin: 0;
    font-size: 24px;
    text-align: left;
    color: #cc0000;
    text-transform: uppercase;
}

.topbar .meta {
    color: #666;
    font-size: 14px;
    line-height: 1.6;
    margin-top: 6px;
}

.top-links {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.top-links a {
    font-size: 14px;
    padding: 10px 14px;
}

/* KORZINKA PAGE */
.wrap-page {
    width: calc(100% - 20px);
    margin: 10px;
    display: grid;
    grid-template-columns: minmax(460px, 1.15fr) minmax(320px, 1fr);
    gap: 16px;
    align-items: start;
}

.panel {
    background: #fff;
    border: 1px solid #dedede;
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 4px 14px rgba(0,0,0,.06);
    min-width: 0;
}

.left {
    min-width: 0;
    overflow: visible;
}

.right {
    min-width: 0;
    position: sticky;
    top: 10px;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 20px);
    overflow: hidden;
}

.searchWrap {
    position: relative;
    margin-bottom: 14px;
}

#searchProduct {
    width: 100%;
    padding-right: 42px;
}

#productSelect {
    width: 100%;
}

/* SEARCH CARD DROPDOWN */
#searchProductList {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    z-index: 80;
    background: #fff;
    border: 1px solid #e7e7e7;
    border-radius: 16px;
    list-style: none;
    margin: 0;
    padding: 10px;
    max-height: 430px;
    overflow-y: auto;
    box-shadow: 0 14px 36px rgba(0,0,0,0.10);
}

#searchProductList li {
    padding: 0;
    border: 0;
    cursor: pointer;
    background: transparent;
}

#searchProductList li + li {
    margin-top: 10px;
}

#searchProductList li:hover {
    background: transparent;
    color: inherit;
}

.search-product-card-item {
    list-style: none;
}

.search-product-card {
    display: grid;
    grid-template-columns: 84px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    padding: 10px;
    border: 1px solid #ededed;
    border-radius: 14px;
    background: #fff;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.search-product-card:hover {
    border-color: #cc0000;
    box-shadow: 0 8px 20px rgba(204,0,0,0.08);
    transform: translateY(-1px);
}

.search-product-thumb-wrap {
    width: 84px;
    height: 84px;
    border-radius: 12px;
    border: 1px solid #ececec;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex: 0 0 84px;
}

.search-product-thumb-wrap.no-image {
    background: #f7f7f7;
}

.search-product-thumb {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.search-product-placeholder {
    padding: 10px;
    text-align: center;
    color: #999;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.3;
}

.search-product-info {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.search-product-title {
    font-size: 15px;
    font-weight: 700;
    color: #222;
    line-height: 1.35;
    word-break: break-word;
}

.search-product-code {
    font-size: 11px;
    color: #cc0000;
    font-weight: 700;
    letter-spacing: .2px;
    word-break: break-all;
}

.search-product-desc {
    font-size: 12px;
    color: #666;
    line-height: 1.45;
    word-break: break-word;
}

#clearSearchProduct {
    position: absolute;
    right: 12px;
    top: 9px;
    cursor: pointer;
    font-weight: bold;
    color: #cc0000;
    display: none;
    font-size: 20px;
    line-height: 1;
}

.productHead {
    display: flex;
    gap: 16px;
    align-items: center;
    margin: 16px 0;
    flex-wrap: nowrap;
    background: linear-gradient(180deg, #fff 0%, #fafafa 100%);
    border: 1px solid #eee;
    border-radius: 14px;
    padding: 14px;
    min-width: 0;
}

.productHeadInfo {
    min-width: 0;
    flex: 1 1 auto;
}

.productHead img {
    width: 120px;
    height: 120px;
    object-fit: contain;
    flex: 0 0 120px;
    border-radius: 12px;
    display: none;
    border: 1px solid #ddd;
    background: #fff;
    padding: 8px;
}

#prodName {
    font-size: 20px;
    font-weight: 700;
    color: #cc0000;
    line-height: 1.25;
    word-break: break-word;
}

#prodDesc {
    margin-top: 6px;
    color: #666;
    font-size: 14px;
    word-break: break-word;
}

/* TABLE */
.tableScroll {
    width: 100%;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    table-layout: auto;
}

th,
td {
    padding: 12px;
    text-align: center;
    border: 1px solid #ddd;
    color: #000;
    background-color: #fff;
    vertical-align: middle;
}

th {
    background-color: #cb3837;
    color: #fff;
}

.variantsTable {
    margin-top: 10px;
    width: max-content;
    min-width: 100%;
    table-layout: fixed;
}

.variantsTable th,
.variantsTable td {
    text-align: center;
    padding: 10px 8px;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.variantsCorner {
    min-width: 48px;
    width: 48px;
}

.variantRowHead {
    min-width: 240px;
    max-width: 320px;
    text-align: left;
    padding: 12px 14px;
    line-height: 1.35;
}

.variantColHead {
    min-width: 180px;
    max-width: 220px;
    line-height: 1.35;
}

.variantCell {
    min-width: 128px;
    width: 128px;
    background: #fff;
}

.comboLine {
    display: block;
    white-space: normal;
    word-break: break-word;
}

.comboLine + .comboLine {
    margin-top: 4px;
}

.qtyInput {
    width: 100% !important;
    min-width: 0;
    max-width: 92px;
    text-align: center;
    padding: 8px !important;
    margin: 0 auto;
    display: block;
}

.error-message {
    display: block;
    color: #b42318;
    font-size: 12px;
    margin-top: 6px;
    white-space: normal;
    line-height: 1.25;
}

.actions {
    position: sticky;
    bottom: 10px;
    z-index: 30;
    margin-top: 15px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    padding: 12px;
    background: #fff;
    border-top: 1px solid #efefef;
}

.actions .btn,
.actions button,
.actions a {
    flex: 1 1 auto;
}

#serverError {
    color: #b42318;
    font-weight: 700;
    margin-top: 12px;
    line-height: 1.4;
}

/* CART */
.cartTop {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 14px;
    flex: 0 0 auto;
    align-items: center;
}

.cartCountBadge {
    flex: 0 0 auto;
    background: #fff4f4;
    color: #cc0000;
    border: 1px solid #f0caca;
    border-radius: 999px;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
}

.cartGrid {
    display: grid;
    grid-template-columns: repeat(auto-fill, 262px);
    gap: 14px;
    justify-content: flex-start;
    overflow-y: auto;
    align-content: start;
    flex: 1 1 auto;
    min-height: 0;
    padding-right: 2px;
}

.cart-card {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 262px;
    max-width: 262px;
    min-width: 262px;
    border-radius: 18px;
    background: #fff;
    border: 1px solid #e6e6e6;
    box-shadow: 0 3px 12px rgba(0,0,0,.04);
}

.remove-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    border: none;
    background: rgba(204, 0, 0, 0.95);
    color: #fff;
    border-radius: 999px;
    width: 32px;
    height: 32px;
    padding: 0 !important;
    cursor: pointer;
    font-size: 20px;
    font-weight: 700;
    line-height: 32px;
    text-align: center;
    z-index: 2;
}

.remove-btn:hover {
    background: #a40000;
}

.cart-card-image-wrap {
    width: 100%;
    background: #fff;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 18px 18px 0 0;
    aspect-ratio: 1 / 1;
    overflow: hidden;
}

.cart-card-image-wrap.no-image {
    background: #f8f8f8;
}

.cart-card-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.cart-card-placeholder {
    color: #999;
    font-size: 13px;
    text-align: center;
    padding: 14px;
}

.cart-card-body {
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
}

.cart-card-title {
    font-size: 15px;
    font-weight: 700;
    color: #222;
    line-height: 1.35;
    word-break: break-word;
}

.cart-card-attrs {
    font-size: 13px;
    line-height: 1.4;
    color: #555;
    word-break: break-word;
    background: #fafafa;
    border: 1px solid #ededed;
    border-radius: 12px;
    padding: 8px 10px;
}

.cart-card-sku {
    font-size: 11px;
    color: #777;
    background: #f5f5f5;
    border: 1px solid #ececec;
    border-radius: 12px;
    padding: 8px 10px;
    white-space: normal;
    word-break: break-all;
    line-height: 1.35;
}

.cart-price-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.cart-price-box,
.cart-total-box {
    background: #fafafa;
    border: 1px solid #ededed;
    border-radius: 14px;
    padding: 10px;
    min-width: 0;
}

.cart-total-box {
    background: #fff7f7;
    border-color: #f3d3d3;
}

.mini-label {
    display: block;
    font-size: 11px;
    color: #666;
    margin-bottom: 6px;
    font-weight: 700;
}

.mini-value {
    font-size: 14px;
    font-weight: 700;
    color: #333;
    line-height: 1.3;
    word-break: break-word;
}

.mini-total {
    font-size: 18px;
    font-weight: 800;
    color: #cc0000;
    line-height: 1.3;
    word-break: break-word;
}

.cartQtyInput {
    width: 100%;
    text-align: center;
    font-weight: 700;
    font-size: 18px;
    padding: 3px 3px;
    min-width: 0;
    border-radius: 12px;
}

.totalBox {
    background: #fff;
    padding-top: 12px;
    margin-top: 14px;
    border-top: 1px solid #efefef;
    flex: 0 0 auto;
}

.totalMain {
    background: #cc0000;
    color: #fff;
    padding: 14px;
    border-radius: 12px;
    font-weight: 700;
    text-align: center;
    font-size: 18px;
    line-height: 1.4;
}

.emptyCart {
    color: #666;
    font-size: 14px;
    border: 1px dashed #ddd;
    border-radius: 14px;
    padding: 30px 16px;
    text-align: center;
    background: #fafafa;
    width: 262px;
}

/* KATALOG PAGE */
.catalog-wrap {
    width: calc(100% - 20px);
    max-width: 100%;
    margin: 10px;
    padding: 6px 0 24px;
}

.catalog-topbar {
    margin-bottom: 12px;
}

.catalog-topbar-center {
    display: flex;
    justify-content: center;
    align-items: center;
}

.catalog-topbar-inner {
    width: 100%;
    max-width: 1100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.catalog-title {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.catalog-title-center {
    width: 100%;
    text-align: center;
    align-items: center;
}

.catalog-title h1 {
    margin: 0;
    font-size: 28px;
    line-height: 1.15;
    color: #b30000;
    text-align: left;
    text-transform: none;
}

.catalog-sub {
    color: #6b7280;
    font-size: 14px;
    line-height: 1.5;
    text-align: center;
    max-width: 900px;
}

.catalog-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.catalog-controls-center {
    width: 100%;
    justify-content: center;
}

.catalog-search {
    min-width: 320px;
    max-width: 520px;
    width: 100%;
    position: relative;
}

.catalog-search input {
    width: 100%;
    height: 46px;
    border: 1px solid #d7dbe5;
    border-radius: 14px;
    background: #fff;
    padding: 0 42px 0 14px;
    font-size: 15px;
    outline: none;
}

.catalog-search button {
    position: absolute;
    right: 8px;
    top: 8px;
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 9px;
    background: #f2f4f8;
    color: #333;
    cursor: pointer;
    font-size: 16px;
    padding: 0;
}

.catalog-search button:hover {
    background: #e4e7ed;
}

.book-shell {
    position: relative;
    background: linear-gradient(180deg, #ffffff 0%, #fafafb 100%);
    border-radius: 28px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.08);
    border: 1px solid #e9ebf1;
    overflow: hidden;
}

.book-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid #eceff5;
    background: #fff;
    flex-wrap: wrap;
}

.book-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.page-chip,
.count-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 16px;
    border-radius: 999px;
    background: #f4f6fa;
    color: #374151;
    font-size: 15px;
    font-weight: 700;
}

.book-nav {
    display: flex;
    align-items: center;
    gap: 10px;
}

.book-nav-top {
    justify-content: flex-end;
}

.book-stage {
    display: grid;
    grid-template-columns: 84px minmax(0, 1fr) 84px;
    align-items: stretch;
    min-height: 70vh;
}

.book-side-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f7f8fb;
}

.book-side-nav.left {
    border-right: 1px solid #eceff5;
}

.book-side-nav.right {
    border-left: 1px solid #eceff5;
}

.nav-btn,
.action-btn,
.drawer-btn {
    border: 0;
    cursor: pointer;
    transition: .18s ease;
}

.nav-btn {
    min-width: 44px;
    height: 44px;
    border-radius: 12px;
    background: #b30000;
    color: #fff;
    font-size: 20px;
    font-weight: 700;
    padding: 0;
}

.nav-btn[disabled] {
    background: #d5d9e3;
    cursor: not-allowed;
}

.nav-btn-side {
    width: 58px;
    min-width: 58px;
    height: 140px;
    border-radius: 18px;
    font-size: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 25px rgba(179, 0, 0, 0.18);
}

.book-spread {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 70vh;
}

.book-page {
    position: relative;
    min-height: 620px;
    padding: 28px;
    overflow: hidden;
}

.book-page.left {
    background:
        linear-gradient(90deg, rgba(0,0,0,0.05), rgba(0,0,0,0.00) 18px),
        linear-gradient(180deg, #ffffff 0%, #fafafa 100%);
    border-right: 1px solid #eceff5;
}

.book-page.right {
    background:
        linear-gradient(270deg, rgba(0,0,0,0.05), rgba(0,0,0,0.00) 18px),
        linear-gradient(180deg, #fffdfd 0%, #fafafa 100%);
}

.page-watermark {
    position: absolute;
    right: 16px;
    bottom: 10px;
    color: rgba(179, 0, 0, 0.10);
    font-weight: 800;
    font-size: 42px;
    letter-spacing: 2px;
    pointer-events: none;
}

.product-visual-wrap {
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 18px;
    justify-content: center;
    align-items: center;
}

.product-visual-frame {
    width: 100%;
    max-width: 620px;
    aspect-ratio: 1 / 1;
    border-radius: 24px;
    background: #fff;
    box-shadow: inset 0 0 0 1px #eceff5;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 22px;
}

.product-visual-frame img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
}

.product-visual-empty {
    width: 100%;
    height: 100%;
    border-radius: 20px;
    background: linear-gradient(135deg, #f8fafc 0%, #eef2f7 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #8b95a7;
    font-size: 18px;
    font-weight: 600;
    text-align: center;
    padding: 20px;
}

.product-shortline {
    width: 100%;
    max-width: 620px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.product-code-badge,
.product-type-badge {
    background: #f4f6fa;
    color: #374151;
    border-radius: 999px;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 700;
}

.product-info-wrap {
    display: flex;
    flex-direction: column;
    height: 100%;
    gap: 18px;
}

.product-name {
    font-size: 34px;
    line-height: 1.1;
    font-weight: 800;
    color: #111827;
}

.product-desc {
    font-size: 15px;
    line-height: 1.7;
    color: #4b5563;
    white-space: normal;
}

.product-desc-html {
    line-height: 1.55;
    color: #444;
    font-size: 15px;
}

.product-desc-html .info-title {
    display: block;
    font-weight: 700;
    color: #cc0000;
    margin: 10px 0 4px;
}

.product-desc-html .info-title:first-child {
    margin-top: 0;
}

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

.field-box {
    background: #fff;
    border: 1px solid #e6eaf1;
    border-radius: 16px;
    padding: 12px;
}

.field-box label {
    display: block;
    margin-bottom: 7px;
    font-size: 13px;
    color: #6b7280;
    font-weight: 700;
}

.field-box select,
.field-box input {
    width: 100%;
    height: 44px;
    border: 1px solid #d7dce6;
    border-radius: 12px;
    background: #fff;
    padding: 0 12px;
    font-size: 14px;
    outline: none;
}

.field-box input.qty-error,
.field-box select.select-error {
    border-color: #dc2626;
    background: #fff5f5;
}

.field-help {
    margin-top: 6px;
    font-size: 12px;
    color: #6b7280;
    min-height: 16px;
}

.variant-preview {
    background: #f9fafc;
    border: 1px dashed #d8dee8;
    border-radius: 16px;
    padding: 14px;
}

.variant-preview .label {
    font-size: 12px;
    color: #6b7280;
    font-weight: 700;
    margin-bottom: 7px;
}

.variant-preview .value {
    font-size: 14px;
    color: #111827;
    line-height: 1.6;
    word-break: break-word;
}

.page-actions {
    display: flex;
    align-items: stretch;
    gap: 12px;
    flex-wrap: wrap;
}

.action-btn {
    min-height: 48px;
    border-radius: 14px;
    padding: 0 18px;
    font-size: 15px;
    font-weight: 700;
}

.action-btn.primary {
    background: #b30000;
    color: #fff;
    flex: 1 1 250px;
}

.action-btn.secondary {
    background: #eef2f7;
    color: #1f2937;
    flex: 1 1 180px;
}

.action-btn:hover,
.nav-btn:hover,
.drawer-btn:hover {
    transform: translateY(-1px);
}

.price-note {
    background: #f8fafc;
    border: 1px solid #e6eaf1;
    border-radius: 16px;
    padding: 14px;
    color: #4b5563;
    font-size: 13px;
    line-height: 1.65;
}

.page-error {
    min-height: 22px;
    color: #dc2626;
    font-size: 13px;
    font-weight: 700;
}

.page-success {
    color: #0f766e;
    font-size: 13px;
    font-weight: 700;
    min-height: 20px;
}

/* KATALOG GALLERY */
.product-visual-frame.gallery-mode {
    position: relative;
    overflow: hidden;
}

.gallery-main {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 320px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-main img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
}

.gallery-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 999px;
    background: rgba(255,255,255,0.92);
    box-shadow: 0 6px 18px rgba(0,0,0,0.12);
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
    color: #cc0000;
    z-index: 3;
    padding: 0;
}

.gallery-nav-btn.left {
    left: 10px;
}

.gallery-nav-btn.right {
    right: 10px;
}

.gallery-counter {
    position: absolute;
    left: 50%;
    bottom: 10px;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.62);
    color: #fff;
    font-size: 12px;
    padding: 6px 10px;
    border-radius: 999px;
    z-index: 3;
}

.gallery-thumbs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 12px;
    width: 100%;
    max-width: 620px;
}

.gallery-thumb {
    width: 58px;
    height: 58px;
    border: 2px solid transparent;
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
    cursor: pointer;
    padding: 0;
    flex: 0 0 58px;
}

.gallery-thumb.active {
    border-color: #cc0000;
}

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

/* DRAWER */
.drawer {
    position: fixed;
    left: 14px;
    right: 14px;
    bottom: 14px;
    z-index: 70;
    border-radius: 22px;
    box-shadow: 0 18px 55px rgba(0,0,0,0.18);
    overflow: hidden;
    background: #fff;
    border: 1px solid #e7ebf2;
}

.drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    background: linear-gradient(180deg, #fff 0%, #f8fafc 100%);
    border-bottom: 1px solid #edf1f5;
    flex-wrap: wrap;
}

.drawer-head-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.drawer-title {
    font-size: 18px;
    font-weight: 800;
    color: #111827;
}

.drawer-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 0 12px;
    border-radius: 999px;
    background: #b30000;
    color: #fff;
    font-weight: 700;
    font-size: 13px;
}

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

.drawer-btn {
    min-height: 42px;
    padding: 0 14px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 700;
}

.drawer-btn.toggle {
    background: #eef2f7;
    color: #111827;
}

.drawer-btn.clear {
    background: #111827;
    color: #fff;
}

.drawer-clear-inline {
    white-space: nowrap;
}

.drawer-body {
    max-height: 50vh;
    overflow: auto;
    transition: max-height .25s ease, opacity .25s ease, padding .25s ease;
    opacity: 1;
    padding: 14px 16px 16px;
}

.drawer.collapsed .drawer-body {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
    overflow: hidden;
}

.cart-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.cart-grid .cart-card {
    width: 100%;
    max-width: none;
    min-width: 0;
    background: #f8fafc;
    border: 1px solid #e6ebf2;
    border-radius: 18px;
    padding: 12px;
    box-shadow: none;
    gap: 10px;
}

.cart-remove {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 10px;
    background: #fff;
    color: #b30000;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.06);
    padding: 0 !important;
}

.cart-img {
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 16px;
    background: #fff;
    border: 1px solid #e8edf5;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cart-img img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
}

.cart-noimg {
    padding: 18px;
    text-align: center;
    color: #8a94a6;
    font-size: 13px;
    font-weight: 700;
}

.cart-name {
    font-size: 15px;
    font-weight: 800;
    color: #111827;
    line-height: 1.35;
}

.cart-attrs {
    color: #6b7280;
    font-size: 12px;
    line-height: 1.55;
    min-height: 18px;
}

.cart-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.cart-box {
    background: #fff;
    border: 1px solid #e8edf5;
    border-radius: 12px;
    padding: 9px;
}

.cart-box input {
    width: 100%;
    height: 38px;
    border: 1px solid #d7dce6;
    border-radius: 10px;
    padding: 0 10px;
    outline: none;
    font-size: 14px;
}

.drawer-total {
    margin-top: 14px;
    border-top: 1px solid #edf1f5;
    padding-top: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
}

.drawer-total-left {
    min-width: 0;
    flex: 1 1 auto;
}

.drawer-total-right {
    flex: 0 0 auto;
}

.drawer-total-main {
    font-size: 18px;
    font-weight: 800;
    color: #111827;
}

.drawer-total-sub {
    font-size: 13px;
    color: #6b7280;
}

.empty-box {
    background: #f8fafc;
    border: 1px dashed #d8dee8;
    border-radius: 18px;
    padding: 30px 20px;
    text-align: center;
    color: #6b7280;
    font-size: 15px;
    font-weight: 600;
}

.mobile-jump {
    display: none;
}

/* SCROLLBAR */
::-webkit-scrollbar-track:hover {
    background: #f5f5f7;
}

::-webkit-scrollbar-thumb {
    background: #888888;
    border-radius: 999px;
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555555;
}

.noteBox {
    margin-top: 10px;
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 14px;
    line-height: 1.5;
}

.noteWarn {
    background: #fff4e5;
    border: 1px solid #f5c27a;
    color: #9a6700;
}

.noteOk {
    background: #edfdf3;
    border: 1px solid #9ad9b0;
    color: #166534;
}

.error-field {
    border-color: #b42318 !important;
}

/* RESPONSIVE */
@media (max-width: 1500px) {
    .cart-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 1280px) {
    .wrap-page {
        grid-template-columns: 1fr;
    }

    .right {
        width: 100%;
        position: static;
        max-height: none;
        overflow: visible;
    }

    .cartGrid {
        overflow: visible;
        grid-template-columns: repeat(auto-fill, 262px);
    }

    .book-stage {
        grid-template-columns: 70px minmax(0, 1fr) 70px;
    }

    .book-spread {
        grid-template-columns: 1fr;
    }

    .book-page.left {
        border-right: 0;
        border-bottom: 1px solid #eceff5;
    }

    .cart-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    .productHead {
        flex-wrap: wrap;
    }

    .productHead img {
        width: 100px;
        height: 100px;
        flex-basis: 100px;
    }

    .variantRowHead {
        min-width: 200px;
        max-width: 240px;
    }

    .variantColHead {
        min-width: 150px;
        max-width: 180px;
    }

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

    .product-name {
        font-size: 28px;
    }

    .book-stage {
        grid-template-columns: 56px minmax(0, 1fr) 56px;
    }

    .nav-btn-side {
        width: 44px;
        min-width: 44px;
        height: 100px;
        font-size: 30px;
        border-radius: 14px;
    }

    .book-page {
        padding: 20px;
        min-height: auto;
    }

    .gallery-main {
        min-height: 260px;
    }

    .search-product-card {
        grid-template-columns: 72px minmax(0, 1fr);
    }

    .search-product-thumb-wrap {
        width: 72px;
        height: 72px;
        flex-basis: 72px;
    }
}

@media (max-width: 767px) {
    body {
        padding: 0;
    }

    .box,
    .wrap,
    .topbar,
    .panel {
        box-shadow: none;
    }

    .box,
    .wrap {
        margin: 0;
        border-radius: 0;
    }

    .topbar,
    .panel {
        border-radius: 12px;
    }

    .topbar {
        width: calc(100% - 20px);
        margin: 10px;
        padding: 14px;
    }

    .topbar h1 {
        font-size: 20px;
    }

    .top-links {
        width: 100%;
        justify-content: stretch;
    }

    .top-links a {
        flex: 1 1 auto;
        text-align: center;
    }

    .actions {
        flex-direction: column;
    }

    .actions .btn,
    .actions button,
    .actions a {
        width: 100%;
        text-align: center;
    }

    .wrap-page {
        width: calc(100% - 20px);
        margin: 10px;
        gap: 12px;
        grid-template-columns: 1fr;
    }

    .panel {
        padding: 14px;
    }

    .cartTop {
        align-items: center;
    }

    .cartCountBadge {
        padding: 7px 10px;
        font-size: 12px;
    }

    .cartGrid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }

    .cart-card {
        width: 100%;
        max-width: none;
        min-width: 0;
    }

    .emptyCart {
        width: 100%;
    }

    .mini-total {
        font-size: 16px;
    }

    .catalog-wrap {
        width: calc(100% - 20px);
        margin: 10px;
        padding: 0 0 18px;
    }

    .catalog-topbar-inner {
        max-width: none;
    }

    .catalog-title h1 {
        font-size: 24px;
    }

    .catalog-search {
        min-width: 100%;
        max-width: none;
    }

    .book-toolbar {
        justify-content: space-between;
    }

    .book-stage {
        grid-template-columns: 1fr;
    }

    .book-side-nav {
        display: none;
    }

    .drawer {
        left: 10px;
        right: 10px;
        bottom: 10px;
    }

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

    .mobile-jump {
        display: inline-flex;
    }

    .page-actions {
        flex-direction: column;
    }

    .page-actions .action-btn {
        width: 100%;
    }

    .drawer-total {
        align-items: stretch;
        flex-direction: column;
    }

    .drawer-total-right {
        width: 100%;
    }

    .drawer-clear-inline {
        width: 100%;
    }

    .gallery-nav-btn {
        width: 38px;
        height: 38px;
        font-size: 22px;
    }

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

    #searchProductList {
        padding: 8px;
        max-height: 360px;
    }

    .search-product-card {
        grid-template-columns: 64px minmax(0, 1fr);
        gap: 10px;
        padding: 8px;
        border-radius: 12px;
    }

    .search-product-thumb-wrap {
        width: 64px;
        height: 64px;
        flex-basis: 64px;
        border-radius: 10px;
    }

    .search-product-title {
        font-size: 14px;
    }

    .search-product-code {
        font-size: 10px;
    }

    .search-product-desc {
        font-size: 11px;
    }
}

@media (max-width: 480px) {
    .wrap-page {
        width: calc(100% - 16px);
        margin: 8px;
    }

    .topbar {
        width: calc(100% - 16px);
        margin: 8px;
    }

    .cart-card-body {
        padding: 12px;
    }

    .totalMain {
        font-size: 15px;
        padding: 12px;
    }


    .variantRowHead {
        min-width: 180px;
    }

    .variantColHead {
        min-width: 140px;
    }

    .catalog-wrap {
        width: calc(100% - 16px);
        margin: 8px;
    }

    .book-toolbar {
        padding: 12px;
    }

    .book-page {
        padding: 16px;
    }

    .product-name {
        font-size: 24px;
    }

    .product-visual-frame {
        padding: 14px;
        border-radius: 18px;
    }

    .product-shortline {
        gap: 8px;
    }

    .product-code-badge,
    .product-type-badge {
        width: 100%;
        justify-content: center;
        text-align: center;
    }

    .drawer-head {
        padding: 12px;
    }

    .drawer-body {
        padding: 12px;
    }

    .drawer-total-main {
        font-size: 16px;
    }

    .gallery-main {
        min-height: 220px;
    }

    .gallery-counter {
        font-size: 11px;
        padding: 5px 8px;
    }

    .gallery-thumb {
        width: 48px;
        height: 48px;
        flex-basis: 48px;
    }

    .search-product-card {
        grid-template-columns: 56px minmax(0, 1fr);
    }

    .search-product-thumb-wrap {
        width: 56px;
        height: 56px;
        flex-basis: 56px;
    }
}