/* TRex Internet — canonical mobile shell.
   Scope: max-width:700px only. Desktop is intentionally untouched. */

.mobile-brand-lockup{display:none!important}

@media(max-width:700px){
  html,body{overflow-x:hidden!important}
  body{
    padding:0!important;
    background:var(--bg)!important;
  }

  /* ---------- fixed mobile header ---------- */
  header{
    position:fixed!important;
    top:0!important;left:0!important;right:0!important;
    z-index:1000!important;
    height:calc(58px + env(safe-area-inset-top))!important;
    min-height:0!important;
    padding:env(safe-area-inset-top) 12px 0!important;
    box-sizing:border-box!important;
    display:flex!important;
    align-items:flex-end!important;
    gap:8px!important;
    background:rgba(13,17,18,.98)!important;
    border-bottom:1px solid var(--line)!important;
    box-shadow:0 8px 24px rgba(0,0,0,.12)!important;
    backdrop-filter:blur(18px)!important;
    -webkit-backdrop-filter:blur(18px)!important;
  }

  .mobile-menu,.header-mascot{display:none!important}

  .mobile-brand-lockup{
    display:flex!important;
    flex:1 1 auto!important;
    min-width:0!important;
    width:auto!important;
    height:58px!important;
    flex-direction:column!important;
    align-items:flex-start!important;
    justify-content:center!important;
    gap:3px!important;
    overflow:hidden!important;
  }
  .mobile-brand-main{
    display:flex!important;
    align-items:baseline!important;
    gap:5px!important;
    width:max-content!important;
    max-width:100%!important;
    font-size:20px!important;
    line-height:20px!important;
    font-weight:850!important;
    letter-spacing:-.7px!important;
    white-space:nowrap!important;
  }
  .mobile-brand-main i{
    font-style:normal!important;
    color:var(--green)!important;
  }
  .mobile-brand-main span{color:#f2f6f4!important}
  .mobile-brand-sub{
    width:100%!important;
    margin:0!important;
    text-align:center!important;
    color:var(--muted)!important;
    font-size:7.5px!important;
    line-height:8px!important;
    font-weight:800!important;
    letter-spacing:1px!important;
    white-space:nowrap!important;
  }

  .head-actions{
    flex:0 0 auto!important;
    margin:0!important;
    padding:0 0 8px!important;
    gap:6px!important;
    align-items:center!important;
  }
  .head-actions>button,
  .head-actions>.avatar{
    width:38px!important;
    min-width:38px!important;
    height:38px!important;
    min-height:38px!important;
    flex:0 0 38px!important;
    border-radius:12px!important;
    box-sizing:border-box!important;
  }
  .head-actions>.avatar{
    display:grid!important;
    place-items:center!important;
    overflow:hidden!important;
  }
  .head-actions>.avatar img{
    width:100%!important;height:100%!important;
    object-fit:cover!important;
  }
  .head-actions>.profile-menu{
    width:28px!important;
    min-width:28px!important;
    flex-basis:28px!important;
    border:0!important;
    background:transparent!important;
    color:var(--muted)!important;
    font-size:22px!important;
    padding:0!important;
  }

  /* ---------- page offset for fixed header/footer ---------- */
  .content{
    padding-top:calc(78px + env(safe-area-inset-top))!important;
    padding-bottom:calc(76px + env(safe-area-inset-bottom))!important;
    box-sizing:border-box!important;
  }

  /* ---------- profile dropdown: below arrow, never on top of header ---------- */
  .profile-menu-popup{
    position:fixed!important;
    top:calc(58px + env(safe-area-inset-top) + 6px)!important;
    right:12px!important;
    left:auto!important;
    width:112px!important;
    min-width:112px!important;
    max-width:112px!important;
    z-index:1001!important;
    padding:5px!important;
    border-radius:11px!important;
    background:var(--surface)!important;
    border:1px solid var(--line)!important;
    box-shadow:0 16px 36px rgba(0,0,0,.38)!important;
  }
  .profile-menu-popup button{
    width:100%!important;
    min-height:34px!important;
    padding:8px 10px!important;
    border:0!important;
    border-radius:7px!important;
    font-size:11px!important;
    line-height:1.1!important;
  }

  /* ---------- base mobile bottom navigation; final six-item geometry is locked below ---------- */
  #mobileBottomNav{
    position:fixed!important;
    left:0!important;right:0!important;bottom:0!important;
    z-index:1100!important;
    width:100%!important;
    height:calc(64px + env(safe-area-inset-bottom))!important;
    min-height:calc(64px + env(safe-area-inset-bottom))!important;
    max-height:calc(64px + env(safe-area-inset-bottom))!important;
    padding:0 2px env(safe-area-inset-bottom)!important;
    box-sizing:border-box!important;
    display:grid!important;
    grid-template-columns:repeat(6,minmax(0,1fr))!important;
    grid-template-rows:64px!important;
    align-items:stretch!important;
    overflow:hidden!important;
    background:#0d1112!important;
    border-top:1px solid var(--line)!important;
    box-shadow:0 -10px 28px rgba(0,0,0,.34)!important;
    backdrop-filter:none!important;
    -webkit-backdrop-filter:none!important;
  }

  #mobileBottomNav .mobile-bottom-nav-item{
    min-width:0!important;
    width:100%!important;height:64px!important;
    min-height:64px!important;
    margin:0!important;padding:0 1px!important;
    display:flex!important;
    flex-direction:column!important;
    align-items:center!important;
    justify-content:flex-end!important;
    gap:3px!important;
    border:0!important;
    border-radius:9px!important;
    background:transparent!important;
    color:var(--muted)!important;
    -webkit-tap-highlight-color:transparent!important;
    touch-action:manipulation!important;
  }
  #mobileBottomNav .mobile-bottom-nav-item.active{
    color:var(--green)!important;
    background:transparent!important;
  }
  #mobileBottomNav .mobile-bottom-nav-item:active{
    transform:none!important;
    background:rgba(53,231,154,.06)!important;
  }
  #mobileBottomNav .mobile-bottom-icon{
    width:22px!important;height:22px!important;
    min-width:22px!important;min-height:22px!important;
    flex:0 0 22px!important;
    display:grid!important;
    place-items:center!important;
    color:currentColor!important;
  }
  #mobileBottomNav .mobile-bottom-icon svg{
    display:block!important;
    width:21px!important;height:21px!important;
    fill:none!important;
    stroke:currentColor!important;
    stroke-width:1.7!important;
    stroke-linecap:round!important;
    stroke-linejoin:round!important;
    overflow:visible!important;
  }
  #mobileBottomNav .mobile-bottom-label{
    width:100%!important;
    max-width:100%!important;
    min-width:0!important;
    height:17px!important;
    max-height:17px!important;
    display:-webkit-box!important;
    -webkit-box-orient:vertical!important;
    -webkit-line-clamp:2!important;
    overflow:hidden!important;
    text-overflow:clip!important;
    white-space:normal!important;
    text-align:center!important;
    color:currentColor!important;
    font-size:7.2px!important;
    line-height:8px!important;
    font-weight:700!important;
    letter-spacing:-.08px!important;
    transform:none!important;
  }
  #mobileBottomNav .mobile-bottom-nav-item.active .mobile-bottom-label{
    font-weight:850!important;
  }

  /* The previous drawer is replaced by the bottom navigation on phones. */
  #sidebar,.mobile-nav-backdrop,#mobileNavBackdrop{pointer-events:none!important}
  #sidebar{visibility:hidden!important}
  #mobileNavBackdrop{display:none!important}
}

