/**
 * FaceMap Sidebar - СЛЕВА, тёмная тема как в оригинале
 */

/* Оверлей */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
    -webkit-tap-highlight-color: transparent;
}

.sidebar-overlay.show {
    opacity: 1;
    visibility: visible;
}

/* САЙДБАР - СЛЕВА */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    -webkit-transform: translateX(-100%);
    -ms-transform: translateX(-100%);
    transform: translateX(-100%);
    width: 420px;
    max-width: 100vw;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height для iOS */
    background: #1e293b;
    color: white;
    z-index: 2000;
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-flex-direction: column;
    -ms-flex-direction: column;
    flex-direction: column;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
    -webkit-transition: transform 0.3s ease;
    transition: transform 0.3s ease;
    -webkit-overflow-scrolling: touch;
}

.sidebar.open {
    -webkit-transform: translateX(0);
    -ms-transform: translateX(0);
    transform: translateX(0);
}

/* Header */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: #0f172a;
    border-bottom: 1px solid #334155;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid #3b82f6;
    object-fit: cover;
}

.sidebar-username {
    font-size: 16px;
    font-weight: 600;
    color: white;
}

.sidebar-role {
    font-size: 12px;
    color: #94a3b8;
}

.sidebar-close {
    width: 36px;
    height: 36px;
    border: none;
    background: #334155;
    color: white;
    border-radius: 8px;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s;
}

.sidebar-close:hover {
    background: #ef4444;
}

/* Tabs */
.sidebar-tabs {
    display: flex;
    background: #1e293b;
    border-bottom: 1px solid #334155;
    overflow-x: auto;
    position: relative;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.sidebar-tabs::-webkit-scrollbar {
    display: none;
}

.sidebar-tabs.has-overflow::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 36px;
    pointer-events: none;
    background: linear-gradient(90deg, rgba(30,41,59,0) 0%, rgba(30,41,59,0.88) 62%, rgba(30,41,59,1) 100%);
    transition: opacity 0.2s ease;
}

.sidebar-tabs.has-overflow::after {
    content: attr(data-scroll-hint);
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    font-weight: 700;
    color: #e2e8f0;
    pointer-events: none;
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
    line-height: 1;
    white-space: nowrap;
    transition: opacity 0.2s ease;
    z-index: 3;
    text-shadow: 0 1px 4px rgba(2, 6, 23, 0.6);
}

.sidebar-tabs.has-overflow.is-scrolled-end::before,
.sidebar-tabs.has-overflow.is-scrolled-end::after {
    opacity: 0;
}

.sidebar-tab {
    flex: 1;
    min-width: 70px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 8px;
    border: none;
    background: transparent;
    color: #94a3b8;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    white-space: nowrap;
    position: relative;
}

.sidebar-tab:hover {
    color: white;
    background: #0f172a;
}

.sidebar-tab.active {
    color: #3b82f6;
    border-bottom-color: #3b82f6;
    background: #0f172a;
}

.sidebar-tab-icon {
    font-size: 18px;
}

.sidebar-tab-badge {
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 999px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    position: absolute;
    top: 4px;
    right: 6px;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.5);
}

/* Content */
.sidebar-content {
    -webkit-box-flex: 1;
    -webkit-flex: 1;
    -ms-flex: 1;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    padding-bottom: 40px; /* Отступ снизу для iOS */
    -webkit-overflow-scrolling: touch; /* Плавная прокрутка на iOS */
    overscroll-behavior: contain; /* Предотвращает pull-to-refresh */
    min-height: 0; /* Важно для Firefox */
}

.sidebar-empty {
    text-align: center;
    color: #94a3b8;
    padding: 40px 20px;
}

/* Section header */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.section-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: white;
    margin: 0;
}

