/* ═══════════════════════════════════════
   НОМИС — стили документных страниц
   (manual_obmen_moysklad, offer, policy)
═══════════════════════════════════════ */

body.doc {
  font-size: 15px;
  line-height: 1.75;
  background: var(--n900);
  max-width: 100%;
}
body.doc a { color: var(--bp); text-decoration: none; transition: color .15s; }
body.doc a:hover { color: var(--be); text-decoration: underline; }
body.doc img { display: block; }

/* ─── HEADER (sticky, светлый) ─── */
.site-header {
  position: sticky; top: 0; z-index: 200;
  height: var(--hdr-h);
  background: rgba(255,255,255,.97);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 40px; gap: 16px;
  box-shadow: 0 2px 20px rgba(29,78,216,.07);
}
.hdr-brand {
  display: flex; align-items: center;
  text-decoration: none; flex-shrink: 0;
}
.hdr-brand img { height: 38px; display: block; }
.hdr-brand:hover { text-decoration: none; opacity: .9; }
.hdr-sep { color: var(--g6); font-size: 18px; font-weight: 300; }
.hdr-page {
  font-size: 13px; font-weight: 600;
  color: var(--g4); letter-spacing: .04em;
}
.hdr-spacer { flex: 1; }
.hdr-badge {
  font-size: 11px; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--bn);
  background: rgba(249,115,22,.10);
  border: 1px solid rgba(249,115,22,.25);
  padding: 4px 12px; border-radius: 20px;
}
.hdr-contact { font-size: 13px; color: var(--g4); font-weight: 600; }
.hdr-contact:hover { color: var(--be); text-decoration: none; }

/* ─── LAYOUT ─── */
.layout {
  display: flex;
  min-height: calc(100vh - var(--hdr-h));
  max-width: 1440px;
  margin: 0 auto;
}

/* ─── SIDEBAR ─── */
.sidebar {
  width: var(--nav-w); flex-shrink: 0;
  background: var(--n950);
  border-right: 1px solid var(--border);
  position: sticky; top: var(--hdr-h);
  height: calc(100vh - var(--hdr-h));
  overflow-y: auto;
  padding: 28px 0 48px;
}
.sidebar::-webkit-scrollbar { width: 3px; }
.sidebar-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; font-weight: 700;
  letter-spacing: .18em; text-transform: uppercase;
  color: var(--be);
  padding: 0 20px 14px;
  display: flex; align-items: center; gap: 10px;
}
.sidebar-label::after {
  content: ''; flex: 1; height: 1px;
  background: rgba(26,111,255,.2);
}
.sidebar ul { list-style: none; }
.sidebar ul li a {
  display: block;
  padding: 5px 20px;
  font-size: 13px; color: var(--g4);
  border-left: 3px solid transparent;
  transition: all .15s; line-height: 1.45;
}
.sidebar ul li a:hover {
  color: var(--bp);
  background: var(--n900);
  border-left-color: var(--n700);
  text-decoration: none;
}
.sidebar ul li a.active {
  color: var(--bp); font-weight: 700;
  background: var(--n800);
  border-left-color: var(--bn);
}
.nav-h1 > a {
  font-size: 14px; font-weight: 700;
  color: var(--bp);
  padding-top: 8px; padding-bottom: 8px;
}
.nav-h2 > a { padding-left: 28px; }
.nav-group {
  font-size: 10px; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--g5);
  padding: 16px 20px 4px 31px;
  margin-top: 4px;
}
.nav-h3 > a {
  padding-left: 40px;
  font-size: 12px;
  color: var(--g6);
}
.nav-new > a { color: var(--bn) !important; font-weight: 700; }

/* ─── MAIN ─── */
.main {
  flex: 1; min-width: 0;
  padding: 48px 56px 96px;
}

