:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --success: #16a34a;
  --warning: #d97706;
  --purple: #7c3aed;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 14px rgba(15, 23, 42, 0.12);
  --radius: 8px;
}

:root[data-theme="dark"] {
  --bg: #0b0f19;
  --surface: #111827;
  --surface-alt: #1e293b;
  --border: #334155;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --success: #22c55e;
  --warning: #f59e0b;
  --purple: #a855f7;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.45);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.65);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Arial, sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}

.hidden {
  display: none !important;
}

/* Авторизация */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 390px;
  background: var(--surface);
  border-radius: 14px;
  padding: 28px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.4);
}

.auth-logo {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 6px;
}

.auth-subtitle {
  color: var(--text-muted);
  margin: 0 0 20px;
  line-height: 1.4;
}

.auth-error {
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  padding: 8px 10px;
  margin-bottom: 12px;
  font-size: 12px;
}

/* Оболочка */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* Верхняя панель */
.topbar {
  height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px 0 10px;
  gap: 8px;
  z-index: 500;
  flex-shrink: 0;
  white-space: nowrap;
  box-sizing: border-box;
  width: 100%;
  max-width: 100vw;
  overflow-x: clip;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  min-width: max-content;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  justify-content: flex-end;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  white-space: nowrap;
  user-select: none;
  cursor: default;
  flex-shrink: 0;
}

.brand-logo-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.brand:hover .brand-logo-wrap {
  transform: translateY(-1px) scale(1.05);
}

.brand-logo-svg {
  display: block;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.18);
  width: 42px;
  height: 42px;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  justify-content: center;
  line-height: 1.12;
  flex-shrink: 0;
}

.brand-title {
  font-weight: 800;
  font-size: 20px;
  color: var(--text);
  letter-spacing: -0.2px;
  white-space: nowrap;
}

.brand-subtitle {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--primary);
  margin-top: 2px;
  white-space: nowrap;
}

:root[data-theme="dark"] .brand-subtitle {
  color: #38bdf8;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  padding: 2px 3px;
  border-radius: 8px;
  flex-shrink: 0;
  white-space: nowrap;
}

.tool-btn {
  border: none;
  background: transparent;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 500;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap !important;
  flex-shrink: 0;
  line-height: 1.2;
  transition: all 0.15s;
}

.tool-btn span {
  display: inline-block;
  line-height: 1;
}

.tool-btn:hover {
  background: #e2e8f0;
}

:root[data-theme="dark"] .tool-btn:hover {
  background: #334155;
}

.tool-btn.active {
  background: var(--primary);
  color: #fff;
}

.tool-icon-dash {
  font-weight: 900;
  letter-spacing: -0.5px;
  color: #2563eb;
  display: inline-block;
  font-size: 13px;
  line-height: 1;
  transition: color 0.15s ease;
}

.tool-btn.active .tool-icon-dash {
  color: #ffffff !important;
}

:root[data-theme="dark"] .tool-icon-dash {
  color: #60a5fa;
}

/* Мониторинг пользователей онлайн: компактная кнопка и выпадающий список */
.online-widget-container {
  position: relative;
  display: inline-block;
  flex-shrink: 0;
}

.online-widget-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  padding: 4px 10px 4px 8px;
  border-radius: 999px;
  user-select: none;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: inherit;
  color: var(--text);
  line-height: 1.2;
}

.online-widget-btn:hover,
.online-widget-btn.active {
  background: var(--surface);
  border-color: #60a5fa;
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.16);
}

:root[data-theme="dark"] .online-widget-btn:hover,
:root[data-theme="dark"] .online-widget-btn.active {
  background: rgba(30, 41, 59, 0.9);
  border-color: #60a5fa;
  box-shadow: 0 2px 12px rgba(37, 99, 235, 0.25);
}

.online-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.85);
  display: inline-block;
  animation: pulseDot 1.8s infinite ease-in-out;
  flex-shrink: 0;
}

@keyframes pulseDot {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.85);
  }
  50% {
    transform: scale(1.3);
    opacity: 0.6;
    box-shadow: 0 0 14px rgba(34, 197, 94, 0.95);
  }
}

.online-label {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-muted);
}

.online-count {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  padding: 0 6px;
  min-width: 18px;
  text-align: center;
  line-height: 1.35;
}

:root[data-theme="dark"] .online-count {
  background: rgba(59, 130, 246, 0.2);
  border-color: rgba(59, 130, 246, 0.4);
  color: #93c5fd;
}

.online-caret {
  font-size: 10px;
  color: var(--text-muted);
  transition: transform 0.2s ease;
  margin-left: 1px;
}

.online-widget-btn.active .online-caret {
  transform: rotate(180deg);
}

/* Всплывающее окно со списком сотрудников */
.online-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 290px;
  max-width: 350px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18), 0 2px 8px rgba(0, 0, 0, 0.06);
  padding: 12px 14px;
  z-index: 2500;
  animation: dropdownFadeIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes dropdownFadeIn {
  from { opacity: 0; transform: translateY(-6px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

:root[data-theme="dark"] .online-dropdown {
  background: #1e293b;
  border-color: #334155;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.online-dropdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.online-dropdown-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.online-count-pill {
  font-size: 11px;
  font-weight: 700;
  background: #eff6ff;
  color: var(--primary);
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  padding: 1px 7px;
}

:root[data-theme="dark"] .online-count-pill {
  background: rgba(59, 130, 246, 0.2);
  border-color: rgba(59, 130, 246, 0.4);
  color: #93c5fd;
}

.online-dropdown-close {
  background: none;
  border: none;
  font-size: 18px;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all 0.15s ease;
}

.online-dropdown-close:hover {
  color: var(--text);
  background: var(--surface-alt);
}

.online-dropdown-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin: 9px 0 7px 0;
}

.online-users-dropdown-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 250px;
  overflow-y: auto;
  padding-right: 2px;
}

.online-user-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 9px;
  transition: all 0.15s ease;
}

.online-user-item:hover {
  border-color: #60a5fa;
  background: var(--surface);
}

.online-user-item.is-self {
  border-color: #93c5fd;
  background: #eff6ff;
}

:root[data-theme="dark"] .online-user-item {
  background: #0f172a;
  border-color: #334155;
}

:root[data-theme="dark"] .online-user-item:hover {
  background: #1e293b;
  border-color: #60a5fa;
}

:root[data-theme="dark"] .online-user-item.is-self {
  background: rgba(37, 99, 235, 0.2);
  border-color: rgba(59, 130, 246, 0.5);
}

.online-user-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.online-user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  flex-shrink: 0;
}

.online-user-item.is-admin .online-user-avatar {
  background: #fef3c7;
  border-color: #fde68a;
}

:root[data-theme="dark"] .online-user-avatar {
  background: #1e293b;
  border-color: #475569;
}

:root[data-theme="dark"] .online-user-item.is-admin .online-user-avatar {
  background: rgba(245, 158, 11, 0.2);
  border-color: rgba(245, 158, 11, 0.4);
}

.online-user-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.online-user-name-row {
  display: flex;
  align-items: center;
  gap: 5px;
}

.online-user-login {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 185px;
}

.online-user-self-tag {
  font-size: 9.5px;
  font-weight: 700;
  color: #1d4ed8;
  background: #dbeafe;
  padding: 0 5px;
  border-radius: 4px;
}

:root[data-theme="dark"] .online-user-self-tag {
  color: #93c5fd;
  background: rgba(59, 130, 246, 0.35);
}

.online-user-role {
  font-size: 10.5px;
  color: var(--text-muted);
}

.online-user-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.7);
  flex-shrink: 0;
}

.role-box {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-right: 6px;
  border-right: 1px solid var(--border);
}

.topbar-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 2px;
  flex-shrink: 0;
}

/* Визитка разработчика — стильный, контрастный и заметный бейдж с живой неоновой пульсацией */
.dev-badge {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 13px 4px 5px;
  background: linear-gradient(135deg, #0b1329 0%, #1e293b 100%);
  border: 1px solid rgba(56, 189, 248, 0.5);
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.16), 0 0 10px rgba(37, 99, 235, 0.22);
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
  white-space: nowrap;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  animation: devBadgePulse 2.8s infinite ease-in-out;
}

@keyframes devBadgePulse {
  0%, 100% {
    border-color: rgba(56, 189, 248, 0.45);
    box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.25),
                0 2px 10px rgba(15, 23, 42, 0.35),
                0 0 12px rgba(37, 99, 235, 0.3);
    transform: translateY(0);
  }
  50% {
    border-color: #38bdf8;
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.75),
                0 4px 18px rgba(37, 99, 235, 0.55),
                0 0 24px rgba(56, 189, 248, 0.65);
    transform: translateY(-0.5px);
  }
}

.dev-badge:hover {
  border-color: #60a5fa;
  box-shadow: 0 0 0 2.5px rgba(96, 165, 250, 0.85),
              0 6px 22px rgba(37, 99, 235, 0.65),
              0 0 30px rgba(56, 189, 248, 0.8);
  transform: translateY(-1.5px) scale(1.02);
}

.dev-badge-avatar {
  position: relative;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12.5px;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: 0.5px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
  flex-shrink: 0;
}

.dev-badge-avatar::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  border: 1.5px solid #38bdf8;
  opacity: 0;
  animation: devAvatarPulse 2.8s infinite ease-out;
  pointer-events: none;
}

