/* ============================================================
   CRM PROFESIONAL — Design System
   Fonts: Syne (headings) + DM Sans (body)
   ============================================================ */

:root {
  /* Brand */
  --brand:       #6366f1;
  --brand-dark:  #4f46e5;
  --brand-light: #eef2ff;
  --brand-glow:  rgba(99,102,241,0.15);

  /* Neutrals */
  --bg:          #f8fafc;
  --surface:     #ffffff;
  --surface2:    #f1f5f9;
  --border:      #e2e8f0;
  --border2:     #cbd5e1;

  /* Text */
  --text:        #0f172a;
  --text-2:      #475569;
  --text-3:      #94a3b8;
  --text-inv:    #ffffff;

  /* Semantic */
  --green:       #10b981;
  --green-bg:    #d1fae5;
  --red:         #ef4444;
  --red-bg:      #fee2e2;
  --amber:       #f59e0b;
  --amber-bg:    #fef3c7;
  --blue:        #3b82f6;
  --blue-bg:     #dbeafe;
  --purple:      #8b5cf6;
  --purple-bg:   #ede9fe;
  --teal:        #14b8a6;

  /* Sidebar */
  --sidebar-w:   240px;
  --sidebar-bg:  #0f172a;
  --sidebar-text:#94a3b8;
  --sidebar-hover: rgba(99,102,241,0.12);
  --sidebar-active: #6366f1;

  /* Topbar */
  --topbar-h:    60px;

  /* Radius / Shadow */
  --radius:      10px;
  --radius-sm:   6px;
  --radius-lg:   16px;
  --shadow:      0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md:   0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg:   0 20px 40px rgba(0,0,0,0.12);

  --transition:  all .18s cubic-bezier(.4,0,.2,1);
}

/* ===== DARK MODE ===== */
[data-theme="dark"] {
  --bg:          #0f172a;
  --surface:     #1e293b;
  --surface2:    #0f172a;
  --border:      #334155;
  --border2:     #475569;
  --text:        #f1f5f9;
  --text-2:      #94a3b8;
  --text-3:      #64748b;
  --sidebar-bg:  #020617;
  --shadow:      0 1px 3px rgba(0,0,0,0.3);
  --shadow-md:   0 4px 12px rgba(0,0,0,0.4);
  --brand-light: rgba(99,102,241,0.15);
}

/* Dark mode: tabla hover con texto visible */
[data-theme="dark"] .data-table tbody tr:hover {
  background: rgba(99,102,241,0.12);
  color: var(--text);
}
[data-theme="dark"] .data-table tbody tr:hover td,
[data-theme="dark"] .data-table tbody tr:hover td * {
  color: var(--text);
}
[data-theme="dark"] .data-table tbody tr:hover .empresa-sector,
[data-theme="dark"] .data-table tbody tr:hover .text-muted,
[data-theme="dark"] .data-table tbody tr:hover small {
  color: var(--text-2) !important;
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
input, select, textarea, button { font-family: inherit; font-size: 14px; }
img { max-width: 100%; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* ============================================================
   LAYOUT
   ============================================================ */

.sidebar {
  position: fixed; top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  z-index: 200;
  transition: width .25s cubic-bezier(.4,0,.2,1);
  overflow: hidden;
}

.main-content {
  margin-left: var(--sidebar-w);
  margin-top: var(--topbar-h);
  min-height: calc(100vh - var(--topbar-h));
  padding: 28px 32px;
  transition: margin-left .25s cubic-bezier(.4,0,.2,1);
}

/* Sidebar brand */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  white-space: nowrap;
  overflow: hidden;
}

.brand-icon {
  width: 34px; height: 34px;
  background: var(--brand);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 16px;
  flex-shrink: 0;
}

.brand-name {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 15px;
  color: #f1f5f9;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-toggle-btn {
  background: none; border: none;
  color: var(--sidebar-text);
  cursor: pointer; font-size: 16px;
  padding: 4px;
  border-radius: 6px;
  transition: var(--transition);
  flex-shrink: 0;
}
.sidebar-toggle-btn:hover { background: rgba(255,255,255,.1); color: white; }

/* Nav */
.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; overflow-x: hidden; }

.nav-section { margin-bottom: 24px; }

.nav-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(148,163,184,.5);
  padding: 0 8px 8px;
  white-space: nowrap;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--sidebar-text);
  margin-bottom: 2px;
  transition: var(--transition);
  white-space: nowrap;
  text-decoration: none;
}

.nav-item i { font-size: 17px; flex-shrink: 0; }
.nav-item span { flex: 1; font-weight: 500; }

.nav-item:hover { background: var(--sidebar-hover); color: #e2e8f0; text-decoration: none; }
.nav-item.active { background: var(--brand); color: white; }
.nav-item.active i, .nav-item.active span { color: white; }

.nav-badge {
  background: var(--brand);
  color: white;
  font-size: 11px; font-weight: 700;
  padding: 1px 7px;
  border-radius: 20px;
  font-style: normal;
}
.nav-badge-warn { background: var(--amber); }

/* Sidebar footer */
.sidebar-footer {
  padding: 14px;
  border-top: 1px solid rgba(255,255,255,.06);
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
  background: rgba(255,255,255,.05);
}

.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--brand);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
  flex-shrink: 0;
}

