:root {
    /* Палитра: Dusty Rose & Deep Plum */
    --primary-color: #e5989b;    /* Пыльная роза */
    --secondary-color: #b5838d;  /* Темная роза */
    --dark-text: #453750;        /* Глубокий сливовый */
    --accent-bg: #f8edeb;       /* Теплый беж (фон карточек) */
    --main-bg: #fdfaf9;          /* Общий фон */
    --white: #ffffff;
    --success: #a7c957;
    --error: #f28482;
    --shadow: 0 10px 40px rgba(69, 55, 80, 0.1);
    --gradient: linear-gradient(135deg, #e5989b 0%, #b5838d 100%);
}

* {
    box-sizing: border-box;
    margin: 0; padding: 0;
    font-family: 'Inter', 'Segoe UI', sans-serif;
}

body {
    background-color: var(--main-bg);
    color: var(--dark-text);
    line-height: 1.6;
}

/* --- Красивые плашки статистики --- */
.crm-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
    margin-bottom: 40px;
}

.crm-card {
    background: var(--white);
    padding: 30px;
    border-radius: 24px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow);
    border: 1px solid rgba(181, 131, 141, 0.1);
    transition: transform 0.3s ease;
}

.crm-card:hover { transform: translateY(-5px); }

/* Декоративный элемент на плашке */
.crm-card::after {
    content: '';
    position: absolute;
    top: -20px; right: -20px;
    width: 80px; height: 80px;
    background: var(--primary-color);
    opacity: 0.1;
    border-radius: 50%;
}

.crm-card h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--secondary-color);
    margin-bottom: 10px;
    font-weight: 700;
}

.crm-card .value {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--dark-text);
    display: block;
}

/* Акцентная плашка с градиентом (например, для дохода) */
.crm-card.highlight {
    background: var(--gradient);
}
.crm-card.highlight h3, 
.crm-card.highlight .value { color: var(--white); }

/* --- Контейнеры и Карточки --- */
.container { max-width: 1200px; margin: 2rem auto; padding: 0 20px; }

.card {
    background: var(--white);
    border-radius: 24px;
    padding: 2.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 30px;
}

/* --- Кнопки --- */
.btn {
    padding: 14px 30px;
    border-radius: 16px;
    font-weight: 700;
    transition: all 0.3s;
    cursor: pointer;
    display: inline-block;
    text-decoration: none;
    border: none;
}

.btn-primary {
    background: var(--gradient);
    color: var(--white);
    box-shadow: 0 8px 20px rgba(181, 131, 141, 0.3);
}

.btn-primary:hover {
    filter: brightness(1.1);
    box-shadow: 0 10px 25px rgba(181, 131, 141, 0.5);
}

