/* Smart marketplace header: append after existing header/shared styles.
   Opt-in only. Native search/menu/profile/basket states and handlers stay owned
   by their existing controllers. No universal font reset: lnr glyphs retain
   their icon face; only actual text labels receive the Smart text family. */
body#body.smart-ui:has(header#header.smart-header-market) {
  --smart-header-height: var(--smart-header-h,120px);
}
body#body.smart-ui header#header.smart-header-market,
body#body.smart-ui header#header.smart-header-market.scroll {
  height: 120px !important;
  padding: 12px 0 !important;
  border-bottom: 1px solid #e8ede9;
  background: #fff;
  box-shadow: 0 3px 14px rgba(31,55,39,.035);
}
body#body.smart-ui header#header.smart-header-market > .smart-header-layout {
  display: grid !important;
  grid-template-columns: 160px 132px minmax(320px,1fr) 72px 80px 72px !important;
  grid-template-rows: 56px 32px !important;
  grid-template-areas: "logo catalog search profile favorites basket" "menu menu location location location location" !important;
  align-items: center;
  gap: 8px 14px;
  width: calc(100% - 48px) !important;
  max-width: 1440px;
  height: 96px !important;
  margin: 0 auto !important;
  padding: 0 !important;
  position: relative;
}
body#body.smart-ui header#header.smart-header-market .logo {
  grid-area: logo;
  display: block !important;
  min-width: 0;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  text-align: left !important;
}
body#body.smart-ui header#header.smart-header-market .logo img {
  display: block;
  width: 160px !important;
  max-width: 100% !important;
  max-height: 46px !important;
  height: auto !important;
  object-fit: contain;
}
body#body.smart-ui header#header.smart-header-market .shc {
  grid-area: catalog;
  position: static !important;
  display: block !important;
  width: auto !important;
  height: auto !important;
  margin: 0 !important;
  padding: 0 !important;
}
body#body.smart-ui header#header.smart-header-market .shc > .shc-button {
  display: flex !important;
  align-items: center;
  justify-content: center;
  gap: 10px !important;
  box-sizing: border-box;
  width: 132px !important;
  height: 52px !important;
  min-height: 44px;
  padding: 0 12px !important;
  border: 0 !important;
  border-radius: 12px !important;
  background: #ffd64d !important;
  color: #29472f !important;
  font-family: var(--smart-ui-font) !important;
  font-size: 16px !important;
  font-weight: 700 !important;
  line-height: 1.25 !important;
  text-decoration: none;
}
body#body.smart-ui header#header.smart-header-market .shc-button::before {
  display: none !important;
  content: none !important;
}
body#body.smart-ui header#header.smart-header-market .shc-button > svg {
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
}
body#body.smart-ui header#header.smart-header-market .shc > .shc-button:hover { background: #ffdc68 !important; }

/* Preserve original form, input, clear, submit and result-list nodes. */
body#body.smart-ui header#header.smart-header-market #s-form.smart-live-search,
body#body.smart-ui header#header.smart-header-market #s-form.smart-live-search.opened {
  grid-area: search;
  height: 52px !important;
  min-width: 0;
  border: 2px solid #e4bc40 !important;
  border-radius: 12px !important;
  background: #fff !important;
  box-shadow: none !important;
}
body#body.smart-ui header#header.smart-header-market #s-form:focus-within {
  border-color: #447b4f !important;
  box-shadow: 0 0 0 3px rgba(70,119,74,.12) !important;
}
body#body.smart-ui header#header.smart-header-market #s-form .smart-live-search__input {
  box-sizing: border-box;
  height: 48px !important;
  min-height: 40px !important;
  padding: 0 100px 0 16px !important;
  border-radius: 10px !important;
  font-family: var(--smart-ui-font) !important;
  font-size: 16px !important;
  font-weight: 400;
  line-height: 1.35 !important;
  white-space: nowrap;
}
body#body.smart-ui header#header.smart-header-market #s-form .smart-live-search__submit {
  top: 2px !important;
  right: 2px !important;
  width: 44px !important;
  height: 44px !important;
  min-width: 44px;
  min-height: 44px;
  border: 0;
  border-radius: 9px !important;
  background: #ffd64d !important;
  color: #29472f;
}
body#body.smart-ui header#header.smart-header-market #s-form .smart-live-search__submit .lnr {
  font-family: "Linearicons-Free" !important;
  font-size: 22px !important;
}
body#body.smart-ui header#header.smart-header-market .smart-header-search-clear {
  top: 2px;
  right: 48px;
  width: 44px;
  height: 44px;
  line-height: 1;
}