.user-info {
  flex: 1; overflow: hidden;
}
.user-info strong { display: block; color: #e2e8f0; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-info span { color: var(--sidebar-text); font-size: 11px; }

.logout-btn {
  color: rgba(148,163,184,.7);
  font-size: 16px;
  padding: 4px;
  border-radius: 6px;
  transition: var(--transition);
  flex-shrink: 0;
}
.logout-btn:hover { color: var(--red); background: rgba(239,68,68,.1); text-decoration: none; }

/* ===== TOPBAR ===== */
.topbar {
  position: fixed;
  top: 0; left: var(--sidebar-w); right: 0;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  z-index: 100;
  transition: left .25s;
}

.topbar-menu-btn {
  display: none;
  background: none; border: none;
  font-size: 20px; cursor: pointer;
  color: var(--text-2);
  padding: 6px;
  border-radius: 6px;
}

.global-search {
  flex: 1;
  max-width: 420px;
  position: relative;
}

.global-search > i {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  font-size: 15px;
}

.global-search input {
  width: 100%;
  padding: 9px 14px 9px 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface2);
  color: var(--text);
  transition: var(--transition);
  outline: none;
}

.global-search input:focus {
  border-color: var(--brand);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--brand-glow);
}

.search-results {
  position: absolute;
  top: calc(100% + 6px); left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  display: none;
  z-index: 1000;
  max-height: 320px;
  overflow-y: auto;
}

.search-result-item {
  padding: 10px 14px;
  cursor: pointer;
  display: flex; align-items: center; gap: 10px;
  transition: var(--transition);
  border-bottom: 1px solid var(--border);
}
.search-result-item:last-child { border: none; }
.search-result-item:hover { background: var(--surface2); }

.topbar-actions { display: flex; align-items: center; gap: 10px; }

.topbar-btn {
  background: none; border: none;
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; cursor: pointer;
  color: var(--text-2);
  transition: var(--transition);
}
.topbar-btn:hover { background: var(--surface2); color: var(--text); }

.btn-new-topbar {
  display: flex; align-items: center; gap: 6px;
  background: var(--brand);
  color: white;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  transition: var(--transition);
  text-decoration: none;
}
.btn-new-topbar:hover { background: var(--brand-dark); text-decoration: none; color: white; }

/* Overlay mobile */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 199;
}

/* ============================================================
   COMPONENTS
   ============================================================ */

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}

.card-header h3 {
  font-family: 'Syne', sans-serif;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  display: flex; align-items: center; gap: 8px;
}

.card-body { padding: 20px; }

.mb-card { margin-bottom: 20px; }
.mt-card { margin-top: 20px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600; font-size: 13px;
  cursor: pointer; border: none;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary { background: var(--brand); color: white; }
.btn-primary:hover { background: var(--brand-dark); color: white; text-decoration: none; }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border2);
  color: var(--text-2);
}
.btn-outline:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }

.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface2); color: var(--text); text-decoration: none; }

.btn-danger { background: var(--red); color: white; }
.btn-danger:hover { background: #dc2626; text-decoration: none; color: white; }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 11px 24px; font-size: 15px; }
.btn-full { width: 100%; justify-content: center; }
.btn-link { background: none; border: none; color: var(--brand); cursor: pointer; font-size: 13px; padding: 0; }

.btn-icon {
  width: 32px; height: 32px;
  border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-2);
  cursor: pointer; font-size: 15px;
  transition: var(--transition);
}
.btn-icon:hover { background: var(--brand-light); color: var(--brand); border-color: var(--brand); }
.btn-icon-danger:hover { background: var(--red-bg); color: var(--red); border-color: var(--red); }

/* Forms */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field label { font-weight: 600; font-size: 13px; color: var(--text-2); }
.form-field.required label::after { content: ' *'; color: var(--red); }

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: var(--transition);
  outline: none;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-glow);
}

.form-input::placeholder, .form-textarea::placeholder { color: var(--text-3); }

.form-textarea { resize: vertical; min-height: 80px; }
.form-range { width: 100%; accent-color: var(--brand); }

.form-input-sm, .form-select-sm {
  padding: 7px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  outline: none;
  font-size: 13px;
  transition: var(--transition);
}
.form-input-sm:focus, .form-select-sm:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-glow); }

.form-actions {
  display: flex; gap: 10px; flex-wrap: wrap;
  padding-top: 8px;
}

.label-check {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; font-weight: 500; color: var(--text-2);
}

/* Avatars */
.avatar-sm {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--brand);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; flex-shrink: 0;
}
.avatar-xs {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--brand);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; flex-shrink: 0;
}

