/* Mobile optimization layer. Loaded after page styles. */
html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body.mobile-menu-open {
  overflow: hidden;
}

section,
main {
  scroll-margin-top: 72px;
}

button,
a,
input,
textarea,
select {
  -webkit-tap-highlight-color: transparent;
}

input,
textarea,
select,
button {
  max-width: 100%;
}

.mobile-menu-toggle,
.mobile-nav {
  display: none;
}

/* External widgets must never expand the page horizontally. */
.polis-widget-wrap,
.polis-widget-slot,
polis-online-widget-osago,
polis-online-widget-mortgage,
polis-online-widget-ifl {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

polis-online-widget-mortgage,
polis-online-widget-ifl {
  display: block;
}

@media (max-width: 880px) {
  .header-inner {
    width: 100%;
    height: 60px !important;
    padding: 0 14px !important;
    gap: 7px !important;
  }

  .logo {
    min-width: 0;
    flex: 0 0 auto;
  }

  .logo img {
    height: 30px !important;
    width: auto;
  }

  .logo-text,
  .header-phone,
  .header > .header-inner > .btn-primary,
  .header > .header-inner > a.btn-primary,
  .nav {
    display: none !important;
  }

  .header-socials {
    display: flex !important;
    margin-left: auto !important;
    gap: 5px !important;
  }

  .header-social-link {
    width: 30px !important;
    height: 30px !important;
    border-radius: 8px !important;
  }

  .header-social-link img {
    width: 18px !important;
    height: 18px !important;
  }

  .mobile-menu-toggle {
    position: relative;
    z-index: 103;
    display: inline-flex;
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 4px;
    padding: 0;
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 9px;
    background: rgba(255,255,255,.07);
    cursor: pointer;
  }

  .mobile-menu-toggle span {
    width: 18px;
    height: 2px;
    border-radius: 2px;
    background: #fff;
    transition: transform .22s ease, opacity .22s ease;
  }

  .mobile-menu-toggle[aria-expanded="true"] span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
  }

  .mobile-menu-toggle[aria-expanded="true"] span:nth-child(2) {
    opacity: 0;
  }

  .mobile-menu-toggle[aria-expanded="true"] span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
  }

  .mobile-nav {
    position: fixed;
    inset: 60px 0 0;
    z-index: 101;
    display: block;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    background: rgba(5,8,13,.72);
    backdrop-filter: blur(8px);
    transition: opacity .22s ease, visibility .22s ease;
  }

  .mobile-nav.open {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
  }

  .mobile-nav__panel {
    width: min(100%, 430px);
    max-height: calc(100dvh - 60px);
    margin-left: auto;
    padding: 18px 16px calc(24px + env(safe-area-inset-bottom));
    overflow-y: auto;
    background: #0c1018;
    border-top: 1px solid rgba(255,255,255,.08);
    box-shadow: 0 22px 50px rgba(0,0,0,.45);
    transform: translateY(-12px);
    transition: transform .22s ease;
  }

  .mobile-nav.open .mobile-nav__panel {
    transform: translateY(0);
  }

  .mobile-nav__links {
    display: grid;
    gap: 6px;
  }

  .mobile-nav__links a {
    display: flex;
    min-height: 46px;
    align-items: center;
    padding: 11px 14px;
    border: 1px solid rgba(255,255,255,.07);
    border-radius: 10px;
    color: rgba(255,255,255,.78);
    font-size: 15px;
    font-weight: 600;
  }

  .mobile-nav__links a.active {
    color: #fff;
    border-color: rgba(227,30,36,.42);
    background: rgba(227,30,36,.16);
  }

  .mobile-nav__contacts {
    display: grid;
    grid-template-columns: repeat(3, minmax(0,1fr));
    gap: 8px;
    margin-top: 16px;
  }

  .mobile-nav__contacts a {
    display: flex;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    padding: 9px 8px;
    border-radius: 9px;
    background: rgba(255,255,255,.07);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
  }

  .mobile-nav__contacts .mobile-nav__phone {
    grid-column: 1 / -1;
    background: var(--red);
    font-size: 15px;
  }
}