/* The native profile glyph is a ::before on the lnr button, not a text font. */
body#body.smart-ui header#header.smart-header-market .profil { grid-area: profile; }
body#body.smart-ui header#header.smart-header-market .smart-header-favorites { grid-area: favorites; }
body#body.smart-ui header#header.smart-header-market #shop-basket { grid-area: basket; }
body#body.smart-ui header#header.smart-header-market :is(.profil-icon,.smart-header-favorites,.shop-header) {
  position: relative;
  display: flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  box-sizing: border-box;
  width: 100% !important;
  min-width: 0;
  height: 52px !important;
  min-height: 44px;
  margin: 0 !important;
  padding: 2px 0 !important;
  border: 0 !important;
  border-radius: 10px !important;
  background: transparent !important;
  color: #35463a;
  box-shadow: none !important;
  line-height: 1 !important;
  text-decoration: none;
  cursor: pointer;
}
body#body.smart-ui header#header.smart-header-market .profil-icon::before,
body#body.smart-ui header#header.smart-header-market .shop-header .shop-header-icon {
  font-family: "Linearicons-Free" !important;
  font-size: 24px !important;
  font-weight: 400;
  line-height: 24px !important;
}
body#body.smart-ui header#header.smart-header-market .smart-header-favorites > svg {
  display: block;
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
}
body#body.smart-ui header#header.smart-header-market .smart-header-action-label,
body#body.smart-ui header#header.smart-header-market .shop-header::after {
  display: block;
  color: inherit;
  font-family: var(--smart-ui-font) !important;
  font-size: 13px !important;
  font-weight: 500;
  line-height: 18px !important;
  white-space: nowrap;
}
body#body.smart-ui header#header.smart-header-market .shop-header::after { content: "Корзина"; }
body#body.smart-ui header#header.smart-header-market .shop-header .shop-header-count {
  top: -3px;
  right: 8px;
  min-width: 19px;
  height: 19px;
  padding: 0 4px;
  border: 2px solid #fff;
  background: #3e7549;
  color: #fff;
  box-shadow: none;
  font-family: var(--smart-ui-font) !important;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}
body#body.smart-ui header#header.smart-header-market :is(.profil-icon,.smart-header-favorites,.shop-header):hover { background: #f3f7f0 !important; }

/* Desktop secondary row uses the original menu; mobile panel states untouched. */
body#body.smart-ui header#header.smart-header-market #menu { grid-area: menu; }
body#body.smart-ui header#header.smart-header-market .smart-header-location {
  grid-area: location;
  justify-self: end;
  display: block;
  min-width: 0;
  max-width: 100%;
  color: #6c786f;
  font-family: var(--smart-ui-font);
  font-size: 13px;
  font-weight: 400;
  line-height: 22px;
  text-decoration: none;
}
body#body.smart-ui header#header.smart-header-market .smart-header-location:hover { color: #39764c; text-decoration: underline; }
body#body.smart-ui header#header.smart-header-market :is(a,button,input):focus-visible { outline: 2px solid #39764c !important; outline-offset: 3px; }
body#body.smart-ui header#header.smart-header-market #s-form .smart-live-search__input:focus-visible { outline: none !important; }
body#body.smart-ui header#header.smart-header-market + .header-bottom { height: var(--smart-header-h,120px) !important; }
body#body.smart-ui header#header.smart-header-market #shop-basket .b-body {
  max-height: min(740px,calc(100vh - var(--smart-header-h,120px) - 14px)) !important;
  max-height: min(740px,calc(100dvh - var(--smart-header-h,120px) - 14px)) !important;
}
@media (min-width: 1100px) {
  body#body.smart-ui header#header.smart-header-market #menu .uMenuRoot { gap: 4px; }
  body#body.smart-ui header#header.smart-header-market #menu .uMenuRoot > li > a {
    min-height: 32px !important;
    padding: 4px 10px !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    line-height: 24px !important;
  }
}