@keyframes devAvatarPulse {
  0% {
    transform: scale(0.9);
    opacity: 0.85;
  }
  60% {
    transform: scale(1.35);
    opacity: 0;
  }
  100% {
    transform: scale(1.35);
    opacity: 0;
  }
}

.dev-badge-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  white-space: nowrap;
}

.dev-badge-role {
  font-size: 9.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.85px;
  color: #38bdf8; /* Неоново-голубой контрастный акцент */
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
}

.dev-badge-role::before {
  content: "";
  display: inline-block;
  width: 4.5px;
  height: 4.5px;
  margin-right: 5px;
  border-radius: 50%;
  background: #38bdf8;
  box-shadow: 0 0 5px #38bdf8;
  animation: devDotPulse 1.4s infinite ease-in-out;
  flex-shrink: 0;
}

@keyframes devDotPulse {
  0%, 100% {
    transform: scale(0.85);
    opacity: 0.65;
    box-shadow: 0 0 4px #38bdf8;
  }
  50% {
    transform: scale(1.3);
    opacity: 1;
    box-shadow: 0 0 8px #38bdf8, 0 0 12px #60a5fa;
  }
}

.dev-badge-name {
  font-size: 14px;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: 0.15px;
  white-space: nowrap;
}

/* Кнопки */
.btn {
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 6px 11px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-sm {
  padding: 5px 9px;
  font-size: 12px;
}

.btn-full {
  width: 100%;
  padding: 10px;
  font-size: 13px;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary {
  background: var(--surface-alt);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { background: #e2e8f0; }

.btn-white {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}
.btn-white:hover { background: var(--surface-alt); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover {
  background: var(--surface-alt);
  color: var(--text);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { background: var(--danger-hover); }

.btn-outline-danger {
  background: transparent;
  color: #dc2626;
  border: 1px solid #fca5a5;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-outline-danger:hover {
  background: #fef2f2;
  border-color: #ef4444;
  color: #b91c1c;
}
:root[data-theme="dark"] .btn-outline-danger {
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.4);
}
:root[data-theme="dark"] .btn-outline-danger:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: #ef4444;
}

.btn-remove-lighting,
.btn-remove-infra {
  background: #fff;
  border: 1px solid #fca5a5;
  color: #dc2626;
  border-radius: 4px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.btn-remove-lighting:hover,
.btn-remove-infra:hover {
  background: #dc2626;
  color: #fff;
  border-color: #dc2626;
}
:root[data-theme="dark"] .btn-remove-lighting,
:root[data-theme="dark"] .btn-remove-infra {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}
:root[data-theme="dark"] .btn-remove-lighting:hover,
:root[data-theme="dark"] .btn-remove-infra:hover {
  background: #dc2626;
  color: #fff;
}

.btn-icon {
  background: transparent;
  color: var(--text-muted);
  padding: 5px 8px;
  font-size: 15px;
}
.btn-icon:hover {
  background: var(--surface-alt);
  color: var(--text);
}

.file-btn {
  position: relative;
  overflow: hidden;
}

/* Бейджи */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.badge-neutral { background: #e2e8f0; color: #334155; }
.badge-admin { background: #dcfce7; color: #166534; }
.badge-viewer { background: #fef3c7; color: #92400e; }
.badge-stage1 { background: #dbeafe; color: #1e40af; }
.badge-stage2 { background: #e2e8f0; color: #0f172a; }
.badge-stage3 { background: #ffedd5; color: #9a3412; }
.badge-tp { background: #fee2e2; color: #991b1b; }
.badge-pole { background: #ede9fe; color: #5b21b6; border: 1px solid #ddd6fe; }
.badge-connpole { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.badge-lighting { background: #fef9c3; color: #854d0e; border: 1px solid #facc15; font-weight: 700; }
.badge-cable { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.badge-cable-project { background: #dbeafe; color: #1d4ed8; border: 1px solid #bfdbfe; font-weight: 600; }

/* Рабочая область */
.workspace {
  flex: 1;
  display: flex;
  min-height: 0;
  position: relative;
}

/* Левый сайдбар */
.sidebar {
  width: 345px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 300;
}

.sidebar.collapsed {
  display: none;
}

.stats-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
}

.stat-item {
  padding: 6px 4px;
  text-align: center;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 48px;
}

.stat-item:nth-child(3n) {
  border-right: none;
}

.stat-item:nth-last-child(-n+3) {
  border-bottom: none;
}

.stat-val {
  display: block;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.15;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.stat-lbl {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1.25;
  margin-top: 2px;
  text-align: center;
  white-space: normal;
}

.stat-item-clickable {
  cursor: pointer;
  transition: background 0.16s ease, box-shadow 0.16s ease;
  user-select: none;
  position: relative;
}

.stat-item-clickable:hover {
  background: rgba(37, 99, 235, 0.08);
}

.stat-item-clickable:hover .stat-lbl {
  color: var(--primary);
}

.stat-item-clickable.stat-item-active {
  background: rgba(37, 99, 235, 0.16);
  box-shadow: inset 0 0 0 2px #2563eb;
}

.stat-item-clickable.stat-item-active .stat-val,
.stat-item-clickable.stat-item-active .stat-lbl {
  color: #1d4ed8;
}

/* Индивидуальные акценты для активных плиток статистики */
.stat-item-clickable[data-stat-filter="lighting"].stat-item-active {
  background: rgba(245, 158, 11, 0.2);
  box-shadow: inset 0 0 0 2px #f59e0b;
}
.stat-item-clickable[data-stat-filter="lighting"].stat-item-active .stat-val,
.stat-item-clickable[data-stat-filter="lighting"].stat-item-active .stat-lbl {
  color: #b45309;
}

.stat-item-clickable[data-stat-filter="conn_poles"].stat-item-active {
  background: rgba(234, 88, 12, 0.16);
  box-shadow: inset 0 0 0 2px #ea580c;
}
.stat-item-clickable[data-stat-filter="conn_poles"].stat-item-active .stat-val,
.stat-item-clickable[data-stat-filter="conn_poles"].stat-item-active .stat-lbl {
  color: #c2410c;
}

.stat-item-clickable[data-stat-filter="cables"].stat-item-active {
  background: rgba(22, 163, 74, 0.16);
  box-shadow: inset 0 0 0 2px #16a34a;
}
.stat-item-clickable[data-stat-filter="cables"].stat-item-active .stat-val,
.stat-item-clickable[data-stat-filter="cables"].stat-item-active .stat-lbl {
  color: #15803d;
}

:root[data-theme="dark"] .stat-item-clickable:hover {
  background: rgba(59, 130, 246, 0.15);
}

:root[data-theme="dark"] .stat-item-clickable:hover .stat-lbl {
  color: #93c5fd;
}

:root[data-theme="dark"] .stat-item-clickable.stat-item-active {
  background: rgba(59, 130, 246, 0.24);
  box-shadow: inset 0 0 0 2px #3b82f6;
}

:root[data-theme="dark"] .stat-item-clickable.stat-item-active .stat-val,
:root[data-theme="dark"] .stat-item-clickable.stat-item-active .stat-lbl {
  color: #93c5fd;
}

:root[data-theme="dark"] .stat-item-clickable[data-stat-filter="lighting"].stat-item-active {
  background: rgba(245, 158, 11, 0.25);
  box-shadow: inset 0 0 0 2px #f59e0b;
}
:root[data-theme="dark"] .stat-item-clickable[data-stat-filter="lighting"].stat-item-active .stat-val,
:root[data-theme="dark"] .stat-item-clickable[data-stat-filter="lighting"].stat-item-active .stat-lbl {
  color: #fde047;
}

:root[data-theme="dark"] .stat-item-clickable[data-stat-filter="conn_poles"].stat-item-active {
  background: rgba(234, 88, 12, 0.24);
  box-shadow: inset 0 0 0 2px #f97316;
}
:root[data-theme="dark"] .stat-item-clickable[data-stat-filter="conn_poles"].stat-item-active .stat-val,
:root[data-theme="dark"] .stat-item-clickable[data-stat-filter="conn_poles"].stat-item-active .stat-lbl {
  color: #fdba74;
}

:root[data-theme="dark"] .stat-item-clickable[data-stat-filter="cables"].stat-item-active {
  background: rgba(22, 163, 74, 0.24);
  box-shadow: inset 0 0 0 2px #22c55e;
}
:root[data-theme="dark"] .stat-item-clickable[data-stat-filter="cables"].stat-item-active .stat-val,
:root[data-theme="dark"] .stat-item-clickable[data-stat-filter="cables"].stat-item-active .stat-lbl {
  color: #86efac;
}

.panel-section {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: 12px;
  margin-bottom: 8px;
}

.select-compact {
  font-size: 11.5px;
  font-weight: 500;
  padding: 3px 7px;
  border: 1.5px solid #cbd5e1;
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

:root[data-theme="dark"] .select-compact {
  border-color: #475569;
}

.layers-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.checkbox-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 11px;
  cursor: pointer;
  background: var(--surface-alt);
  user-select: none;
}
.checkbox-pill input { margin: 0; }

.tabs-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--border);
  gap: 1px;
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  border: none;
  background: var(--surface-alt);
  padding: 8px 6px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.tab-btn:hover {
  color: var(--text);
  background: var(--surface);
}

.tab-btn.active {
  background: var(--surface);
  color: var(--primary);
  font-weight: 700;
  box-shadow: inset 0 -2px 0 var(--primary);
}

/* Пока вкладок 3, 3-я («📊 Отчёт ТУ») занимает второй ряд целиком.
   Как только добавится 4-я вкладка, они автоматически разделят второй ряд пополам (сетка 2x2)! */
.tab-btn:nth-child(3):last-child {
  grid-column: 1 / -1;
}

.filters-box {
  display: flex;
  flex-direction: column;
  gap: 7px;
  background: #f1f5f9;
}

:root[data-theme="dark"] .filters-box {
  background: #161e2e;
}

.search-input, .filters-box select, input[type="text"], input[type="url"], input[type="email"], input[type="password"], input[type="color"], textarea, .inspector select {
  width: 100%;
  padding: 6px 9px;
  border: 1.5px solid #cbd5e1;
  border-radius: 7px;
  font-size: 12px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}

:root[data-theme="dark"] .search-input,
:root[data-theme="dark"] .filters-box select,
:root[data-theme="dark"] input[type="text"],
:root[data-theme="dark"] input[type="url"],
:root[data-theme="dark"] input[type="email"],
:root[data-theme="dark"] input[type="password"],
:root[data-theme="dark"] textarea,
:root[data-theme="dark"] .inspector select {
  border-color: #475569;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.filters-box select:hover,
.inspector select:hover,
input[type="text"]:hover,
input[type="url"]:hover,
textarea:hover {
  border-color: #94a3b8;
}

.search-input:focus, input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.16);
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 9px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  line-height: 1;
  pointer-events: none;
  opacity: 0.75;
}

.search-box .search-input {
  padding: 8px 30px 8px 30px;
  font-size: 13px;
  border: 2px solid #60a5fa;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.14);
}

.search-box .search-input:hover {
  border-color: #3b82f6;
}

.search-box .search-input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.22), 0 2px 8px rgba(37, 99, 235, 0.18);
}

.search-box .search-input:not(:placeholder-shown) {
  border-color: #2563eb;
  background: #eff6ff;
  font-weight: 600;
}

:root[data-theme="dark"] .search-box .search-input {
  background: #0f172a;
  border-color: #3b82f6;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.28);
}

:root[data-theme="dark"] .search-box .search-input:not(:placeholder-shown) {
  background: rgba(37, 99, 235, 0.2);
  border-color: #60a5fa;
}

.search-clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(148, 163, 184, 0.18);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.search-clear:hover {
  background: #cbd5e1;
  color: #0f172a;
}

:root[data-theme="dark"] .search-clear:hover {
  background: #475569;
  color: #ffffff;
}

.filter-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.object-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
}

.list-card {
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 6px;
  cursor: pointer;
  background: var(--surface);
  transition: border-color 0.15s, background 0.15s;
}

.list-card:hover {
  border-color: #93c5fd;
  background: #f8fafc;
}

.list-card.selected {
  border-color: #2563eb !important;
  background: #eff6ff !important;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.45), 0 4px 14px rgba(37, 99, 235, 0.18) !important;
  position: relative;
}

.list-card.selected::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  background: #2563eb;
  border-radius: 4px 0 0 4px;
}

.list-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 4px;
}

.list-card-num {
  font-weight: 700;
  font-size: 12px;
}

.list-card-addr {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  color: #1d4ed8;
  margin-bottom: 4px;
}

.list-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

/* Контейнер карты */
.map-container {
  flex: 1;
  position: relative;
  min-width: 0;
}

.map-canvas {
  width: 100%;
  height: 100%;
}

.map-container.crosshair .leaflet-container,
.map-container.crosshair #yandexMap {
  cursor: crosshair !important;
}

/* Полное скрытие встроенного поиска, копирайтов, рекламы и промо-ссылок Яндекс.Карт */
#yandexMap .ymaps-2-1-79-searchbox,
#yandexMap [class*="searchbox"],
#yandexMap [class*="search-control"],
#yandexMap .ymaps-2-1-79-map-copyrights-promo,
#yandexMap .ymaps-2-1-79-copyrights-promo,
#yandexMap .ymaps-2-1-79-copyright,
#yandexMap .ymaps-2-1-79-gotoymaps,
#yandexMap .ymaps-2-1-79-gototech,
#yandexMap [class*="copyrights-promo"],
#yandexMap [class*="map-copyrights"],
#yandexMap [class*="copyright"],
#yandexMap [class*="gotoymaps"],
#yandexMap [class*="gototech"],
#yandexMap [class*="gototaxi"],
#yandexMap [class*="promo-link"],
#yandexMap [class*="logo-link"],
#yandexMap [class*="logotype"] {
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.map-floating-top-right {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 400;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Компактное поле быстрого поиска точки по координатам */
.coord-search-wrap {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 2px 4px 2px 8px;
  box-shadow: var(--shadow-sm);
  gap: 4px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.coord-search-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.coord-search-icon {
  font-size: 13px;
  user-select: none;
  opacity: 0.85;
}

.coord-search-input {
  border: none;
  outline: none;
  background: transparent;
  font-size: 11.5px;
  color: var(--text);
  width: 170px;
  font-family: inherit;
}

.coord-search-input::placeholder {
  color: var(--text-muted);
  font-size: 11px;
}

.coord-search-go-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 5px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}

.coord-search-go-btn:hover {
  background: #1d4ed8;
}

.coord-search-clear-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  line-height: 1;
}

.coord-search-clear-btn:hover {
  background: var(--surface-alt);
  color: #ef4444;
}

/* Пульсирующая метка найденной точки */
.coord-search-pin {
  position: relative;
}

.coord-pin-icon {
  font-size: 30px;
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.45));
  animation: bouncePin 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.coord-pin-pulse {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 18px;
  height: 18px;
  background: rgba(239, 68, 68, 0.45);
  border-radius: 50%;
  animation: pinPulse 1.5s infinite;
}

@keyframes pinPulse {
  0% { transform: translateX(-50%) scale(0.5); opacity: 1; }
  100% { transform: translateX(-50%) scale(2.8); opacity: 0; }
}

@keyframes bouncePin {
  0% { transform: translateX(-50%) translateY(-24px); opacity: 0; }
  100% { transform: translateX(-50%) translateY(0); opacity: 1; }
}

.basemap-select {
  padding: 5px 8px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 12px;
  box-shadow: var(--shadow-sm);
}

.drawing-hud {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 450;
  background: #0f172a;
  color: #fff;
  padding: 7px 12px;
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 96%;
  white-space: nowrap;
}

.hud-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  white-space: nowrap;
}

.hud-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #22c55e;
  flex-shrink: 0;
  animation: pulse 1.2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.hud-snap {
  background: #2563eb;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.hud-snap-btn {
  background: rgba(30, 41, 59, 0.85);
  border: 1px solid rgba(59, 130, 246, 0.4);
  color: #93c5fd;
  border-radius: 6px;
  padding: 4px 9px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  user-select: none;
  white-space: nowrap;
}

.hud-snap-btn:hover {
  background: rgba(37, 99, 235, 0.4);
  border-color: #60a5fa;
  color: #fff;
}

.hud-snap-btn.active {
  background: rgba(37, 99, 235, 0.85);
  border-color: #3b82f6;
  color: #ffffff;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.4);
}

.hud-actions {
  display: flex;
  gap: 6px;
}

.map-legend {
  position: absolute;
  bottom: 12px;
  left: 12px;
  z-index: 400;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(4px);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 11px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  box-shadow: var(--shadow-sm);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

/* Правый инспектор */
.inspector {
  width: 375px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 350;
}

.inspector-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  background: var(--surface-alt);
}

.inspector-header h2 {
  margin: 5px 0 0;
  font-size: 15px;
  line-height: 1.3;
}

.inspector-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.insp-block {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: var(--surface);
}

.insp-block-lighting {
  border-color: #fcd34d;
  background: #fffdf5;
  box-shadow: 0 1px 4px rgba(245, 158, 11, 0.08);
}

.insp-block-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.kv-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 0;
  border-bottom: 1px dashed #f1f5f9;
  font-size: 12px;
}
.kv-row:last-child { border-bottom: none; }

.kv-key {
  color: var(--text-muted);
  flex-shrink: 0;
}

.kv-val {
  text-align: right;
  font-weight: 500;
  word-break: break-word;
}

.kv-val-addr {
  font-size: 13.5px;
  font-weight: 700;
  color: #1d4ed8;
  line-height: 1.35;
}

.field-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 8px;
}

.field-label:last-child { margin-bottom: 0; }

.link-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 7px;
  color: #1d4ed8;
  text-decoration: none;
  font-weight: 600;
  font-size: 12px;
  margin-bottom: 6px;
}
.link-btn:hover { background: #dbeafe; }

.link-btn-green {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #15803d;
}
.link-btn-green:hover { background: #dcfce7; }

.link-btn-disabled {
  background: #f8fafc;
  border-color: #e2e8f0;
  color: #64748b;
  cursor: default;
  font-weight: 500;
  opacity: 0.9;
  user-select: text;
}
.link-btn-disabled:hover { background: #f8fafc; }

.link-btn-tag {
  font-size: 10px;
  font-weight: 600;
  color: #94a3b8;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 1px 5px;
  flex-shrink: 0;
  margin-left: 8px;
}

.link-btn-telegram {
  background: linear-gradient(135deg, #24a1de 0%, #0088cc 100%);
  border: 1px solid #1a87be;
  color: #ffffff !important;
  font-weight: 600;
  padding: 9px 12px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 136, 204, 0.28);
  transition: all 0.18s ease;
}
.link-btn-telegram:hover {
  background: linear-gradient(135deg, #2bb5f8 0%, #0099e6 100%);
  border-color: #2bb5f8;
  color: #ffffff !important;
  box-shadow: 0 4px 14px rgba(0, 136, 204, 0.42);
  transform: translateY(-1px);
}
.link-btn-telegram:active {
  transform: translateY(0);
}

.link-btn-tag-blue {
  font-size: 11px;
  font-weight: 700;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: 5px;
  padding: 2px 7px;
  flex-shrink: 0;
  margin-left: 8px;
  backdrop-filter: blur(4px);
  letter-spacing: 0.2px;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.link-btn-telegram:hover .link-btn-tag-blue {
  background: rgba(255, 255, 255, 0.32);
  border-color: rgba(255, 255, 255, 0.55);
}

.badge-telegram {
  background: #e0f2fe;
  color: #0284c7;
  border: 1px solid #bae6fd;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 1px 5px;
  border-radius: 4px;
  transition: all 0.15s ease;
}
.badge-telegram:hover {
  background: #0284c7;
  color: #ffffff;
  border-color: #0284c7;
  transform: translateY(-1px);
}

.badge-telegram-tag {
  background: #e0f2fe;
  color: #0284c7;
  border: 1px solid #bae6fd;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ============================================================================
   ВЕТКА КОММЕНТАРИЕВ (ДОПОЛНИТЕЛЬНАЯ ИНФОРМАЦИЯ ПО ТОЧКЕ)
   ============================================================================ */
.comments-thread {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 8px;
  max-height: 250px;
  overflow-y: auto;
  padding-right: 2px;
}

.comment-card {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 8px 10px;
  transition: all 0.15s ease;
}

.comment-card:hover {
  border-color: #cbd5e1;
}

:root[data-theme="dark"] .comment-card {
  background: #1e293b;
  border-color: #334155;
}

:root[data-theme="dark"] .comment-card:hover {
  border-color: #475569;
}

.comment-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 5px;
}

.comment-author-info {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.comment-author-badge {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--primary);
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  padding: 1px 7px;
  border-radius: 999px;
  line-height: 1.3;
}

:root[data-theme="dark"] .comment-author-badge {
  background: rgba(59, 130, 246, 0.2);
  border-color: rgba(59, 130, 246, 0.4);
  color: #93c5fd;
}

.comment-time {
  font-size: 10px;
  color: var(--text-muted);
}

.btn-del-comment {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  padding: 2px 5px;
  border-radius: 5px;
  cursor: pointer;
  opacity: 0.65;
  transition: all 0.15s ease;
  line-height: 1;
}

.btn-del-comment:hover {
  opacity: 1;
  background: #fee2e2;
  color: var(--danger);
  transform: scale(1.1);
}

:root[data-theme="dark"] .btn-del-comment:hover {
  background: rgba(239, 68, 68, 0.25);
  color: #fca5a5;
}

.comment-body-text {
  font-size: 12px;
  color: var(--text);
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.comments-empty {
  padding: 12px 10px;
  text-align: center;
  background: var(--surface-alt);
  border: 1px dashed var(--border);
  border-radius: 7px;
  font-size: 12px;
  color: var(--text-muted);
}

:root[data-theme="dark"] .comments-empty {
  background: rgba(30, 41, 59, 0.5);
  border-color: #334155;
}

.comment-add-box textarea {
  width: 100%;
  resize: vertical;
  min-height: 52px;
  border-radius: 6px;
  padding: 6px 9px;
  font-family: inherit;
  font-size: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  line-height: 1.35;
}

.comment-add-box textarea:focus {
  outline: none;
  border-color: var(--primary);
}

/* Модальные окна */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-card {
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.modal-lg {
  max-width: 650px;
}

.modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.modal-header h3 { margin: 0; font-size: 15px; }

.modal-body {
  padding: 16px 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  flex: 1 1 auto;
}

.modal-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

/* Модальное окно чата по точке (правый клик) */
.camera-chat-card {
  max-width: 530px;
  height: 580px;
  max-height: 88vh;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.25);
  animation: modalFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.chat-modal-header-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

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

.btn-chat-tg {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #0284c7;
  color: #ffffff !important;
  font-size: 11px;
  font-weight: 600;
  padding: 2.5px 9px;
  border-radius: 6px;
  text-decoration: none;
  white-space: nowrap;
  border: 1px solid #0284c7;
  transition: all 0.15s ease;
}
.btn-chat-tg:hover {
  background: #0369a1;
  border-color: #0369a1;
  transform: translateY(-1px);
}

.btn-chat-tg-action {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: #f0f9ff;
  color: #0284c7;
  border: 1px solid #bae6fd;
  font-size: 10.5px;
  font-weight: 600;
  padding: 2.5px 8px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}
.btn-chat-tg-action:hover {
  background: #e0f2fe;
  color: #0369a1;
  border-color: #7dd3fc;
}

.chat-modal-badge {
  font-size: 11px;
  font-weight: 700;
  color: #2563eb;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  padding: 1px 7px;
  border-radius: 999px;
  white-space: nowrap;
}

:root[data-theme="dark"] .chat-modal-badge {
  background: rgba(37, 99, 235, 0.2);
  border-color: rgba(59, 130, 246, 0.4);
  color: #93c5fd;
}

.chat-modal-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-modal-address {
  font-size: 11.5px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 420px;
}

.chat-modal-body {
  flex: 1;
  padding: 14px 16px;
  overflow-y: auto;
  background: var(--surface-alt);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

:root[data-theme="dark"] .chat-modal-body {
  background: #0b1120;
}

.chat-messages-container {
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-height: 100%;
}

.chat-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  transition: all 0.15s ease;
}

:root[data-theme="dark"] .chat-bubble {
  background: #1e293b;
  border-color: #334155;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.chat-bubble.is-self {
  border-color: #93c5fd;
  background: #f0f7ff;
}

:root[data-theme="dark"] .chat-bubble.is-self {
  background: rgba(37, 99, 235, 0.15);
  border-color: rgba(59, 130, 246, 0.4);
}

.chat-bubble-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 5px;
}

.chat-bubble-author {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text);
}

.chat-bubble-icon {
  font-size: 11px;
}

.chat-bubble-self-badge {
  font-size: 9.5px;
  font-weight: 700;
  color: #1d4ed8;
  background: #dbeafe;
  padding: 0 5px;
  border-radius: 4px;
}

:root[data-theme="dark"] .chat-bubble-self-badge {
  color: #93c5fd;
  background: rgba(59, 130, 246, 0.35);
}

.chat-bubble-time {
  font-size: 10.5px;
  color: var(--text-muted);
}

.chat-bubble-del {
  background: none;
  border: none;
  cursor: pointer;
  padding: 1px 4px;
  border-radius: 4px;
  font-size: 12px;
  opacity: 0.65;
  transition: all 0.15s ease;
}

.chat-bubble-del:hover {
  opacity: 1;
  background: rgba(239, 68, 68, 0.15);
}

.chat-bubble-text {
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-empty-state {
  text-align: center;
  margin: auto;
  padding: 30px 14px;
  color: var(--text-muted);
}

.chat-modal-footer {
  padding: 12px 16px 10px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

:root[data-theme="dark"] .chat-modal-footer {
  background: #1e293b;
  border-color: #334155;
}

.chat-input-wrapper {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

#chatModalInput {
  flex: 1;
  resize: none;
  font-family: inherit;
  font-size: 12.5px;
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 8px 10px;
  line-height: 1.35;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease;
}

#chatModalInput:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

:root[data-theme="dark"] #chatModalInput {
  background: #0f172a;
  color: #f8fafc;
  border-color: #334155;
}

:root[data-theme="dark"] #chatModalInput:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.2);
}

.btn-chat-send {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 42px;
  padding: 0 16px;
  font-weight: 600;
  flex-shrink: 0;
  border-radius: 8px;
}

.send-arrow {
  font-size: 11px;
}

.chat-footer-hint {
  font-size: 10.5px;
  color: var(--text-muted);
  text-align: center;
}

.settings-section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}
.settings-section h4 {
  margin: 0 0 6px;
  font-size: 13px;
}

.hint {
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.45;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.danger-zone {
  border-color: #fecaca;
  background: #fef2f2;
}

/* Уведомления (Toast) */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: #0f172a;
  color: #fff;
  padding: 9px 14px;
  border-radius: 8px;
  font-size: 12px;
  box-shadow: var(--shadow-md);
  max-width: 340px;
  animation: fadeIn 0.2s ease;
}
.toast.success { background: #15803d; }
.toast.error { background: #b91c1c; }
.toast.info { background: #1e40af; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Кастомные маркеры Leaflet */
.custom-pin {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* Выделенный маркер (камера, ТП, опора) */
.custom-pin.pin-selected {
  z-index: 10000 !important;
}

.custom-pin.pin-selected .pin-label {
  background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 100%) !important;
  color: #ffffff !important;
  font-weight: 800 !important;
  font-size: 11px !important;
  padding: 2.5px 8px !important;
  border: 1.5px solid #93c5fd !important;
  border-radius: 6px !important;
  box-shadow: 0 4px 14px rgba(29, 78, 216, 0.6), 0 0 0 2px rgba(255, 255, 255, 0.9) !important;
  transform: translateX(-50%) scale(1.15) !important;
  top: -24px !important;
  z-index: 10001 !important;
}

/* Радарная волна вокруг выбранного маркера */
.pin-selection-radar {
  position: absolute;
  width: 54px;
  height: 54px;
  top: 50%;
  left: 50%;
  margin-top: -27px;
  margin-left: -27px;
  border-radius: 50%;
  border: 3px solid #2563eb;
  background: rgba(37, 99, 235, 0.2);
  pointer-events: none;
  animation: pinRadarWave 1.6s infinite ease-out;
  z-index: -1;
}

/* Мягкое неоновое свечение ядра выбранного маркера */
.pin-selection-glow {
  position: absolute;
  width: 38px;
  height: 38px;
  top: 50%;
  left: 50%;
  margin-top: -19px;
  margin-left: -19px;
  border-radius: 50%;
  border: 2px solid #60a5fa;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.5) 0%, rgba(37, 99, 235, 0.15) 70%, transparent 100%);
  pointer-events: none;
  animation: pinGlowBreathe 2s infinite ease-in-out;
  z-index: -1;
}

@keyframes pinRadarWave {
  0% {
    transform: scale(0.65);
    opacity: 0.95;
    box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.85);
  }
  70% {
    transform: scale(1.65);
    opacity: 0;
    box-shadow: 0 0 0 18px rgba(37, 99, 235, 0);
  }
  100% {
    transform: scale(1.65);
    opacity: 0;
  }
}

@keyframes pinGlowBreathe {
  0%, 100% {
    transform: scale(1);
    opacity: 0.85;
  }
  50% {
    transform: scale(1.22);
    opacity: 1;
  }
}

/* ============================================================================
   ВЫДЕЛЕНИЕ КАБЕЛЬНЫХ ЛИНИЙ (LEAFLET & YANDEX)
   ============================================================================ */

/* Подложка выделенной линии (неоновый световой ореол) */
.selected-cable-halo {
  stroke: #38bdf8 !important;
  stroke-linecap: round !important;
  stroke-linejoin: round !important;
  opacity: 0.9 !important;
  filter: drop-shadow(0 0 6px rgba(56, 189, 248, 0.95)) drop-shadow(0 0 12px rgba(37, 99, 235, 0.8));
  animation: cableHaloBreathe 1.8s infinite ease-in-out;
  pointer-events: none;
}

/* Ядро выделенной линии с бегущим импульсом тока */
.selected-cable-core {
  stroke-linecap: round !important;
  stroke-linejoin: round !important;
  animation: cableFlowMove 1.2s infinite linear;
}

@keyframes cableHaloBreathe {
  0%, 100% {
    opacity: 0.75;
    filter: drop-shadow(0 0 5px rgba(56, 189, 248, 0.8));
  }
  50% {
    opacity: 1;
    filter: drop-shadow(0 0 10px rgba(56, 189, 248, 1)) drop-shadow(0 0 16px rgba(37, 99, 235, 0.9));
  }
}

@keyframes cableFlowMove {
  from {
    stroke-dashoffset: 20;
  }
  to {
    stroke-dashoffset: 0;
  }
}

/* Маркеры концов (А и В) выбранной линии */
.cable-node-marker {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  z-index: 10005 !important;
}

.cable-node-pulse {
  position: absolute;
  width: 44px;
  height: 44px;
  top: 50%;
  left: 50%;
  margin-top: -22px;
  margin-left: -22px;
  border-radius: 50%;
  pointer-events: none;
  animation: cableNodePulse 1.6s infinite ease-out;
  z-index: -1;
}

.cable-node-start .cable-node-pulse {
  border: 2.5px solid #22c55e;
  background: rgba(34, 197, 94, 0.25);
}

.cable-node-end .cable-node-pulse {
  border: 2.5px solid #ef4444;
  background: rgba(239, 68, 68, 0.25);
}

@keyframes cableNodePulse {
  0% {
    transform: scale(0.55);
    opacity: 0.95;
  }
  70% {
    transform: scale(1.6);
    opacity: 0;
  }
  100% {
    transform: scale(1.6);
    opacity: 0;
  }
}

.cable-node-circle {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.45), 0 0 0 2px #ffffff;
}

.cable-node-start .cable-node-circle {
  background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
  border: 1.5px solid #86efac;
}

.cable-node-end .cable-node-circle {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  border: 1.5px solid #fca5a5;
}

.cable-node-tag {
  position: absolute;
  top: -24px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 10.5px;
  font-weight: 800;
  padding: 2.5px 8px;
  border-radius: 6px;
  color: #ffffff;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  z-index: 10006;
}

.cable-node-start .cable-node-tag {
  background: linear-gradient(135deg, #15803d 0%, #166534 100%);
  border: 1.5px solid #86efac;
}

.cable-node-end .cable-node-tag {
  background: linear-gradient(135deg, #b91c1c 0%, #991b1b 100%);
  border: 1.5px solid #fca5a5;
}

/* Промежуточные изломы/вершины выбранной линии */
.cable-vertex-pin {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  border: 2.5px solid #2563eb;
  color: #1e40af;
  font-size: 9.5px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.45), 0 0 0 2px rgba(255, 255, 255, 0.9);
  cursor: pointer;
  transition: transform 0.15s ease;
  z-index: 10003 !important;
}

.cable-vertex-pin:hover {
  transform: scale(1.3);
  background: #eff6ff;
  border-color: #1d4ed8;
}

/* Центральный парящий бейдж выбранной линии */
.cable-mid-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #0f172a;
  color: #f8fafc;
  border: 1.5px solid #38bdf8;
  border-radius: 20px;
  padding: 3.5px 12px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45), 0 0 10px rgba(56, 189, 248, 0.4);
  transform: translate(-50%, -50%);
  pointer-events: auto;
  cursor: pointer;
  z-index: 10004 !important;
  animation: cableMidBadgeFloat 2.4s infinite ease-in-out;
}

.cable-mid-badge .mid-badge-len {
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.18);
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 800;
}

@keyframes cableMidBadgeFloat {
  0%, 100% {
    transform: translate(-50%, -50%) scale(1);
  }
  50% {
    transform: translate(-50%, -58%) scale(1.04);
  }
}

.pin-label {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.85);
  color: #fff;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
}

/* Бейдж комментариев над маркером камеры на карте */
.pin-comment-badge {
  position: absolute;
  top: -11px;
  right: -11px;
  background: #ef4444;
  background: linear-gradient(135deg, #f87171 0%, #dc2626 100%);
  color: #ffffff;
  border: 2px solid #ffffff;
  border-radius: 999px;
  padding: 0 5px;
  font-size: 11px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5px;
  box-shadow: 0 3px 10px rgba(220, 38, 38, 0.55), 0 0 0 1px rgba(0, 0, 0, 0.15);
  animation: pulseCommentBadge 2s infinite ease-in-out;
  pointer-events: none;
  z-index: 100;
  min-width: 22px;
  height: 22px;
  line-height: 1;
}

@keyframes pulseCommentBadge {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 3px 10px rgba(220, 38, 38, 0.55), 0 0 0 1px rgba(0, 0, 0, 0.15);
  }
  50% {
    transform: scale(1.22);
    box-shadow: 0 0 18px rgba(239, 68, 68, 0.95), 0 0 0 1px rgba(0, 0, 0, 0.2);
  }
}

.pin-comment-badge .badge-cnt {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: -0.5px;
}

/* Бейджи комментариев в карточках списка камер */
.badge-comment {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #dc2626;
  font-weight: 700;
  font-size: 10.5px;
  padding: 2px 7px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

:root[data-theme="dark"] .badge-comment {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.45);
  color: #fca5a5;
}

.list-card-comment-snippet {
  font-size: 11px;
  color: #b91c1c;
  background: #fff5f5;
  border: 1px solid #fee2e2;
  border-radius: 6px;
  padding: 3px 8px;
  margin-top: 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

:root[data-theme="dark"] .list-card-comment-snippet {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

/* ============================================================================
   АДАПТИВ ВЕРХНЕЙ ПАНЕЛИ: ДВУХРЯДНЫЙ РЕЖИМ ДЛЯ НОУТБУКОВ И УЗКИХ ЭКРАНОВ
   ============================================================================ */

/* Кнопка "Отчёт ТУ" в верхней панели не нужна (она всегда доступна в левом сайдбаре) */
#openReportModalBtn {
  display: none !important;
}

/* На экранах мониторов и ноутбуков (<= 2280px) верхняя панель переходит в просторный двухрядный режим:
   Ряд 1: Бренд и подзаголовок (слева) + Все элементы управления и визитка разработчика (справа)
   Ряд 2: Инженерная лента инструментов черчения (начинается ровно под кнопкой "Онлайн")
*/
@media (max-width: 2280px) {
  .topbar {
    height: auto !important;
    min-height: 60px;
    padding: 7px 14px 7px 10px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-rows: auto auto;
    row-gap: 6px;
    column-gap: 16px;
    align-items: center;
    overflow-x: clip;
  }

  .topbar-left {
    grid-column: 1 / 2;
    grid-row: 1 / 2;
    align-self: center;
  }

  /* Колонка 2 (1fr) создает гибкий воздух между брендом и функциональными кнопками */

  .topbar-right {
    grid-column: 3 / 4;
    grid-row: 1 / 2;
    justify-self: end;
    justify-content: flex-end;
    gap: 6px;
    align-self: center;
  }

  .editor-toolbar {
    grid-column: 1 / -1;
    grid-row: 2 / 3;
    justify-self: center;
    display: flex;
    align-items: center;
    gap: 3px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    padding: 3px 6px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    max-width: 100%;
  }

  /* Гарантируем, что подзаголовок бренда и подпись "РАЗРАБОТЧИК" всегда полностью видны */
  .brand-subtitle {
    display: block !important;
  }

  .dev-badge-role {
    display: block !important;
  }

  .dev-badge-name {
    display: block !important;
  }
}

/* Тонкая подстройка для средних и компактных ноутбуков (1366px - 1440px) */
@media (max-width: 1440px) {
  .topbar {
    padding: 6px 12px 6px 8px;
    column-gap: 10px;
    row-gap: 5px;
  }

  .brand-logo-wrap,
  .brand-logo-svg {
    width: 38px;
    height: 38px;
  }

  .brand-title {
    font-size: 18px;
  }

  .brand-subtitle {
    font-size: 10px;
  }

  .dev-badge {
    gap: 7px;
    padding: 4px 11px 4px 5px;
  }

  .dev-badge-avatar {
    width: 29px;
    height: 29px;
    font-size: 11.5px;
  }

  .dev-badge-role {
    font-size: 8.5px;
  }

  .dev-badge-name {
    font-size: 13px;
  }

  .topbar-right {
    gap: 4px;
  }

  .topbar-right .btn-sm {
    padding: 4px 7px;
    font-size: 11px;
  }

  .role-box {
    gap: 4px;
  }

  #demoRoleSwitchBtn {
    padding: 3px 6px;
    font-size: 10.5px;
  }

  .tool-btn {
    padding: 4px 7px;
    font-size: 11px;
  }
}

/* Для компактных экранов до 1280px */
@media (max-width: 1280px) {
  .online-label {
    display: none;
  }

  .theme-text {
    display: none;
  }

  .tool-btn {
    padding: 3px 5px;
    font-size: 10.5px;
  }

  .topbar-right {
    gap: 3px;
  }

  .topbar-right .btn-sm {
    padding: 3px 6px;
    font-size: 10.5px;
  }

  .brand-logo-wrap,
  .brand-logo-svg {
    width: 34px;
    height: 34px;
  }

  .brand-title {
    font-size: 15.5px;
  }

  .brand-subtitle {
    font-size: 9px;
    display: block !important;
  }

  .dev-badge {
    gap: 6px;
    padding: 3px 9px 3px 4px;
  }

  .dev-badge-avatar {
    width: 26px;
    height: 26px;
    font-size: 10.5px;
  }

  .dev-badge-role {
    font-size: 8px;
  }

  .dev-badge-name {
    font-size: 12px;
  }
}

/* При сильном сжатии окна (до 1050px) */
@media (max-width: 1050px) {
  .topbar {
    overflow-x: auto;
    overflow-y: hidden;
  }
}

@media (max-width: 960px) {
  .sidebar { width: 280px; }
  .inspector {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 320px;
    box-shadow: var(--shadow-md);
  }
}

/* ============================================================================
   ПЕРЕКЛЮЧАТЕЛЬ ТЕМЫ (СВЕТЛАЯ / ТЕМНАЯ)
   ============================================================================ */
.theme-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
}

.theme-toggle-btn:hover {
  background: var(--surface-alt);
  border-color: var(--primary);
  transform: translateY(-1px);
}

.theme-icon {
  font-size: 13px;
  line-height: 1;
  display: inline-block;
  transition: transform 0.25s ease;
}

.theme-toggle-btn:hover .theme-icon {
  transform: rotate(20deg) scale(1.18);
}

/* ============================================================================
   ПРАВИЛА И СТИЛИ ТЁМНОЙ ТЕМЫ (data-theme="dark")
   ============================================================================ */
:root[data-theme="dark"] .theme-toggle-btn {
  background: #1e293b;
  border-color: #475569;
  color: #fef08a; /* Солнечный акцент */
}

:root[data-theme="dark"] .theme-toggle-btn:hover {
  background: #334155;
  border-color: #facc15;
}

:root[data-theme="dark"] .tool-btn:hover,
:root[data-theme="dark"] .btn-secondary:hover,
:root[data-theme="dark"] .search-clear:hover {
  background: #334155;
}

:root[data-theme="dark"] .btn-white {
  background: #1e293b;
  color: var(--text);
  border-color: #475569;
}
:root[data-theme="dark"] .btn-white:hover {
  background: #334155;
}

/* Карточки в списке */
:root[data-theme="dark"] .list-card:hover {
  background: #1e293b;
  border-color: #60a5fa;
}

:root[data-theme="dark"] .list-card.selected {
  background: rgba(37, 99, 235, 0.25) !important;
  border-color: #60a5fa !important;
  box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.45), 0 4px 16px rgba(0, 0, 0, 0.4) !important;
}

:root[data-theme="dark"] .list-card.selected::before {
  background: #60a5fa;
}

/* Блоки инспектора */
:root[data-theme="dark"] .insp-block-lighting {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.45);
}

:root[data-theme="dark"] .kv-row {
  border-bottom-color: #1e293b;
}

:root[data-theme="dark"] .kv-val-addr {
  color: #60a5fa;
}

/* Кнопки ссылок на таблицы */
:root[data-theme="dark"] .link-btn {
  background: rgba(37, 99, 235, 0.16);
  border-color: rgba(59, 130, 246, 0.35);
  color: #93c5fd;
}
:root[data-theme="dark"] .link-btn:hover {
  background: rgba(37, 99, 235, 0.28);
}

:root[data-theme="dark"] .link-btn-green {
  background: rgba(22, 163, 74, 0.16);
  border-color: rgba(34, 197, 94, 0.35);
  color: #86efac;
}
:root[data-theme="dark"] .link-btn-green:hover {
  background: rgba(22, 163, 74, 0.28);
}

:root[data-theme="dark"] .link-btn-disabled {
  background: #1e293b;
  border-color: #334155;
  color: #64748b;
}

:root[data-theme="dark"] .link-btn-tag {
  background: #0f172a;
  border-color: #334155;
  color: #94a3b8;
}

:root[data-theme="dark"] .link-btn-telegram {
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  border-color: rgba(56, 189, 248, 0.45);
  color: #ffffff !important;
  box-shadow: 0 2px 10px rgba(2, 132, 199, 0.35);
}
:root[data-theme="dark"] .link-btn-telegram:hover {
  background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
  border-color: #38bdf8;
  color: #ffffff !important;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.5);
}
:root[data-theme="dark"] .link-btn-tag-blue {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.35);
  color: #ffffff;
}
:root[data-theme="dark"] .link-btn-telegram:hover .link-btn-tag-blue {
  background: rgba(255, 255, 255, 0.3);
}
:root[data-theme="dark"] .badge-telegram {
  background: rgba(2, 132, 199, 0.18);
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.35);
}
:root[data-theme="dark"] .badge-telegram:hover {
  background: #0284c7;
  color: #ffffff;
}
:root[data-theme="dark"] .badge-telegram-tag {
  background: rgba(2, 132, 199, 0.18);
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.35);
}
:root[data-theme="dark"] .btn-chat-tg {
  background: #0284c7;
  border-color: #0284c7;
  color: #ffffff !important;
}
:root[data-theme="dark"] .btn-chat-tg-action {
  background: rgba(2, 132, 199, 0.15);
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.35);
}
:root[data-theme="dark"] .btn-chat-tg-action:hover {
  background: rgba(2, 132, 199, 0.25);
  border-color: rgba(56, 189, 248, 0.5);
}

