:root{
  --bg:#0b1020;
  --panel:#121a33;
  --panel2:#0f1730;
  --text:#e9ecff;
  --muted:#b7c0ff;
  --accent:#7aa2ff;
  --accent2:#54f2d2;
  --danger:#ff6b6b;
  --warn:#ffd166;
  --ok:#2fe67b;
  --border:rgba(255,255,255,.10);
  --shadow: 0 16px 40px rgba(0,0,0,.45);
  --radius: 16px;
  --max: 1100px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family: var(--sans);
  background: radial-gradient(1200px 700px at 10% 10%, rgba(122,162,255,.20), transparent 60%),
              radial-gradient(900px 600px at 80% 20%, rgba(84,242,210,.12), transparent 65%),
              var(--bg);
  color:var(--text);
}

/* Базовые стили для всех изображений */
img{
  max-width: 100%;
  height: auto;
  width: 100%;
}

a{ color:var(--accent); text-decoration:none; }
a:hover{ text-decoration:underline; }

.topbar{
  position:sticky;
  top:0;
  z-index:10;
  backdrop-filter: blur(10px);
  background: rgba(11,16,32,.65);
  border-bottom: 1px solid var(--border);
}
.topbar-inner{
  max-width: var(--max);
  margin:0 auto;
  padding: 14px 18px;
  display:flex;
  align-items:center;
  gap: 14px;
}
.brand{
  display:flex;
  flex-direction:column;
  line-height:1.1;
  min-width: 240px;
}
.brand .title{ font-weight: 800; letter-spacing:.2px; }
.brand .subtitle{ color: var(--muted); font-size: 13px; }
.nav{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  align-items:center;
}
.nav a{
  display:inline-block;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(18,26,51,.45);
  color: var(--text);
}
.nav a:hover{
  background: rgba(18,26,51,.80);
  text-decoration:none;
}

.container{
  max-width: var(--max);
  margin: 0 auto;
  padding: 22px 18px 60px;
}

.hero{
  display:grid;
  grid-template-columns: 1.2fr .8fr;
  gap: 18px;
  align-items:stretch;
  margin-top: 18px;
}
.card{
  border:1px solid var(--border);
  background: linear-gradient(180deg, rgba(18,26,51,.75), rgba(15,23,48,.65));
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  padding: 18px;
}
.card h1{ margin: 0 0 8px; font-size: 26px; }
.card h2{ margin: 0 0 10px; font-size: 18px; }
.card p{ margin: 10px 0; color: rgba(233,236,255,.92); }
.muted{ color: rgba(183,192,255,.92); }

.kpis{
  display:grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 10px;
}
.kpi{
  border:1px solid var(--border);
  background: rgba(11,16,32,.30);
  border-radius: 14px;
  padding: 12px 12px 10px;
}
.kpi .n{ font-size: 18px; font-weight: 800; }
.kpi .l{ font-size: 12.5px; color: var(--muted); margin-top: 2px; }

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

.btnrow{ display:flex; gap:10px; flex-wrap:wrap; margin-top: 12px; }
.btn{
  display:inline-flex;
  gap:8px;
  align-items:center;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(122,162,255,.10);
  color: var(--text);
}
.btn:hover{ background: rgba(122,162,255,.18); text-decoration:none; }
.btn.secondary{ background: rgba(84,242,210,.08); }
.btn.secondary:hover{ background: rgba(84,242,210,.14); }

.footer{
  border-top: 1px solid var(--border);
  margin-top: 26px;
  padding-top: 16px;
  color: rgba(183,192,255,.85);
  font-size: 13px;
}