/* Tablet: first row retains catalogue and native menu toggle; search spans row2. */
@media (min-width: 768px) and (max-width: 1099.98px) {
  body#body.smart-ui header#header.smart-header-market,
  body#body.smart-ui header#header.smart-header-market.scroll { height: 116px !important; padding: 10px 0 !important; }
  body#body.smart-ui header#header.smart-header-market > .smart-header-layout {
    grid-template-columns: 150px 132px minmax(44px,1fr) 64px 72px 64px !important;
    grid-template-rows: 44px 44px !important;
    grid-template-areas: "logo catalog menu profile favorites basket" "search search search search search search" !important;
    gap: 8px 10px;
    width: calc(100% - 32px) !important;
    height: 96px !important;
  }
  body#body.smart-ui header#header.smart-header-market .logo img { width: 150px !important; max-height: 43px !important; }
  body#body.smart-ui header#header.smart-header-market .shc > .shc-button { height: 44px !important; }
  body#body.smart-ui header#header.smart-header-market :is(.profil-icon,.smart-header-favorites,.shop-header) { height: 44px !important; gap: 2px; padding: 0 !important; }
  body#body.smart-ui header#header.smart-header-market .smart-header-action-label,
  body#body.smart-ui header#header.smart-header-market .shop-header::after { font-size: 12px !important; line-height: 16px !important; }
  body#body.smart-ui header#header.smart-header-market .profil-icon::before,
  body#body.smart-ui header#header.smart-header-market .shop-header .shop-header-icon { font-size: 22px !important; line-height: 22px !important; }
  body#body.smart-ui header#header.smart-header-market .smart-header-favorites > svg { width: 22px; height: 22px; flex-basis: 22px; }
  body#body.smart-ui header#header.smart-header-market #menu { justify-self: end; }
  body#body.smart-ui header#header.smart-header-market .smart-header-menu-toggle { width: 44px; padding: 0 !important; }
  body#body.smart-ui header#header.smart-header-market .smart-header-menu-toggle > span:not(.lnr) { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  body#body.smart-ui header#header.smart-header-market .smart-header-location { display: none; }
}

/* At mobile widths the search is permanent, and all exposed actions stay44px. */
@media (max-width: 767.98px) {
  body#body.smart-ui header#header.smart-header-market,
  body#body.smart-ui header#header.smart-header-market.scroll { height: 112px !important; padding: 8px 0 !important; }
  body#body.smart-ui header#header.smart-header-market > .smart-header-layout {
    grid-template-columns: minmax(0,1fr) repeat(4,44px) !important;
    grid-template-rows: 44px 44px !important;
    grid-template-areas: "logo menu profile favorites basket" "search search search search search" !important;
    gap: 8px 6px;
    width: calc(100% - 24px) !important;
    height: 96px !important;
  }
  body#body.smart-ui header#header.smart-header-market .logo img { width: 132px !important; max-height: 38px !important; }
  body#body.smart-ui header#header.smart-header-market .shc { display: none !important; }
  body#body.smart-ui header#header.smart-header-market #menu { justify-self: stretch; }
  body#body.smart-ui header#header.smart-header-market .smart-header-menu-toggle { width: 44px; min-width: 44px; padding: 0 !important; }
  body#body.smart-ui header#header.smart-header-market .smart-header-menu-toggle > span:not(.lnr) { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  body#body.smart-ui header#header.smart-header-market :is(.profil-icon,.smart-header-favorites,.shop-header) { width: 44px !important; height: 44px !important; min-width: 44px; gap: 0; padding: 0 !important; }
  body#body.smart-ui header#header.smart-header-market .smart-header-action-label,
  body#body.smart-ui header#header.smart-header-market .shop-header::after { display: none; }
  body#body.smart-ui header#header.smart-header-market .shop-header .shop-header-count { top: -3px; right: -3px; }
  body#body.smart-ui header#header.smart-header-market .smart-header-location { display: none; }
}

