:root {
    --bg: #f5f7fa;
    --bg-card: #ffffff;
    --bg-hover: #f0f3ff;
    --bg-soft: #fafafa;
    --text: #333;
    --text-muted: #888;
    --text-faint: #999;
    --border: #eee;
    --primary: #667eea;
    --primary-hover: #5568d3;
    --primary-soft: #e8ecff;
    --shadow-sm: 0 2px 6px rgba(0,0,0,0.05);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 20px rgba(0,0,0,0.12);
    --skeleton-1: #f0f0f0;
    --skeleton-2: #e0e0e0;
}

body.dark {
    --bg: #0f1419;
    --bg-card: #1a2029;
    --bg-hover: #232b36;
    --bg-soft: #232b36;
    --text: #e6e8eb;
    --text-muted: #9ba3ae;
    --text-faint: #6b7280;
    --border: #2a3340;
    --primary: #7b8cff;
    --primary-hover: #667eea;
    --primary-soft: #2a3350;
    --shadow-sm: 0 2px 6px rgba(0,0,0,0.3);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 20px rgba(0,0,0,0.5);
    --skeleton-1: #232b36;
    --skeleton-2: #2f3a48;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: 'Segoe UI', Arial, sans-serif;
    background: var(--bg); color: var(--text);
    transition: background 0.25s, color 0.25s;
}

.container { max-width: 1400px; margin: 0 auto; padding: 0 20px; }

header {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white; padding: 15px 0; position: sticky; top: 0; z-index: 100;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
body.dark header { background: linear-gradient(135deg, #3d4a8a, #4a2d6b); }

.header-inner { display: flex; justify-content: space-between; align-items: center; gap: 15px; flex-wrap: wrap; }
.header-inner h1 { font-size: 22px; }
.header-right { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.header-link-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 10px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.2s, border-color 0.2s;
}
.header-link-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.6);
}

.header-inner input {
    padding: 8px 15px; border-radius: 20px; border: none;
    width: 250px; font-size: 14px; background: white; color: #333;
}
body.dark .header-inner input { background: rgba(255,255,255,0.15); color: #e6e8eb; }
body.dark .header-inner input::placeholder { color: rgba(255,255,255,0.6); }

#cartBtn {
    background: white; color: #667eea; border: none; padding: 10px 18px;
    border-radius: 20px; cursor: pointer; font-weight: bold; font-size: 14px;
}
body.dark #cartBtn { background: rgba(255,255,255,0.15); color: #e6e8eb; }
#cartBtn span {
    background: #ff4757; color: white; padding: 2px 8px;
    border-radius: 10px; margin-left: 5px; font-size: 12px;
}

.layout {
    display: grid; grid-template-columns: 260px 1fr;
    gap: 20px; padding-top: 25px; padding-bottom: 40px; align-items: start;
}

.sidebar {
    background: var(--bg-card); border-radius: 12px; padding: 18px;
    box-shadow: var(--shadow-sm); position: sticky; top: 85px;
    max-height: calc(100vh - 110px); overflow-y: auto;
    transition: background 0.25s;
}
.sidebar-title {
    font-size: 16px; margin-bottom: 14px; padding-bottom: 10px;
    border-bottom: 1px solid var(--border); color: var(--text);
}
.category-tree { font-size: 14px; }
.cat-loading { color: var(--text-muted); font-size: 13px; text-align: center; padding: 20px 0; }
.cat-item { margin-bottom: 2px; }
.cat-row {
    display: flex; align-items: center; gap: 6px;
    padding: 7px 10px; border-radius: 8px; cursor: pointer;
    transition: background 0.15s; user-select: none;
    line-height: 1.3; color: var(--text);
}
.cat-row:hover { background: var(--bg-hover); color: var(--primary); }
.cat-row.active { background: var(--primary); color: white; font-weight: 600; }
.cat-toggle {
    width: 16px; height: 16px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 10px; color: var(--text-muted); transition: transform 0.2s;
}
.cat-toggle.open { transform: rotate(90deg); }
.cat-toggle.empty { visibility: hidden; }
.cat-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-count { font-size: 11px; color: var(--text-faint); flex-shrink: 0; }
.cat-row.active .cat-count { color: rgba(255,255,255,0.8); }
.cat-children {
    padding-left: 14px; margin-left: 8px;
    border-left: 1px solid var(--border); display: none;
}
.cat-children.open { display: block; }