@media (max-width: 768px) {
  body {
    font-size: 15px;
  }

  section,
  main {
    scroll-margin-top: 60px;
  }

  .section-inner,
  .footer-inner {
    width: 100%;
    padding-left: 16px !important;
    padding-right: 16px !important;
  }

  .section-tag {
    margin-bottom: 12px;
    font-size: 10px;
    letter-spacing: 1.2px;
  }

  .section-title {
    margin-bottom: 12px !important;
    font-size: clamp(24px, 7.5vw, 32px) !important;
    line-height: 1.16 !important;
    letter-spacing: -.45px !important;
    overflow-wrap: anywhere;
  }

  .section-sub {
    max-width: 100% !important;
    font-size: 15px !important;
    line-height: 1.65 !important;
  }

  .section-header {
    margin-bottom: 30px !important;
  }

  [style*="padding:80px 0"] {
    padding-top: 46px !important;
    padding-bottom: 46px !important;
  }

  [style*="padding:64px 0"] {
    padding-top: 44px !important;
    padding-bottom: 44px !important;
  }

  .btn-primary,
  .btn-outline,
  .messenger-btn {
    min-height: 48px;
    justify-content: center;
    text-align: center;
  }

  /* Home hero */
  .hero {
    min-height: auto !important;
  }

  .hero-inner {
    display: block !important;
    padding: 92px 16px 42px !important;
  }

  .hero-content {
    max-width: 100% !important;
  }

  .hero-right,
  .hero-geo,
  .hero-geo2 {
    display: none !important;
  }

  .hero-badge {
    margin-bottom: 16px !important;
    font-size: 11px !important;
    padding: 6px 11px !important;
  }

  .hero .hero-title {
    max-width: 100%;
    margin-bottom: 18px !important;
    font-size: clamp(34px, 10.5vw, 46px) !important;
    line-height: 1.07 !important;
    letter-spacing: -1.2px !important;
  }

  .hero .hero-title br {
    display: none;
  }

  .hero .hero-title span {
    display: block;
    margin-top: 8px;
  }

  .hero .hero-sub {
    max-width: 100% !important;
    margin-bottom: 26px !important;
    font-size: 15px !important;
    line-height: 1.62 !important;
  }

  .hero-btns {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 10px !important;
    margin-bottom: 28px !important;
  }

  .hero-btns > * {
    width: 100% !important;
    min-height: 50px !important;
    justify-content: center !important;
  }

  .hero-stats {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 0 !important;
  }

  .hero-stat {
    display: grid !important;
    grid-template-columns: minmax(118px, auto) 1fr;
    gap: 14px;
    align-items: baseline;
    padding: 12px 0;
    border-top: 1px solid rgba(255,255,255,.09);
  }

  .hero-stat-num {
    font-size: 19px !important;
    line-height: 1.2 !important;
    white-space: nowrap;
  }

  .hero-stat-label {
    margin-top: 0 !important;
    font-size: 12px !important;
    line-height: 1.45 !important;
  }

  /* Service heroes */
  .page-hero {
    min-height: auto !important;
  }

  .page-hero .section-inner {
    padding-top: 88px !important;
    padding-bottom: 40px !important;
  }

  .breadcrumb {
    margin-bottom: 18px !important;
    font-size: 12px !important;
  }

  .service-hero-layout {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 28px !important;
  }

  .page-hero .hero-title {
    margin-bottom: 16px !important;
    font-size: clamp(29px, 8.7vw, 38px) !important;
    line-height: 1.12 !important;
    letter-spacing: -.8px !important;
  }

  .page-hero .hero-title br {
    display: none;
  }

  .page-hero .hero-title span {
    display: block;
    margin-top: 5px;
  }

  .page-hero .hero-sub {
    margin-bottom: 24px !important;
    font-size: 15px !important;
    line-height: 1.62 !important;
  }

  .service-hero-facts {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0,1fr)) !important;
    gap: 10px !important;
  }

  .hero-info-card {
    min-width: 0;
    padding: 14px !important;
  }

  .hero-info-num {
    font-size: 18px !important;
    line-height: 1.25 !important;
    overflow-wrap: anywhere;
  }

  .hero-info-label {
    font-size: 11px !important;
    line-height: 1.45 !important;
  }

  /* Main grids and cards */
  .about-grid,
  .services-grid,
  .why-grid,
  .team-grid,
  .contacts-grid,
  .form-grid,
  .footer-grid,
  .directions-grid,
  .offers-grid,
  .who-grid,
  .stages,
  .process-steps,
  .what-grid,
  .steps-grid {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }

  .about-facts,
  .partners-grid,
  .banks-grid,
  .risks-grid,
  .for-whom {
    grid-template-columns: repeat(2, minmax(0,1fr)) !important;
    gap: 12px !important;
  }

  .about-fact,
  .service-card,
  .team-card,
  .offer-card,
  .dir-card,
  .who-card,
  .stage-card,
  .what-card,
  .whom-item,
  .risk-item {
    min-width: 0;
  }

  .service-card,
  .offer-card,
  .dir-card,
  .who-card,
  .what-card {
    padding: 22px 20px !important;
  }

  .about-fact {
    padding: 16px !important;
  }

  .about-fact-num {
    font-size: 24px !important;
    overflow-wrap: anywhere;
  }

  .about-visual {
    min-height: 240px !important;
    aspect-ratio: 4 / 3 !important;
  }

  .team-photo {
    height: 190px !important;
  }

  .partners-grid .partner-item,
  .bank-item {
    min-height: 72px;
    padding: 14px 10px !important;
  }

  .why-item {
    padding: 24px 20px !important;
  }

  .steps-grid::before {
    display: none !important;
  }

  .step-item {
    display: grid;
    grid-template-columns: 50px 1fr;
    column-gap: 14px;
    padding: 0 !important;
    text-align: left !important;
  }

  .step-num {
    grid-row: 1 / span 2;
    width: 50px !important;
    height: 50px !important;
    margin: 0 !important;
    font-size: 17px !important;
  }

  .stage-card,
  .process-step {
    padding: 22px 18px !important;
  }

  .kbm-check-form,
  .wrong-kbm {
    padding: 24px 18px !important;
  }

  .kbm-scale {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0,1fr));
    border-radius: 10px !important;
  }

  .kbm-step {
    min-width: 0;
    padding: 14px 7px !important;
  }

  .kbm-step-num {
    font-size: 17px !important;
  }

  .kbm-step-label {
    font-size: 9px !important;
  }

  /* Forms */
  .form-grid,
  [style*="grid-template-columns:1fr 1fr"][style*="margin-bottom:16px"],
  [style*="grid-template-columns:1fr 1fr"][style*="margin-bottom:20px"] {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  .input-light,
  .input-dark,
  .form-field input,
  .form-field textarea {
    min-height: 48px;
    font-size: 16px !important;
  }

  textarea.input-light,
  textarea.input-dark,
  .form-field textarea {
    min-height: 110px;
  }

  /* FAQ */
  .faq-q,
  .home-faq .faq-q {
    min-height: 58px;
    padding: 17px 0 !important;
    font-size: 15px !important;
    line-height: 1.45;
  }

  .faq-a,
  .home-faq .faq-a {
    font-size: 14px !important;
    line-height: 1.7 !important;
  }

  /* Contact and map */
  .contact-info-card,
  .contact-map-card {
    padding: 20px 16px !important;
    border-radius: 16px !important;
  }

  .contact-item {
    gap: 12px !important;
    margin-bottom: 18px !important;
  }

  .contact-icon {
    width: 44px !important;
    height: 44px !important;
  }

  .contact-val,
  .contact-val a {
    max-width: 100%;
    font-size: 14px !important;
    overflow-wrap: anywhere;
  }

  .messengers {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }

  .yandex-map-frame,
  .yandex-map-frame iframe {
    min-height: 300px !important;
    height: 300px !important;
    border-radius: 14px !important;
  }

  /* Widgets */
  .osago-widget-section,
  .product-widget-section {
    padding-top: 38px !important;
    padding-bottom: 40px !important;
  }

  .polis-widget-wrap,
  .polis-widget-slot {
    width: 100%;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: visible !important;
  }

  polis-online-widget-osago,
  polis-online-widget-mortgage,
  polis-online-widget-ifl {
    display: block !important;
    width: 100% !important;
    min-height: 0 !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }

  .polis-widget-fallback .pw-btns {
    display: grid !important;
    grid-template-columns: 1fr !important;
  }

  /* Contact strip and footer */
  .site-contact-strip {
    padding: 42px 0 !important;
  }

  .site-contact-strip__grid,
  .site-contact-strip__links,
  .service-footer-grid {
    grid-template-columns: 1fr !important;
    gap: 18px !important;
  }

  .site-contact-link {
    padding: 14px 15px !important;
  }

  .service-footer-links {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 10px 16px !important;
    justify-content: stretch !important;
  }

  .footer-bottom {
    align-items: flex-start !important;
    flex-direction: column !important;
    gap: 10px !important;
  }

  .sticky-phone {
    right: 16px !important;
    bottom: calc(16px + env(safe-area-inset-bottom)) !important;
    width: 52px !important;
    height: 52px !important;
  }

  .review-card {
    padding: 24px 20px !important;
  }
}

