:root{
    --bg:#ffffff;
    --text:#000000;
    --muted:#6b7280;
    --line:#D9D9D9;
    --brand:#2563eb;
    --brand-50:#eff6ff;
    --shadow:0 10px 30px rgba(0,0,0,.08);
    --radius:16px;
    --header-h:90px;
}

/* ========== Base ========== */
*{box-sizing:border-box}
a{color:inherit;text-decoration:none}
img{max-width:100%;display:block}

/* ========== Header (fixed, overlay, smooth) ========== */
.header{
    position:fixed; left:0; right:0; top:0;
    height:var(--header-h);
    z-index:1080;
    background:transparent!important;
    border-bottom-color:transparent!important;
    box-shadow:none!important;
    isolation:isolate; /* слои внутри хедера управляются предсказуемо */
}
.header::before{
    content:"";
    position:absolute; inset:0;
    background:#fff;
    border-bottom:1px solid var(--line);
    box-shadow:0 6px 20px rgba(0,0,0,.06);
    opacity:0;
    transform:translateY(-6px);
    transition:opacity .22s ease, transform .22s ease;
    pointer-events:none;
    z-index:0;
}
.header.is-entering::before,
.header.is-hover::before,
.header.is-solid::before{ opacity:1; transform:translateY(0) }
.header > *{ position:relative; z-index:1 }

/* ========== Top bar layout ========== */
.container{max-width:1200px;margin:0 auto;padding:0 16px}
.bar{display:flex;align-items:center;gap:24px;height:100%}
.logo{font-weight:800;letter-spacing:.3px}
.logo img{display:block;transition:opacity .2s ease}
.nav{
    margin-right: auto;
    margin-left: auto;
    position: relative;
    left: -90px;
}
.nav ul{
    display:flex;
    list-style:none;
    padding:0;
    margin:0;
}
.nav > ul > li{position:static}
.nav a.toplink{
    height:var(--header-h); /* кликабельная зона на всю высоту хедера */
    padding:0 12px;
    display:flex; align-items:center; gap:8px;
    border-radius:10px; position:relative;
    font-weight: 200;
    font-size: 18px;
}
.nav a.toplink:focus-visible{outline:2px solid var(--brand)}
.nav a.toplink:hover{}
/* Индикатор активной верхней категории */
.nav > ul > li.mega-item:hover > a.toplink::before,
.nav > ul > li.mega-item.active > a.toplink::before{
    content:""; position:absolute; left:12px; top:4px;
    width:28px; height:2px; background:#0F367A; border-radius:2px;
}

/* ========== Mobile trigger ========== */
.burger{display:none;margin-left:auto;border:0;background:transparent;font-size:0}
.burger span{display:block;width:24px;height:2px;background:var(--text);position:relative}
.burger span:before,.burger span:after{
    content:""; position:absolute; left:0; width:24px; height:2px; background:var(--text)
}
.burger span:before{top:-7px} .burger span:after{top:7px}

/* ========== Mega menu (desktop) ========== */
.mega{
    position:fixed; left: 20px; right:0; top:var(--header-h);width: calc(100% - 40px);
    z-index:1000; opacity:0; visibility:hidden; pointer-events:none;
    transition:opacity .22s ease, visibility .22s ease;
    background: #F7F7F7;
    padding: 30px;
    height: 70vh;
}
.mega.open{opacity:1;visibility:visible;pointer-events:auto}
.mega .panel{
    display:grid;
    grid-template-columns:300px 1fr;
    margin:0; max-width:none;
    max-height: calc(100% - 30px);
    overflow:hidden;
    background:#F7F7F7;
    border-radius:0;
    width: 1380px;
    margin-left: auto;
    margin-right: auto;
}
.mega .left {
    background: #F7F7F7;
    max-height: 66.666vh;
    overflow: auto;
    /*scrollbar-gutter: stable both-edges;*/
    border-top: 1px solid var(--line);
}
.mega .right{
    padding: 0 16px 60px 0;
    max-height:66.666vh;
    overflow:auto;
    scrollbar-gutter:stable both-edges;
    background: #F7F7F7;
    border-top: 1px solid var(--line);
}
.section-title{font-weight:700;margin:6px 10px 10px}

