/* KK CRM */
.crm-layout{display:block;background:var(--bg);height:100%;overflow:hidden;}
.crm-main{padding:28px 32px;height:100%;overflow-y:auto;}
.crm-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:20px;gap:12px;flex-wrap:wrap;}
.crm-header h2{font-size:18px;font-weight:700;color:var(--text);margin:0;}
.crm-btn{display:inline-flex;align-items:center;gap:6px;padding:8px 18px;border-radius:8px;font-size:13px;font-weight:600;border:none;cursor:pointer;transition:all .15s;}
.crm-btn-primary{background:var(--navy);color:#fff;} .crm-btn-primary:hover{opacity:.9;}
.crm-btn-outline{background:none;border:1px solid var(--border);color:var(--text-sec);} .crm-btn-outline:hover{border-color:var(--accent);color:var(--accent);}
.crm-btn-sm{padding:5px 12px;font-size:11px;}
.crm-btn-danger{background:#fee2e2;color:#dc2626;border:1px solid #fecaca;} .crm-btn-danger:hover{background:#fecaca;}

/* Stats row */
.crm-stats{display:grid;grid-template-columns:repeat(5,1fr);gap:10px;margin-bottom:20px;}
.crm-stat{background:var(--surface);border:1px solid var(--border);border-radius:10px;padding:14px;text-align:center;cursor:pointer;transition:all .15s;}
.crm-stat:hover{border-color:var(--accent);box-shadow:0 2px 8px rgba(0,0,0,.04);}
.crm-stat.active{border-color:var(--navy);background:var(--navy-soft);}
.crm-stat-count{font-size:22px;font-weight:800;color:var(--text);}
.crm-stat-label{font-size:10px;font-weight:600;color:var(--text-ter);text-transform:uppercase;letter-spacing:.04em;margin-top:2px;}

/* Filters */
.crm-filters{display:flex;gap:8px;margin-bottom:16px;flex-wrap:wrap;align-items:center;}
.crm-search{padding:7px 12px;border:1px solid var(--border);border-radius:8px;font-size:13px;background:var(--surface);color:var(--text);outline:none;min-width:220px;}
.crm-search:focus{border-color:var(--accent);}
.crm-select{padding:7px 10px;border:1px solid var(--border);border-radius:8px;font-size:12px;background:var(--surface);color:var(--text);outline:none;}

/* Lead list */
.crm-list{display:flex;flex-direction:column;gap:6px;}
.crm-row{display:flex;align-items:center;gap:14px;padding:12px 14px;background:var(--surface);border:1px solid var(--border);border-radius:10px;cursor:pointer;transition:all .15s;}
.crm-row:hover{border-color:var(--accent);box-shadow:0 2px 8px rgba(0,0,0,.04);}
.crm-row-avatar{width:36px;height:36px;border-radius:50%;background:var(--accent);color:#fff;display:flex;align-items:center;justify-content:center;font-size:14px;font-weight:700;flex-shrink:0;}
.crm-row-info{flex:1;min-width:0;}
.crm-row-name{font-size:13px;font-weight:600;color:var(--text);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.crm-row-meta{font-size:11px;color:var(--text-ter);margin-top:1px;}
.crm-row-source{font-size:10px;font-weight:600;padding:2px 8px;border-radius:12px;background:var(--bg);color:var(--text-sec);white-space:nowrap;}
.crm-row-stage{font-size:10px;font-weight:600;padding:2px 8px;border-radius:12px;white-space:nowrap;}
.crm-stage-lead{background:#dbeafe;color:#1e40af;}
.crm-stage-contacto{background:#fef3c7;color:#92400e;}
.crm-stage-prospecto{background:#e0e7ff;color:#4338ca;}
.crm-stage-cliente{background:#d1fae5;color:#065f46;}
.crm-stage-archivado{background:#f1f5f9;color:#64748b;}

/* Empty state */
.crm-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:60px 20px;color:var(--text-ter);text-align:center;}
.crm-empty-icon{font-size:48px;margin-bottom:16px;opacity:.5;}
.crm-empty-title{font-size:15px;font-weight:600;color:var(--text-sec);margin-bottom:6px;}

/* Lead detail panel */
.crm-detail{display:grid;grid-template-columns:1fr 320px;gap:16px;height:100%;}
.crm-detail-main{overflow-y:auto;}
.crm-detail-side{border-left:1px solid var(--border);padding-left:16px;overflow-y:auto;}
.crm-detail-head{display:flex;align-items:center;gap:14px;margin-bottom:20px;}
.crm-detail-avatar{width:52px;height:52px;border-radius:50%;background:var(--accent);color:#fff;display:flex;align-items:center;justify-content:center;font-size:22px;font-weight:700;flex-shrink:0;}
.crm-detail-name{font-size:17px;font-weight:700;color:var(--text);}
.crm-detail-stage{margin-top:2px;}
.crm-field-group{display:grid;grid-template-columns:1fr 1fr;gap:10px;margin-bottom:16px;}
.crm-field{display:grid;gap:3px;}
.crm-field label{font-size:10px;font-weight:600;color:var(--text-sec);}
.crm-field input,.crm-field select,.crm-field textarea{padding:7px 10px;border:1px solid var(--border);border-radius:6px;font-size:12px;background:var(--surface);color:var(--text);outline:none;font-family:inherit;}
.crm-field input:focus,.crm-field select:focus,.crm-field textarea:focus{border-color:var(--accent);}

/* Timeline */
.crm-timeline{display:flex;flex-direction:column;gap:8px;}
.crm-timeline-title{font-size:11px;font-weight:800;color:var(--text-sec);text-transform:uppercase;letter-spacing:.04em;margin-bottom:4px;}
.crm-timeline-item{display:flex;gap:10px;font-size:11px;color:var(--text-sec);padding:8px 0;border-bottom:1px solid var(--border);}
.crm-timeline-item:last-child{border-bottom:none;}
.crm-timeline-dot{width:8px;height:8px;border-radius:50%;background:var(--accent);flex-shrink:0;margin-top:3px;}
.crm-timeline-text{flex:1;}
.crm-timeline-date{font-size:10px;color:var(--text-ter);white-space:nowrap;}

/* Add note */
.crm-note-input{width:100%;padding:8px 10px;border:1px solid var(--border);border-radius:8px;font-size:12px;resize:none;min-height:60px;font-family:inherit;outline:none;}
.crm-note-input:focus{border-color:var(--accent);}

/* Modal */
.crm-modal-overlay{position:fixed;inset:0;background:rgba(0,0,0,.4);z-index:9999;display:flex;align-items:center;justify-content:center;}
.crm-modal{background:var(--surface);border-radius:12px;padding:24px;max-width:480px;width:92%;box-shadow:0 8px 32px rgba(0,0,0,.15);position:relative;}
.crm-modal h3{font-size:15px;font-weight:700;margin-bottom:16px;color:var(--text);}
.crm-modal-close{position:absolute;top:12px;right:14px;background:none;border:none;font-size:18px;cursor:pointer;color:var(--text-ter);}

/* Tags */
.crm-tags{display:flex;flex-wrap:wrap;gap:4px;margin-top:4px;}
.crm-tag{font-size:10px;font-weight:600;padding:2px 8px;border-radius:12px;background:var(--bg);color:var(--text-sec);border:1px solid var(--border);}

@media(max-width:900px){
  .crm-stats{grid-template-columns:repeat(3,1fr);}
  .crm-detail{grid-template-columns:1fr;}
  .crm-detail-side{border-left:none;padding-left:0;border-top:1px solid var(--border);padding-top:16px;}
}
@media(max-width:600px){
  .crm-stats{grid-template-columns:repeat(2,1fr);}
  .crm-main{padding:16px;}
}