/* Badges */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px; font-weight: 700;
  background: var(--surface2);
  color: var(--text-2);
}
.badge-green { background: var(--green-bg); color: #065f46; }
.badge-red { background: var(--red-bg); color: #991b1b; }
.badge-amber { background: var(--amber-bg); color: #92400e; }
.badge-blue { background: var(--blue-bg); color: #1e40af; }
.badge-purple { background: var(--purple-bg); color: #5b21b6; }

.badge-priority-baja { background: #d1fae5; color: #065f46; }
.badge-priority-media { background: #fef3c7; color: #92400e; }
.badge-priority-alta { background: #fed7aa; color: #9a3412; }
.badge-priority-urgente { background: var(--red-bg); color: #991b1b; }

/* Status pill */
.status-pill {
  display: inline-flex; align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px; font-weight: 600;
}

/* Modals */
.modal {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.6);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fadeIn .15s ease;
}

.modal-box {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp .2s ease;
}

.modal-sm { max-width: 420px; }

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}

.modal-header h3 {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 17px;
  display: flex; align-items: center; gap: 8px;
}

.modal-close {
  background: none; border: none;
  width: 32px; height: 32px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; cursor: pointer;
  color: var(--text-3);
  transition: var(--transition);
}
.modal-close:hover { background: var(--surface2); color: var(--text); }

.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* Toast messages */
.toast-msg {
  position: fixed;
  top: 80px; right: 24px;
  padding: 14px 20px;
  border-radius: 10px;
  display: flex; align-items: center; gap: 10px;
  font-weight: 600;
  z-index: 99999;
  box-shadow: var(--shadow-md);
  animation: slideInRight .3s ease;
  max-width: 380px;
}

.toast-success { background: var(--green); color: white; }
.toast-error { background: var(--red); color: white; }

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Data table */
.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table th {
  padding: 12px 16px;
  background: var(--surface2);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--text-2);
  text-align: left;
  white-space: nowrap;
}
.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr:hover { background: var(--brand-light); }
.data-table tbody tr:last-child td { border-bottom: none; }

.sortable { cursor: pointer; user-select: none; }
.sortable:hover { color: var(--brand); }

.row-actions { display: flex; gap: 6px; }

.cell-company { display: flex; align-items: center; gap: 12px; }
.company-initial {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 15px;
  flex-shrink: 0;
}
.cell-user { display: flex; align-items: center; gap: 8px; }

/* Filters bar */
.filters-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}
.filters-left { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-count { color: var(--text-3); font-size: 13px; }

/* Page header */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap; gap: 12px;
}

.page-title {
  font-family: 'Syne', sans-serif;
  font-size: 24px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
  display: flex; align-items: center; gap: 10px;
}

.page-sub { color: var(--text-3); font-size: 13px; margin-top: 2px; }
.page-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* Breadcrumb */
.breadcrumb-nav {
  display: flex; align-items: center; gap: 8px;
  color: var(--text-3); font-size: 13px;
  margin-bottom: 4px;
}
.breadcrumb-nav a { color: var(--text-2); text-decoration: none; }
.breadcrumb-nav a:hover { color: var(--brand); }
.breadcrumb-nav span { color: var(--text); font-weight: 600; }

/* Progress */
.progress-bar-wrap {
  width: 100%; height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand), var(--green));
  border-radius: 3px;
  transition: width .5s;
}

/* Mini progress */
.mini-progress {
  display: flex; align-items: center; gap: 8px;
}
.mini-progress-fill {
  flex: 1; height: 6px;
  background: linear-gradient(90deg, var(--brand), var(--green));
  border-radius: 3px;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 20px;
}
.empty-icon {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: var(--surface2);
  display: flex; align-items: center; justify-content: center;
  font-size: 32px;
  color: var(--text-3);
  margin: 0 auto 16px;
}
.empty-state h3 { font-family: 'Syne', sans-serif; font-size: 18px; margin-bottom: 8px; }
.empty-state p { color: var(--text-3); margin-bottom: 20px; }
.empty-state-sm {
  text-align: center; padding: 32px 20px;
  color: var(--text-3); font-size: 13px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}

/* Text utilities */
.text-muted { color: var(--text-3); }
.text-sm { font-size: 12px; }
.text-danger { color: var(--red); }

/* Spin */
.spin { animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   DASHBOARD
   ============================================================ */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex; align-items: center; gap: 16px;
  position: relative; overflow: hidden;
  transition: var(--transition);
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.kpi-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.kpi-value {
  font-family: 'Syne', sans-serif;
  font-size: 24px; font-weight: 800;
  color: var(--text);
  line-height: 1;
}

.kpi-label { color: var(--text-3); font-size: 12px; margin-top: 3px; }

.kpi-blue .kpi-icon { background: var(--blue-bg); color: var(--blue); }
.kpi-green .kpi-icon { background: var(--green-bg); color: var(--green); }
.kpi-red .kpi-icon { background: var(--red-bg); color: var(--red); }
.kpi-purple .kpi-icon { background: var(--purple-bg); color: var(--purple); }
.kpi-amber .kpi-icon { background: var(--amber-bg); color: var(--amber); }
.kpi-teal .kpi-icon { background: #ccfbf1; color: var(--teal); }

.kpi-trend {
  position: absolute; right: 16px; bottom: 16px;
  font-size: 20px; color: var(--green); opacity: .4;
}

.dash-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

/* Funnel */
.funnel-body { display: flex; flex-direction: column; gap: 10px; }

.funnel-row {
  display: flex; align-items: center; gap: 12px;
  cursor: default;
}

.funnel-label {
  display: flex; align-items: center; gap: 7px;
  width: 130px; flex-shrink: 0;
  font-size: 12px; font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
}

.estate-dot {
  width: 8px; height: 8px;
  border-radius: 50%; flex-shrink: 0;
}

.funnel-bar-wrap {
  flex: 1;
  height: 10px;
  background: var(--surface2);
  border-radius: 5px;
  overflow: hidden;
}

.funnel-bar {
  height: 100%;
  border-radius: 5px;
  transition: width .5s;
  opacity: .85;
}

.funnel-count {
  display: flex; flex-direction: column;
  align-items: flex-end;
  width: 80px; flex-shrink: 0;
}
.funnel-count strong { font-weight: 700; font-size: 13px; }
.funnel-count small { color: var(--text-3); font-size: 10px; }

/* Activity feed */
.activity-feed { display: flex; flex-direction: column; }

.activity-item {
  display: flex; gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  transition: var(--transition);
}
.activity-item:last-child { border: none; }
.activity-item:hover { background: var(--surface2); }

.activity-icon {
  width: 34px; height: 34px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}
.act-nota { background: var(--blue-bg); color: var(--blue); }
.act-llamada { background: var(--green-bg); color: var(--green); }
.act-email { background: var(--purple-bg); color: var(--purple); }
.act-reunion { background: var(--amber-bg); color: var(--amber); }
.act-seguimiento { background: #f0fdf4; color: var(--teal); }
.act-tarea { background: var(--surface2); color: var(--text-2); }

.activity-main { display: flex; align-items: center; gap: 8px; margin-bottom: 2px; }
.activity-main strong { font-size: 13px; }
.act-type {
  font-size: 10px; font-weight: 700;
  background: var(--surface2);
  color: var(--text-3);
  padding: 1px 6px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.activity-desc { color: var(--text-3); font-size: 12px; line-height: 1.4; margin-bottom: 2px; }
.activity-meta { color: var(--text-3); font-size: 11px; }

/* Tasks list */
.tasks-list { display: flex; flex-direction: column; }

.task-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  transition: var(--transition);
}
.task-item:last-child { border: none; }
.task-item:hover { background: var(--surface2); }

.task-check {
  background: none; border: none;
  font-size: 18px; cursor: pointer;
  color: var(--text-3);
  flex-shrink: 0;
  padding: 2px;
  transition: var(--transition);
}
.task-check:hover { color: var(--green); transform: scale(1.1); }

.task-title { font-size: 13px; font-weight: 500; }
.task-empresa { color: var(--text-3); font-size: 11px; }

.task-meta { display: flex; align-items: center; gap: 6px; margin-left: auto; flex-shrink: 0; }

.task-overdue .task-title { color: var(--red); }

/* Pipeline totals */
.pipeline-totals {
  display: flex; gap: 24px;
  margin-bottom: 16px;
  padding: 14px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.pt-item { display: flex; flex-direction: column; gap: 2px; }
.pt-item span { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.pt-item strong { font-family: 'Syne', sans-serif; font-size: 18px; font-weight: 800; }

/* ============================================================
   PIPELINE KANBAN
   ============================================================ */

.kanban-board {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 20px;
  min-height: 600px;
  align-items: flex-start;
}

.kanban-col {
  flex: 0 0 280px;
  background: var(--surface2);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: flex; flex-direction: column;
  max-height: calc(100vh - 260px);
}

.kanban-col-header {
  padding: 14px 16px;
  border-bottom: 2px solid var(--col-color, var(--brand));
  border-radius: var(--radius) var(--radius) 0 0;
}

.col-title {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 4px;
}

.col-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.col-title strong { font-size: 14px; font-weight: 700; }

.col-meta { display: flex; align-items: center; gap: 8px; }
.col-count {
  background: var(--col-color, var(--brand));
  color: white;
  font-size: 11px; font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  opacity: .85;
}

.col-valor { font-size: 12px; color: var(--text-3); margin-top: 4px; font-weight: 600; }

.kanban-cards {
  padding: 12px;
  flex: 1;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 10px;
  min-height: 120px;
}

/* Kanban cards */
.kanban-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  cursor: grab;
  transition: var(--transition);
  position: relative;
}
.kanban-card:hover {
  border-color: var(--brand);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.kanban-card:active { cursor: grabbing; }

.kanban-ghost {
  opacity: .4;
  background: var(--brand-light);
  border: 2px dashed var(--brand);
}

.kanban-dragging {
  box-shadow: 0 10px 30px rgba(99,102,241,.25);
  transform: rotate(2deg) scale(1.02);
}

.card-actions-top {
  position: absolute; top: 10px; right: 10px;
  display: none;
}
.kanban-card:hover .card-actions-top { display: block; }

.card-edit-btn {
  width: 24px; height: 24px;
  border-radius: 4px;
  background: var(--brand-light);
  color: var(--brand);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  transition: var(--transition);
  text-decoration: none;
}
.card-edit-btn:hover { background: var(--brand); color: white; text-decoration: none; }

.kcard-title { font-weight: 700; font-size: 14px; margin-bottom: 6px; padding-right: 28px; }
.kcard-contact { color: var(--text-2); font-size: 12px; margin-bottom: 3px; display: flex; align-items: center; gap: 5px; }
.kcard-phone, .kcard-email { color: var(--text-3); font-size: 11px; margin-bottom: 2px; display: flex; align-items: center; gap: 5px; }

.kcard-footer {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 10px; padding-top: 10px;
  border-top: 1px solid var(--border);
}

.kcard-valor { font-weight: 800; font-size: 13px; color: var(--green); }

.kcard-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--brand);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
}

.kcard-prob {
  display: flex; align-items: center; gap: 6px;
  margin-top: 8px;
}
.kcard-prob-bar {
  flex: 1; height: 4px;
  background: var(--border);
  border-radius: 2px; overflow: hidden;
}
.kcard-prob-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--amber), var(--green));
  border-radius: 2px;
}
.kcard-prob small { font-size: 10px; color: var(--text-3); }

.kcard-next {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; color: var(--text-3);
  margin-top: 6px;
  padding: 3px 7px;
  background: var(--surface2);
  border-radius: 4px;
}
.kcard-next.overdue { background: var(--red-bg); color: var(--red); }

.kcard-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.kcard-tag {
  font-size: 10px; font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
}

.kanban-placeholder {
  display: none;
  padding: 20px;
  text-align: center;
  color: var(--text-3);
  font-size: 12px;
  border: 2px dashed var(--border);
  border-radius: 8px;
  flex-direction: column; align-items: center; gap: 4px;
}

.sortable-empty .kanban-placeholder { display: flex; }

.add-to-col-btn {
  margin: 8px 12px 12px;
  width: calc(100% - 24px);
  padding: 8px;
  background: none;
  border: 1.5px dashed var(--border);
  border-radius: 6px;
  color: var(--text-3);
  cursor: pointer; font-size: 13px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: var(--transition);
}
.add-to-col-btn:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-light); }

/* Pipeline selector */
.pipeline-selector {
  display: flex; flex-wrap: wrap; gap: 8px;
}

.pipeline-opt {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 14px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  font-size: 12px; font-weight: 600;
  color: var(--text-2);
  transition: var(--transition);
  user-select: none;
}
.pipeline-opt:hover { border-color: var(--col); color: var(--col); }
.pipeline-opt.selected {
  background: color-mix(in srgb, var(--col) 12%, transparent);
  border-color: var(--col);
  color: var(--col);
}
.pipe-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* Tags selector */
.tags-selector { display: flex; flex-wrap: wrap; gap: 8px; }

.tag-opt {
  display: inline-flex; align-items: center;
  padding: 5px 14px;
  border: 1.5px solid color-mix(in srgb, var(--tc) 40%, transparent);
  border-radius: 20px;
  cursor: pointer;
  font-size: 12px; font-weight: 600;
  color: var(--tc);
  background: color-mix(in srgb, var(--tc) 8%, transparent);
  transition: var(--transition);
  user-select: none;
}
.tag-opt.selected {
  background: color-mix(in srgb, var(--tc) 18%, transparent);
  border-color: var(--tc);
}

/* ============================================================
   EMPRESA LAYOUT
   ============================================================ */

.empresa-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 24px;
  align-items: flex-start;
}

