.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 20px;
    border-radius: 8px;
    width: 80%;
    max-width: 1000px;
    max-height: 80vh;
    overflow-y: auto;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: black;
}

.modal-controls {
    margin-top: 20px;
}

.sensor-templates {
    margin-bottom: 10px;
    padding: 15px;
    background-color: #f5f5f5;
    border-radius: 8px;
}

.template-options {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 10px;
    font-size: 12px;
}

.template-options label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background-color: white;
    border-radius: 5px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: all 0.2s ease;
}

.template-options label:hover {
    background-color: #f0f0f0;
}

.template-options input[type="radio"] {
    margin-right: 5px;
}

.template-options img {
    border-radius: 3px;
}

.current-selector,
.resistance-selector {
    margin: 5px 0;
    padding: 15px;
    background-color: #f0f0f0;
    border-radius: 8px;
}

.current-options,
.resistance-options {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 10px;
}

.current-options label,
.resistance-options label {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 8px 12px;
    background-color: white;
    border-radius: 5px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    cursor: pointer;
}

.current-options label:hover,
.resistance-options label:hover {
    background-color: #f0f0f0;
}

.current-options input[type="radio"],
.resistance-options input[type="radio"] {
    margin-right: 5px;
}




.thresholds-container {
    display: flex;
    gap: 30px;
    margin-bottom: 20px;
}

.thresholds-column {
    flex: 1;
    padding: 15px;
    margin-bottom: 15px;
    background-color: #f5f5f5;
    border-radius: 8px;
}

.thresholds-column h4 {
    margin-top: 0;
    text-align: center;
    color: #333;
    padding-bottom: 10px;
    border-bottom: 1px solid #ddd;
}

.threshold-group {
    margin-bottom: 8px;
    padding: 5px;
    background-color: white;
    border-radius: 5px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.threshold-group h5 {
    margin: 0 0 10px 0;
    color: #444;
}

.threshold-range {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
}

.threshold-range input {
    width: 70px;
    padding: 5px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 10px;
    border-top: 1px solid #ddd;
}


.save-thresholds {
    border-radius: 5px;
    color: white;
    transition: .2s linear;
    background: #0B63F6;
    min-height: 50px;
    min-width: 120px;
}

.save-thresholds:hover {
    box-shadow: 0 0 0 2px white, 0 0 0 4px #3C82F8;
}

.reset-thresholds {
    border-radius: 5px;
    color: white;
    transition: .2s linear;
    background: #0B63F6;
    min-height: 50px;
    min-width: 120px;
}

.reset-thresholds:hover {
    box-shadow: 0 0 0 2px white, 0 0 0 4px #3C82F8;
}


/* Стили для модального окна оконечного резистора */
#end-resistor-modal .modal-content {
    max-width: 400px;
}

#end-resistor-modal .controls {
    margin-bottom: 15px;
}

#end-resistor-modal input[type="number"] {
    width: 80px;
}

#end-resistor-modal input[type="range"] {
    width: 200px;
    margin-top: 5px;
}

.settings-button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2em;
    margin-left: 10px;
    vertical-align: middle;
}

.settings-button:hover {
    opacity: 0.7;
}



/* Стили для модального окна настроек провода */
#wire-settings-modal .modal-content {
    max-width: 600px;
}

#wire-settings-modal .controls {
    margin-bottom: 15px;
}

#wire-settings-modal select {
    padding: 5px;
    border: 1px solid #ccc;
    border-radius: 4px;
    width: 100%;
    max-width: 200px;
}

#wire-resistance-per-meter {
    font-weight: bold;
    color: #2c3e50;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    /* Отступ между кнопками */
    margin-top: 15px;
    /* Отступ сверху, если нужен */
}

.modal-buttons button {
    flex: 1;
    /* Равномерное распределение ширины */
    max-width: 120px;
    /* Максимальная ширина кнопки (можно настроить) */
}


.led-rd {
    margin: 5px;
    padding: 5px;
    border-radius: 10px;
    border: 1px solid #7883a5;
}
.led-rd:hover {
    /* border: 2px solid #7883a5; */
    background-color: #aaa;
}

.name-modal-add {
    font-family: 'Arial', 'Verdana', sans-serif;
    font-family: 'Arial';
    font-size: 21px;
  text-align: center;
}





.modal-controls-table {
  width: 100%;
  border-collapse: collapse;
}

.modal-controls-table col:first-child {
  width: 150px; /* Фиксированная ширина первого столбца */
}

.modal-controls-table col:last-child {
  width: auto; /* Второй столбец занимает оставшееся пространство */
}

.modal-controls-table td {
  padding: 4px 12px;
  border-bottom: 1px solid #eee;
  vertical-align: top;
  vertical-align: middle; /* Измените с top на middle */
  transition: background-color 0.2s ease; /* Плавный переход для подсветки */
}
/* Для всех ячеек таблицы выравниваем содержимое по центру по вертикали */
.modal-controls-table td {
  vertical-align: middle;
}

