:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #1c2530;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --green: #16a34a;
  --red: #dc2626;
  --orange: #ea580c;
  --purple: #7c3aed;
  --teal: #0d9488;
  --gray: #64748b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 24px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  font-weight: 700;
  font-size: 18px;
  color: var(--primary-dark);
}
.brand span {
  font-weight: 400;
  color: var(--muted);
  font-size: 14px;
  margin-left: 6px;
}

.tabs { display: flex; gap: 4px; flex: 1; }
.tab-btn {
  border: none;
  background: transparent;
  padding: 10px 16px;
  cursor: pointer;
  font-size: 14px;
  color: var(--muted);
  border-radius: 8px;
  font-weight: 600;
}
.tab-btn:hover { background: #eef2ff; }
.tab-btn.active { background: var(--primary); color: white; }

.asesor-select { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.asesor-select select { padding: 6px 8px; border-radius: 6px; border: 1px solid var(--border); }

main#app { padding: 24px; max-width: 1400px; margin: 0 auto; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}

.toolbar input, .toolbar select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: white;
}

button.primary {
  background: var(--primary);
  color: white;
  border: none;
  padding: 9px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
}
button.primary:hover { background: var(--primary-dark); }

button.secondary {
  background: white;
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
}
button.secondary:hover { background: #f1f5f9; }

button.danger { background: var(--red); color: white; border: none; padding: 6px 10px; border-radius: 6px; cursor: pointer; font-size: 12px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  margin-bottom: 18px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: var(--card);
}
th, td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
th {
  background: #f8fafc;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.03em;
}
tr:hover td { background: #f8fafc; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  color: white;
  white-space: nowrap;
  background: var(--gray);
}
.badge-CHAT { background: var(--gray); }
.badge-LLAMADA { background: var(--primary); }
.badge-VIDEOLLAMADA { background: var(--purple); }
.badge-PRUEBA_CALIDAD { background: var(--teal); }
.badge-REMARKETING { background: var(--orange); }
.badge-CONTRATADO { background: var(--green); }
.badge-NO_CONTRATADO { background: var(--red); }
.badge-DESCARTADO { background: #334155; }
.badge-ALTA { background: var(--green); }
.badge-MEDIA { background: #d97706; }
.badge-BAJA { background: var(--red); }
.badge-GANADO { background: var(--green); }
.badge-DESCARTADA { background: #334155; }

.score-bar-wrap { width: 60px; height: 6px; background: #e2e8f0; border-radius: 3px; overflow: hidden; display: inline-block; vertical-align: middle; margin-left: 6px; }
.score-bar-fill { height: 100%; border-radius: 3px; }
.factor-item { display: flex; justify-content: space-between; font-size: 12px; padding: 4px 0; border-bottom: 1px dashed var(--border); }
.factor-item .pts-pos { color: var(--green); font-weight: 700; }
.factor-item .pts-neg { color: var(--red); font-weight: 700; }

.pill { font-size: 11px; padding: 2px 8px; border-radius: 6px; background: #f1f5f9; color: var(--muted); }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,0.5);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal {
  background: white; border-radius: 12px; padding: 24px;
  width: 520px; max-width: 92vw; max-height: 88vh; overflow-y: auto;
}
.modal h2 { margin-top: 0; font-size: 18px; }
.modal label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin: 12px 0 4px; }
.modal input, .modal select, .modal textarea {
  width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; font-family: inherit;
}
.modal textarea { min-height: 70px; resize: vertical; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.modal-close { position: absolute; top: 16px; right: 20px; cursor: pointer; color: var(--muted); font-size: 20px; background: none; border: none; }
.modal { position: relative; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 16px;
}
.stat-card .value { font-size: 26px; font-weight: 700; color: var(--primary-dark); }
.stat-card .label { font-size: 12px; color: var(--muted); margin-top: 4px; }

.funnel { display: flex; flex-direction: column; gap: 8px; }
.funnel-row { display: flex; align-items: center; gap: 10px; }
.funnel-label { width: 220px; font-size: 13px; color: var(--text); }
.funnel-bar-wrap { flex: 1; background: #eef2f7; border-radius: 6px; overflow: hidden; height: 22px; }
.funnel-bar { height: 100%; background: linear-gradient(90deg, var(--primary), #60a5fa); border-radius: 6px; display: flex; align-items: center; justify-content: flex-end; padding-right: 8px; color: white; font-size: 11px; font-weight: 700; }
.funnel-n { width: 44px; text-align: right; font-size: 12px; font-weight: 700; color: var(--muted); }

.chart-row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 900px) { .chart-row { grid-template-columns: 1fr; } }

.bar-chart { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.bar-row .bar-label { width: 140px; color: var(--muted); }
.bar-row .bar-track { flex: 1; background: #eef2f7; border-radius: 4px; height: 16px; overflow: hidden; }
.bar-row .bar-fill { height: 100%; border-radius: 4px; background: var(--teal); }
.bar-row .bar-value { width: 36px; text-align: right; font-weight: 700; }

.section-title { font-size: 15px; font-weight: 700; margin: 0 0 12px; }

.empty-state { text-align: center; padding: 40px; color: var(--muted); }

.overdue { color: var(--red); font-weight: 700; }
.today { color: var(--orange); font-weight: 700; }

.actuacion-item { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.actuacion-item .meta { font-size: 11px; color: var(--muted); }

.filters { display: flex; gap: 8px; flex-wrap: wrap; }

.kanban-board {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(240px, 1fr);
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 8px;
  align-items: start;
}
.kanban-col {
  background: #eef1f6;
  border-radius: 10px;
  padding: 10px;
  min-height: 200px;
  transition: background 0.15s;
}
.kanban-col.drag-over { background: #dbe4f3; }
.kanban-col-header {
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.kanban-col-body { display: flex; flex-direction: column; gap: 10px; min-height: 60px; }
.kanban-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  cursor: grab;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.kanban-card:active { cursor: grabbing; }
.kanban-card.dragging { opacity: 0.4; }
.kanban-card-title { font-weight: 700; font-size: 13px; margin-bottom: 4px; }
.kanban-card-meta { font-size: 11px; color: var(--muted); margin-bottom: 4px; }

.calendar { background: var(--card); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}
.cal-weekdays div { padding: 8px; text-align: center; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); grid-auto-rows: minmax(90px, auto); }
.cal-cell { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 6px; overflow-y: auto; }
.cal-cell:nth-child(7n) { border-right: none; }
.cal-cell-out { background: #fafbfc; color: var(--muted); }
.cal-cell-out .cal-cell-num { color: #cbd5e1; }
.cal-cell-today { background: #eff6ff; }
.cal-cell-num { font-size: 12px; font-weight: 700; margin-bottom: 4px; }
.cal-cell-events { display: flex; flex-direction: column; gap: 3px; }
.cal-event {
  background: var(--primary);
  color: white;
  border-radius: 4px;
  padding: 2px 5px;
  font-size: 10.5px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-event:hover { background: var(--primary-dark); }
.cal-event-done { background: var(--green); text-decoration: line-through; opacity: 0.75; }
.cal-meet-link { display: block; font-size: 10px; color: var(--teal); text-decoration: underline; margin: -2px 0 3px 2px; }

.contacto-resaltado { font-weight: 700; }
.cita-badge { display: inline-block; margin-top: 3px; padding: 1px 7px; border-radius: 5px; font-size: 10.5px; font-weight: 700; }
.cita-badge.cita-hoy { background: #fef3c7; color: #92400e; }
.cita-badge.cita-proxima { background: #dbeafe; color: #1e40af; }
.cita-badge.cita-vencida { background: #fee2e2; color: #991b1b; }