.empresa-sidebar { position: sticky; top: calc(var(--topbar-h) + 20px); }

.empresa-quick-info {
  display: flex; flex-direction: column; gap: 10px; padding: 16px;
}

.qi-item {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-2);
  text-decoration: none;
  transition: var(--transition);
}
.qi-item:hover { color: var(--brand); text-decoration: none; }
.qi-item i { color: var(--text-3); }

/* Activity panel */
.nueva-actividad-panel {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}

.act-type-tabs {
  display: flex; gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.act-tab {
  padding: 5px 10px;
  border-radius: 6px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  cursor: pointer; font-size: 11px;
  transition: var(--transition);
  color: var(--text-2);
}
.act-tab:hover { border-color: var(--brand); color: var(--brand); }
.act-tab.active { background: var(--brand); color: white; border-color: var(--brand); }

.act-meta-row, .act-file-row {
  display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap;
}

.act-item {
  display: flex; gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.act-item:last-child { border: none; }

.act-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0;
  margin-top: 2px;
}

.act-header {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 4px;
}
.act-tipo { font-size: 11px; font-weight: 700; color: var(--text-3); text-transform: uppercase; }
.act-fecha { font-size: 11px; color: var(--text-3); margin-left: auto; }
.act-del-btn {
  background: none; border: none;
  color: var(--text-3); cursor: pointer;
  font-size: 14px; padding: 2px;
  border-radius: 4px;
  transition: var(--transition);
}
.act-del-btn:hover { background: var(--red-bg); color: var(--red); }

.act-desc { color: var(--text-2); font-size: 13px; line-height: 1.5; margin-bottom: 4px; }
.act-resultado {
  display: inline-block; font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 10px;
  margin-bottom: 4px;
}
.resultado-completado { background: var(--green-bg); color: #065f46; }
.resultado-no_contesta { background: var(--red-bg); color: #991b1b; }
.resultado-interesado { background: var(--green-bg); color: #065f46; }
.resultado-volver_llamar { background: var(--amber-bg); color: #92400e; }
.resultado-no_interesado { background: var(--red-bg); color: #991b1b; }

.act-archivo {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; color: var(--brand);
  background: var(--brand-light);
  padding: 3px 8px; border-radius: 4px;
  text-decoration: none;
}
.act-autor { color: var(--text-3); font-size: 11px; }

/* Pipeline history */
.history-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.history-item:last-child { border: none; }
.history-icon { color: var(--brand); font-size: 15px; flex-shrink: 0; }
.history-from { color: var(--text-3); }
.history-to { font-weight: 700; color: var(--text); }
.history-meta { display: block; color: var(--text-3); font-size: 11px; margin-top: 2px; }

/* ============================================================
   COMERCIALES
   ============================================================ */

.stats-row {
  display: flex; gap: 12px;
  margin-bottom: 24px;
}

.stat-mini {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 20px;
  display: flex; align-items: center; gap: 10px;
}
.stat-mini strong { font-family: 'Syne', sans-serif; font-size: 22px; font-weight: 800; }
.stat-mini span { color: var(--text-3); font-size: 12px; }
.stat-mini.green strong { color: var(--green); }
.stat-mini.red strong { color: var(--red); }

.comerciales-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.comercial-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex; gap: 16px;
  align-items: flex-start;
  transition: var(--transition);
  position: relative;
}
.comercial-card:hover { box-shadow: var(--shadow-md); }
.comercial-card.inactive { opacity: .55; }

.comercial-avatar {
  width: 50px; height: 50px;
  border-radius: 14px;
  background: var(--brand);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Syne', sans-serif;
  font-size: 20px; font-weight: 800;
  flex-shrink: 0;
}

.comercial-info { flex: 1; }
.comercial-info h4 { font-family: 'Syne', sans-serif; font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.comercial-info p { color: var(--text-3); font-size: 12px; margin-bottom: 2px; }
.comercial-stats { display: flex; gap: 12px; margin: 8px 0; font-size: 12px; color: var(--text-2); }
.comercial-stats strong { color: var(--text); font-weight: 700; }

.comercial-actions {
  position: absolute; top: 16px; right: 16px;
  display: flex; gap: 6px;
}

/* ============================================================
   TAREAS
   ============================================================ */

.tab-filters {
  display: flex; gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.tab-btn {
  padding: 7px 16px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  cursor: pointer; font-size: 13px; font-weight: 600;
  color: var(--text-2);
  transition: var(--transition);
}
.tab-btn:hover { border-color: var(--brand); color: var(--brand); }
.tab-btn.active { background: var(--brand); color: white; border-color: var(--brand); }

.tasks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}

.task-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: var(--transition);
}
.task-card:hover { box-shadow: var(--shadow-md); }
.task-card.task-done { opacity: .6; }
.task-card.task-overdue-card { border-left: 3px solid var(--red); }

.task-card-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
}
.task-card-left { display: flex; gap: 10px; align-items: flex-start; }

.task-toggle {
  background: none; border: none;
  font-size: 20px; cursor: pointer;
  color: var(--text-3); padding: 2px;
  transition: var(--transition);
  flex-shrink: 0;
}
.task-toggle:hover { color: var(--green); transform: scale(1.1); }
.task-toggle.checked { color: var(--green); }

.task-card-title { font-weight: 600; font-size: 14px; margin-bottom: 2px; }
.task-card-meta { display: flex; align-items: center; gap: 6px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.task-date { font-size: 11px; color: var(--text-3); }
.task-card-desc { color: var(--text-3); font-size: 12px; line-height: 1.5; margin: 8px 0 8px 30px; }
.task-card-actions {
  display: flex; gap: 12px;
  margin-top: 10px; padding-top: 10px;
  border-top: 1px solid var(--border);
}

/* ============================================================
   LOGIN
   ============================================================ */

.login-body {
  background: var(--bg);
  min-height: 100vh;
  display: flex;
}

.login-wrapper {
  display: flex;
  width: 100%;
  min-height: 100vh;
}

.login-panel {
  flex: 0 0 460px;
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #312e81 100%);
  padding: 48px;
  display: flex; flex-direction: column; justify-content: center;
  position: relative; overflow: hidden;
}

.login-panel-content { position: relative; z-index: 2; }

.login-logo {
  width: 56px; height: 56px;
  background: var(--brand);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; color: white;
  margin-bottom: 24px;
}

.login-panel h1 {
  font-family: 'Syne', sans-serif;
  font-size: 32px; font-weight: 800;
  color: white; margin-bottom: 12px;
}

.login-panel > .login-panel-content > p {
  color: rgba(255,255,255,.7);
  font-size: 15px; line-height: 1.6;
  margin-bottom: 36px;
}

.login-stats {
  display: flex; gap: 24px;
}

.lstat {
  display: flex; flex-direction: column;
}
.lstat strong { font-family: 'Syne', sans-serif; font-size: 28px; font-weight: 800; color: white; }
.lstat span { color: rgba(255,255,255,.5); font-size: 12px; }

.login-panel-decor { position: absolute; inset: 0; z-index: 1; }

.decor-circle {
  position: absolute;
  border-radius: 50%;
  background: rgba(99,102,241,.15);
}
.c1 { width: 300px; height: 300px; top: -80px; right: -80px; }
.c2 { width: 200px; height: 200px; bottom: 100px; right: -50px; background: rgba(139,92,246,.1); }
.c3 { width: 100px; height: 100px; bottom: 40px; left: 30px; background: rgba(16,185,129,.1); }

.login-form-side {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  padding: 48px;
}

.login-form-container {
  width: 100%;
  max-width: 400px;
}

.login-form-container h2 {
  font-family: 'Syne', sans-serif;
  font-size: 28px; font-weight: 800;
  margin-bottom: 6px;
}

.login-sub { color: var(--text-3); margin-bottom: 28px; }

.alert-error {
  background: var(--red-bg);
  color: var(--red);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 13px; font-weight: 600;
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 20px;
}

.field-group { margin-bottom: 18px; }
.field-group label { display: block; font-weight: 600; font-size: 13px; color: var(--text-2); margin-bottom: 7px; }

.field-input-wrap {
  position: relative;
}

.field-input-wrap > i {
  position: absolute; left: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-3); font-size: 16px;
}

.field-input-wrap input {
  width: 100%;
  padding: 12px 14px 12px 40px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: var(--transition);
}
.field-input-wrap input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-glow); }

.pwd-toggle {
  position: absolute; right: 10px; top: 50%;
  transform: translateY(-50%);
  background: none; border: none;
  color: var(--text-3); cursor: pointer;
  font-size: 16px;
}

.btn-login {
  width: 100%;
  padding: 13px 20px;
  background: var(--brand);
  color: white;
  border: none; border-radius: var(--radius-sm);
  font-family: 'Syne', sans-serif;
  font-size: 15px; font-weight: 700;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  transition: var(--transition);
  margin-top: 24px;
}
.btn-login:hover { background: var(--brand-dark); transform: translateY(-1px); }

.login-hint {
  margin-top: 20px;
  padding: 12px 14px;
  background: var(--surface2);
  border-radius: 8px;
  font-size: 12px; color: var(--text-3);
  display: flex; align-items: center; gap: 8px;
}
.login-hint code {
  background: var(--border);
  padding: 1px 5px; border-radius: 3px;
  font-size: 11px; color: var(--brand);
}

/* Import zone */
.import-zone {
  border: 2px dashed var(--border2);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-3);
}
.import-zone:hover { border-color: var(--brand); background: var(--brand-light); }
.import-zone i { font-size: 40px; display: block; margin-bottom: 12px; }
.import-zone p { margin-bottom: 12px; }

.import-tip {
  background: var(--blue-bg);
  color: #1e40af;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12px;
  margin-top: 12px;
  display: flex; align-items: flex-start; gap: 8px;
}

/* Filter group */
.filter-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 1200px) {
  .dash-grid-2 { grid-template-columns: 1fr; }
  .empresa-layout { grid-template-columns: 1fr; }
  .empresa-sidebar { position: static; }
}

