/* AHProfi SK v641: layout-only fixes.
   All selectors are scoped to the affected SK screens; prices, products,
   configuration state, and navigation are deliberately untouched. */

/* 1. Setup USP: three visible benefits fill the row.  When a fourth benefit
   is added, the original four-column composition automatically returns. */
@media (min-width: 1024px) {
  html.ahp-layout-v497 #app #startScreen.start-usp-below-v537.start-refined-v538 .start-card > .start-usp {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
  html.ahp-layout-v497 #app #startScreen.start-usp-below-v537.start-refined-v538 .start-card > .start-usp:has(> .start-usp-item:nth-child(4):not([hidden]):not(.hidden)) {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  }
}
/* Keep the existing two-column tablet and one-column phone layout.
   Ensure a future four-benefit SK version also flows to two rows on tablet. */
@media (min-width: 601px) and (max-width: 1023.98px) {
  html.ahp-layout-v497 #app #startScreen.start-usp-below-v537.start-refined-v538 .start-card > .start-usp {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}
@media (max-width: 600px) {
  html.ahp-layout-v497 #app #startScreen.start-usp-below-v537.start-refined-v538 .start-card > .start-usp {
    grid-template-columns: minmax(0, 1fr) !important;
  }
}

/* 2. Start hamburger: header switches to hamburger at <=1239px,
   but legacy item styling only applied at <=1099px.  Unify all actions,
   including the sole Help action shown before any configuration exists. */
@media (max-width: 1239.98px) {
  html.ahp-layout-v497 #startHeader #startMobileHeaderMenu :is(.ahp-mobile-menu-action, .ahp-mobile-menu-link) {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    width: 100% !important;
    min-width: 0 !important;
    min-height: 46px !important;
    margin: 0 !important;
    padding: 10px 12px !important;
    box-sizing: border-box !important;
    border: 0 !important;
    border-radius: 8px !important;
    background: transparent !important;
    color: #fff !important;
    font: 800 15px/1.35 Arial, sans-serif !important;
    text-align: left !important;
    text-decoration: none !important;
    cursor: pointer !important;
    white-space: normal !important;
  }
  html.ahp-layout-v497 #startHeader #startMobileHeaderMenu :is(.ahp-mobile-menu-action, .ahp-mobile-menu-link)[hidden] {
    display: none !important;
  }
  html.ahp-layout-v497 #startHeader #startMobileHeaderMenu :is(.ahp-mobile-menu-action, .ahp-mobile-menu-link):is(:hover, :focus-visible) {
    background: #191919 !important;
    color: #c11015 !important;
  }
  html.ahp-layout-v497 #startHeader #startMobileHeaderMenu .ahp-mobile-menu-social {
    margin-top: 8px !important;
    padding-top: 10px !important;
    border-top: 1px solid #333 !important;
  }
}

/* 3. SK inquiry summary: on notebooks and narrow desktop windows, keep
   hero + previews together but give the product table the FULL grid width.
   This fixes the one-letter-per-line names caused by a narrow table column. */
@media (min-width: 1100px) and (max-width: 1399.98px) {
  html.ahp-layout-v497 .ahp-checkout-page .ahp-checkout-grid {
    display: grid !important;
    grid-template-columns: minmax(0, clamp(340px, 34%, 470px)) minmax(0, 1fr) !important;
    grid-template-areas: "hero side" "list list" !important;
    gap: 20px !important;
    align-items: start !important;
  }
  html.ahp-layout-v497 .ahp-checkout-page .ahp-checkout-grid > .ahp-checkout-hero {
    grid-area: hero !important;
    min-width: 0 !important;
  }
  html.ahp-layout-v497 .ahp-checkout-page .ahp-checkout-grid > .ahp-checkout-side {
    grid-area: side !important;
    min-width: 0 !important;
    position: static !important;
    top: auto !important;
  }
  html.ahp-layout-v497 .ahp-checkout-page .ahp-checkout-grid > .ahp-checkout-list-card {
    grid-area: list !important;
    grid-column: 1 / -1 !important;
    min-width: 0 !important;
    width: 100% !important;
    overflow: hidden !important;
  }
  html.ahp-layout-v497 .ahp-checkout-page :is(.ahp-row, .ahp-table-head, .ahp-section-total) {
    grid-template-columns: 64px minmax(240px, 1fr) 90px 130px 130px !important;
    gap: 12px !important;
  }
  /* Legacy 761-1160px rules hide the first (blank) table-header cell,
     shifting all labels one column left. Restore its grid track. */
  html.ahp-layout-v497 .ahp-checkout-page .ahp-table-head > span:first-child {
    display: block !important;
    grid-column: 1 !important;
  }
  html.ahp-layout-v497 .ahp-checkout-page .ahp-table-head > span:nth-child(2) { grid-column: 2 !important; }
  html.ahp-layout-v497 .ahp-checkout-page .ahp-table-head > span:nth-child(3) { grid-column: 3 !important; }
  html.ahp-layout-v497 .ahp-checkout-page .ahp-table-head > span:nth-child(4) { grid-column: 4 !important; }
  html.ahp-layout-v497 .ahp-checkout-page .ahp-table-head > span:nth-child(5) { grid-column: 5 !important; }
  html.ahp-layout-v497 .ahp-checkout-page .ahp-row-title {
    min-width: 0 !important;
    word-break: normal !important;
    overflow-wrap: break-word !important;
  }
}

