/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', system-ui, sans-serif; background: #f4f7fb; color: #1a2340; display: flex; min-height: 100vh; }

/* ===== SIDEBAR ===== */
.sidebar {
  width: 230px; min-height: 100vh; background: #ffffff;
  display: flex; flex-direction: column; padding: 24px 0;
  position: fixed; left: 0; top: 0; z-index: 100;
  border-right: 1px solid #e8edf5;
  box-shadow: 2px 0 12px rgba(0,0,0,0.06);
}
.logo { display: flex; align-items: center; gap: 12px; padding: 0 20px 24px; border-bottom: 1px solid #eef1f7; }
.logo-icon { font-size: 24px; }
.logo-text { color: #1a2340; font-size: 16px; font-weight: 800; letter-spacing: 0.3px; }

/* PROFILE CARD */
.profile-card {
  display: flex; flex-direction: column; align-items: center;
  padding: 20px 16px; border-bottom: 1px solid #eef1f7; text-align: center;
}
.profile-avatar {
  width: 72px; height: 72px; border-radius: 50%; object-fit: cover;
  border: 3px solid #c9a84c; margin-bottom: 10px;
  box-shadow: 0 4px 12px rgba(201,168,76,0.3);
}
.profile-name { font-size: 14px; font-weight: 700; color: #1a2340; }
.profile-title { font-size: 11px; color: #8a9bbf; margin-top: 2px; }
.profile-phone { font-size: 12px; color: #c9a84c; font-weight: 600; margin-top: 4px; }

nav { display: flex; flex-direction: column; padding-top: 12px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 20px; color: #8a9bbf; text-decoration: none;
  font-size: 13px; font-weight: 500; transition: all 0.2s; cursor: pointer;
  margin: 2px 10px; border-radius: 8px;
}
.nav-item:hover { background: #f0f4ff; color: #1a2340; }
.nav-item.active { background: #eef2ff; color: #2b52d4; border-left: 3px solid #c9a84c; font-weight: 700; }
.nav-icon { font-size: 16px; }

/* ===== MAIN ===== */
.main { margin-left: 220px; flex: 1; display: flex; flex-direction: column; min-height: 100vh; }

/* ===== TOPBAR ===== */
.topbar {
  background: #fff; padding: 16px 28px; display: flex;
  align-items: center; justify-content: space-between;
  border-bottom: 1px solid #e8eaf0; position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-size: 20px; font-weight: 700; color: #1a1a2e; }

/* ===== SECTIONS ===== */
.section { display: none; padding: 28px; flex-direction: column; gap: 20px; }
.section.active { display: flex; }

/* ===== STATS ===== */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stat-card {
  border-radius: 14px; padding: 22px 20px;
  display: flex; flex-direction: column; gap: 4px;
  background: #fff; border: 1px solid #e8edf5;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.stat-card.blue   { border-top: 4px solid #2b52d4; }
.stat-card.green  { border-top: 4px solid #0aaf6e; }
.stat-card.orange { border-top: 4px solid #c9a84c; }
.stat-card.purple { border-top: 4px solid #7c4ddb; }
.stat-label { font-size: 13px; color: #8a9bbf; font-weight: 600; }
.stat-value { font-size: 38px; font-weight: 800; line-height: 1; color: #1a2340; }
.stat-sub { font-size: 12px; color: #aab4cc; }

/* ===== CARDS ===== */
.card { background: #fff; border-radius: 14px; padding: 20px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.card-title { font-size: 16px; font-weight: 700; margin-bottom: 14px; color: #1a1a2e; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.filters { display: flex; gap: 10px; align-items: center; }
.dash-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.dash-half {}

/* ===== TABLE ===== */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { background: #f8f9fc; padding: 10px 12px; text-align: left; font-weight: 600; color: #555; border-bottom: 2px solid #eee; }
.table td { padding: 10px 12px; border-bottom: 1px solid #f0f0f0; color: #333; vertical-align: middle; }
.table tr:hover td { background: #fafbff; }
.empty { text-align: center; color: #aaa; font-style: italic; padding: 24px !important; }

/* ===== BADGES ===== */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
}
.badge-nuevo       { background: #e8f4fd; color: #1a7fc4; }
.badge-contactado  { background: #fff3e0; color: #e65100; }
.badge-cita        { background: #e8f5e9; color: #2e7d32; }
.badge-negociacion { background: #f3e5f5; color: #7b1fa2; }
.badge-cerrado     { background: #e0f2f1; color: #00695c; }
.badge-perdido     { background: #fce4ec; color: #c62828; }

.interest-badge {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 600; background: #ede7f6; color: #4527a0;
}

/* ===== BUTTONS ===== */
.btn-primary {
  background: linear-gradient(135deg, #2b52d4, #1a3aaa); color: #fff;
  border: none; border-radius: 8px; padding: 9px 20px;
  font-size: 14px; font-weight: 600; cursor: pointer; transition: opacity 0.2s;
  text-decoration: none;
}
.btn-primary:hover { opacity: 0.88; }
.btn-secondary {
  background: #f0f0f0; color: #333; border: none; border-radius: 8px;
  padding: 9px 20px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.btn-danger { background: #fce4ec; color: #c62828; border: none; border-radius: 6px; padding: 5px 10px; font-size: 12px; cursor: pointer; }
.btn-sm { background: #ede7f6; color: #4527a0; border: none; border-radius: 6px; padding: 5px 10px; font-size: 12px; cursor: pointer; }

/* ===== INPUTS ===== */
input, select, textarea {
  width: 100%; border: 1.5px solid #e0e0e0; border-radius: 8px;
  padding: 9px 12px; font-size: 14px; color: #333; background: #fafafa;
  transition: border 0.2s; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: #6c63ff; background: #fff; }
textarea { resize: vertical; min-height: 80px; }
.input-sm { width: auto; padding: 7px 10px; font-size: 13px; }

/* ===== FORM ===== */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 13px; font-weight: 600; color: #444; }
.full-width { grid-column: 1 / -1; }

/* ===== MODAL ===== */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  z-index: 1000; align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff; border-radius: 16px; width: 90%; max-width: 560px;
  max-height: 90vh; overflow-y: auto; padding: 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.modal-wide { max-width: 720px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-header h2 { font-size: 18px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 24px; cursor: pointer; color: #999; line-height: 1; }
.modal-footer { display: flex; gap: 12px; justify-content: flex-end; margin-top: 20px; padding-top: 16px; border-top: 1px solid #eee; }

/* ===== PIPELINE ===== */
.pipeline-board {
  display: flex; gap: 16px; overflow-x: auto; padding: 4px;
  align-items: flex-start; min-height: 60vh;
}
.pipeline-col {
  min-width: 200px; max-width: 220px; flex-shrink: 0;
  background: #f8f9fc; border-radius: 12px; padding: 14px;
}
.pipeline-col-title {
  font-size: 13px; font-weight: 700; margin-bottom: 12px;
  display: flex; align-items: center; justify-content: space-between;
}
.pipeline-count {
  background: #e0e0e0; color: #555; border-radius: 10px;
  padding: 2px 8px; font-size: 11px;
}
.pipeline-card {
  background: #fff; border-radius: 10px; padding: 12px;
  margin-bottom: 10px; box-shadow: 0 2px 6px rgba(0,0,0,0.06);
  cursor: pointer; transition: transform 0.15s, box-shadow 0.15s;
}
.pipeline-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.pipeline-card-name { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.pipeline-card-meta { font-size: 12px; color: #888; }
.pipeline-card-budget { font-size: 12px; color: #6c63ff; font-weight: 600; margin-top: 6px; }

/* ===== FUNNEL ===== */
.funnel { display: flex; flex-direction: column; gap: 8px; padding: 8px 0; }
.funnel-row { display: flex; align-items: center; gap: 10px; }
.funnel-label { font-size: 12px; color: #555; width: 90px; text-align: right; }
.funnel-bar-wrap { flex: 1; background: #f0f0f0; border-radius: 6px; height: 22px; overflow: hidden; }
.funnel-bar { height: 100%; border-radius: 6px; transition: width 0.5s ease; display: flex; align-items: center; padding-left: 8px; font-size: 11px; color: #fff; font-weight: 700; }
.funnel-count { font-size: 12px; font-weight: 700; color: #333; width: 24px; }

/* ===== FOLLOW-UP ===== */
.followup-list { display: flex; flex-direction: column; gap: 10px; }
.followup-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; background: #fff8e1; border-radius: 10px;
  border-left: 4px solid #ffc107;
}
.followup-item.overdue { background: #fce4ec; border-left-color: #e91e63; }
.followup-name { font-weight: 600; font-size: 14px; }
.followup-date { font-size: 12px; color: #888; }

/* ===== TEMPLATES ===== */
.templates-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.template-card { background: #f8f9fc; border-radius: 10px; padding: 16px; }
.template-title { font-weight: 700; font-size: 14px; margin-bottom: 8px; color: #4527a0; }
.template-body { font-size: 13px; color: #555; line-height: 1.5; white-space: pre-wrap; }
.template-copy { margin-top: 10px; background: #ede7f6; color: #4527a0; border: none; border-radius: 6px; padding: 6px 14px; font-size: 12px; cursor: pointer; font-weight: 600; }

/* ===== LEAD DETAIL ===== */
.lead-detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.lead-detail-item label { font-size: 12px; color: #888; display: block; margin-bottom: 3px; }
.lead-detail-item span { font-size: 14px; font-weight: 600; }
.notes-box { background: #f8f9fc; border-radius: 8px; padding: 12px; font-size: 13px; color: #555; line-height: 1.5; margin-top: 8px; }
.history-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.history-item { font-size: 13px; color: #555; padding: 8px 12px; background: #f8f9fc; border-radius: 8px; }
.history-date { font-size: 11px; color: #aaa; }

/* ===== TOAST ===== */
.toast {
  position: fixed; bottom: 28px; right: 28px; background: #1a1a2e; color: #fff;
  padding: 12px 22px; border-radius: 10px; font-size: 14px; font-weight: 500;
  opacity: 0; transform: translateY(10px); transition: all 0.3s; z-index: 9999;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ===== TEXT UTILS ===== */
.text-muted { color: #888; font-size: 13px; margin-bottom: 10px; }

/* ===== FOLLOWUP CALENDAR ===== */
.calendar-grid { display: flex; flex-direction: column; gap: 8px; }
.calendar-day { padding: 12px 14px; background: #f8f9fc; border-radius: 10px; }
.calendar-day-title { font-weight: 700; font-size: 13px; margin-bottom: 8px; color: #1a1a2e; }
.calendar-lead { font-size: 13px; color: #555; padding: 5px 0; border-bottom: 1px solid #eee; display: flex; justify-content: space-between; }

/* ===== QUICK APPS BAR ===== */
.quick-apps {
  display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px;
}
.quick-app {
  display: flex; flex-direction: row; align-items: center; gap: 12px;
  background: #fff; border: 1px solid #e8edf5; border-radius: 10px;
  padding: 11px 16px; text-decoration: none; color: #1a2340;
  font-size: 13px; font-weight: 600; transition: all 0.2s;
  box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}
.quick-app span:first-child { font-size: 20px; }
.quick-app:hover { background: #eef2ff; border-color: #c9a84c; transform: translateX(3px); box-shadow: 0 4px 12px rgba(0,0,0,0.08); }

/* ===== APPS SECTION ===== */
.apps-section {
  margin-top: auto; padding: 16px 12px 20px;
  border-top: 1px solid #eef1f7;
}
.apps-title {
  font-size: 11px; font-weight: 700; color: #aab4cc;
  text-transform: uppercase; letter-spacing: 1px;
  padding: 0 8px; margin-bottom: 8px;
}
.app-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px; text-decoration: none;
  color: #555e7a; font-size: 13px; font-weight: 500;
  transition: all 0.2s; margin-bottom: 2px;
}
.app-link:hover { background: #f0f4ff; color: #2b52d4; }
.app-icon { font-size: 15px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-row { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .sidebar { width: 64px; }
  .logo-text, .nav-item span:last-child { display: none; }
  .main { margin-left: 64px; }
}