@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }

  .sidebar {
    width: 240px;
    transform: translateX(-100%);
    transition: transform .25s cubic-bezier(.4,0,.2,1);
  }

  .sidebar.open {
    transform: translateX(0);
    width: 240px;
  }

  .sidebar-overlay.open { display: block; }

  .main-content { margin-left: 0; }
  .topbar { left: 0; }
  .topbar-menu-btn { display: flex; }

  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .kanban-board { overflow-x: scroll; }
  .login-panel { display: none; }
  .login-form-side { padding: 24px; }
  .form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .main-content { padding: 16px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .page-header { flex-direction: column; }
  .tasks-grid { grid-template-columns: 1fr; }
  .comerciales-grid { grid-template-columns: 1fr; }
}

/* ── Toast notifications ────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: .6rem;
  max-width: 360px;
}

.toast {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .85rem 1rem;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,.18);
  font-size: .9rem;
  font-weight: 500;
  background: var(--surface);
  color: var(--text);
  border-left: 4px solid transparent;
  transform: translateX(120%);
  transition: transform .35s cubic-bezier(.34,1.56,.64,1);
  min-width: 260px;
}

.toast.show { transform: translateX(0); }
.toast-success { border-color: #16a34a; background: #f0fdf4; color: #166534; }
.toast-error   { border-color: #dc2626; background: #fef2f2; color: #991b1b; }
.toast-warning { border-color: #d97706; background: #fffbeb; color: #92400e; }
.toast-info    { border-color: #2563eb; background: #eff6ff; color: #1d4ed8; }

.toast-icon { flex-shrink: 0; display: flex; }
.toast-msg  { flex: 1; }
.toast-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: .9rem;
  opacity: .5;
  padding: 0;
  line-height: 1;
  color: inherit;
}
.toast-close:hover { opacity: 1; }

/* ── Modales ────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  transition: opacity .3s;
}
.modal-overlay.open { opacity: 1; }

.modal {
  background: var(--surface);
  border-radius: 14px;
  box-shadow: 0 8px 40px rgba(0,0,0,.25);
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(24px) scale(.97);
  transition: transform .3s cubic-bezier(.34,1.56,.64,1);
}
.modal-overlay.open .modal { transform: translateY(0) scale(1); }

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1.05rem; font-weight: 700; color: var(--text); margin: 0; }
.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--text-secondary);
  line-height: 1;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background .15s;
}
.modal-close:hover { background: var(--bg); }
.modal-body   { padding: 1.5rem; }
.modal-footer { display: flex; justify-content: flex-end; gap: .75rem; padding: 1rem 1.5rem; border-top: 1px solid var(--border); background: var(--bg); border-radius: 0 0 14px 14px; }

/* ── Búsqueda global ────────────────────────────────────────── */
.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 30px rgba(0,0,0,.15);
  z-index: 200;
  overflow: hidden;
  max-height: 360px;
  overflow-y: auto;
}