/* Doc viewer */
.docwrap{
  display:grid;
  grid-template-columns: 290px 1fr;
  gap: 14px;
}
.side{
  position: sticky;
  top: 74px;
  align-self:start;
  max-height: calc(100vh - 90px);
  overflow:auto;
  padding: 12px;
  border-radius: var(--radius);
  border:1px solid var(--border);
  background: rgba(18,26,51,.50);
}
.side .s-title{ font-weight: 800; margin: 0 0 10px; }
.side .s-path{ font-family: var(--mono); font-size: 12px; color: var(--muted); word-break: break-all; }
.side .s-actions{ margin-top: 10px; display:flex; gap: 8px; flex-wrap: wrap; }
.input{
  width:100%;
  padding: 10px 10px;
  border-radius: 12px;
  border:1px solid var(--border);
  outline:none;
  background: rgba(11,16,32,.35);
  color: var(--text);
}
.content{
  border-radius: var(--radius);
  border:1px solid var(--border);
  background: rgba(18,26,51,.35);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  min-height: 240px;
}
.content h1,.content h2,.content h3{ margin: 18px 0 8px; }
.content h1{ font-size: 26px; }
.content h2{ font-size: 20px; }
.content h3{ font-size: 16px; }
.content p{ margin: 10px 0; line-height: 1.55; }
.content ul,.content ol{ margin: 10px 0 10px 22px; }
.content li{ margin: 6px 0; line-height: 1.55; }
.content code{
  font-family: var(--mono);
  font-size: 0.95em;
  background: rgba(11,16,32,.55);
  padding: 2px 6px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,.06);
}
.content pre{
  overflow:auto;
  background: rgba(11,16,32,.55);
  padding: 12px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.08);
}
.content pre code{
  background: transparent;
  padding:0;
  border: none;
}
.content blockquote{
  margin: 12px 0;
  padding: 10px 12px;
  border-left: 3px solid rgba(122,162,255,.7);
  background: rgba(11,16,32,.35);
  border-radius: 12px;
  color: rgba(233,236,255,.92);
}
.content table{
  width:100%;
  border-collapse: collapse;
  margin: 12px 0;
  overflow:hidden;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.10);
}
.content th,.content td{
  padding: 10px 10px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  vertical-align: top;
  font-size: 13.5px;
}
.content th{
  background: rgba(11,16,32,.40);
  text-align:left;
}

.pill{
  display:inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(11,16,32,.35);
  color: rgba(233,236,255,.95);
  font-size: 12px;
}
.pill.ok{ border-color: rgba(47,230,123,.35); }
.pill.warn{ border-color: rgba(255,209,102,.35); }
.pill.todo{ border-color: rgba(255,107,107,.30); }

/* Мобильное меню (гамбургер) */
.menu-toggle{
  display: none;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  width: 40px;
  height: 40px;
  justify-content: center;
  align-items: center;
}
.menu-toggle span{
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: all 0.3s ease;
}
.menu-toggle.active span:nth-child(1){ transform: rotate(45deg) translate(5px, 5px); }
.menu-toggle.active span:nth-child(2){ opacity: 0; }
.menu-toggle.active span:nth-child(3){ transform: rotate(-45deg) translate(7px, -6px); }

/* Планшеты и небольшие экраны (до 980px) */
@media (max-width: 980px){
  .hero{ grid-template-columns: 1fr; }
  .docwrap{ grid-template-columns: 1fr; }
  .side{ position: relative; top:auto; max-height:none; }
  .brand{ min-width: 160px; }
  .grid2{ grid-template-columns: 1fr; }
  .grid3{ grid-template-columns: repeat(2, minmax(0,1fr)); }
}

