/* ==========================================================================
   Clinic Pulse — Sistema de diseño
   by Don Galeón
   ========================================================================== */

:root {
  /* Base */
  --bg: #f6f6f7;
  --surface: #ffffff;
  --surface-2: #fafafb;
  --line: #e9eaee;
  --line-strong: #d9dbe1;
  --ink: #16181d;
  --ink-2: #3f434c;
  --muted: #6f7482;
  --muted-2: #9a9eab;

  /* Marca */
  --brand: #3a49d6;
  --brand-hover: #2f3dbf;
  --brand-soft: #eef0fd;
  --brand-ink: #2a36a8;

  /* Estados */
  --hot: #e5484d;
  --hot-soft: #fdecec;
  --warm: #d9930d;
  --warm-soft: #fdf3dc;
  --cool: #3b7ddd;
  --cool-soft: #e8f0fc;
  --ok: #24925f;
  --ok-soft: #e6f5ec;
  --ai: #7a5af8;
  --ai-soft: #f0ecfe;

  /* Forma */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 18px;
  --shadow-sm: 0 1px 2px rgba(22, 24, 29, 0.04);
  --shadow-md: 0 8px 24px -12px rgba(22, 24, 29, 0.18);
  --shadow-lg: 0 24px 60px -20px rgba(22, 24, 29, 0.28);

  /* Layout */
  --sidebar-w: 248px;
  --sidebar-w-collapsed: 72px;
  --content-max: 1360px;
  --gap: 20px;

  /* Tipografía */
  --font: "Manrope", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --t-fast: 140ms var(--ease);
  --t-med: 240ms var(--ease);
}

/* --------------------------------------------------------------------------
   Reset ligero
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "tnum" 1, "cv11" 1;
}
h1, h2, h3, h4, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
svg { display: block; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--brand-soft); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* --------------------------------------------------------------------------
   Utilidades tipográficas
   -------------------------------------------------------------------------- */
.t-title { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
.t-h2 { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.t-h3 { font-size: 13px; font-weight: 700; }
.t-sub { color: var(--muted); font-size: 13px; }
.t-small { font-size: 12px; color: var(--muted); }
.t-num { font-variant-numeric: tabular-nums; }
.t-strong { font-weight: 700; }
.t-muted { color: var(--muted); }
.t-ok { color: var(--ok); }
.t-hot { color: var(--hot); }
.t-brand { color: var(--brand); }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --------------------------------------------------------------------------
   Shell: sidebar + contenido
   -------------------------------------------------------------------------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed; inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 18px 12px 14px;
  z-index: 40;
  transition: width var(--t-med), transform var(--t-med);
}

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 8px 18px;
}
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px; flex: 0 0 auto;
  background: var(--ink); color: #fff;
  display: grid; place-items: center;
}
.brand-mark svg { width: 18px; height: 18px; }
.brand-text { line-height: 1.1; min-width: 0; }
.brand-name { font-weight: 800; font-size: 15px; letter-spacing: -0.02em; white-space: nowrap; }
.brand-by { font-size: 11px; color: var(--muted); font-weight: 500; white-space: nowrap; }

.nav { display: flex; flex-direction: column; gap: 18px; overflow-y: auto; padding-bottom: 12px; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 10.5px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted-2); padding: 0 10px 6px; }
.nav-group.is-nested { position: relative; padding-left: 10px; }
.nav-group.is-nested::before { content: ""; position: absolute; left: 6px; top: 24px; bottom: 6px; width: 2px; border-radius: 2px; background: var(--line); }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--r-md);
  color: var(--ink-2); font-weight: 600; font-size: 13.5px;
  transition: background var(--t-fast), color var(--t-fast);
  position: relative; white-space: nowrap;
}
.nav-item svg { width: 18px; height: 18px; flex: 0 0 auto; color: var(--muted); }
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.is-active { background: var(--brand-soft); color: var(--brand-ink); }
.nav-item.is-active svg { color: var(--brand); }
.nav-badge {
  margin-left: auto; font-size: 11px; font-weight: 700;
  padding: 1px 7px; border-radius: 999px;
  background: var(--hot-soft); color: var(--hot);
}
.nav-sep { height: 1px; background: var(--line); margin: 10px 8px; }

