/* ═══════════════════════════════════════════════════════════════
   CRM Module — Premium Styles (crm.css)
   iEnTop ERP · Indigo Deep Theme
   ═══════════════════════════════════════════════════════════════ */

/* ── CSS Variables (CRM-specific) ──────────────────────────── */
:root {
  --crm-accent: var(--color-accent, #6366f1);
  --crm-accent-light: var(--color-accent-hover, #818cf8);
  --crm-accent-glow: var(--color-accent-subtle, rgba(99, 102, 241, 0.15));
  --crm-bg-base: var(--color-bg-primary, #0a0e1a);
  --crm-bg-card: var(--color-bg-card, #111827);
  --crm-bg-elevated: var(--color-bg-secondary, #1e293b);
  --crm-border: var(--color-border, #1e293b);
  --crm-border-light: var(--color-bg-hover, #334155);
  --crm-text: var(--color-text-primary, #f1f5f9);
  --crm-text-muted: var(--color-text-secondary, #94a3b8);
  --crm-text-dim: var(--color-text-muted, #64748b);
  --crm-success: var(--color-success, #10b981);
  --crm-warning: var(--color-warning, #f59e0b);
  --crm-danger: var(--color-danger, #ef4444);
  --crm-info: #3b82f6;
  --crm-violet: #8b5cf6;
  --crm-nav-width: 240px;
  --crm-nav-width-collapsed: 0px;
  --crm-radius: 12px;
  --crm-radius-sm: 8px;
  --crm-transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Global Reset ──────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ── TMS WEB Core Form Wrapper Fix ─────────────────────────── */
/* TMS WEB Core wraps Unit1.html body inside a form <div>.
   Without explicit dimensions, the flex layout breaks.
   ⚠️ ACOTADO a body.crm-standalone (Project1/Unit1/test_standalone llevan la
   clase): sin acotar, estos selectores casaban con CUALQUIER popup colgado
   de body en el ERP —crm.css carga en el shell para todos— y con
   especificidad de ID (los :not) + !important lo inflaban a pantalla
   completa y lo tiraban al flujo (position:relative). Rompió el menú
   contextual de carpetas del correo (01-09-2026, verificado en producción). */
body.crm-standalone>div:not(#cp-toast-container):not(.cp-confirm-overlay):not([id*="validation"]),
body.crm-standalone>div:not(#cp-toast-container)>div:not(.cp-confirm-overlay):not(.cp-toast),
.TWebForm,
[class*="TForm"] {
  width: 100% !important;
  height: 100% !important;
  position: relative;
}

/* ═══════════════════════════════════════════════════════════════
   1. LAYOUT — Sidebar + Main
   ═══════════════════════════════════════════════════════════════ */

.crm-layout {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  background: var(--crm-bg-base);
  color: var(--crm-text);
}

/* ── Sidebar Navigation ────────────────────────────────────── */
.crm-nav {
  width: var(--crm-nav-width);
  min-width: var(--crm-nav-width);
  background: linear-gradient(180deg, var(--crm-bg-elevated) 0%, var(--crm-bg-base) 100%);
  border-right: 1px solid var(--crm-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width var(--crm-transition), min-width var(--crm-transition);
  z-index: 100;
}

.crm-nav-header {
  padding: 20px 16px 12px;
  border-bottom: 1px solid var(--crm-border);
}

.crm-nav-title {
  font-size: 16px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--crm-accent-light), var(--crm-violet));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.crm-nav-version {
  font-size: 10px;
  color: var(--crm-text-dim);
  margin-top: 2px;
}

.crm-nav-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.crm-nav-body::-webkit-scrollbar {
  width: 3px;
}

.crm-nav-body::-webkit-scrollbar-thumb {
  background: var(--crm-border-light);
  border-radius: 3px;
}

.crm-nav-section {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--crm-text-dim);
  padding: 16px 16px 6px;
}

.crm-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  cursor: pointer;
  color: var(--crm-text-muted);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s ease;
  border-left: 3px solid transparent;
  margin: 1px 0;
}

.crm-nav-item:hover {
  background: rgba(99, 102, 241, 0.06);
  color: var(--crm-text);
}

.crm-nav-item.crm-active {
  background: var(--crm-accent-glow);
  color: var(--crm-accent-light);
  border-left-color: var(--crm-accent);
  font-weight: 600;
}

.crm-nav-icon {
  font-size: 15px;
  width: 20px;
  text-align: center;
}

.crm-nav-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  background: var(--crm-accent);
  color: white;
}

.crm-nav-bottom {
  border-top: 1px solid var(--crm-border);
  padding: 8px 0;
}

/* ── Main Content Area ─────────────────────────────────────── */
.crm-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--crm-bg-base);
}

/* ── Views ──────────────────────────────────────────────────── */
.crm-view {
  display: none;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.crm-view.crm-active {
  display: flex;
}

/* ── Header Bar ────────────────────────────────────────────── */
.crm-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--crm-border);
  background: color-mix(in srgb, var(--crm-bg-base) 60%, transparent);
  backdrop-filter: blur(12px);
  flex-shrink: 0;
}

.crm-header-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--crm-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  background: linear-gradient(135deg, var(--crm-accent), var(--crm-violet));
  flex-shrink: 0;
}

.crm-header-text {
  flex: 1;
}

.crm-header-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--crm-text);
}

.crm-header-sub {
  font-size: 12px;
  color: var(--crm-text-dim);
  margin-top: 1px;
}

.crm-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ═══════════════════════════════════════════════════════════════
   2. BUTTONS
   ═══════════════════════════════════════════════════════════════ */

.crm-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--crm-radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
  white-space: nowrap;
}

.crm-btn-primary {
  background: linear-gradient(135deg, var(--crm-accent), var(--crm-violet));
  color: white;
  border: none;
}

.crm-btn-primary:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.crm-btn-ghost {
  background: transparent;
  color: var(--crm-text-muted);
  border-color: var(--crm-border-light);
}

.crm-btn-ghost:hover {
  background: var(--crm-accent-glow);
  color: var(--crm-text);
  border-color: var(--crm-accent);
}

.crm-btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.crm-btn-success {
  background: var(--crm-success);
  color: white;
  border: none;
}

.crm-btn-success:hover {
  opacity: 0.9;
}

/* ═══════════════════════════════════════════════════════════════
   3. DASHBOARD — KPIs + Charts
   ═══════════════════════════════════════════════════════════════ */

.crm-dash-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.crm-kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.crm-kpi {
  background: var(--crm-bg-card);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
  text-align: center;
}

.crm-kpi:hover {
  border-color: var(--crm-border-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow-card, 0 8px 25px rgba(0, 0, 0, 0.3));
}

.crm-kpi::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: var(--crm-radius) var(--crm-radius) 0 0;
}

.crm-kpi.k-indigo::before {
  background: linear-gradient(90deg, #6366f1, #8b5cf6);
}

.crm-kpi.k-emerald::before {
  background: linear-gradient(90deg, #10b981, #34d399);
}

.crm-kpi.k-amber::before {
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.crm-kpi.k-rose::before {
  background: linear-gradient(90deg, #f43f5e, #fb7185);
}

.crm-kpi-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.crm-kpi-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--crm-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.crm-kpi-icon {
  font-size: 22px;
  opacity: 0.6;
}

.crm-kpi-value {
  font-size: 28px;
  font-weight: 800;
  margin: 8px 0;
  color: var(--crm-text);
}

.crm-kpi-footer {
  font-size: 12px;
  color: var(--crm-text-dim);
  display: flex;
  align-items: center;
  gap: 6px;
}

.crm-trend-up {
  color: var(--crm-success);
  font-weight: 600;
}

.crm-trend-down {
  color: var(--crm-danger);
  font-weight: 600;
}

.crm-dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.crm-dash-bottom-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 20px;
}

.crm-dash-bottom-row>div {
  background: var(--crm-bg-card);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius);
  overflow: hidden;
}

/* ── Forecast Panel ────────────────────────────────────────── */
.crm-forecast-header,
.crm-team-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--crm-border);
}

.crm-forecast-title,
.crm-team-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--crm-text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.crm-forecast-values {
  display: flex;
  gap: 24px;
  padding: 16px 20px;
}

.crm-forecast-val-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--crm-text-dim);
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.crm-forecast-val-number {
  font-size: 20px;
  font-weight: 800;
  color: var(--crm-text);
}

.crm-forecast-val-number.actual {
  color: var(--crm-success);
}

.crm-forecast-val-number.target {
  color: var(--crm-text-muted);
}

.crm-forecast-bar-track {
  margin: 0 20px;
  height: 8px;
  background: color-mix(in srgb, var(--crm-border-light) 30%, transparent);
  border-radius: 4px;
  overflow: hidden;
}

.crm-forecast-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--crm-accent), var(--crm-success));
  border-radius: 4px;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.crm-forecast-pct {
  padding: 10px 20px 16px;
  font-size: 11px;
  color: var(--crm-text-dim);
  text-align: right;
}

/* ── Team Ranking Panel ────────────────────────────────────── */
.crm-team-row {
  display: flex;
  align-items: center;
  padding: 10px 20px;
  border-bottom: 1px solid var(--crm-border);
}

.crm-team-row:last-child {
  border-bottom: none;
}

.crm-team-rank {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--crm-text-dim);
  background: color-mix(in srgb, var(--crm-border-light) 25%, transparent);
  margin-right: 10px;
  flex-shrink: 0;
}

.crm-team-rank.rank-1 {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #000;
}

.crm-team-rank.rank-2 {
  background: linear-gradient(135deg, #94a3b8, #64748b);
  color: #fff;
}

.crm-team-rank.rank-3 {
  background: linear-gradient(135deg, #b45309, #92400e);
  color: #fff;
}

.crm-team-info {
  flex: 1;
  min-width: 0;
}

.crm-team-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--crm-text);
}

.crm-team-deals {
  font-size: 11px;
  color: var(--crm-text-dim);
}

.crm-team-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--crm-success);
  white-space: nowrap;
}

/* ── Cards ──────────────────────────────────────────────────── */
.crm-card {
  background: var(--crm-bg-card);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius);
  overflow: hidden;
}

.crm-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--crm-border);
}

.crm-card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--crm-text);
}

.crm-card-body {
  padding: 20px;
}

/* ── Funnel Chart (CSS) ────────────────────────────────────── */
.crm-funnel {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.crm-funnel-step {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
}

.crm-funnel-label {
  width: 120px;
  font-size: 12px;
  font-weight: 600;
  color: var(--crm-text-muted);
  text-align: right;
  flex-shrink: 0;
}

.crm-funnel-bar-wrap {
  flex: 1;
  height: 28px;
  background: rgba(99, 102, 241, 0.08);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}

.crm-funnel-bar {
  height: 100%;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 10px;
  font-size: 11px;
  font-weight: 700;
  color: white;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.crm-funnel-count {
  font-size: 13px;
  font-weight: 700;
  color: var(--crm-text);
  width: 40px;
  text-align: right;
  flex-shrink: 0;
}

/* ── Activity Feed ─────────────────────────────────────────── */
.crm-feed {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.crm-feed-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--crm-border);
}

.crm-feed-item:last-child {
  border-bottom: none;
}

.crm-feed-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
  margin-top: 2px;
}

.crm-feed-dot.dot-call {
  background: rgba(59, 130, 246, 0.15);
  color: var(--crm-info);
}

.crm-feed-dot.dot-email {
  background: rgba(99, 102, 241, 0.15);
  color: var(--crm-accent-light);
}

.crm-feed-dot.dot-meeting {
  background: rgba(139, 92, 246, 0.15);
  color: var(--crm-violet);
}

.crm-feed-dot.dot-note {
  background: rgba(245, 158, 11, 0.15);
  color: var(--crm-warning);
}

.crm-feed-dot.dot-deal {
  background: rgba(16, 185, 129, 0.15);
  color: var(--crm-success);
}

.crm-feed-dot.dot-task {
  background: rgba(244, 63, 94, 0.15);
  color: #f43f5e;
}

.crm-feed-body {
  flex: 1;
}

.crm-feed-text {
  font-size: 13px;
  color: var(--crm-text);
  line-height: 1.4;
}

.crm-feed-text strong {
  font-weight: 600;
  color: var(--crm-accent-light);
}

.crm-feed-time {
  font-size: 11px;
  color: var(--crm-text-dim);
  margin-top: 2px;
}

/* ═══════════════════════════════════════════════════════════════
   4. PIPELINE — Column Layout
   ═══════════════════════════════════════════════════════════════ */

.crm-pipeline-wrap {
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 20px;
}

.crm-pipeline-board {
  display: flex;
  gap: 16px;
  height: 100%;
  min-width: max-content;
}

.crm-pipeline-col {
  width: 280px;
  min-width: 280px;
  background: var(--crm-bg-card);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.crm-pipeline-col-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--crm-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.crm-pipeline-col-title {
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.crm-pipeline-col-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.crm-pipeline-col-count {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--crm-border-light) 30%, transparent);
  color: var(--crm-text-muted);
}

.crm-pipeline-col-total {
  font-size: 11px;
  font-weight: 700;
  color: var(--crm-text-dim);
  padding: 8px 16px;
  border-top: 1px solid var(--crm-border);
  text-align: right;
  flex-shrink: 0;
}

.crm-pipeline-cards {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.crm-pipeline-cards::-webkit-scrollbar {
  width: 3px;
}

.crm-pipeline-cards::-webkit-scrollbar-thumb {
  background: var(--crm-border-light);
  border-radius: 3px;
}

/* ── Deal Card ─────────────────────────────────────────────── */
.crm-deal-card {
  background: var(--crm-bg-elevated);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-sm);
  padding: 14px;
  cursor: grab;
  transition: all 0.2s ease;
}

.crm-deal-card:hover {
  border-color: var(--crm-accent);
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.15);
  transform: translateY(-1px);
}

.crm-deal-card.dragging {
  opacity: 0.5;
  transform: rotate(2deg);
}

.crm-deal-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.crm-deal-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--crm-text);
  line-height: 1.3;
}

.crm-deal-amount {
  font-size: 13px;
  font-weight: 700;
  color: var(--crm-success);
  white-space: nowrap;
}

.crm-deal-company {
  font-size: 11px;
  color: var(--crm-text-muted);
  margin-bottom: 10px;
}

.crm-deal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.crm-deal-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  color: white;
}

.crm-deal-prob {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
}

.crm-deal-date {
  font-size: 10px;
  color: var(--crm-text-dim);
}

