/* Предотвращение артефактов под подвалом и наложений */
body.page { overflow-x: hidden; }
body.page .wrp { min-height: 0; }
body.page .ftr { flex-shrink: 0; }
/* Отступ от шапки, чтобы контент не наезжал на навбар */
.ovik-page { padding-top: 50px; }
@media (max-width: 760px) {
    .ovik-page { padding-top: 0; } /* на мобиле .hdr+* уже даёт margin-top */
}
/* Оверлей попапов — только в viewport */
.popup_background { position: fixed !important; top: 0 !important; left: 0 !important; right: 0 !important; bottom: 0 !important; width: 100vw !important; height: 100vh !important; }
/* Wrapper попапа — fixed поверх viewport, центрирование */
[id$="_wrapper"] {
    position: fixed !important;
    top: 0 !important; left: 0 !important; right: 0 !important; bottom: 0 !important;
    z-index: 100000 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    pointer-events: none;
    visibility: hidden;
    opacity: 0;
}
[id$="_wrapper"].popup_visible {
    pointer-events: auto;
    visibility: visible !important;
    opacity: 1 !important;
}

.ovik-hero {
    background: linear-gradient(135deg, rgba(13,65,110,.95) 0%, rgba(0,155,227,.9) 100%);
    padding: 28px 0 32px;
    color: #fff;
}
.ovik-hero .ovik-hero__inner {
    display: block;
    max-width: 800px;
}
.ovik-hero h1 { margin: 0 0 8px; font-size: 1.6em; font-weight: 700; }
.ovik-hero p { margin: 0; opacity: .9; font-size: 0.98em; line-height: 1.5; }
.ovik-calc {
    padding: 20px 0 48px;
}
.ovik-project {
    background: #fff;
    border: 2px solid #009be3;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 4px 16px rgba(0,155,227,.15);
    height: auto;
    display: block;
}
.ovik-project__head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
}
.ovik-project__text {
    flex: 1;
    min-width: 0;
    font-size: 1em;
    color: #1a1a2e;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ovik-project__toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    min-width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: #009be3;
    font-size: 0.95em;
    cursor: pointer;
    transition: background .2s;
}
.ovik-project__toggle:hover { background: rgba(0,155,227,.15); }
/* Modal */
.ovik-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 9000;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
}
.ovik-modal-overlay.open { display: flex; }
.ovik-modal {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 40px rgba(0,0,0,.18);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.ovik-modal__head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid #e8e8e8;
    flex-shrink: 0;
}
.ovik-modal__title {
    flex: 1;
    font-size: 1.05em;
    font-weight: 700;
    color: #1a1a2e;
}
.ovik-modal__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: #888;
    font-size: 1em;
    cursor: pointer;
    transition: background .2s, color .2s;
}
.ovik-modal__close:hover { background: #f2f2f2; color: #333; }
.ovik-modal__body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}
.ovik-modal__foot {
    padding: 14px 20px;
    border-top: 1px solid #e8e8e8;
    display: flex;
    justify-content: flex-end;
    flex-shrink: 0;
}
.ovik-modal__save {
    background: #009be3;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 10px 28px;
    font-size: 0.97em;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s;
}
.ovik-modal__save:hover { background: #007bbf; }
.ovik-project__form {
    display: grid;
    gap: 14px;
}
.ovik-project__form label {
    display: block;
    font-size: 0.9em;
    font-weight: 600;
    color: #0d416e;
    margin-bottom: 4px;
}
.ovik-project__form input,
.ovik-project__form textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.95em;
    box-sizing: border-box;
}
.ovik-project__form input:focus,
.ovik-project__form textarea:focus {
    outline: none;
    border-color: #009be3;
    box-shadow: 0 0 0 2px rgba(0,155,227,.2);
}
.ovik-project__form textarea { min-height: 70px; resize: vertical; }
.ovik-project-floors-row {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
    margin-bottom: 24px;
    min-width: 0;
    width: 100%;
}
.ovik-project-floors-row .ovik-project {
    margin-bottom: 0;
    flex: 0 0 auto;
    width: 100%;
    align-self: flex-start;
}
.ovik-project-floors-row .ovik-floors {
    flex: 1 1 auto;
    margin-bottom: 0;
}
@media (min-width: 600px) {
    .ovik-project-floors-row { flex-direction: row; }
    .ovik-project-floors-row .ovik-project { flex: 0 0 auto; width: auto; min-width: 200px; max-width: 320px; }
}
@media (max-width: 480px) {
    .ovik-project__head { padding: 12px 14px; gap: 10px; }
    .ovik-project__text { font-size: 0.95em; }
}
.ovik-floors {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 24px;
    position: relative;
}
.ovik-floors-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    flex: 1 1 auto;
    min-width: 0;
}
.ovik-floor-tab {
    flex: 0 0 auto;
    min-width: 90px;
    padding: 12px 24px;
    background: #fff;
    border: 2px solid #009be3;
    border-radius: 8px;
    font-weight: 600;
    color: #0d416e;
    cursor: pointer;
    transition: background .2s, color .2s;
}
.ovik-floor-tab:hover { background: rgba(0,155,227,.12); color: #0d416e; }
.ovik-floor-tab.active {
    background: #009be3;
    color: #fff;
    border-color: #009be3;
}
@media (max-width: 599px) {
    .ovik-project-floors-row .ovik-floors {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        align-self: stretch;
    }
    .ovik-floor-del, .ovik-floor-add-wrap {
        flex-shrink: 0;
    }
    .ovik-floor-del, .ovik-floor-add {
        padding: 12px 10px;
        min-width: 36px;
    }
    .ovik-floor-tab {
        min-width: 0;
        flex: 1 1 auto;
        padding: 10px 12px;
        font-size: 0.88em;
    }
}
.ovik-floor-del, .ovik-floor-add-wrap { flex-shrink: 0; }
.ovik-floor-add {
    padding: 12px 20px;
    background: transparent;
    border: 2px dashed #009be3;
    border-radius: 8px;
    color: #009be3;
    font-size: 1.2em;
    cursor: pointer;
    transition: background .2s, color .2s;
}
.ovik-floor-add:hover { background: rgba(0,155,227,.1); }
.ovik-floor-add-wrap { position: relative; }
.ovik-floor-add-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 6px;
    background: #fff;
    border: 2px solid #009be3;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,.12);
    z-index: 100;
    min-width: 160px;
    overflow: hidden;
}
.ovik-floor-add-dropdown.open { display: block; }
.ovik-floor-add-opt {
    display: block;
    width: 100%;
    padding: 12px 20px;
    text-align: left;
    background: transparent;
    border: none;
    font-size: 1em;
    font-weight: 600;
    color: #0d416e;
    cursor: pointer;
    transition: background .2s;
}
.ovik-floor-add-opt:hover { background: rgba(0,155,227,.1); }
.ovik-floor-add-opt + .ovik-floor-add-opt { border-top: 1px solid #e8e8e8; }
.ovik-floor-del {
    padding: 12px 20px;
    background: transparent;
    border: 2px dashed #009be3;
    border-radius: 8px;
    color: #009be3;
    font-size: 1.2em;
    cursor: pointer;
    transition: background .2s, color .2s;
}
.ovik-floor-del:hover { background: rgba(0,155,227,.1); }
.ovik-floor-del:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}
.ovik-main {
    display: flex;
    gap: 24px;
    background: #fff;
    border: 2px solid #009be3;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,155,227,.12);
}
.ovik-rooms-wrap {
    width: 220px;
    flex-shrink: 0;
    padding: 12px 0;
    border-right: 1px solid #e8e8e8;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.ovik-rooms {
    flex: 1;
    padding: 0 0 0 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.ovik-room-item {
    display: flex;
    align-items: stretch;
    gap: 0;
    padding: 0;
    border-radius: 6px;
    border-left: 4px solid transparent;
    transition: background .2s, border-color .2s;
    width: 100%;
    min-width: 0;
}
.ovik-room-item:hover { background: rgba(0,155,227,.06); }
.ovik-room-item.active { background: rgba(0,155,227,.1); border-left-color: #009be3; }
.ovik-room-item .ovik-room-name-wrap {
    flex: 1;
    min-width: 0;
    padding: 10px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
}
.ovik-room-item .ovik-room-name-txt {
    font-size: 0.95em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ovik-room-item .ovik-room-name-inp {
    width: 100%;
    min-width: 0;
    padding: 6px 8px;
    border: 1px solid #009be3;
    border-radius: 4px;
    font-size: 0.95em;
    background: #fff;
}
.ovik-room-item .ovik-room-name-inp:focus { outline: none; }
.ovik-room-item .ovik-room-actions {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    padding: 4px 8px 4px 4px;
    gap: 2px;
}
.ovik-room-item .ovik-room-actions button {
    width: 28px;
    height: 26px;
    padding: 0;
    background: transparent;
    border: 1px solid #ddd;
    border-radius: 4px;
    color: #666;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85em;
    transition: background .2s, color .2s, border-color .2s;
}
.ovik-room-item .ovik-room-actions button:hover { background: rgba(0,155,227,.1); color: #009be3; border-color: #009be3; }
.ovik-room-item .ovik-room-actions .ovik-room-del:hover { background: rgba(229,57,53,.1); color: #e53935; border-color: #e53935; }
.ovik-room-item .ovik-room-actions .ovik-room-del:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }
.ovik-room-del-confirm {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,.4);
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
}
.ovik-room-del-confirm.visible { display: flex; }
.ovik-room-del-confirm .ovik-del-popup {
    background: #fff;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,.2);
    max-width: 320px;
}
.ovik-room-del-confirm .ovik-del-popup p { margin: 0 0 20px; font-size: 1em; }
.ovik-room-del-confirm .ovik-del-popup .ovik-del-btns { display: flex; gap: 12px; justify-content: flex-end; }
.ovik-room-del-confirm .ovik-del-popup button { padding: 10px 20px; border-radius: 6px; cursor: pointer; font-size: 0.95em; }
.ovik-room-del-confirm .ovik-del-popup .ovik-del-cancel { background: #f0f0f0; border: 1px solid #ddd; }
.ovik-room-del-confirm .ovik-del-popup .ovik-del-ok { background: #e53935; color: #fff; border: none; }
.ovik-room-add-wrap { position: relative; display: block; margin-top: 4px; }
.ovik-room-add {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 10px 12px;
    background: transparent;
    border: 2px dashed #009be3;
    border-radius: 6px;
    color: #009be3;
    font-size: 0.95em;
    cursor: pointer;
    transition: background .2s, color .2s;
}
.ovik-room-add:hover { background: rgba(0,155,227,.1); }
.ovik-room-add-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    min-width: 100%;
    max-height: 50vh;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,.1);
    display: none;
    z-index: 100;
}
.ovik-room-add-dropdown.open { display: block; }
.ovik-room-add-dropdown.open-up {
    top: auto;
    bottom: 100%;
    margin-top: 0;
    margin-bottom: 4px;
}
.ovik-room-add-dropdown button {
    display: block;
    width: 100%;
    padding: 10px 14px;
    background: transparent;
    border: none;
    text-align: left;
    font-size: 0.95em;
    cursor: pointer;
    transition: background .2s;
}
.ovik-room-add-dropdown button:hover { background: rgba(0,155,227,.08); }
.ovik-room-content {
    flex: 1;
    min-width: 0;
    padding: 20px;
}
.ovik-section-ttl { margin: 0 0 12px; font-size: 1em; color: #666; }
.ovik-char-wrap {
    margin-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}
.ovik-char-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: #f5f9fc;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    font-size: 0.9em;
    cursor: pointer;
    transition: background .2s, border-color .2s;
}
.ovik-char-chip:hover { background: #e8f4fc; border-color: #009be3; }
.ovik-char-chip .ovik-char-label { color: #666; }
.ovik-char-chip .ovik-char-value { font-weight: 600; color: #0d416e; min-width: 1.5em; font-variant-numeric: tabular-nums; }
.ovik-char-chip .ovik-char-input {
    width: 56px;
    padding: 4px 8px;
    border: 1px solid #009be3;
    border-radius: 4px;
    font-size: 0.9em;
    box-sizing: border-box;
}
.ovik-char-chip.power .ovik-char-value { color: #e53935; }
.ovik-devices-wrap { margin-top: 0; }
.ovik-devices-add { margin-bottom: 12px; }
.ovik-device-add-wrap { position: relative; display: inline-block; }
.ovik-room-content { overflow: visible; }
.ovik-device-add-btn {
    padding: 10px 16px;
    background: transparent;
    border: 2px dashed #009be3;
    border-radius: 6px;
    color: #009be3;
    font-size: 0.95em;
    cursor: pointer;
    transition: background .2s, color .2s;
}
.ovik-device-add-btn:hover { background: rgba(0,155,227,.1); }
.ovik-device-add-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    min-width: 200px;
    max-height: 70vh;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,.1);
    display: none;
    z-index: 100;
}
.ovik-device-add-dropdown.open { display: block; }
.ovik-device-add-dropdown.open-up {
    top: auto;
    bottom: 100%;
    margin-top: 0;
    margin-bottom: 4px;
}
.ovik-device-add-dropdown button {
    display: block;
    width: 100%;
    padding: 10px 16px;
    background: transparent;
    border: none;
    text-align: left;
    font-size: 0.95em;
    cursor: pointer;
    transition: background .2s;
}
.ovik-device-add-dropdown button:hover { background: rgba(0,155,227,.08); }
.ovik-devices-list { list-style: none; margin: 0; padding: 0; }
.ovik-device-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    margin-bottom: 8px;
    background: #f5f9fc;
    border-radius: 8px;
    border: 1px solid #e8e8e8;
}
.ovik-device-item .ovik-device-del { padding: 4px 10px; color: #e53935; border: 1px solid #e53935; border-radius: 4px; cursor: pointer; background: transparent; }
.ovik-room-btn {
    display: block;
    width: 100%;
    padding: 12px 20px;
    text-align: left;
    background: transparent;
    border: none;
    border-left: 4px solid transparent;
    font-size: 0.95em;
    color: #333;
    cursor: pointer;
    transition: background .2s, border-color .2s;
}
.ovik-room-btn:hover, .ovik-room-btn.active {
    background: rgba(0,155,227,.08);
    border-left-color: #009be3;
    color: #0d416e;
}
@media (max-width: 768px) {
    .ovik-main { flex-direction: column; }
    .ovik-rooms-wrap { width: 100%; border-right: none; border-bottom: 1px solid #e8e8e8; padding: 12px; }
    .ovik-rooms { flex-direction: row; flex-wrap: wrap; gap: 8px; }
    .ovik-room-item { flex: 1 1 auto; min-width: 140px; }
    .ovik-room-add-wrap { margin: 0; flex: 1 1 auto; min-width: 140px; }
    .ovik-room-content { padding: 12px; }
    .ovik-char-chip { padding: 6px 10px; font-size: 0.85em; }
}
