:root{
  --bg:#ffffff;
  --text:#0f172a;
  --muted:#475569;
  --card:#ffffff;
  --border:#e2e8f0;
  --accent:#ff1f2d;
  --accent2:#b10010;
  --shadow: 0 14px 40px rgba(2,6,23,.10);
  --radius: 18px;
  --max: 1120px;
}

*{box-sizing:border-box}
html,body{margin:0;padding:0}


/* ===== Fix horizontal overflow on mobile ===== */
html, body{overflow-x:hidden;}
/* Grid children can overflow if min-width:auto; force shrink */
.hero-content, .article, .aside, .layout{min-width:0;}
/* Wrap long words/URLs so text never выходит за границы */
.article, .hero-content{
  overflow-wrap:anywhere;
  word-break: break-word;
}
.article p, .article li, .article h2, .article h3, .article h4,
.hero-content h1, .hero-content p,
.data-table th, .data-table td{
  overflow-wrap:anywhere;
  word-break: break-word;
}

body{
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height:1.65;
  text-rendering: optimizeLegibility;
}
a{color:inherit; text-decoration:none}
.container{max-width:var(--max); margin:0 auto; padding:16px}

.header{
  position:sticky; top:0; z-index:60;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-inner{
  max-width:var(--max); margin:0 auto;
  display:flex; align-items:center; justify-content:space-between; gap:10px;
  padding:10px 16px;
  position:relative;
}
.brand{display:flex; align-items:center; gap:10px; font-weight:900; letter-spacing:.3px}
.brand img{height:34px; border-radius:10px}
.brand span{font-size:16px}

.nav{display:flex; align-items:center; gap:8px; flex-wrap:wrap}
.nav a{
  padding:10px 12px;
  border:1px solid transparent;
  border-radius:999px;
  color: var(--muted);
  font-weight:800;
  white-space:nowrap;
}
.nav a:hover{border-color:var(--border); color: var(--text); background:#f8fafc}
.nav a.active{color: var(--accent2); border-color: rgba(255,31,45,.28); background: rgba(255,31,45,.06)}

.menu-btn{
  display:none;
  align-items:center; justify-content:center;
  width:42px; height:42px;
  border-radius:12px;
  border:1px solid var(--border);
  background:#fff;
  cursor:pointer;
}
.menu-btn svg{width:22px; height:22px}

.hero{
  margin-top:14px;
  border:1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow);
  overflow:hidden;
  background:#fff;
  display:grid;
  grid-template-columns: 1.25fr 0.75fr;
}
.hero-media{min-height: 300px; background:#fff}
.hero-media img{width:100%; height:100%; object-fit:cover; display:block}
.hero-content{
  padding:20px;
  display:flex;
  flex-direction:column;
  justify-content:center;
  gap:12px;
}
.hero-content h1{margin:0; font-size:32px; line-height:1.15}
.hero-content p{margin:0; color: var(--muted)}
.hero-actions{display:flex; gap:10px; flex-wrap:wrap; margin-top:6px}
.btn{
  display:inline-flex; align-items:center; justify-content:center;
  gap:10px;
  padding:12px 16px;
  border-radius: 14px;
  font-weight:900;
  border:1px solid transparent;
}
.btn-primary{background: var(--accent); color:#fff; border-color: rgba(255,31,45,.35)}
.btn-primary:hover{background: #e50e1c}
.btn-ghost{background:#fff; border-color: var(--border); color: var(--text)}
.btn-ghost:hover{background:#f8fafc}
.smallnote{color: var(--muted); font-size: 13px}

.layout{
  margin-top:16px;
  display:grid;
  grid-template-columns: 1fr 320px;
  gap:16px;
  align-items:start;
}
.article{
  padding:20px;
  border:1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}
.article h2{font-size:22px; margin:24px 0 10px; scroll-margin-top: 90px}
.article h3{font-size:18px; margin:18px 0 8px; scroll-margin-top: 90px}
.article h4{font-size:16px; margin:16px 0 8px; scroll-margin-top: 90px}
.article p{margin:10px 0}
.bullets{margin:10px 0 10px 18px}
.bullets li{margin:6px 0; color: var(--muted)}

/* ===== Tables: normal table + horizontal scroll wrapper ===== */
.table-wrap{
  overflow-x:auto;
  overflow-y:hidden;
  -webkit-overflow-scrolling: touch;
  border-radius:14px;
  border:1px solid var(--border);
  margin:14px 0;
  background:#fff;
  position:relative;
}
/* subtle scroll hint */
.table-wrap::after{
  content:"";
  position:absolute;
  top:0; right:0;
  width:34px; height:100%;
  pointer-events:none;
  background: linear-gradient(90deg, rgba(255,255,255,0), rgba(255,255,255,.95));
  opacity:0.0;
  transition: opacity .2s ease;
}
.table-wrap.is-scrollable::after{opacity:1;}

.data-table{width:100%; border-collapse:collapse; min-width: 720px}
.data-table th, .data-table td{padding:12px 12px; border-bottom:1px solid var(--border); vertical-align:top}
.data-table th{position:sticky; top:0; background:#fff; text-align:left}
.data-table td{color: var(--muted)}
.data-table tr:hover td{background:#f8fafc; color: var(--text)}

.aside{
  position:sticky;
  top:78px;
  padding:16px;
  border:1px solid var(--border);
  border-radius: var(--radius);
  background:#fff;
  box-shadow: var(--shadow);
}
.aside h4{margin:0 0 10px; font-size:13px; color: var(--muted); letter-spacing:.2px; text-transform:uppercase}
.toc{display:flex; flex-direction:column; gap:6px; max-height: 58vh; overflow:auto; padding-right:4px}
.toc a{color: var(--muted); font-size:14px; padding:7px 8px; border-radius:12px; border:1px solid transparent}
.toc a:hover{border-color: var(--border); color: var(--text); background:#f8fafc}
.toc a.level-3{padding-left:18px; font-size:13px}
.toc a.level-4{padding-left:26px; font-size:12.5px}

.footer{
  margin-top:18px;
  border-top:1px solid var(--border);
  color: var(--muted);
  padding:16px 0 40px;
  font-size:14px;
}

.topbtn{
  position:fixed; right:14px; bottom:14px; z-index:70;
  border:1px solid var(--border);
  background:#fff;
  color: var(--text);
  padding:10px 12px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  cursor:pointer;
  display:none;
}
.topbtn:hover{background:#f8fafc}

/* ===== Mobile ===== */
@media (max-width: 980px){
  .hero{grid-template-columns: 1fr}
  .hero-media{min-height: 220px}
  .layout{grid-template-columns: 1fr}
  .aside{position:relative; top:auto}
  .toc{max-height:none}
}

@media (max-width: 860px){
  .nav{display:none}
  .menu-btn{display:inline-flex}
  .nav.open{
    display:flex;
    flex-direction:column;
    gap:6px;
    position:absolute;
    left:16px; right:16px; top:60px;
    background:#fff;
    border:1px solid var(--border);
    border-radius: 18px;
    padding:10px;
    box-shadow: var(--shadow);
  }
  .nav.open a{width:100%; text-align:left}
}

@media (max-width: 520px){
  .container{padding:14px}
  .hero-content{padding:16px}
  .hero-content h1{font-size:26px}
  .hero-actions{flex-direction:column}
  .btn{width:100%}
  .article{padding:16px}
}

@media (prefers-reduced-motion: reduce){
  *{scroll-behavior:auto !important}
}

/* Header CTA button */
.header-cta{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:10px 14px;
  border-radius: 14px;
  font-weight:900;
  border:1px solid rgba(255,31,45,.35);
  background: rgba(255,31,45,.08);
  color: var(--accent2);
  white-space:nowrap;
}
.header-cta:hover{background: rgba(255,31,45,.12);}
@media (max-width: 860px){
  .header-cta{padding:10px 12px; font-size:14px}
  .nav.open + .header-cta{display:none;}
}
@media (max-width: 520px){
  .header-cta{display:none;}
}
