/* ============================================================
   Эпиляция CRM — стили
   ============================================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

body {
    background: #f5f0f8;
    padding: 12px;
    padding-bottom: 100px;
    min-height: 100vh;
}

/* iOS standalone режим */
@supports (-webkit-touch-callout: none) {
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
    .header { padding-top: env(safe-area-inset-top); }
}

/* Полноэкранный режим для Android */
@media display-mode: standalone {
    body { padding-top: 0; }
    .header { margin-top: 0; }
}

/* Служебные элементы */
.hidden-data { display: none; }

.divider {
    border: none;
    border-top: 2px dashed #e8dff0;
    margin: 12px 0;
}

/* ===== ШАПКА ===== */
.header {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.header input {
    flex: 1;
    min-width: 140px;
    padding: 14px 18px;
    border: none;
    border-radius: 30px;
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    font-size: 16px;
}

.header input:focus { outline: 2px solid #b388c9; }

.header button {
    padding: 14px 20px;
    border: none;
    border-radius: 30px;
    background: #6c3b8c;
    color: white;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(108, 59, 140, 0.3);
    white-space: nowrap;
}

.header button:active { transform: scale(0.96); }

/* ===== СПИСОК КЛИЕНТОВ ===== */
.list-card {
    background: white;
    border-radius: 16px;
    padding: 14px 16px;
    margin-bottom: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
    border-left: 5px solid #c9a8d9;
    cursor: pointer;
    transition: 0.1s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.list-card:active { background: #f8f2fc; }
.list-card .name { font-size: 17px; font-weight: 600; color: #2d1b36; }
.list-card .phone { font-size: 14px; color: #7a6a82; }

.list-card .assoc {
    font-size: 13px;
    color: #8a7a92;
    max-width: 45%;
    text-align: right;
    word-break: break-word;
}

.empty {
    text-align: center;
    padding: 50px 20px;
    color: #a090a8;
}

.empty span {
    font-size: 40px;
    display: block;
    margin-bottom: 8px;
}

/* ===== МОДАЛКИ ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 999;
    backdrop-filter: blur(4px);
    overflow-y: auto;
    padding: 20px 0;
}

.modal.show { display: flex; }

.modal-content {
    background: white;
    width: 94%;
    max-width: 500px;
    border-radius: 32px;
    padding: 24px 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-height: 95vh;
    overflow-y: auto;
    margin: 10px 0;
}

.modal-content::-webkit-scrollbar { width: 4px; }
.modal-content::-webkit-scrollbar-thumb { background: #c9a8d9; border-radius: 10px; }

.modal-title {
    font-size: 20px;
    font-weight: 700;
    color: #2d1b36;
    margin-bottom: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title .close-btn {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #999;
    padding: 0 8px;
}

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

.modal-title .title-left span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ===== ПОЛЯ ВВОДА ===== */
.field-group { margin-bottom: 14px; }

.field-group label {
    font-size: 13px;
    font-weight: 600;
    color: #5a4a62;
    display: block;
    margin-bottom: 3px;
}

.field-group input,
.field-group textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #e0d6e6;
    border-radius: 16px;
    font-size: 15px;
    color: #1a0a24;
    background: #fff;
    transition: 0.2s;
}

.field-group input:focus,
.field-group textarea:focus {
    outline: 2px solid #b388c9;
    border-color: transparent;
}

.field-group textarea { resize: vertical; min-height: 60px; }

.field-group input#clientAssociation {
    border: 1px solid #d4b0e0;
    background: #faf8fb;
    transition: 0.1s;
}

/* ===== ШАБЛОН ЗОН ===== */
.zone-template-simple {
    background: #f8f4fa;
    border-radius: 16px;
    padding: 12px 14px;
    border: 2px solid #d4b0e0;
}

.zone-template-simple .zone-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.zone-template-simple .zone-row textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 12px;
    font-size: 14px;
    background: white;
    font-family: inherit;
    line-height: 1.4;
    resize: none;
    overflow: hidden;
    min-height: 42px;
    box-sizing: border-box;
    color: #1a0a24;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;
}

.zone-template-simple .zone-row textarea:focus,
.zone-template-simple .zone-row .price-input:focus {
    outline: 2px solid #b388c9;
    border-color: transparent;
}

.zone-template-simple .zone-row .price-input {
    width: 150px;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 12px;
    font-size: 14px;
    background: white;
    color: #1a0a24;
}

/* ===== ПОДСКАЗКИ ЗОН ===== */
.zone-ac {
    position: fixed;
    z-index: 1500;
    background: white;
    border-radius: 14px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
    max-height: 210px;
    overflow-y: auto;
    min-width: 180px;
    display: none;
    border: 1px solid #e0d6e6;
}

.zone-ac-item {
    padding: 10px 14px;
    font-size: 14px;
    color: #2d1b36;
    cursor: pointer;
    transition: 0.1s;
}

.zone-ac-item.active,
.zone-ac-item:hover {
    background: #f3ebf8;
    color: #6c3b8c;
    font-weight: 600;
}

/* ===== ПРИЁМЫ ===== */
.visit-block {
    background: #faf8fb;
    border-radius: 16px;
    padding: 12px 14px;
    margin-bottom: 10px;
    border: 1px solid #ede6f2;
    position: relative;
}

.visit-block .delete-visit {
    position: absolute;
    top: 8px;
    right: 12px;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #cc8888;
}

.visit-block .visit-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 4px;
    align-items: flex-start;
}

.visit-block .visit-row input,
.visit-block .visit-row textarea {
    flex: 1;
    min-width: 70px;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 12px;
    font-size: 14px;
    background: white;
    font-family: inherit;
    color: #1a0a24;
}

.visit-block .visit-row input:focus,
.visit-block .visit-row textarea:focus {
    outline: 2px solid #b388c9;
    border-color: transparent;
}

.visit-block .visit-row textarea {
    flex: 2.5;
    min-width: 120px;
    resize: none;
    overflow: hidden;
    line-height: 1.4;
    min-height: 36px;
    box-sizing: border-box;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;
}

.visit-block .visit-row .date-input {
    min-width: 120px;
    flex: 1.2;
    font-weight: 600;
}

.visit-block .visit-row .zone-input { flex: 2.5; min-width: 120px; }
.visit-block .visit-row .time-input { max-width: 80px; flex: 0.8; }
.visit-block .visit-row .sum-input { max-width: 110px; flex: 1; }

/* Заметка к приёму — авторасширяемая textarea */
.visit-block .visit-note {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 12px;
    font-size: 14px;
    background: white;
    margin-top: 4px;
    color: #1a0a24;
    font-family: inherit;
    line-height: 1.4;
    resize: none;
    overflow: hidden;
    min-height: 34px;
    box-sizing: border-box;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;
}

.visit-block .visit-note:focus {
    outline: 2px solid #b388c9;
    border-color: transparent;
}

.add-visit-btn {
    background: #ede6f2;
    border: 2px dashed #b388c9;
    border-radius: 16px;
    padding: 12px;
    width: 100%;
    font-size: 15px;
    font-weight: 600;
    color: #6c3b8c;
    cursor: pointer;
    transition: 0.1s;
    margin: 4px 0 10px;
}

.add-visit-btn:active { background: #dccce6; }

/* ===== ИТОГИ ===== */
.totals {
    background: #f0ebf5;
    border-radius: 16px;
    padding: 14px 16px;
    margin: 12px 0;
    display: flex;
    justify-content: space-between;
    font-weight: 700;
    font-size: 17px;
    color: #2d1b36;
}

.totals span { color: #6c3b8c; }

/* ===== МЕССЕНДЖЕРЫ ===== */
.messengers-group { margin-top: 8px; }

.messengers-icons {
    display: flex;
    gap: 16px;
    justify-content: center;
    padding: 8px 0 4px;
    flex-wrap: wrap;
}

.messenger-item {
    display: flex;
    align-items: center;
    gap: 4px;
    background: #f0ebf5;
    border-radius: 30px;
    padding: 4px 8px 4px 4px;
    transition: 0.2s;
}

.messenger-item.active {
    background: #6c3b8c;
    box-shadow: 0 4px 12px rgba(108, 59, 140, 0.3);
}

.messenger-item .icon-btn {
    cursor: pointer;
    background: none;
    border: none;
    padding: 4px 8px;
    border-radius: 30px;
    transition: 0.1s;
    opacity: 0.35;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6c3b8c;
}

.messenger-item .icon-btn svg { width: 28px; height: 28px; }

.messenger-item.active .icon-btn {
    opacity: 1;
    color: white;
}

.messenger-item.active .icon-btn svg { fill: white; }

.messenger-item .icon-btn:active { transform: scale(0.85); }

.messenger-item .dots-btn {
    font-size: 18px;
    cursor: pointer;
    background: none;
    border: none;
    padding: 4px 4px 4px 0;
    color: #999;
    font-weight: 700;
    line-height: 1;
    transition: 0.1s;
}

.messenger-item.active .dots-btn { color: rgba(255, 255, 255, 0.7); }
.messenger-item .dots-btn:active { transform: scale(0.85); }

/* ===== ТОСТ ===== */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: #2d1b36;
    color: white;
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    z-index: 2000;
    opacity: 0;
    transition: 0.3s;
    pointer-events: none;
    white-space: nowrap;
}

.toast.show { opacity: 1; }

/* ===== ПОПАП МЕССЕНДЖЕРА ===== */
.messenger-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.messenger-popup.show { display: flex; }

.messenger-popup-content {
    background: white;
    border-radius: 28px;
    padding: 24px 20px;
    width: 90%;
    max-width: 360px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.messenger-popup-content h3 {
    margin-bottom: 12px;
    color: #2d1b36;
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.messenger-popup-content h3 .popup-icon { font-size: 26px; }

.messenger-popup-content input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #ddd;
    border-radius: 16px;
    font-size: 15px;
    margin-bottom: 12px;
}

.messenger-popup-content input:focus {
    outline: 2px solid #b388c9;
    border-color: transparent;
}

.messenger-popup-content .popup-actions {
    display: flex;
    gap: 10px;
}

.messenger-popup-content .popup-actions button {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 30px;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
}

.messenger-popup-content .popup-actions .save-popup { background: #6c3b8c; color: white; }
.messenger-popup-content .popup-actions .cancel-popup { background: #eee; color: #333; }
.messenger-popup-content .popup-actions button:active { transform: scale(0.96); }

/* ===== КНОПКИ КАРТОЧКИ ===== */
.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.modal-actions button {
    flex: 1;
    padding: 14px;
    border: none;
    border-radius: 30px;
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    min-width: 100px;
}

.modal-actions .save-btn {
    background: #6c3b8c;
    color: white;
    box-shadow: 0 4px 12px rgba(108, 59, 140, 0.3);
}

.modal-actions .delete-btn { background: #fee8e8; color: #b33; }

.modal-actions .save-btn:active,
.modal-actions .delete-btn:active { transform: scale(0.96); }

.modal-actions button.delete-btn-dots {
    flex: 0 0 auto !important;
    width: 34px !important;
    height: 34px;
    min-width: 0 !important;
    padding: 0 !important;
    align-self: center;
    border: none;
    border-radius: 50%;
    background: #f5f0f8;
    color: #b399c2;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    line-height: 1;
    transition: 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.delete-btn-dots:hover { background: #fee8e8; color: #b33; }
.delete-btn-dots:active { transform: scale(0.9); }

/* ===== ПЛАВАЮЩИЕ КНОПКИ ===== */
.fab {
    position: fixed;
    bottom: 28px;
    right: 28px;
    background: #6c3b8c;
    color: white;
    border: none;
    border-radius: 60px;
    padding: 16px 24px;
    font-size: 17px;
    font-weight: bold;
    box-shadow: 0 8px 24px rgba(108, 59, 140, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 100;
}

.fab:active { transform: scale(0.92); }

.stats-fab {
    left: 28px;
    right: auto;
    bottom: 28px;
    width: 60px;
    height: 60px;
    padding: 0;
    justify-content: center;
    font-size: 26px;
    background: #4caf7d;
    box-shadow: 0 8px 24px rgba(76, 175, 125, 0.4);
    border-radius: 50%;
}

/* ===== СТАТИСТИКА ЗАРАБОТКА ===== */
.stats-modal-content { max-width: 420px; }

.stats-big {
    background: linear-gradient(135deg, #4caf7d 0%, #3d9a6b 100%);
    border-radius: 20px;
    padding: 18px 20px;
    margin-bottom: 12px;
    color: white;
    text-align: center;
}

.stats-big .stats-amount { font-size: 32px; font-weight: 800; }
.stats-big .stats-label { font-size: 13px; opacity: 0.85; margin-top: 2px; }

.stats-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f5f0f8;
    border-radius: 16px;
    padding: 14px 18px;
    margin-bottom: 8px;
}

.stats-row .stats-row-label { font-size: 15px; color: #5a4a62; font-weight: 600; }
.stats-row .stats-row-value { font-size: 18px; font-weight: 700; color: #6c3b8c; }

.stats-months { margin-top: 14px; }

.stats-months-title {
    font-size: 13px;
    font-weight: 700;
    color: #5a4a62;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stats-month-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 9px 14px;
    border-bottom: 1px solid #f0e8f5;
    font-size: 15px;
}

.stats-month-row:last-child { border-bottom: none; }
.stats-month-row .m-name { color: #5a4a62; font-weight: 500; }
.stats-month-row .m-sum { color: #6c3b8c; font-weight: 700; }

/* ===== МОБИЛЬНАЯ АДАПТАЦИЯ ===== */
@media (max-width: 450px) {
    .modal-content { padding: 18px 14px; }

    .visit-block .visit-row input,
    .visit-block .visit-row textarea {
        min-width: 50px;
        font-size: 13px;
        padding: 6px 8px;
    }

    .zone-template-simple .zone-row textarea,
    .zone-template-simple .zone-row .price-input {
        font-size: 13px;
        padding: 8px 10px;
    }

    .messenger-item .icon-btn { padding: 2px 6px; }
    .messenger-item .icon-btn svg { width: 24px; height: 24px; }
    .messenger-item .dots-btn { font-size: 16px; }
    .messengers-icons { gap: 10px; }

    .toast {
        font-size: 13px;
        padding: 10px 18px;
        white-space: normal;
        max-width: 90%;
    }
}

/* ===== ФОТО ПРИЁМОВ ===== */
.visit-photos {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
    align-items: center;
}

.visit-photo-item {
    position: relative;
    width: 80px;
    height: 80px;
}

.visit-photo-thumb {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 12px;
    cursor: pointer;
    border: 1px solid #e0d6e6;
    display: block;
    transition: 0.1s;
}

.visit-photo-thumb:active {
    transform: scale(0.95);
}

.photo-remove-btn {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #e05252;
    color: white;
    border: none;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    padding: 0;
    transition: 0.1s;
}

.photo-remove-btn:hover {
    background: #c73e3e;
    transform: scale(1.1);
}

.visit-photo-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 2px dashed #b388c9;
    border-radius: 14px;
    font-size: 13px;
    font-weight: 600;
    color: #6c3b8c;
    background: #faf5fd;
    cursor: pointer;
    transition: 0.1s;
}

.visit-photo-btn:active {
    background: #f0e5f8;
    transform: scale(0.97);
}

.visit-photo-input {
    display: none;
}

/* ===== ПРОСМОТР ФОТО ===== */
.photo-viewer {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    z-index: 3000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.photo-viewer.show {
    display: flex;
}

.photo-viewer img {
    max-width: 100%;
    max-height: 100%;
    border-radius: 12px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}

.photo-viewer-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border: none;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
    transition: 0.1s;
}

.photo-viewer-close:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* ===== МЕТКА "АВТО" ===== */
.sum-wrap {
    position: relative;
    display: flex;
    align-items: center;
    gap: 4px;
}

.sum-auto-tag {
    font-size: 11px;
    font-weight: 600;
    color: #4caf7d;
    background: #e8f5ee;
    padding: 2px 6px;
    border-radius: 6px;
    white-space: nowrap;
}