@media(max-width:370px){
  @media(max-width:700px){
    .mobile-brand-main{font-size:18px!important;letter-spacing:-.65px!important}
    .mobile-brand-sub{font-size:7px!important;letter-spacing:.75px!important}
    .head-actions>button,.head-actions>.avatar{width:36px!important;min-width:36px!important;height:36px!important;min-height:36px!important;flex-basis:36px!important}
    .head-actions>.profile-menu{width:24px!important;min-width:24px!important;flex-basis:24px!important}
    #mobileBottomNav .mobile-bottom-icon{width:21px!important;height:21px!important;flex-basis:21px!important}
    #mobileBottomNav .mobile-bottom-icon svg{width:20px!important;height:20px!important}
    #mobileBottomNav .mobile-bottom-label{font-size:6.7px!important;line-height:7.5px!important}
  }
}

/* 2026-09-21 MOBILE FINAL LANGUAGE/SPACE LOCK — canonical shell. */
@media(max-width:700px){
  /* Brand subtitle: slightly narrower than the logo, never clipped. */
  .mobile-brand-lockup{
    flex:0 0 auto!important;
    width:max-content!important;
    min-width:0!important;
    max-width:calc(100vw - 220px)!important;
    align-items:flex-start!important;
    overflow:visible!important;
  }
  .mobile-brand-main{
    width:max-content!important;
    max-width:none!important;
  }
  .mobile-brand-sub{
    width:max-content!important;
    min-width:0!important;
    max-width:none!important;
    align-self:center!important;
    box-sizing:border-box!important;
    padding:0!important;
    margin:0!important;
    text-align:center!important;
    font-size:7px!important;
    line-height:8px!important;
    font-weight:800!important;
    letter-spacing:0!important;
    white-space:nowrap!important;
    overflow:visible!important;
    transform:none!important;
  }

  /* Header controls: centered with the brand block and lifted as one header construction. */
  .mobile-brand-lockup{transform:translateY(0)!important;}
  .head-actions{
    flex:0 0 auto!important;
    margin-left:auto!important;
    margin-right:-6px!important;
    padding:0!important;
    gap:6px!important;
    justify-content:flex-end!important;
    align-items:center!important;
    transform:translateY(-7px)!important;
  }

  /* Six-item dock: larger labels/icons after removing the obsolete Events section. */
  #mobileBottomNav{
    height:calc(46px + env(safe-area-inset-bottom))!important;
    min-height:calc(46px + env(safe-area-inset-bottom))!important;
    max-height:calc(46px + env(safe-area-inset-bottom))!important;
    bottom:0!important;
    padding:0 2px env(safe-area-inset-bottom)!important;
    grid-template-columns:repeat(6,minmax(0,1fr))!important;
    grid-template-rows:46px!important;
    overflow:hidden!important;
  }
  #mobileBottomNav .mobile-bottom-nav-item{
    width:100%!important;
    min-width:0!important;
    height:46px!important;
    min-height:46px!important;
    padding:0 1px!important;
    margin:0!important;
    justify-content:flex-end!important;
    gap:0!important;
    overflow:visible!important;
  }
  #mobileBottomNav .mobile-bottom-icon{
    width:23px!important;height:23px!important;min-width:23px!important;min-height:23px!important;
    flex:0 0 23px!important;
  }
  #mobileBottomNav .mobile-bottom-icon svg{width:22px!important;height:22px!important;}
  #mobileBottomNav .mobile-bottom-label{
    width:100%!important;
    max-width:none!important;
    min-width:0!important;
    height:15px!important;
    max-height:15px!important;
    display:flex!important;
    align-items:flex-end!important;
    justify-content:center!important;
    overflow:visible!important;
    text-overflow:clip!important;
    white-space:nowrap!important;
    text-align:center!important;
    font-size:7.8px!important;
    line-height:8.2px!important;
    font-weight:700!important;
    letter-spacing:-.12px!important;
    transform:none!important;
  }
  #mobileBottomNav .mobile-bottom-nav-item.active .mobile-bottom-label{font-weight:850!important;}
}
@media(max-width:370px){
  @media(max-width:700px){
    .mobile-brand-sub{font-size:6.7px!important;letter-spacing:.7px!important;}
    #mobileBottomNav .mobile-bottom-label{font-size:7.4px!important;line-height:7.8px!important;letter-spacing:-.12px!important;}
  }
}