.section-hint {
    font-size: 13px;
    color: #94a3b8;
    margin-bottom: 16px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.btn-primary:hover {
    opacity: 0.9;
}

.btn-secondary {
    background: #334155;
    color: white;
}

.btn-secondary:hover {
    background: #475569;
}

.btn-success {
    background: #16a34a;
    color: #fff;
}

.btn-success:hover {
    background: #15803d;
}

.btn-danger {
    background: #dc2626;
    color: #fff;
}

.btn-danger:hover {
    background: #b91c1c;
}

.btn-sm {
    padding: 8px 12px;
    font-size: 13px;
}

.btn-full {
    width: 100%;
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.blocked-banner {
    margin: 12px 14px 0;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid #7f1d1d;
    background: #450a0a;
    color: #fecaca;
    font-size: 13px;
    line-height: 1.35;
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: #94a3b8;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #334155;
    border-radius: 8px;
    background: #0f172a;
    color: white;
    font-size: 14px;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #3b82f6;
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #334155;
}

.form-actions .btn {
    flex: 1;
}

/* Editor section */
.editor-section {
    background: #0f172a;
    border-radius: 12px;
    padding: 20px;
}

.editor-title {
    font-size: 18px;
    font-weight: 600;
    color: white;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid #334155;
}

/* Link rows */
.link-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.link-row input {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid #334155;
    border-radius: 6px;
    background: #0f172a;
    color: white;
    font-size: 13px;
}

.link-row .link-name { flex: 0.4; }
.link-row .link-url { flex: 0.6; }

.btn-x {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
    flex-shrink: 0;
}

.btn-x:hover {
    background: #ef4444;
    color: white;
}

/* Photo upload */
.photo-upload-area {
    display: flex;
    align-items: center;
    gap: 16px;
}

.photo-preview-large {
    width: 80px;
    height: 80px;
    border-radius: 12px;
    object-fit: cover;
    border: 2px solid #334155;
}

/* Avatar cropper */
.avatar-crop-overlay {
    position: fixed;
    inset: 0;
    z-index: 3200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(2, 6, 23, 0.8);
    backdrop-filter: blur(2px);
}

.avatar-crop-dialog {
    width: min(460px, 100%);
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}

.avatar-crop-title {
    font-size: 18px;
    font-weight: 700;
    color: #f8fafc;
}

.avatar-crop-subtitle {
    margin-top: 4px;
    margin-bottom: 14px;
    color: #94a3b8;
    font-size: 13px;
}

.avatar-crop-stage-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 14px;
}

.avatar-crop-toolbar {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.avatar-crop-tool-btn {
    flex: 1;
    border: 1px solid #334155;
    background: #1e293b;
    color: #e2e8f0;
    border-radius: 10px;
    padding: 8px 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.avatar-crop-tool-btn:hover {
    background: #334155;
    border-color: #475569;
}

.avatar-crop-tool-btn:disabled {
    opacity: 0.6;
    cursor: wait;
}

.avatar-crop-stage {
    position: relative;
    width: min(320px, 78vw);
    aspect-ratio: 1;
    border-radius: 12px;
    overflow: hidden;
    background: #020617;
    cursor: grab;
    touch-action: none;
}

.avatar-crop-stage.dragging {
    cursor: grabbing;
}

.avatar-crop-image {
    position: absolute;
    top: 0;
    left: 0;
    user-select: none;
    -webkit-user-drag: none;
    transform: translate(0, 0);
    transform-origin: top left;
}

.avatar-crop-mask {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.avatar-crop-mask::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 78%;
    height: 78%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.95);
    box-shadow: 0 0 0 200vmax rgba(2, 6, 23, 0.45);
}

.avatar-crop-controls {
    margin-bottom: 14px;
}

.avatar-crop-controls label {
    display: block;
    font-size: 13px;
    color: #cbd5e1;
    margin-bottom: 8px;
}

.avatar-crop-zoom {
    width: 100%;
}

.avatar-crop-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

@media (max-width: 560px) {
    .avatar-crop-dialog {
        padding: 14px;
    }

    .avatar-crop-stage {
        width: min(280px, 82vw);
    }
}

/* Photos preview */
.photos-preview {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.photo-thumb-wrap {
    position: relative;
    aspect-ratio: 1;
}

.photo-thumb-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
}

.photo-thumb-wrap button {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 20px;
    height: 20px;
    border: none;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    font-size: 12px;
    cursor: pointer;
}

.no-photos {
    color: #64748b;
    font-size: 13px;
    grid-column: 1 / -1;
}

/* Coords */
.coords-display {
    padding: 10px 12px;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 8px;
    color: #94a3b8;
    font-size: 13px;
    margin-bottom: 8px;
}

.coords-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.btn-cancel-map-pick {
    border: 1px solid #64748b;
    background: #1e293b;
    color: #cbd5e1;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #94a3b8;
}

.empty-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 12px;
    opacity: 0.5;
}

.empty-state p {
    font-size: 15px;
    margin-bottom: 8px;
}

.empty-state small {
    font-size: 12px;
    opacity: 0.7;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #94a3b8;
}

/* ==========================================
   ПРОФИЛЬ
   ========================================== */

.profile-hero {
    text-align: center;
    padding: 24px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 12px;
    margin-bottom: 20px;
}

.profile-photo-large {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 4px solid white;
    object-fit: cover;
    margin-bottom: 12px;
}

.profile-name-large {
    font-size: 20px;
    font-weight: 700;
    color: white;
    margin: 0 0 4px 0;
}

.profile-company {
    font-size: 14px;
    color: rgba(255,255,255,0.9);
}

.profile-company a {
    color: #ffffff;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.profile-company a:hover {
    opacity: 0.9;
}

.profile-slots-box {
    background: #0f172a;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
}

.slots-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    color: #e2e8f0;
    font-size: 14px;
}

.slots-info strong {
    color: #3b82f6;
}

.slots-progress {
    height: 8px;
    background: #334155;
    border-radius: 4px;
    overflow: hidden;
}

.slots-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #10b981);
    border-radius: 4px;
}

.profile-card {
    background: #0f172a;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
}