/* One44px action is omitted only below360; wishlist remains in native profile. */
@media (max-width: 359.98px) {
  body#body.smart-ui header#header.smart-header-market > .smart-header-layout {
    grid-template-columns: minmax(0,1fr) repeat(3,44px) !important;
    grid-template-areas: "logo menu profile basket" "search search search search" !important;
    width: calc(100% - 16px) !important;
  }
  body#body.smart-ui header#header.smart-header-market .logo img { width: 112px !important; max-height: 34px !important; }
  body#body.smart-ui header#header.smart-header-market .smart-header-favorites { display: none !important; }
}
@media (max-width: 1099.98px) {
  body#body.smart-ui header#header.smart-header-market #s-form.smart-live-search,
  body#body.smart-ui header#header.smart-header-market #s-form.smart-live-search.opened { height: 44px !important; }
  body#body.smart-ui header#header.smart-header-market #s-form .smart-live-search__input { height: 40px !important; padding: 0 94px 0 12px !important; }
  body#body.smart-ui header#header.smart-header-market #s-form .smart-live-search__submit { top: -2px !important; right: -2px !important; }
  body#body.smart-ui header#header.smart-header-market .smart-header-search-clear { top: -2px; right: 42px; }
}

/* Fractional CSS viewport widths must use the same native mobile-menu branch.
   Keep [hidden] authoritative; the existing JS alone changes hidden/is-open. */
@media (max-width: 1099.98px) {
  body#body.smart-ui header#header.smart-header-market .smart-header-menu-toggle {
    display: flex !important;
    align-items: center;
    justify-content: center;
  }
  body#body.smart-ui header#header.smart-header-market .smart-header-nav-panel {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    left: auto;
    width: min(340px,calc(100vw - 24px));
    padding: 8px;
    border: 1px solid #e0e5eb;
    border-radius: 11px;
    background: #fff;
    box-shadow: 0 12px 30px rgba(25,34,45,.16);
    z-index: 35;
  }
  body#body.smart-ui header#header.smart-header-market .smart-header-nav-panel.is-open { display: block; }
  body#body.smart-ui header#header.smart-header-market .smart-header-nav-panel[hidden] { display: none !important; }
  body#body.smart-ui header#header.smart-header-market .smart-header-catalog-mobile {
    display: block !important;
    width: auto !important;
    height: auto !important;
    min-height: 44px;
    margin: 0 !important;
    padding: 11px 12px !important;
    border-radius: 7px !important;
    background: #fff5cf;
    font-size: 14px !important;
    line-height: 22px !important;
    text-align: left !important;
  }
  body#body.smart-ui header#header.smart-header-market #menu .uMenuRoot { display: block !important; }
  body#body.smart-ui header#header.smart-header-market #menu .uMenuRoot > li { margin: 0 !important; padding: 0 !important; }
  body#body.smart-ui header#header.smart-header-market #menu .uMenuRoot > li > a {
    min-height: 44px;
    padding: 10px 12px !important;
    font-size: 14px !important;
    line-height: 24px !important;
    white-space: normal;
  }
  body#body.smart-ui header#header.smart-header-market #menu .uMenuRoot ul {
    position: static !important;
    left: auto !important;
    top: auto !important;
    width: auto !important;
    opacity: 1 !important;
    box-shadow: none !important;
    border-radius: 0 !important;
  }
  body#body.smart-ui header#header.smart-header-market #menu .uMenuRoot > li > a > span::after { display: none; }
}