.search-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1rem;
  text-decoration: none;
  color: var(--text);
  transition: background .15s;
}
.search-item:hover { background: var(--bg); }
.search-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: .8rem; font-weight: 700; flex-shrink: 0; }
.search-info { flex: 1; min-width: 0; }
.search-name { font-weight: 600; font-size: .9rem; display: block; }
.search-sub  { font-size: .78rem; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.search-estado { font-size: .72rem; font-weight: 600; padding: .2rem .5rem; border-radius: 6px; white-space: nowrap; }
.search-loading, .search-empty { padding: 1rem; text-align: center; color: var(--text-secondary); font-size: .875rem; }

/* ── Dropzone importar ──────────────────────────────────────── */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 2.5rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
  color: var(--text-secondary);
}
.dropzone:hover, .dropzone.drag-over {
  border-color: var(--primary);
  background: var(--primary-light, #eff6ff);
  color: var(--primary);
}
.dropzone-file { display: flex; flex-direction: column; align-items: center; gap: .5rem; color: var(--primary); font-weight: 600; }

/* ── Progress bar ───────────────────────────────────────────── */
.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-top: .75rem;
}
.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width .3s;
}

/* ── Task done animation ────────────────────────────────────── */
.task-done { opacity: .4; pointer-events: none; transition: opacity .4s; }