/* ── Pipeline Drop Zones ───────────────────────────────────── */
.crm-pipeline-col.drag-over .crm-pipeline-cards {
  background: rgba(99, 102, 241, 0.05);
  border: 2px dashed var(--crm-accent);
  border-radius: var(--crm-radius-sm);
}

/* ═══════════════════════════════════════════════════════════════
   5. KANBAN — Task Board
   ═══════════════════════════════════════════════════════════════ */

.crm-kanban-wrap {
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 20px;
}

.crm-kanban-board {
  display: flex;
  gap: 16px;
  height: 100%;
  min-width: max-content;
}

.crm-kanban-col {
  width: 300px;
  min-width: 300px;
  background: var(--crm-bg-card);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.crm-kanban-col-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--crm-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.crm-kanban-col-title {
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.crm-kanban-cards {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ── Task Card ─────────────────────────────────────────────── */
.crm-task-card {
  background: var(--crm-bg-elevated);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-sm);
  padding: 14px;
  cursor: grab;
  transition: all 0.2s ease;
}

.crm-task-card:hover {
  border-color: var(--crm-accent);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.1);
}

.crm-task-card.dragging {
  opacity: 0.4;
}

.crm-task-card.drop-before {
  box-shadow: 0 -3px 0 0 var(--crm-accent) inset, 0 -3px 0 0 var(--crm-accent);
  border-top: 2px solid var(--crm-accent);
}

.crm-task-card.drop-after {
  border-bottom: 2px solid var(--crm-accent);
}

.crm-task-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--crm-text);
  margin-bottom: 6px;
}

.crm-task-project {
  font-size: 11px;
  color: var(--crm-accent-light);
  font-weight: 500;
  margin-bottom: 8px;
}

.crm-task-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.crm-task-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  color: white;
}

.crm-task-priority {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
}

.crm-priority-high {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
}

.crm-priority-medium {
  background: rgba(245, 158, 11, 0.15);
  color: #fcd34d;
}

.crm-priority-low {
  background: rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
}

.crm-task-due {
  font-size: 10px;
  color: var(--crm-text-dim);
}

.crm-task-due.overdue {
  color: var(--crm-danger);
  font-weight: 600;
}

/* ═══════════════════════════════════════════════════════════════
   6. TIMELINE — Activity Feed
   ═══════════════════════════════════════════════════════════════ */

.crm-timeline-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.crm-timeline {
  position: relative;
  padding-left: 40px;
}

.crm-timeline::before {
  content: '';
  position: absolute;
  left: 15px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(180deg, var(--crm-accent), var(--crm-violet), transparent);
}

.crm-tl-item {
  position: relative;
  margin-bottom: 20px;
  padding: 16px 20px;
  background: var(--crm-bg-card);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius);
  transition: all 0.2s ease;
}

.crm-tl-item:hover {
  border-color: var(--crm-border-light);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.crm-tl-dot {
  position: absolute;
  left: -33px;
  top: 18px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  border: 2px solid var(--crm-bg-base);
}

.crm-tl-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.crm-tl-action {
  font-size: 13px;
  font-weight: 600;
  color: var(--crm-text);
}

.crm-tl-action strong {
  color: var(--crm-accent-light);
}

.crm-tl-time {
  font-size: 11px;
  color: var(--crm-text-dim);
}

.crm-tl-body {
  font-size: 12px;
  color: var(--crm-text-muted);
  line-height: 1.5;
}

.crm-tl-tags {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.crm-tag {
  font-size: 10px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 10px;
  background: rgba(99, 102, 241, 0.12);
  color: var(--crm-accent-light);
}

.crm-tag-success {
  background: rgba(16, 185, 129, 0.12);
  color: var(--crm-success);
}

.crm-tag-warning {
  background: rgba(245, 158, 11, 0.12);
  color: var(--crm-warning);
}

.crm-tag-danger {
  background: rgba(239, 68, 68, 0.12);
  color: var(--crm-danger);
}

/* ═══════════════════════════════════════════════════════════════
   7. CONTACTS — List/Table
   ═══════════════════════════════════════════════════════════════ */

/* Layout en columna con scroll SOLO en la tabla.
   KPIs, búsqueda, filtros y paginación quedan inmóviles en la cabecera. */
.crm-contacts-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  padding: 20px;
}

#contacts-kpis,
.crm-contacts-filters,
.crm-contacts-bulk,
.crm-contacts-counter {
  flex-shrink: 0;
}

.crm-contacts-filters {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  align-items: center;
  flex-wrap: wrap;
}

/* Paginación inline a la derecha de los botones de tipo. margin-left:auto la
   empuja al final manteniéndose alineada con los filtros, no debajo de la lista. */
.crm-contacts-pg-inline {
  margin-left: auto;
}

/* Wrapper con scroll vertical interno para la tabla. Las cabeceras de columna
   se quedan visibles vía position:sticky en thead th. */
.crm-contacts-table-wrap {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  border: 1px solid var(--crm-border-light);
  border-radius: var(--crm-radius-sm);
}

.crm-search {
  flex: 1;
  max-width: 400px;
  padding: 10px 16px;
  border-radius: var(--crm-radius-sm);
  border: 1px solid var(--crm-border);
  background: var(--crm-bg-elevated);
  color: var(--crm-text);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}

.crm-search:focus {
  border-color: var(--crm-accent);
}

.crm-search::placeholder {
  color: var(--crm-text-dim);
}

.crm-filter-btn {
  padding: 8px 14px;
  border-radius: var(--crm-radius-sm);
  border: 1px solid var(--crm-border);
  background: transparent;
  color: var(--crm-text-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.crm-filter-btn:hover,
.crm-filter-btn.active {
  background: var(--crm-accent-glow);
  border-color: var(--crm-accent);
  color: var(--crm-accent-light);
}

.crm-contacts-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.crm-contacts-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--crm-text-dim);
  border-bottom: 1px solid var(--crm-border-light);
  /* Sticky para que la cabecera de columnas se quede visible al scrollear */
  position: sticky;
  top: 0;
  background: var(--crm-bg-card);
  z-index: 2;
}

.crm-contacts-table td {
  padding: 14px;
  font-size: 13px;
  color: var(--crm-text);
  border-bottom: 1px solid var(--crm-border);
}

.crm-contacts-table tr:hover td {
  background: rgba(99, 102, 241, 0.03);
}

.crm-contact-name {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.crm-contact-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.crm-type-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* ═══════════════════════════════════════════════════════════════
   8. CONFIG — Settings Tabs
   ═══════════════════════════════════════════════════════════════ */

.crm-config-tabs {
  display: flex;
  border-bottom: 1px solid var(--crm-border-light);
  padding: 0 20px;
  flex-shrink: 0;
}

.crm-config-tab {
  padding: 12px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--crm-text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
  background: none;
  border-left: none;
  border-right: none;
  border-top: none;
}

.crm-config-tab:hover {
  color: var(--crm-text);
}

.crm-config-tab.active {
  color: var(--crm-accent-light);
  border-bottom-color: var(--crm-accent);
}

.crm-config-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.crm-config-panel {
  display: none;
}

.crm-config-panel.active {
  display: block;
}

/* ═══════════════════════════════════════════════════════════════
   9. SIDE PANEL — Detail Slide-In
   ═══════════════════════════════════════════════════════════════ */

.crm-side-panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.1s ease, visibility 0.1s ease;
}

.crm-side-panel-backdrop.open {
  opacity: 1;
  visibility: visible;
}

/* Colores del TEMA activo (--crm-* salen de --color-* del ERP). Antes el fondo era un
   degradado pizarra fijo y no seguía el tema (oled-black, claros…): 20-10-2026. */
.crm-side-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 560px;
  max-width: 100vw;
  background: var(--crm-bg-card);
  color: var(--crm-text);
  backdrop-filter: blur(20px);
  border-left: 1px solid var(--crm-border);
  box-shadow: -8px 0 40px rgba(0, 0, 0, 0.35);
  z-index: 2001;
  transform: translateX(100%);
  transition: transform 0.12s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.crm-side-panel.open {
  transform: translateX(0);
}

/* ── Side Panel Header ─────────────────────────────────────── */
.crm-sp-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 24px 28px 20px;
  border-bottom: 1px solid var(--crm-border);
  flex-shrink: 0;
  position: relative;
}

.crm-sp-header::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--crm-accent), var(--crm-violet), transparent 80%);
}

.crm-sp-close {
  background: color-mix(in srgb, var(--crm-border-light) 25%, transparent);
  border: 1px solid var(--crm-border);
  color: var(--crm-text-muted);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.crm-sp-close:hover {
  background: color-mix(in srgb, var(--crm-danger) 15%, transparent);
  color: var(--crm-danger);
  border-color: var(--crm-danger);
}

.crm-sp-title-block {
  flex: 1;
  min-width: 0;
  margin-right: 16px;
}

.crm-sp-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--crm-accent-light);
  margin-bottom: 4px;
}

.crm-sp-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--crm-text);
  line-height: 1.2;
  margin-bottom: 4px;
}

.crm-sp-subtitle {
  font-size: 13px;
  color: var(--crm-text-muted);
}

/* ── Side Panel Body ───────────────────────────────────────── */
.crm-sp-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
}

.crm-sp-body::-webkit-scrollbar {
  width: 4px;
}

.crm-sp-body::-webkit-scrollbar-track {
  background: transparent;
}

.crm-sp-body::-webkit-scrollbar-thumb {
  background: var(--crm-border-light);
  border-radius: 2px;
}

/* ── Detail Sections ───────────────────────────────────────── */
.crm-detail-section {
  margin-bottom: 28px;
}

.crm-detail-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--crm-text-dim);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.crm-detail-section-title i {
  color: var(--crm-accent-light);
  font-size: 13px;
}

/* Info Grid */
.crm-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.crm-info-item {
  background: color-mix(in srgb, var(--crm-text) 3%, transparent);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-sm);
  padding: 12px 14px;
}

.crm-info-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--crm-text-dim);
  margin-bottom: 4px;
}

.crm-info-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--crm-text);
}

.crm-info-value.highlight {
  color: var(--crm-success);
  font-size: 18px;
  font-weight: 800;
}

/* ── Stage Badge Large ─────────────────────────────────────── */
.crm-stage-badge-lg {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
}

.crm-stage-dot-lg {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

/* ── Mini Timeline in Detail ───────────────────────────────── */
.crm-sp-timeline {
  position: relative;
  padding-left: 24px;
}

.crm-sp-timeline::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(180deg, var(--crm-accent), transparent);
}

.crm-sp-tl-item {
  position: relative;
  margin-bottom: 14px;
  padding: 10px 14px;
  background: color-mix(in srgb, var(--crm-text) 3%, transparent);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-sm);
  transition: border-color 0.2s;
}

.crm-sp-tl-item:hover {
  border-color: var(--crm-border-light);
}

.crm-sp-tl-dot {
  position: absolute;
  left: -21px;
  top: 14px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  border: 2px solid var(--crm-bg-base);
}

.crm-sp-tl-text {
  font-size: 12px;
  color: var(--crm-text);
  font-weight: 600;
}

.crm-sp-tl-detail {
  font-size: 11px;
  color: var(--crm-text-muted);
  margin-top: 2px;
}

.crm-sp-tl-time {
  font-size: 10px;
  color: var(--crm-text-dim);
  margin-top: 4px;
}

/* ── Notes Section ─────────────────────────────────────────── */
.crm-note-item {
  padding: 12px 14px;
  background: rgba(245, 158, 11, 0.04);
  border: 1px solid rgba(245, 158, 11, 0.1);
  border-radius: var(--crm-radius-sm);
  margin-bottom: 8px;
}

.crm-note-text {
  font-size: 12px;
  color: var(--crm-text);
  line-height: 1.5;
}

.crm-note-meta {
  font-size: 10px;
  color: var(--crm-text-dim);
  margin-top: 6px;
}

.crm-note-input {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--crm-radius-sm);
  border: 1px solid var(--crm-border);
  background: var(--crm-bg-elevated);
  color: var(--crm-text);
  font-size: 12px;
  resize: vertical;
  min-height: 60px;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}

.crm-note-input:focus {
  border-color: var(--crm-accent);
}

/* ── SP Actions Bar ────────────────────────────────────────── */
.crm-sp-actions {
  display: flex;
  gap: 8px;
  padding: 16px 28px;
  border-top: 1px solid var(--crm-border);
  flex-shrink: 0;
  background: var(--crm-bg-elevated);
}

.crm-sp-actions .crm-btn {
  flex: 1;
  justify-content: center;
}

/* ── Linked Deals List ─────────────────────────────────────── */
.crm-linked-deal {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: color-mix(in srgb, var(--crm-text) 3%, transparent);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-sm);
  margin-bottom: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.crm-linked-deal:hover {
  border-color: var(--crm-accent);
  background: var(--crm-accent-glow);
}

.crm-linked-deal-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--crm-text);
}

.crm-linked-deal-amt {
  font-size: 12px;
  font-weight: 700;
  color: var(--crm-success);
}

/* Contact Detail avatar large */
.crm-avatar-lg {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 800;
  color: white;
  margin-right: 16px;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.crm-sp-hero {
  display: flex;
  align-items: center;
}

/* ═══════════════════════════════════════════════════════════════
   10. DASHBOARD EXTRAS — Forecast + Team
   ═══════════════════════════════════════════════════════════════ */

.crm-dash-bottom-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 20px;
}

/* Forecast Card */
.crm-forecast-card {
  background: var(--crm-bg-card);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius);
  padding: 20px 24px;
}

.crm-forecast-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.crm-forecast-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--crm-text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.crm-forecast-values {
  display: flex;
  gap: 20px;
  margin-bottom: 14px;
}

.crm-forecast-val-block {
  display: flex;
  flex-direction: column;
}

.crm-forecast-val-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--crm-text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.crm-forecast-val-number {
  font-size: 20px;
  font-weight: 800;
}

.crm-forecast-val-number.actual {
  color: var(--crm-success);
}

.crm-forecast-val-number.target {
  color: var(--crm-text-muted);
}

.crm-forecast-bar-track {
  height: 12px;
  background: color-mix(in srgb, var(--crm-border-light) 25%, transparent);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}

.crm-forecast-bar-fill {
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--crm-accent), var(--crm-success));
  transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.crm-forecast-bar-fill::after {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 20px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2));
  border-radius: 0 6px 6px 0;
}