.profile-card h4 {
    font-size: 14px;
    font-weight: 600;
    color: #e2e8f0;
    margin: 0 0 12px 0;
}

.contact-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #334155;
    font-size: 14px;
    color: #e2e8f0;
}

.contact-row:last-child {
    border-bottom: none;
}

.contact-row span:first-child {
    color: #94a3b8;
}

.profile-bio {
    font-size: 14px;
    line-height: 1.6;
    color: #e2e8f0;
}

/* ==========================================
   БЕЙДЖИ
   ========================================== */

.badge-counter {
    background: #3b82f6;
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
}

.badges-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.badge-card-v2 {
    display: flex;
    gap: 12px;
    padding: 14px;
    background: #0f172a;
    border-radius: 12px;
    border: 1px solid #334155;
}

.badge-thumb {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
}

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

.badge-title {
    font-weight: 600;
    color: white;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.badge-meta {
    font-size: 12px;
    color: #94a3b8;
    margin-bottom: 6px;
}

.badge-status {
    font-size: 11px;
    font-weight: 600;
}

.status-active { color: #10b981; }
.status-paused { color: #f59e0b; }
.status-blocked { color: #ef4444; }

.badge-actions-v2 {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.badge-actions-v2 button {
    width: 32px;
    height: 32px;
    border: none;
    background: #334155;
    color: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
}

.badge-actions-v2 button:hover {
    background: #3b82f6;
}

.btn-danger-icon:hover {
    background: #ef4444 !important;
}

/* ==========================================
   СТАТИСТИКА
   ========================================== */

.stats-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.stat-card {
    background: #0f172a;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
}

.stat-num {
    font-size: 28px;
    font-weight: 700;
    color: white;
}

.stat-label {
    font-size: 12px;
    color: #94a3b8;
    margin-top: 4px;
}

/* ==========================================
   РЕФЕРАЛЫ
   ========================================== */

.referral-box {
    text-align: center;
    padding: 24px;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    border-radius: 12px;
    color: white;
}

.referral-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.referral-box h3 {
    margin: 0 0 8px 0;
    font-size: 22px;
}

.referral-box p {
    margin: 0 0 20px 0;
    opacity: 0.9;
}

.ref-stats {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-bottom: 20px;
}

.ref-stats div {
    text-align: center;
}

.ref-stats strong {
    display: block;
    font-size: 28px;
    font-weight: 700;
}

.ref-stats span {
    font-size: 12px;
    opacity: 0.8;
}

.ref-link-box {
    display: flex;
    gap: 8px;
    background: rgba(255,255,255,0.2);
    padding: 8px;
    border-radius: 8px;
}

.ref-link-box input {
    flex: 1;
    border: none;
    background: white;
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 13px;
    color: #333;
}

/* ==========================================
   АДМИН ПАНЕЛЬ - ОБЪЕКТЫ
   ========================================== */

.admin-panel {
    margin-bottom: 16px;
}

.admin-row {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
}

.btn-property-submit {
    padding: 8px 12px;
    font-size: 13px;
    line-height: 1.1;
    white-space: nowrap;
    border-radius: 10px;
}

.btn-property-draft {
    padding: 8px 10px;
    font-size: 12px;
    line-height: 1.1;
    white-space: nowrap;
    background: #1f2937;
    border: 1px solid #475569;
}

.prop-mode-switch {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.prop-mode-btn {
    flex: 1;
    border: 1px solid #334155;
    background: #0f172a;
    color: #cbd5e1;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.prop-mode-btn.active {
    border-color: #3b82f6;
    color: #bfdbfe;
    background: #1e3a8a33;
}

.search-input-dark {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #334155;
    border-radius: 8px;
    background: #0f172a;
    color: white;
    font-size: 14px;
}

.search-input-dark:focus {
    outline: none;
    border-color: #3b82f6;
}

.filters-box {
    background: #0f172a;
    border-radius: 12px;
    padding: 16px;
    border: 1px solid #334155;
}

.filter-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 12px;
}

.filter-row:last-child {
    margin-bottom: 0;
}

.filter-col-full {
    grid-column: 1 / -1;
}

.filter-col label {
    display: block;
    font-size: 12px;
    color: #94a3b8;
    margin-bottom: 6px;
}

.date-range {
    display: flex;
    align-items: center;
    gap: 8px;
}

.date-range input {
    flex: 1;
    padding: 8px;
    border: 1px solid #334155;
    border-radius: 6px;
    background: #1e293b;
    color: white;
    font-size: 12px;
}

.date-range span {
    color: #94a3b8;
}

.filter-col select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #334155;
    border-radius: 6px;
    background: #1e293b;
    color: white;
    font-size: 13px;
}

.quick-filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.quick-filters button {
    padding: 6px 14px;
    border: none;
    background: #334155;
    color: white;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
}

.quick-filters button:hover {
    background: #3b82f6;
}

@media (max-width: 768px) {
    .sidebar-tabs.has-overflow::before {
        width: 30px;
    }

    .sidebar-tabs.has-overflow::after {
        right: 8px;
        top: 50%;
        transform: translateY(-50%);
        font-size: 16px;
        padding: 0;
    }

    .btn-property-submit {
        padding: 7px 10px;
        font-size: 12px;
    }

    .btn-property-draft {
        padding: 7px 9px;
        font-size: 11px;
    }
}

/* Items list */
.items-list {
    margin-top: 12px;
}

.list-counter {
    font-size: 13px;
    color: #94a3b8;
    margin-bottom: 12px;
}

/* Property item */
.property-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #0f172a;
    border-radius: 10px;
    border: 1px solid #334155;
    margin-bottom: 10px;
}

.prop-num {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
    flex-shrink: 0;
}

.prop-thumb {
    width: 70px;
    height: 70px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
    background: #334155;
}

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

.prop-title {
    font-weight: 600;
    color: white;
    font-size: 14px;
    margin-bottom: 2px;
}

.prop-status-chip {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    margin-bottom: 4px;
}

.prop-status-chip.approved {
    color: #065f46;
    background: #d1fae5;
}

.prop-status-chip.pending {
    color: #92400e;
    background: #fef3c7;
}

.prop-status-chip.rejected {
    color: #991b1b;
    background: #fee2e2;
}

.prop-address {
    font-size: 12px;
    color: #94a3b8;
    margin-bottom: 4px;
}

.prop-bonus-line {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 999px;
    margin-bottom: 6px;
}

.prop-bonus-line.ok {
    background: rgba(16, 185, 129, 0.18);
    color: #6ee7b7;
}

.prop-bonus-line.pending {
    background: rgba(59, 130, 246, 0.16);
    color: #93c5fd;
}

.prop-bonus-line.warn {
    background: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
}

.prop-comment {
    font-size: 11px;
    color: #92400e;
    background: #fef3c7;
    padding: 3px 8px;
    border-radius: 4px;
    display: inline-block;
    margin-bottom: 4px;
}

.prop-meta {
    font-size: 11px;
    color: #64748b;
}

.prop-meta span {
    margin-left: 8px;
}

.prop-actions {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-shrink: 0;
}

.prop-actions button {
    width: 32px;
    height: 32px;
    border: none;
    background: #334155;
    color: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
}

.prop-actions button:hover {
    background: #3b82f6;
}

.prop-actions .btn-success-icon {
    background: #065f46;
    width: auto;
    min-width: 32px;
    padding: 0 10px;
    font-size: 12px;
}

.prop-actions .btn-success-icon:hover {
    background: #10b981;
}

/* Zone item */
.zone-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    background: #0f172a;
    border-radius: 10px;
    border: 1px solid #334155;
    margin-bottom: 10px;
}

.zone-color-dot {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    flex-shrink: 0;
}

.zone-info {
    flex: 1;
}

.zone-name {
    font-weight: 600;
    color: white;
}

.zone-price {
    font-size: 13px;
    color: #10b981;
    font-weight: 600;
}

.zone-actions {
    display: flex;
    gap: 6px;
}

.zone-actions button {
    width: 32px;
    height: 32px;
    border: none;
    background: #334155;
    color: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
}

.zone-actions button:hover {
    background: #3b82f6;
}

/* Agent item */
.agent-admin-card {
    margin-bottom: 10px;
    border: 1px solid #253447;
    border-radius: 14px;
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.96), rgba(11, 18, 32, 0.98));
    overflow: hidden;
    box-shadow: 0 8px 20px rgba(3, 8, 20, 0.28);
}

