/* =======================
   ПЕРЕМЕННЫЕ ТЕМЫ (НОЧЬ ПО УМОЛЧАНИЮ + ДНЕВНОЙ РЕЖИМ)
   ======================= */
:root {
  --bg: #0b0f17;
  --bg-grad: radial-gradient(1200px 800px at 80% -10%, #132036 0%, transparent 70%);
  --panel: #101622;
  --panel-2: #0d121c;
  --figure-bg: #0a101d;
  --kv-bg: #0e1728;
  --text: #e6edf7;
  --muted: #9fb2d3;
  --accent: #7cc6ff;
  --accent-soft: rgba(124, 198, 255, 0.14);
  --ok: #56d364;
  --warn: #ffcf33;
  --danger: #ff7b72;
  --border: rgba(255, 255, 255, 0.09);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --tile-max-h: 340px;
}

body.day-mode {
  --bg: #f2f5f9;
  --bg-grad: radial-gradient(1100px 700px at 85% -10%, #e1ebf7 0%, transparent 70%);
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --figure-bg: #edf2f7;
  --kv-bg: #f1f5f9;
  --text: #16202c;
  --muted: #526378;
  --accent: #1d5fd6;
  --accent-soft: rgba(29, 95, 214, 0.1);
  --ok: #15803d;
  --warn: #b45309;
  --danger: #b91c1c;
  --border: #d8e0ea;
  --shadow: 0 6px 20px rgba(15, 23, 42, 0.06);
}

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

html, body {
  min-height: 100%;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", sans-serif;
  color: var(--text);
  background-color: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  line-height: 1.45;
  display: flex;
  flex-direction: column;
  transition: background-color 0.25s ease, color 0.25s ease;
}

/* =======================
   ШАПКА И ПАНЕЛЬ УПРАВЛЕНИЯ
   ======================= */
.site-header {
  top: 0;
  z-index: 30;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 12px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.branding {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: conic-gradient(from 0deg, #ffb703, #fb8500, #ffd166, #ffb703);
  box-shadow: 0 0 18px rgba(251, 133, 0, 0.28);
  font-size: 20px;
  flex-shrink: 0;
}

.title {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.subtitle {
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 2px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 12px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: border-color 0.2s, background-color 0.2s, transform 0.12s;
}

.btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.btn:active {
  transform: scale(0.98);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 7px;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 9px;
  background: var(--panel-2);
  border: 1px solid var(--border);
}

.status {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

/* =======================
   ГЛАВНОЕ МЕНЮ
   ======================= */
.main-menu {
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
  z-index: 20;
}

.main-menu .menu {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
  padding: 6px 14px;
}

.main-menu .menu a {
  display: block;
  padding: 8px 15px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.4px;
  transition: background-color 0.2s, color 0.2s;
}

.main-menu .menu a:hover,
.main-menu .menu a.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.mobile-menu-bar {
  display: none;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
}

.mobile-menu-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.menu-toggle-btn {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

/* =======================
   ФИЛЬТРЫ И ЖИВАЯ СВОДКА
   ======================= */
.summary-bar {
  max-width: 1480px;
  width: 100%;
  margin: 16px auto 0;
  padding: 0 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.filter-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pill {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 6px 13px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.pill:hover {
  color: var(--text);
  border-color: var(--accent);
}

.pill.active {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

body:not(.day-mode) .pill.active {
  color: #09111e;
}

.live-strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.live-chip {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 9px;
  font-size: 12px;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.live-chip strong {
  color: var(--text);
  font-weight: 700;
}

/* =======================
   СЕТКА И ФИКСИРОВАННЫЙ РАЗМЕР ПЛИТОК
   ======================= */
.main-content {
  flex: 1;
  max-width: 1480px;
  width: 100%;
  margin: 0 auto;
  padding: 16px 18px 36px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.cols-12 { grid-column: span 12; }
.cols-6  { grid-column: span 6; }
.cols-4  { grid-column: span 4; }
.cols-3  { grid-column: span 3; }

.tile {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 455px;
  box-shadow: var(--shadow);
  transition: transform 0.18s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.tile:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.tile.is-hidden {
  display: none;
}

.tile-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.tile-title {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.badge {
  font-size: 11px;
  font-weight: 700;
  color: #08111e;
  background: var(--accent);
  padding: 3px 8px;
  border-radius: 999px;
}

body.day-mode .badge {
  color: #ffffff;
}

.zoom-btn {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 7px;
  padding: 3px 8px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
}

.zoom-btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.tile-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

/* Ограничиваем высоту медиа-области, чтобы блоки не раздувались */
.figure {
  position: relative;
  width: 100%;
  height: 250px;
  max-height: var(--tile-max-h);
  background: var(--figure-bg);
  display: grid;
  place-items: center;
  cursor: zoom-in;
  overflow: hidden;
}

.cols-12 .figure {
  height: 300px;
}

.figure img,
.figure video,
.tile-canvas,
canvas.figure {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.figure .loader {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 12px;
  color: var(--muted);
  background: var(--figure-bg);
}

.tile-meta {
  padding: 8px 12px;
  color: var(--muted);
  font-size: 11.5px;
  border-top: 1px solid var(--border);
  background: var(--panel);
}

.kv {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.kv div {
  background: var(--kv-bg);
  border: 1px solid var(--border);
  padding: 4px 8px;
  border-radius: 7px;
  font-size: 11.5px;
  color: var(--muted);
}

/* =======================
   МОДАЛЬНОЕ ОКНО ДЕТАЛЬНОГО ИЗУЧЕНИЯ
   ======================= */
.modal-backdrop[hidden] {
  display: none;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(4, 8, 15, 0.82);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.modal-dialog {
  width: min(1160px, 100%);
  max-height: 92vh;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-size: 17px;
  font-weight: 700;
}

.modal-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.modal-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.modal-stage {
  flex: 1;
  min-height: 300px;
  max-height: 68vh;
  background: var(--figure-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  overflow: auto;
}

.modal-stage img,
.modal-stage canvas {
  max-width: 100%;
  max-height: 64vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
}

.modal-footer-info {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
  background: var(--panel-2);
}

/* =======================
   УЛУЧШЕННЫЙ ФУТЕР
   ======================= */
.site-footer {
  margin-top: auto;
  background: var(--panel);
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
  padding: 26px 20px 22px;
}

.footer-inner {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  flex-wrap: wrap;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.footer-brand {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.footer-note {
  max-width: 560px;
  font-size: 12.5px;
  line-height: 1.5;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
}

.footer-links a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s;
}

.footer-links a:hover {
  color: var(--accent);
}

.footer-bottom {
  max-width: 1440px;
  margin: 14px auto 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12.5px;
}

/* =======================
   АДАПТИВНОСТЬ ДЛЯ ВСЕХ УСТРОЙСТВ
   ======================= */
@media (max-width: 1024px) {
  .cols-3 { grid-column: span 6; }
  .cols-4 { grid-column: span 6; }
  .cols-6 { grid-column: span 12; }
}

@media (max-width: 768px) {
  .site-header {
    position: static;
    padding: 12px 14px;
  }

  .toolbar {
    width: 100%;
    justify-content: space-between;
  }

  .mobile-menu-bar {
    display: flex;
  }

  .main-menu .menu {
    display: none;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 10px 12px 12px;
    border-top: 1px solid var(--border);
  }

  .main-menu .menu.open {
    display: flex;
  }

  .main-menu .menu a {
    display: inline-block;
    text-align: center;
    padding: 7px 12px;
    border-radius: 8px;
    background: var(--panel);
    border: 1px solid var(--border);
    font-size: 13px;
  }

  .summary-bar {
    padding: 0 12px;
  }

  .main-content {
    padding: 14px 12px 28px;
  }

  .grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .cols-12, .cols-6, .cols-4, .cols-3 {
    grid-column: 1 / -1;
  }

  .tile {
    max-height: none;
  }

  .figure,
  .cols-12 .figure {
    height: 220px;
  }

  .footer-inner,
  .footer-bottom {
    flex-direction: column;
    align-items: flex-start;
  }
}
/* Блок D-RAP и пояснительная карточка */
.cols-12 .figure {
  height: 340px;
  padding: 6px;
}

.drap-info-box {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

.drap-info-box h4 {
  color: var(--text);
  font-size: 14px;
  margin-bottom: 2px;
}

.drap-legend-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.drap-legend-list li {
  background: var(--kv-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  font-size: 12.5px;
}

@media (max-width: 768px) {
  .cols-12 .figure {
    height: 260px;
  }
}