:root {
    --apple-bg: #f5f5f7;
    --apple-card: #ffffff;
    --apple-dark: #1d1d1f;
    --apple-gray: #86868b;
    --apple-border: #e2e8f0;
    --psn-orange: #F15B27;
    --psn-orange-hover: #d4481b;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
body { background-color: var(--apple-bg); color: var(--apple-dark); overflow-x: hidden; }

/* ГЛОБАЛЬНЫЙ ЛОАДЕР С ПОЛУПРОЗРАЧНОСТЬЮ */
.crm-loader-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(255, 255, 255, 0.7); backdrop-filter: blur(4px);
    z-index: 999999; display: none; flex-direction: column; align-items: center; justify-content: center;
}
.crm-loader-spinner {
    width: 40px; height: 40px; border: 3px solid var(--apple-border);
    border-top: 3px solid var(--psn-orange); border-radius: 50%;
    animation: crmSpin 0.8s linear infinite; margin-bottom: 12px;
}
.crm-loader-text { font-size: 14px; font-weight: 500; color: var(--apple-dark); }
@keyframes crmSpin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* СЕТКА ИНТЕРФЕЙСА */
.crm-wrapper { display: flex; flex-direction: column; height: 100vh; }
.crm-header {
    height: 56px; background: var(--apple-card); border-bottom: 1px solid var(--apple-border);
    display: flex; justify-content: space-between; align-items: center; padding: 0 24px; position: fixed; top:0; left:0; width:100%; z-index:100;
}
.crm-logo-block {
    background: var(--apple-dark); color: #fff; padding: 8px 16px; border-radius: 8px; font-weight: 700; font-size: 14px; letter-spacing: 0.5px;
}
.crm-user-block { display: flex; align-items: center; gap: 20px; }
.crm-header-btn { background: none; border: none; font-size: 18px; cursor: pointer; transition: opacity 0.2s; }
.crm-header-btn:hover { opacity: 0.7; }
.crm-user-profile { display: flex; align-items: center; gap: 10px; }
.crm-user-name { font-size: 14px; font-weight: 500; }
.crm-user-avatar {
    width: 32px; height: 32px; background: var(--apple-bg); border-radius: 50%;
    display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; color: var(--psn-orange);
}
.crm-logout-btn { font-size: 13px; color: var(--apple-gray); text-decoration: none; font-weight: 500; }
.crm-logout-btn:hover { color: var(--apple-dark); }

.crm-main-container { display: flex; flex: 1; margin-top: 56px; height: calc(100vh - 56px); }
.crm-sidebar { width: 240px; background: var(--apple-card); border-right: 1px solid var(--apple-border); padding: 20px 12px; overflow-y: auto; }
.crm-nav { display: flex; flex-direction: column; gap: 4px; }
.crm-nav-item {
    display: block; padding: 10px 14px; color: var(--apple-dark); text-decoration: none; font-size: 14px; font-weight: 500; border-radius: 8px; transition: all 0.15s;
}
.crm-nav-item:hover { background: var(--apple-bg); }
.crm-nav-item.active { background: rgba(241, 91, 39, 0.08); color: var(--psn-orange); font-weight: 600; }

.crm-content { flex: 1; padding: 24px; overflow-y: auto; display: flex; flex-direction: column; justify-content: space-between; }
.crm-footer { margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--apple-border); display: flex; justify-content: space-between; font-size: 12px; color: var(--apple-gray); }

/* СТАНДАРТНОЕ МОДАЛЬНОЕ ОКНО */
.crm-modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.4); backdrop-filter: blur(8px);
    z-index: 1000; display: none; align-items: center; justify-content: center;
}
.crm-modal-container {
    background: var(--apple-card); width: 100%; max-width: 760px; max-height: 85vh; border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.15); position: relative; display: flex; flex-direction: column; overflow: hidden;
}
.crm-modal-close {
    position: absolute; top: 16px; right: 20px; font-size: 28px; background: none; border: none; color: var(--apple-gray); cursor: pointer; z-index: 10;
}
.crm-modal-close:hover { color: var(--apple-dark); }
.crm-modal-body { padding: 24px; overflow-y: auto; flex: 1; }