/* 2026-09-21 MOBILE CONTROL MICRO-POLISH: flip language/theme, light refresh, stable brand */
@media(max-width:700px){
  .mobile-brand-main span{color:#f2f6f4!important}
  .head-actions>button#lang,
  .head-actions>button#theme,
  .head-actions>button#pageRefresh{
    transform-style:preserve-3d!important;
    backface-visibility:hidden!important;
    -webkit-backface-visibility:hidden!important;
    perspective:600px!important;
  }
  .head-actions>button#lang.is-lang-flipping{animation:trexLangFlip .62s cubic-bezier(.22,.8,.22,1)!important;}
  .head-actions>button#theme.is-theme-flipping{animation:trexThemeFlip .62s cubic-bezier(.22,.8,.22,1)!important;}
  .head-actions>button#pageRefresh.is-refreshing{animation:trexRefreshDark .65s ease!important;}
  html[data-theme="light"] .head-actions>button#pageRefresh.is-refreshing{animation:trexRefreshLight .65s cubic-bezier(.22,.8,.22,1)!important;color:#19c984!important;border-color:rgba(25,201,132,.55)!important;background:rgba(25,201,132,.08)!important;box-shadow:0 0 0 0 rgba(25,201,132,0)!important;}
}
@keyframes trexLangFlip{0%{transform:rotateY(0)}45%{transform:rotateY(90deg)}100%{transform:rotateY(0)}}
@keyframes trexThemeFlip{0%{transform:rotateX(0)}45%{transform:rotateX(90deg)}100%{transform:rotateX(0)}}
@keyframes trexRefreshDark{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}
@keyframes trexRefreshLight{0%{transform:rotate(0);color:#687772;box-shadow:0 0 0 0 rgba(25,201,132,0)}35%{transform:rotate(125deg);color:#19c984;box-shadow:0 0 0 4px rgba(25,201,132,.10)}70%{transform:rotate(270deg);color:#19c984;box-shadow:0 0 0 2px rgba(25,201,132,.06)}100%{transform:rotate(360deg);color:#19c984;box-shadow:0 0 0 0 rgba(25,201,132,0)}}

/* 2026-09-21 MOBILE TRAFFIC + MODAL FINAL — dialogs stay inside the fixed header/footer safe zone. */
@media(max-width:700px){
  .traffic-server-breakdown{position:relative!important;padding-top:18px!important;}
  .traffic-server-breakdown::before{
    content:'ТЕЛЕМЕТРИЯ УЗЛОВ'!important;
    position:absolute!important;
    top:0!important;
    left:0!important;
    color:var(--muted)!important;
    font-size:8px!important;
    line-height:10px!important;
    font-weight:850!important;
    letter-spacing:1px!important;
  }
  .traffic-server-row:first-of-type .traffic-server-name small{font-size:0!important;}
  .traffic-server-row:first-of-type .traffic-server-name small::after{content:'Источник расчёта'!important;font-size:9px!important;}
  .traffic-server-row:nth-of-type(2) .traffic-server-name small{font-size:0!important;}
  .traffic-server-row:nth-of-type(2) .traffic-server-name small::after{content:'Сетевая телеметрия'!important;font-size:9px!important;}
}

/* 2026-09-21 MOBILE MODAL FINAL — keep dialogs inside the fixed header/footer safe zone. */
@media(max-width:700px){
  .modal-backdrop{
    position:fixed!important;
    top:calc(58px + env(safe-area-inset-top))!important;
    right:0!important;
    bottom:calc(46px + env(safe-area-inset-bottom))!important;
    left:0!important;
    z-index:1200!important;
    display:grid!important;
    place-items:center!important;
    align-items:center!important;
    justify-items:center!important;
    padding:10px 12px!important;
    box-sizing:border-box!important;
    overflow:hidden!important;
  }
  .modal-backdrop>.modal{
    position:relative!important;
    width:min(100%,700px)!important;
    max-width:700px!important;
    max-height:100%!important;
    min-height:0!important;
    margin:0 auto!important;
    padding:18px!important;
    box-sizing:border-box!important;
    overflow:auto!important;
    overscroll-behavior:contain!important;
    -webkit-overflow-scrolling:touch!important;
    border-radius:20px!important;
  }
  .modal-backdrop>.modal .modal-close{
    position:absolute!important;
    top:10px!important;
    right:10px!important;
    z-index:5!important;
    width:40px!important;
    height:40px!important;
    min-width:40px!important;
    min-height:40px!important;
    display:grid!important;
    place-items:center!important;
    border-radius:12px!important;
    background:var(--surface2)!important;
    color:var(--muted)!important;
    font-size:25px!important;
    line-height:1!important;
  }
  .client-modal{
    max-height:100%!important;
    padding:18px!important;
  }
  .client-modal-head{
    padding-right:48px!important;
    margin-top:4px!important;
    margin-bottom:12px!important;
  }
  .client-modal-head h2{font-size:22px!important;line-height:1.15!important;}
  .client-modal-head p{font-size:10px!important;}
  .detail-grid{gap:7px!important;}
  .detail-grid div{padding:10px!important;}
  .detail-grid b{font-size:11px!important;}
  .portal-link{margin-top:10px!important;padding:10px!important;}
  .endpoint-list{gap:7px!important;margin-top:10px!important;}
  .endpoint-item{padding:10px!important;gap:8px!important;}
  .endpoint-item>b,.endpoint-item small{font-size:9px!important;line-height:1.3!important;}
  .endpoint-buttons{grid-template-columns:1fr 1fr 1fr!important;gap:5px!important;}
  .endpoint-buttons button{min-width:0!important;padding:7px 5px!important;font-size:9px!important;}
  .client-modal-foot{margin-top:10px!important;}

  .qr-modal{
    width:min(100%,620px)!important;
    max-height:100%!important;
    padding:16px!important;
    text-align:center!important;
  }
  .qr-modal h2{font-size:20px!important;margin:7px 0 10px!important;}
  .qr-modal .eyebrow{font-size:8px!important;}
  .qr-modal .qr-wrap{
    width:min(245px,66vw)!important;
    max-width:245px!important;
    margin:10px auto 9px!important;
    padding:9px!important;
    border-radius:12px!important;
    box-sizing:border-box!important;
  }
  .qr-modal .qr-wrap img{width:100%!important;max-width:100%!important;height:auto!important;display:block!important;}
  .qr-modal p{font-size:9px!important;margin:7px 0 0!important;}

  .vless-modal{max-height:100%!important;}
}