/* Tabs (left) */
.subnav{
    display:flex;
    flex-direction:column;
    list-style:none;
    margin:0;
    padding:4px
}
.subnav li{margin:0}
.subbtn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px 0 40px;
    background: none;
    cursor: pointer;
    border: none;
    border-bottom: 1px solid var(--line);
    border-right: 1px solid var(--line);
    border-left: 1px solid #F7F7F7;
    box-sizing: border-box;
    height: 56px;
    font-weight: 200;
}
.subbtn:hover,.subbtn[aria-current="true"],.subbtn.active{
    border-color:var(--line);
    border-left: 1px solid var(--line);
    border-right: none;
}
.subbtn .chev{font-size:12px;color:var(--muted)}

/* Tabpanels (right) */
.products{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:18px}
[role="tabpanel"][hidden]{display:none!important}
.card{
    display:flex;
    flex-direction:column;
    align-items:center;
    gap:10px;
    padding:14px;
    transition: all 0.3s ease-in-out;
    position: relative;
}
.card img{
    height:130px;
    object-fit:contain;
    transition: transform 0.3s ease;
}
.card span{font-size:20px;text-align:center;color:var(--muted)}
.card:hover span{
    color: #4E74FF!important;
}
.card:hover img {
    transform: scale(1.05);
}
/* Custom scrollbars inside mega */
.mega .left,.mega .right{scrollbar-width:thin;scrollbar-color:#0F367A #f1f5f9}
.mega .left::-webkit-scrollbar,.mega .right::-webkit-scrollbar{width:10px;height:10px}
.mega .left::-webkit-scrollbar-track,.mega .right::-webkit-scrollbar-track{background:#f1f5f9;border-radius:8px}
.mega .left::-webkit-scrollbar-thumb,.mega .right::-webkit-scrollbar-thumb{
    background:#0F367A;border-radius:8px;border:2px solid #f1f5f9
}

.header::before {
    opacity: 1 !important;
    transform: translateY(0) !important;
}

.header {
    background: #fff !important;
    border-bottom: 1px solid var(--line) !important;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.06) !important;
}

.nav > ul > li:hover > a.toplink::before,
.nav > ul > li.active > a.toplink::before {
    content: "";
    position: absolute;
    left: 12px;
    top: 4px;
    width: 28px;
    height: 2px;
    background: #0F367A;
    border-radius: 2px;
}

/* ========== Drawer (mobile) ========== */
.drawer{display:none}
@media (max-width:992px){
    .nav{display:none}
    .burger{display:block}

    /* полноэкранный drawer, выезжает слева, без оверлея */
    .drawer{
        display:block;
        position:fixed; left:0; right:auto; top:0; bottom:0;
        width:100vw; max-width:100vw;
        background:#fff; z-index:1100;
        transform:translateX(-100%);
        transition:transform .25s ease;
        box-shadow:-20px 0 30px rgba(0,0,0,.15);
        pointer-events:none;
    }
    .drawer.open{transform:none;pointer-events:auto}

    .drawer .head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        height: var(--header-h);
        border-bottom: 1px solid var(--line);
        width: calc(100% - 30px);
        margin: 0 auto;
    }
    .drawer .menu{
        height:calc(100dvh - var(--header-h));
        overflow:auto;
        padding:6px 15px 24px;
        -webkit-overflow-scrolling:touch;
    }

    /* убираем чёрный фон, если он создан скриптом */
    .drawer-overlay{display:none!important}

    /* верхний уровень (аккордеоны) */
    .acc{border-bottom:1px solid var(--line)}
    .acc > button{
        width:100%; min-height:48px;
        text-align:left; display:flex; align-items:center; justify-content:space-between; gap:8px;
        padding:14px 10px; background:transparent; border:0; font-size:18px;font-weight: 200;
    }
    .acc > button:focus-visible{outline:2px solid var(--brand)}
    .acc .chev{transition:transform .2s}
    .acc.open .chev{transform:rotate(180deg)}
    .acc .panel{padding:0} /* фактическую высоту задаёт slide-анимация в JS */

    /* второй уровень */
    .m-subnav{list-style:none;margin:0;padding:0}
    .m-subnav li {
        border-top: 1px solid var(--line);
        background: #F3F3F3;
    }
    .m-subnav summary {
        position: relative;
        list-style: none;
        cursor: default;
        min-height: 44px;
        display: flex;
        align-items: center;
        padding: 10px 12px;
        font-weight: 200;
        font-size: 16px;
        justify-content: space-between;
    }
    .m-subnav details[open] summary{
        font-weight: 400;
    }
    .m-subnav ul{list-style:none;margin:0;padding:0 12px 8px}
    .m-subnav ul li {
        border-bottom: 1px solid #fff;
        border-top: none;
        margin: 0 -12px;
        padding-left: 36px;
    }
    .m-subnav ul li:first-child{
        border-top: 1px solid var(--line);
    }
    .m-subnav ul li a{
        display:flex;
        align-items:center;
        min-height:40px;
        padding:8px 6px;
        font-size: 14px;
        font-weight: 200;
    }

    /* slide-анимация (управляется JS-классами) */
    .slide{overflow:hidden; height:0; transition:height .22s ease}
    .slide.open{height:auto}
}