/* Бейджи статусов и элементов */
:root[data-theme="dark"] .badge-neutral {
  background: #334155;
  color: #e2e8f0;
}
:root[data-theme="dark"] .badge-admin {
  background: rgba(34, 197, 94, 0.18);
  color: #86efac;
  border: 1px solid rgba(34, 197, 94, 0.35);
}
:root[data-theme="dark"] .badge-viewer {
  background: rgba(245, 158, 11, 0.18);
  color: #fde68a;
  border: 1px solid rgba(245, 158, 11, 0.35);
}
:root[data-theme="dark"] .badge-stage1 {
  background: rgba(59, 130, 246, 0.22);
  color: #93c5fd;
}
:root[data-theme="dark"] .badge-stage2 {
  background: #334155;
  color: #f1f5f9;
}
:root[data-theme="dark"] .badge-stage3 {
  background: rgba(249, 115, 22, 0.22);
  color: #fdba74;
}
:root[data-theme="dark"] .badge-tp {
  background: rgba(239, 68, 68, 0.22);
  color: #fca5a5;
}
:root[data-theme="dark"] .badge-pole {
  background: rgba(124, 58, 237, 0.22);
  color: #c4b5fd;
  border: 1px solid rgba(167, 139, 250, 0.4);
}
:root[data-theme="dark"] .badge-connpole {
  background: rgba(245, 158, 11, 0.22);
  color: #fde047;
  border: 1px solid rgba(245, 158, 11, 0.45);
}
:root[data-theme="dark"] .badge-lighting {
  background: rgba(234, 179, 8, 0.22);
  color: #fef08a;
  border: 1px solid rgba(234, 179, 8, 0.5);
}
:root[data-theme="dark"] .badge-cable {
  background: rgba(34, 197, 94, 0.2);
  border: 1px solid rgba(34, 197, 94, 0.4);
  color: #86efac;
}
:root[data-theme="dark"] .badge-cable-project {
  background: rgba(37, 99, 235, 0.22);
  border: 1px solid rgba(59, 130, 246, 0.4);
  color: #93c5fd;
}