.sidebar-footer { margin-top: auto; padding-top: 12px; }
.user-card { border: 1px solid var(--line); border-radius: var(--r-lg); padding: 8px; background: var(--surface-2); display: flex; flex-direction: column; gap: 2px; }
.user-card .user { margin-bottom: 4px; }
.user-card .nav-item { padding: 7px 8px; font-size: 13px; }
.user-card .nav-item:hover { background: var(--surface); }
.user {
  display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: var(--r-md);
  transition: background var(--t-fast);
}
.user:hover { background: var(--surface-2); }
.user-meta { min-width: 0; line-height: 1.2; }
.user-name { font-weight: 700; font-size: 13px; }
.user-clinic { font-size: 12px; color: var(--muted); }

.sidebar-toggle {
  display: none; position: absolute; top: 22px; right: -13px;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--line);
  color: var(--muted); place-items: center; box-shadow: var(--shadow-sm);
}
.sidebar-toggle svg { width: 14px; height: 14px; }

/* Colapsado (tablet/desktop) */
.app.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); padding-left: 10px; padding-right: 10px; }
.app.sidebar-collapsed .brand-text,
.app.sidebar-collapsed .nav-item span,
.app.sidebar-collapsed .nav-badge,
.app.sidebar-collapsed .user-meta { display: none; }
.app.sidebar-collapsed .nav-item { justify-content: center; padding: 10px; }
.app.sidebar-collapsed .brand { justify-content: center; padding-left: 0; padding-right: 0; }
.app.sidebar-collapsed .user { justify-content: center; }
.app.sidebar-collapsed .nav-label { display: none; }
.app.sidebar-collapsed .nav-group.is-nested { padding-left: 0; }
.app.sidebar-collapsed .nav-group.is-nested::before { display: none; }
.app.sidebar-collapsed .nav { gap: 10px; }
.app.sidebar-collapsed .user-card { padding: 4px; }
.app.sidebar-collapsed .main { margin-left: var(--sidebar-w-collapsed); }
.app.sidebar-collapsed .sidebar-toggle svg { transform: rotate(180deg); }

.main {
  flex: 1; min-width: 0;
  margin-left: var(--sidebar-w);
  transition: margin var(--t-med);
}
.page {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 28px 32px 48px;
}

/* Topbar móvil */
.topbar {
  display: none; position: sticky; top: 0; z-index: 30;
  height: 56px; align-items: center; gap: 12px;
  padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.topbar .brand { padding: 0; }
.icon-btn {
  width: 36px; height: 36px; border-radius: var(--r-md);
  display: grid; place-items: center; color: var(--ink-2);
  transition: background var(--t-fast);
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 18px; height: 18px; }

.scrim {
  position: fixed; inset: 0; background: rgba(22,24,29,0.4);
  opacity: 0; pointer-events: none; transition: opacity var(--t-med); z-index: 35;
}
.scrim.is-open { opacity: 1; pointer-events: auto; }

/* Nav inferior móvil */
.mobile-nav {
  display: none; position: fixed; inset: auto 0 0 0; z-index: 30;
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}
.mobile-nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 4px; border-radius: var(--r-md); font-size: 10.5px; font-weight: 600; color: var(--muted);
}
.mobile-nav a svg { width: 20px; height: 20px; }
.mobile-nav a.is-active { color: var(--brand); }

/* --------------------------------------------------------------------------
   Cabecera de página
   -------------------------------------------------------------------------- */
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  margin-bottom: 24px; flex-wrap: wrap;
}
.page-head .t-sub { margin-top: 4px; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* --------------------------------------------------------------------------
   Paneles
   -------------------------------------------------------------------------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px 0;
}
.panel-head .t-sub { margin-top: 2px; }
.panel-body { padding: 16px 20px 20px; }
.panel-link { font-size: 12.5px; font-weight: 700; color: var(--brand); white-space: nowrap; }
.panel-link:hover { text-decoration: underline; }

/* --------------------------------------------------------------------------
   Botones
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px; border-radius: var(--r-md);
  font-weight: 700; font-size: 13px; white-space: nowrap;
  border: 1px solid transparent;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast), transform var(--t-fast);
}
.btn svg { width: 16px; height: 16px; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #2a2d35; }
.btn-brand { background: var(--brand); color: #fff; }
.btn-brand:hover { background: var(--brand-hover); }
.btn-secondary { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost { color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--hot-soft); color: var(--hot); }
.btn-danger:hover { background: #fbdcdd; }
.btn-ok { background: var(--ok-soft); color: var(--ok); }
.btn-ok:hover { background: #d6eede; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; }
.btn-sm svg { width: 14px; height: 14px; }
.btn-lg { height: 42px; padding: 0 18px; font-size: 14px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* Segmentado */
.seg {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md);
}
.seg button {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 12px; border-radius: 7px;
  font-size: 12.5px; font-weight: 600; color: var(--muted);
  transition: background var(--t-fast), color var(--t-fast), box-shadow var(--t-fast);
}
.seg button:hover { color: var(--ink); }
.seg button.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); border: 1px solid var(--line); }