.crm-forecast-pct {
  text-align: right;
  font-size: 11px;
  font-weight: 700;
  color: var(--crm-accent-light);
  margin-top: 6px;
}

/* Team Ranking */
.crm-team-card {
  background: var(--crm-bg-card);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius);
  padding: 20px 24px;
}

.crm-team-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.crm-team-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--crm-text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.crm-team-row {
  display: flex;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--crm-border);
}

.crm-team-row:last-child {
  border-bottom: none;
}

.crm-team-rank {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  margin-right: 12px;
  flex-shrink: 0;
}

.crm-team-rank.rank-1 {
  background: linear-gradient(135deg, #f59e0b, #fbbf24);
  color: #78350f;
}

.crm-team-rank.rank-2 {
  background: linear-gradient(135deg, #94a3b8, #cbd5e1);
  color: #334155;
}

.crm-team-rank.rank-3 {
  background: linear-gradient(135deg, #b45309, #d97706);
  color: #fff;
}

.crm-team-rank.rank-4 {
  background: color-mix(in srgb, var(--crm-border-light) 25%, transparent);
  color: var(--crm-text-dim);
}

.crm-team-info {
  flex: 1;
  min-width: 0;
}

.crm-team-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--crm-text);
}

.crm-team-deals {
  font-size: 11px;
  color: var(--crm-text-dim);
}

.crm-team-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--crm-success);
  text-align: right;
}

/* ═══════════════════════════════════════════════════════════════
   11. TASK MINI-MODAL
   ═══════════════════════════════════════════════════════════════ */

.crm-task-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(3px);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.crm-task-modal-backdrop.open {
  opacity: 1;
  visibility: visible;
}

.crm-task-modal {
  background: linear-gradient(160deg, rgba(15, 23, 42, 0.98), rgba(30, 41, 59, 0.99));
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: var(--crm-radius);
  width: 440px;
  max-width: 90vw;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 20px rgba(99, 102, 241, 0.08);
  transform: scale(0.95) translateY(8px);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.crm-task-modal-backdrop.open .crm-task-modal {
  transform: scale(1) translateY(0);
}

.crm-task-modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--crm-border);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.crm-task-modal-body {
  padding: 20px 24px;
}

.crm-task-modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--crm-border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  background: rgba(15, 23, 42, 0.3);
}

/* ═══════════════════════════════════════════════════════════════
   12. RESPONSIVE — Mobile
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .crm-nav {
    position: fixed;
    left: -240px;
    top: 0;
    bottom: 0;
    z-index: 1000;
    transition: left 0.3s ease;
  }

  .crm-nav.mobile-open {
    left: 0;
  }

  .crm-kpi-row {
    grid-template-columns: repeat(2, 1fr);
  }

  .crm-dash-grid {
    grid-template-columns: 1fr;
  }

  .crm-pipeline-col,
  .crm-kanban-col {
    width: 260px;
    min-width: 260px;
  }
}

@media (max-width: 480px) {
  .crm-kpi-row {
    grid-template-columns: 1fr;
  }

  .crm-pipeline-col,
  .crm-kanban-col {
    width: 240px;
    min-width: 240px;
  }

  .crm-header {
    padding: 12px 16px;
  }

  .crm-header-title {
    font-size: 15px;
  }
}

/* ═══════════════════════════════════════════════════════════════
   PIPELINE — Zone Separator (Lead → CRM)
   ═══════════════════════════════════════════════════════════════ */
.crm-pipeline-separator {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  padding: 0 4px;
  flex-shrink: 0;
}

.crm-pipeline-sep-line {
  width: 2px;
  height: 60px;
  background: linear-gradient(180deg, transparent, var(--crm-accent), transparent);
  margin-bottom: 8px;
}

.crm-pipeline-sep-labels {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.crm-pipeline-sep-lead {
  color: #06b6d4;
}

.crm-pipeline-sep-arrow {
  color: var(--crm-text-dim);
  font-size: 12px;
}

.crm-pipeline-sep-crm {
  color: var(--crm-accent-light);
}

.crm-pipeline-col-lead {
  background: rgba(6, 182, 212, 0.03);
  border: 1px solid rgba(6, 182, 212, 0.08);
}

/* ═══════════════════════════════════════════════════════════════
   PROYECTOS — Project Cards + Kanban
   ═══════════════════════════════════════════════════════════════ */
/* Layout de 3 zonas dentro de la vista Proyectos:
   1. KPIs (cabecera fija arriba — flex-shrink:0)
   2. Cards / listado (flex:1, scroll vertical propio)
   3. Detalle del proyecto seleccionado (flex-shrink:0, max-height:50vh,
      scroll interno propio si excede)
   El wrap NO scrollea — overflow:hidden — para evitar que las 3 zonas
   se desplacen como una sola.                                                */
.crm-proyectos-wrap {
  padding: 0 24px;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0; /* fix flex en padre */
}

/* Zócalo legacy: vaciado ahora que cada pestaña pinta sus KPIs dentro
   de su propio cuerpo. Se mantiene en el frame para no recompilar pas2js. */
#proyectos-kpis {
  display: none;
}

#proyectos-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  padding-top: 8px;
}

.crm-prj-cards-zone {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding-bottom: 14px;
}

.crm-prj-detail-zone {
  flex-shrink: 0;
  max-height: 50vh;        /* ocupa máximo medio viewport */
  overflow-y: auto;        /* scroll interno si excede */
  border-top: 2px dashed var(--crm-border);
  background: var(--crm-bg-primary, var(--crm-bg, #0f172a));
  padding: 6px 0 14px;
}

/* (30-10-2026) El detalle del proyecto vive en un POPUP (crm_engine.js,
   _ensureProjectPopup): overlay propio —no .crm-modal-overlay, que
   closeModal() borra— y caja ancha. Dentro, la zona de detalle ya no limita
   su altura ni lleva el borde superior: el scroll lo da .crm-modal-body. */
.crm-prj-popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.crm-modal.crm-modal-prj {
  width: 94vw;
  max-width: 1400px;
  max-height: 92vh;
}

.crm-modal-prj .crm-modal-body {
  padding: 0 0 14px;
}

/* (30-10-2026) Visor de documentos adjuntos (CRM.viewAttachment). */
.crm-att-viewer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.crm-modal.crm-att-viewer {
  width: 86vw;
  max-width: 1200px;
  height: 86vh;
  max-height: 92vh;
}

.crm-att-viewer-body {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--crm-text-dim);
  background: var(--crm-bg, #0f172a);
}

.crm-modal-prj .crm-prj-detail-zone {
  max-height: none;
  overflow: visible;
  border-top: 0;
  background: transparent;
  padding: 0 0 14px;
}

.crm-project-selector {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.crm-project-card {
  background: var(--crm-bg-card);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius);
  padding: 16px;
  cursor: pointer;
  transition: all var(--crm-transition);
}

.crm-project-card:hover {
  border-color: var(--crm-border-light);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.crm-project-card.active {
  border-color: var(--crm-accent);
  background: var(--crm-accent-glow);
  box-shadow: 0 0 0 1px var(--crm-accent), 0 4px 16px rgba(99, 102, 241, 0.15);
}

.crm-project-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.crm-project-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--crm-text);
}

.crm-project-status {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.crm-status-active {
  background: rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
}

.crm-status-planning {
  background: rgba(245, 158, 11, 0.15);
  color: #fcd34d;
}

.crm-project-desc {
  font-size: 12px;
  color: var(--crm-text-dim);
  margin-bottom: 12px;
  line-height: 1.4;
}

.crm-project-progress {
  margin-bottom: 12px;
}

.crm-project-progress-bar {
  height: 4px;
  background: var(--crm-bg-elevated);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 4px;
}

.crm-project-progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
}

.crm-project-progress-text {
  font-size: 11px;
  color: var(--crm-text-muted);
}

.crm-project-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.crm-project-team {
  display: flex;
  gap: -8px;
}

.crm-mini-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  color: white;
  border: 2px solid var(--crm-bg-card);
  margin-right: -6px;
}

.crm-project-deadline {
  font-size: 11px;
  color: var(--crm-text-dim);
}

.crm-project-deadline i {
  margin-right: 4px;
  opacity: 0.6;
}

.crm-project-deal {
  font-size: 11px;
  color: var(--crm-text-muted);
  padding-top: 8px;
  border-top: 1px solid var(--crm-border);
}

/* ═══════════════════════════════════════════════════════════════
   ACTIVIDADES — Filters + List
   ═══════════════════════════════════════════════════════════════ */
.crm-actividades-wrap {
  padding: 0 24px 24px;
  overflow-y: auto;
  flex: 1;
}

.crm-act-filters {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.crm-act-filter-btn {
  padding: 8px 16px;
  border: 1px solid var(--crm-border);
  background: var(--crm-bg-card);
  color: var(--crm-text-muted);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--crm-transition);
  display: flex;
  align-items: center;
  gap: 6px;
}

.crm-act-filter-btn:hover {
  background: var(--crm-bg-elevated);
  color: var(--crm-text);
  border-color: var(--crm-border-light);
}

.crm-act-filter-btn.active {
  background: var(--crm-accent-glow);
  color: var(--crm-accent-light);
  border-color: var(--crm-accent);
}

.crm-act-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.crm-act-item {
  display: flex;
  gap: 16px;
  padding: 16px;
  background: var(--crm-bg-card);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius);
  cursor: pointer;
  transition: all var(--crm-transition);
}

.crm-act-item:hover {
  border-color: var(--crm-border-light);
  transform: translateX(4px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.crm-act-dot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
}

.crm-act-content {
  flex: 1;
  min-width: 0;
}

.crm-act-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 6px;
}

.crm-act-title {
  font-size: 13px;
  color: var(--crm-text);
}

.crm-act-time {
  font-size: 11px;
  color: var(--crm-text-dim);
  white-space: nowrap;
  margin-left: 12px;
}

.crm-act-body {
  font-size: 12px;
  color: var(--crm-text-muted);
  margin-bottom: 8px;
  line-height: 1.5;
}

.crm-act-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* ═══════════════════════════════════════════════════════════════
   TASKS SEPARATOR BAR
   ═══════════════════════════════════════════════════════════════ */
.crm-tasks-separator {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  margin: 8px 0 16px;
  border-top: 1px solid var(--crm-border);
  border-bottom: 1px solid var(--crm-border);
}

.crm-tasks-sep-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.crm-tasks-sep-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--crm-text);
  display: flex;
  align-items: center;
}

.crm-tasks-sep-count {
  font-size: 12px;
  font-weight: 400;
  color: var(--crm-text-dim);
  margin-left: 8px;
}

.crm-tasks-sep-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── View Toggle (Kanban / List) ── */
.crm-view-toggle {
  display: flex;
  background: var(--crm-bg-card);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-sm);
  overflow: hidden;
}

.crm-toggle-btn {
  padding: 6px 12px;
  border: none;
  background: transparent;
  color: var(--crm-text-dim);
  cursor: pointer;
  transition: all var(--crm-transition);
  font-size: 13px;
}

.crm-toggle-btn:hover {
  color: var(--crm-text);
  background: var(--crm-bg-elevated);
}

.crm-toggle-btn.active {
  background: var(--crm-accent);
  color: white;
}

/* ═══════════════════════════════════════════════════════════════
   TASK LIST TABLE
   ═══════════════════════════════════════════════════════════════ */
.crm-task-list-wrap {
  overflow-x: auto;
}

.crm-task-list-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.crm-task-list-table thead th {
  text-align: left;
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--crm-text-dim);
  border-bottom: 1px solid var(--crm-border);
  white-space: nowrap;
}

.crm-task-list-row {
  cursor: pointer;
  transition: all var(--crm-transition);
}

.crm-task-list-row:hover {
  background: var(--crm-bg-card);
}

.crm-task-list-row td {
  padding: 12px;
  border-bottom: 1px solid var(--crm-border);
  color: var(--crm-text-muted);
  vertical-align: middle;
}

.crm-tl-cell-title {
  font-weight: 500;
  color: var(--crm-text) !important;
}

.crm-tl-project-badge {
  padding: 3px 8px;
  font-size: 11px;
  background: rgba(30, 41, 59, 0.5);
  border-radius: 4px;
  white-space: nowrap;
}

.crm-tl-user {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.crm-tl-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  white-space: nowrap;
}

.crm-tl-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.crm-overdue-text {
  color: var(--crm-danger) !important;
}

/* ═══════════════════════════════════════════════════════════════
   CREATION MODALS
   ═══════════════════════════════════════════════════════════════ */
.crm-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.crm-modal {
  background: var(--crm-bg-card);
  border: 1px solid var(--crm-border-light);
  border-radius: var(--crm-radius);
  width: 90%;
  max-width: 520px;
  /* Layout en columna: header/footer fijos, body con scroll interno.
     max-height < 100vh garantiza que el modal NUNCA supera el viewport
     (si lo hace, align-items:center del overlay desplaza la cabecera
     fuera de pantalla y el usuario no puede cerrar el diálogo). */
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: slideUp 0.25s ease;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.crm-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--crm-border);
  flex-shrink: 0; /* siempre visible aunque el body crezca */
}

.crm-modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--crm-text);
  display: flex;
  align-items: center;
}

.crm-modal-body {
  padding: 20px;
  flex: 1;
  overflow-y: auto; /* scroll interno cuando el contenido excede max-height del modal */
  min-height: 0;    /* fix flex: necesario para que overflow funcione en flex children */
}

.crm-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--crm-border);
  flex-shrink: 0; /* siempre visible aunque el body crezca */
}

.crm-modal-field {
  margin-bottom: 14px;
  flex: 1;
}

.crm-modal-field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--crm-text-dim);
  margin-bottom: 6px;
}

/* Cuando el label dentro de un crm-modal-field es un switch toggle,
   restaurar el flex (display:block lo rompía y dejaba el thumb suelto). */
.crm-modal-field label.crm-switch-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-transform: none;
  letter-spacing: normal;
  font-size: 12px;
  color: var(--crm-text-muted);
  margin-bottom: 0;
}

.crm-modal-row {
  display: flex;
  gap: 12px;
}

.crm-input {
  width: 100%;
  padding: 8px 12px;
  background: var(--crm-bg-base);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-sm);
  color: var(--crm-text);
  font-size: 13px;
  font-family: inherit;
  transition: border-color var(--crm-transition);
}

.crm-input:focus {
  outline: none;
  border-color: var(--crm-accent);
  box-shadow: 0 0 0 2px var(--crm-accent-glow);
}