/* Элементы карты Leaflet */
:root[data-theme="dark"] .map-legend {
  background: rgba(17, 24, 39, 0.92);
  border-color: #334155;
  color: #f8fafc;
}

:root[data-theme="dark"] .basemap-select {
  background: #111827;
  border-color: #334155;
  color: #f8fafc;
}

:root[data-theme="dark"] .leaflet-container {
  background: #0b0f19;
}

:root[data-theme="dark"] .leaflet-bar a {
  background-color: #1e293b;
  border-bottom-color: #334155;
  color: #f8fafc;
}

:root[data-theme="dark"] .leaflet-bar a:hover {
  background-color: #334155;
  color: #ffffff;
}

:root[data-theme="dark"] .leaflet-popup-content-wrapper,
:root[data-theme="dark"] .leaflet-popup-tip {
  background: #1e293b;
  color: #f8fafc;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.6);
}

:root[data-theme="dark"] .leaflet-container a.leaflet-popup-close-button {
  color: #94a3b8;
}

:root[data-theme="dark"] .leaflet-container a.leaflet-popup-close-button:hover {
  color: #ffffff;
}

/* Плавный переход подложки карты при смене темы */
.leaflet-tile-pane,
#yandexMap [class*="pane_ground"],
#yandexMap [class*="ground-pane"] {
  transition: filter 0.35s ease;
}

