/* KARETA r56 — real route reference style activation.
   Problem fixed: r52-r55 applied well to #services, but other pages were gated by role/body classes.
   This layer targets actual hash routes via body.kr-route-* added by js/route_style_r56.js. */

:root{
  --r56-bg:#eef0f2;
  --r56-page:#ffffff;
  --r56-soft:#f4f4f5;
  --r56-line:#e7e8eb;
  --r56-text:#090b10;
  --r56-muted:#707782;
  --r56-orange:#ffb000;
  --r56-orange-2:#ff9800;
  --r56-radius:18px;
  --r56-radius-lg:28px;
  --r56-shadow:0 16px 42px rgba(15,23,42,.08);
  --r56-shadow-soft:0 8px 24px rgba(15,23,42,.055);
}

body.kr-route-myorders,
body.kr-route-messages,
body.kr-route-masters,
body.kr-route-cabinet,
body.kr-route-parts{
  background:var(--r56-bg) !important;
}

/* Real route shell activation */
body.kr-route-myorders #app > .page,
body.kr-route-messages #app > .page,
body.kr-route-masters #app > .page,
body.kr-route-cabinet #app > .page,
body.kr-route-parts #app > .page{
  min-height:100dvh !important;
  background:var(--r56-bg) !important;
  padding:clamp(14px,2.6vw,32px) clamp(12px,2.8vw,38px) calc(112px + env(safe-area-inset-bottom,0px)) !important;
}

body.kr-route-myorders #app > .page > section,
body.kr-route-messages #app > .page > section,
body.kr-route-masters #app > .page > section,
body.kr-route-cabinet #app > .page > section,
body.kr-route-parts #app > .page > section{
  margin:0 !important;
  padding:0 !important;
}

body.kr-route-myorders #app > .page .container,
body.kr-route-messages #app > .page .container,
body.kr-route-masters #app > .page .container,
body.kr-route-cabinet #app > .page .container,
body.kr-route-parts #app > .page .container,
body.kr-route-cabinet .cab-pane > .container{
  width:100% !important;
  max-width:1120px !important;
  margin:0 auto !important;
  padding:clamp(20px,3vw,38px) !important;
  background:var(--r56-page) !important;
  border:1px solid rgba(15,23,42,.055) !important;
  border-radius:var(--r56-radius-lg) !important;
  box-shadow:var(--r56-shadow) !important;
  overflow:hidden !important;
}

/* Hero/header actual classes */
body.kr-route-myorders :where(.spa-hero,.page-hero,.kr-header,.section-head,.cab-head,.ccab-hero),
body.kr-route-messages :where(.spa-hero,.page-hero,.kr-header,.section-head,.cab-head,.ccab-hero),
body.kr-route-masters :where(.spa-hero,.page-hero,.kr-header,.section-head,.cab-head,.ccab-hero),
body.kr-route-cabinet :where(.spa-hero,.page-hero,.kr-header,.section-head,.cab-head,.ccab-hero),
body.kr-route-parts :where(.spa-hero,.page-hero,.kr-header,.section-head,.cab-head,.ccab-hero){
  margin:0 0 clamp(18px,2.4vw,30px) !important;
  padding:0 !important;
  background:transparent !important;
  border:0 !important;
  box-shadow:none !important;
}

body.kr-route-myorders :where(h1,.spa-hero-title,.kr-header__title,.page-title,.cab-title,.ccab-title),
body.kr-route-messages :where(h1,.spa-hero-title,.kr-header__title,.page-title,.cab-title,.ccab-title),
body.kr-route-masters :where(h1,.spa-hero-title,.kr-header__title,.page-title,.cab-title,.ccab-title),
body.kr-route-cabinet :where(h1,.spa-hero-title,.kr-header__title,.page-title,.cab-title,.ccab-title),
body.kr-route-parts :where(h1,.spa-hero-title,.kr-header__title,.page-title,.cab-title,.ccab-title){
  color:var(--r56-text) !important;
  font-size:clamp(32px,4.6vw,58px) !important;
  line-height:.96 !important;
  font-weight:950 !important;
  letter-spacing:-.07em !important;
  margin:0 0 10px !important;
}

