.sb-area-crm {
    --crm-bg: #f4f5f6;
    --crm-surface: #fff;
    --crm-border: #dfe3e6;
    --crm-text: #202427;
    --crm-muted: #778087;
    --crm-hover: #f7f8f9;
    --crm-accent: #2475a8;
    --crm-danger: #b64d56;
    display: none;
    height: calc(100vh - 65px);
    background: var(--crm-bg);
    color: var(--crm-text);
    overflow: hidden;
    position: relative;
}

.sb-area-crm.sb-active { display: flex !important; flex-direction: column; }
.sb-crm-dark .sb-area-crm { --crm-bg: #202326; --crm-surface: #292d30; --crm-border: #3b4145; --crm-text: #ebedef; --crm-muted: #a6adb2; --crm-hover: #31363a; --crm-accent: #62a9d5; }
.sb-area-crm * { box-sizing: border-box; letter-spacing: 0; }
.crm-header { min-height: 66px; padding: 0 28px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--crm-border); background: var(--crm-surface); }
.crm-title { display: flex; align-items: center; gap: 12px; }
.crm-title h2 { margin: 0; font-size: 18px; line-height: 1.2; }
.crm-sync-state { font-size: 11px; font-weight: 600; padding-left: 12px; color: var(--crm-muted); position: relative; }
.crm-sync-state:before { content: ''; position: absolute; width: 7px; height: 7px; border-radius: 50%; background: #a7adb1; left: 0; top: 4px; }
.crm-sync-state.crm-online:before { background: #2f9b63; }
.crm-actions, .crm-view-toggle { display: flex; align-items: center; gap: 6px; }
.crm-view-toggle { padding-right: 8px; margin-right: 2px; border-right: 1px solid var(--crm-border); }
.crm-icon-btn { width: 34px; height: 34px; min-width: 34px; border: 1px solid var(--crm-border); border-radius: 5px; background: var(--crm-surface); color: var(--crm-muted); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; transition: background .15s, color .15s, border-color .15s; }
.crm-icon-btn:hover, .crm-icon-btn.sb-active { color: var(--crm-accent); border-color: var(--crm-accent); background: var(--crm-hover); }
.crm-icon-btn i { font-size: 15px; }
.crm-stats { min-height: 70px; padding: 0 28px; display: grid; grid-template-columns: 150px 150px 150px minmax(220px, 1fr); background: var(--crm-surface); border-bottom: 1px solid var(--crm-border); }
.crm-stats > div { display: flex; flex-direction: column; justify-content: center; gap: 5px; border-right: 1px solid var(--crm-border); padding: 0 22px; min-width: 0; }
.crm-stats > div:first-child { padding-left: 0; }
.crm-stats > div:last-child { border-right: 0; }
.crm-stats span { color: var(--crm-muted); font-size: 11px; text-transform: uppercase; font-weight: 600; }
.crm-stats strong { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crm-stats .crm-stat-alert strong { color: var(--crm-danger); }
.crm-toolbar { padding: 12px 28px; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--crm-border); background: var(--crm-surface); overflow-x: auto; min-height: 59px; }
.crm-toolbar select, .crm-toolbar input, .crm-drawer input, .crm-drawer select, .crm-drawer textarea, .crm-settings input, .crm-settings select, .crm-settings textarea { height: 35px; border: 1px solid var(--crm-border); border-radius: 4px; background: var(--crm-surface); color: var(--crm-text); padding: 0 10px; outline: 0; font-size: 12px; }
.crm-toolbar select:focus, .crm-toolbar input:focus, .crm-drawer input:focus, .crm-drawer select:focus, .crm-drawer textarea:focus, .crm-settings input:focus, .crm-settings select:focus, .crm-settings textarea:focus { border-color: var(--crm-accent); }
.crm-toolbar select { max-width: 145px; flex: 0 0 auto; }
.crm-search { position: relative; min-width: 210px; }
.crm-search i { position: absolute; left: 11px; top: 10px; color: var(--crm-muted); font-size: 13px; }
.crm-search input { width: 100%; padding-left: 32px; }
.crm-check { height: 35px; display: inline-flex; align-items: center; gap: 7px; padding: 0 10px; border: 1px solid var(--crm-border); border-radius: 4px; white-space: nowrap; cursor: pointer; font-size: 12px; }
.crm-check input { width: 14px; height: 14px; margin: 0; }
.crm-content { min-height: 0; flex: 1; overflow: auto; }
.crm-board { min-width: max-content; height: 100%; display: flex; gap: 12px; padding: 16px 20px 22px; align-items: stretch; }
.crm-column { width: 286px; min-width: 286px; display: flex; flex-direction: column; border-left: 1px solid var(--crm-border); border-right: 1px solid var(--crm-border); background: rgba(255,255,255,.22); }
.sb-crm-dark .crm-column { background: rgba(255,255,255,.015); }
.crm-column > header { min-height: 49px; padding: 0 12px; display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--crm-border); border-bottom: 1px solid var(--crm-border); background: var(--crm-surface); }
.crm-column > header h3 { margin: 0; font-size: 12px; line-height: 1.3; flex: 1; }
.crm-column > header b { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; border-radius: 50%; background: var(--crm-hover); font-size: 10px; }
.crm-column > header small { max-width: 92px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--crm-muted); font-size: 9px; }
.crm-stage-dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
.crm-column-body { flex: 1; min-height: 160px; padding: 8px; overflow-y: auto; transition: background .15s; }
.crm-column-body.crm-drop { background: rgba(36,117,168,.09); }
.crm-column-empty { display: flex; align-items: center; justify-content: center; min-height: 100px; color: var(--crm-muted); }
.crm-lead-card { width: 100%; min-height: 170px; padding: 12px; margin-bottom: 8px; border: 1px solid var(--crm-border); border-radius: 6px; background: var(--crm-surface); cursor: pointer; box-shadow: 0 1px 2px rgba(25,31,35,.04); }
.crm-lead-card:hover { border-color: #adb5ba; box-shadow: 0 3px 9px rgba(25,31,35,.08); }
.crm-lead-card.crm-overdue { border-left: 3px solid var(--crm-danger); padding-left: 10px; }
.crm-lead-card.crm-dragging { opacity: .45; }
.crm-card-top { display: grid; grid-template-columns: 34px 1fr 10px; gap: 9px; align-items: center; }
.crm-card-top img, .crm-card-owner img, .crm-list-user img, .crm-lead-summary img, .crm-manager header img { object-fit: cover; border-radius: 50%; background: var(--crm-hover); }
.crm-card-top img { width: 34px; height: 34px; }
.crm-card-top h4 { margin: 0 0 3px; font-size: 12px; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crm-card-top span { display: block; color: var(--crm-muted); font-size: 10px; }
.crm-priority { width: 8px; height: 8px; border-radius: 50%; background: #99a1a7; }
.crm-priority-low { color: #6f8794; background-color: #6f8794; }
.crm-priority-normal { color: #3b82a7; background-color: #3b82a7; }
.crm-priority-high { color: #d28b25; background-color: #d28b25; }
.crm-priority-urgent { color: #b64d56; background-color: #b64d56; }
.crm-lead-card > p { margin: 12px 0; height: 44px; overflow: hidden; color: var(--crm-text); font-size: 11px; line-height: 1.45; }
.crm-card-meta { display: flex; align-items: center; justify-content: space-between; font-size: 10px; font-weight: 600; border-top: 1px solid var(--crm-border); padding-top: 9px; }
.crm-card-meta span:last-child { color: var(--crm-muted); font-weight: 400; }
.crm-card-owner { display: flex; align-items: center; gap: 6px; min-height: 25px; margin-top: 8px; color: var(--crm-muted); font-size: 10px; }
.crm-card-owner img { width: 20px; height: 20px; }
.crm-card-owner > i { width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--crm-hover); }
.crm-card-owner time { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.crm-due { color: var(--crm-danger) !important; font-weight: 600; }
.crm-list-wrap { padding: 18px 28px 40px; min-width: 980px; }
.crm-list { width: 100%; border-collapse: collapse; background: var(--crm-surface); border: 1px solid var(--crm-border); }
.crm-list th { padding: 12px; text-align: left; color: var(--crm-muted); font-size: 10px; text-transform: uppercase; border-bottom: 1px solid var(--crm-border); white-space: nowrap; }
.crm-list td { padding: 11px 12px; font-size: 11px; border-bottom: 1px solid var(--crm-border); vertical-align: middle; }
.crm-list tbody tr { cursor: pointer; }
.crm-list tbody tr:hover { background: var(--crm-hover); }
.crm-list-user { display: flex; align-items: center; gap: 9px; min-width: 180px; }
.crm-list-user img { width: 32px; height: 32px; }
.crm-list-user strong, .crm-list-user span { display: block; max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crm-list-user span, .crm-muted { color: var(--crm-muted); }
.crm-stage-label { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.crm-stage-label i { width: 7px; height: 7px; border-radius: 50%; }
.crm-priority-text { background: transparent !important; font-weight: 600; }
.crm-empty { min-height: 220px; width: 100%; display: flex; flex-direction: column; gap: 10px; align-items: center; justify-content: center; color: var(--crm-muted); }
.crm-empty i { font-size: 22px; }
.crm-overlay { position: absolute; inset: 0; z-index: 40; background: rgba(18,22,25,.38); opacity: 0; visibility: hidden; transition: opacity .18s; }
.crm-drawer, .crm-settings { position: absolute; right: 0; top: 0; bottom: 0; width: min(520px, 100%); z-index: 41; background: var(--crm-surface); border-left: 1px solid var(--crm-border); transform: translateX(100%); transition: transform .2s ease; display: flex; flex-direction: column; }
.crm-settings { width: min(700px, 100%); }
.crm-panel-open .crm-overlay { opacity: 1; visibility: visible; }
.crm-lead-open .crm-drawer, .crm-settings-open .crm-settings { transform: translateX(0); }
.crm-panel-head { min-height: 70px; padding: 0 20px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--crm-border); }
.crm-panel-head span { display: block; color: var(--crm-muted); font-size: 10px; text-transform: uppercase; margin-bottom: 4px; }
.crm-panel-head h3 { margin: 0; font-size: 17px; }
.crm-panel-scroll, .crm-settings-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 20px; }
.crm-lead-summary { display: flex; align-items: center; gap: 11px; padding-bottom: 18px; margin-bottom: 18px; border-bottom: 1px solid var(--crm-border); }
.crm-lead-summary img { width: 42px; height: 42px; }
.crm-lead-summary strong, .crm-lead-summary span { display: block; }
.crm-lead-summary span { color: var(--crm-muted); font-size: 11px; margin-top: 4px; }
.crm-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.crm-form-grid label, .crm-field-wide, .crm-ai-settings > label, .crm-manager-fields label { display: flex; flex-direction: column; gap: 6px; color: var(--crm-muted); font-size: 10px; font-weight: 600; }
.crm-form-grid input, .crm-form-grid select { width: 100%; }
.crm-field-wide { margin-top: 14px; }
.crm-drawer textarea, .crm-settings textarea { height: auto; min-height: 76px; padding: 9px 10px; resize: vertical; line-height: 1.45; }
.crm-ai-block { margin: 20px 0; padding: 14px 0; border-top: 1px solid var(--crm-border); border-bottom: 1px solid var(--crm-border); }
.crm-ai-block > div { display: flex; align-items: center; justify-content: space-between; color: var(--crm-muted); font-size: 10px; font-weight: 600; text-transform: uppercase; }
.crm-ai-block b { color: var(--crm-accent); }
.crm-ai-block p { font-size: 12px; line-height: 1.55; margin: 10px 0; }
.crm-ai-block small { display: block; margin-top: 7px; line-height: 1.45; color: var(--crm-muted); }
.crm-history h4 { font-size: 12px; margin: 0 0 15px; }
.crm-history-item { display: grid; grid-template-columns: 12px 1fr; gap: 9px; padding-bottom: 14px; }
.crm-history-item > i { width: 7px; height: 7px; border-radius: 50%; background: var(--crm-border); margin-top: 4px; position: relative; }
.crm-history-item > i:after { content: ''; position: absolute; width: 1px; height: 35px; background: var(--crm-border); left: 3px; top: 9px; }
.crm-history-item:last-child > i:after { display: none; }
.crm-history-item strong { font-size: 11px; }
.crm-history-item p { color: var(--crm-muted); margin: 5px 0; font-size: 10px; line-height: 1.4; }
.crm-history-item span { color: var(--crm-muted); font-size: 9px; }
.crm-panel-actions, .crm-settings-footer { min-height: 64px; padding: 12px 20px; border-top: 1px solid var(--crm-border); display: flex; align-items: center; gap: 8px; }
.crm-panel-actions .sb-btn { margin-left: auto; }
.crm-settings-nav { height: 48px; padding: 0 20px; display: flex; align-items: stretch; gap: 22px; border-bottom: 1px solid var(--crm-border); overflow-x: auto; }
.crm-settings-nav button { background: transparent; border: 0; border-bottom: 2px solid transparent; color: var(--crm-muted); font-size: 11px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.crm-settings-nav button.sb-active { color: var(--crm-accent); border-color: var(--crm-accent); }
.crm-settings-content { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.crm-stage-editor { display: flex; flex-direction: column; gap: 9px; }
.crm-stage-row { display: grid; grid-template-columns: 36px 1fr 34px; gap: 10px; align-items: start; padding: 12px; border: 1px solid var(--crm-border); border-radius: 6px; }
.crm-stage-row > input[type="color"] { width: 34px; height: 34px; padding: 3px; }
.crm-stage-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.crm-stage-fields input, .crm-stage-fields select, .crm-stage-fields textarea { width: 100%; }
.crm-stage-fields select { grid-column: 1 / -1; }
.crm-stage-controls { display: flex; flex-direction: column; gap: 5px; }
.crm-stage-controls .crm-icon-btn { width: 30px; height: 30px; min-width: 30px; }
.crm-btn-text { margin-top: 12px; height: 34px; border: 0; background: transparent; color: var(--crm-accent); font-size: 11px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.crm-manager-list { display: flex; flex-direction: column; gap: 12px; }
.crm-manager { border: 1px solid var(--crm-border); border-radius: 6px; padding: 14px; }
.crm-manager > header { display: grid; grid-template-columns: 38px 1fr auto; gap: 10px; align-items: center; padding-bottom: 13px; border-bottom: 1px solid var(--crm-border); }
.crm-manager header img { width: 38px; height: 38px; }
.crm-manager header strong, .crm-manager header span { display: block; }
.crm-manager header span { color: var(--crm-muted); font-size: 10px; margin-top: 3px; }
.crm-switch { display: inline-flex !important; }
.crm-switch input { position: absolute; opacity: 0; pointer-events: none; }
.crm-switch i { width: 34px; height: 19px; border-radius: 10px; background: #a9b0b5; position: relative; cursor: pointer; transition: background .15s; }
.crm-switch i:after { content: ''; position: absolute; width: 15px; height: 15px; background: #fff; border-radius: 50%; left: 2px; top: 2px; transition: transform .15s; }
.crm-switch input:checked + i { background: #2f8f5b; }
.crm-switch input:checked + i:after { transform: translateX(15px); }
.crm-manager-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 14px 0; }
.crm-manager-fields select[multiple] { height: 88px; padding: 5px; }
.crm-manager-competencies { grid-column: 1 / -1; }
.crm-ai-settings { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-content: start; }
.crm-ai-settings > label input, .crm-ai-settings > label select, .crm-ai-settings > label textarea { width: 100%; }
.crm-ai-settings > label:last-child { grid-column: 1 / -1; }
.crm-setting-line { grid-column: 1 / -1; min-height: 42px; flex-direction: row !important; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--crm-border); }
.crm-queue-row { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 13px 0; border-bottom: 1px solid var(--crm-border); }
.crm-queue-row strong, .crm-queue-row span, .crm-queue-row small { display: block; }
.crm-queue-row span { color: var(--crm-danger); font-size: 10px; margin: 4px 0; max-width: 540px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crm-queue-row small { color: var(--crm-muted); }
.crm-loading:after, .crm-saving:after { content: ''; position: absolute; z-index: 60; inset: 0; background: rgba(255,255,255,.45); }
.sb-crm-dark .crm-loading:after, .sb-crm-dark .crm-saving:after { background: rgba(20,23,25,.45); }
.crm-notice { position: absolute; z-index: 80; left: 50%; bottom: 24px; max-width: calc(100% - 32px); transform: translate(-50%, 12px); opacity: 0; padding: 10px 14px; border-radius: 5px; background: #2f8f5b; color: #fff; font-size: 11px; font-weight: 600; box-shadow: 0 5px 18px rgba(20,28,31,.2); transition: opacity .18s, transform .18s; }
.crm-notice.crm-notice-error { background: var(--crm-danger); }
.crm-notice.crm-notice-visible { transform: translate(-50%, 0); opacity: 1; }

@media (max-width: 900px) {
    .crm-header { padding: 0 16px; }
    .crm-stats { padding: 0 16px; grid-template-columns: repeat(4, minmax(120px, 1fr)); overflow-x: auto; }
    .crm-toolbar { padding: 10px 16px; }
    .crm-board { padding-left: 12px; padding-right: 12px; }
    .crm-column { width: 270px; min-width: 270px; }
}

@media (max-width: 600px) {
    .sb-area-crm { height: calc(100vh - 55px); }
    .crm-header { min-height: 58px; }
    .crm-title h2 { font-size: 16px; }
    .crm-sync-state { display: none; }
    .crm-stats { min-height: 62px; grid-template-columns: repeat(4, 125px); }
    .crm-stats > div { padding: 0 12px; }
    .crm-stats > div:first-child { padding-left: 0; }
    .crm-stats strong { font-size: 14px; }
    .crm-toolbar { min-height: 54px; }
    .crm-search { min-width: 180px; }
    .crm-form-grid, .crm-manager-fields, .crm-ai-settings, .crm-stage-fields { grid-template-columns: 1fr; }
    .crm-manager-competencies, .crm-ai-settings > label:last-child, .crm-setting-line, .crm-stage-fields select { grid-column: auto; }
    .crm-stage-row { grid-template-columns: 34px 1fr; }
    .crm-stage-controls { grid-column: 1 / -1; flex-direction: row; justify-content: flex-end; }
    .crm-list-wrap { padding: 12px; }
}
