.color-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 99999;
    justify-content: center;
    align-items: center;
}
.color-modal-overlay.show { display: flex; }
.color-modal {
    display: none;
    background: #252526;
    border: 2px solid #4a7aae;
    border-radius: 12px;
    padding: 24px 32px 28px 32px;
    max-width: 520px;
    width: 92%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.9);
    z-index: 999999;
    max-height: 90vh;
    overflow-y: auto;
}
.color-modal.show { display: block; animation: modalFadeIn 0.25s ease-out; }
@keyframes modalFadeIn {
    from { opacity: 0; transform: scale(0.95) translateY(-10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}
.color-modal-title {
    color: #d4d4d4;
    font-size: 18px;
    font-family: 'Segoe UI', sans-serif;
    font-weight: 600;
    margin-bottom: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.color-modal-title .close-btn {
    background: transparent;
    border: none;
    color: #888;
    font-size: 24px;
    cursor: pointer;
    padding: 0 6px;
    line-height: 1;
    transition: color 0.2s;
}
.color-modal-title .close-btn:hover { color: #ff6b6b; }
.color-modal-subtitle {
    color: #888;
    font-size: 13px;
    font-family: 'Segoe UI', sans-serif;
    margin-bottom: 18px;
    border-bottom: 1px solid #2d2d2d;
    padding-bottom: 10px;
}
.color-modal-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 16px;
    margin-bottom: 18px;
}
.color-modal-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 8px;
    border-radius: 4px;
    background: #1e1e1e;
    min-height: 32px;
}
.color-modal-item label {
    color: #aaaaaa;
    font-size: 12px;
    font-family: 'Segoe UI', sans-serif;
    width: 75px;
    min-width: 75px;
    font-weight: 500;
    flex-shrink: 0;
}
.color-modal-item input[type="color"] {
    width: 34px;
    height: 28px;
    border: 2px solid #3a3a3a;
    border-radius: 4px;
    background: transparent;
    cursor: pointer;
    padding: 2px;
    flex-shrink: 0;
}
.color-modal-item input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.color-modal-item input[type="color"]::-webkit-color-swatch { border: none; border-radius: 2px; }
.color-modal-item .color-hex {
    color: #666;
    font-size: 11px;
    font-family: 'Consolas', monospace;
    width: 58px;
    min-width: 58px;
    text-align: center;
    background: #111;
    padding: 2px 6px;
    border-radius: 3px;
    flex-shrink: 0;
}
.color-modal-item .color-spacer { flex: 1; }
.color-modal-actions {
    display: none;
    gap: 10px;
    justify-content: flex-end;
    border-top: 1px solid #2d2d2d;
    padding-top: 14px;
}
.color-modal-actions.show { display: flex; }
.color-modal-actions button {
    padding: 6px 22px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-family: 'Segoe UI', sans-serif;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}
.color-modal-actions .btn-reset {
    background: transparent;
    color: #888;
    border: 1px solid #3a3a3a;
}
.color-modal-actions .btn-reset:hover { background: rgba(255,255,255,0.05); color: #d4d4d4; }
.color-modal-actions .btn-cancel {
    background: transparent;
    color: #aaaaaa;
    border: 1px solid #3a3a3a;
}
.color-modal-actions .btn-cancel:hover { background: rgba(255,255,255,0.05); color: #ffffff; }
.color-modal-actions .btn-apply {
    background: #3a6a9e;
    color: white;
}
.color-modal-actions .btn-apply:hover { background: #4a7aae; box-shadow: 0 2px 10px rgba(58,106,158,0.3); }
.color-modal::-webkit-scrollbar { width: 6px; }
.color-modal::-webkit-scrollbar-track { background: #1e1e1e; }
.color-modal::-webkit-scrollbar-thumb { background: #3a3a3a; border-radius: 3px; }

/* ===== МОДАЛЬНОЕ ОКНО ШАБЛОНОВ ===== */
.template-modal-overlay {
    display: none;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(0, 0, 0, 0.7) !important;
    z-index: 99999 !important;
    justify-content: center !important;
    align-items: center !important;
}
.template-modal-overlay.show {
    display: flex !important;
}

.template-modal {
    display: none;
    background: #2d2d2d;
    border: 2px solid #4a7aae;
    border-radius: 12px;
    padding: 20px 24px 24px 24px;
    max-width: 520px;
    width: 92%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.9);
    z-index: 999999;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
}
.template-modal.show {
    display: block !important;
    animation: modalSlideIn 0.25s ease-out;
}

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

.template-modal-title {
    color: #d4d4d4;
    font-size: 17px;
    font-family: 'Segoe UI', sans-serif;
    font-weight: 600;
    margin-bottom: 2px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.template-modal-title .close-btn {
    background: transparent;
    border: none;
    color: #888;
    font-size: 22px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    transition: color 0.2s;
}
.template-modal-title .close-btn:hover { color: #ff6b6b; }

.template-modal-subtitle {
    color: #888;
    font-size: 12px;
    font-family: 'Segoe UI', sans-serif;
    margin-bottom: 10px;
    border-bottom: 1px solid #3a3a3a;
    padding-bottom: 8px;
}

.template-modal-body .form-group { margin-bottom: 10px; }
.template-modal-body .form-group label {
    display: block;
    color: #aaaaaa;
    font-size: 12px;
    font-family: 'Segoe UI', sans-serif;
    font-weight: 500;
    margin-bottom: 3px;
}
.template-modal-body .form-group input,
.template-modal-body .form-group textarea {
    width: 100%;
    padding: 6px 10px;
    background: #1e1e1e;
    border: 1px solid #3a3a3a;
    border-radius: 4px;
    color: #d4d4d4;
    font-size: 13px;
    font-family: 'Consolas', monospace;
    outline: none;
    box-sizing: border-box;
}
.template-modal-body .form-group input:focus,
.template-modal-body .form-group textarea:focus {
    border-color: #4a7aae;
}
.template-modal-body .form-group textarea {
    min-height: 80px;
    max-height: 150px;
    resize: vertical;
    font-family: 'Consolas', monospace;
    line-height: 1.5;
}

.template-modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    border-top: 1px solid #3a3a3a;
    padding-top: 10px;
    margin-top: 2px;
}
.template-modal-actions button {
    padding: 6px 16px;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    font-family: 'Segoe UI', sans-serif;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}
.template-modal-actions .btn-cancel {
    background: transparent;
    color: #aaaaaa;
    border: 1px solid #3a3a3a;
}
.template-modal-actions .btn-cancel:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #ffffff;
}
.template-modal-actions .btn-save {
    background: #3a6a9e;
    color: white;
}
.template-modal-actions .btn-save:hover {
    background: #4a7aae;
}
.template-modal-actions .btn-delete {
    background: transparent;
    color: #ff6b6b;
    border: 1px solid #ff6b6b;
}
.template-modal-actions .btn-delete:hover {
    background: rgba(255, 107, 107, 0.1);
}

.template-modal::-webkit-scrollbar { width: 6px; }
.template-modal::-webkit-scrollbar-track { background: #1a1a1a; }
.template-modal::-webkit-scrollbar-thumb { background: #3a3a3a; border-radius: 3px; }

@media (max-width: 768px) {
    .template-modal { max-width: 96%; padding: 14px 16px; }
    .template-modal-body .form-group textarea {
        min-height: 60px;
        max-height: 120px;
    }
}