.agent-item {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
}

.agent-top {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.agent-photo {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid #4f74df;
    box-shadow: 0 0 0 3px rgba(79, 116, 223, 0.15);
}

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

.agent-name-row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.agent-name {
    font-size: 14px;
    font-weight: 700;
    color: white;
    line-height: 1.2;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.agent-account-status {
    border-radius: 999px;
    padding: 2px 8px;
    font-size: 10px;
    font-weight: 700;
    line-height: 1.2;
    border: 1px solid transparent;
    white-space: nowrap;
}

.agent-account-status.is-active {
    color: #10b981;
    background: rgba(16, 185, 129, 0.14);
    border-color: rgba(16, 185, 129, 0.35);
}

.agent-account-status.is-blocked {
    color: #f87171;
    background: rgba(248, 113, 113, 0.14);
    border-color: rgba(248, 113, 113, 0.35);
}

.agent-phone {
    font-size: 12px;
    color: #94a3b8;
    margin-top: 2px;
}

.agent-id-line {
    font-size: 11px;
    color: #93c5fd;
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.agent-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.agent-metric-chip {
    font-size: 11px;
    color: #c3dafe;
    padding: 5px 9px;
    border-radius: 999px;
    background: rgba(51, 65, 85, 0.45);
    border: 1px solid rgba(80, 98, 124, 0.7);
}

.agent-metric-chip strong {
    color: #ffffff;
    font-weight: 700;
}

.agent-admin-actions {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
}

.agent-action-btn {
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 7px 8px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.2;
    color: #e2e8f0;
    background: #334155;
    cursor: pointer;
    transition: transform 0.16s ease, filter 0.16s ease, background 0.16s ease;
}

.agent-action-btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.05);
}

.agent-action-btn.is-neutral {
    background: #273549;
    border-color: #324965;
    color: #dbeafe;
}

.agent-action-btn.is-chat {
    background: rgba(56, 189, 248, 0.14);
    border-color: rgba(56, 189, 248, 0.45);
    color: #bae6fd;
}

.agent-action-btn.is-accent {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    border-color: rgba(124, 58, 237, 0.7);
}

.agent-action-btn.is-warning {
    background: rgba(239, 68, 68, 0.16);
    border-color: rgba(239, 68, 68, 0.45);
    color: #fecaca;
}

.agent-action-btn.is-success {
    background: rgba(16, 185, 129, 0.16);
    border-color: rgba(16, 185, 129, 0.45);
    color: #bbf7d0;
}

.agent-action-btn.is-danger {
    background: rgba(127, 29, 29, 0.32);
    border-color: rgba(239, 68, 68, 0.45);
    color: #fee2e2;
}

.agent-badges-panel {
    border-top: 1px solid #233244;
    background: rgba(8, 14, 26, 0.85);
    padding: 10px;
}

.agent-badge-admin-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px;
    border: 1px solid #243244;
    border-radius: 10px;
    background: #101827;
    margin-bottom: 8px;
}