/* ─── TYPOGRAPHY ─── */
.main h1 {
  font-family: 'Inter', sans-serif;
  font-size: 36px; font-weight: 700;
  letter-spacing: -.02em; line-height: 1.15;
  color: var(--text);
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 3px solid var(--bp);
  position: relative;
}
.main h1::after {
  content: ''; position: absolute;
  bottom: -3px; left: 0;
  width: 56px; height: 3px;
  background: var(--bn);
}
.main h2 {
  font-family: 'Inter', sans-serif;
  font-size: 24px; font-weight: 700;
  letter-spacing: -.01em;
  color: var(--bp);
  margin: 52px 0 18px;
  display: flex; align-items: center; gap: 12px;
  scroll-margin-top: calc(var(--hdr-h) + 24px);
}
.h2-accent {
  display: inline-block;
  width: 4px; height: 28px;
  background: linear-gradient(180deg, var(--bn) 0%, var(--be) 100%);
  border-radius: 2px;
  flex-shrink: 0;
}
.main h3 {
  font-family: 'Inter', sans-serif;
  font-size: 17px; font-weight: 700;
  color: var(--bi);
  margin: 36px 0 14px;
  padding-left: 14px;
  border-left: 3px solid var(--bn);
}
.main p {
  margin-bottom: 14px;
  max-width: 820px;
  color: var(--text);
}
.main ul {
  max-width: 820px;
  margin: 0 0 16px;
  padding-left: 0;
  list-style: none;
}
.main ul li {
  padding: 4px 0 4px 22px;
  position: relative;
  color: var(--text);
}
.main ul li::before {
  content: ''; position: absolute;
  left: 0; top: 13px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--bn);
}
.main ol {
  max-width: 820px;
  margin: 0 0 16px;
  padding-left: 0;
  list-style: none;
  counter-reset: item;
}
.main ol li {
  padding: 5px 0 5px 28px;
  position: relative;
  counter-increment: item;
}
.main ol li::before {
  content: counter(item) ".";
  position: absolute; left: 0; top: 7px;
  color: var(--bn); font-weight: 700; font-size: 13px;
}

/* ─── INLINE CODE ─── */
.main code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  background: var(--n800);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 7px;
  color: var(--bi);
  word-break: break-all;
}

/* ─── CALLOUT ─── */
.callout {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 16px 20px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  max-width: 820px;
}
.callout-warn {
  background: rgba(249,115,22,.07);
  border: 1px solid rgba(249,115,22,.25);
  border-left: 4px solid var(--bn);
}
.callout-info {
  background: rgba(29,78,216,.05);
  border: 1px solid rgba(29,78,216,.15);
  border-left: 4px solid var(--bp);
}
.callout-success {
  background: rgba(22,163,74,.05);
  border: 1px solid rgba(22,163,74,.2);
  border-left: 4px solid #16A34A;
}
.callout-icon { font-size: 18px; flex-shrink: 0; line-height: 1.5; }

/* ─── EXTERNAL LINK CARD ─── */
.ext-link {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 10px 16px; margin: 6px 0;
  background: var(--n900);
  border: 1px solid var(--border);
  border-left: 3px solid var(--bp);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  text-decoration: none;
  color: var(--bp);
  font-size: 13px; font-weight: 600;
  max-width: 820px;
  transition: background .15s, border-color .15s;
}
.ext-link:hover {
  background: var(--n800);
  border-left-color: var(--bn);
  color: var(--bn);
  text-decoration: none;
}
.ext-link-icon { flex-shrink: 0; width: 14px; height: 14px; opacity: .6; }
.ext-link-domain {
  font-size: 11px; font-weight: 400;
  color: var(--g6); margin-left: 4px;
}

/* ─── IMAGES & VIDEO BLOCKS ─── */
.img-block {
  margin: 24px auto;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  display: block;
  max-width: 100%;
  background: var(--n950);
}
.img-block img { display: block; max-width: 860px; width: 100%; }

.video-wrap {
  position: relative;
  width: 100%; max-width: 860px;
  aspect-ratio: 16/9;
  margin: 28px 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  background: var(--text);
}
.video-wrap iframe {
  position: absolute; inset: 0;
  width: 100%; height: 100%; border: none;
}

/* ─── PAGE META (юр. документы) ─── */
.page-meta {
  display: flex; align-items: center; gap: 16px;
  margin-bottom: 36px; flex-wrap: wrap;
}
.meta-tag {
  font-size: 12px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  padding: 4px 12px; border-radius: 20px;
}
.meta-tag-law {
  color: var(--bp);
  background: rgba(29,78,216,.08);
  border: 1px solid rgba(29,78,216,.2);
}
.meta-tag-adv {
  color: #16A34A;
  background: rgba(22,163,74,.08);
  border: 1px solid rgba(22,163,74,.2);
}
.meta-date { font-size: 13px; color: var(--g6); font-weight: 500; }

