/* ===== Beauty CRM — фирменный стиль =====
   Палитра: тёплый айвори, кофейный графит, терракота-роза, золото. */
:root {
    --bg: #f7f3ee;
    --bg-deep: #f1eae2;
    --card: #ffffff;
    --ink: #26201c;
    --muted: #8b7f76;
    --line: #eae1d8;
    --accent: #c0705f;
    --accent-dark: #a95d4d;
    --gold: #b08a4f;
    --ok: #5e8b6a;
    --hot: #c0574a;
    --warm: #c8873b;
    --cold: #7a93a8;
    --radius: 14px;
    --shadow: 0 6px 24px rgba(38, 32, 28, 0.07);
    --serif: Georgia, "Times New Roman", serif;
    --sans: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    background: var(--bg);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 15px;
    line-height: 1.5;
    min-height: 100vh;
}

h1, h2, .brand, .login-brand { font-family: var(--serif); font-weight: 600; }
h1 { font-size: 26px; }
h2 { font-size: 18px; margin-bottom: 12px; }
a { color: var(--accent-dark); text-decoration: none; }
code { background: var(--bg-deep); padding: 1px 6px; border-radius: 6px; font-size: 13px; }
.muted { color: var(--muted); }

/* ===== Каркас: сайдбар + контент ===== */
.brand { font-size: 20px; letter-spacing: 2px; color: var(--ink); }
.brand-dot { color: var(--gold); }
.user-name { color: var(--muted); }

.app { display: flex; min-height: 100vh; }
.sidebar {
    width: 224px;
    flex-shrink: 0;
    background: var(--card);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 40;
}
.side-brand { display: block; padding: 20px 18px 12px; }
.side-switch { padding: 0 14px 10px; }
.side-switch select { width: 100%; }
.side-nav { flex: 1; padding: 4px 10px 10px; }
.side-group {
    font-size: 10px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--muted);
    padding: 14px 10px 6px;
}
.side-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 10px;
    color: var(--ink);
    font-size: 14px;
    margin-bottom: 2px;
}
.side-nav a span { width: 20px; text-align: center; }
.side-nav a:hover { background: var(--bg); }
.side-nav a.active {
    background: #f7e7e2;
    color: var(--accent-dark);
    font-weight: 600;
}
.side-foot {
    border-top: 1px solid var(--line);
    padding: 12px 14px;
}
.side-foot .user-name { display: block; font-size: 13px; margin-bottom: 8px; }
.side-foot-actions { display: flex; gap: 8px; align-items: center; }

.maincol { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.mobilebar { display: none; }
.overlay { display: none; }

.page { padding: 24px 28px 48px; width: 100%; max-width: 1500px; margin: 0 auto; flex: 1; }

@media (max-width: 900px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-100%);
        transition: transform 0.2s;
        box-shadow: 0 0 40px rgba(38, 32, 28, 0.25);
    }
    .sidebar.open { transform: translateX(0); }
    .overlay.show {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(38, 32, 28, 0.35);
        z-index: 30;
    }
    .mobilebar {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 12px 16px;
        background: var(--card);
        border-bottom: 1px solid var(--line);
        position: sticky;
        top: 0;
        z-index: 20;
    }
    .burger {
        border: 1px solid var(--line);
        background: var(--bg);
        border-radius: 10px;
        font-size: 18px;
        padding: 4px 12px;
        cursor: pointer;
    }
    .page { padding: 16px 14px 40px; }
}
.page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 20px;
}
.page-sub { color: var(--muted); margin-top: 4px; }
.head-actions { display: flex; gap: 10px; align-items: center; }