.crm-input::placeholder {
  color: var(--crm-text-dim);
}

select.crm-input {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath fill='%2394a3b8' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}

textarea.crm-input {
  resize: vertical;
  min-height: 50px;
}

/* ── Color Picker ── */
.crm-color-picker {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.crm-color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all var(--crm-transition);
}

.crm-color-swatch:hover {
  transform: scale(1.15);
}

.crm-color-swatch.active {
  border-color: white;
  box-shadow: 0 0 0 2px var(--crm-accent);
  transform: scale(1.15);
}

/* ═══════════════════════════════════════════════════════════════
   PROJECT CARD ACTIONS
   ═══════════════════════════════════════════════════════════════ */
.crm-project-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.crm-project-action-bar {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity var(--crm-transition);
}

.crm-project-card:hover .crm-project-action-bar {
  opacity: 1;
}

.crm-proj-act-btn {
  width: 24px;
  height: 24px;
  border: none;
  background: color-mix(in srgb, var(--crm-border-light) 25%, transparent);
  color: var(--crm-text-dim);
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--crm-transition);
}

.crm-proj-act-btn:hover {
  background: var(--crm-accent);
  color: white;
}

.crm-proj-act-danger:hover {
  background: var(--crm-danger) !important;
}

/* ── Team Checklist (edit modal) ── */
.crm-team-checklist {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.crm-team-check {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--crm-text-muted);
  background: var(--crm-bg-elevated);
  border: 1px solid var(--crm-border);
  transition: all var(--crm-transition);
}

.crm-team-check:hover {
  border-color: var(--crm-accent);
  color: var(--crm-text);
}

.crm-team-check input[type="checkbox"] {
  accent-color: var(--crm-accent);
  margin: 0;
}

.crm-team-check .crm-mini-avatar {
  width: 22px;
  height: 22px;
  font-size: 9px;
}

/* ═══════════════════════════════════════════════════════════════
   GLOBAL SEARCH
   ═══════════════════════════════════════════════════════════════ */
.crm-global-search {
  padding: 12px 24px;
  position: relative;
  z-index: 100;
}

.crm-search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  max-width: 560px;
  margin: 0 auto;
}

.crm-search-icon {
  position: absolute;
  left: 14px;
  color: var(--crm-text-dim);
  font-size: 14px;
  pointer-events: none;
  z-index: 1;
}

.crm-search-input {
  width: 100%;
  padding: 10px 80px 10px 40px;
  background: var(--crm-bg-card);
  border: 1px solid var(--crm-border);
  border-radius: 10px;
  color: var(--crm-text);
  font-size: 14px;
  font-family: inherit;
  transition: all var(--crm-transition);
}

.crm-search-input:focus {
  outline: none;
  border-color: var(--crm-accent);
  box-shadow: 0 0 0 3px var(--crm-accent-glow), 0 4px 20px rgba(0, 0, 0, 0.3);
  background: var(--crm-bg-elevated);
}

.crm-search-input::placeholder {
  color: var(--crm-text-dim);
  font-size: 13px;
}

.crm-search-shortcut {
  position: absolute;
  right: 12px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--crm-text-dim);
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid var(--crm-border);
  border-radius: 5px;
  pointer-events: none;
  font-family: inherit;
}

/* ── Search Results Dropdown ── */
.crm-search-results {
  position: absolute;
  top: calc(100% - 4px);
  left: 24px;
  right: 24px;
  max-width: 560px;
  margin: 0 auto;
  background: var(--crm-bg-card);
  border: 1px solid var(--crm-border-light);
  border-radius: 0 0 var(--crm-radius) var(--crm-radius);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  max-height: 420px;
  overflow-y: auto;
  display: none;
  z-index: 200;
}

.crm-search-results.open {
  display: block;
  animation: fadeIn 0.15s ease;
}

.crm-search-group {
  border-bottom: 1px solid var(--crm-border);
}

.crm-search-group:last-of-type {
  border-bottom: none;
}

.crm-search-group-header {
  padding: 10px 16px 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--crm-text-dim);
}

.crm-search-group-count {
  font-weight: 400;
  color: var(--crm-text-dim);
  opacity: 0.6;
}

.crm-search-item {
  padding: 8px 16px 8px 28px;
  cursor: pointer;
  transition: background var(--crm-transition);
}

.crm-search-item:hover {
  background: var(--crm-bg-elevated);
}

.crm-search-item-text {
  font-size: 13px;
  font-weight: 500;
  color: var(--crm-text);
}

.crm-search-item-sub {
  font-size: 11px;
  color: var(--crm-text-dim);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.crm-search-highlight {
  background: rgba(245, 158, 11, 0.3);
  color: var(--crm-text);
  border-radius: 2px;
  padding: 0 1px;
}

.crm-search-empty {
  padding: 24px 16px;
  text-align: center;
  font-size: 13px;
  color: var(--crm-text-dim);
}

.crm-search-footer {
  padding: 8px 16px;
  font-size: 11px;
  color: var(--crm-text-dim);
  text-align: center;
  border-top: 1px solid var(--crm-border);
  background: rgba(30, 41, 59, 0.5);
}

/* ═══════════════════════════════════════════════════════════════
   DEAL DETAIL — QUICK ACTION TOOLBAR
   ═══════════════════════════════════════════════════════════════ */
.crm-deal-actions-bar {
  display: flex;
  gap: 6px;
  padding: 12px 0;
  justify-content: center;
}

.crm-quick-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--crm-border);
  background: var(--crm-bg-elevated);
  color: var(--crm-text-muted);
  border-radius: 8px;
  cursor: pointer;
  font-size: 10px;
  font-family: inherit;
  transition: all var(--crm-transition);
  flex: 1;
  min-width: 0;
}

.crm-quick-action i {
  font-size: 16px;
}

.crm-quick-action:hover {
  background: var(--crm-accent);
  color: white;
  border-color: var(--crm-accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--crm-accent-glow);
}

/* ── Deal Team List ── */
.crm-deal-team-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.crm-deal-team-member {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 6px;
  transition: background var(--crm-transition);
}

.crm-deal-team-member:hover {
  background: color-mix(in srgb, var(--crm-text) 4%, transparent);
}

/* ── Interactive Pipeline Stages ── */
.crm-pipeline-stages {
  display: flex;
  gap: 4px;
}

.crm-pipeline-stage {
  flex: 1;
  cursor: pointer;
  text-align: center;
  transition: all var(--crm-transition);
}

.crm-pipeline-stage .crm-stage-bar {
  height: 6px;
  border-radius: 3px;
  transition: all 0.3s ease;
}

.crm-pipeline-stage.active .crm-stage-bar {
  background: var(--stage-color);
  box-shadow: 0 0 8px var(--stage-color);
}

.crm-pipeline-stage.past .crm-stage-bar {
  background: color-mix(in srgb, var(--stage-color) 50%, transparent);
}

.crm-pipeline-stage.future .crm-stage-bar {
  background: color-mix(in srgb, var(--crm-border-light) 25%, transparent);
}

.crm-pipeline-stage .crm-stage-label {
  font-size: 9px;
  color: var(--crm-text-dim);
  margin-top: 4px;
  opacity: 0;
  transition: opacity var(--crm-transition);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.crm-pipeline-stage:hover .crm-stage-label {
  opacity: 1;
}

.crm-pipeline-stage:hover .crm-stage-bar {
  height: 8px;
}

/* ── Buttons: accent and xs ── */
.crm-btn-accent {
  background: linear-gradient(135deg, var(--crm-accent), #7c3aed);
  color: white;
  border: none;
}

.crm-btn-accent:hover {
  box-shadow: 0 4px 15px var(--crm-accent-glow);
  transform: translateY(-1px);
}

.crm-btn-xs {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 5px;
}

/* ── Note add section ── */
.crm-note-add {
  display: flex;
  flex-direction: column;
}

/* ── Modal rows ── */
.crm-modal-row {
  display: flex;
  gap: 12px;
}

.crm-modal-row .crm-modal-field {
  flex: 1;
}

/* ═══════════════════════════════════════════════════════════════
   ACTIVITY MODALS — SYSTEM INFO BAR & CALL TIMER
   ═══════════════════════════════════════════════════════════════ */
.crm-activity-sysbar {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--crm-bg-elevated);
  border: 1px solid var(--crm-border);
  border-radius: 6px;
  margin-bottom: 14px;
}

.crm-sysbar-item {
  font-size: 11px;
  color: var(--crm-text-dim);
  display: flex;
  align-items: center;
  gap: 5px;
}

.crm-sysbar-item i {
  font-size: 12px;
  color: var(--crm-accent-light);
  opacity: 0.7;
}

/* ── Call Timer ── */
.crm-call-timer-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: 8px;
  margin: 8px 0;
}

.crm-call-timer-label {
  font-size: 12px;
  color: var(--crm-text-dim);
  display: flex;
  align-items: center;
  gap: 6px;
}

.crm-call-timer-label i {
  color: #10b981;
}

.crm-call-timer {
  font-size: 24px;
  font-weight: 700;
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  color: #10b981;
  letter-spacing: 2px;
  animation: timerPulse 2s ease-in-out infinite;
}

@keyframes timerPulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.7;
  }
}

/* ── Larger textareas for activity modals ── */
.crm-textarea-lg {
  min-height: 140px;
  resize: vertical;
}

/* ── Previous Activity Panel ── */
.crm-prev-activity-panel {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--crm-border);
}

.crm-prev-header {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--crm-text-dim);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.crm-prev-header i {
  opacity: 0.5;
}

.crm-prev-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--crm-border);
}

.crm-prev-item:last-child {
  border-bottom: none;
}

.crm-prev-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}

.crm-prev-content {
  flex: 1;
  min-width: 0;
}

.crm-prev-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--crm-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.crm-prev-detail {
  font-size: 11px;
  color: var(--crm-text-dim);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.crm-prev-time {
  font-size: 10px;
  color: var(--crm-text-dim);
  opacity: 0.6;
  margin-top: 1px;
}

/* ── Registrar email / llamada con el historial del canal a la derecha
   (22-10-2026): dos columnas con scroll propio; el formulario a la
   izquierda y todo lo hablado por ese canal, de lo más reciente a lo más
   antiguo, a la derecha. En pantalla estrecha, una debajo de la otra. ── */
.crm-modal.crm-modal-hist {
  width: 95%;
  max-width: 1100px;
}

.crm-modal-hist .crm-modal-body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.crm-act-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  flex: 1;
  min-height: 0;
}

.crm-act-form {
  overflow-y: auto;
  min-height: 0;
  padding-right: 4px;
}

.crm-hist-col {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-left: 1px solid var(--crm-border);
  padding-left: 16px;
}

.crm-hist-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}

.crm-hist-vacio {
  font-size: 12px;
  color: var(--crm-text-dim);
  padding: 10px 0;
}

.crm-hist-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--crm-border);
}

.crm-hist-item:last-child {
  border-bottom: none;
}

.crm-hist-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.crm-hist-head .crm-prev-dot {
  margin-top: 6px;
}

.crm-hist-titulo {
  font-size: 13px;
  font-weight: 600;
  color: var(--crm-text);
  line-height: 1.35;
}

.crm-hist-meta {
  font-size: 11px;
  color: var(--crm-text-dim);
  margin: 2px 0 6px 14px;
}

.crm-hist-texto {
  font-size: 12px;
  line-height: 1.5;
  color: var(--crm-text-muted, var(--crm-text-dim));
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin-left: 14px;
}

.crm-hist-corto {
  max-height: 10.5em;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(180deg, #000 70%, transparent);
  mask-image: linear-gradient(180deg, #000 70%, transparent);
}

.crm-hist-mas {
  margin: 4px 0 0 14px;
  padding: 2px 8px;
  font-size: 11px;
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-sm);
  background: var(--crm-bg-elevated);
  color: var(--crm-accent-light);
  cursor: pointer;
}

@media (max-width: 900px) {
  .crm-modal-hist .crm-modal-body {
    overflow-y: auto;
  }

  .crm-act-grid {
    grid-template-columns: 1fr;
  }

  .crm-act-form,
  .crm-hist-list {
    overflow: visible;
  }

  .crm-hist-col {
    border-left: none;
    padding-left: 0;
    border-top: 1px solid var(--crm-border);
    padding-top: 12px;
  }
}

/* ═══════════════════════════════════════════════════════════════
   OWNER BAR & NOTIFICATION TOGGLE
   ═══════════════════════════════════════════════════════════════ */
.crm-owner-bar {
  margin-top: 8px;
}

.crm-owner-display {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid var(--crm-border);
  border-radius: 6px;
  font-size: 13px;
  color: var(--crm-text);
}

.crm-notify-toggle {
  margin-top: 10px;
  padding: 8px 0;
}

.crm-switch-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 12px;
  color: var(--crm-text-muted);
  user-select: none;
}

.crm-switch-label input[type="checkbox"] {
  display: none;
}

.crm-switch-track {
  position: relative;
  width: 36px;
  height: 20px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  transition: background 0.2s;
  flex-shrink: 0;
}

.crm-switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #cbd5e1;
  border-radius: 50%;
  transition: all 0.2s;
}

.crm-switch-label input:checked+.crm-switch-track {
  background: var(--crm-accent);
}

.crm-switch-label input:checked+.crm-switch-track .crm-switch-thumb {
  left: 18px;
  background: white;
}

/* ═══════════════════════════════════════════════════════════════
   CONTACT 360° — Timeline Filters, Pinned Notes, Changelog
   ═══════════════════════════════════════════════════════════════ */

/* Timeline Filters */
.crm-timeline-filters {
  display: flex;
  gap: 4px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.crm-tl-filter {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--crm-border);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 11px;
  color: var(--crm-text-muted);
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 4px;
}

.crm-tl-filter:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--crm-text);
}

.crm-tl-filter.active {
  background: var(--crm-accent);
  color: white;
  border-color: var(--crm-accent);
}

.crm-tl-filter i {
  font-size: 10px;
}

