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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  padding: 20px;
}

.container {
  max-width: 100%;
  margin: 0 auto;
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

h1 {
  background: linear-gradient(135deg, #4A00E0, #8E2DE2);
  color: white;
  padding: 20px;
  text-align: center;
  font-size: 24px;
}

.subtitle {
  text-align: center;
  color: #666;
  padding: 10px;
  font-size: 14px;
  border-bottom: 1px solid #eee;
}

.main-content {
  display: flex;
  min-height: 700px;
}

.left-panel {
  width: 300px;
  background: #f8f9fa;
  border-right: 1px solid #e9ecef;
  padding: 15px;
  overflow-y: auto;
}

.canvas-container {
  flex: 1;
  padding: 20px;
  background: #f8f9fa;
}

#canvas-container {
  width: 100%;
  height: 100%;
  background: white;
  border: 2px solid #dee2e6;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

#fabric-canvas {
  display: block;
}


.image-library #imageLibraryGrid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}

#tools, .control-buttons {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}


#tools button,
.control-buttons button {
  background: white;
  border: 1px solid #dee2e6;
  border-radius: 6px;
  padding: 10px;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: all 0.3s;
}

#tools button:hover {
  background: #e9ecef;
  transform: translateY(-2px);
}

#tools button.active-mode {
  background: #4A00E0;
  color: white;
  border-color: #4A00E0;
}

.line-split-mode-btn {
  grid-column: 1 / -1;
  background: #ff6b6b !important;
  color: white !important;
  border-color: #ff6b6b !important;
}

#image-tools-container {
  background: white;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 20px;
}

.image-tools-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.image-tools-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.image-item {
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 6px;
  padding: 10px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
  position: relative;
  overflow: hidden;
}

.image-item:hover {
  background: #e9ecef;
  transform: scale(1.05);
}

.image-item.active-mode {
  background: #4A00E0;
  color: white;
  border-color: #4A00E0;
}

.image-item img {
  width: 30px;
  height: 30px;
  object-fit: contain;
  margin-bottom: 5px;
}

.image-item-name {
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.properties-panel {
  background: white;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 20px;
}

.properties-panel h3 {
  margin-bottom: 15px;
  color: #333;
  font-size: 16px;
  border-bottom: 2px solid #4A00E0;
  padding-bottom: 5px;
}

.property-group {
  background: #f8f9fa;
  border-left: 4px solid #4A00E0;
  padding: 10px;
  margin-bottom: 15px;
  border-radius: 0 6px 6px 0;
}

.property-group h4 {
  color: #333;
  margin-bottom: 8px;
  font-size: 14px;
}

.property-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px dashed #dee2e6;
}

.property-row:last-child {
  border-bottom: none;
}

.property-label {
  color: #666;
  font-size: 12px;
}

.property-value {
  color: #333;
  font-size: 12px;
  font-weight: 500;
}

#status {
  background: white;
  border: 1px solid #dee2e6;
  border-radius: 6px;
  padding: 10px;
  font-size: 12px;
  color: #666;
  margin-bottom: 20px;
}

.instructions {
  background: white;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  padding: 15px;
  font-size: 12px;
}

.instructions h4 {
  margin-bottom: 10px;
  color: #333;
}

.instructions ul {
  list-style: none;
  padding-left: 0;
}

.instructions li {
  padding: 4px 0;
  border-bottom: 1px solid #f8f9fa;
}

.instructions li:last-child {
  border-bottom: none;
}

.instructions strong {
  color: #4A00E0;
}

/* Модальные окна */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: white;
  border-radius: 12px;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.modal-header {
  background: linear-gradient(135deg, #4A00E0, #8E2DE2);
  color: white;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: 12px 12px 0 0;
}

.modal-title {
  font-size: 20px;
}

.close-modal {
  background: none;
  border: none;
  color: white;
  font-size: 28px;
  cursor: pointer;
  line-height: 1;
}

.modal-form {
  padding: 20px;
}

.form-group {
  margin-bottom: 15px;
}

.form-label {
  display: block;
  margin-bottom: 5px;
  color: #333;
  font-weight: 500;
  font-size: 13px;
}

.modal-form input,
.modal-form select,
.modal-form textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #dee2e6;
  border-radius: 6px;
  font-size: 14px;
  transition: border-color 0.3s;
}