.active-category {
    display: flex; align-items: center; justify-content: space-between;
    background: var(--primary-soft); padding: 10px 15px; border-radius: 10px;
    margin-bottom: 15px; color: var(--primary); font-size: 14px;
}
.active-category button {
    background: none; border: none; font-size: 18px;
    cursor: pointer; color: var(--primary); padding: 0 5px; line-height: 1;
}

.main-content { min-width: 0; }

.status {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 15px; background: var(--bg-card); padding: 12px 20px;
    border-radius: 10px; box-shadow: var(--shadow-sm);
    color: var(--text); transition: background 0.25s;
}
#reloadBtn {
    background: var(--primary); color: white; border: none; padding: 8px 15px;
    border-radius: 8px; cursor: pointer; font-size: 14px;
}
#reloadBtn:hover { background: var(--primary-hover); }

.progress-box {
    display: flex; align-items: center; gap: 20px;
    background: var(--bg-card); padding: 20px 25px; border-radius: 12px;
    box-shadow: var(--shadow-md); margin-bottom: 20px;
    transition: opacity 0.5s, max-height 0.5s, padding 0.5s, margin 0.5s, background 0.25s;
    color: var(--text);
}
.progress-box.done {
    opacity: 0; max-height: 0;
    padding-top: 0; padding-bottom: 0; margin-bottom: 0;
    overflow: hidden; pointer-events: none;
}
.progress-icon { font-size: 36px; animation: spin 1.5s linear infinite; }
.progress-box.done .progress-icon { animation: none; }
@keyframes spin { 0%{transform:rotate(0)} 100%{transform:rotate(360deg)} }
.progress-content { flex: 1; min-width: 0; }
.progress-stage { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 10px; }
.progress-bar-track {
    width: 100%; height: 10px; background: var(--bg-hover);
    border-radius: 10px; overflow: hidden; position: relative;
}
.progress-bar-fill {
    height: 100%; width: 0%;
    background: linear-gradient(90deg, var(--primary), #764ba2);
    border-radius: 10px; transition: width 0.35s ease-out; position: relative;
}
.progress-bar-fill::after {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.5), transparent);
    animation: shine 1.5s infinite;
}
@keyframes shine { 0%{transform:translateX(-100%)} 100%{transform:translateX(100%)} }
.progress-meta {
    display: flex; justify-content: space-between;
    font-size: 13px; color: var(--text-muted); margin-top: 8px;
}
.progress-meta #progressPercent { font-weight: bold; color: var(--primary); }
.progress-meta #progressTime { font-variant-numeric: tabular-nums; }