/* ВЫЕЗЖАЮЩАЯ КАРТОЧКА ОБЪЕКТА СПРАВА */
.crm-side-panel-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.2); backdrop-filter: blur(8px);
    z-index: 999; display: none; justify-content: flex-end;
}
.crm-side-panel-container {
    background: var(--apple-card); width: 75%; max-width: 1100px; height: 100%;
    box-shadow: -10px 0 30px rgba(0,0,0,0.1); position: relative; display: flex; flex-direction: column;
    transform: translateX(100%); transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.crm-side-panel-overlay.open .crm-side-panel-container { transform: translateX(0); }
.crm-panel-close {
    position: absolute; top: 20px; right: 24px; font-size: 32px; background: none; border: none; color: var(--apple-gray); cursor: pointer; z-index: 11;
}
.crm-panel-close:hover { color: var(--apple-dark); }
.crm-side-panel-body { padding: 32px; overflow-y: auto; flex: 1; }

/* ФИЛЬТРЫ И УМНЫЙ ПОИСК */
.crm-search-panel { background: var(--apple-card); padding: 16px; border-radius: 12px; border: 1px solid var(--apple-border); margin-bottom: 16px; display: flex; gap: 12px; }
.crm-smart-search-wrapper { flex: 1; position: relative; }
.crm-smart-input {
    width: 100%; height: 42px; background: var(--apple-bg); border: 1px solid transparent; border-radius: 8px;
    padding: 0 16px 0 36px; font-size: 14px; outline: none; transition: all 0.2s;
}
.crm-smart-input:focus { border-color: var(--psn-orange); background: var(--apple-card); box-shadow: 0 0 0 3px rgba(241,91,39,0.15); }
.crm-search-icon { position: absolute; left: 12px; top: 12px; color: var(--apple-gray); }
.crm-btn {
    height: 42px; padding: 0 20px; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 8px; border: none; transition: all 0.2s;
}
.crm-btn-primary { background: var(--psn-orange); color: #fff; }
.crm-btn-primary:hover { background: var(--psn-orange-hover); }
.crm-btn-secondary { background: var(--apple-bg); color: var(--apple-dark); border: 1px solid var(--apple-border); }
.crm-btn-secondary:hover { background: #e5e5ea; }

/* СТАТИСТИКА БЫСТРОГО ДОСТУПА */
.crm-mini-stats { display: flex; align-items: center; justify-content: space-between; background: var(--apple-card); padding: 12px 20px; border-radius: 12px; border: 1px solid var(--apple-border); margin-bottom: 20px; font-size: 13px; }
.crm-stats-counters { display: flex; gap: 24px; color: var(--apple-gray); }
.crm-stats-counters strong { color: var(--apple-dark); font-size: 14px; }

/* РЕЖИМЫ ОТОБРАЖЕНИЯ И СПИСКИ */
.crm-view-selector { display: flex; gap: 4px; background: var(--apple-bg); padding: 4px; border-radius: 8px; }
.crm-view-btn { padding: 6px 12px; font-size: 12px; font-weight: 600; border: none; background: none; border-radius: 6px; cursor: pointer; color: var(--apple-gray); }
.crm-view-btn.active { background: var(--apple-card); color: var(--apple-dark); box-shadow: 0 1px 3px rgba(0,0,0,0.1); }

/* БЕЙДЖИ ПАРАМЕТРОВ */
.crm-badge { display: inline-flex; align-items: center; padding: 4px 8px; border-radius: 6px; font-size: 11px; font-weight: 600; background: var(--apple-bg); color: #475569; }
.crm-badge-orange { background: rgba(241, 91, 39, 0.1); color: var(--psn-orange); }
.crm-badge-green { background: #f0fdf4; color: #16a34a; }
.crm-badge-feed { background: #f1f5f9; color: #334155; border: 1px solid #cbd5e1; }

/* РЕЖИМ: СПИСОК (CIAN STYLE) */
.crm-list-container { display: flex; flex-direction: column; gap: 12px; }
.crm-item-row { background: var(--apple-card); border: 1px solid var(--apple-border); border-radius: 12px; padding: 16px; display: flex; gap: 16px; align-items: flex-start; position: relative; }
.crm-item-checkbox { margin-top: 4px; transform: scale(1.1); cursor: pointer; }
.crm-item-photo { width: 140px; height: 105px; border-radius: 8px; overflow: hidden; background: #e5e5ea; flex-shrink: 0; }
.crm-item-photo img { width: 100%; height: 100%; object-fit: cover; }
.crm-item-details { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.crm-item-header { display: flex; justify-content: space-between; align-items: flex-start; }
.crm-item-title { font-size: 16px; font-weight: 700; color: var(--apple-dark); cursor: pointer; }
.crm-item-title:hover { color: var(--psn-orange); }
.crm-item-price { font-size: 16px; font-weight: 700; color: var(--psn-orange); text-align: right; }
.crm-item-address { font-size: 13px; color: var(--apple-dark); font-weight: 500; }
.crm-item-highway { font-size: 12px; color: var(--apple-gray); }
.crm-item-descr { font-size: 13px; color: #475569; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.crm-item-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }

/* РЕЖИМ: ТАБЛИЦА (УЗКИЙ) */
.crm-table { width: 100%; border-collapse: collapse; background: var(--apple-card); border-radius: 12px; overflow: hidden; border: 1px solid var(--apple-border); font-size: 13px; }
.crm-table th { background: #f8fafc; text-align: left; padding: 12px 16px; font-weight: 600; color: #475569; border-bottom: 1px solid var(--apple-border); }
.crm-table td { padding: 10px 16px; border-bottom: 1px solid var(--apple-border); color: var(--apple-dark); vertical-align: middle; }
.crm-table tr:last-child td { border-bottom: none; }
.crm-table tr:hover td { background: var(--apple-bg); }









/* СТИЛИ СТРАНИЦЫ АВТОРИЗАЦИИ (APPLE / YANDEX ID STYLE) */
.crm-auth-page-wrapper {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: #f5f5f7; display: flex; align-items: center; justify-content: center;
    z-index: 999999;
}
.crm-auth-card {
    background: #ffffff; width: 100%; max-width: 400px; padding: 40px 32px;
    border-radius: 20px; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.05);
    border: 1px solid #e2e8f0; display: flex; flex-direction: column;
}
.crm-auth-logo {
    align-self: center; background: #1d1d1f; color: #ffffff; 
    padding: 8px 16px; border-radius: 8px; font-weight: 700; 
    font-size: 13px; letter-spacing: 0.5px; margin-bottom: 24px;
}
.crm-auth-title {
    font-size: 22px; font-weight: 700; color: #1d1d1f; 
    text-align: center; margin-bottom: 8px; letter-spacing: -0.5px;
}
.crm-auth-subtitle {
    font-size: 13px; color: #86868b; text-align: center; 
    line-height: 1.4; margin-bottom: 28px; padding: 0 10px;
}
.crm-auth-group {
    display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px;
}
.crm-auth-label {
    font-size: 12px; font-weight: 600; color: #475569; padding-left: 2px;
}
.crm-auth-input {
    height: 44px; width: 100%; background: #f5f5f7; border: 1px solid transparent;
    border-radius: 10px; padding: 0 14px; font-size: 14px; outline: none;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1); color: #1d1d1f;
}
.crm-auth-input:focus {
    background: #ffffff; border-color: #F15B27; 
    box-shadow: 0 0 0 4px rgba(241, 91, 39, 0.12);
}
.crm-auth-remember {
    display: flex; align-items: center; margin: 12px 0 20px 2px;
}
.crm-remember-label {
    display: flex; align-items: center; gap: 8px; font-size: 13px; 
    color: #475569; cursor: pointer; user-select: none;
}
.crm-remember-label input[type="checkbox"] {
    transform: scale(1.1); accent-color: #F15B27; cursor: pointer;
}
.crm-auth-submit-btn {
    width: 100%; height: 46px; background: #F15B27; color: #ffffff;
    border: none; border-radius: 10px; font-size: 14px; font-weight: 600;
    cursor: pointer; transition: all 0.15s; margin-bottom: 20px;
}
.crm-auth-submit-btn:hover { background: #d4481b; transform: translateY(-0.5px); }
.crm-auth-submit-btn:active { transform: translateY(0); }

.crm-auth-footer-links {
    display: flex; justify-content: center; gap: 16px; font-size: 12px;
}
.crm-auth-link {
    color: #86868b; text-decoration: none; transition: color 0.15s; font-weight: 500;
}
.crm-auth-link:hover { color: #1d1d1f; text-decoration: underline; }

/* Стилизация блока капчи Netcat */
.crm-captcha-inline { display: flex; gap: 10px; align-items: center; }
.crm-captcha-inline img { border-radius: 8px; height: 44px; }
.crm-captcha-input { max-width: 120px; text-align: center; }