/* Below 1100px the existing CZ-derived stacked-card rendering takes over.
   Explicitly restore the grid areas so a desktop two-column rule cannot win. */
@media (max-width: 1099.98px) {
  html.ahp-layout-v497 .ahp-checkout-page .ahp-checkout-grid {
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-areas: "hero" "side" "list" !important;
  }
  html.ahp-layout-v497 .ahp-checkout-page .ahp-checkout-grid > :is(.ahp-checkout-hero, .ahp-checkout-side, .ahp-checkout-list-card) {
    min-width: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  html.ahp-layout-v497 .ahp-checkout-page .ahp-row-title {
    word-break: normal !important;
    overflow-wrap: break-word !important;
  }
}


/* ===== AHProfi SK v642: isolated fixes for product cards, menu and summary ===== */
/* The mobile catalogue used a 146px viewport while quantity controls could
   extend below a fixed 132px card. Every card now fits its own controls. */
@media (max-width: 899px) and (orientation: portrait) {
  html.ahp-layout-v497 #editorScreen #productList.product-list {
    flex: 0 0 177px !important;
    height: 177px !important;
    min-height: 177px !important;
    max-height: 177px !important;
    grid-auto-rows: max-content !important;
    align-items: start !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    padding-bottom: 7px !important;
  }
  html.ahp-layout-v497 #editorScreen #productList .product-card {
    box-sizing: border-box !important;
    height: 160px !important;
    min-height: 160px !important;
    max-height: 160px !important;
    display: grid !important;
    grid-template-areas: "media main" "divider divider" "bottom bottom" !important;
    grid-template-rows: minmax(66px,1fr) 1px 38px !important;
    align-self: start !important;
    overflow: hidden !important;
  }
  html.ahp-layout-v497 #editorScreen #productList .product-bottom {
    grid-area: bottom !important;
    box-sizing: border-box !important;
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
    min-width: 0 !important;
    height: 38px !important;
    min-height: 38px !important;
    max-height: 38px !important;
    padding: 2px 0 0 !important;
    gap: 3px !important;
    overflow: hidden !important;
  }
  html.ahp-layout-v497 #editorScreen #productList .product-price {
    flex: 1 1 0 !important;
    min-width: 0 !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    text-align: center !important;
  }
  html.ahp-layout-v497 #editorScreen #productList .product-controls {
    flex: 0 0 78px !important;
    display: grid !important;
    grid-template-columns: 25px 28px 25px !important;
    width: 78px !important;
    min-width: 78px !important;
    max-width: 78px !important;
    height: 30px !important;
    min-height: 30px !important;
    max-height: 30px !important;
    margin: 0 !important;
    gap: 0 !important;
    position: static !important;
    transform: none !important;
  }
  html.ahp-layout-v497 #editorScreen #productList :is(.product-sub,.product-add) {
    width: 25px !important; min-width: 25px !important; max-width: 25px !important;
    height: 30px !important; min-height: 30px !important; max-height: 30px !important;
  }
  html.ahp-layout-v497 #editorScreen #productList .product-count-input {
    width: 28px !important; min-width: 28px !important; max-width: 28px !important;
    height: 30px !important; min-height: 30px !important; max-height: 30px !important;
  }
  html.ahp-layout-v497 #editorScreen #productList .price-sale {font-size: 12px !important;}
  html.ahp-layout-v497 #editorScreen #productList .price-old {font-size: 10px !important;}
}
/* On the narrowest phone, the sum of price and +/- controls cannot fit beside
   each other within half a screen. Use two lines rather than overflowing. */