.products {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 18px;
}
.card {
    background: var(--bg-card); border-radius: 12px; overflow: hidden;
    box-shadow: var(--shadow-md); display: flex; flex-direction: column;
    transition: transform 0.2s, box-shadow 0.2s, background 0.25s;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.card-img {
    width: 100%; height: 180px; background: var(--bg-soft);
    display: flex; align-items: center; justify-content: center;
    overflow: hidden; cursor: pointer; position: relative;
    transition: background 0.25s;
}
.card-img img { max-width: 100%; max-height: 100%; object-fit: contain; transition: transform 0.3s; }
.card-img:hover img { transform: scale(1.05); }
.card-img:hover::after {
    content: '🔍'; position: absolute; bottom: 8px; right: 8px;
    background: rgba(0,0,0,0.6); color: white; padding: 4px 8px;
    border-radius: 6px; font-size: 14px;
}
.img-skeleton {
    width: 100%; height: 100%;
    background: linear-gradient(90deg, var(--skeleton-1) 25%, var(--skeleton-2) 50%, var(--skeleton-1) 75%);
    background-size: 200% 100%; animation: shimmer 1.5s infinite;
}
@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
.card-body { padding: 12px 15px 15px; display: flex; flex-direction: column; flex: 1; }
.card-title {
    font-size: 14px; font-weight: 600; line-height: 1.3;
    margin-bottom: 6px; min-height: 36px; color: var(--text);
}
.card-sku { font-size: 11px; color: var(--text-faint); margin-bottom: 8px; }
.card-price { font-size: 20px; font-weight: bold; color: var(--primary); margin-bottom: 6px; }
.card-stock { font-size: 12px; color: #28a745; margin-bottom: 10px; }
.card-stock.out { color: #dc3545; }
.buy-btn {
    background: var(--primary); color: white; border: none; padding: 10px;
    border-radius: 8px; cursor: pointer; font-weight: 600;
    margin-top: auto; transition: background 0.2s;
}
.buy-btn:hover { background: var(--primary-hover); }
.buy-btn:disabled { background: #ccc; cursor: not-allowed; }
body.dark .buy-btn:disabled { background: #444; }

.error {
    text-align: center; padding: 30px 20px; font-size: 16px; color: #dc3545;
    background: var(--bg-card); border-radius: 12px; margin-bottom: 20px;
}

.modal {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.5); z-index: 1000;
    justify-content: center; align-items: center;
}
body.dark .modal { background: rgba(0,0,0,0.75); }
.modal.active { display: flex; }
.modal-box {
    background: var(--bg-card); padding: 30px; border-radius: 15px;
    width: 90%; max-width: 500px; max-height: 80vh; overflow-y: auto;
    position: relative; color: var(--text); transition: background 0.25s;
}
.close { position: absolute; right: 20px; top: 15px; font-size: 28px; cursor: pointer; color: var(--text-muted); }
.close:hover { color: var(--text); }

.cart-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 0; border-bottom: 1px solid var(--border); gap: 10px;
    color: var(--text);
}
.cart-row small { color: var(--text-muted); }
.cart-row button {
    background: #ff4757; color: white; border: none;
    width: 26px; height: 26px; border-radius: 50%; cursor: pointer;
}
.cart-total { margin: 20px 0; font-size: 20px; text-align: right; color: var(--text); }

.gallery-box {
    background: var(--bg-card); border-radius: 15px;
    width: 90%; max-width: 900px; max-height: 90vh;
    padding: 25px; position: relative;
    display: flex; flex-direction: column; overflow: hidden;
    transition: background 0.25s;
}
.gallery-main {
    position: relative; flex: 1;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-soft); border-radius: 10px;
    min-height: 400px; overflow: hidden; transition: background 0.25s;
}
#galleryMainImg { max-width: 100%; max-height: 70vh; object-fit: contain; }
.gallery-arrow {
    position: absolute; top: 50%; transform: translateY(-50%);
    background: rgba(0,0,0,0.5); color: white; border: none;
    width: 44px; height: 60px; font-size: 32px; line-height: 1;
    cursor: pointer; border-radius: 8px; transition: background 0.2s; z-index: 2;
}
.gallery-arrow:hover { background: rgba(0,0,0,0.8); }
.gallery-prev { left: 10px; }
.gallery-next { right: 10px; }
.gallery-title { text-align: center; font-size: 15px; color: var(--text); margin: 12px 0; font-weight: 600; }
.gallery-thumbs {
    display: flex; gap: 8px; justify-content: center; flex-wrap: wrap;
    padding-top: 10px; border-top: 1px solid var(--border);
    max-height: 120px; overflow-y: auto;
}
.gallery-thumb {
    width: 70px; height: 70px; object-fit: cover;
    border-radius: 6px; cursor: pointer; border: 2px solid transparent;
    background: var(--bg-soft); transition: border-color 0.2s;
}
.gallery-thumb:hover { border-color: #aaa; }
.gallery-thumb.active { border-color: var(--primary); }

.sort-wrapper { position: relative; }
.sort-btn {
    display: flex; align-items: center; gap: 8px;
    background: rgba(255, 255, 255, 0.15); color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 10px 16px; border-radius: 20px;
    cursor: pointer; font-weight: 600; font-size: 14px;
    transition: background 0.2s, border-color 0.2s; white-space: nowrap;
}
.sort-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
}
.sort-btn.active {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.7);
}
.sort-icon { font-size: 16px; font-weight: bold; }
.sort-label { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sort-caret { font-size: 10px; transition: transform 0.2s; }
.sort-btn.active .sort-caret { transform: rotate(180deg); }
.sort-menu {
    display: none; position: absolute;
    top: calc(100% + 8px); right: 0;
    background: var(--bg-card); border-radius: 10px;
    box-shadow: var(--shadow-lg); min-width: 230px; padding: 6px;
    z-index: 200; animation: dropdownFade 0.15s ease-out;
}
.sort-menu.open { display: block; }
@keyframes dropdownFade {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.sort-option {
    padding: 10px 14px; border-radius: 6px;
    cursor: pointer; font-size: 14px; color: var(--text);
    transition: background 0.15s; white-space: nowrap;
}
.sort-option:hover { background: var(--bg-hover); color: var(--primary); }
.sort-option.active { background: var(--primary); color: white; font-weight: 600; }

.theme-toggle {
    position: fixed; bottom: 25px; right: 25px; z-index: 500;
    width: 56px; height: 56px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: var(--primary); color: white; border: none; cursor: pointer;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4), 0 2px 6px rgba(0,0,0,0.15);
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
    font-size: 24px; line-height: 1; font-family: inherit;
}
.theme-toggle:hover {
    transform: translateY(-3px) scale(1.05);
    background: var(--primary-hover);
}
.theme-toggle:active { transform: translateY(0) scale(0.98); }
body.dark .theme-toggle {
    background: #f1c40f; color: #1a1a1a;
    box-shadow: 0 6px 20px rgba(241, 196, 15, 0.35), 0 2px 6px rgba(0,0,0,0.4);
}
body.dark .theme-toggle:hover { background: #ffd93b; }
.theme-icon { font-size: 24px; line-height: 1; display: block; }

@media (max-width: 900px) {
    .layout { grid-template-columns: 1fr; }
    .sidebar { position: static; max-height: none; }
    .category-tree { max-height: 300px; overflow-y: auto; }
}
@media (max-width: 700px) {
    .sort-label { display: none; }
    .sort-btn { padding: 10px 14px; }
    .theme-toggle { width: 48px; height: 48px; bottom: 18px; right: 18px; }
    .theme-icon { font-size: 20px; }
}
/* ==================== КНОПКА ПОЛЬЗОВАТЕЛЯ ==================== */
.user-btn {
    min-width: 90px;
    justify-content: center;
    gap: 8px;
}

.user-btn.logged-in {
    background: rgba(40, 200, 100, 0.25);
    border-color: rgba(40, 200, 100, 0.5);
}
.user-btn.logged-in:hover {
    background: rgba(40, 200, 100, 0.35);
}
/* ==================== РЕДАКТОР КОРЗИНЫ ==================== */
.cart-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.cart-row-info {
    flex: 1;
    min-width: 0;
}

.cart-row-name {
    font-size: 14px;
    color: var(--text);
    margin-bottom: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cart-row-price {
    font-size: 12px;
    color: var(--text-muted);
}

/* Контрол количества */
.qty-control {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-hover);
    border-radius: 8px;
    padding: 3px;
    flex-shrink: 0;
}

.qty-btn {
    width: 30px;
    height: 30px;
    border: none;
    background: var(--bg-card);
    color: var(--text);
    border-radius: 6px;
    cursor: pointer;
    font-size: 18px;
    font-weight: 700;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
    font-family: inherit;
    padding: 0;
}

.qty-btn:hover {
    background: var(--primary);
    color: white;
}

.qty-btn:active {
    transform: scale(0.95);
}

.qty-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    background: var(--bg-card);
    color: var(--text-faint);
}

.qty-input {
    width: 44px;
    height: 30px;
    border: none;
    background: var(--bg-card);
    color: var(--text);
    border-radius: 6px;
    text-align: center;
    font-size: 14px;
    font-weight: 700;
    font-family: inherit;
    padding: 0;
    -moz-appearance: textfield;
}

.qty-input::-webkit-outer-spin-button,
.qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.qty-input:focus {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}

/* Кнопка удаления */
.cart-row .remove-btn {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--text-faint);
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
    padding: 0;
    flex-shrink: 0;
}

.cart-row .remove-btn:hover {
    background: #ffe0e3;
    color: #dc3545;
}

body.dark .cart-row .remove-btn:hover {
    background: #3a1a1a;
    color: #ff6b7a;
}

/* Строка итога */
.cart-total {
    margin: 20px 0 15px;
    font-size: 20px;
    text-align: right;
    color: var(--text);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 15px;
    border-top: 2px solid var(--border);
}

.cart-total b {
    font-size: 24px;
    color: var(--primary);
}

/* Пустая корзина */
.cart-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.cart-empty-icon {
    font-size: 50px;
    margin-bottom: 15px;
    opacity: 0.6;
}
/* ==================== МОДАЛКА ОФОРМЛЕНИЯ ЗАКАЗА ==================== */
.checkout-modal-box {
    max-width: 480px;
    padding: 30px 30px 25px;
}

.checkout-modal-box h2 {
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    font-size: 20px;
}

.checkout-summary {
    background: var(--bg-hover);
    border-radius: 10px;
    padding: 14px 18px;
    margin-bottom: 20px;
}

.checkout-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    color: var(--text-muted);
    padding: 4px 0;
}