/* Тёмная тема для тайлов карты (Leaflet и Яндекс.Карты) */
:root[data-theme="dark"] .map-container:not(.map-satellite) .leaflet-tile-pane,
:root[data-theme="dark"] .map-container:not(.map-satellite) #yandexMap [class*="pane_ground"],
:root[data-theme="dark"] .map-container:not(.map-satellite) #yandexMap [class*="ground-pane"],
:root[data-theme="dark"] .map-container:not(.map-satellite) #yandexMap [class*="pane_tiles"],
:root[data-theme="dark"] .map-container:not(.map-satellite) #yandexMap [class*="tiles-pane"],
:root[data-theme="dark"] .map-container:not(.map-satellite) #yandexMap [class*="layer-pane"] {
  filter: brightness(0.65) invert(1) contrast(2.6) hue-rotate(200deg) saturate(0.35) brightness(0.75) !important;
}

/* Копирайт Leaflet в тёмной теме */
:root[data-theme="dark"] .leaflet-control-attribution {
  background: rgba(17, 24, 39, 0.85) !important;
  color: #94a3b8 !important;
}
:root[data-theme="dark"] .leaflet-control-attribution a {
  color: #60a5fa !important;
}

:root[data-theme="dark"] .leaflet-container,
:root[data-theme="dark"] .map-container,
:root[data-theme="dark"] #leafletMap,
:root[data-theme="dark"] #yandexMap {
  background: #0f172a !important;
}