body.kr-route-myorders :where(.spa-hero-sub,.page-subtitle,.kr-header__sub,.cab-sub,.ccab-sub,.muted),
body.kr-route-messages :where(.spa-hero-sub,.page-subtitle,.kr-header__sub,.cab-sub,.ccab-sub,.muted),
body.kr-route-masters :where(.spa-hero-sub,.page-subtitle,.kr-header__sub,.cab-sub,.ccab-sub,.muted),
body.kr-route-cabinet :where(.spa-hero-sub,.page-subtitle,.kr-header__sub,.cab-sub,.ccab-sub,.muted),
body.kr-route-parts :where(.spa-hero-sub,.page-subtitle,.kr-header__sub,.cab-sub,.ccab-sub,.muted){
  color:var(--r56-muted) !important;
  font-size:clamp(15px,1.8vw,18px) !important;
  line-height:1.35 !important;
}

/* Real page card classes */
body.kr-route-myorders :where(.mo-card,.myorder-card,.order-card,.order-row,.exchange-card),
body.kr-route-messages :where(.messenger-card,.message-card,.dialog-card,.chat-card,.msg-card),
body.kr-route-masters :where(.master-card,.mcl-card,.masters-page-card,.master-list-card),
body.kr-route-cabinet :where(.cab-card,.cab-pane,.ccab-card,.ccab-panel,.cabinet-card,.settings-row,.profile-row,.car-card,.notify-row),
body.kr-route-parts :where(.parts-category-card,.product-card,.parts-card,.shop-card){
  min-width:0 !important;
  max-width:100% !important;
  border:1px solid var(--r56-line) !important;
  border-radius:var(--r56-radius) !important;
  background:#fff !important;
  box-shadow:var(--r56-shadow-soft) !important;
  overflow:hidden !important;
}

/* Myorders exact blocks */
body.kr-route-myorders :where(.mo-filter-bar,.myorders-sticky-tools,.catalog-tools,.spa-tools){
  border:1px solid var(--r56-line) !important;
  border-radius:16px !important;
  background:var(--r56-soft) !important;
  padding:10px !important;
  box-shadow:none !important;
  overflow:auto !important;
}
body.kr-route-myorders :where(.mo-filter-tabs){
  display:flex !important;
  gap:8px !important;
  overflow:auto !important;
  scrollbar-width:none !important;
}
body.kr-route-myorders :where(.mo-filter-tab){
  min-height:38px !important;
  border:0 !important;
  border-radius:12px !important;
  background:#fff !important;
  color:var(--r56-muted) !important;
  padding:0 12px !important;
  font-weight:850 !important;
  white-space:nowrap !important;
}
body.kr-route-myorders :where(.mo-filter-tab.active){
  color:#111 !important;
  background:#fff3c7 !important;
  box-shadow:inset 0 -2px 0 var(--r56-orange) !important;
}
body.kr-route-myorders :where(.mo-card){
  padding:16px !important;
  margin:12px 0 !important;
  display:grid !important;
  gap:12px !important;
}

/* Messages exact + generic messenger */
body.kr-route-messages :where(.messenger-page,.messenger-shell,.messages-page,.dialogs-page){
  background:transparent !important;
}
body.kr-route-messages :where(.messenger-card,.dialog-card,.chat-card,.message-card){
  padding:14px !important;
  display:grid !important;
  grid-template-columns:54px minmax(0,1fr) auto !important;
  gap:12px !important;
  align-items:center !important;
}
body.kr-route-messages :where(.messenger-avatar,.dialog-avatar,.chat-avatar,.avatar){
  width:54px !important;
  height:54px !important;
  border-radius:14px !important;
  background:#26282e !important;
  color:#fff !important;
  flex:0 0 auto !important;
}

/* Masters exact classes */
body.kr-route-masters :where(.masters-page-shell,.masters-shell){
  max-width:1120px !important;
  margin:0 auto !important;
}
body.kr-route-masters :where(.masters-grid,.masters-list,.mcl-grid,.mcl-list){
  display:grid !important;
  gap:14px !important;
}
body.kr-route-masters :where(.master-card,.mcl-card){
  padding:16px !important;
}

/* Cabinet actual panes */
body.kr-route-cabinet :where(.cab-pane){
  display:block;
  padding:0 !important;
  background:transparent !important;
  border:0 !important;
  box-shadow:none !important;
}
body.kr-route-cabinet :where(.cab-pane-layout,.ccab-grid,.cab-grid){
  display:grid !important;
  gap:14px !important;
}
body.kr-route-cabinet :where(.settings-row,.profile-row,.cab-row,.ccab-row){
  min-height:56px !important;
  padding:12px 14px !important;
  display:grid !important;
  grid-template-columns:38px minmax(0,1fr) auto !important;
  gap:12px !important;
  align-items:center !important;
}