.checkout-summary-row b {
    color: var(--text);
    font-weight: 600;
}

.checkout-summary-total {
    border-top: 1px dashed var(--border);
    margin-top: 6px;
    padding-top: 10px;
    font-size: 15px;
}

.checkout-summary-total b {
    font-size: 20px;
    color: var(--primary);
}

.checkout-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.checkout-label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
}

.checkout-label input,
.checkout-label textarea {
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 15px;
    background: var(--bg-card);
    color: var(--text);
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.checkout-label input:focus,
.checkout-label textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.checkout-label textarea {
    resize: vertical;
    min-height: 70px;
    font-size: 14px;
}

.checkout-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.btn-outline {
    flex: 1;
    padding: 12px 20px;
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-main-checkout {
    flex: 2;
    padding: 12px 20px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.2s, transform 0.1s;
}

.btn-main-checkout:hover {
    background: var(--primary-hover);
}

.btn-main-checkout:active {
    transform: scale(0.98);
}

.btn-main-checkout:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
/* ==================== ЧАТ С МЕНЕДЖЕРОМ (вертикальный) ==================== */

/* Контейнер чата — на весь экран */
.chat-modal-vertical {
    background: var(--bg-card);
    border-radius: 16px;
    width: 100%;
    max-width: 520px;
    height: 90vh;
    max-height: 800px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: chatSlideIn 0.25s ease-out;
}

@keyframes chatSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Шапка чата */
.chat-header {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 18px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.chat-header-avatar {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.chat-header-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 3px;
}

.chat-header-status {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-header-status::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4cd964;
    box-shadow: 0 0 6px #4cd964;
    display: inline-block;
}

.chat-header-close {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    font-family: inherit;
}

.chat-header-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Подсказка */
.chat-hint {
    background: #f0f3ff;
    color: #5568d3;
    padding: 12px 18px;
    font-size: 13px;
    line-height: 1.5;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

body.dark .chat-hint {
    background: #2a3350;
    color: #b8c2ff;
}

/* Сообщения */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 18px;
    background: var(--bg-soft);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 20px;
    font-size: 14px;
}

.chat-empty-icon {
    font-size: 50px;
    margin-bottom: 12px;
    opacity: 0.6;
}

.chat-msg {
    display: flex;
    flex-direction: column;
    max-width: 80%;
}

.chat-msg-client {
    align-self: flex-end;
}

.chat-msg-admin {
    align-self: flex-start;
}

.chat-msg-bubble {
    padding: 11px 15px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.chat-msg-client .chat-msg-bubble {
    background: #667eea;
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-msg-admin .chat-msg-bubble {
    background: var(--bg-card);
    color: var(--text);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.chat-msg-time {
    font-size: 11px;
    color: var(--text-faint);
    margin-top: 4px;
    padding: 0 4px;
}

.chat-msg-client .chat-msg-time {
    text-align: right;
}

/* Поля имя/телефон */
.chat-name-block {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px 18px 0;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.chat-label {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
}

.chat-label input {
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    background: var(--bg-card);
    color: var(--text);
    font-family: inherit;
    transition: border-color 0.2s;
}

.chat-label input:focus {
    outline: none;
    border-color: var(--primary);
}

/* Форма ввода */
.chat-form {
    display: flex;
    gap: 10px;
    padding: 14px 18px 18px;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    align-items: center;
}

.chat-form input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 24px;
    font-size: 14px;
    background: var(--bg-hover);
    color: var(--text);
    font-family: inherit;
    transition: border-color 0.2s;
}

.chat-form input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-card);
}

.chat-form button {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: #667eea;
    color: white;
    border: none;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.1s;
    flex-shrink: 0;
    font-family: inherit;
    padding: 0;
}

.chat-form button:hover {
    background: #5568d3;
}

.chat-form button:active {
    transform: scale(0.95);
}

.chat-form button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chat-form button span {
    display: inline-block;
    transform: translateX(1px);
}

/* Мобильная адаптация */
@media (max-width: 600px) {
    .chat-modal-vertical {
        max-width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
}