.agent-badge-admin-row:last-child {
    margin-bottom: 0;
}

.agent-badge-admin-row.is-blocked {
    border-color: #7f1d1d;
    background: #1b1320;
}

.agent-badge-admin-meta {
    flex: 1;
    min-width: 0;
}

.agent-badge-admin-title {
    font-size: 13px;
    font-weight: 700;
    color: #e2e8f0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.agent-badge-admin-sub {
    font-size: 11px;
    color: #94a3b8;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}

.agent-badge-admin-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
    flex-shrink: 0;
}

.agent-mini-btn {
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 6px 9px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.2;
    color: #e2e8f0;
    background: #334155;
    cursor: pointer;
    transition: transform 0.16s ease, filter 0.16s ease, background 0.16s ease;
}

.agent-mini-btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.07);
}

.agent-mini-btn.is-neutral {
    background: #273549;
    border-color: #33465f;
    color: #dbeafe;
}

.agent-mini-btn.is-success {
    background: rgba(16, 185, 129, 0.16);
    border-color: rgba(16, 185, 129, 0.45);
    color: #bbf7d0;
}

.agent-mini-btn.is-danger {
    background: rgba(239, 68, 68, 0.16);
    border-color: rgba(239, 68, 68, 0.45);
    color: #fecaca;
}

.agent-badge-status {
    border-radius: 999px;
    padding: 2px 7px;
    font-size: 10px;
    font-weight: 700;
    line-height: 1.2;
    border: 1px solid transparent;
}

.agent-badge-status.active {
    color: #10b981;
    border-color: rgba(16, 185, 129, 0.35);
    background: rgba(16, 185, 129, 0.12);
}

.agent-badge-status.paused {
    color: #f59e0b;
    border-color: rgba(245, 158, 11, 0.35);
    background: rgba(245, 158, 11, 0.12);
}

.agent-badge-status.blocked {
    color: #f87171;
    border-color: rgba(248, 113, 113, 0.4);
    background: rgba(248, 113, 113, 0.12);
}