@media (max-width: 359px) and (orientation: portrait) {
  html.ahp-layout-v497 #editorScreen #productList.product-list {
    flex-basis: 194px !important; height: 194px !important;
    min-height: 194px !important; max-height: 194px !important;
  }
  html.ahp-layout-v497 #editorScreen #productList .product-card {
    height: 178px !important; min-height: 178px !important; max-height: 178px !important;
    grid-template-rows: minmax(62px,1fr) 1px 64px !important;
  }
  html.ahp-layout-v497 #editorScreen #productList .product-bottom {
    flex-direction: column !important; justify-content: center !important;
    height: 64px !important; min-height: 64px !important; max-height: 64px !important;
    gap: 2px !important;
  }
  html.ahp-layout-v497 #editorScreen #productList .product-price { flex: 0 1 auto !important; }
  html.ahp-layout-v497 #editorScreen #productList .product-controls { flex: 0 0 30px !important; }
}
/* More recognizable pegboard silhouette on narrow category buttons: preserve
   dimensions rather than forcing a stretched product image. */
html.ahp-layout-v497 #editorScreen #categoryTabs .category-icon-tab img[src*="KPK7_derovane_desky.svg"] {
  object-fit: contain !important; object-position: center !important;
}

/* ONE hamburger style across setup, editor and checkout, independent of the
   older <=1099px menu CSS. Avoid button styles leaking from form/modals. */
@media (max-width: 1239.98px) {
  html.ahp-layout-v497 .ahp-mobile-header-menu :is(.ahp-mobile-menu-link,.ahp-mobile-menu-action) {
    display: flex !important;
    align-items: center !important;
    width: 100% !important;
    min-width: 0 !important;
    min-height: 44px !important;
    margin: 0 !important;
    padding: 10px 12px !important;
    border: 0 !important;
    outline-offset: 2px !important;
    border-radius: 8px !important;
    appearance: none !important;
    background: transparent !important;
    box-shadow: none !important;
    color: #fff !important;
    font: 800 15px/1.4 Arial,sans-serif !important;
    text-align: left !important;
    text-decoration: none !important;
    white-space: normal !important;
    text-transform: none !important;
    cursor: pointer !important;
  }
  html.ahp-layout-v497 .ahp-mobile-header-menu :is(.ahp-mobile-menu-link,.ahp-mobile-menu-action)[hidden] {display:none !important;}
  html.ahp-layout-v497 .ahp-mobile-header-menu :is(.ahp-mobile-menu-link,.ahp-mobile-menu-action):hover {
    background: #1c1c1c !important; color: #c11015 !important;
  }
  html.ahp-layout-v497 .ahp-mobile-header-menu :is(.ahp-mobile-menu-link,.ahp-mobile-menu-action):focus-visible {
    outline: 2px solid #fff !important; background: #1c1c1c !important;
  }
}
/* Summary: the 3% / 5% progress exists in editor and cart, not on this page. */
html.ahp-layout-v497 .ahp-checkout-page .ahp-quantity-discount-progress {display:none !important;}

/* Summary layout: full-width heading when the product table would otherwise
   be squeezed into a narrow left-hand column. Normal desktop layout >=1560px. */