/* Мобильные устройства (до 768px) */
@media (max-width: 768px){
  /* Топбар и навигация */
  .topbar-inner{
    padding: 12px 14px;
    flex-wrap: wrap;
    gap: 10px;
  }
  .brand{
    min-width: auto;
    flex: 1;
    min-width: 0;
  }
  .brand .title{ font-size: 16px; }
  .brand .subtitle{ font-size: 11.5px; }
  
  /* Мобильное меню */
  .menu-toggle{
    display: flex;
    order: 2;
    margin-left: auto;
  }
  .nav{
    display: none;
    width: 100%;
    order: 3;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
  }
  .nav.active{
    display: flex;
  }
  .nav a{
    width: 100%;
    text-align: center;
    padding: 10px 12px;
    font-size: 14px;
  }
  
  /* Контейнер и отступы */
  .container{
    padding: 16px 14px 40px;
  }
  
  /* Карточки */
  .card{
    padding: 14px;
    border-radius: 12px;
  }
  .card h1{ font-size: 22px; }
  .card h2{ font-size: 17px; }
  .card p{ font-size: 14.5px; line-height: 1.5; }
  
  /* KPI */
  .kpis{
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .kpi{
    padding: 10px;
  }
  .kpi .n{ font-size: 16px; }
  .kpi .l{ font-size: 11.5px; }
  
  /* Grid */
  .grid2, .grid3{
    grid-template-columns: 1fr;
    gap: 12px;
  }
  
  /* Кнопки */
  .btn{
    padding: 12px 14px;
    font-size: 14px;
    min-height: 44px; /* Минимальный размер для touch */
    justify-content: center;
  }
  .btnrow{
    flex-direction: column;
    gap: 8px;
  }
  .btnrow .btn{
    width: 100%;
  }
  
  /* Hero секция */
  .hero{
    gap: 12px;
    margin-top: 12px;
  }
  
  /* Doc viewer */
  .docwrap{
    gap: 12px;
  }
  .side{
    padding: 10px;
    border-radius: 12px;
  }
  .side .s-title{ font-size: 16px; }
  .side .s-path{ font-size: 11px; }
  .content{
    padding: 14px;
    border-radius: 12px;
  }
  .content h1{ font-size: 22px; }
  .content h2{ font-size: 18px; }
  .content h3{ font-size: 16px; }
  .content p, .content li{ font-size: 14.5px; }
  .content th, .content td{
    font-size: 12.5px;
    padding: 8px 6px;
  }
  
  /* Таблицы - делаем прокручиваемыми */
  .content table{
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 12px -14px;
    width: calc(100% + 28px);
    border-radius: 0;
  }
  .content table thead,
  .content table tbody,
  .content table tr{
    display: table;
    width: 100%;
    table-layout: fixed;
  }
  
  /* Code blocks */
  .content pre{
    padding: 10px;
    font-size: 12.5px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .content code{
    font-size: 12.5px;
    padding: 2px 4px;
  }
  
  /* Footer */
  .footer{
    font-size: 12px;
    margin-top: 20px;
    padding-top: 12px;
  }
  
  /* Pills */
  .pill{
    font-size: 11px;
    padding: 3px 8px;
  }
}

/* Маленькие мобильные (до 480px) */
@media (max-width: 480px){
  /* Ещё более компактные отступы */
  .topbar-inner{
    padding: 10px 12px;
  }
  .container{
    padding: 12px 12px 32px;
  }
  .card{
    padding: 12px;
  }
  .card h1{ font-size: 20px; }
  .card h2{ font-size: 16px; }
  .card p{ font-size: 14px; }
  
  /* Уменьшаем градиенты фона для производительности */
  body{
    background: radial-gradient(800px 500px at 10% 10%, rgba(122,162,255,.15), transparent 50%),
                radial-gradient(600px 400px at 80% 20%, rgba(84,242,210,.10), transparent 50%),
                var(--bg);
  }
  
  /* KPI более компактные */
  .kpi{
    padding: 8px;
  }
  .kpi .n{ font-size: 15px; }
  .kpi .l{ font-size: 11px; }
  
  /* Кнопки */
  .btn{
    padding: 11px 12px;
    font-size: 13.5px;
  }
  
  /* Content */
  .content{
    padding: 12px;
  }
  .content h1{ font-size: 20px; }
  .content h2{ font-size: 17px; }
  .content h3{ font-size: 15px; }
  .content p, .content li{ font-size: 14px; }
  
  /* Таблицы - ещё более компактные */
  .content th, .content td{
    font-size: 11.5px;
    padding: 6px 4px;
  }
  
  /* Input */
  .input{
    padding: 10px;
    font-size: 14px;
  }
}

/* Очень маленькие экраны (до 360px) */
@media (max-width: 360px){
  .brand .title{ font-size: 14px; }
  .brand .subtitle{ font-size: 10.5px; }
  .card h1{ font-size: 18px; }
  .card h2{ font-size: 15px; }
  .content h1{ font-size: 18px; }
  .content h2{ font-size: 16px; }
}

/* Галерея изображений */
.gallery{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 20px;
}
.gallery-item{
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: rgba(18,26,51,.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  max-width: 100%;
}
.gallery-item:hover{
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.gallery-item img{
  width: 100%;
  max-width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
  background: rgba(11,16,32,.20);
  cursor: pointer;
  transition: opacity 0.2s ease;
}
.gallery-item img:hover{
  opacity: 0.9;
}

/* Модальное окно для просмотра изображений */
.image-modal{
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  background: rgba(11, 16, 32, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.3s ease;
}
.image-modal.active{
  display: flex;
}
.image-modal-content{
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: zoomIn 0.3s ease;
}
.image-modal-content img{
  max-width: 100%;
  max-height: 85vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,.8);
}
.image-modal-close{
  position: absolute;
  top: -40px;
  right: 0;
  background: rgba(18,26,51,.9);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text);
  font-size: 24px;
  line-height: 1;
  transition: background 0.2s ease, transform 0.2s ease;
}
.image-modal-close:hover{
  background: rgba(18,26,51,1);
  transform: scale(1.1);
}
.image-modal-caption{
  margin-top: 16px;
  padding: 12px 16px;
  background: rgba(18,26,51,.9);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  text-align: center;
  max-width: 100%;
}
.image-modal-caption-title{
  font-weight: 600;
  font-size: 16px;
  margin-bottom: 4px;
}
.image-modal-caption-text{
  font-size: 13px;
  color: var(--muted);
  line-height: 1.4;
}

@keyframes fadeIn{
  from{ opacity: 0; }
  to{ opacity: 1; }
}
@keyframes zoomIn{
  from{ transform: scale(0.9); opacity: 0; }
  to{ transform: scale(1); opacity: 1; }
}

/* Изображения в контенте */
.content img{
  max-width: 100%;
  height: auto;
  display: block;
  margin: 16px auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  cursor: pointer;
}

.gallery-item-caption{
  padding: 12px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.4;
}
.gallery-item-title{
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  font-size: 14px;
}

@media (max-width: 768px){
  .gallery{
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .gallery-item{
    max-width: 100%;
  }
  .gallery-item img{
    max-width: 100%;
    width: 100%;
  }
  .gallery-item-caption{
    padding: 10px;
    font-size: 12px;
  }
  .content img{
    max-width: 100%;
    margin: 12px 0;
  }
  .image-modal{
    padding: 10px;
  }
  .image-modal-content{
    max-width: 95vw;
    max-height: 95vh;
  }
  .image-modal-content img{
    max-height: 80vh;
  }
  .image-modal-close{
    top: -35px;
    width: 35px;
    height: 35px;
    font-size: 20px;
  }
  .image-modal-caption{
    margin-top: 12px;
    padding: 10px 12px;
  }
  .image-modal-caption-title{
    font-size: 14px;
  }
  .image-modal-caption-text{
    font-size: 12px;
  }
}

@media (max-width: 480px){
  .gallery{
    gap: 10px;
  }
  .gallery-item img{
    width: 100%;
    max-width: 100%;
  }
  .content img{
    max-width: 100%;
    border-radius: 12px;
  }
}

/* Ландшафтная ориентация на мобильных */
@media (max-width: 768px) and (orientation: landscape){
  .topbar-inner{
    padding: 10px 14px;
  }
  .nav{
    flex-direction: row;
    flex-wrap: wrap;
  }
  .nav a{
    width: auto;
    flex: 1;
    min-width: 120px;
  }
}