.modal-form input:focus,
.modal-form select:focus,
.modal-form textarea:focus {
  outline: none;
  border-color: #4A00E0;
}

.form-row {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
}

.form-row .form-group {
  flex: 1;
  margin-bottom: 0;
}

.modal-buttons {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.3s;
  flex: 1;
}

.btn-primary {
  background: linear-gradient(135deg, #4A00E0, #8E2DE2);
  color: white;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(74, 0, 224, 0.3);
}

.btn-secondary {
  background: #6c757d;
  color: white;
}

.btn-secondary:hover {
  background: #5a6268;
}

/* Точки пересечения */
.intersection-point {
  fill: #ff4757;
  stroke: #ff4757;
  stroke-width: 2;
  cursor: pointer;
}

.intersection-point:hover {
  fill: #ff6b81;
  stroke: #ff6b81;
}

/* Контекстное меню */
.context-menu {
  display: none;
  position: absolute;
  background: white;
  border-radius: 8px;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
  z-index: 1000;
  min-width: 180px;
  overflow: hidden;
}

.context-menu-item {
  padding: 10px 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.3s;
  font-size: 13px;
}

.context-menu-item:hover {
  background: #f8f9fa;
}

.context-menu-divider {
  height: 1px;
  background: #dee2e6;
  margin: 4px 0;
}

/* Уведомления */
.notification {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 12px 20px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 1001;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.notification.success {
  border-left: 4px solid #2ed573;
}

.notification.error {
  border-left: 4px solid #ff4757;
}

.notification.info {
  border-left: 4px solid #3742fa;
}

.notification.warning {
  border-left: 4px solid #ffa502;
}

/* Информация о точке пересечения */
.line-info-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  font-size: 12px;
}

.line-info-table th,
.line-info-table td {
  border: 1px solid #dee2e6;
  padding: 8px;
  text-align: left;
}

.line-info-table th {
  background: #f8f9fa;
  font-weight: 600;
}

.line-end-marker {
  display: inline-block;
  width: 24px;
  height: 24px;
  background: #2ed573;
  color: white;
  border-radius: 50%;
  text-align: center;
  line-height: 24px;
  font-weight: bold;
  font-size: 12px;
  margin-right: 8px;
}

.line-end-marker-bg {
  display: inline-block;
  width: 24px;
  height: 24px;
  background: #ff4757;
  color: white;
  border-radius: 50%;
  text-align: center;
  line-height: 24px;
  font-weight: bold;
  font-size: 12px;
  margin-right: 8px;
}

.intersection-line-item {
  display: flex;
  align-items: center;
  padding: 8px;
  background: #f8f9fa;
  border-radius: 6px;
  margin-bottom: 6px;
}

.object-at-intersection {
  display: flex;
  align-items: center;
  padding: 8px;
  background: #e3f2fd;
  border-radius: 6px;
  margin-bottom: 6px;
}

.object-icon {
  font-size: 20px;
  margin-right: 10px;
}

/* Добавьте в существующий CSS */
.intersection-line-item {
  display: flex;
  align-items: flex-start;
  padding: 8px;
  margin: 5px 0;
  background: #f8f9fa;
  border-radius: 4px;
  border-left: 3px solid #00b894;
}

.line-end-marker,
.line-end-marker-bg {
  min-width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 10px;
  font-size: 10px;
  font-weight: bold;
}

.line-end-marker {
  background: #00b894;
  color: white;
}

.line-end-marker-bg {
  background: #e17055;
  color: white;
}

.line-properties-details {
  background: white;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  padding: 8px;
  margin-top: 5px;
  font-size: 11px;
}

.line-properties-details div {
  display: flex;
  justify-content: space-between;
  padding: 2px 0;
  border-bottom: 1px dashed #eee;
}

.line-properties-details div:last-child {
  border-bottom: none;
}

.property-group h4,
.property-group h5 {
  margin: 10px 0 5px 0;
  color: #2d3436;
}

.property-group h4 {
  border-bottom: 2px solid #4A00E0;
  padding-bottom: 5px;
}

.property-group h5 {
  color: #636e72;
  font-size: 14px;
}


/*===========================*/

/* Общие стили для всех модальных окон */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-content {
  background: white;
  border-radius: 12px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
  from {
    transform: translateY(-20px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-header {
  background: linear-gradient(135deg, #4A00E0, #8E2DE2);
  color: white;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: 12px 12px 0 0;
  position: sticky;
  top: 0;
  z-index: 1;
}

.modal-title {
  font-size: 20px;
  margin: 0;
  font-weight: 600;
}

.close-modal {
  background: none;
  border: none;
  color: white;
  font-size: 28px;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
}

.close-modal:hover {
  transform: scale(1.1);
}

.modal-form {
  padding: 20px;
}

.form-group {
  margin-bottom: 15px;
}

.form-label {
  display: block;
  margin-bottom: 6px;
  color: #333;
  font-weight: 500;
  font-size: 13px;
}

.form-row {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
}

.form-row .form-group {
  flex: 1;
  margin-bottom: 0;
}

.modal-form input,
.modal-form select,
.modal-form textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #dee2e6;
  border-radius: 6px;
  font-size: 14px;
  transition: all 0.3s;
  background: white;
}

.modal-form input:focus,
.modal-form select:focus,
.modal-form textarea:focus {
  outline: none;
  border-color: #4A00E0;
  box-shadow: 0 0 0 3px rgba(74, 0, 224, 0.1);
}

.modal-form textarea {
  resize: vertical;
  min-height: 80px;
}

.modal-form input[type="range"] {
  padding: 0;
  height: 6px;
  border-radius: 3px;
  background: #dee2e6;
  appearance: none;
}

.modal-form input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #4A00E0;
  cursor: pointer;
  border: 2px solid white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.modal-form input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #4A00E0;
  cursor: pointer;
  border: 2px solid white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.modal-form input[type="color"] {
  height: 40px;
  padding: 2px;
  cursor: pointer;
}

.modal-buttons {
  display: flex;
  gap: 10px;
  margin-top: 25px;
}

.btn {
  padding: 12px 20px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

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

.btn-primary {
  background: linear-gradient(135deg, #4A00E0, #8E2DE2);
  color: white;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #5a1aed, #9e3df3);
}

.btn-secondary {
  background: #6c757d;
  color: white;
}

.btn-secondary:hover {
  background: #5a6268;
}

.btn-danger {
  background: linear-gradient(135deg, #ff4757, #ff3838);
  color: white;
}

.btn-danger:hover {
  background: linear-gradient(135deg, #ff6b81, #ff5252);
}

/* Стили для модального окна информации о точке */
#intersectionPointModal .modal-content {
  max-width: 800px;
}

/* Для маленьких экранов */
@media (max-width: 768px) {
  .modal {
    padding: 10px;
  }

  .modal-content {
    max-height: 95vh;
  }

  .form-row {
    flex-direction: column;
    gap: 10px;
  }

  .modal-buttons {
    flex-direction: column;
  }

  .btn {
    width: 100%;
  }
}

/* Стили для контента внутри информации о точке */
.intersection-point-content {
  padding: 20px;
}

.point-stats {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 20px;
}

.point-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 15px;
  margin-top: 10px;
}

.stat-item {
  text-align: center;
  padding: 10px;
  border-radius: 6px;
  background: white;
}

.stat-item.start {
  border-top: 3px solid #00b894;
}

.stat-item.end {
  border-top: 3px solid #e17055;
}

.stat-item.objects {
  border-top: 3px solid #4A00E0;
}

.stat-value {
  font-size: 24px;
  font-weight: bold;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 12px;
  color: #666;
}

.point-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 15px 0;
}

.point-actions button {
  padding: 8px 12px;
  font-size: 12px;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  gap: 4px;
}

.object-item,
.line-item {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 10px;
  border-left: 4px solid #4A00E0;
}

.line-item.start {
  border-left-color: #00b894;
}

.line-item.end {
  border-left-color: #e17055;
}

.item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.item-actions {
  display: flex;
  gap: 5px;
}

.item-actions button {
  padding: 4px 8px;
  font-size: 11px;
  border-radius: 3px;
  border: none;
  cursor: pointer;
}

.custom-data {
  background: white;
  border-radius: 4px;
  padding: 8px;
  margin-top: 8px;
  font-size: 10px;
  max-height: 100px;
  overflow-y: auto;
}

.json-pre {
  margin: 0;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.btn-small {
  padding: 6px 12px;
  font-size: 12px;
  background: #4A00E0;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.3s;
}

.btn-small:hover {
  background: #3a00b0;
}

.btn-small.danger {
  background: #ff4757;
}

.btn-small.danger:hover {
  background: #ff3742;
}

/* Контейнер для канваса */
.canvas-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: #fff;
  min-height: 700px;
  /* Минимальная высота */
}

#canvas-wrapper {
  width: 100%;
  height: 100%;
  position: relative;
}

#fabric-canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* Адаптивные стили для мобильных устройств */
@media (max-width: 768px) {
  .main-content {
    flex-direction: column;
  }

  .left-panel {
    width: 100% !important;
    max-height: 300px;
    overflow-y: auto;
  }

  .canvas-container {
    min-height: 500px;
  }

  .toolbar h3,
  .image-library h3,
  .properties-panel h3 {
    font-size: 14px;
  }

  .toolbar button,
  .control-buttons button {
    padding: 6px 8px;
    font-size: 12px;
  }
}

/* Стили для модального окна экспорта PDF */
.form-select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  background-color: #fff;
}

.form-group label {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
  cursor: pointer;
}

.form-group label input[type="checkbox"] {
  margin-right: 8px;
  width: 16px;
  height: 16px;
}


/*===================*/
/* Стили для HTML меток объема воздуха */
.air-volume-label {
  position: absolute;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid #4A00E0;
  color: #4A00E0;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: bold;
  font-family: Arial, sans-serif;
  pointer-events: none;
  z-index: 1000;
  transform-origin: center center;
  white-space: nowrap;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: opacity 0.2s;
}

.air-volume-label:hover {
  opacity: 0.9;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15);
}

/*==============--------------------*/
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

.modal-content {
  background-color: white;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  /* max-width: 90%; */
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  padding: 20px;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  margin: 0;
  font-size: 1.5rem;
  color: #333;
}

.close-modal {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #666;
}

.modal-body {
  padding: 20px;
}

.property-group {
  margin-bottom: 20px;
  padding: 15px;
  border-radius: 6px;
  background: #f8f9fa;
  border-left: 4px solid #4A00E0;
}

.property-group h4 {
  margin-top: 0;
  margin-bottom: 15px;
  color: #333;
  font-size: 1.1rem;
}

.property-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #eee;
}

.property-label {
  font-weight: 500;
  color: #666;
  flex: 1;
}

.property-value {
  flex: 2;
  text-align: right;
  font-weight: 500;
  color: #333;
}

.btn-small {
  padding: 8px 16px;
  border: none;
  border-radius: 4px;
  background: #0984e3;
  color: white;
  cursor: pointer;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.btn-small:hover {
  opacity: 0.9;
}

.btn-small.danger {
  background: #e17055;
}


.point-info h4 {
  margin-top: 20px;
  margin-bottom: 10px;
  color: #4A00E0;
  border-bottom: 2px solid #eee;
  padding-bottom: 5px;
}
.point-info p {
  margin: 5px 0;
}
.lines-list, .objects-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.lines-list li, .objects-list li {
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 5px;
  padding: 10px;
  margin-bottom: 10px;
}
.detail {
  color: #6c757d;
  font-size: 0.9em;
}
.point-summary {
  background: #e3f2fd;
  border-left: 4px solid #4A00E0;
  padding: 10px;
  margin: 10px 0;
  border-radius: 4px;
}
.point-coordinates {
  background: #f3e5f5;
  padding: 10px;
  border-radius: 4px;
  margin: 10px 0;
}
.no-data {
  color: #6c757d;
  font-style: italic;
  text-align: center;
  padding: 20px;
}
.loading {
  text-align: center;
  padding: 40px;
  color: #6c757d;
}