/* --------------------------------------------------------------------------
   Formularios
   -------------------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; font-weight: 700; color: var(--ink-2); }
.field .hint { font-size: 12px; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; height: 38px; padding: 0 12px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-md);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.textarea { height: auto; padding: 10px 12px; resize: vertical; min-height: 84px; }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}
.input::placeholder, .textarea::placeholder { color: var(--muted-2); }
.select {
  appearance: none; padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236f7482' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }

.search {
  position: relative; display: flex; align-items: center;
}
.search svg { position: absolute; left: 11px; width: 16px; height: 16px; color: var(--muted-2); pointer-events: none; }
.search .input { padding-left: 34px; }

.switch { position: relative; width: 38px; height: 22px; border-radius: 999px; background: var(--line-strong); transition: background var(--t-fast); flex: 0 0 auto; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform var(--t-fast); }
.switch.is-on { background: var(--ok); }
.switch.is-on::after { transform: translateX(16px); }

/* --------------------------------------------------------------------------
   Badges y estados
   -------------------------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; white-space: nowrap;
  background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line);
}
.badge svg { width: 12px; height: 12px; }
.badge-hot { background: var(--hot-soft); color: var(--hot); border-color: transparent; }
.badge-warm { background: var(--warm-soft); color: var(--warm); border-color: transparent; }
.badge-cool { background: var(--cool-soft); color: var(--cool); border-color: transparent; }
.badge-ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge-ai { background: var(--ai-soft); color: var(--ai); border-color: transparent; }
.badge-brand { background: var(--brand-soft); color: var(--brand-ink); border-color: transparent; }
.badge-muted { color: var(--muted); }

.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }

/* Score */
.score {
  display: inline-flex; align-items: center; gap: 5px;
  font-weight: 800; font-size: 12.5px; font-variant-numeric: tabular-nums;
  padding: 2px 8px 2px 6px; border-radius: 999px;
}
.score-hot { background: var(--hot-soft); color: var(--hot); }
.score-warm { background: var(--warm-soft); color: var(--warm); }
.score-cool { background: var(--cool-soft); color: var(--cool); }
.score svg { width: 12px; height: 12px; }

/* Avatares */
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: 0 0 auto;
  display: grid; place-items: center;
  font-size: 11.5px; font-weight: 800; letter-spacing: 0.02em;
  background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line);
}
.avatar-sm { width: 26px; height: 26px; font-size: 10px; }
.avatar-lg { width: 44px; height: 44px; font-size: 14px; }
.avatar-brand { background: var(--brand); color: #fff; border-color: transparent; }
.avatar-ai { background: var(--ai-soft); color: var(--ai); border-color: transparent; }

/* Delta */
.delta { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 700; }
.delta svg { width: 13px; height: 13px; }
.delta-up { color: var(--ok); }
.delta-down { color: var(--hot); }
.delta-flat { color: var(--muted); }

/* --------------------------------------------------------------------------
   Tablas
   -------------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; font-size: 12px; font-weight: 700; color: var(--muted);
  padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background var(--t-fast); }
.table tbody tr:hover { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tr.is-clickable { cursor: pointer; }

/* --------------------------------------------------------------------------
   Modales, drawers, toasts, tooltips
   -------------------------------------------------------------------------- */
.modal-root { position: fixed; inset: 0; z-index: 60; display: none; }
.modal-root.is-open { display: block; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(22,24,29,0.45); animation: fadeIn var(--t-med); }
.modal {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow: auto;
  background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--shadow-lg);
  animation: popIn var(--t-med);
}
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 22px 0; }
.modal-body { padding: 18px 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 0 22px 20px; }

.drawer-root { position: fixed; inset: 0; z-index: 55; display: none; }
.drawer-root.is-open { display: block; }
.drawer {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: min(820px, 100vw);
  background: var(--surface); border-left: 1px solid var(--line); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  animation: slideIn var(--t-med);
}
.drawer-body { flex: 1; overflow: auto; }