@media (max-width: 768px) {
    .agent-admin-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .agent-action-btn {
        padding: 6px 8px;
        font-size: 11px;
    }

    .agent-badge-admin-row {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .agent-badge-admin-actions {
        justify-content: flex-end;
    }
}

/* Toast */
.fm-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 14px 24px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    z-index: 9999;
    opacity: 0;
    transition: all 0.3s;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.fm-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.fm-toast-success { background: #10b981; color: white; }
.fm-toast-error { background: #ef4444; color: white; }
.fm-toast-info { background: #3b82f6; color: white; }

/* Mobile */
@media (max-width: 480px) {
    .sidebar {
        width: 100vw;
    }
    
    .filter-row {
        grid-template-columns: 1fr;
    }
    
    .form-row-2 {
        grid-template-columns: 1fr;
    }
    
    .photos-preview {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ==========================================
   КАРТОЧКИ БЕЙДЖЕЙ - ПОЛНЫЕ
   ========================================== */

.badges-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.badge-card-full {
    background: #0f172a;
    border-radius: 14px;
    padding: 16px;
    border: 1px solid #334155;
}

.badge-card-full.disabled {
    opacity: 0.7;
}

.badge-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 8px;
}

.badge-card-title {
    font-size: 15px;
    font-weight: 700;
    color: white;
    flex: 1;
}

.badge-status-tag {
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 6px;
    white-space: nowrap;
}

.badge-status-tag.active {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
}

.badge-status-tag.paused {
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
}

.badge-status-tag.blocked {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.badge-card-address {
    font-size: 12px;
    color: #94a3b8;
    margin-bottom: 8px;
}

.badge-card-dates {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 12px;
    color: #64748b;
    margin-bottom: 10px;
}

.badge-card-dates .warning {
    color: #f59e0b;
    font-weight: 500;
}

.badge-card-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 12px;
    color: #94a3b8;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #334155;
}

.badge-origin-bonus {
    color: #fbbf24;
    font-weight: 600;
}

.badge-blocked-msg {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ef4444;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 12px;
}

.badge-card-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.badge-btn {
    padding: 8px 12px;
    border: none;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.badge-btn:hover {
    transform: translateY(-1px);
}

.badge-btn-map {
    background: #3b82f6;
    color: white;
}

.badge-btn-edit {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.badge-btn-share {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    color: white;
}

.badge-btn-pause {
    background: #f59e0b;
    color: white;
}

.badge-btn-activate {
    background: #10b981;
    color: white;
}

.badge-btn-delete {
    background: #ef4444;
    color: white;
}

/* ==========================================
   ИЗБРАННОЕ АГЕНТА
   ========================================== */

.favorites-section {
    padding-bottom: 20px;
}

.favorites-header-block {
    margin-bottom: 16px;
}

.favorites-header-block h3 {
    font-size: 18px;
    font-weight: 700;
    color: white;
    margin: 0 0 8px 0;
}

.favorites-header-block p {
    font-size: 13px;
    color: #94a3b8;
    margin: 0;
}

.favorites-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.favorites-actions .btn {
    flex: 1;
    padding: 12px 16px;
    font-size: 13px;
}

.btn-danger-outline {
    background: transparent;
    color: #ef4444;
    border: 2px solid #ef4444;
}

.btn-danger-outline:hover {
    background: #ef4444;
    color: white;
}

.favorites-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.favorites-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #0f172a;
    border-radius: 12px;
    border: 1px solid #334155;
    cursor: pointer;
    transition: all 0.2s;
}

.favorites-item:hover {
    border-color: #667eea;
    background: #1e293b;
}

.favorites-item-photo {
    width: 70px;
    height: 70px;
    border-radius: 10px;
    object-fit: cover;
    flex-shrink: 0;
}

.favorites-item-info {
    flex: 1;
    min-width: 0;
}

.favorites-item-title {
    font-weight: 600;
    font-size: 14px;
    color: white;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.favorites-item-address {
    font-size: 12px;
    color: #94a3b8;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.favorites-item-price {
    font-size: 13px;
    font-weight: 600;
    color: #60a5fa;
}

.favorites-item-remove {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
}

.favorites-item-remove:hover {
    background: #ef4444;
    color: white;
}

/* Кнопка продлить бейдж */
.badge-btn-extend {
    background: linear-gradient(135deg, #10b981, #059669) !important;
    color: white !important;
}

.badge-btn-extend:hover {
    background: linear-gradient(135deg, #059669, #047857) !important;
}

.badge-btn-auto-renew {
    background: #1f2937 !important;
    color: #cbd5e1 !important;
}

.badge-btn-auto-renew.enabled {
    background: #0f766e !important;
    color: #ecfeff !important;
}

.badge-btn-auto-renew:hover {
    opacity: 0.9;
}

/* Кнопка продлить - неактивна */
.badge-btn-extend-disabled {
    background: #374151 !important;
    color: #9ca3af !important;
    cursor: pointer;
    opacity: 0.7;
}

.badge-btn-extend-disabled:hover {
    opacity: 1;
}

/* Кнопка продлить - уже использована */
.badge-btn-extend-used {
    background: #1f2937 !important;
    color: #6b7280 !important;
    cursor: not-allowed;
}

/* Меню избранного счётчик */
.menu-badge {
    background: #ef4444;
    color: white;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: auto;
}

/* Поле ввода цены с валютой */
.price-input-row {
    display: flex;
    gap: 10px;
}

.price-input-row input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #334155;
    border-radius: 8px;
    background: #0f172a;
    color: white;
    font-size: 14px;
}

.price-input-row input:focus {
    outline: none;
    border-color: #3b82f6;
}

.price-input-row select {
    width: 140px;
    padding: 10px;
    border: 1px solid #334155;
    border-radius: 8px;
    background: #1e293b;
    color: white;
    font-size: 13px;
}

/* ==========================================
   ПРОСМОТР ФОТО НА ВЕСЬ ЭКРАН
   ========================================== */

.photo-viewer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
}

.photo-viewer-content {
    position: relative;
    max-width: 95vw;
    max-height: 95vh;
    cursor: default;
}

.photo-viewer-image {
    max-width: 95vw;
    max-height: 95vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.photo-viewer-close {
    position: absolute;
    top: -40px;
    right: 0;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s;
}

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

/* ==========================================
   СТАТИСТИКА АДМИНА
   ========================================== */

.stats-filters {
    margin-bottom: 20px;
}

.stats-period-btns {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.period-btn {
    padding: 8px 16px;
    border: 2px solid #e2e8f0;
    background: white;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    color: #64748b;
}

.period-btn:hover {
    border-color: #667eea;
    color: #667eea;
}

.period-btn.active {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border-color: transparent;
}

.stats-date-range {
    display: flex;
    align-items: center;
    gap: 10px;
}

.stats-date-range input {
    padding: 8px 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    flex: 1;
}

.stats-date-range input:focus {
    outline: none;
    border-color: #667eea;
}

.stats-date-range span {
    color: #94a3b8;
}

.stats-section {
    margin-top: 24px;
}

.stats-section h4 {
    font-size: 14px;
    color: #64748b;
    margin-bottom: 12px;
    font-weight: 600;
}

.stat-card-wide {
    grid-column: 1 / -1;
}

.top-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.top-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: #f8fafc;
    border-radius: 8px;
}

.top-rank {
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
}

.top-item:nth-child(1) .top-rank {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.top-item:nth-child(2) .top-rank {
    background: linear-gradient(135deg, #94a3b8, #64748b);
}

.top-item:nth-child(3) .top-rank {
    background: linear-gradient(135deg, #cd7f32, #a0522d);
}

.top-name {
    flex: 1;
    font-weight: 500;
    color: #1e293b;
}

.top-value {
    font-size: 13px;
    color: #64748b;
}

/* Сообщения */
.msg-card {
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 10px;
}

.msg-card.unread {
    border-color: #2563eb;
    box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.35);
}

.msg-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 6px;
}

.messages-header-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.msg-kind-select {
    min-width: 128px;
    padding: 7px 10px;
    border: 1px solid #334155;
    border-radius: 8px;
    background: #0f172a;
    color: #e2e8f0;
    font-size: 12px;
}

.msg-header-badges {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.msg-kind-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 20px;
    padding: 0 8px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.2);
    border: 1px solid rgba(148, 163, 184, 0.5);
    color: #cbd5e1;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.news-visibility-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.45);
    background: rgba(148, 163, 184, 0.14);
    color: #cbd5e1;
    font-size: 11px;
    font-weight: 600;
    text-transform: none;
    white-space: nowrap;
}

.msg-title {
    color: #ffffff;
    font-weight: 700;
    font-size: 14px;
}

.msg-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: #2563eb;
    color: #ffffff;
    font-size: 10px;
    font-weight: 700;
}

.msg-body {
    color: #cbd5e1;
    font-size: 13px;
    line-height: 1.45;
    white-space: pre-wrap;
}

.msg-meta {
    margin-top: 10px;
    color: #94a3b8;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.news-editor {
    margin-bottom: 14px;
}

.news-sticky-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #cbd5e1;
    font-size: 13px;
    margin: 4px 0 14px;
}

.news-sticky-toggle input[type="checkbox"] {
    width: 16px;
    height: 16px;
}

.news-bulk-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin: 10px 0 12px;
}

.news-select-all {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: #cbd5e1;
    font-size: 13px;
}

.news-select-all input[type="checkbox"] {
    width: 16px;
    height: 16px;
}

.news-selected-count {
    color: #94a3b8;
    font-size: 12px;
}

.news-item-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    max-width: 72%;
}

.news-item-check input[type="checkbox"] {
    width: 16px;
    height: 16px;
}

.news-item-check .msg-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-search-row {
    margin-bottom: 10px;
}

.chat-search-row .search-input-dark {
    margin: 0;
}

.msg-targets {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 10px;
    border: 1px solid #334155;
    border-radius: 8px;
    background: #0f172a;
    margin-bottom: 14px;
}

.msg-targets label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #e2e8f0;
}

.messages-mode-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}

.msg-mode-btn {
    border: 1px solid #334155;
    border-radius: 10px;
    background: #0f172a;
    color: #cbd5e1;
    font-size: 12px;
    font-weight: 600;
    padding: 8px 10px;
    cursor: pointer;
}

.msg-mode-btn.active {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.15);
    color: #ffffff;
}

.sidebar .chat-layout {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px;
    margin-top: 8px;
    width: 100%;
    min-width: 0;
}

.sidebar .chat-layout > * {
    min-width: 0;
}

.chat-layout-full {
    margin-top: 0;
}

.chat-threads {
    border: 1px solid #334155;
    border-radius: 10px;
    background: #0f172a;
    max-height: 240px;
    overflow: auto;
    padding: 8px;
    display: grid;
    gap: 8px;
}

.chat-thread-item {
    width: 100%;
    border: 1px solid #334155;
    border-radius: 10px;
    background: #111f37;
    color: #e2e8f0;
    text-align: left;
    padding: 10px;
    cursor: pointer;
    display: grid;
    gap: 4px;
    position: relative;
}

.chat-thread-item.active {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.14);
}