/* ── Sidebar overlay (móvil) ────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 99;
}
.sidebar-overlay.visible { display: block; }

@media (max-width: 900px) {
  #sidebar { transform: translateX(-100%); transition: transform .3s; }
  #sidebar.open { transform: translateX(0); }
}

/* ── Fix: modal-overlay pattern (nueva versión) ─────────────── */
.modal-overlay {
  position: fixed !important;
  top: 0 !important; left: 0 !important;
  width: 100vw !important; height: 100vh !important;
  background: rgba(0,0,0,.6) !important;
  z-index: 99999 !important;
  display: none;
  align-items: center !important;
  justify-content: center !important;
  padding: 1rem !important;
}
.modal-overlay > .modal {
  position: relative !important;
  inset: auto !important;
  background: var(--surface) !important;
  border-radius: 14px !important;
  box-shadow: 0 20px 60px rgba(0,0,0,.4) !important;
  width: 100% !important;
  max-height: 90vh !important;
  overflow-y: auto !important;
  z-index: auto !important;
  animation: slideUp .2s ease !important;
}

/* ── Agenda items en empresa detalle ─────────────── */
.agenda-item {
  display: flex; align-items: flex-start; gap: .65rem;
  padding: .65rem 1rem; border-bottom: 1px solid var(--border);
  transition: background .15s;
}
.agenda-item:hover { background: var(--bg); }
.agenda-item:last-child { border-bottom: none; }
.agenda-date {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 40px; padding: .35rem .25rem; border-radius: 8px;
  gap: 1px; text-align: center; flex-shrink: 0;
}
.agenda-body { flex: 1; min-width: 0; }
.act-tab-btn {
  padding: .3rem .7rem; border: 1px solid var(--border); border-radius: 20px;
  background: var(--surface); color: var(--text-2); cursor: pointer; font-size: .78rem;
  transition: all .15s;
}
.act-tab-btn:hover { border-color: var(--brand); color: var(--brand); }
.act-tab-btn.active { background: var(--brand); color: #fff; border-color: var(--brand); }