/* ========== Desktop-only tweaks ========== */
@media (min-width:993px){
    /* на десктопе хедер всегда оверлеем; страницу не двигаем */
    body{padding-top:0!important; transition:none!important}
}

/* ========== Small polish ========== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0;
    border: none;
    font-size: 12px;
    background: none;
}
body.noscroll{overflow:hidden}

@media (max-width: 992px) {
    /* убираем системный маркер у <summary> */
    .m-subnav summary::-webkit-details-marker { display: none; }
    .m-subnav summary::marker { content: ""; }

    /* место под иконку справа */
    .m-subnav summary {
        position: relative;
    }
    .acc > button {
        position: relative;
        padding-right: 40px; /* место под иконку справа */
    }
    /* прячем текстовую стрелку ▾ */
    .acc > button .chev {
        display: none;
    }
    /* иконка-галочка */
    .acc > button::after {
        content: "";
        position: absolute;
        right: 12px;
        top: 50%;
        width: 18px;
        height: 18px;
        background: url("/img/ico-1.png") center/contain no-repeat; /* поправь путь при необходимости */
        transform: translateY(-50%) rotate(0deg);
        transition: transform .22s ease;
        opacity: .9;
    }
    /* поворот при раскрытии аккордеона */
    .acc.open > button::after {
        transform: translateY(-50%) rotate(180deg);
    }
    .acc-link{
        width: 100%;
        min-height: 48px;
        text-align: left;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        padding: 14px 10px;
        background: transparent;
        border: 0;
        font-size: 18px;
        font-weight: 200;
    }
    .acc-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .acc-link {
        font-size: 16px;
        text-decoration: none;
        color: inherit;
    }

    .acc-toggle {
        position: relative;
        width: 36px;
        height: 36px;
        padding: 0;
        background: none;
        border: none;
        cursor: pointer;
    }

    /* Иконка-галочка */
    .acc-toggle::after {
        content: "";
        position: absolute;
        right: 9px;
        top: 50%;
        width: 18px;
        height: 18px;
        background: url("/img/ico-1.png") center/contain no-repeat;
        transform: translateY(-50%) rotate(0deg);
        transition: transform .22s ease;
        opacity: .9;
    }

    /* Поворот при открытом состоянии */
    .acc.open .acc-toggle::after {
        transform: translateY(-50%) rotate(180deg);
    }

    .m-subnav .sub-link {
        flex: 1;
        text-decoration: none;
        color: inherit;
    }

    .m-subnav .sub-toggle {
        position: relative;
        width: 28px;
        height: 28px;
        background: none;
        border: none;
        padding: 0;
        cursor: pointer;
    }

    .m-subnav .sub-toggle::after {
        content: "";
        position: absolute;
        right: 0;
        top: 50%;
        width: 15px;
        height: 9px;
        background: url(/img/ico-3.png) center/contain no-repeat;
        transform: translateY(-50%) rotate(0deg);
        transition: transform .22s ease;
        opacity: .9;
    }

    /* Поворот стрелки при открытом блоке */
    .m-subnav details[open] .sub-toggle::after {
        transform: translateY(-50%) rotate(90deg);
    }
}
