/* CRM — Управление клиентами в Lean (Phase 18) */

.crm-page {
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

/* Header */
.crm-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    gap: 12px;
    flex-wrap: wrap;
}

.crm-title {
    font-size: 22px;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 4px;
}

.crm-subtitle {
    font-size: 13px;
    color: #64748b;
    margin: 0;
}

/* Buttons */
.crm-btn {
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    padding: 10px 16px;
    transition: all 0.15s;
    white-space: nowrap;
}

.crm-btn-primary {
    background: #3b82f6;
    color: white;
}
.crm-btn-primary:hover { background: #2563eb; }

.crm-btn-secondary {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
}
.crm-btn-secondary:hover { background: #e2e8f0; }

.crm-btn-danger {
    background: #fee2e2;
    color: #dc2626;
    border: 1px solid #fecaca;
}
.crm-btn-danger:hover { background: #fecaca; }

.crm-btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.crm-btn-icon {
    padding: 6px 8px;
    background: transparent;
    color: #94a3b8;
    border: none;
    font-size: 14px;
}
.crm-btn-icon:hover { color: #dc2626; background: #fee2e2; border-radius: 6px; }

/* Stats row */
.crm-stats-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

@media (max-width: 768px) {
    .crm-stats-row {
        grid-template-columns: repeat(2, 1fr);
    }
}

.crm-stat-card {
    background: white;
    border-radius: 12px;
    padding: 16px;
    border: 1px solid #e5e7eb;
    text-align: center;
}

.crm-stat-card.active { border-left: 3px solid #10b981; }
.crm-stat-card.prospect { border-left: 3px solid #3b82f6; }
.crm-stat-card.complaints { border-left: 3px solid #ef4444; }
.crm-stat-card.warning { border-left: 3px solid #f59e0b; }

.crm-stat-value {
    font-size: 28px;
    font-weight: 700;
    color: #1e293b;
    line-height: 1;
    margin-bottom: 4px;
}

.crm-stat-label {
    font-size: 11px;
    color: #64748b;
    font-weight: 500;
}

/* Filters */
.crm-filters {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.crm-search {
    flex: 1;
    min-width: 220px;
    max-width: 360px;
    padding: 10px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s;
}
.crm-search:focus { border-color: #3b82f6; }

.crm-filter-tabs {
    display: flex;
    gap: 4px;
    background: #f1f5f9;
    border-radius: 8px;
    padding: 3px;
}

.crm-filter-tab {
    border: none;
    background: transparent;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 500;
    color: #64748b;
    cursor: pointer;
    transition: all 0.15s;
}

.crm-filter-tab.active {
    background: white;
    color: #1e293b;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0,0,0,.1);
}

/* Client list */
.crm-clients-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.crm-client-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    transition: all 0.15s;
}

.crm-client-card:hover {
    border-color: #3b82f6;
    box-shadow: 0 2px 8px rgba(59,130,246,.1);
    transform: translateY(-1px);
}

.crm-client-avatar {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    color: white;
    font-size: 20px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.crm-client-info {
    flex: 1;
    min-width: 0;
}

.crm-client-name {
    font-size: 15px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.crm-client-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 12px;
    color: #64748b;
    margin-bottom: 2px;
}

.crm-client-last {
    font-size: 12px;
    color: #94a3b8;
}

.crm-client-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}

.crm-client-arrow {
    font-size: 18px;
    color: #94a3b8;
}

/* Status badges */
.crm-status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.crm-status-active { background: #dcfce7; color: #16a34a; }
.crm-status-inactive { background: #f1f5f9; color: #64748b; }
.crm-status-prospect { background: #dbeafe; color: #1d4ed8; }
.crm-status-lost { background: #fee2e2; color: #dc2626; }
.crm-status-open { background: #fee2e2; color: #dc2626; }
.crm-status-in_progress { background: #fef3c7; color: #b45309; }
.crm-status-resolved { background: #dcfce7; color: #16a34a; }
.crm-status-closed { background: #f1f5f9; color: #64748b; }

.crm-complaints-badge {
    background: #fee2e2;
    color: #dc2626;
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
}

/* Priority badges */
.crm-priority-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.crm-priority-low { background: #dcfce7; color: #16a34a; }
.crm-priority-medium { background: #fef3c7; color: #b45309; }
.crm-priority-high { background: #fed7aa; color: #c2410c; }
.crm-priority-critical { background: #fee2e2; color: #dc2626; }

/* Primary contact badge */
.crm-primary-badge {
    background: #dbeafe;
    color: #1d4ed8;
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 10px;
    font-weight: 600;
    margin-left: 6px;
}

/* Outcome badge */
.crm-outcome-badge {
    display: inline-block;
    margin-top: 4px;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}
.crm-outcome-positive { background: #dcfce7; color: #16a34a; }
.crm-outcome-neutral { background: #f1f5f9; color: #64748b; }
.crm-outcome-negative { background: #fee2e2; color: #dc2626; }

/* Client detail */
.crm-detail-grid {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 16px;
    align-items: start;
}

@media (max-width: 900px) {
    .crm-detail-grid {
        grid-template-columns: 1fr;
    }
}

.crm-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px;
}

.crm-card-title {
    font-size: 14px;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid #f1f5f9;
}

.crm-info-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.crm-info-row {
    display: flex;
    gap: 12px;
    font-size: 13px;
}

.crm-info-label {
    color: #64748b;
    flex-shrink: 0;
    width: 80px;
    padding-top: 1px;
    font-size: 12px;
}

/* Contacts */
.crm-contact-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 10px 0;
    border-bottom: 1px solid #f1f5f9;
    font-size: 13px;
}
.crm-contact-row:last-child { border-bottom: none; }

/* Interactions */
.crm-interaction-row {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 10px 0;
    border-bottom: 1px solid #f8fafc;
    font-size: 13px;
}
.crm-interaction-row:last-child { border-bottom: none; }

.crm-interaction-icon {
    font-size: 18px;
    width: 28px;
    text-align: center;
    flex-shrink: 0;
    margin-top: 1px;
}

/* Complaints */
.crm-complaint-row {
    padding: 10px 0;
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
    transition: background 0.15s;
    border-radius: 6px;
    padding: 8px;
    margin: -2px;
}
.crm-complaint-row:hover { background: #f8fafc; }
.crm-complaint-row:last-child { border-bottom: none; }

/* Form grid */
.crm-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
@media (max-width: 480px) {
    .crm-form-grid { grid-template-columns: 1fr; }
}

/* Loading / Empty */
.crm-loading {
    text-align: center;
    padding: 40px;
    color: #64748b;
    font-size: 14px;
}

.crm-empty {
    text-align: center;
    padding: 60px 20px;
    color: #94a3b8;
    font-size: 14px;
    background: white;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
}

/* ==================== Phase 18.2: Воронка продаж ==================== */

.deals-page {
    padding: 20px;
    max-width: 1400px;
    margin: 0 auto;
}

.deals-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
    gap: 12px;
    flex-wrap: wrap;
}

.deals-title {
    font-size: 22px;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 4px;
}

.deals-subtitle {
    font-size: 13px;
    color: #64748b;
    margin: 0;
}

/* Analytics bar */
.deals-analytics {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

@media (max-width: 768px) {
    .deals-analytics { grid-template-columns: repeat(2, 1fr); }
}

.deals-analytic-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px;
    text-align: center;
}
.deals-analytic-card.won { border-left: 3px solid #10b981; }

.deals-analytic-value {
    font-size: 24px;
    font-weight: 700;
    color: #1e293b;
    line-height: 1;
    margin-bottom: 4px;
}

.deals-analytic-label {
    font-size: 11px;
    color: #64748b;
    font-weight: 500;
}

/* Kanban board */
.deals-kanban {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 16px;
    align-items: flex-start;
}

.deals-column {
    background: #f8fafc;
    border-radius: 12px;
    padding: 12px;
    min-width: 230px;
    max-width: 260px;
    flex-shrink: 0;
    border: 1px solid #e5e7eb;
}

.deals-col-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e5e7eb;
}

.deals-col-icon { font-size: 16px; }
.deals-col-label { font-size: 13px; font-weight: 700; color: #1e293b; flex: 1; }
.deals-col-cnt {
    background: #e2e8f0;
    color: #475569;
    border-radius: 10px;
    padding: 1px 7px;
    font-size: 11px;
    font-weight: 600;
}

.deals-col-amount {
    font-size: 11px;
    color: #64748b;
    font-weight: 600;
    margin-bottom: 8px;
    text-align: right;
}

.deals-col-cards {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 40px;
    margin-bottom: 8px;
}

.deals-col-empty {
    color: #cbd5e1;
    font-size: 12px;
    text-align: center;
    padding: 12px 0;
}

.deals-add-btn {
    width: 100%;
    border: 1px dashed #cbd5e1;
    background: transparent;
    border-radius: 8px;
    padding: 6px;
    font-size: 12px;
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.15s;
    margin-top: 4px;
}
.deals-add-btn:hover { border-color: #3b82f6; color: #3b82f6; background: #eff6ff; }

/* Deal card */
.deal-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.15s;
}
.deal-card:hover {
    border-color: #3b82f6;
    box-shadow: 0 2px 8px rgba(59,130,246,.12);
    transform: translateY(-1px);
}

.deal-card-title {
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 4px;
    line-height: 1.3;
}

.deal-card-client {
    font-size: 11px;
    color: #64748b;
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.deal-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.deal-card-amount {
    font-size: 12px;
    font-weight: 700;
    color: #1e293b;
}

.deal-card-date {
    font-size: 11px;
    color: #64748b;
}
.deal-card-date.overdue { color: #ef4444; font-weight: 600; }

.deal-card-prob {
    height: 3px;
    background: #e2e8f0;
    border-radius: 2px;
    overflow: hidden;
}
.deal-card-prob-bar {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s;
}

/* Deal Detail grid */
.deal-detail-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 16px;
    align-items: start;
}

@media (max-width: 900px) {
    .deal-detail-grid { grid-template-columns: 1fr; }
}

/* Stage change buttons */
.deals-stage-btn {
    border: 2px solid #e2e8f0;
    background: white;
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
    font-weight: 500;
}
.deals-stage-btn:hover { opacity: 0.8; }
.deals-stage-btn.active { font-weight: 700; }

/* Tasks */
.deal-task {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #f1f5f9;
    font-size: 13px;
}
.deal-task:last-child { border-bottom: none; }
.deal-task.done { opacity: 0.6; }

.deal-task-date {
    font-size: 11px;
    color: #94a3b8;
    white-space: nowrap;
    margin-left: 8px;
    flex-shrink: 0;
}