/* Parts as adjacent route */
body.kr-route-parts :where(.parts-category-grid,.parts-grid,.product-grid){
  display:grid !important;
  gap:14px !important;
}
body.kr-route-parts :where(.parts-category-card,.product-card,.parts-card){
  padding:16px !important;
}

/* Buttons / inputs */
body:is(.kr-route-myorders,.kr-route-messages,.kr-route-masters,.kr-route-cabinet,.kr-route-parts) :where(.btn,.button,button,.action-btn){
  min-width:0 !important;
  max-width:100% !important;
  border-radius:12px !important;
  font-weight:850 !important;
  overflow-wrap:anywhere !important;
}
body:is(.kr-route-myorders,.kr-route-messages,.kr-route-masters,.kr-route-cabinet,.kr-route-parts) :where(.btn-primary,.primary-btn,.submit-btn,.cta){
  background:linear-gradient(180deg,var(--r56-orange),var(--r56-orange-2)) !important;
  color:#111 !important;
  border:0 !important;
  box-shadow:0 10px 22px rgba(255,176,0,.22) !important;
}
body:is(.kr-route-myorders,.kr-route-messages,.kr-route-masters,.kr-route-cabinet,.kr-route-parts) :where(input,select,textarea){
  min-height:44px !important;
  border:1px solid var(--r56-line) !important;
  border-radius:12px !important;
  background:#fff !important;
  color:var(--r56-text) !important;
  font-size:16px !important;
}

/* Tablet and PC layout */
@media (min-width:768px){
  body:is(.kr-route-myorders,.kr-route-messages,.kr-route-masters,.kr-route-cabinet,.kr-route-parts) #app > .page{
    padding:clamp(22px,3vw,40px) clamp(20px,3vw,48px) calc(126px + env(safe-area-inset-bottom,0px)) !important;
  }
  body.kr-route-myorders :where(.mo-list,.myorders-list,.orders-grid),
  body.kr-route-masters :where(.masters-grid,.masters-list,.mcl-grid,.mcl-list),
  body.kr-route-parts :where(.parts-category-grid,.parts-grid,.product-grid),
  body.kr-route-cabinet :where(.cab-pane-layout,.ccab-grid,.cab-grid){
    grid-template-columns:repeat(2,minmax(0,1fr)) !important;
  }
}
@media (min-width:1024px){
  body.kr-route-myorders :where(.mo-list,.myorders-list,.orders-grid),
  body.kr-route-masters :where(.masters-grid,.masters-list,.mcl-grid,.mcl-list),
  body.kr-route-parts :where(.parts-category-grid,.parts-grid,.product-grid){
    grid-template-columns:repeat(3,minmax(0,1fr)) !important;
  }
  body.kr-route-messages :where(.messenger-shell,.messages-shell){
    display:grid !important;
    grid-template-columns:minmax(320px,.42fr) minmax(0,.58fr) !important;
    gap:16px !important;
  }
}

/* Mobile clean app mode */
@media (max-width:767px){
  body:is(.kr-route-myorders,.kr-route-messages,.kr-route-masters,.kr-route-cabinet,.kr-route-parts),
  body:is(.kr-route-myorders,.kr-route-messages,.kr-route-masters,.kr-route-cabinet,.kr-route-parts) #app > .page{
    background:#fff !important;
  }
  body:is(.kr-route-myorders,.kr-route-messages,.kr-route-masters,.kr-route-cabinet,.kr-route-parts) #app > .page{
    padding:0 0 calc(92px + env(safe-area-inset-bottom,0px)) !important;
  }
  body:is(.kr-route-myorders,.kr-route-messages,.kr-route-masters,.kr-route-cabinet,.kr-route-parts) #app > .page .container,
  body.kr-route-cabinet .cab-pane > .container{
    border:0 !important;
    border-radius:0 !important;
    box-shadow:none !important;
    padding:18px 14px 22px !important;
    min-height:100dvh !important;
  }
  body:is(.kr-route-myorders,.kr-route-messages,.kr-route-masters,.kr-route-cabinet,.kr-route-parts) :where(h1,.spa-hero-title,.kr-header__title,.page-title,.cab-title,.ccab-title){
    font-size:clamp(30px,9vw,40px) !important;
  }
}

/* Final hard overlap guard for real routes */
body:is(.kr-route-myorders,.kr-route-messages,.kr-route-masters,.kr-route-cabinet,.kr-route-parts) :where(h1,h2,h3,h4,p,span,small,b,strong,a,button,label,div){
  min-width:0 !important;
  max-width:100% !important;
  overflow-wrap:anywhere !important;
  word-break:normal !important;
}