.chat-thread-name {
    font-size: 13px;
    font-weight: 700;
    color: #f8fafc;
}

.chat-thread-meta {
    font-size: 12px;
    color: #94a3b8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-thread-time {
    font-size: 10px;
    color: #64748b;
}

.chat-thread-unread {
    position: absolute;
    top: 8px;
    right: 8px;
    min-width: 18px;
    height: 18px;
    border-radius: 999px;
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
}

.chat-window-card {
    border: 1px solid #334155;
    border-radius: 10px;
    background: #0f172a;
    padding: 10px;
    display: grid;
    grid-template-rows: auto minmax(170px, 1fr) auto;
    gap: 10px;
    min-height: 0;
    width: 100%;
    overflow: hidden;
}

.chat-window-header {
    color: #f8fafc;
    font-size: 14px;
    display: grid;
    gap: 4px;
}

.chat-presence-line {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.chat-presence-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px rgba(2, 6, 23, 0.35);
}

.chat-presence-dot.is-online {
    background: #22c55e;
}

.chat-presence-dot.is-away {
    background: #facc15;
}

.chat-presence-text {
    color: #cbd5e1;
    font-size: 12px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-presence-text.compact {
    font-size: 11px;
    color: #94a3b8;
}

.chat-messages {
    border: 1px solid #334155;
    border-radius: 10px;
    background: #0b1323;
    min-height: 170px;
    max-height: 38vh;
    overflow: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-msg {
    width: fit-content;
    max-width: 78%;
    padding: 8px 10px;
    border-radius: 10px;
    display: grid;
    gap: 4px;
    line-height: 1.35;
}

.chat-msg.in {
    align-self: flex-start;
    background: #1e293b;
    border: 1px solid #334155;
    color: #e2e8f0;
}

.chat-msg.out {
    align-self: flex-end;
    background: linear-gradient(135deg, #3b82f6, #7c3aed);
    color: #fff;
}

.chat-msg-text {
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
    font-size: 13px;
}

.chat-msg-time {
    font-size: 11px;
    opacity: 0.8;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.chat-msg-read {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.chat-msg-read.is-sent {
    color: rgba(219, 234, 254, 0.9);
}

.chat-msg-read.is-read {
    color: #bbf7d0;
}

.chat-input-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    align-items: stretch;
}

.chat-input {
    width: 100%;
    border: 1px solid #334155;
    border-radius: 10px;
    background: #111f37;
    color: #fff;
    padding: 9px 10px;
    resize: vertical;
    min-height: 42px;
    font-family: inherit;
    font-size: 13px;
}

.chat-input-row .btn {
    justify-self: end;
    min-width: 132px;
}

@media (max-width: 900px) {
    .chat-threads {
        max-height: 220px;
    }

    .chat-window-card {
        min-height: 0;
    }

    .chat-messages {
        min-height: 180px;
        max-height: 340px;
    }
}

@media (max-width: 768px) {
    .news-item-check {
        max-width: 100%;
    }

    .news-visibility-badge {
        font-size: 10px;
        padding: 2px 7px;
    }

    .news-bulk-toolbar {
        align-items: stretch;
    }

    .news-bulk-toolbar .btn {
        width: 100%;
    }

    .chat-threads {
        max-height: 190px;
    }

    .chat-window-card {
        min-height: 0;
    }

    .chat-messages {
        min-height: 200px;
        max-height: 42dvh;
    }

    .chat-input-row .btn {
        width: 100%;
        min-width: 0;
        justify-self: stretch;
    }
}

@media (max-width: 480px) {
    .stats-period-btns {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }
    
    .stats-date-range {
        flex-direction: column;
    }
    
    .stats-date-range input {
        width: 100%;
    }
}

/* ==========================================
   iOS SAFE AREA
   ========================================== */

@supports (padding: env(safe-area-inset-top)) {
    .sidebar-header {
        padding-top: calc(16px + env(safe-area-inset-top));
    }
    
    .sidebar-content {
        padding-bottom: calc(40px + env(safe-area-inset-bottom));
    }
}

/* ==========================================
   ДОПОЛНИТЕЛЬНЫЕ КРОССБРАУЗЕРНЫЕ СТИЛИ
   ========================================== */

/* Flexbox с префиксами для старых браузеров */
.stats-cards {
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-flex-wrap: wrap;
    -ms-flex-wrap: wrap;
    flex-wrap: wrap;
}

.stats-section {
    margin-top: 24px;
}

/* Улучшенная прокрутка на всех платформах */
.sidebar-content::-webkit-scrollbar {
    width: 6px;
}

.sidebar-content::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-content::-webkit-scrollbar-thumb {
    background: #475569;
    border-radius: 3px;
}

.sidebar-content::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

/* Firefox */
.sidebar-content {
    scrollbar-width: thin;
    scrollbar-color: #475569 transparent;
}