/* Pinned Notes */
.crm-pinned-notes {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.crm-pinned-note {
  padding: 8px 10px;
  background: rgba(99, 102, 241, 0.06);
  border-left: 3px solid var(--crm-accent);
  border-radius: 0 6px 6px 0;
}

.crm-pinned-note-text {
  font-size: 12px;
  color: var(--crm-text);
  line-height: 1.4;
}

.crm-pinned-note-meta {
  font-size: 10px;
  color: var(--crm-text-dim);
  margin-top: 4px;
}

/* Changelog */
.crm-changelog {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.crm-changelog-item {
  font-size: 11px;
  color: var(--crm-text-muted);
  padding: 4px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.02);
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.crm-changelog-item:last-child {
  border-bottom: none;
}

.crm-changelog-field {
  font-weight: 600;
  color: var(--crm-text);
}

.crm-changelog-value {
  color: var(--crm-accent-light);
  font-weight: 500;
}

.crm-changelog-time {
  margin-left: auto;
  font-size: 10px;
  color: var(--crm-text-dim);
  opacity: 0.6;
}

/* ═══════════════════════════════════════════════════════════════
   ATTACHMENT MANAGEMENT SYSTEM
   ═══════════════════════════════════════════════════════════════ */

/* Inline Preview Grid */
.crm-attach-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 8px;
}

.crm-attach-card {
  background: color-mix(in srgb, var(--crm-text) 3%, transparent);
  border: 1px solid var(--crm-border);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.15s;
}

.crm-attach-card:hover {
  background: color-mix(in srgb, var(--crm-border-light) 30%, transparent);
  border-color: var(--crm-accent);
  transform: translateY(-1px);
}

.crm-attach-preview {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--crm-bg-base);
  background-size: cover;
  background-position: center;
}

.crm-attach-name {
  font-size: 10px;
  color: var(--crm-text);
  padding: 6px 8px 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}

.crm-attach-meta {
  font-size: 9px;
  color: var(--crm-text-dim);
  padding: 0 8px 6px;
}

.crm-attach-more .crm-attach-preview {
  background: var(--crm-accent-glow);
  color: var(--crm-accent-light);
}

/* Manager Modal */
.crm-attach-manager {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.crm-attach-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--crm-border);
}

.crm-attach-count {
  font-size: 12px;
  color: var(--crm-text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.crm-attach-manager-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  max-height: 400px;
  overflow-y: auto;
}

.crm-attach-mgr-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: color-mix(in srgb, var(--crm-text) 3%, transparent);
  border: 1px solid var(--crm-border);
  border-radius: 8px;
  transition: all 0.15s;
}

.crm-attach-mgr-card:hover {
  background: color-mix(in srgb, var(--crm-border-light) 30%, transparent);
  border-color: var(--crm-border-light);
}

.crm-attach-mgr-preview {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: 6px;
  background: var(--crm-bg-base);
  display: flex;
  align-items: center;
  justify-content: center;
  background-size: cover;
  background-position: center;
}

.crm-attach-mgr-info {
  flex: 1;
  min-width: 0;
}

.crm-attach-mgr-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--crm-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.crm-attach-mgr-meta {
  font-size: 10px;
  color: var(--crm-text-dim);
  margin-top: 2px;
}

.crm-attach-mgr-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.crm-att-action {
  width: 30px;
  height: 30px;
  border: 1px solid var(--crm-border);
  border-radius: 6px;
  background: transparent;
  color: var(--crm-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  font-size: 12px;
}

.crm-att-action:hover {
  background: color-mix(in srgb, var(--crm-text) 8%, transparent);
  color: var(--crm-text);
}

.crm-att-delete:hover {
  background: color-mix(in srgb, var(--crm-danger) 15%, transparent);
  color: var(--crm-danger);
  border-color: color-mix(in srgb, var(--crm-danger) 30%, transparent);
}

.crm-attach-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: var(--crm-text-muted);
  font-size: 13px;
  grid-column: 1 / -1;
}

/* ═══════════════════════════════════════════════════════════════
   PREMIUM ACTIVITY FEED
   ═══════════════════════════════════════════════════════════════ */

/* KPI Stats Bar */
.crm-act-kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.crm-act-kpi {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--crm-border);
  border-radius: 10px;
  transition: all 0.15s;
}

.crm-act-kpi:hover {
  background: color-mix(in srgb, var(--crm-border-light) 25%, transparent);
  transform: translateY(-1px);
}

.crm-act-kpi-alert {
  border-color: rgba(239, 68, 68, 0.25);
  animation: kpiPulse 2s ease-in-out infinite;
}

@keyframes kpiPulse {

  0%,
  100% {
    box-shadow: none;
  }

  50% {
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.15);
  }
}

.crm-act-kpi-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.crm-act-kpi-val {
  font-size: 22px;
  font-weight: 800;
  color: var(--crm-text);
  line-height: 1;
}

.crm-act-kpi-label {
  font-size: 10px;
  color: var(--crm-text-dim);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Toolbar */
.crm-act-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.crm-act-search-wrap {
  flex: 1;
  min-width: 180px;
  position: relative;
}

.crm-act-search-wrap i {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--crm-text-dim);
}

.crm-act-search {
  width: 100%;
  padding: 7px 10px 7px 30px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--crm-border);
  border-radius: 8px;
  color: var(--crm-text);
  font-size: 12px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

.crm-act-search:focus {
  border-color: var(--crm-accent);
}

.crm-act-user-sel {
  padding: 7px 28px 7px 10px;
  /* --crm-card-bg NO existe (el token real es --crm-bg-card), asi que este var()
     caia SIEMPRE a su fallback rgba(15,23,42,.95): un azul casi negro fijo, que
     en tema claro se veia como un rectangulo oscuro fuera de sitio. Se usa el
     mismo fondo que .crm-act-search, su hermano de la misma barra. */
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--crm-border);
  border-radius: 8px;
  color: var(--crm-text);
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 14px;
}

.crm-act-user-sel option {
  background: var(--crm-bg-elevated);
  /* Era #e2e8f0 fijo: texto casi blanco, ilegible al desplegar en tema claro. */
  color: var(--crm-text);
  padding: 6px 10px;
}

/* ── Detalle de actividad (modal de solo lectura) ────────────── */
.crm-actdet-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 12px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--crm-border);
}

.crm-actdet-titular {
  font-size: 15px;
  font-weight: 600;
  color: var(--crm-text);
}

.crm-actdet-subject {
  font-size: 12px;
  color: var(--crm-text-muted);
  margin-top: 2px;
}

.crm-actdet-row {
  display: flex;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid var(--crm-border);
  font-size: 12px;
}

.crm-actdet-row:last-child {
  border-bottom: none;
}

.crm-actdet-label {
  flex: 0 0 130px;
  color: var(--crm-text-dim);
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.4px;
  padding-top: 2px;
}

.crm-actdet-value {
  flex: 1;
  color: var(--crm-text);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.crm-actdet-desc {
  white-space: pre-wrap;
  line-height: 1.5;
  color: var(--crm-text-muted);
}

/* ── Actividades: el cliente/lead manda en la fila ─────────────
   El titular es el cliente; el usuario que registró la actividad baja al pie
   como dato de contexto. */
.crm-act-titular {
  color: var(--crm-text);
  font-weight: 600;
}

.crm-act-titular-empty {
  color: var(--crm-text-dim);
  font-weight: 500;
  font-style: italic;
}

.crm-act-subject {
  color: var(--crm-text-muted);
  font-weight: 400;
}

.crm-act-owner {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  color: var(--crm-text-dim);
  margin-left: auto;
  padding-left: 8px;
  white-space: nowrap;
}

.crm-act-quick-btns {
  display: flex;
  gap: 4px;
}

/* Filter count badges */
.crm-act-filter-count {
  font-size: 9px;
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 6px;
  border-radius: 8px;
  margin-left: 4px;
  font-weight: 600;
}

.crm-act-filter-btn.active .crm-act-filter-count {
  background: rgba(255, 255, 255, 0.2);
}

/* Upcoming Activities Section */
.crm-act-upcoming {
  background: rgba(99, 102, 241, 0.04);
  border: 1px solid rgba(99, 102, 241, 0.12);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 16px;
}

.crm-act-upcoming-header {
  font-size: 12px;
  font-weight: 700;
  color: var(--crm-text);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.crm-act-upcoming-header i {
  color: var(--crm-accent-light);
}

.crm-act-upcoming-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.crm-act-upcoming-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.crm-act-upcoming-time {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 58px;
  padding: 6px 8px;
  border-left: 3px solid;
  border-radius: 0 6px 6px 0;
  background: rgba(0, 0, 0, 0.15);
}

.crm-act-upcoming-countdown {
  font-size: 12px;
  font-weight: 700;
  color: var(--crm-text);
}

.crm-act-upcoming-date {
  font-size: 9px;
  color: var(--crm-text-dim);
  margin-top: 2px;
}

.crm-act-upcoming-info {
  flex: 1;
  min-width: 0;
}

.crm-act-upcoming-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--crm-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.crm-act-upcoming-meta {
  font-size: 10px;
  color: var(--crm-text-dim);
  margin-top: 2px;
}

.crm-act-upcoming-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

/* Date Group Separators */
.crm-act-date-sep {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 16px 0 8px;
}

.crm-act-date-sep:first-child {
  margin-top: 0;
}

.crm-act-date-dot {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: white;
  flex-shrink: 0;
}

.crm-act-date-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--crm-text);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.crm-act-date-count {
  font-size: 10px;
  color: var(--crm-text-dim);
  background: color-mix(in srgb, var(--crm-border-light) 30%, transparent);
  padding: 1px 8px;
  border-radius: 8px;
}

.crm-act-date-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.08), transparent);
}

/* Activity footer with inline actions */
.crm-act-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
}

.crm-act-inline-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s;
}

.crm-act-item:hover .crm-act-inline-actions {
  opacity: 1;
}

.crm-act-inline-btn {
  width: 26px;
  height: 26px;
  border: 1px solid var(--crm-border);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--crm-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  transition: all 0.15s;
}

.crm-act-inline-btn:hover {
  background: var(--crm-accent);
  color: white;
  border-color: var(--crm-accent);
}

.crm-act-inline-complete:hover {
  background: #10b981;
  border-color: #10b981;
}

/* Empty State */
.crm-act-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
}

/* ═══════════════════════════════════════════════════════════════
   NEW ACTIVITY SELECTION MODAL
   ═══════════════════════════════════════════════════════════════ */

.crm-newact-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.crm-newact-step {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.crm-newact-step-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--crm-accent);
  color: white;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.crm-newact-step-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--crm-text);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.crm-newact-search-wrap {
  position: relative;
  margin-bottom: 4px;
}

.crm-newact-search-wrap i {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--crm-text-dim);
}

.crm-newact-results {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--crm-border);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.15);
}

.crm-newact-results::-webkit-scrollbar {
  width: 4px;
}

.crm-newact-results::-webkit-scrollbar-track {
  background: transparent;
}

.crm-newact-results::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

.crm-newact-group-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--crm-text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 12px 4px;
}

.crm-newact-result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  transition: all 0.1s;
  border-left: 3px solid transparent;
}

.crm-newact-result-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.crm-newact-result-item.selected {
  background: rgba(99, 102, 241, 0.08);
  border-left-color: var(--crm-accent);
}

.crm-newact-result-info {
  flex: 1;
  min-width: 0;
}

.crm-newact-result-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--crm-text);
}

.crm-newact-result-sub {
  font-size: 10px;
  color: var(--crm-text-dim);
  margin-top: 1px;
}

.crm-newact-types {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-top: 4px;
}

.crm-newact-type-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--crm-border);
  border-radius: 10px;
  color: var(--crm-text);
  cursor: pointer;
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  transition: all 0.15s;
}

.crm-newact-type-btn i {
  font-size: 18px;
}

.crm-newact-type-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.crm-newact-type-btn:not(:disabled):hover {
  background: rgba(99, 102, 241, 0.1);
  border-color: var(--crm-accent);
  transform: translateY(-2px);
}

/* ═══════════════════════════════════════════════════════════════
   PREMIUM CONTACT LIST
   ═══════════════════════════════════════════════════════════════ */

/* Contact KPIs — reuse activity KPI pattern */
.crm-ct-kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.crm-ct-kpi {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--crm-border);
  border-radius: 10px;
  transition: all 0.15s;
}

.crm-ct-kpi:hover {
  background: color-mix(in srgb, var(--crm-border-light) 25%, transparent);
  transform: translateY(-1px);
}

.crm-ct-kpi-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.crm-ct-kpi-val {
  font-size: 22px;
  font-weight: 800;
  color: var(--crm-text);
  line-height: 1;
}

.crm-ct-kpi-label {
  font-size: 10px;
  color: var(--crm-text-dim);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Sortable headers */
.crm-sortable {
  cursor: pointer;
  user-select: none;
  transition: color 0.15s;
}

.crm-sortable:hover {
  color: var(--crm-accent-light);
}

.crm-sortable i {
  margin-left: 4px;
  font-size: 10px;
  opacity: 0.5;
}

/* Selected row */
.crm-ct-selected {
  background: rgba(99, 102, 241, 0.06) !important;
}

.crm-ct-selected td:first-child {
  border-left: 3px solid var(--crm-accent);
}

/* Bulk action bar */
.crm-contacts-bulk {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(139, 92, 246, 0.08));
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 8px;
  margin-bottom: 10px;
  animation: bulkSlideIn 0.15s ease-out;
}

@keyframes bulkSlideIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.crm-bulk-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--crm-accent-light);
}

.crm-bulk-actions {
  display: flex;
  gap: 6px;
}

/* Tags */
.crm-ct-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.crm-ct-tag {
  font-size: 9px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 6px;
  white-space: nowrap;
  letter-spacing: 0.3px;
}

/* Deals column */
.crm-ct-deals {
  display: flex;
  align-items: center;
  gap: 6px;
}

.crm-ct-deal-count {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(99, 102, 241, 0.15);
  color: var(--crm-accent-light);
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.crm-ct-deal-val {
  font-size: 11px;
  color: var(--crm-text-muted);
  font-weight: 500;
}

/* Engagement bar */
.crm-ct-engagement {
  display: flex;
  align-items: center;
  gap: 6px;
}

.crm-ct-eng-bar {
  width: 40px;
  height: 5px;
  background: color-mix(in srgb, var(--crm-border-light) 30%, transparent);
  border-radius: 3px;
  overflow: hidden;
}

.crm-ct-eng-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease;
}

.crm-ct-eng-label {
  font-size: 10px;
  color: var(--crm-text-dim);
  font-weight: 600;
  min-width: 12px;
}

/* Inline actions */
.crm-ct-actions {
  display: flex;
  gap: 3px;
  opacity: 0;
  transition: opacity 0.12s;
}

.crm-contacts-table tr:hover .crm-ct-actions {
  opacity: 1;
}