/* ===== Кнопки ===== */
.btn {
    display: inline-block;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 9px 18px;
    font-size: 14px;
    cursor: pointer;
    transition: 0.15s;
    font-family: var(--sans);
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-primary:disabled { background: var(--muted); cursor: wait; }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--line); }
.btn-ghost:hover { color: var(--ink); border-color: var(--muted); }
.btn-gold { background: #fff7ea; color: var(--gold); border-color: #e4d3b6; }
.btn-gold:hover { background: #fdefd8; }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-block { width: 100%; }

/* ===== Карточки ===== */
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.pad { padding: 20px; }
.narrow { max-width: 720px; }

.alert {
    background: #fdf0ee;
    border: 1px solid #eccfc9;
    color: var(--accent-dark);
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 16px;
}

.pill { padding: 3px 10px; border-radius: 99px; font-size: 12px; }
.pill-ok { background: #edf4ef; color: var(--ok); }
.pill-warn { background: #fdf3e4; color: var(--warm); }

/* ===== Вход ===== */
.login-wrap { display: flex; justify-content: center; padding-top: 10vh; }
.login-card {
    width: 380px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow);
    padding: 36px;
    text-align: center;
}
.login-brand { font-size: 26px; letter-spacing: 3px; }
.login-sub { color: var(--muted); margin: 6px 0 24px; font-size: 13px; }
.login-card form { text-align: left; }

/* ===== Формы ===== */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field span { font-size: 13px; color: var(--muted); }
.field input, .field select, .field textarea, .chat-form textarea {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 9px 12px;
    font-size: 14px;
    font-family: var(--sans);
    background: #fdfbf9;
    color: var(--ink);
    width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus, .chat-form textarea:focus {
    outline: none;
    border-color: var(--accent);
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.form-grid .field-wide { grid-column: 1 / -1; }
.check-field { flex-direction: row; align-items: center; gap: 9px; }
.check-field input[type="checkbox"] { width: auto; accent-color: var(--accent); }
.check-field span { font-size: 14px; color: var(--ink); }

/* ===== Доска ===== */
.board {
    display: flex;
    gap: 14px;
    overflow-x: auto;
    align-items: flex-start;
    padding-bottom: 12px;
}
.column {
    background: var(--bg-deep);
    border-radius: var(--radius);
    min-width: 272px;
    width: 272px;
    flex-shrink: 0;
}
.column-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px 8px;
    font-weight: 600;
}
.column-count {
    background: var(--card);
    border-radius: 99px;
    font-size: 12px;
    padding: 1px 9px;
    color: var(--muted);
}
.column-body { padding: 6px 10px 12px; min-height: 60px; display: flex; flex-direction: column; gap: 10px; }
.column-body.drop-target { outline: 2px dashed var(--accent); outline-offset: -4px; border-radius: 10px; }
.column-empty { color: var(--muted); font-size: 13px; text-align: center; padding: 14px 0; }

.lead-card { padding: 12px 14px; cursor: grab; }
.lead-card.dragging { opacity: 0.5; }
.lead-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.lead-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lead-line { font-size: 13px; color: var(--muted); margin-top: 2px; }
.lead-service { color: var(--gold); }
.lead-src { float: right; font-size: 12px; }
.lead-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px dashed var(--line);
}
.lead-resp { font-size: 12px; color: var(--muted); }

.badge { border-radius: 99px; font-size: 11px; padding: 2px 9px; color: #fff; white-space: nowrap; }
.badge-hot { background: var(--hot); }
.badge-warm { background: var(--warm); }
.badge-cold { background: var(--cold); }

/* ===== Карточка лида ===== */
.detail-grid { display: grid; grid-template-columns: 1fr 1.1fr; gap: 18px; align-items: start; }
@media (max-width: 1000px) { .detail-grid { grid-template-columns: 1fr; } }

.chat-card { display: flex; flex-direction: column; }
.chat-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.chat-scroll {
    overflow-y: auto;
    max-height: 480px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 4px 2px;
}
.chat-page .chat-scroll { max-height: 56vh; min-height: 200px; }
.bubble {
    border-radius: 14px;
    padding: 10px 14px;
    max-width: 85%;
    font-size: 14px;
}
.bubble-client { background: var(--bg-deep); align-self: flex-start; }
.bubble-ai { background: #f4ede1; align-self: flex-start; border: 1px solid #e9dcc6; }
.bubble-staff { background: #f7e7e2; align-self: flex-end; }
.bubble-meta { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.bubble-text { white-space: pre-wrap; word-break: break-word; }
.chat-form { display: flex; gap: 10px; margin-top: 14px; align-items: flex-end; }
.chat-form textarea { flex: 1; resize: vertical; }

/* ===== AI-команда ===== */
.quick { margin-bottom: 22px; }
.quick-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.quick-chip {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 99px;
    padding: 8px 16px;
    font-size: 13px;
    color: var(--ink);
    box-shadow: var(--shadow);
}
.quick-chip:hover { border-color: var(--accent); }

.agent-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
    gap: 14px;
}
.agent-card { display: block; padding: 18px; color: var(--ink); transition: 0.15s; }
.agent-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.agent-emoji { font-size: 28px; }
.agent-title { font-family: var(--serif); font-size: 17px; margin-top: 8px; }
.agent-tagline { color: var(--gold); font-size: 13px; margin-top: 2px; }
.agent-desc { color: var(--muted); font-size: 13px; margin-top: 8px; min-height: 40px; }
.agent-open { display: inline-block; margin-top: 10px; font-size: 13px; color: var(--accent-dark); }
.agent-intro { padding: 20px; color: var(--ink); }
.agent-intro .muted { margin-top: 8px; }

/* ===== Таблицы ===== */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
    text-align: left;
    color: var(--muted);
    font-weight: 500;
    font-size: 12px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--line);
}
.table td { padding: 9px 10px; border-bottom: 1px solid var(--bg-deep); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table-plain td { border: none; padding: 6px 10px; }
.row-muted { opacity: 0.55; }
.cell-actions { display: flex; gap: 6px; align-items: center; white-space: nowrap; }
.cell-actions form { display: inline; }
.btn-danger { color: var(--hot); }
.mt { margin-top: 18px; }

.alert-ok { background: #edf4ef; border-color: #cfe0d4; color: var(--ok); }
.pill-cat { background: var(--bg-deep); color: var(--ink); }

/* ===== Анкета салона ===== */
.profile-section { margin-bottom: 16px; }
.section-hint { margin: -6px 0 10px; font-size: 13px; }
.save-bar {
    position: sticky;
    bottom: 12px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 12px 16px;
    display: flex;
    justify-content: flex-end;
}

/* ===== Мастера ===== */
.master-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.master-card {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-start;
}
.master-name { font-weight: 600; font-size: 15px; }
.master-services { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.checkbox-list, .checkbox-row { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.checkbox-list li, .checkbox-row li { list-style: none; }
.checkbox-list label, .checkbox-row label { display: flex; gap: 6px; align-items: center; font-size: 14px; }
.check-line { flex-direction: row !important; align-items: center; gap: 8px; }
.check-line span { font-size: 14px; color: var(--ink); }

/* ===== Календарь записей ===== */
.cal-wrap { overflow-x: auto; }
.cal-table { width: 100%; border-collapse: collapse; min-width: 700px; }
.cal-table th {
    padding: 10px;
    border-bottom: 1px solid var(--line);
    font-family: var(--serif);
    font-size: 15px;
    text-align: left;
}
.cal-hour-col { width: 64px; }
.cal-hour { color: var(--muted); font-size: 12px; padding: 8px 10px; vertical-align: top; }
.cal-cell {
    border: 1px solid var(--bg-deep);
    padding: 4px;
    vertical-align: top;
    min-width: 150px;
    height: 52px;
    position: relative;
}
.cal-off { background: repeating-linear-gradient(45deg, #f3ede6, #f3ede6 6px, #efe7de 6px, #efe7de 12px); }
.cal-add {
    position: absolute;
    right: 6px;
    bottom: 4px;
    color: var(--line);
    font-size: 16px;
    line-height: 1;
    padding: 2px 6px;
    border-radius: 6px;
}
.cal-cell:hover .cal-add { color: var(--accent); background: #f7e7e2; }
.appt {
    display: block;
    border-radius: 8px;
    padding: 4px 8px;
    font-size: 12px;
    margin-bottom: 3px;
    color: var(--ink);
    background: #f7e7e2;
    border-left: 3px solid var(--accent);
}
.appt-done { background: #edf4ef; border-left-color: var(--ok); }
.appt-no_show { background: #fdf0ee; border-left-color: var(--hot); opacity: 0.8; }
.appt-time { font-weight: 600; margin-right: 4px; }
.appt-service { display: block; color: var(--muted); }
.appt-pill-scheduled { background: #f7e7e2; color: var(--accent-dark); }
.appt-pill-done { background: #edf4ef; color: var(--ok); }
.appt-pill-cancelled { background: var(--bg-deep); color: var(--muted); }
.appt-pill-no_show { background: #fdf0ee; color: var(--hot); }
.inline-form { display: inline; }
.day-nav { flex-wrap: wrap; }
.pay-form { margin-bottom: 12px; }
.action-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

/* ===== Поиск ===== */
.searchbox { display: flex; gap: 8px; margin-bottom: 14px; max-width: 480px; }
.searchbox input {
    flex: 1;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 9px 12px;
    background: var(--card);
    font-size: 14px;
}

/* ===== Сегодня ===== */
.today-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 1000px) { .today-grid { grid-template-columns: 1fr; } }
.today-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 10px;
    border-radius: 10px;
    border: 1px solid var(--bg-deep);
    margin-bottom: 8px;
    color: var(--ink);
    flex-wrap: wrap;
}
a.today-item:hover { border-color: var(--accent); }
.today-time { font-weight: 700; font-family: var(--serif); min-width: 46px; }
.today-main { flex: 1; min-width: 160px; }
.remind-actions { display: flex; gap: 6px; align-items: center; }
.count-pill {
    background: var(--bg-deep);
    border-radius: 99px;
    font-size: 12px;
    padding: 1px 9px;
    color: var(--muted);
    vertical-align: middle;
}
.today-item.appt-done { background: #f4faf6; }

/* ===== Аналитика ===== */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { padding: 16px; text-align: center; }
.stat-value { font-family: var(--serif); font-size: 24px; }
.stat-label { color: var(--muted); font-size: 12px; margin-top: 4px; }
.bars { display: flex; gap: 8px; align-items: flex-end; height: 140px; padding-top: 10px; }
.bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; }
.bar { width: 70%; background: var(--accent); border-radius: 6px 6px 0 0; min-height: 2px; }
.bar-label { font-size: 10px; color: var(--muted); margin-top: 4px; }

/* ===== База знаний ===== */
.kb-form { display: grid; grid-template-columns: 200px 1fr auto; gap: 10px; align-items: start; }
.kb-form select, .kb-form textarea {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 9px 12px;
    font-size: 14px;
    background: #fdfbf9;
    width: 100%;
}
@media (max-width: 800px) { .kb-form { grid-template-columns: 1fr; } }
.kb-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.kb-entry { border-top: 1px dashed var(--line); padding: 12px 0; display: flex; gap: 12px; align-items: flex-start; }
.kb-entry:first-of-type { border-top: none; }
.kb-text { flex: 1; font-size: 14px; }
.kb-meta { display: flex; gap: 10px; align-items: center; }

/* ===== Онлайн-чат: настройки ===== */
.code-block {
    background: var(--bg-deep);
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 12px;
    overflow-x: auto;
    margin: 8px 0;
    white-space: pre-wrap;
    word-break: break-all;
}
.qr-card { text-align: center; }
.qr-box { display: flex; justify-content: center; padding: 10px; }
.qr-box svg { width: 220px; height: 220px; }

/* ===== Переключатель организаций ===== */
.salon-switch select {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 6px 10px;
    background: var(--bg);
    font-size: 13px;
    color: var(--ink);
    max-width: 210px;
}

/* ===== Подсказка «Как всё устроено» ===== */
.howto { margin-bottom: 18px; background: #fffdf7; border-color: #eadfc9; }
.howto-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.howto-head h2 { margin-bottom: 0; }
.howto-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 8px 20px;
    font-size: 13px;
    color: var(--muted);
}
.howto-grid b { color: var(--ink); }

/* ===== Внимание: ждут ответа ===== */
.card-attention { border-left: 4px solid var(--warm); }
.debt { color: var(--hot); font-size: 12px; margin-left: 6px; }
.searchbox-inline { margin-bottom: 0; }
.searchbox-inline input { min-width: 220px; }
.nav-admin { color: var(--gold) !important; }
.block-title { margin: 22px 0 10px; font-size: 16px; }
.unread-pill { background: var(--hot); color: #fff; margin-left: auto; }
.bar-gold { background: var(--gold); }
.load-bar {
    display: inline-block;
    width: 70px;
    height: 8px;
    background: var(--bg-deep);
    border-radius: 99px;
    margin-right: 6px;
    vertical-align: middle;
    overflow: hidden;
}
.load-fill { display: block; height: 100%; background: var(--ok); border-radius: 99px; }