/* Модальные окна */
:root[data-theme="dark"] .modal-backdrop {
  background: rgba(0, 0, 0, 0.75);
}

:root[data-theme="dark"] .danger-zone {
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.08);
}

:root[data-theme="dark"] .auth-error {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
}

/* Стилизация скроллбаров под тёмную тему */
:root[data-theme="dark"] ::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}
:root[data-theme="dark"] ::-webkit-scrollbar-track {
  background: #0b0f19;
}
:root[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: 4px;
}
:root[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
  background: #475569;
}

@media (max-width: 1240px) {
  .theme-text { display: none; }
  .online-label { display: none; }
}

@media (max-width: 600px) {
  .online-dropdown {
    right: -40px;
    min-width: 260px;
  }
}

/* ============================================================================
   ОТЧЕТ И АНАЛИТИКА ПО СТАТУСАМ ТУ (ГРАФИКИ И СВОДКА)
   ============================================================================ */

.report-panel {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.report-header-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  box-shadow: var(--shadow-sm);
}

.report-header-info h4 {
  margin: 0;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
}

.report-header-info span {
  font-size: 11px;
  color: var(--text-muted);
}

.report-kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.report-kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 9px 11px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: relative;
  overflow: hidden;
}

.report-kpi-card.kpi-card-clickable {
  cursor: pointer;
  transition: transform 0.16s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.16s ease, border-color 0.16s ease, background-color 0.16s ease;
  user-select: none;
}