.crm-ct-act-btn {
  width: 24px;
  height: 24px;
  border: 1px solid var(--crm-border);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--crm-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  transition: all 0.12s;
}

.crm-ct-act-btn:hover {
  background: var(--crm-accent);
  color: white;
  border-color: var(--crm-accent);
}

/* Contador bajo la tabla — informativo (rango / total filtrado) */
.crm-contacts-counter {
  font-size: 11px;
  color: var(--crm-text-dim);
  padding: 8px 4px 0;
  text-align: right;
}

/* Paginación canónica modelo Diario — replica del patrón de Facturación
   con prefijo .crm-* para usar variables del módulo. */
.crm-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: .8rem;
}
.crm-pg-btn {
  background: transparent;
  border: 1px solid var(--crm-border);
  color: var(--crm-text-dim);
  padding: 5px 12px;
  border-radius: 6px;
  font-size: .8rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all .12s;
  white-space: nowrap;
  font-family: inherit;
}
.crm-pg-btn:hover:not([disabled]) {
  border-color: var(--crm-accent);
  color: var(--crm-text);
  background: rgba(99, 102, 241, 0.08);
}
.crm-pg-btn[disabled] { opacity: .35; cursor: not-allowed; }
.crm-pg-info {
  color: var(--crm-text);
  font-size: .8rem;
  padding: 0 4px;
}
.crm-pg-info b {
  color: var(--crm-accent);
}
.crm-pg-size {
  padding: 4px 8px;
  border: 1px solid var(--crm-border);
  border-radius: 6px;
  background: var(--crm-bg-elevated);
  color: var(--crm-text);
  font-size: .75rem;
  cursor: pointer;
  font-family: inherit;
}

/* Checkbox styling */
.crm-contacts-table input[type="checkbox"] {
  accent-color: var(--crm-accent);
  cursor: pointer;
  width: 14px;
  height: 14px;
}

/* ═══════════════════════════════════════════════════════════════
   PREMIUM PIPELINE
   ═══════════════════════════════════════════════════════════════ */

/* Filter panel */
.crm-pl-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--crm-border);
  border-radius: 10px;
  margin-bottom: 12px;
  animation: bulkSlideIn 0.15s ease-out;
}

.crm-pl-filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 120px;
}

.crm-pl-filter-group label {
  font-size: 10px;
  color: var(--crm-text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

/* Deal rotting — red pulsing border */
.crm-deal-rotting {
  border-left: 3px solid #ef4444 !important;
  animation: dealRot 2s ease-in-out infinite;
}

@keyframes dealRot {

  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }

  50% {
    box-shadow: 0 0 8px 2px rgba(239, 68, 68, 0.15);
  }
}

/* Deal tags row (age + stale) */
.crm-deal-tags {
  display: flex;
  gap: 4px;
  padding: 2px 0;
  flex-wrap: wrap;
}

.crm-deal-age {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid;
  white-space: nowrap;
}

.crm-deal-stale {
  font-size: 9px;
  font-weight: 600;
  color: #ef4444;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(239, 68, 68, 0.1);
  white-space: nowrap;
}

/* Quick actions on deal card hover */
.crm-deal-quick-actions {
  display: flex;
  gap: 3px;
  justify-content: flex-end;
  padding-top: 4px;
  opacity: 0;
  transition: opacity 0.12s;
}

.crm-deal-card:hover .crm-deal-quick-actions {
  opacity: 1;
}

/* Weighted value in column total */
.crm-pl-weighted {
  font-size: 10px;
  color: var(--crm-text-dim);
  font-weight: 500;
}

/* Forecast footer */
.crm-pl-forecast {
  margin-top: 10px;
}

.crm-pl-forecast-bar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--crm-border);
  border-radius: 10px;
  flex-wrap: wrap;
}

.crm-pl-fc-item {
  font-size: 12px;
  color: var(--crm-text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
}

.crm-pl-fc-item i {
  font-size: 11px;
}

.crm-pl-fc-item strong {
  color: var(--crm-text);
}

.crm-pl-fc-warn {
  color: #ef4444 !important;
  font-weight: 600;
}

.crm-pl-fc-warn i {
  color: #ef4444;
}

/* ═══════════════════════════════════════════════════════════════
   PREMIUM PROJECTS
   ═══════════════════════════════════════════════════════════════ */

/* Health badge */
.crm-prj-health {
  font-size: 9px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  white-space: nowrap;
  letter-spacing: 0.3px;
}

/* Milestone timeline */
.crm-prj-milestones {
  display: flex;
  align-items: center;
  padding: 6px 0 2px;
  gap: 0;
}

.crm-prj-ms {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.crm-prj-ms-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--crm-border);
  background: transparent;
  transition: all 0.2s;
}

.crm-prj-ms.done .crm-prj-ms-dot,
.crm-prj-ms.active .crm-prj-ms-dot {
  transform: scale(1.2);
}

.crm-prj-ms.active .crm-prj-ms-dot {
  box-shadow: 0 0 6px currentColor;
}

.crm-prj-ms-label {
  font-size: 7px;
  color: var(--crm-text-dim);
  text-align: center;
  max-width: 45px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crm-prj-ms.done .crm-prj-ms-label,
.crm-prj-ms.active .crm-prj-ms-label {
  color: var(--crm-text-muted);
  font-weight: 600;
}

.crm-prj-ms-line {
  flex: 1;
  height: 2px;
  background: var(--crm-border);
  min-width: 8px;
  align-self: flex-start;
  margin-top: 6px;
}

.crm-prj-ms-line.done {
  height: 2px;
}

/* ═══════════════════════════════════════════════════════════════
   PROJECT DETAIL — Hitos / Equipo / Recursos
   Stepper estilo wizard VeriFactu adaptado a CRM (pills + dots).
   ═══════════════════════════════════════════════════════════════ */

.crm-prj-detail-sections {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 0 14px;
  margin-top: 14px;
}

/* Layout en grid del detalle del proyecto. Tres filas:
   1) Acceso | Hitos          (1fr 1fr)
   2) Equipo | Recursos       (1fr 1fr)
   3) Tareas | Documentos     (2fr 1fr)
   En pantallas estrechas (<900px) colapsa a una columna. */
.crm-prj-detail-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 0 14px;
  margin-top: 14px;
}

.crm-prj-grid-row {
  display: grid;
  gap: 14px;
}

.crm-prj-grid-2col {
  grid-template-columns: 1fr 1fr;
}

.crm-prj-grid-23 {
  grid-template-columns: 2fr 1fr;
}

.crm-prj-tasks-cell {
  /* La celda de tareas absorbe scroll horizontal si el kanban no cabe; el
     Kanban interior queda con scroll propio sin desbordar el grid. */
  overflow: hidden;
  min-width: 0;
}

.crm-prj-tasks-cell .crm-kanban-board {
  overflow-x: auto;
}

/* Anular margen externo del bloque Documentos cuando vive dentro de
   una celda del grid del detalle (la celda ya da el borde y padding). */
.crm-prj-detail-grid .crm-detail-section {
  margin-bottom: 0;
}

@media (max-width: 900px) {
  .crm-prj-grid-2col,
  .crm-prj-grid-23 {
    grid-template-columns: 1fr;
  }
}

.crm-prj-section {
  background: var(--crm-bg-elevated, rgba(255, 255, 255, 0.02));
  border: 1px solid var(--crm-border);
  border-radius: 10px;
  padding: 14px 16px;
}

.crm-prj-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.crm-prj-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--crm-text);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.crm-prj-section-title i {
  margin-right: 6px;
  color: var(--crm-accent-light);
}

.crm-prj-section-count {
  font-weight: 500;
  font-size: 11px;
  color: var(--crm-text-dim);
  margin-left: 8px;
  text-transform: none;
  letter-spacing: 0;
}

.crm-prj-empty {
  font-size: 12px;
  color: var(--crm-text-dim);
  font-style: italic;
  padding: 12px 0;
  text-align: center;
}

/* ── Stepper de hitos (estilo VeriFactu wizard) ── */

.crm-prj-stepper {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px 0;
}

.crm-prj-step {
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 20px;
  color: var(--crm-text-dim);
  background: var(--crm-bg, rgba(0, 0, 0, 0.15));
  border: 1px solid var(--crm-border);
  cursor: pointer;
  transition: all 0.3s;
  white-space: nowrap;
  user-select: none;
}

.crm-prj-step:hover {
  background: var(--crm-bg-hover, rgba(99, 102, 241, 0.1));
  border-color: var(--crm-accent-light);
  color: var(--crm-text);
}

.crm-prj-step.active {
  background: var(--crm-accent, #6366f1);
  color: #fff;
  border-color: var(--crm-accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
  animation: crmStepPulse 2s ease-in-out infinite;
}

.crm-prj-step.done {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border-color: rgba(16, 185, 129, 0.4);
}

.crm-prj-step.done i.fa-check {
  margin-right: 4px;
}

@keyframes crmStepPulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2); }
  50%      { box-shadow: 0 0 0 5px rgba(99, 102, 241, 0.35); }
}

.crm-prj-step-link {
  width: 12px;
  height: 2px;
  background: var(--crm-border);
  flex-shrink: 0;
}

.crm-prj-step-link.done {
  background: #10b981;
}

/* ── Acceso al proyecto (grupos con permiso) — Sprint 1.6 ── */

.crm-prj-acceso-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.crm-prj-acceso-row {
  display: grid;
  grid-template-columns: 28px 1fr 130px 28px;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--crm-bg, rgba(0, 0, 0, 0.1));
  border: 1px solid var(--crm-border);
  border-radius: 6px;
}

.crm-prj-acceso-toggle {
  background: transparent;
  border: 1px solid var(--crm-border);
  color: var(--crm-text-dim);
}

.crm-prj-acceso-toggle:hover {
  border-color: var(--crm-accent-light);
  color: var(--crm-text);
}

/* Sublist de usuarios del grupo (Sprint 1.6.7) */
.crm-prj-acceso-sublist {
  margin: 4px 0 8px 36px;
  border-left: 2px solid var(--crm-border);
  padding-left: 10px;
}

.crm-grupo-users-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.crm-grupo-user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  background: var(--crm-bg-elevated, rgba(255, 255, 255, 0.02));
  border: 1px solid var(--crm-border);
  border-radius: 6px;
}

.crm-user-avatar {
  flex-shrink: 0;
  border-radius: 50%;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  overflow: hidden;
}

.crm-grupo-user-info {
  flex: 1;
  min-width: 0;
}

.crm-grupo-user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--crm-text);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.crm-grupo-user-tag {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 1px 6px;
  border-radius: 8px;
}

.crm-grupo-user-contact {
  font-size: 11px;
  color: var(--crm-text-dim);
  margin-top: 2px;
}

.crm-grupo-user-contact a {
  color: var(--crm-text-muted);
  text-decoration: none;
  margin-right: 8px;
}

.crm-grupo-user-contact a:hover {
  color: var(--crm-accent-light);
  text-decoration: underline;
}

.crm-grupo-user-contact i {
  margin-right: 3px;
  width: 12px;
}

.crm-prj-acceso-grupo {
  font-size: 13px;
  color: var(--crm-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crm-prj-acceso-rol {
  font-size: 12px;
  padding: 4px 6px;
}

.crm-prj-acceso-add {
  display: grid;
  grid-template-columns: 1fr 140px;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--crm-border);
}

/* ── Equipo del proyecto ── */

.crm-prj-team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
}

.crm-prj-team-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px;
  background: var(--crm-bg, rgba(0, 0, 0, 0.1));
  border: 1px solid var(--crm-border);
  border-radius: 8px;
  transition: border-color 0.2s;
}

.crm-prj-team-card:hover {
  border-color: var(--crm-accent-light);
}

.crm-prj-team-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--crm-accent, #6366f1);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.crm-prj-team-info { flex: 1; min-width: 0; }
.crm-prj-team-name { font-weight: 600; font-size: 13px; color: var(--crm-text); }
.crm-prj-team-meta { font-size: 11px; color: var(--crm-text-dim); margin-top: 2px; }

.crm-prj-team-roles {
  display: flex;
  gap: 4px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.crm-prj-rol-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
}

.crm-prj-team-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

/* ── Multi-select de roles en modal de equipo ── */

.crm-prj-roles-multi {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.crm-prj-rol-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--crm-border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  background: var(--crm-bg);
  color: var(--crm-text);
  transition: background 0.2s;
}

.crm-prj-rol-check:hover { background: var(--crm-bg-hover, rgba(99, 102, 241, 0.08)); }
.crm-prj-rol-check input[type="checkbox"] { margin: 0; }

/* ── Recursos del proyecto ── */

.crm-prj-resources-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.crm-prj-resources-table th {
  text-align: left;
  padding: 6px 8px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--crm-text-dim);
  border-bottom: 1px solid var(--crm-border);
  font-weight: 600;
}

.crm-prj-resources-table td {
  padding: 8px;
  border-bottom: 1px solid var(--crm-border-light, rgba(255,255,255,0.05));
  color: var(--crm-text);
}

.crm-prj-resources-table tfoot td {
  border-bottom: none;
  border-top: 2px solid var(--crm-border);
  font-size: 13px;
}

.crm-prj-tipo-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(99, 102, 241, 0.1);
  color: var(--crm-accent-light);
  font-size: 10px;
  text-transform: capitalize;
}

/* Burndown bar */
.crm-prj-burndown {
  padding: 2px 0;
}

.crm-prj-bd-bar {
  display: flex;
  height: 5px;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 3px;
}

.crm-prj-bd-seg {
  height: 100%;
  transition: width 0.3s ease;
}

.crm-prj-bd-legend {
  display: flex;
  gap: 8px;
  font-size: 9px;
  color: var(--crm-text-dim);
}

.crm-prj-bd-legend span {
  display: flex;
  align-items: center;
  gap: 3px;
}

.crm-prj-bd-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

/* Budget bar */
.crm-prj-budget {
  padding: 3px 0;
}

.crm-prj-budget-bar {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.crm-prj-budget-revenue {
  height: 4px;
  background: #10b981;
  border-radius: 2px;
  transition: width 0.3s;
}

.crm-prj-budget-cost {
  height: 4px;
  background: #ef4444;
  border-radius: 2px;
  opacity: 0.5;
  transition: width 0.3s;
}

.crm-prj-budget-labels {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: var(--crm-text-dim);
  margin-top: 2px;
}

/* Risk badge */
.crm-prj-risk-badge {
  font-size: 9px;
  font-weight: 700;
  color: #f59e0b;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.crm-prj-days-left {
  font-size: 9px;
  font-weight: 600;
}

/* Status filter tabs */
.crm-prj-status-tabs {
  display: flex;
  gap: 2px;
  padding: 0 4px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--crm-border);
  align-items: center;
  flex-wrap: wrap;
}