@media (max-width: 430px) {
  .header-socials .location-link {
    display: none !important;
  }

  .section-inner,
  .footer-inner {
    padding-left: 14px !important;
    padding-right: 14px !important;
  }

  .hero-inner {
    padding-left: 14px !important;
    padding-right: 14px !important;
  }

  .hero .hero-title {
    font-size: clamp(31px, 10vw, 40px) !important;
  }

  .page-hero .hero-title {
    font-size: 29px !important;
  }

  .service-hero-facts,
  .about-facts,
  .partners-grid,
  .banks-grid,
  .risks-grid,
  .for-whom {
    grid-template-columns: 1fr !important;
  }

  .service-footer-links {
    grid-template-columns: 1fr !important;
  }

  .mobile-nav__contacts {
    grid-template-columns: 1fr !important;
  }

  .mobile-nav__contacts .mobile-nav__phone {
    grid-column: auto;
  }

  .policy-card {
    padding: 22px 16px !important;
    border-radius: 10px !important;
  }

  .policy-card h1 {
    font-size: 27px !important;
    overflow-wrap: anywhere;
  }
}

/* External calculators use their own natural height. */
.polis-widget-wrap,
.polis-widget-slot {
  width: 100% !important;
  min-width: 0 !important;
  min-height: 0 !important;
  height: auto !important;
  max-height: none !important;
  overflow: visible !important;
}

.polis-widget-slot > *,
polis-online-widget-osago,
polis-online-widget-mortgage,
polis-online-widget-ifl {
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  min-height: 0 !important;
  height: auto !important;
  max-height: none !important;
}

.polis-widget-slot iframe {
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  min-height: 0 !important;
  border: 0 !important;
}