/* --- Таблицы --- */
.table-wrapper { overflow-x: auto; border-radius: 20px; }
table { width: 100%; border-collapse: collapse; background: var(--white); }
th { background: #fcf8f8; padding: 20px; text-align: left; color: var(--secondary-color); font-size: 0.8rem; text-transform: uppercase; }
td { padding: 20px; border-bottom: 1px solid #f1f1f1; }

/* --- Адаптивность --- */
@media (max-width: 768px) {
    .crm-grid { grid-template-columns: 1fr; }
    .container { margin: 1rem auto; padding: 0 15px; }
    .card { padding: 1.5rem; border-radius: 20px; }
    h1 { font-size: 1.8rem; margin-bottom: 15px; }
    
    /* Улучшение таблиц */
    .table-wrapper th, .table-wrapper td { padding: 12px; white-space: nowrap; }
    
    /* Модальные окна */
    .modal-content { width: 95%; padding: 20px; margin: 10px; }
    
    /* Hero секция */
    .hero-section { padding: 60px 15px 80px; border-radius: 0 0 30px 30px; }
    .hero-title { font-size: 2rem; }
    .hero-subtitle { font-size: 1rem; }
}
/* --- Стили новой шапки --- */
.main-header {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px); /* Эффект матового стекла */
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(229, 152, 155, 0.2);
    position: sticky;
    top: 0;
    z-index: 1000;
    padding: 0.8rem 0;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Логотип */
.logo {
    text-decoration: none;
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--dark-text);
    letter-spacing: -1px;
}

.logo span {
    color: var(--secondary-color);
}

/* Навигация */
.nav-menu {
    display: flex;
    align-items: center;
}

.nav-link {
    text-decoration: none;
    color: var(--dark-text);
    font-weight: 600;
    margin: 0 15px;
    font-size: 0.95rem;
    transition: color 0.3s;
}

.nav-link:hover {
    color: var(--primary-color);
}

.user-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Кнопка Профиля */
.btn-profile {
    background: var(--accent-bg);
    color: var(--secondary-color);
    padding: 8px 18px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-profile:hover {
    background: var(--primary-color);
    color: white;
}

/* Кнопка выхода */
.btn-logout {
    color: #b5838d;
    display: flex;
    align-items: center;
    padding: 8px;
    border-radius: 12px;
    transition: all 0.3s;
}

.btn-logout:hover {
    background: #fff0f0;
    color: var(--error);
}

/* --- Гамбургер-меню --- */
.hamburger {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 30px;
    height: 20px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1002;
}

.hamburger span {
    width: 100%;
    height: 2px;
    background-color: var(--dark-text);
    border-radius: 2px;
    transition: all 0.3s ease;
}

/* Блокировка скролла при открытом меню */
body.no-scroll { overflow: hidden; }

/* Адаптивность для мобильных */
@media (max-width: 768px) {
    .header-container {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
    
    .hamburger { display: flex; }

    .nav-menu {
        position: fixed;
        top: 0;
        right: -100%;
        width: 100%;
        height: 100vh;
        background: rgba(255, 255, 255, 0.98);
        backdrop-filter: blur(10px);
        flex-direction: column;
        justify-content: center;
        align-items: center;
        transition: right 0.3s ease;
        z-index: 1001;
        padding: 40px;
    }
    
    .nav-menu.active { right: 0; }
    
    .nav-link {
        margin: 15px 0;
        font-size: 1.3rem;
    }
    
    /* Компактный выбор города */
    .city-picker {
        padding: 5px 8px;
    }
    
    .user-actions, .auth-buttons {
        flex-direction: column;
        width: 100%;
        gap: 20px;
        justify-content: center;
    }
    
    .btn-profile, .btn-logout, .btn-primary {
        width: 100%;
        justify-content: center;
        text-align: center;
        padding: 15px;
        font-size: 1rem;
    }

    /* Анимация крестика */
    .hamburger.active span:nth-child(1) { transform: translateY(9px) rotate(45deg); }
    .hamburger.active span:nth-child(2) { opacity: 0; }
    .hamburger.active span:nth-child(3) { transform: translateY(-9px) rotate(-45deg); }
}
input {
    width: 100%;
    padding: 16px;
    margin-top: 8px;
    border: 2px solid #f1f1f1;
    border-radius: 16px; /* Мягкое скругление как у карточек */
    background-color: #fdfaf9;
    color: var(--dark-text);
    font-size: 1rem;
    transition: all 0.3s ease;
    outline: none;
}

input:focus {
    border-color: var(--primary-color);
    background-color: var(--white);
    box-shadow: 0 0 0 4px rgba(229, 152, 155, 0.1); /* Нежное розовое свечение */
}

input::placeholder {
    color: #ccc;
}
.custom-select {
    width: 100%;
    padding: 16px;
    margin-top: 8px;
    border: 2px solid #f1f1f1;
    border-radius: 16px;
    background-color: #fdfaf9;
    color: var(--dark-text);
    font-size: 1rem;
    cursor: pointer;
    appearance: none; /* Убираем стандартную стрелочку */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23b5838d' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: calc(100% - 20px) center;
    transition: all 0.3s ease;
}

.custom-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(229, 152, 155, 0.1);
}
.filter-wrapper {
    display: flex;
    gap: 12px;
    margin-top: 30px;
    overflow-x: auto; /* Прокрутка, если категорий много */
    padding-bottom: 10px;
    scrollbar-width: none; /* Скрываем скроллбар в Firefox */
}

.filter-wrapper::-webkit-scrollbar { display: none; } /* Скрываем в Chrome/Safari */

.filter-item {
    padding: 10px 22px;
    background: var(--white);
    border: 1px solid var(--accent-bg);
    border-radius: 50px;
    text-decoration: none;
    color: var(--secondary-color);
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    transition: all 0.3s ease;
}

.filter-item:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.filter-item.active {
    background: var(--gradient);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 15px rgba(229, 152, 155, 0.3);
}

/* Сетка мастеров */
.masters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 25px;
    margin-top: 20px;
}

.master-card {
    background: white;
    padding: 20px;
    border-radius: 24px;
    text-align: center;
    box-shadow: var(--shadow);
    transition: transform 0.3s ease;
}

.master-card:hover { transform: translateY(-5px); }

.master-card img {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 15px;
    border: 3px solid var(--accent-bg);
}
.header-left {
    display: flex;
    align-items: center;
    gap: 30px;
}

.city-picker {
    display: flex;
    align-items: center;
    background: var(--main-bg);
    padding: 5px 12px;
    border-radius: 10px;
    border: 1px solid rgba(0,0,0,0.05);
}

.city-picker .icon {
    margin-right: 5px;
    font-size: 0.9rem;
}

.header-city-select {
    border: none;
    background: transparent;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--dark-text);
    outline: none;
    cursor: pointer;
}

