/* ============================================================================
   NEVOD — современное оформление панели (поверх battle.css).
   Задача: читаемая типографика вместо базовых 8–9px, карточки с иерархией,
   аккуратные состояния и переходы. Подключается ПОСЛЕ battle.css и ДО
   battle-mobile.css (мобильные правила остаются приоритетными на телефоне).
   ========================================================================= */

:root {
  --type-xs: 10.5px;
  --type-sm: 11.5px;
  --type-md: 12.5px;
  --type-lg: 15px;
  --type-xl: 19px;
  --radius-card: 15px;
  --radius-chip: 999px;
  --line: 1px solid rgba(255, 255, 255, 0.07);
  --line-strong: 1px solid rgba(255, 255, 255, 0.12);
  --card-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.022));
  --card-bg-hover: linear-gradient(180deg, rgba(255, 255, 255, 0.085), rgba(255, 255, 255, 0.035));
  --transition: 0.18s cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* --- Панель и секции --------------------------------------------------- */

#panel {
  width: clamp(250px, 20vw, 310px);
  padding: 6px;
  gap: 2px;
}

.section {
  margin: 5px 4px;
  padding: 9px 10px 10px;
  border-radius: var(--radius-card);
  border: var(--line);
  background: var(--card-bg);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.section-header {
  margin-bottom: 7px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.s-title {
  font-size: var(--type-xs);
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--dim-strong);
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.s-title::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--aglow);
}

.section-header .s-count,
.section-header .s-title + * {
  font-size: var(--type-xs);
  color: var(--dim);
}

/* --- Узлы ------------------------------------------------------------- */

.n-item {
  padding: 9px 10px;
  margin-bottom: 6px;
  border-radius: var(--radius-card);
  border: var(--line);
  background: var(--card-bg);
  font-size: var(--type-sm);
  gap: 8px;
  position: relative;
  overflow: hidden;
  transition: border-color var(--transition), background var(--transition), transform var(--transition);
}

.n-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--green);
  opacity: 0.85;
}

.n-item.health-warn::before,
.n-item.fault::before {
  background: var(--warn);
}

.n-item.health-bad::before,
.n-item.critical::before {
  background: var(--red);
}

.n-item:hover {
  border-color: var(--border);
  background: var(--card-bg-hover);
  transform: translateY(-1px);
}

.n-item.selected {
  border-color: rgba(251, 146, 60, 0.42);
  box-shadow: 0 0 0 1px rgba(251, 146, 60, 0.25), var(--shadow-soft);
}

.n-name,
.n-item .n-title {
  font-size: var(--type-md);
  font-weight: 650;
  letter-spacing: 0.01em;
}

.n-chips {
  gap: 4px;
  margin-top: 5px;
}

.n-chip {
  font-size: var(--type-xs);
  padding: 2px 7px;
  border-radius: var(--radius-chip);
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(255, 255, 255, 0.045);
  letter-spacing: 0.01em;
}

.n-sub,
.n-item .n-meta {
  font-size: var(--type-xs);
  color: var(--dim);
  margin-top: 5px;
}

/* --- События ---------------------------------------------------------- */

.alert-item {
  padding: 8px 10px;
  margin-bottom: 6px;
  border-radius: 12px;
  border: var(--line);
  border-left: 3px solid var(--accent);
  background: var(--card-bg);
  font-size: var(--type-sm);
  line-height: 1.45;
  transition: border-color var(--transition), transform var(--transition);
}

.alert-item:hover {
  transform: translateX(1px);
  border-color: rgba(255, 255, 255, 0.14);
}

.alert-item.alert-warning {
  border-left-color: var(--warn);
}

.alert-item.alert-critical,
.alert-item.alert-error {
  border-left-color: var(--red);
}

.alert-item.alert-info {
  border-left-color: var(--blue);
}

.alert-group-title {
  font-size: var(--type-xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
  margin: 6px 0 4px;
}

/* --- Цели ------------------------------------------------------------- */

.target-card {
  padding: 10px 11px;
  border-radius: var(--radius-card);
  border: var(--line);
  background: var(--card-bg);
  transition: border-color var(--transition), background var(--transition), transform var(--transition);
}

.target-card:hover {
  background: var(--card-bg-hover);
  transform: translateY(-1px);
}

.target-title {
  font-size: var(--type-md);
  font-weight: 650;
}

.target-sub,
.target-meta,
.t-motion {
  font-size: var(--type-xs);
}

.target-meta .t-dist {
  font-size: var(--type-sm);
}

/* --- Шапка ------------------------------------------------------------ */

#header {
  padding: 9px 12px;
  border-radius: 18px;
  gap: 10px;
}

.logo {
  font-size: var(--type-md);
  letter-spacing: 0.06em;
}

.stat-pill {
  width: auto;
  min-width: 46px;
  height: 32px;
  padding: 0 10px;
  border-radius: 11px;
  font-size: var(--type-sm);
  border: var(--line);
  transition: border-color var(--transition), background var(--transition);
}

.stat-pill:hover {
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
}

.stat-pill .stat-value {
  font-size: var(--type-sm);
  font-weight: 650;
}