/* Подсветка строк при наведении */
.modal-controls-table tr:not(.section-header):hover td {
  background-color: #f8f9fa; /* Светло-серый фон при наведении */
  cursor: pointer;
}

/* Для строк с colspan (заголовки секций) - другая подсветка */
.modal-controls-table tr.section-header:hover td {
  background-color: #e9ecef; /* Немного темнее для заголовков */
}

/* Стили для первого столбца */
.modal-controls-table td:first-child {
  font-weight: 500;
  text-align: right; /* Выравнивание подписей по правому краю */
  padding-right: 15px;
}

/* Стили для заголовков секций */
.modal-controls-table .section-header td {
  background-color: #f5f5f5;
  font-weight: bold;
  padding-top: 16px;
  border-bottom: none;
  text-align: left;
}

/* Убираем подсветку для скрытых строк */
.modal-controls-table tr[style*="display: none"]:hover td {
  background-color: transparent;
  cursor: default;
}


.modal-controls-table input{
    padding: 6px 10px;
    min-width: 80px;
    width: 90px;
    border: 1px solid #ddd;
    border-radius: 4px;
}
.modal-controls-table select{
    padding: 4px 10px;
    min-width: 80px;
    border: 1px solid #ddd;
    border-radius: 4px;
}





/* Адаптивные стили для модального окна добавления датчиков */
@media (max-width: 768px) {
    #sensor-modal .modal-content {
        width: 95%;
        max-width: 95%;
        margin: 10% auto;
        padding: 15px;
        max-height: 85vh;
    }
    
    .modal-controls-table {
        width: 100%;
        display: block;
        overflow-x: hidden;
    }
    
    .modal-controls-table colgroup {
        display: none;
    }
    
    .modal-controls-table tr {
        display: flex;
        flex-direction: column;
        margin-bottom: 15px;
        padding: 10px;
        background-color: #f9f9f9;
        border-radius: 8px;
        border: 1px solid #eee;
    }
    
    .modal-controls-table td {
        display: block;
        width: 100% !important;
        padding: 8px 5px;
        border-bottom: none;
        text-align: left;
    }
    
    .modal-controls-table td:first-child {
        text-align: left;
        font-weight: bold;
        padding-bottom: 5px;
        border-bottom: 1px dashed #ddd;
        margin-bottom: 5px;
    }
    
    .modal-controls-table td:nth-child(2) {
        padding-left: 0;
    }
    
    .modal-controls-table td:last-child {
        padding-top: 8px;
    }
    
    .modal-controls-table input,
    .modal-controls-table select {
        width: 100%;
        max-width: 100%;
        min-width: auto;
    }
    
    /* Шаблоны датчиков */
    .template-options {
        flex-direction: column;
        gap: 10px;
    }
    
    .template-options label {
        justify-content: flex-start;
        padding: 10px;
    }
    
    /* Селекторы сопротивления и тока */
    .resistance-options,
    .current-options {
        flex-direction: column;
        gap: 8px;
    }
    
    .resistance-options label,
    .current-options label {
        justify-content: flex-start;
        padding: 8px;
    }
    
    /* Кнопки */
    .modal-buttons {
        flex-direction: column;
        gap: 10px;
    }
    
    .modal-buttons button {
        max-width: 100%;
        width: 100%;
    }
    
    /* Заголовки */
    .resistance-selector h4,
    .current-selector h4 {
        font-size: 14px;
        line-height: 1.4;
    }
}

/* Для очень маленьких экранов */
@media (max-width: 480px) {
    #sensor-modal .modal-content {
        width: 98%;
        margin: 5% auto;
        padding: 10px;
    }
    
    .name-modal-add {
        font-size: 18px;
    }
    
    .modal-controls-table tr {
        padding: 8px;
    }
    
    .template-options label {
        font-size: 11px;
    }
    
    .template-options img {
        width: 40px;
        height: 40px;
    }
}

/* Убираем горизонтальный скролл для всего модального окна */
#sensor-modal .modal-content {
    overflow-x: hidden;
}

/* Улучшаем внешний вид для мобильных */
@media (max-width: 768px) {
    .modal-controls-table tr:hover td {
        background-color: transparent;
    }
    
    .modal-controls-table tr:active td {
        background-color: #e9ecef;
    }
}






/* Адаптив для модального окна оконечного резистора */
@media (max-width: 768px) {
    #end-resistor-modal .modal-content {
        width: 95%;
        max-width: 95%;
        margin: 10% auto;
        padding: 15px;
    }
    
    .end-resistor-quick-buttons {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        margin: 15px 0;
        justify-content: center;
    }
    
    .resistor-quick-btn {
        padding: 8px 12px;
        background: #f0f0f0;
        border: 1px solid #ddd;
        border-radius: 4px;
        cursor: pointer;
        font-size: 14px;
        transition: all 0.2s;
    }
    
    .resistor-quick-btn:hover {
        background: #e0e0e0;
    }
    
    .resistor-quick-btn.active {
        background: #4a90e2;
        color: white;
        border-color: #4a90e2;
    }
    
    #end-resistor-modal .controls {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        margin-bottom: 15px;
    }
    
    #end-resistor-modal .controls label {
        min-width: auto;
        width: 100%;
    }
    
    #end-resistor-modal input[type="number"] {
        width: 100%;
        /* max-width: 200px; */
    }
    
    #end-resistor-modal input[type="range"] {
        width: 100%;
        max-width: 300px;
    }
    
    #modal-save-end-resistor {
        width: 100%;
        max-width: 200px;
        margin: 10px auto 0;
    }
}