/* ─── BACK TO TOP ─── */
.back-top {
  display: inline-flex; align-items: center; gap: 8px;
  margin-top: 56px;
  padding: 10px 24px;
  background: var(--bp); color: #fff;
  font-family: 'Lato', sans-serif;
  font-size: 13px; font-weight: 700; letter-spacing: .04em;
  border-radius: 10px;
  border: none; cursor: pointer;
  text-decoration: none;
  box-shadow: 0 0 20px rgba(29,78,216,.2);
  transition: background .2s, box-shadow .2s;
}
.back-top:hover {
  background: var(--be);
  box-shadow: 0 0 28px rgba(79,122,228,.35);
  color: #fff; text-decoration: none;
}

/* ─── SITE FOOTER (светлый — для doc-страниц) ─── */
.site-footer {
  background: #0A1A35;
  color: rgba(255,255,255,.55);
  padding: 40px 56px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 24px; flex-wrap: wrap;
  font-size: 13px;
}
.site-footer .footer-brand {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.site-footer .footer-brand img { width: 52px; height: 52px; }
.site-footer .footer-nomis {
  font-size: 13px;
  letter-spacing: .18em;
  color: rgba(255,255,255,.55);
}
.site-footer .footer-nomis span {
  text-decoration-line: underline;
  text-decoration-color: #F97316;
  text-underline-offset: 3px;
}
.site-footer .footer-links { display: flex; gap: 20px; flex-wrap: wrap; }
.site-footer .footer-links a {
  color: rgba(255,255,255,.45);
  font-size: 13px;
  transition: color .15s;
  text-decoration: none;
}
.site-footer .footer-links a:hover {
  color: rgba(255,255,255,.85);
  text-decoration: none;
}
.site-footer .footer-copy {
  font-size: 12px; color: rgba(255,255,255,.35);
}

/* ─── AUTO-TOC (генерируется js/auto-toc.js на [data-auto-toc]) ─── */
.auto-toc {
  background: rgba(29, 78, 216, .04);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 22px;
  margin: 0 0 32px;
}
.auto-toc-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--g6);
  margin-bottom: 10px;
}
.auto-toc ul {
  list-style: none;
  padding: 0;
  margin: 0;
  columns: 2;
  column-gap: 28px;
}
.auto-toc li {
  break-inside: avoid;
  padding: 4px 0;
}
.auto-toc a {
  font-size: 14px;
  color: var(--g4);
  text-decoration: none;
  transition: color .12s;
}
.auto-toc a:hover { color: var(--bp); text-decoration: underline; }
.auto-toc a.active { color: var(--bp); font-weight: 600; }

/* Плавный скролл к якорю + отступ от sticky-хедера. */
html { scroll-behavior: smooth; }
body.doc h2[id] { scroll-margin-top: calc(var(--hdr-h, 64px) + 16px); }

/* ─── SIDEBAR MOBILE LINKS (только в drawer) ─── */
.sidebar-mobile-links { display: none; }

/* ─── SIDEBAR OVERLAY ─── */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 299;
  cursor: pointer;
}
.sidebar-overlay.open { display: block; }

/* ─── SCROLL TO BOTTOM ─── */
#scroll-bottom-btn {
  display: none;
  position: fixed;
  bottom: 80px;
  right: 18px;
  width: 46px; height: 46px;
  border-radius: 50%;
  background: var(--g4);
  color: #fff;
  border: none;
  cursor: pointer;
  z-index: 150;
  box-shadow: 0 4px 18px rgba(0,0,0,.2);
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity .3s, transform .3s;
}
#scroll-bottom-btn.visible {
  opacity: 1;
  transform: translateY(0);
}
#scroll-bottom-btn svg { width: 20px; height: 20px; fill: #fff; }
@media (max-width: 900px) {
  #scroll-bottom-btn { display: flex; }
}