/* Selector de orden inline a la derecha de los chips de estado del Pipeline.
   margin-left:auto lo empuja al final manteniéndose alineado con los chips. */
.crm-pl-orden-inline {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  padding: 0 6px;
}
.crm-pl-orden-label {
  color: var(--crm-text-dim);
  font-size: 11px;
  font-weight: 600;
}
.crm-pl-orden-sel {
  background: var(--crm-bg-elevated);
  border: 1px solid var(--crm-border);
  color: var(--crm-text);
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}
.crm-pl-orden-count {
  color: var(--crm-text-dim);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.crm-pl-orden-warn {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  padding: 3px 10px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 11px;
}

.crm-prj-tab {
  background: none;
  border: none;
  color: var(--crm-text-dim);
  font-size: 11px;
  font-weight: 600;
  padding: 8px 14px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 5px;
}

.crm-prj-tab:hover {
  color: var(--crm-text-muted);
  background: rgba(255, 255, 255, 0.02);
}

.crm-prj-tab.active {
  color: var(--crm-accent-light);
  border-bottom-color: var(--crm-accent);
}

.crm-prj-tab i {
  font-size: 10px;
}

/* List view table */
.crm-prj-list-table {
  animation: bulkSlideIn 0.2s ease-out;
}
/* ============================================================
   ERP Integration - Width containment
   When CRM runs inside the ERP formarea, constrain to parent
   ============================================================ */
#formarea .crm-layout {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  box-sizing: border-box;
}
#formarea .crm-main {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
}
#formarea .crm-view {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  overflow-y: auto;
}
#formarea .crm-header {
  flex-wrap: wrap;
}
#formarea .crm-dash-grid {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}
#formarea .crm-kpi-row {
  flex-wrap: wrap;
}

/* ============================================================
   Pestañas de la sección Proyectos (proyectos / empleados / recursos)
   ============================================================ */
.crm-prj-section-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 12px 0;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--crm-border);
  background: var(--crm-bg-base);
  z-index: 5;
  flex-shrink: 0;
}
.crm-prj-section-tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--crm-text-dim);
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.crm-prj-section-tab:hover {
  color: var(--crm-text);
}
.crm-prj-section-tab.active {
  color: var(--crm-accent);
  border-bottom-color: var(--crm-accent);
}

/* Cuerpo de la pestaña Proyectos: KPIs arriba + zonas existentes debajo. */
.crm-prj-tab-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
.crm-prj-tab-kpis {
  flex-shrink: 0;
  padding: 4px 16px 8px;
  border-bottom: 1px solid var(--crm-border-light, rgba(255,255,255,0.05));
}

/* Vista agregada de Empleados / Recursos por proyecto */
.crm-occ-wrap {
  padding: 12px 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.crm-occ-chart {
  background: var(--crm-bg-card);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius);
  padding: 16px;
}
.crm-occ-chart-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--crm-text);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.crm-occ-row {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 12px;
  align-items: center;
  padding: 6px 0;
}
.crm-occ-row-name {
  font-size: 12px;
  color: var(--crm-text);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.crm-occ-row-meta {
  display: block;
  font-size: 10px;
  color: var(--crm-text-dim);
  font-weight: 400;
  margin-top: 2px;
}
.crm-occ-bar-wrap {
  background: rgba(148, 163, 184, 0.12);
  border-radius: 4px;
  height: 18px;
  overflow: hidden;
  position: relative;
}
.crm-occ-bar-est {
  background: linear-gradient(90deg, #6366f1, #8b5cf6);
  height: 100%;
  border-radius: 4px;
  position: relative;
  transition: width 0.3s ease;
}
.crm-occ-bar-rec {
  background: linear-gradient(90deg, #06b6d4, #10b981);
}
.crm-occ-bar-real {
  background: rgba(255, 255, 255, 0.35);
  height: 100%;
  border-radius: 4px;
  border-right: 2px solid rgba(255, 255, 255, 0.6);
}

.crm-occ-list-wrap {
  background: var(--crm-bg-card);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius);
  padding: 12px 16px 16px;
}
.crm-occ-list-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.crm-occ-list-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--crm-text);
  display: flex;
  align-items: center;
  gap: 6px;
}
.crm-occ-search {
  flex: 1;
  max-width: 320px;
  font-size: 12px;
}
.crm-occ-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.crm-occ-card {
  background: var(--crm-bg-elevated);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-sm);
  padding: 12px 14px;
}
.crm-occ-card-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.crm-occ-card-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--crm-text);
  display: flex;
  align-items: center;
  gap: 6px;
}
.crm-occ-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 11px;
  color: var(--crm-text-dim);
}
.crm-occ-card-meta i {
  margin-right: 3px;
  color: var(--crm-accent-light);
}
.crm-occ-card-roles {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.crm-occ-card-projects {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.crm-occ-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 8px;
  background: var(--crm-bg-card);
  border: 1px solid var(--crm-border);
  border-radius: 14px;
  font-size: 11px;
  color: var(--crm-text);
  cursor: pointer;
  transition: all 0.15s ease;
}
.crm-occ-pill:hover {
  border-color: var(--crm-accent);
  transform: translateY(-1px);
}
.crm-occ-pill-meta {
  font-size: 10px;
  color: var(--crm-text-dim);
}

/* Filtro por usuario en cabecera de tareas */
.crm-task-user-filter {
  width: 200px;
  height: 30px;
  font-size: 12px;
  margin-right: 8px;
}

/* ============================================================
   Vista Gantt — timeline horizontal de proyectos
   ============================================================ */
.crm-gantt-wrap {
  padding: 8px 14px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.crm-gantt-legend {
  display: flex;
  gap: 18px;
  font-size: 11px;
  color: var(--crm-text-dim);
  align-items: center;
}
.crm-gantt-legend span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.crm-gantt-grid {
  background: var(--crm-bg-card);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius);
  overflow: hidden;
}
.crm-gantt-axis {
  position: relative;
  height: 28px;
  background: var(--crm-bg-elevated);
  border-bottom: 1px solid var(--crm-border);
  margin-left: 220px;
}
.crm-gantt-axis-tick {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(148, 163, 184, 0.18);
}
.crm-gantt-axis-label {
  position: absolute;
  top: 6px;
  left: 4px;
  font-size: 10px;
  color: var(--crm-text-dim);
  white-space: nowrap;
}
.crm-gantt-rows {
  display: flex;
  flex-direction: column;
}
.crm-gantt-row {
  display: grid;
  grid-template-columns: 220px 1fr;
  border-bottom: 1px solid var(--crm-border);
  cursor: pointer;
  transition: background 0.15s ease;
}
.crm-gantt-row:hover {
  background: rgba(99, 102, 241, 0.04);
}
.crm-gantt-row-label {
  padding: 10px 12px;
  border-right: 1px solid var(--crm-border);
  font-size: 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.crm-gantt-row-meta {
  font-size: 10px;
  color: var(--crm-text-dim);
  margin-top: 3px;
  font-weight: 400;
}
.crm-gantt-row-track {
  position: relative;
  padding: 10px 0;
  background-image: linear-gradient(to right, rgba(148, 163, 184, 0.06) 1px, transparent 1px);
  background-size: 60px 100%;
}
.crm-gantt-bar {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  height: 22px;
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  display: flex;
  align-items: center;
  padding: 0 8px;
  min-width: 18px;
}
.crm-gantt-bar-progress {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.35);
  pointer-events: none;
}
.crm-gantt-bar-label {
  position: relative;
  z-index: 1;
  font-size: 10px;
  color: white;
  white-space: nowrap;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}
.crm-gantt-today {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #ef4444;
  z-index: 5;
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.6);
}

/* =================================================================
   TELÉFONO (≤ 760 px) — CRM (dashboard, contactos, pipeline, actividades,
   proyectos, productividad y configuración), 10-11-2026
   Una sola zona de desplazamiento por vista, cabecera compacta con las
   acciones en su fila, KPIs de dos en dos, pestañas y chips deslizables,
   contactos en tarjetas, tablero por columnas con imán y paneles y
   ventanas a pantalla completa. Toque en un contacto = abrirlo
   (crm_engine.js, contactRowTap).
   ================================================================= */