/* Адаптив для модального окна напряжения */
@media (max-width: 768px) {
    #voltage-modal .modal-content {
        width: 95%;
        max-width: 95%;
        margin: 10% auto;
        padding: 15px;
    }
    
    #voltage-modal .controls {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    #voltage-modal .controls label {
        width: 100%;
        text-align: left;
        word-wrap: break-word;
        white-space: normal;
        line-height: 1.4;
    }
    
    #voltage-modal .controls > div {
        width: 100%;
    }
    
    #voltage-modal .controls > div:first-child label {
        font-size: 14px;
        line-height: 1.5;
    }
    
    #voltage-modal input[type="number"] {
        width: 100%;
        max-width: 200px;
    }
    
    #modal-save-voltage {
        width: 100%;
        max-width: 200px;
        margin: 10px auto 0;
    }
    
    /* Специфичные стили для текста в voltage-modal */
    #voltage-modal .modal-content h3 {
        font-size: 18px;
        text-align: center;
    }
    
    #voltage-modal .controls div:first-child {
        background: #f8f9fa;
        padding: 12px;
        border-radius: 6px;
        /* border-left: 4px solid #4a90e2; */
    }
}


/* Адаптив для модального окна настроек провода */
@media (max-width: 768px) {
    #wire-settings-modal .modal-content {
        width: 95%;
        max-width: 95%;
        margin: 10% auto;
        padding: 15px;
    }
    
    #wire-settings-modal .controls {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        margin-bottom: 15px;
    }
    
    #wire-settings-modal .controls label {
        width: 100%;
        text-align: left;
        word-wrap: break-word;
        white-space: normal;
        line-height: 1.4;
    }
    
    #wire-settings-modal select,
    #wire-settings-modal input[type="number"] {
        width: 100%;
        /* max-width: 250px; */
    }
    
    .result-box {
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
    
    #modal-save-wire-settings {
        width: 100%;
        max-width: 200px;
        margin: 10px auto 0;
    }
    
    /* Улучшаем отображение чекбокса */
    #consider-wire-length {
        transform: scale(1.2);
        margin-right: 8px;
    }
}




/* Общие адаптивные стили для всех модальных окон */
@media (max-width: 480px) {
    .modal-content {
        width: 98% !important;
        max-width: 98% !important;
        margin: 5% auto !important;
        padding: 12px !important;
    }
    
    .modal-content h3 {
        font-size: 16px !important;
    }
    
    /* Улучшаем читаемость текста */
    .modal-content label {
        font-size: 14px;
    }
    
    /* Увеличиваем область касания для кнопок */
    button {
        min-height: 44px;
        min-width: 44px;
    }
}

/* Предотвращаем горизонтальный скролл для всех модальных окон */
.modal-content {
    overflow-x: hidden;
    box-sizing: border-box;
}

/* Улучшаем отображение длинного текста */
.controls label,
.threshold-group h5,
.result-label {
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}





/* Исправляем стили для чекбоксов в модальном окне */
@media (max-width: 768px) {
    .modal-controls-table input:not([type="checkbox"]), 
    .modal-controls-table select {
        width: 100%;
        max-width: 100%;
        min-width: auto;
    }
    
    /* Специфичные стили только для чекбоксов */
    .modal-controls-table input[type="checkbox"] {
        width: auto !important;
        min-width: auto !important;
        max-width: none !important;
        transform: scale(1.3);
        margin-right: 8px;
    }
    
    /* Убираем стандартные отступы для label с чекбоксами */
    .modal-controls-table label {
        display: flex !important;
        align-items: center;
        width: 100%;
        cursor: pointer;
        margin: 0;
        padding: 0;
    }
    
    /* Специальные стили для строк с чекбоксами */
    .modal-controls-table tr:has(input[type="checkbox"]) td {
        padding-top: 12px;
        padding-bottom: 12px;
    }
    
    .modal-controls-table tr:has(input[type="checkbox"]) td:first-child {
        border-bottom: none;
        padding-bottom: 0;
    }
}

/* Общие стили для чекбоксов (работают везде) */
.modal-controls-table input[type="checkbox"] {
    width: auto;
    min-width: auto;
    padding: 0;
    margin: 0;
    margin-right: 8px;
}

.modal-controls-table label {
    display: flex;
    align-items: center;
    cursor: pointer;
    white-space: nowrap;
}

/* Убираем стандартные стили для чекбоксов в таблице */
.modal-controls-table input[type="checkbox"] {
    width: 16px;
    height: 16px;
    min-width: 16px;
}