#ws-status {
  position: relative;
  width: auto;
  min-width: 56px;
}

#ws-status .stat-icon {
  font-size: 10px;
}

#ws-status::after {
  content: '';
  position: absolute;
  right: 6px;
  top: 6px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.75;
  animation: nevod-pulse 2.4s ease-in-out infinite;
}

@keyframes nevod-pulse {
  0%, 100% { opacity: 0.25; }
  50% { opacity: 0.9; }
}

.theme-toggle {
  width: 32px;
  height: 32px;
  border-radius: 11px;
  font-size: var(--type-md);
}

/* --- Кнопки и чипы ---------------------------------------------------- */

.btn {
  min-height: 32px;
  padding: 0 12px;
  border-radius: 11px;
  font-size: var(--type-sm);
  font-weight: 600;
  transition: transform var(--transition), filter var(--transition), border-color var(--transition);
}

.btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.07);
}

.btn:active {
  transform: translateY(0);
}

.btn-ghost {
  border: var(--line-strong);
  background: rgba(255, 255, 255, 0.04);
}

.map-chip {
  min-height: 30px;
  padding: 0 11px;
  border-radius: var(--radius-chip);
  font-size: var(--type-xs);
  font-weight: 600;
  letter-spacing: 0.01em;
  border: var(--line);
  background: rgba(255, 255, 255, 0.04);
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.map-chip:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.16);
}

.map-chip.active {
  background: rgba(251, 146, 60, 0.16);
  border-color: rgba(251, 146, 60, 0.42);
  color: var(--text);
}

.map-tools-title {
  font-size: var(--type-xs);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dim-strong);
  margin-bottom: 6px;
}

.map-summary,
.map-tools-summary {
  font-size: var(--type-xs);
  color: var(--dim);
  line-height: 1.5;
}

/* --- Карточка узла (быстрый обзор) ------------------------------------ */

.quick-card {
  width: clamp(280px, 24vw, 360px);
  padding: 14px;
  border-radius: 18px;
  border: var(--line);
  background: linear-gradient(180deg, rgba(12, 16, 24, 0.94), rgba(9, 12, 18, 0.9));
}

.quick-card-title,
.quick-card .quick-card-title {
  font-size: var(--type-xs);
  letter-spacing: 0.1em;
  color: var(--dim);
}

.quick-card-main,
.quick-card .quick-card-main {
  font-size: var(--type-xl);
  font-weight: 700;
  letter-spacing: 0.01em;
}

.quick-card-sub,
.quick-card .quick-card-sub {
  font-size: var(--type-xs);
  color: var(--dim-strong);
  line-height: 1.5;
}

/* --- Скроллбары и мелочи --------------------------------------------- */

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16);
  border: 2px solid transparent;
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.26);
  background-clip: padding-box;
}

.section,
.alert-item,
.n-item,
.target-card,
.map-chip,
.btn {
  will-change: transform;
}

@media (prefers-reduced-motion: reduce) {
  .alert-item,
  .n-item,
  .target-card,
  .btn,
  .map-chip {
    transition: none !important;
    transform: none !important;
  }

  #ws-status::after {
    animation: none;
  }
}

/* --- Светлая тема ----------------------------------------------------- */

:root[data-theme="light"] {
  --line: 1px solid rgba(15, 23, 42, 0.08);
  --line-strong: 1px solid rgba(15, 23, 42, 0.14);
  --card-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(246, 249, 254, 0.9));
  --card-bg-hover: linear-gradient(180deg, #ffffff, rgba(240, 245, 252, 0.95));
}

:root[data-theme="light"] .s-title {
  color: rgba(15, 23, 42, 0.68);
}

:root[data-theme="light"] .n-chip,
:root[data-theme="light"] .map-chip {
  border-color: rgba(15, 23, 42, 0.1);
  background: rgba(15, 23, 42, 0.035);
}

:root[data-theme="light"] .quick-card {
  background: linear-gradient(180deg, #ffffff, rgba(246, 249, 254, 0.96));
}

/* ============================================================================
   Раскладка сайдбара: секции делят высоту панели, списки прокручиваются
   внутри себя. Без этого разделы по содержимому выдавливали «Узлы» (и
   «Цели») за пределы панели — на экране их не было видно.
   ========================================================================= */

#panel {
  gap: 0;
}

#panel .section-events {
  flex: 0 0 auto;
  max-height: clamp(120px, 24vh, 230px);
  min-height: 96px;
}

#panel .section-nodes {
  flex: 1 1 auto;
  min-height: 150px;
}

#panel .section-targets {
  flex: 0 1 auto;
  max-height: clamp(96px, 30vh, 320px);
  min-height: 84px;
}

#panel .section-map-tools {
  flex: 0 1 auto;
  max-height: clamp(110px, 30vh, 300px);
  min-height: 0;
  overflow-y: auto;
}

#alert-stream,
#node-list,
#target-list,
.section-map-tools .pot-list {
  overflow-y: auto;
  min-height: 0;
}

/* На телефоне компоновку задаёт нижний лист (battle-mobile.css) */
@media (max-width: 700px) {
  #panel .section {
    max-height: none;
  }
}