@media (min-width: 1240px) and (max-width: 1559.98px) {
  html.ahp-layout-v497 .ahp-checkout-page .ahp-checkout-grid {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(340px, 380px) !important;
    grid-template-areas: "hero hero" "list side" !important;
    column-gap: 20px !important; row-gap: 20px !important; align-items: start !important;
  }
  html.ahp-layout-v497 .ahp-checkout-page .ahp-checkout-grid > .ahp-checkout-hero {grid-area:hero !important;min-width:0 !important;}
  html.ahp-layout-v497 .ahp-checkout-page .ahp-checkout-grid > .ahp-checkout-list-card {grid-area:list !important;grid-column:auto !important;min-width:0 !important;max-width:100% !important;}
  html.ahp-layout-v497 .ahp-checkout-page .ahp-checkout-grid > .ahp-checkout-side {grid-area:side !important;min-width:0 !important;max-width:100% !important;position:static !important;}
  html.ahp-layout-v497 .ahp-checkout-page :is(.ahp-table-head,.ahp-row,.ahp-section-total) {
    grid-template-columns: 52px minmax(170px,1fr) 65px 96px 96px !important;
    gap: 9px !important;
  }
  html.ahp-layout-v497 .ahp-checkout-page .ahp-table-head > span:first-child {display:block !important;grid-column:1 !important;}
  html.ahp-layout-v497 .ahp-checkout-page .ahp-table-head > span:nth-child(2) {grid-column:2 !important;}
  html.ahp-layout-v497 .ahp-checkout-page .ahp-table-head > span:nth-child(3) {grid-column:3 !important;}
  html.ahp-layout-v497 .ahp-checkout-page .ahp-table-head > span:nth-child(4) {grid-column:4 !important;}
  html.ahp-layout-v497 .ahp-checkout-page .ahp-table-head > span:nth-child(5) {grid-column:5 !important;}
  html.ahp-layout-v497 .ahp-checkout-page .ahp-row-title {word-break:normal !important;overflow-wrap:break-word !important;}
}
@media (max-width: 1239.98px) {
  html.ahp-layout-v497 .ahp-checkout-page .ahp-checkout-grid {
    display: grid !important;
    grid-template-columns: minmax(0,1fr) !important;
    grid-template-areas: "hero" "side" "list" !important;
    gap: 20px !important;
  }
  html.ahp-layout-v497 .ahp-checkout-page .ahp-checkout-grid > .ahp-checkout-hero {grid-area:hero !important;min-width:0 !important;max-width:100% !important;}
  html.ahp-layout-v497 .ahp-checkout-page .ahp-checkout-grid > .ahp-checkout-list-card {grid-area:list !important;grid-column:1 !important;min-width:0 !important;width:100% !important;max-width:100% !important;}
  html.ahp-layout-v497 .ahp-checkout-page .ahp-checkout-grid > .ahp-checkout-side {grid-area:side !important;min-width:0 !important;width:100% !important;max-width:100% !important;position:static !important;}
}
@media (min-width: 761px) and (max-width: 1239.98px) {
  html.ahp-layout-v497 .ahp-checkout-page :is(.ahp-table-head,.ahp-row,.ahp-section-total) {
    grid-template-columns: 64px minmax(210px,1fr) 92px 116px 116px !important;
    gap: 12px !important;
  }
  html.ahp-layout-v497 .ahp-checkout-page .ahp-table-head > span:first-child {display:block !important;grid-column:1 !important;}
  html.ahp-layout-v497 .ahp-checkout-page .ahp-table-head > span:nth-child(2) {grid-column:2 !important;}
  html.ahp-layout-v497 .ahp-checkout-page .ahp-table-head > span:nth-child(3) {grid-column:3 !important;}
  html.ahp-layout-v497 .ahp-checkout-page .ahp-table-head > span:nth-child(4) {grid-column:4 !important;}
  html.ahp-layout-v497 .ahp-checkout-page .ahp-table-head > span:nth-child(5) {grid-column:5 !important;}
}
html.ahp-layout-v497 .ahp-checkout-page .ahp-checkout-grid > *,
html.ahp-layout-v497 .ahp-checkout-page :is(.ahp-checkout-list-card,.ahp-preview-card,.ahp-totals-card) {min-width:0;max-width:100%;}
html.ahp-layout-v497 .ahp-checkout-page .ahp-checkout-setup {max-width:100%;}

/* The stacked summary on 820-1239px should not turn preview images into
   enormous full-screen panels. Show previews next to totals, both below
   the full-width configuration summary, while products stay full width. */
@media (min-width: 820px) and (max-width: 1239.98px) {
  html.ahp-layout-v497 .ahp-checkout-page .ahp-checkout-grid > .ahp-checkout-side {
    display: grid !important;
    grid-template-columns: minmax(0, 1.25fr) minmax(290px, .75fr) !important;
    align-items: start !important;
    gap: 16px !important;
  }
  html.ahp-layout-v497 .ahp-checkout-page .ahp-checkout-side > :is(.ahp-preview-card,.ahp-totals-card) {
    min-width: 0 !important; max-width: 100% !important;
  }
}
@media (min-width: 900px) and (max-width: 1239.98px) {
  html.ahp-layout-v497 .ahp-checkout-page #checkoutSetupBox {
    grid-template-columns: repeat(5, minmax(0,1fr)) !important;
  }
}