.report-kpi-card.kpi-card-clickable:hover {
  transform: translateY(-2px);
  border-color: var(--kpi-color, var(--primary));
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.09);
}

.report-kpi-card.kpi-card-clickable:active {
  transform: translateY(0);
}

.report-kpi-card.kpi-card-clickable.active {
  border-color: var(--kpi-color, var(--primary)) !important;
  box-shadow: 0 0 0 2px var(--kpi-color, var(--primary)), 0 4px 14px rgba(0, 0, 0, 0.12);
  background: var(--surface-alt);
}

.report-kpi-card.kpi-card-clickable.active::after {
  content: "●";
  position: absolute;
  top: 5px;
  right: 7px;
  font-size: 10px;
  color: var(--kpi-color, var(--primary));
}

.smr-stage-card.stage-card-clickable {
  cursor: pointer;
  transition: transform 0.16s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.16s ease, border-color 0.16s ease, background-color 0.16s ease;
  user-select: none;
}

.smr-stage-card.stage-card-clickable:hover {
  transform: translateY(-2px);
  border-color: var(--stage-color, var(--primary));
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}

.smr-stage-card.stage-card-clickable:active {
  transform: translateY(0);
}

.smr-stage-card.stage-card-clickable.active {
  border-color: var(--stage-color, var(--primary)) !important;
  box-shadow: 0 0 0 2px var(--stage-color, var(--primary)), 0 4px 14px rgba(0, 0, 0, 0.12);
  background: var(--surface-alt);
}

.report-kpi-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  background: var(--kpi-color, var(--primary));
}

.report-kpi-val {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.1;
}

.report-kpi-label {
  font-size: 10.5px;
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.report-chart-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.report-chart-title {
  width: 100%;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.donut-chart-box {
  position: relative;
  width: 180px;
  height: 180px;
  margin: 6px 0 10px 0;
}

.donut-chart-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.donut-chart-center {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.donut-center-num {
  font-size: 26px;
  font-weight: 900;
  color: var(--text);
  line-height: 1;
}

.donut-center-sub {
  font-size: 9.5px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

.donut-segment {
  cursor: pointer;
  transition: stroke-width 0.2s ease, opacity 0.2s ease;
}

.donut-segment:hover {
  stroke-width: 26;
  opacity: 0.9;
}

/* Список полос распределения по статусам */
.report-bars-box {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 6px;
}

.report-bar-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  transition: background 0.15s ease;
}

.report-bar-row:hover {
  background: var(--surface-alt);
}

.report-bar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11.5px;
}

.report-bar-title {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--text);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
}

.report-bar-val {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.report-bar-val b {
  color: var(--text);
  font-size: 12px;
}

.report-bar-track {
  width: 100%;
  height: 6px;
  background: var(--surface-alt);
  border-radius: 999px;
  overflow: hidden;
}

.report-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Модальное окно полноэкранного отчета */
.report-modal-card {
  max-width: 1050px;
  width: 95vw;
  height: 90vh;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.report-modal-header-info h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
}

.report-modal-sub {
  font-size: 11.5px;
  color: var(--text-muted);
}

.report-modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  scrollbar-width: thin;
  scrollbar-color: #94a3b8 var(--surface-alt);
}

.report-modal-body::-webkit-scrollbar {
  width: 10px;
}

.report-modal-body::-webkit-scrollbar-track {
  background: var(--surface-alt);
  border-radius: 999px;
}

.report-modal-body::-webkit-scrollbar-thumb {
  background: #94a3b8;
  border-radius: 999px;
  border: 2px solid var(--surface-alt);
}

.report-modal-body::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}

.report-modal-grid-2 {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 20px;
  align-items: center;
}

@media (max-width: 768px) {
  .report-modal-grid-2 {
    grid-template-columns: 1fr;
  }
}

.report-table-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow-x: auto;
  overflow-y: visible;
  position: relative;
}

.report-table-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 6px;
  margin-bottom: -6px;
}

.report-table-title-wrap {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

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

.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.report-table th {
  background: var(--surface-alt);
  padding: 8px 12px;
  text-align: left;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: -16px;
  z-index: 10;
  box-shadow: 0 1px 0 var(--border);
}

.report-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.report-table tr:hover td {
  background: var(--surface-alt);
  cursor: pointer;
}

@media print {
  body * {
    visibility: hidden;
  }
  #reportModal,
  #reportModal *,
  #smrModal,
  #smrModal * {
    visibility: visible;
  }
  #reportModal,
  #smrModal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #fff;
    padding: 0;
  }
  .modal-close,
  .modal-footer,
  #printReportBtn,
  #exportReportCsvBtn,
  #printSmrReportBtn,
  #exportSmrReportCsvBtn {
    display: none !important;
  }
}