.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 80; display: flex; flex-direction: column; gap: 8px; }
.toast {
  display: flex; align-items: center; gap: 10px;
  min-width: 260px; max-width: 380px; padding: 12px 14px;
  background: var(--ink); color: #fff; border-radius: var(--r-md);
  font-size: 13px; font-weight: 600; box-shadow: var(--shadow-lg);
  animation: toastIn var(--t-med);
}
.toast svg { width: 16px; height: 16px; flex: 0 0 auto; }
.toast-ok svg { color: #6fd39c; }
.toast-hot svg { color: #ff8b8f; }
.toast-ai svg { color: #b8a6ff; }
.toast.is-leaving { animation: toastOut var(--t-med) forwards; }

[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute; left: 50%; bottom: calc(100% + 6px); transform: translateX(-50%) translateY(2px);
  background: var(--ink); color: #fff; font-size: 11.5px; font-weight: 600;
  padding: 5px 8px; border-radius: 6px; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity var(--t-fast), transform var(--t-fast); z-index: 50;
}
[data-tip]:hover::after { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Empty states */
.empty {
  padding: 32px 20px; text-align: center; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.empty svg { width: 28px; height: 28px; color: var(--muted-2); }
.empty .t-h3 { color: var(--ink-2); }

/* Skeleton */
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, #f0f1f4 50%, var(--surface-2) 75%);
  background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 6px;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: translate(-50%, -48%) scale(0.98); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
@keyframes slideIn { from { transform: translateX(24px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes toastOut { to { transform: translateY(8px); opacity: 0; } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* --------------------------------------------------------------------------
   Dashboard
   -------------------------------------------------------------------------- */
.kpis {
  display: grid; grid-template-columns: repeat(6, 1fr);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  overflow: hidden; margin-bottom: var(--gap);
}
.kpi { padding: 18px 20px; border-right: 1px solid var(--line); min-width: 0; }
.kpi:last-child { border-right: 0; }
.kpi-label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.kpi-value {
  font-size: 26px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.15;
  margin: 6px 0 6px; font-variant-numeric: tabular-nums;
}
.kpi-money .kpi-value { color: var(--ok); }
.kpi-pipeline .kpi-value { color: var(--brand-ink); }
.kpi-foot { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); white-space: nowrap; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); margin-bottom: var(--gap); }
.grid-3-2 { display: grid; grid-template-columns: 3fr 2fr; gap: var(--gap); margin-bottom: var(--gap); }
.grid-2-3 { display: grid; grid-template-columns: 2fr 3fr; gap: var(--gap); margin-bottom: var(--gap); }

/* Alertas */
.alerts { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; margin-bottom: var(--gap); scrollbar-width: none; }
.alerts::-webkit-scrollbar { display: none; }
.alert {
  flex: 0 0 auto; display: flex; align-items: center; gap: 10px;
  padding: 9px 14px 9px 10px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); font-size: 12.5px; font-weight: 600;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.alert:hover { border-color: var(--line-strong); background: var(--surface-2); }
.alert-icon { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; flex: 0 0 auto; }
.alert-icon svg { width: 13px; height: 13px; }
.alert-hot .alert-icon { background: var(--hot-soft); color: var(--hot); }
.alert-warm .alert-icon { background: var(--warm-soft); color: var(--warm); }
.alert-cool .alert-icon { background: var(--cool-soft); color: var(--cool); }
.alert-ok .alert-icon { background: var(--ok-soft); color: var(--ok); }
.alert-ai .alert-icon { background: var(--ai-soft); color: var(--ai); }

/* Embudo */
.funnel { display: flex; flex-direction: column; gap: 4px; }
.funnel-row { display: grid; grid-template-columns: 110px 1fr 64px; align-items: center; gap: 14px; }
.funnel-label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.funnel-track { height: 38px; position: relative; }
.funnel-bar {
  height: 100%; border-radius: 8px; background: var(--brand);
  display: flex; align-items: center; padding: 0 12px;
  color: #fff; font-weight: 800; font-size: 13px; font-variant-numeric: tabular-nums;
  min-width: 52px; transform-origin: left; animation: growX 700ms var(--ease) both;
}
.funnel-row:nth-child(1) .funnel-bar { background: var(--brand); }
.funnel-row:nth-child(2) .funnel-bar { background: #5866df; }
.funnel-row:nth-child(3) .funnel-bar { background: #7682e6; }
.funnel-row:nth-child(4) .funnel-bar { background: var(--ok); }
.funnel-rate { font-size: 12px; font-weight: 700; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.funnel-drop {
  display: grid; grid-template-columns: 110px 1fr 64px; gap: 14px; align-items: center;
  height: 22px;
}
.funnel-drop span { grid-column: 2; font-size: 11.5px; color: var(--muted-2); padding-left: 12px; display: inline-flex; align-items: center; gap: 4px; }
.funnel-drop svg { width: 12px; height: 12px; }
.funnel-drop b { color: var(--hot); font-weight: 700; }
.funnel-drop em { font-style: normal; }
.subhead { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 22px 0 10px; padding-top: 16px; border-top: 1px solid var(--line); }
.reasons { display: flex; flex-direction: column; gap: 8px; }
.reason { display: grid; grid-template-columns: 110px 1fr 76px; align-items: center; gap: 14px; font-size: 12.5px; }
.reason-label { font-weight: 600; color: var(--ink-2); }
.reason-track { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.reason-bar { display: block; height: 100%; border-radius: 4px; background: var(--hot); opacity: 0.75; }
.reason-val { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 600; }
@keyframes growX { from { transform: scaleX(0.2); opacity: 0; } to { transform: scaleX(1); opacity: 1; } }

/* IA hoy */
.ai-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.ai-stat { padding: 12px 14px; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--line); }
.ai-stat b { display: block; font-size: 20px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
.ai-stat span { font-size: 12px; color: var(--muted); font-weight: 600; }
.ai-stat.money b { color: var(--ok); }
.ai-live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ai); font-weight: 700; }
.ai-live .dot { animation: pulse 1.6s infinite; }

.feed { display: flex; flex-direction: column; }
.feed-item { display: grid; grid-template-columns: 44px 1fr; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 13px; }
.feed-item:first-child { border-top: 0; }
.feed-time { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; padding-top: 1px; }
.feed-text b { font-weight: 700; }
.feed-who { display: inline-flex; align-items: center; gap: 4px; margin-right: 6px; font-size: 11px; font-weight: 800; padding: 1px 6px; border-radius: 4px; vertical-align: 1px; }
.feed-who.ai { background: var(--ai-soft); color: var(--ai); }
.feed-who.human { background: var(--brand-soft); color: var(--brand-ink); }
.feed-who.lead { background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }

/* Oportunidades prioritarias */
.hot-list { display: flex; flex-direction: column; }
.hot-item {
  display: grid; grid-template-columns: 36px 1fr auto; gap: 12px; align-items: center;
  padding: 12px 0; border-top: 1px solid var(--line);
}
.hot-item:first-child { border-top: 0; padding-top: 4px; }
.hot-main { min-width: 0; }
.hot-name { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.hot-meta { display: flex; flex-wrap: wrap; gap: 6px 10px; font-size: 12px; color: var(--muted); margin-top: 2px; }
.hot-quote { font-size: 12.5px; color: var(--ink-2); margin-top: 4px; font-style: italic; }
.hot-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.hot-value { font-weight: 800; font-variant-numeric: tabular-nums; }

/* Agenda de hoy */
.today { display: flex; flex-direction: column; }
.today-item { display: grid; grid-template-columns: 52px 3px 1fr auto; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.today-item:first-child { border-top: 0; padding-top: 4px; }
.today-time { font-weight: 800; font-variant-numeric: tabular-nums; font-size: 13.5px; }
.today-line { height: 36px; border-radius: 3px; background: var(--line-strong); }
.today-item.st-confirmada .today-line { background: var(--ok); }
.today-item.st-pendiente .today-line { background: var(--warm); }
.today-item.st-cancelada .today-line { background: var(--hot); }
.today-item.st-noshow .today-line { background: var(--hot); }
.today-item.st-asistio .today-line { background: var(--brand); }
.today-main { min-width: 0; }
.today-treat { font-weight: 700; }
.today-who { font-size: 12.5px; color: var(--muted); }

.chart-box { position: relative; height: 240px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); font-weight: 600; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (min-width: 1025px) {
  .sidebar-toggle { display: grid; }
}

@media (max-width: 1280px) {
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .kpi:nth-child(3) { border-right: 0; }
  .kpi:nth-child(-n+3) { border-bottom: 1px solid var(--line); }
}

@media (max-width: 1024px) {
  :root { --sidebar-w: 72px; }
  .brand-text, .nav-item span, .nav-badge, .user-meta { display: none; }
  .nav-item { justify-content: center; padding: 10px; }
  .nav-label { display: none; }
  .nav-group.is-nested { padding-left: 0; }
  .nav-group.is-nested::before { display: none; }
  .nav { gap: 10px; }
  .user-card { padding: 4px; }
  .brand { justify-content: center; padding-left: 0; padding-right: 0; }
  .user { justify-content: center; }
  .sidebar { padding-left: 10px; padding-right: 10px; }
  .grid-3-2, .grid-2-3, .grid-2 { grid-template-columns: 1fr; }
  .page { padding: 24px 24px 40px; }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); width: 264px; padding-left: 12px; padding-right: 12px; }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar .brand-text, .sidebar .nav-item span, .sidebar .nav-badge, .sidebar .user-meta { display: block; }
  .sidebar .nav-item { justify-content: flex-start; padding: 9px 10px; }
  .sidebar .nav-label { display: block; }
  .sidebar .nav-group.is-nested { padding-left: 10px; }
  .sidebar .nav-group.is-nested::before { display: block; }
  .sidebar .nav { gap: 18px; }
  .sidebar .user-card { padding: 8px; }
  .sidebar .brand { justify-content: flex-start; padding-left: 8px; }
  .sidebar .user { justify-content: flex-start; }
  .main { margin-left: 0; }
  .topbar { display: flex; }
  .mobile-nav { display: flex; }
  .page { padding: 18px 16px 90px; }
  .page-head { margin-bottom: 18px; }
  .t-title { font-size: 20px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .kpi { padding: 14px 16px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
  .kpi:nth-child(2n) { border-right: 0; }
  .kpi:nth-child(3) { border-right: 1px solid var(--line); }
  .kpi:nth-last-child(-n+2) { border-bottom: 0; }
  .kpi-value { font-size: 22px; }
  .funnel-row, .funnel-drop, .reason { grid-template-columns: 80px 1fr 52px; gap: 10px; }
  .reason { grid-template-columns: 80px 1fr 72px; font-size: 12px; }
  .reason-val { white-space: nowrap; }
  .funnel-drop .pass { display: none; }
  .ai-stats { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .toasts { left: 16px; right: 16px; bottom: 84px; }
  .toast { max-width: none; }
  .modal { top: auto; bottom: 0; left: 0; transform: none; width: 100%; border-radius: var(--r-xl) var(--r-xl) 0 0; max-height: 92vh; animation: sheetIn var(--t-med); }
  .hot-item { grid-template-columns: 36px 1fr; }
  .hot-side { grid-column: 2; flex-direction: row; align-items: center; justify-content: space-between; }
}
@keyframes sheetIn { from { transform: translateY(24px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ==========================================================================
   Oportunidades — toolbar, Kanban, lista
   ========================================================================== */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .search { flex: 1 1 260px; max-width: 360px; }
.toolbar .select { width: auto; height: 36px; font-size: 13px; font-weight: 600; padding-right: 30px; }
.toolbar .select.is-set { border-color: var(--brand); color: var(--brand-ink); background-color: var(--brand-soft); }
.toolbar-right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.filter-chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-ink); font-size: 12px; font-weight: 700; }
.filter-chip button { display: grid; place-items: center; color: inherit; }
.filter-chip svg { width: 13px; height: 13px; }
.result-count { font-size: 12.5px; color: var(--muted); font-weight: 600; }

.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 14px; align-items: flex-start; scroll-snap-type: x proximity; }
.col { flex: 0 0 248px; scroll-snap-align: start; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-lg); display: flex; flex-direction: column; max-height: calc(100vh - 230px); min-height: 200px; transition: border-color var(--t-fast), background var(--t-fast); }
.col.is-over { border-color: var(--brand); background: var(--brand-soft); }
.col-head { display: flex; align-items: center; gap: 8px; padding: 12px 12px 10px; position: sticky; top: 0; }
.col-name { font-weight: 800; font-size: 13px; }
.col-count { font-size: 11.5px; font-weight: 700; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 0 7px; height: 20px; display: inline-flex; align-items: center; }
.col-total { margin-left: auto; font-size: 11.5px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.col.stage-ganado .col-total { color: var(--ok); }
.col.stage-ganado .col-name::before, .col.stage-perdido .col-name::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 7px; vertical-align: 1px; }
.col.stage-ganado .col-name::before { background: var(--ok); }
.col.stage-perdido .col-name::before { background: var(--hot); }
.col-body { padding: 0 8px 8px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.col-empty { padding: 18px 8px; text-align: center; font-size: 12px; color: var(--muted-2); border: 1px dashed var(--line-strong); border-radius: var(--r-md); }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px;
  cursor: pointer; transition: border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
}
.card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-md); }
.card.is-dragging { opacity: 0.45; transform: rotate(1.5deg); }
.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.card-name { font-weight: 700; font-size: 13.5px; line-height: 1.25; }
.card-treat { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.card-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.card-meta .t-num { color: var(--ink-2); font-weight: 600; }
.card-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.card-value { font-weight: 800; font-size: 13px; font-variant-numeric: tabular-nums; }
.card-rep { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.card-last { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--muted); }
.card-last svg { width: 12px; height: 12px; }
.card-last.is-stale { color: var(--warm); }
.card-last.is-hot { color: var(--hot); }
.pulse { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--ai); animation: pulse 1.6s infinite; margin-right: 2px; }

.list-name { display: flex; align-items: center; gap: 10px; }
.list-name b { display: block; font-weight: 700; }
.list-name small { display: block; font-size: 11.5px; color: var(--muted); }

/* ==========================================================================
   Ficha de oportunidad (drawer)
   ========================================================================== */
.lead-head { padding: 18px 22px 14px; border-bottom: 1px solid var(--line); display: flex; align-items: flex-start; gap: 14px; }
.lead-head .avatar-lg { margin-top: 2px; }
.lead-title { flex: 1; min-width: 0; }
.lead-title h2 { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.lead-sub { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 6px; font-size: 12.5px; color: var(--muted); }
.lead-sub span { display: inline-flex; align-items: center; gap: 5px; }
.lead-sub svg { width: 13px; height: 13px; }
.lead-stage { display: flex; align-items: center; gap: 8px; }
.lead-stage .select { height: 32px; font-size: 12.5px; font-weight: 700; width: auto; }

.lead-actions { display: flex; gap: 8px; flex-wrap: wrap; padding: 12px 22px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.lead-actions .btn { flex: 0 0 auto; }

.lead-grid { display: grid; grid-template-columns: 300px minmax(0, 1fr); min-height: 100%; }
.lead-grid > * { min-width: 0; }
.lead-col { padding: 18px 22px; display: flex; flex-direction: column; gap: 22px; }
.lead-col.is-side { border-right: 1px solid var(--line); background: var(--surface-2); }
.block-title { font-size: 12.5px; font-weight: 800; color: var(--ink-2); margin-bottom: 8px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; text-align: right; }
.kv dd.money { color: var(--ok); font-weight: 800; }

.factors { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; }
.factor { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.factor b { font-variant-numeric: tabular-nums; color: var(--ok); }
.factor b.neg { color: var(--hot); }
.factor-total { display: flex; justify-content: space-between; border-top: 1px solid var(--line); padding-top: 8px; margin-top: 4px; font-weight: 800; }
.score-bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin: 8px 0 10px; }
.score-bar i { display: block; height: 100%; border-radius: 3px; background: var(--hot); }
.score-bar.warm i { background: var(--warm); }
.score-bar.cool i { background: var(--cool); }

.seq { display: flex; flex-direction: column; gap: 0; }
.seq-step { display: grid; grid-template-columns: 18px 1fr; gap: 10px; padding: 8px 0; position: relative; }
.seq-step::before { content: ""; position: absolute; left: 8px; top: 26px; bottom: -8px; width: 2px; background: var(--line); }
.seq-step:last-child::before { display: none; }
.seq-dot { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line-strong); background: var(--surface); display: grid; place-items: center; margin-top: 1px; }
.seq-dot svg { width: 10px; height: 10px; }
.seq-step.is-sent .seq-dot { border-color: var(--ok); background: var(--ok); color: #fff; }
.seq-step.is-next .seq-dot { border-color: var(--ai); }
.seq-when { font-size: 11.5px; font-weight: 800; color: var(--muted); }
.seq-step.is-next .seq-when { color: var(--ai); }
.seq-msg { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; line-height: 1.45; }
.seq-step.is-sent .seq-msg { color: var(--muted); }

.chat { display: flex; flex-direction: column; gap: 10px; }
.chat-ctrl { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface); font-size: 12.5px; font-weight: 700; }
.chat-ctrl.is-ai { border-color: #dcd4fb; background: var(--ai-soft); color: var(--ai); }
.chat-ctrl.is-human { border-color: #d7dcf7; background: var(--brand-soft); color: var(--brand-ink); }
.chat-ctrl .btn { margin-left: auto; flex: 0 0 auto; }
.chat-ctrl-text { flex: 1; min-width: 0; }
.msgs { display: flex; flex-direction: column; gap: 8px; padding: 4px 0; }
.msg { max-width: 82%; padding: 9px 12px; border-radius: 14px; font-size: 13px; line-height: 1.45; position: relative; }
.msg time { display: block; font-size: 10.5px; margin-top: 4px; opacity: 0.7; font-variant-numeric: tabular-nums; }
.msg-lead { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg-ai { align-self: flex-end; background: var(--ai-soft); color: #3d2a8a; border-bottom-right-radius: 4px; }
.msg-human { align-self: flex-end; background: var(--ink); color: #fff; border-bottom-right-radius: 4px; }
.msg-who { font-size: 10.5px; font-weight: 800; letter-spacing: 0.02em; opacity: 0.75; margin-bottom: 2px; }
.chat-input { display: flex; gap: 8px; }
.chat-input .input { flex: 1; }

.tl { display: flex; flex-direction: column; }
.tl-item { display: grid; grid-template-columns: 22px 1fr auto; gap: 10px; padding: 7px 0; position: relative; align-items: start; }
.tl-item::before { content: ""; position: absolute; left: 10px; top: 26px; bottom: -6px; width: 2px; background: var(--line); }
.tl-item:last-child::before { display: none; }
.tl-dot { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted-2); }
.tl-dot svg { width: 12px; height: 12px; }
.tl-item.is-done .tl-dot { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.tl-item.is-current .tl-dot { background: var(--brand); border-color: transparent; color: #fff; }
.tl-item.is-lost .tl-dot { background: var(--hot-soft); border-color: transparent; color: var(--hot); }
.tl-text { font-size: 13px; font-weight: 600; padding-top: 2px; }
.tl-text small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; }
.tl-item:not(.is-done):not(.is-current):not(.is-lost) .tl-text { color: var(--muted-2); font-weight: 500; }
.tl-when { font-size: 11.5px; color: var(--muted); padding-top: 4px; white-space: nowrap; }

.mini-list { display: flex; flex-direction: column; }
.mini-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 12.5px; }
.mini-item:first-child { border-top: 0; }
.mini-item b { font-weight: 700; }
.mini-item .t-small { margin-left: auto; white-space: nowrap; }

.slots { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.slot { height: 34px; border-radius: var(--r-sm); border: 1px solid var(--line-strong); font-size: 12.5px; font-weight: 700; color: var(--ink-2); background: var(--surface); transition: all var(--t-fast); }
.slot:hover { border-color: var(--brand); color: var(--brand-ink); }
.slot.is-active { background: var(--ink); color: #fff; border-color: var(--ink); }
.slot[disabled] { opacity: 0.35; text-decoration: line-through; cursor: not-allowed; }

@media (max-width: 900px) {
  .lead-grid { grid-template-columns: 1fr; }
  .lead-col.is-side { border-right: 0; border-bottom: 1px solid var(--line); }
}
@media (max-width: 768px) {
  .toolbar .search { max-width: none; flex-basis: 100%; }
  .toolbar-right { margin-left: 0; width: 100%; justify-content: space-between; }
  .board { margin: 0 -16px; padding: 0 16px 14px; }
  .col { flex-basis: 84vw; max-height: none; }
  .lead-head { padding: 14px 16px 12px; }
  .lead-title h2 { font-size: 18px; }
  .lead-sub span:nth-child(2), .lead-sub span:nth-child(4), .lead-sub span:nth-child(5) { display: none; }
  .lead-head .avatar-lg { display: none; }
  .lead-actions { padding: 10px 16px; }
  .lead-actions .btn span { display: none; }
  .lead-actions .btn { flex: 1 1 0; padding: 0 8px; }
  .lead-col { padding: 16px; }
  .slots { grid-template-columns: repeat(3, 1fr); }
}