/* Для мобильных устройств прячем выбор города или адаптируем */
@media (max-width: 768px) {
    .header-left { gap: 15px; }
    .city-picker span { display: none; }
}
.status-badge { padding: 4px 8px; border-radius: 5px; font-size: 0.8rem; }
.status-pending { background: #fff3cd; color: #856404; }
.status-confirmed { background: #d4edda; color: #155724; }
.status-cancelled { background: #f8d7da; color: #721c24; }

/* --- Анимация появления (Fade In Up) --- */
.fade-in-up {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
    will-change: opacity, transform;
}

.fade-in-up.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* --- Адаптивные сетки (Новые классы) --- */
.services-layout { display: grid; grid-template-columns: 1fr 2fr; gap: 20px; }
.settings-layout { display: grid; grid-template-columns: 1.2fr 1fr; gap: 30px; align-items: start; }
.profile-layout { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }
.master-header-card { display: flex; gap: 30px; align-items: center; }
.client-header-flex { display: flex; gap: 20px; align-items: flex-start; }

/* Мобильная адаптация для сеток */
@media (max-width: 900px) {
    .services-layout, 
    .settings-layout, 
    .profile-layout { 
        grid-template-columns: 1fr; /* Перестраиваем в одну колонку */
    }
    
    .master-header-card,
    .client-header-flex {
        flex-direction: column;
        text-align: center;
        align-items: center;
    }
    
    .client-header-flex .profile-form-grid {
        text-align: left; /* Возвращаем выравнивание текста формы */
    }
    
    /* Кнопки на всю ширину на мобильных */
    .card-actions {
        flex-direction: column;
    }
    
    .card-actions .btn {
        width: 100%;
    }
}

/* --- Hero Section (Главный баннер) --- */
.hero-section {
    /* Картинка + Градиентное затемнение в цветах бренда */
    background: linear-gradient(135deg, rgba(229, 152, 155, 0.85), rgba(181, 131, 141, 0.85)), 
                url('https://images.unsplash.com/photo-1616394584738-fc6e612e71b9?q=80&w=2070&auto=format&fit=crop');
    background-size: cover;
    background-position: center;
    padding: 80px 20px 100px;
    text-align: center;
    color: white;
    border-radius: 0 0 50px 50px;
    margin-bottom: -50px; /* Чтобы контент "наезжал" на баннер */
    position: relative;
    z-index: 1;
    box-shadow: 0 20px 40px rgba(181, 131, 141, 0.2);
}

.hero-title {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: 15px;
    text-shadow: 0 4px 15px rgba(0,0,0,0.1);
    letter-spacing: -1px;
}

.hero-subtitle {
    font-size: 1.2rem;
    opacity: 0.95;
    margin-bottom: 40px;
    font-weight: 500;
}

/* Кнопки в карточке мастера */
.card-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

/* --- Чат Сайдбар (Drawer) --- */
.chat-sidebar {
    position: fixed;
    top: 0;
    right: -450px; /* Скрыт по умолчанию */
    width: 400px;
    height: 100vh;
    background: white;
    box-shadow: -5px 0 30px rgba(0,0,0,0.1);
    z-index: 2000;
    transition: right 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex;
    flex-direction: column;
}

.chat-sidebar.active { right: 0; }

.chat-sidebar-header { padding: 15px; border-bottom: 1px solid #eee; display: flex; align-items: center; gap: 15px; background: #fff; }
.chat-sidebar-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.chat-sidebar-close { margin-left: auto; background: none; border: none; font-size: 1.5rem; cursor: pointer; color: #999; }

.chat-sidebar-body { flex: 1; overflow-y: auto; padding: 15px; background: #f9f9f9; display: flex; flex-direction: column; gap: 10px; }
.chat-sidebar-footer { padding: 15px; border-top: 1px solid #eee; background: #fff; }

/* Стили сообщений (перенесены из chat.php) */
.message-bubble { max-width: 80%; padding: 10px 15px; border-radius: 15px; font-size: 0.9rem; line-height: 1.4; position: relative; word-wrap: break-word; }
.msg-sent { align-self: flex-end; background: var(--primary-color); color: white; border-bottom-right-radius: 2px; }
.msg-received { align-self: flex-start; background: white; color: var(--dark-text); border: 1px solid #eee; border-bottom-left-radius: 2px; }
.msg-time { font-size: 0.7rem; opacity: 0.7; margin-left: 5px; }
.msg-status { font-size: 0.75rem; margin-left: 5px; color: #aebac1; font-weight: bold; }
.msg-status.read { color: #fff; } /* Белый для отправленных (на цветном фоне) */

/* Индикатор печати */
.typing-indicator { font-size: 0.8rem; color: #999; margin: 5px 15px; height: 15px; font-style: italic; opacity: 0; transition: opacity 0.3s; }
.typing-indicator.active { opacity: 1; }
.typing-dots::after { content: '...'; animation: typing 1.5s infinite; }
@keyframes typing { 0% { content: '.'; } 33% { content: '..'; } 66% { content: '...'; } }

/* Затемнение фона */
.chat-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.3); z-index: 1999; display: none; opacity: 0; transition: opacity 0.3s; }
.chat-overlay.active { display: block; opacity: 1; }

/* Мобильная адаптация чата */
@media (max-width: 600px) {
    .chat-sidebar {
        width: 100%;
        right: -100%;
    }
}