/* Стили для аналитики и карточек этапов СМР */
.smr-stage-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.smr-stage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.smr-stage-title-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.smr-stage-title {
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
}

.smr-progress-dual {
  width: 100%;
  height: 9px;
  background: #e2e8f0;
  border-radius: 999px;
  display: flex;
  overflow: hidden;
}

:root[data-theme="dark"] .smr-progress-dual {
  background: #334155;
}

.smr-progress-seg-done {
  background: #22c55e;
  height: 100%;
  transition: width 0.3s ease;
}

.smr-progress-seg-prog {
  background: #f59e0b;
  height: 100%;
  transition: width 0.3s ease;
}

.smr-progress-seg-not {
  background: #94a3b8;
  height: 100%;
  opacity: 0.35;
}

.smr-filter-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.smr-filter-btn {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}

.smr-filter-btn:hover {
  background: var(--surface);
  border-color: #60a5fa;
  color: var(--primary);
  transform: translateY(-1px);
}

.smr-filter-btn.btn-done-filter {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #166534;
}

.smr-filter-btn.btn-done-filter:hover {
  background: #dcfce7;
  border-color: #86efac;
}

:root[data-theme="dark"] .smr-filter-btn.btn-done-filter {
  background: rgba(34, 197, 94, 0.15);
  border-color: rgba(34, 197, 94, 0.3);
  color: #86efac;
}

.badge-smr-done {
  background: #dcfce7;
  border: 1px solid #bbf7d0;
  color: #166534;
  font-weight: 700;
  font-size: 10px;
  padding: 1.5px 6px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

:root[data-theme="dark"] .badge-smr-done {
  background: rgba(34, 197, 94, 0.2);
  border-color: rgba(34, 197, 94, 0.4);
  color: #86efac;
}

.badge-smr-empty {
  color: var(--text-muted);
  font-style: italic;
  font-size: 11.5px;
}

/* Компактные подсказки при наведении на метки (перенос длинных адресов на 2-3 строки) */
.leaflet-tooltip {
  max-width: 580px !important;
  min-width: 360px !important;
  white-space: normal !important;
  line-height: 1.35 !important;
  border-radius: 8px !important;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15) !important;
}

[class*="ymaps-2-1"][class*="-hint"] {
  max-width: 580px !important;
  min-width: 360px !important;
  white-space: normal !important;
  border-radius: 8px !important;
}

/* Полное скрытие бейджей и служебных виджетов Netlify */
#nl-badge-frame,
iframe#nl-badge-frame,
iframe[id*="nl-badge"],
#netlify-badge,
.netlify-badge,
netlify-badge,
[data-netlify-badge],
iframe[src*="netlify"],
[class*="netlify-badge"] {
  display: none !important;
  opacity: 0 !important;
  pointer-events: none !important;
  visibility: hidden !important;
  width: 0 !important;
  height: 0 !important;
  max-width: 0 !important;
  max-height: 0 !important;
  transform: scale(0) !important;
}

/* ============================================================================
   МОБИЛЬНАЯ АДАПТАЦИЯ (СМАРТФОНЫ И ПЛАНШЕТЫ: <= 768px и <= 480px)
   ============================================================================ */

/* Затемняющий фон при открытом мобильном меню */
.sidebar-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 1190;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.sidebar-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

/* Мобильная шапка сайдбара с кнопкой закрытия */
.sidebar-mobile-header {
  display: none;
}

/* Кнопка "Где я" на карте */
.btn-geo-active {
  background: #2563eb !important;
  color: #fff !important;
  border-color: #1d4ed8 !important;
}

/* ----------------------------------------------------------------------------
   Медиа-запрос: Планшеты и смартфоны (<= 768px)
   ---------------------------------------------------------------------------- */
@media (max-width: 768px) {
  /* Рабочая область и карта */
  .workspace {
    position: relative;
    overflow: hidden;
    width: 100vw;
  }

  .map-container {
    width: 100% !important;
    height: 100% !important;
    flex: 1 1 100%;
  }

  /* Сайдбар превращается в боковую шторку (Off-Canvas Drawer) */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(340px, 86vw) !important;
    max-width: 86vw;
    height: 100vh;
    z-index: 1200;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 6px 0 24px rgba(0, 0, 0, 0.3);
    display: flex !important;
    background: var(--surface);
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .sidebar-mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-alt);
  }

  .sidebar-mobile-title {
    font-weight: 700;
    font-size: 14px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 6px;
  }

  /* Инспектор превращается в выдвижной Bottom Sheet */
  .inspector {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    width: 100% !important;
    max-width: 100% !important;
    max-height: 68vh;
    height: auto;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.32);
    z-index: 1150;
    border-top: 1px solid var(--border);
    border-left: none;
    background: var(--surface);
    animation: slideUpBottom 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  }

  @keyframes slideUpBottom {
    from {
      transform: translateY(100%);
    }
    to {
      transform: translateY(0);
    }
  }

  .inspector-header {
    padding: 10px 14px;
    border-radius: 18px 18px 0 0;
    position: sticky;
    top: 0;
    z-index: 5;
  }

  .inspector-body {
    max-height: calc(68vh - 54px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px 14px 24px;
  }

  /* Верхняя панель на экранах <= 768px: строгая 2-рядная компактная сетка */
  .topbar {
    display: grid !important;
    grid-template-columns: 1fr auto !important;
    grid-template-rows: auto auto !important;
    padding: 6px 10px 4px !important;
    row-gap: 5px !important;
    column-gap: 8px !important;
    align-items: center !important;
    min-height: auto !important;
    height: auto !important;
    overflow-x: hidden !important;
  }

  .topbar-left {
    grid-column: 1 / 2 !important;
    grid-row: 1 / 2 !important;
    display: flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
  }

  .topbar-right {
    grid-column: 2 / 3 !important;
    grid-row: 1 / 2 !important;
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: nowrap;
    justify-content: flex-end;
  }

  .topbar-divider {
    display: none !important;
  }

  .topbar-btn-text {
    display: none !important;
  }

  /* Лента инструментов черчения: строка 2 на всю ширину */
  .editor-toolbar {
    grid-column: 1 / -1 !important;
    grid-row: 2 / 3 !important;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 4px;
    scrollbar-width: none;
    flex-wrap: nowrap;
    border-radius: 8px;
  }

  .editor-toolbar::-webkit-scrollbar {
    display: none;
  }

  .tool-btn {
    flex-shrink: 0;
    padding: 4px 8px;
    font-size: 11.5px;
    white-space: nowrap;
  }

  /* Плавающие элементы на карте */
  .map-floating-top-right {
    top: 8px;
    right: 8px;
    gap: 4px;
    max-width: calc(100vw - 16px);
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .coord-search-wrap {
    padding: 2px 5px;
  }

  .coord-search-input {
    width: 115px;
    font-size: 11px;
  }

  .basemap-select {
    padding: 4px 6px;
    font-size: 11px;
    max-width: 90px;
  }

  /* Модальные окна */
  .modal-card {
    width: 95vw !important;
    max-width: 95vw !important;
    max-height: 92vh !important;
    margin: 8px auto;
    border-radius: 12px;
  }

  .modal-header {
    padding: 10px 14px;
  }

  .modal-body {
    padding: 12px 14px;
    gap: 12px;
  }

  .modal-footer {
    padding: 10px 14px;
  }

  .report-modal-card {
    width: 96vw !important;
    max-width: 96vw !important;
    height: 94vh !important;
    max-height: 94vh !important;
  }

  .report-modal-body {
    padding: 10px 12px;
    gap: 12px;
  }

  .report-modal-grid-2 {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .report-table-box {
    -webkit-overflow-scrolling: touch;
  }

  .report-table-header-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
}

/* ----------------------------------------------------------------------------
   Медиа-запрос: Узкие экраны смартфонов (<= 480px)
   ---------------------------------------------------------------------------- */
@media (max-width: 480px) {
  .brand-logo-wrap,
  .brand-logo-svg {
    width: 30px;
    height: 30px;
  }

  .brand-title {
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 145px;
  }

  .brand-subtitle {
    display: none !important;
  }

  .role-box {
    display: none !important;
  }

  .dev-badge-text {
    display: none !important;
  }

  .dev-badge {
    padding: 2px 3px;
    gap: 0;
  }

  .dev-badge-avatar {
    width: 25px;
    height: 25px;
    font-size: 10px;
  }

  .topbar-right .btn-sm {
    padding: 3px 6px;
    font-size: 10px;
  }

  .online-widget-btn {
    padding: 3px 6px;
    font-size: 11px;
  }

  .coord-search-wrap {
    width: 100%;
    max-width: 140px;
  }

  .coord-search-input {
    width: 80px;
    font-size: 10px;
  }

  .report-kpi-grid {
    grid-template-columns: 1fr;
  }

  .report-modal-header-info h3 {
    font-size: 13.5px;
  }

  .report-modal-sub {
    font-size: 10px;
  }

  .stats-strip {
    grid-template-columns: repeat(2, 1fr);
  }

  .stat-item:nth-child(3n) {
    border-right: 1px solid var(--border);
  }

  .stat-item:nth-child(2n) {
    border-right: none;
  }
}