@media (max-width: 760px) {
  /* ── Una sola zona de desplazamiento: la vista entera ── */
  .crm-view.crm-active {
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .crm-view.crm-active > * {
    flex-shrink: 0;
  }
  .crm-dash-scroll,
  .crm-contacts-wrap,
  .crm-contacts-table-wrap,
  .crm-actividades-wrap,
  .crm-proyectos-wrap,
  .crm-prj-tab-body,
  .crm-prj-cards-zone,
  .crm-config-body {
    flex: none;
    overflow: visible;
    min-height: 0;
  }
  /* Productividad: su caja lleva un alto en línea medido contra la ventana
     (calc(100vh - 120px)) que en el teléfono la cortaba */
  #view-productividad > div[style*="100vh"] {
    height: auto !important;
    overflow: visible !important;
    padding: 12px 16px 20px !important;
  }

  /* ── Cabecera de pantalla ── */
  .crm-header {
    flex-wrap: wrap;
    gap: 10px 12px;
    padding: 12px 16px 10px;
  }
  .crm-header-icon {
    width: 36px;
    height: 36px;
    font-size: 15px;
  }
  .crm-header-text {
    flex: 1 1 0;
    min-width: 0;
  }
  .crm-header-title {
    font-size: 1.1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .crm-header-sub {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .crm-header-actions {
    flex: 1 1 100%;
    flex-wrap: wrap;
    gap: 8px;
  }
  .crm-header-actions > .crm-btn {
    min-height: 40px;
  }
  .crm-header-actions > .crm-btn-primary,
  .crm-header-actions > .crm-btn[class*="crm-btn-success"] {
    flex: 1 1 auto;
    justify-content: center;
  }
  .crm-view-toggle .crm-toggle-btn {
    min-width: 40px;
    min-height: 40px;
  }
  #prod-period-bar {
    width: 100%;
  }
  #prod-period-bar > .crm-btn {
    flex: 1 1 0;
    justify-content: center;
    min-height: 36px;
  }

  /* ── Pestañas de estado (pipeline y proyectos): una fila deslizable; el
        selector de orden del pipeline queda en la fila de debajo ── */
  .crm-prj-status-tabs {
    display: grid;
    grid-template-columns: repeat(5, max-content);
    align-items: center;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 0 8px;
  }
  .crm-prj-status-tabs::-webkit-scrollbar {
    display: none;
  }
  .crm-prj-tab {
    min-height: 40px;
    white-space: nowrap;
    padding: 8px 12px;
  }
  .crm-prj-status-tabs > .crm-pl-orden-inline {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: start;
    padding: 4px 4px 8px;
  }
  .crm-prj-section-tabs {
    overflow-x: auto;
    scrollbar-width: none;
    padding: 6px 8px 0;
  }
  .crm-prj-section-tabs::-webkit-scrollbar {
    display: none;
  }
  .crm-prj-section-tab {
    flex: 1 0 auto;
    justify-content: center;
    white-space: nowrap;
    min-height: 42px;
    padding: 8px 10px;
  }

  /* ── KPIs: de dos en dos, cifras sin desbordar ── */
  .crm-kpi-row,
  .crm-ct-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 12px;
  }
  .crm-kpi {
    padding: 14px 12px;
    min-width: 0;
  }
  .crm-kpi-value {
    font-size: clamp(20px, 6vw, 26px);
    font-variant-numeric: tabular-nums;
    margin: 4px 0;
  }
  .crm-ct-kpi {
    padding: 10px 12px;
    min-width: 0;
  }
  .crm-ct-kpi-icon {
    width: 32px;
    height: 32px;
  }
  .crm-ct-kpi > :last-child {
    min-width: 0;
  }
  .crm-ct-kpi-val {
    font-size: clamp(16px, 4.8vw, 20px);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
  }
  .crm-act-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .crm-dash-scroll {
    padding: 12px 16px 20px;
  }

  /* ── Contactos ── */
  .crm-contacts-wrap {
    padding: 12px;
  }
  .crm-contacts-filters {
    gap: 8px;
    margin-bottom: 12px;
  }
  .crm-search {
    flex: 1 1 100%;
    max-width: none;
    min-height: 42px;
  }
  /* Tipos: una fila que reparte el ancho (en 360 px parte en dos) */
  .crm-filter-btn {
    flex: 1 1 auto;
    min-height: 36px;
    padding: 8px 6px;
    font-size: 11px;
    white-space: nowrap;
  }
  .crm-contacts-pg-inline {
    flex: 1 1 100%;
    margin-left: 0;
    justify-content: center;
    flex-wrap: wrap;
  }
  .crm-contacts-table-wrap {
    border: none;
  }
  /* La tabla de contactos (solo esta: la lista del pipeline usa la misma
     clase y sigue como tabla) pasa a tarjetas: arriba nombre y tipo, luego correo e
     importe, y los datos secundarios con su etiqueta */
  #view-contacts .crm-contacts-table,
  #view-contacts .crm-contacts-table tbody,
  #view-contacts .crm-contacts-table thead {
    display: block;
  }
  /* Cabecera = barra de orden: casilla «todos» y las tres columnas ordenables */
  #view-contacts .crm-contacts-table thead tr {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 0 0 8px;
  }
  #view-contacts .crm-contacts-table thead tr::-webkit-scrollbar {
    display: none;
  }
  #view-contacts .crm-contacts-table thead th {
    display: none;
    position: static;
  }
  #view-contacts .crm-contacts-table thead th:first-child,
  #view-contacts .crm-contacts-table thead th.crm-sortable {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
    width: auto !important;   /* vence el width:36px en línea de la casilla */
    min-height: 36px;
    padding: 0 12px;
    border: 1px solid var(--crm-border);
    border-radius: 999px;
    background: var(--crm-bg-elevated);
  }
  #view-contacts .crm-contacts-table tbody tr {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr) auto;
    grid-template-areas:
      "cb   nom  tipo"
      ".    mail deal"
      ".    orig ult"
      ".    tags eng"
      ".    acc  acc";
    gap: 6px 8px;
    align-items: center;
    padding: 12px;
    margin-bottom: 8px;
    border: 1px solid var(--crm-border);
    border-radius: var(--crm-radius-sm);
    background: var(--crm-bg-card);
  }
  #view-contacts .crm-contacts-table tbody tr.crm-ct-selected {
    border-color: var(--crm-accent);
  }
  #view-contacts .crm-contacts-table td {
    display: block;
    padding: 0;
    border: none;
    min-width: 0;
    background: none !important;
  }
  #view-contacts .crm-contacts-table td:nth-child(1) { grid-area: cb; }
  #view-contacts .crm-contacts-table td:nth-child(2) { grid-area: nom; }
  #view-contacts .crm-contacts-table td:nth-child(3) { grid-area: tipo; justify-self: end; }
  #view-contacts .crm-contacts-table td:nth-child(4) { grid-area: orig; }
  #view-contacts .crm-contacts-table td:nth-child(5) { grid-area: tags; }
  #view-contacts .crm-contacts-table td:nth-child(6) { grid-area: deal; justify-self: end; }
  #view-contacts .crm-contacts-table td:nth-child(7) { grid-area: mail; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #view-contacts .crm-contacts-table td:nth-child(8) { grid-area: ult; justify-self: end; white-space: nowrap; }
  #view-contacts .crm-contacts-table td:nth-child(9) { grid-area: eng; justify-self: end; }
  #view-contacts .crm-contacts-table td:nth-child(10) { grid-area: acc; }
  #view-contacts .crm-contacts-table td:nth-child(8)::before {
    content: "Últ. contacto ";
    color: var(--crm-text-dim);
    font-size: 10px;
  }
  #view-contacts .crm-contacts-table td:nth-child(9)::before {
    content: "Actividad";
    color: var(--crm-text-dim);
    font-size: 10px;
    margin-right: 6px;
  }
  #view-contacts .crm-contacts-table td:nth-child(9) {
    display: flex;
    align-items: center;
  }
  /* Celdas vacías («—») de origen, etiquetas e importe: sin línea en blanco */
  #view-contacts .crm-contacts-table td:nth-child(4):not(:has(span[style*="display:flex"])),
  #view-contacts .crm-contacts-table td:nth-child(5):not(:has(.crm-ct-tag)),
  #view-contacts .crm-contacts-table td:nth-child(6):not(:has(.crm-ct-deals)) {
    display: none;
  }
  .crm-contact-name > div {
    min-width: 0;
    overflow-wrap: anywhere;
  }
  /* Acciones de las filas: siempre visibles (en táctil no hay «pasar el
     ratón»); en las tarjetas de contactos, además, de 40 px */
  .crm-ct-actions {
    opacity: 1;
  }
  #view-contacts .crm-ct-actions {
    opacity: 1;
    gap: 6px;
    justify-content: flex-end;
    padding-top: 4px;
    border-top: 1px solid var(--crm-border);
  }
  #view-contacts .crm-ct-act-btn {
    width: 40px;
    height: 40px;
    font-size: 13px;
  }
  #view-contacts .crm-contacts-table input[type="checkbox"] {
    width: 18px;
    height: 18px;
  }

  /* ── Pipeline: columnas casi a lo ancho, deslizando de una en una ── */
  .crm-pipeline-wrap {
    flex: none;
    padding: 4px 12px 12px;
    overflow-y: visible;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
  }
  .crm-pipeline-board {
    height: auto;
    gap: 10px;
  }
  .crm-pipeline-col,
  .crm-kanban-col {
    width: min(84vw, 340px);
    min-width: min(84vw, 340px);
    scroll-snap-align: start;
  }
  /* Cada columna con su propio desplazamiento, a la altura de la pantalla */
  .crm-pipeline-cards {
    flex: none;
    max-height: 62vh;
  }
  .crm-deal-card {
    padding: 12px;
  }
  .crm-deal-card-header {
    gap: 8px;
  }
  .crm-deal-name {
    min-width: 0;
    overflow-wrap: anywhere;
  }
  .crm-deal-quick-actions {
    opacity: 1;
    gap: 6px;
  }
  .crm-deal-quick-actions .crm-ct-act-btn {
    width: 36px;
    height: 36px;
  }
  .crm-pl-filters {
    margin: 0 12px 12px;
  }
  .crm-pl-filter-group {
    flex: 1 1 calc(50% - 10px);
    min-width: 0;
  }
  /* Totales del pipeline: fijos al pie mientras se desplaza */
  #pipeline-forecast {
    position: sticky;
    bottom: 0;
    z-index: 4;
    margin: 0;
    padding: 6px 12px 8px;
    background: var(--crm-bg-base);
  }
  .crm-pl-forecast-bar {
    gap: 6px 14px;
    padding: 8px 12px;
  }

  /* ── Actividades ── */
  .crm-actividades-wrap {
    padding: 0 12px 20px;
  }
  .crm-act-toolbar {
    gap: 8px;
  }
  .crm-act-search-wrap {
    flex: 1 1 100%;
    min-width: 0;
  }
  .crm-act-filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    margin-bottom: 12px;
  }
  .crm-act-filters::-webkit-scrollbar {
    display: none;
  }
  .crm-act-filter-btn {
    flex: 0 0 auto;
    min-height: 36px;
    white-space: nowrap;
  }
  .crm-act-item:hover {
    transform: none;
  }
  .crm-act-inline-actions {
    opacity: 1;
  }
  .crm-act-inline-btn {
    min-width: 36px;
    min-height: 36px;
  }

  /* ── Proyectos ── */
  .crm-proyectos-wrap {
    padding: 0 12px;
  }
  .crm-prj-tab-kpis {
    padding: 4px 0 8px;
  }
  /* Cabeceras de las secciones del proyecto (Equipo, Recursos…): los
     botones bajan debajo del título cuando no caben */
  .crm-prj-section-header {
    flex-wrap: wrap;
    gap: 8px;
  }
  .crm-prj-section-header > div:last-child {
    flex-wrap: wrap;
  }
  /* Tareas del proyecto: título arriba; filtro, «Nueva tarea» y vista debajo */
  .crm-tasks-separator {
    flex-wrap: wrap;
    gap: 8px;
  }
  .crm-tasks-sep-right {
    flex: 1 1 100%;
    flex-wrap: wrap;
    min-width: 0;
  }
  .crm-task-user-filter {
    flex: 1 1 100%;
    width: auto;
    min-width: 0;
    height: 40px;
    margin-right: 0;
  }
  .crm-tasks-sep-right > .crm-btn {
    min-height: 40px;
    flex: 0 0 auto;
  }
  .crm-tasks-sep-right > .crm-view-toggle {
    margin-left: 0 !important;   /* vence el margin-left:8px en línea */
  }

  /* ── Productividad: ranking con columnas a la medida. El selector va por
        «40px 1fr 100px 80px 80px» y no por «grid-template-columns:…»: el
        onmouseover del motor reescribe el style y el navegador lo vuelve a
        serializar con espacios («grid-template-columns: 40px…») ── */
  #prod-ranking [style*="40px 1fr 100px 80px 80px"] {
    grid-template-columns: 28px minmax(0, 1fr) 60px 44px 52px !important;
    column-gap: 6px;
    padding: 10px !important;
  }
  #prod-ranking [style*="40px 1fr 100px 80px 80px"] {
    overflow-wrap: anywhere;
  }
  #prod-ranking [style*="40px 1fr 100px 80px 80px"] div {
    min-width: 0;
  }
  /* La foto no se encoge aunque el nombre parta línea */
  #prod-ranking [style*="40px 1fr 100px 80px 80px"] .crm-deal-avatar {
    flex-shrink: 0;
  }
  /* Encabezados del ranking más pequeños para que «PUNTUACIÓN» quepa */
  #prod-ranking > div > div:first-child {
    font-size: 9px !important;
    letter-spacing: 0 !important;
  }
  #prod-users {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  /* ── Configuración: pestañas en una fila deslizable ── */
  .crm-config-tabs {
    overflow-x: auto;
    scrollbar-width: none;
    padding: 0 8px;
  }
  .crm-config-tabs::-webkit-scrollbar {
    display: none;
  }
  .crm-config-tab {
    flex: 0 0 auto;
    white-space: nowrap;
    padding: 12px 14px;
    min-height: 44px;
  }
  .crm-config-body {
    padding: 16px 12px;
  }

  /* ── Panel lateral (oportunidad, contacto 360): pantalla completa ── */
  .crm-side-panel {
    width: 100%;
    border-left: none;
  }
  .crm-sp-header {
    padding: 14px 16px 12px;
  }
  .crm-sp-title {
    font-size: 1.15rem;
    overflow-wrap: anywhere;
  }
  .crm-sp-body {
    padding: 16px;
  }
  .crm-sp-actions {
    flex-wrap: wrap;
    padding: 10px 12px;
  }
  .crm-sp-actions .crm-btn {
    flex: 1 1 calc(50% - 8px);
    min-height: 40px;
  }

  /* ── Ventanas: casi a pantalla completa, campos de uno en uno ── */
  .crm-modal {
    width: calc(100vw - 16px);
    max-width: none;
  }
  .crm-modal-header {
    padding: 12px 14px;
  }
  .crm-modal-body {
    padding: 14px;
  }
  .crm-modal-footer {
    padding: 10px 14px;
    flex-wrap: wrap;
  }
  .crm-modal-footer > .crm-btn {
    min-height: 40px;
  }
  .crm-modal-row {
    flex-direction: column;
    gap: 0;
  }
}

/* ═══════════════════════════════════════════════════════════════
   FICHA 360 CON PESTAÑAS (19-11-2026)
   La vista 360 del contacto o lead y el detalle de la oportunidad, con el
   modelo de la ficha de Terceros (terceros.css: .ter-detail-tabs): ocupan la
   pantalla dentro del frame, con cabecera y pestañas. Sustituyen al panel
   lateral (.crm-side-panel), que queda solo por el marcado viejo del frame
   de Contactos hasta que la ficha lo retira.
   ═══════════════════════════════════════════════════════════════ */
.crm-view.crm-ficha-oculta {
  display: none !important;
}

.crm-ficha {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: var(--crm-bg-base);
  color: var(--crm-text);
}

.crm-ficha-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  flex-wrap: wrap;
  padding: 14px 24px 12px;
  border-bottom: 1px solid var(--crm-border);
}

.crm-ficha-head-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1 1 320px;
}

.crm-ficha-back {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: var(--crm-radius-sm);
  border: 1px solid var(--crm-border);
  background: var(--crm-bg-card);
  color: var(--crm-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.crm-ficha-back:hover {
  color: var(--crm-accent-light);
  border-color: var(--crm-accent);
}

.crm-ficha-avatar {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
  color: #fff;
}

.crm-ficha-titles {
  min-width: 0;
}

.crm-ficha-titles .crm-sp-label {
  margin-bottom: 2px;
}

.crm-ficha-title {
  font-size: 17px;
  font-weight: 800;
  line-height: 1.25;
  color: var(--crm-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crm-ficha-subtitle {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--crm-text-muted);
}

.crm-ficha-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  background: color-mix(in srgb, var(--crm-text) 6%, transparent);
  color: var(--crm-text-muted);
}

.crm-ficha-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.crm-ficha-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.crm-ficha-tabs {
  flex: 0 0 auto;
  display: flex;
  gap: 6px;
  padding: 10px 24px;
  border-bottom: 1px solid var(--crm-border);
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.crm-ficha-tabs::-webkit-scrollbar {
  display: none;
}

.crm-ficha-tab {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  color: var(--crm-text-muted);
  background: color-mix(in srgb, var(--crm-accent) 6%, transparent);
  border: 1px solid var(--crm-border);
  border-radius: var(--crm-radius-sm);
  transition: all 0.2s;
}

.crm-ficha-tab:hover {
  color: var(--crm-accent-light);
  background: color-mix(in srgb, var(--crm-accent) 12%, transparent);
  border-color: color-mix(in srgb, var(--crm-accent) 30%, transparent);
}

.crm-ficha-tab.active {
  color: #fff;
  background: var(--crm-accent);
  border-color: var(--crm-accent);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--crm-accent) 35%, transparent);
}

.crm-ficha-n {
  font-weight: 700;
  opacity: 0.75;
}

.crm-ficha-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 24px 32px;
}

.crm-ficha-pane {
  animation: crm-ficha-in 0.2s ease-out;
}

.crm-ficha-pane[hidden] {
  display: none !important;
}

/* Documentos: la base documental llena la pestaña */
.crm-ficha-pane.crm-ficha-full {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.crm-ficha-bdc {
  flex: 1 1 auto;
  min-height: 480px;
  border-radius: var(--crm-radius-sm);
  overflow: hidden;
  background: color-mix(in srgb, var(--crm-text) 3%, transparent);
}

/* Progreso del embudo: a lo ancho hay sitio para los nombres de las etapas
   (en el panel lateral solo salían al pasar el ratón) */
.crm-ficha .crm-pipeline-stage .crm-stage-label {
  opacity: 1;
  font-size: 11px;
  margin-top: 6px;
}

.crm-ficha .crm-pipeline-stage.active .crm-stage-label {
  color: var(--crm-text);
  font-weight: 700;
}

.crm-ficha .crm-pipeline-stage {
  min-width: 0;
}

/* Dos columnas en pantallas anchas (Resumen, Conversaciones) */
.crm-ficha-cols {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0 28px;
  align-items: start;
}

@keyframes crm-ficha-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 1100px) {
  .crm-ficha-cols {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 768px) {
  .crm-ficha-head {
    padding: 10px 12px;
  }
  .crm-ficha-head-left {
    flex-basis: 100%;
  }
  .crm-ficha-title {
    white-space: normal;
  }
  .crm-ficha-actions {
    width: 100%;
    justify-content: flex-start;
  }
  .crm-ficha-actions .crm-btn {
    min-height: 40px;
  }
  .crm-ficha-tabs {
    padding: 8px 12px;
  }
  .crm-ficha-tab {
    min-height: 38px;
  }
  .crm-ficha-body {
    padding: 14px 12px 24px;
  }
  .crm-ficha-bdc {
    min-height: 420px;
  }
  /* En el teléfono no caben los nombres de todas las etapas: solo el de la actual */
  .crm-ficha .crm-pipeline-stage:not(.active) .crm-stage-label {
    visibility: hidden;
  }
  .crm-ficha .crm-pipeline-stage.active .crm-stage-label {
    overflow: visible;
    text-align: left;
  }
}