/* ─── BURGER + MOBILE NAV ─── */
.hdr-burger {
  display: none;
  width: 36px; height: 36px;
  background: none; border: none; cursor: pointer;
  color: var(--g4); padding: 4px;
  border-radius: 8px; flex-shrink: 0;
  align-items: center; justify-content: center;
  transition: background .15s;
}
.hdr-burger svg { width: 22px; height: 22px; display: block; }
.hdr-burger:hover { background: var(--n800); }

.mobile-nav {
  display: none;
  position: fixed;
  top: var(--hdr-h); left: 0; right: 0;
  background: #fff;
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  z-index: 310;
  flex-direction: column;
}
.mobile-nav.open { display: flex; }
.mobile-nav a {
  padding: 14px 20px;
  font-size: 14px; font-weight: 600;
  color: var(--text); text-decoration: none;
  border-bottom: 1px solid var(--border);
  transition: background .12s, color .12s;
}
.mobile-nav a:last-child { border-bottom: none; }
.mobile-nav a:hover { background: var(--n900); color: var(--bp); text-decoration: none; }

/* ─── RESPONSIVE ─── */
@media (max-width: 960px) {
  .hdr-burger { display: flex; }
  .sidebar {
    display: block !important;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    width: 290px;
    z-index: 300;
    transform: translateX(-100%);
    transition: transform .3s ease;
    overflow-y: auto;
    padding-top: calc(var(--hdr-h) + 8px);
    box-shadow: 4px 0 32px rgba(0,0,0,.18);
    border-right: none;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-mobile-links {
    display: flex; flex-direction: column;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px; padding-bottom: 4px;
  }
  .sidebar-mobile-links a {
    display: block; padding: 10px 20px;
    font-size: 14px; font-weight: 600;
    color: var(--g4); text-decoration: none;
    transition: color .15s, background .15s;
  }
  .sidebar-mobile-links a:hover { color: var(--bp); background: var(--n900); }
  .main {
    padding: 28px 20px 60px;
    overflow-x: hidden;
    overflow-wrap: break-word;
    word-break: break-word;
  }
  .site-header { padding: 0 16px; gap: 10px; }
  .site-footer { padding: 32px 16px; flex-direction: column; align-items: flex-start; overflow-x: hidden; }
  .site-footer .footer-links { flex-wrap: wrap; gap: 12px; }
  .auto-toc ul { columns: 1; }
  /* Заголовки */
  .main h1 { font-size: 28px; }
  .main h2 { font-size: 20px; }
  /* Текстовые блоки */
  .main p, .main ul, .main ol, .callout { max-width: 100%; }
  /* Картинки */
  .img-block { max-width: 100% !important; }
  .img-block img { width: 100%; }
  /* Видео */
  .video-wrap { max-width: 100%; }
  .video-wrap iframe { width: 100%; }
  /* Таблицы */
  .main table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100% !important;
  }
  /* Внешние ссылки — главный виновник переполнения */
  .ext-link {
    display: flex;
    max-width: 100%;
    white-space: normal;
    word-break: break-word;
  }
}
@media (max-width: 540px) {
  .hdr-sep { display: none; }
  .hdr-page { display: none; }
  .hdr-contact { display: none; }
  .hdr-badge { font-size: 10px; padding: 3px 8px; flex-shrink: 0; }
  .site-header { gap: 8px; padding: 0 12px; }
  .hdr-burger { display: flex; }
  .main h1 { font-size: 22px; }
  .main h2 { font-size: 18px; }
  .main h3 { font-size: 15px; }
}

/* ─── FOCUS VISIBLE ─── */
:focus-visible {
  outline: 2px solid var(--bp);
  outline-offset: 2px;
}
button:focus-visible, .back-top:focus-visible {
  outline: 2px solid var(--bn);
  outline-offset: 2px;
}

/* ─── SCROLL TO TOP ─── */
#scroll-top-btn {
  display: flex;
  position: fixed;
  bottom: 24px;
  right: 18px;
  width: 46px; height: 46px;
  border-radius: 50%;
  background: var(--bp);
  color: #fff;
  border: none;
  cursor: pointer;
  z-index: 150;
  box-shadow: 0 4px 18px rgba(29,78,216,.4);
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity .3s, transform .3s;
  pointer-events: none;
}
#scroll-top-btn.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
#scroll-top-btn svg { width: 20px; height: 20px; fill: #fff; }
