@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

/* ===== Tokens (alineados al prototipo VISAL.travels) ===== */
:root {
  --radius: 0.875rem;
  --background: oklch(0.985 0.003 280);
  --foreground: oklch(0.2 0.04 280);
  --card: oklch(1 0 0);
  --primary: oklch(0.55 0.22 258);
  --primary-foreground: oklch(0.99 0.005 280);
  --primary-soft: oklch(0.96 0.025 258);
  --muted: oklch(0.97 0.008 280);
  --muted-foreground: oklch(0.5 0.025 280);
  --accent-foreground: oklch(0.4 0.18 258);
  --gold: oklch(0.78 0.14 70);
  --gold-foreground: oklch(0.22 0.04 70);
  --destructive: oklch(0.6 0.22 22);
  --warning: oklch(0.74 0.16 65);
  --warning-foreground: oklch(0.22 0.05 65);
  --success: oklch(0.62 0.16 155);
  --border: oklch(0.93 0.008 280);
  --sidebar: oklch(1 0 0);
  --sidebar-border: oklch(0.94 0.008 280);
  --shadow-soft: 0 1px 2px oklch(0.4 0.15 280 / 0.04), 0 1px 3px oklch(0.4 0.15 280 / 0.05);
  --shadow-card: 0 4px 24px -8px oklch(0.4 0.15 280 / 0.10);
  --gradient-violet: linear-gradient(135deg, oklch(0.6 0.22 258), oklch(0.45 0.24 262));
}

html, body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background-color: var(--background);
  color: var(--foreground);
  -webkit-font-smoothing: antialiased;
}

a, .btn-link { color: var(--primary); }
h1, h2, h3 { letter-spacing: -0.01em; }

/* Catalogos simples de configuracion */
.cat-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 14px; }
.cat-eyebrow { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .16em; color: var(--primary); }
.cat-title { font-size: 22px; margin: 2px 0 0; }
.cat-sub { color: var(--muted-foreground); font-size: 13px; margin: 2px 0 0; }
.cat-card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 14px; max-width: 760px; }
.cat-actions { display: flex; gap: 4px; white-space: nowrap; }
.cat-empty { color: var(--muted-foreground); font-size: 13px; padding: 12px 2px; text-align: center; }
.cat-alert { padding: 10px 14px; border-radius: 8px; background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; font-size: 13px; margin-bottom: 12px; max-width: 760px; }

/* Modulos de configuracion (aseguradoras, roles, usuarios, pacientes...) */
.ase-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 14px; }
.ase-eyebrow { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .16em; color: var(--primary); }
.ase-title { font-size: 22px; margin: 2px 0 0; }
.ase-alert { padding: 10px 14px; border-radius: 8px; background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; font-size: 13px; margin-bottom: 12px; }
.ase-ok { padding: 10px 14px; border-radius: 8px; background: #ecfdf5; border: 1px solid #a7f3d0; color: #047857; font-size: 13px; margin-bottom: 12px; }
.ase-grid { display: flex; gap: 14px; align-items: flex-start; }
/* Lista de items: scroll interno propio para que cuando crezca a cientos de
   items la pagina no se ponga larguisima y el detalle siga visible al lado.
   Maximo 75% del viewport menos el topbar. */
.ase-list { width: 300px; flex-shrink: 0; max-height: calc(100vh - 160px); overflow-y: auto; position: sticky; top: 12px; }
.ase-detail { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.ase-card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 14px; }
.ase-card-h { font-weight: 700; font-size: 14px; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ase-empty { color: var(--muted-foreground); font-size: 13px; padding: 12px 2px; text-align: center; }
.ase-li { display: block; width: 100%; text-align: left; border: 1px solid var(--border); border-radius: 8px; background: var(--card); padding: 8px 10px; margin-bottom: 6px; cursor: pointer; }
.ase-li:hover { border-color: var(--primary); }
.ase-li.sel { border-color: var(--primary); background: var(--primary-soft); }
.ase-li-name { font-weight: 600; font-size: 13px; color: var(--foreground); }
.ase-li-sub { font-size: 11px; color: var(--muted-foreground); }
.ase-form { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.ase-f { display: flex; flex-direction: column; gap: 3px; }
.ase-f label { font-size: 11px; font-weight: 700; color: var(--muted-foreground); text-transform: uppercase; letter-spacing: .03em; }
.ase-f-wide { grid-column: span 2; }
.ase-f-full { grid-column: span 4; }
.ase-actions { display: flex; gap: 8px; margin-top: 12px; }
.ase-chk { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.ase-row-actions { display: flex; gap: 4px; white-space: nowrap; }
.ms-auto { margin-left: auto; }
.rol-grupo { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--primary); margin: 12px 0 4px; }
.rol-table th { font-size: 11px; text-transform: uppercase; color: var(--muted-foreground); text-align: center; }
.rol-table td { text-align: center; }
.rol-table td:first-child { text-align: left; }
@media (max-width: 1100px) {
  .ase-grid { flex-direction: column; }
  /* En pantallas chicas la lista vuelve a su altura natural y el scroll lo
     maneja la pagina; sticky tampoco aplica con la columna apilada. */
  .ase-list { width: 100%; max-height: none; position: static; overflow: visible; }
  .ase-form { grid-template-columns: repeat(2, 1fr); }
  .ase-f-wide, .ase-f-full { grid-column: span 2; }
}

/* ===== Layout shell ===== */
.visal-shell { display: flex; min-height: 100vh; }

.visal-sidebar {
  width: 268px;
  flex-shrink: 0;
  background: var(--sidebar);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.visal-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.visal-topbar {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: oklch(1 0 0 / 0.7);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.visal-content { padding: 26px 30px; width: 100%; }

/* Piezas del menu movil: ocultas en escritorio. */
.visal-nav-toggle { display: none; }
.visal-nav-collapse { display: none; }
.visal-nav-overlay { display: none; }
.visal-hamburger { display: none; }
.visal-hamburger-mobile { display: none; }
.visal-topbar-brand { display: none; }

/* Boton "Mostrar menu" en escritorio: solo visible cuando el sidebar esta colapsado.
   El boton vive en el topbar; al inicio (sidebar abierto) esta oculto. */
.visal-hamburger-desktop {
  display: none;
  align-items: center; justify-content: center;
  width: 38px; height: 38px;
  border-radius: 10px; cursor: pointer; color: var(--foreground);
  margin-right: auto; /* lo empuja a la izquierda del topbar */
}
.visal-hamburger-desktop:hover { background: var(--muted); }
.visal-hamburger-desktop svg { width: 22px; height: 22px; }

/* Boton interno del sidebar para colapsarlo (chevron izquierdo). */
.visal-nav-collapse-btn {
  position: absolute; top: 10px; right: 8px; z-index: 2;
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  border-radius: 8px; cursor: pointer; color: var(--muted-foreground, #64748b);
  background: transparent; transition: background .15s ease, color .15s ease;
}
.visal-nav-collapse-btn:hover { background: var(--muted); color: var(--foreground); }
.visal-nav-collapse-btn svg { width: 18px; height: 18px; }

/* Asegura que el sidebar tenga contexto de posicion para el boton interno. */
.visal-sidebar { position: sticky; }

/* === Colapsado en escritorio === */
.visal-nav-collapse:checked ~ .visal-sidebar {
  width: 0;
  min-width: 0;
  border-right: 0;
  overflow: hidden;
}
.visal-nav-collapse:checked ~ .visal-main .visal-hamburger-desktop {
  display: inline-flex;
}

/* ===== Sidebar header / brand ===== */
.visal-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid var(--sidebar-border);
}
/* Variante en columna: logo grande arriba, nombre debajo, lema debajo.
   Es la que usamos en el tenant para que el logo se vea completo. */
.visal-brand.visal-brand-stack {
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 12px;
  text-align: center;
}
.visal-logo {
  position: relative;
  width: 38px; height: 38px;
  border-radius: 12px;
  background: var(--gradient-violet);
  display: grid; place-items: center;
  box-shadow: var(--shadow-soft);
  color: #fff;
}
/* Logo subido por el tenant: bloque ancho rectangular (~170x60) para que se
   vea completo sin recortar las proporciones del archivo. Sin gradiente. */
.visal-logo.visal-logo-wide {
  width: 100%;
  max-width: 200px;
  height: 64px;
  border-radius: 10px;
  background: #fff;
  padding: 4px;
  box-shadow: var(--shadow-soft);
}
.visal-logo svg { width: 18px; height: 18px; transform: rotate(-45deg); }
/* Logo cuadrado (default): el SVG centrado en el bloque 38x38. */
.visal-logo img {
  width: 100%; height: 100%; object-fit: cover;
  border-radius: 12px; display: block;
}
/* Logo wide del tenant: object-fit contain para no recortar la imagen. */
.visal-logo.visal-logo-wide img {
  object-fit: contain;
  border-radius: 6px;
  background: #fff;
}
.visal-logo:has(img):not(.visal-logo-wide) { background: #fff; }
.visal-logo:not(.visal-logo-wide)::after {
  content: ""; position: absolute; bottom: -2px; right: -2px;
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--gold); border: 2px solid var(--sidebar);
}
.visal-brand-text { width: 100%; }
.visal-brand-stack .visal-brand-text { text-align: center; }
.visal-brand-name { font-weight: 800; font-size: 15px; letter-spacing: -0.02em; line-height: 1.15; }
.visal-brand-name span { color: var(--primary); }
.visal-brand-sub { font-size: 10px; text-transform: uppercase; letter-spacing: 0.14em; color: var(--muted-foreground); font-weight: 600; margin-top: 4px; }

.visal-agency {
  margin: 12px 14px 4px;
  border-radius: 10px;
  background: var(--primary-soft);
  border: 1px solid oklch(0.55 0.22 258 / 0.15);
  padding: 10px 12px;
}
.visal-agency .lbl { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: oklch(0.55 0.22 258 / 0.85); }
.visal-agency .name { font-size: 14px; font-weight: 600; }
.visal-agency .meta { font-size: 11px; color: var(--muted-foreground); }

/* ===== Sidebar nav ===== */
.visal-nav { flex: 1; overflow-y: auto; padding: 8px 10px; }
.visal-nav-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.14em;
  color: oklch(0.5 0.025 280 / 0.8); padding: 14px 8px 6px;
}
.visal-nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 9px;
  color: oklch(0.35 0.04 280); text-decoration: none;
  font-size: 13.5px; font-weight: 500; line-height: 1.2;
  transition: background .12s, color .12s;
}
.visal-nav-link svg { width: 17px; height: 17px; flex-shrink: 0; opacity: .85; }
.visal-nav-link:hover { background: var(--muted); color: var(--foreground); }
.visal-nav-link.active { background: var(--primary-soft); color: var(--accent-foreground); font-weight: 600; }
.visal-nav-link.active svg { opacity: 1; color: var(--primary); }
.visal-nav-badge { margin-left: auto; font-size: 10px; font-weight: 700; padding: 1px 7px; border-radius: 7px; background: oklch(0.55 0.22 258 / 0.12); color: var(--primary); }

/* ===== Sidebar footer (user) ===== */
.visal-user { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--sidebar-border); }
.visal-avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, oklch(0.82 0.13 70), oklch(0.74 0.15 70)); color: var(--gold-foreground); display: grid; place-items: center; font-weight: 700; font-size: 12px; flex-shrink: 0; }
.visal-user .nm { font-size: 12.5px; font-weight: 600; }
.visal-user .rl { font-size: 11px; color: var(--muted-foreground); }
.visal-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); margin-left: auto; }

/* topbar user chip */
.visal-user-chip { font-size: 13px; color: var(--muted-foreground); }
.visal-user-chip strong { color: var(--foreground); font-weight: 600; }

/* ===== Page header ===== */
.page-eyebrow { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.16em; color: var(--primary); }
.page-title { font-size: 1.7rem; font-weight: 800; margin: 4px 0 2px; }
.page-title span { color: var(--primary); }
.page-sub { font-size: 0.9rem; color: var(--muted-foreground); margin-bottom: 22px; }

/* ===== KPI cards ===== */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; max-width: 1000px; }
.kpi-card { background: var(--card); border: 1px solid var(--border); border-radius: 1.25rem; padding: 18px 20px; box-shadow: var(--shadow-soft); }
.kpi-top { display: flex; align-items: flex-start; justify-content: space-between; }
.kpi-icon { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; }
.kpi-icon svg { width: 18px; height: 18px; }
.kpi-icon.tone-primary { background: var(--primary-soft); color: var(--primary); }
.kpi-icon.tone-gold { background: oklch(0.78 0.14 70 / 0.16); color: var(--gold-foreground); }
.kpi-icon.tone-success { background: oklch(0.62 0.16 155 / 0.15); color: var(--success); }
.kpi-icon.tone-danger { background: oklch(0.6 0.22 22 / 0.10); color: var(--destructive); }
.kpi-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted-foreground); font-weight: 700; margin-top: 14px; }
.kpi-value { font-size: 2rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi-hint { font-size: 11px; color: var(--muted-foreground); }

/* ===== Cards (override bootstrap) ===== */
.card { border: 1px solid var(--border); border-radius: 1.1rem; box-shadow: var(--shadow-card); }
.card-title { font-weight: 700; letter-spacing: -0.01em; }

/* ===== Buttons (override bootstrap) ===== */
.btn { border-radius: 0.6rem; font-weight: 600; font-size: 0.875rem; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-foreground); }
.btn-primary:hover, .btn-primary:focus { background: oklch(0.5 0.22 258); border-color: oklch(0.5 0.22 258); color: #fff; }
.btn-outline-secondary { color: var(--foreground); border-color: var(--border); background: var(--card); }
.btn-outline-secondary:hover { background: var(--muted); color: var(--foreground); }
.btn-outline-success { color: var(--success); border-color: oklch(0.62 0.16 155 / 0.5); }
.btn-outline-success:hover { background: var(--success); color: #fff; }
.btn-outline-danger { color: var(--destructive); border-color: oklch(0.6 0.22 22 / 0.5); }
.btn-outline-danger:hover { background: var(--destructive); color: #fff; }
.btn:focus, .btn:active:focus, .form-control:focus { box-shadow: 0 0 0 3px oklch(0.55 0.22 258 / 0.25); }

/* ===== Forms (override bootstrap) ===== */
.form-control { border-radius: 0.55rem; border-color: var(--border); font-size: 0.9rem; }
.form-control:focus { border-color: var(--primary); }
.form-label { font-size: 0.8rem; font-weight: 600; color: var(--muted-foreground); }

/* ===== Tables (override bootstrap) ===== */
.table { --bs-table-bg: transparent; color: var(--foreground); }
.table > thead th { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted-foreground); font-weight: 700; border-bottom: 1px solid var(--border); padding-bottom: 10px; }
.table > tbody td { border-bottom: 1px solid var(--border); padding: 12px 8px; vertical-align: middle; }
.table.table-hover > tbody > tr:hover > * { background: var(--muted); }

/* ===== Badges (override bootstrap bg-*) ===== */
.badge { font-weight: 700; font-size: 10.5px; padding: 4px 9px; border-radius: 7px; letter-spacing: 0.02em; }
.badge.bg-success { background: oklch(0.62 0.16 155 / 0.15) !important; color: var(--success) !important; }
.badge.bg-info { background: var(--primary-soft) !important; color: var(--primary) !important; }
.badge.bg-danger { background: oklch(0.6 0.22 22 / 0.12) !important; color: var(--destructive) !important; }
.badge.bg-warning { background: oklch(0.78 0.14 70 / 0.18) !important; color: var(--warning-foreground) !important; }
.badge.bg-secondary { background: var(--muted) !important; color: var(--muted-foreground) !important; }

.text-muted { color: var(--muted-foreground) !important; }

/* ===== Login ===== */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background:
  radial-gradient(1200px 600px at 50% -10%, oklch(0.93 0.05 258), transparent), var(--background); }
.login-card { width: 380px; background: var(--card); padding: 34px; border-radius: 1.25rem; box-shadow: var(--shadow-card); border: 1px solid var(--border); }
.login-logo { width: 48px; height: 48px; border-radius: 14px; background: var(--gradient-violet); display: grid; place-items: center; color: #fff; margin-bottom: 16px; }
.login-logo svg { width: 22px; height: 22px; transform: rotate(-45deg); }
.login-title { font-size: 1.4rem; font-weight: 800; letter-spacing: -0.02em; }
.login-title span { color: var(--primary); }

/* ===== Auth (login + registro autogestion, diseno de dos paneles) ===== */
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; background: #fff; }
@media (max-width: 900px) { .auth-shell { grid-template-columns: 1fr; } .auth-aside { display: none !important; } }

/* Panel izquierdo azul Visal */
.auth-aside { position: relative; overflow: hidden; color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between;
  background: linear-gradient(-45deg, #1565c0, #1976d2, #1e88e5, #0d47a1); background-size: 300% 300%; animation: authGradient 14s ease infinite; }
@keyframes authGradient { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }
.auth-aside-deco { position: absolute; width: 220px; height: 220px; border-radius: 50%; background: radial-gradient(circle, rgba(255,255,255,.16), transparent 65%); pointer-events: none; }
.auth-deco-tr { top: -60px; right: -60px; }
.auth-deco-bl { bottom: -60px; left: -60px; }
.auth-brand { display: flex; align-items: center; gap: 12px; position: relative; z-index: 1; }
.auth-brand-logo { width: 46px; height: 46px; border-radius: 13px; background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.25); display: grid; place-items: center; backdrop-filter: blur(6px); }
.auth-brand-logo svg { width: 22px; height: 22px; transform: rotate(-45deg); }
.auth-brand-logo-img { height: 46px; max-width: 180px; object-fit: contain; border-radius: 10px; background: rgba(255,255,255,.92); padding: 6px 10px; }
.auth-brand-name { font-size: 1.45rem; font-weight: 800; letter-spacing: -0.02em; }
.auth-aside-body { position: relative; z-index: 1; max-width: 420px; }
.auth-aside-body h2 { font-size: 2.1rem; font-weight: 800; line-height: 1.15; letter-spacing: -0.02em; margin: 0 0 14px; }
.auth-aside-body p { font-size: 1rem; line-height: 1.6; color: rgba(255,255,255,.9); margin: 0 0 22px; }
.auth-dots { display: flex; gap: 8px; }
.auth-dots span { width: 8px; height: 8px; border-radius: 99px; background: rgba(255,255,255,.45); }
.auth-dots span:first-child { width: 22px; background: #fff; }

/* Panel derecho formularios */
.auth-main { display: flex; flex-direction: column; padding: 40px clamp(24px, 6vw, 80px); }
.auth-form-wrap { flex: 1; display: flex; flex-direction: column; justify-content: center; max-width: 440px; width: 100%; margin: 0 auto; }
.auth-pane-signup { display: none; }
.auth-shell.is-signup .auth-pane-login { display: none; }
.auth-shell.is-signup .auth-pane-signup { display: block; }
.auth-head { margin-bottom: 26px; }
.auth-head h1 { font-size: 1.9rem; font-weight: 800; letter-spacing: -0.02em; color: var(--foreground); margin: 0 0 6px; }
.auth-head p { font-size: .92rem; color: var(--muted-foreground); margin: 0; }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-field { display: flex; flex-direction: column; gap: 6px; }
.auth-field label { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted-foreground); }
.auth-field input { width: 100%; padding: 13px 15px; border-radius: 12px; border: 1px solid var(--border); background: var(--background); font-size: .95rem; transition: border-color .15s, box-shadow .15s; }
.auth-field input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px oklch(0.62 0.2 258 / .15); background: #fff; }
.auth-select { width: 100%; padding: 13px 15px; border-radius: 12px; border: 1px solid var(--border); background: var(--background); font-size: .95rem; transition: border-color .15s, box-shadow .15s; appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'/%3e%3c/svg%3e"); background-repeat: no-repeat; background-position: right 12px center; background-size: 18px; padding-right: 40px; }
.auth-select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px oklch(0.62 0.2 258 / .15); background-color: #fff; }
.auth-input-icon { position: relative; }
.auth-input-icon input { padding-right: 78px; }
.auth-eye { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); background: none; border: none; font-size: .68rem; font-weight: 700; letter-spacing: .04em; color: var(--muted-foreground); cursor: pointer; }
.auth-eye:hover { color: var(--primary); }
.auth-submit { margin-top: 8px; display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 14px; border: none; border-radius: 12px; background: var(--gradient-violet, #1565c0); color: #fff; font-size: .98rem; font-weight: 700; cursor: pointer; box-shadow: 0 10px 24px -10px rgba(21,101,192,.6); transition: transform .12s, box-shadow .15s; }
.auth-submit:hover { box-shadow: 0 14px 30px -10px rgba(21,101,192,.7); }
.auth-submit:active { transform: scale(.99); }
.auth-submit svg { width: 16px; height: 16px; }
.auth-switch { margin-top: 24px; text-align: center; font-size: .9rem; color: var(--muted-foreground); }
.auth-switch button { background: none; border: none; color: var(--primary); font-weight: 700; cursor: pointer; margin-left: 4px; }
.auth-switch button:hover { text-decoration: underline; }
.auth-alert { padding: 11px 14px; border-radius: 10px; font-size: .88rem; margin-bottom: 18px; }
.auth-alert-error { background: oklch(0.95 0.04 25); color: oklch(0.5 0.2 25); border: 1px solid oklch(0.85 0.08 25); }
.auth-alert-ok { background: oklch(0.95 0.05 150); color: oklch(0.45 0.13 150); border: 1px solid oklch(0.85 0.09 150); }
.auth-label-row { display: flex; justify-content: space-between; align-items: center; }
.auth-forgot { font-size: .72rem; font-weight: 700; color: var(--primary); text-decoration: none; }
.auth-forgot:hover { text-decoration: underline; }
.auth-legal { font-size: .76rem; line-height: 1.5; color: var(--muted-foreground); margin: 2px 0 0; }
.auth-footer { text-align: center; font-size: .76rem; color: var(--muted-foreground); padding-top: 24px; border-top: 1px solid var(--border); margin-top: 24px; }
.auth-providers { display: grid; grid-template-columns: 1fr; gap: 10px; margin-bottom: 18px; }
.auth-provider { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--background); font-size: .9rem; font-weight: 600; color: var(--foreground); cursor: pointer; }
.auth-provider[disabled] { opacity: .65; cursor: not-allowed; }
.auth-provider small { font-size: .68rem; color: var(--muted-foreground); font-weight: 600; }
.auth-hint { margin: -8px 0 14px; font-size: .8rem; color: #dc2626; }
.auth-input-error { border-color: #dc2626 !important; box-shadow: 0 0 0 3px rgba(220, 38, 38, .12); }
.auth-divider { position: relative; text-align: center; margin: 18px 0; }
.auth-divider::before { content: ""; position: absolute; top: 50%; left: 0; right: 0; height: 1px; background: var(--border); }
.auth-divider span { position: relative; background: #fff; padding: 0 12px; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; color: var(--muted-foreground); }

/* ===== Pagina Marca (branding super admin) ===== */
.brand-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 22px; align-items: start; }
@media (max-width: 1000px) { .brand-cols { grid-template-columns: 1fr; } }
.brand-form { padding: 22px; }
.brand-logo-current { display: flex; align-items: center; gap: 14px; margin-top: 12px; padding: 12px; border: 1px dashed var(--border); border-radius: 12px; }
.brand-logo-current img { height: 46px; max-width: 200px; object-fit: contain; }
.brand-preview { position: relative; }
.brand-preview-aside { border-radius: 16px; overflow: hidden; color: #fff; padding: 32px; min-height: 320px; display: flex; flex-direction: column; justify-content: space-between;
  background: linear-gradient(-45deg, #1565c0, #1976d2, #1e88e5, #0d47a1); background-size: 300% 300%; animation: authGradient 14s ease infinite; }
.bp-brand { display: flex; align-items: center; gap: 10px; }
.bp-brand img { height: 40px; max-width: 160px; object-fit: contain; background: rgba(255,255,255,.92); padding: 5px 9px; border-radius: 9px; }
.bp-logo { width: 40px; height: 40px; border-radius: 11px; background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.25); display: grid; place-items: center; }
.bp-logo svg { width: 19px; height: 19px; transform: rotate(-45deg); }
.bp-brand span { font-size: 1.2rem; font-weight: 800; }
.bp-body h3 { font-size: 1.6rem; font-weight: 800; line-height: 1.15; margin: 0 0 10px; }
.bp-body p { font-size: .92rem; line-height: 1.55; color: rgba(255,255,255,.9); margin: 0; }
.brand-preview-label { text-align: center; font-size: .76rem; color: var(--muted-foreground); margin-top: 10px; }
.brand-suggested { display: flex; gap: 10px; flex-wrap: wrap; }
.brand-suggested-item { padding: 8px; border: 2px solid var(--border); border-radius: 12px; background: #fff; cursor: pointer; }
.brand-suggested-item.active { border-color: var(--primary); box-shadow: 0 0 0 3px oklch(0.62 0.2 258 / .15); }
.brand-suggested-item img { height: 40px; max-width: 130px; object-fit: contain; display: block; }

/* error boundary (keep functional) */
.blazor-error-boundary { background: var(--destructive); padding: 1rem; color: white; border-radius: 8px; }
.blazor-error-boundary::after { content: "Ha ocurrido un error."; }
.validation-message { color: var(--destructive); }

/* ===== Module header (icono + eyebrow + titulo + acciones), estilo prototipo ===== */
.module-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.module-icon { width: 38px; height: 38px; border-radius: 11px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; }
.module-icon svg { width: 19px; height: 19px; }
.module-eyebrow { display: flex; align-items: center; gap: 10px; }
.module-eyebrow span { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.18em; color: var(--primary); }

/* ===== Plan cards (estilo prototipo) ===== */
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; max-width: 1100px; }
.plan-card { background: var(--card); border: 1px solid var(--border); border-radius: 1.25rem; box-shadow: var(--shadow-soft); padding: 24px; display: flex; flex-direction: column; }
.plan-card.featured { border-color: oklch(0.55 0.22 258 / 0.4); box-shadow: 0 0 0 1px oklch(0.55 0.22 258 / 0.3), var(--shadow-card); }
.plan-card.gold { border-color: oklch(0.78 0.14 70 / 0.45); }
.plan-card .pname { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted-foreground); font-weight: 700; }
.plan-card .pprice { font-size: 1.9rem; font-weight: 800; line-height: 1.15; margin-top: 4px; }
.plan-card .pprice small { font-size: 0.85rem; font-weight: 600; color: var(--muted-foreground); }
.plan-features { list-style: none; padding: 0; margin: 18px 0 0; display: flex; flex-direction: column; gap: 9px; font-size: 0.9rem; }
.plan-features li { display: flex; align-items: center; gap: 8px; }
.plan-check { width: 16px; height: 16px; color: var(--success); flex-shrink: 0; }
.plan-edit { margin-top: 22px; }

/* ===== Modal ===== */
.modal-overlay { position: fixed; inset: 0; background: oklch(0.2 0.04 280 / 0.45); backdrop-filter: blur(2px); display: grid; place-items: center; z-index: 50; padding: 20px; }
/* pointer-events:auto anula el .modal-dialog de Bootstrap (que lo pone en none para
   dejar pasar el clic al backdrop); sin esto no se puede enfocar/escribir en los inputs. */
.modal-dialog { pointer-events: auto; background: var(--card); border-radius: 1.1rem; box-shadow: 0 16px 40px -12px oklch(0.42 0.22 258 / 0.28); width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 1.05rem; font-weight: 700; margin: 0; }
.modal-close { display: grid; place-items: center; width: 34px; height: 34px; margin: -6px -6px -6px 0; border-radius: 0.6rem; background: none; border: none; font-size: 1.4rem; color: var(--muted-foreground); cursor: pointer; line-height: 1; transition: background .15s, color .15s; }
.modal-close:hover { background: var(--muted); color: var(--foreground); }
.modal-body { padding: 20px 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 22px; border-top: 1px solid var(--border); }
.field { margin-bottom: 14px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ===== Placeholder "Proximamente" ===== */
.coming-soon { max-width: 1040px; border: 1px dashed var(--border); border-radius: 1.25rem; background: var(--card); padding: 56px 24px; display: flex; flex-direction: column; align-items: center; text-align: center; }
.coming-soon-icon { width: 56px; height: 56px; border-radius: 16px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; margin-bottom: 16px; }
.coming-soon-icon svg { width: 26px; height: 26px; }
.coming-soon h3 { font-size: 1.1rem; font-weight: 700; margin: 0; }
.coming-soon p { font-size: 0.9rem; color: var(--muted-foreground); margin: 6px 0 0; max-width: 420px; }

/* ===== Pares etiqueta/valor (config Wompi) ===== */
.wlbl { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted-foreground); font-weight: 700; }
.wval { font-size: 0.92rem; font-weight: 600; margin-top: 2px; margin-bottom: 4px; }

/* ===== Mi cuenta (tenant) ===== */
.acct-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; max-width: 1040px; }
.acct-logo { width: 64px; height: 64px; border-radius: 14px; object-fit: cover; border: 1px solid var(--border); background: var(--card); flex-shrink: 0; }
.acct-logo-empty { display: grid; place-items: center; font-weight: 800; font-size: 1.2rem; color: var(--primary); background: var(--primary-soft); }

/* ===== Pipeline Kanban ===== */
.kanban { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.kb-col { flex: 0 0 270px; background: var(--muted); border: 1px solid var(--border); border-radius: 1rem; display: flex; flex-direction: column; max-height: calc(100vh - 230px); }
.kb-col.drop-hover { outline: 2px dashed var(--primary); outline-offset: -2px; }
.kb-col-head { padding: 12px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kb-col-title { font-weight: 700; font-size: 0.92rem; }
.kb-col-meta { font-size: 11px; color: var(--muted-foreground); margin-top: 2px; }
.kb-col-count { font-size: 10px; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); }
.kb-body { padding: 10px; display: flex; flex-direction: column; gap: 9px; overflow-y: auto; flex: 1; min-height: 60px; }
.kb-card { background: var(--card); border: 1px solid var(--border); border-radius: 0.75rem; padding: 11px 12px; box-shadow: var(--shadow-soft); cursor: pointer; }
.kb-card:hover { border-color: oklch(0.55 0.22 258 / 0.4); }
.kb-card .nm { font-weight: 700; font-size: 0.9rem; }
.kb-card .meta { font-size: 11.5px; color: var(--muted-foreground); margin-top: 3px; }
.kb-card .val { font-weight: 700; font-size: 0.92rem; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kb-card .ase { width: 22px; height: 22px; border-radius: 50%; background: var(--gradient-violet); color: #fff; font-size: 10px; font-weight: 800; display: grid; place-items: center; }
.kb-cardrow { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.kb-empty { font-size: 12px; color: var(--muted-foreground); text-align: center; padding: 14px 0; }

/* ===== Pipeline: tarjeta enriquecida (estilo prototipo) ===== */
.kb-card.stale { box-shadow: var(--shadow-soft), -3px 0 0 var(--destructive) inset; padding-left: 15px; border-color: oklch(0.6 0.22 22 / 0.35); }
.kb-top { display: flex; align-items: center; justify-content: space-between; font-size: 11px; color: var(--muted-foreground); font-weight: 600; margin-bottom: 8px; gap: 8px; }
.kb-time { display: inline-flex; align-items: center; gap: 5px; }
.kb-time svg { width: 11px; height: 11px; }
.kb-badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 7px; border-radius: 999px; font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em; white-space: nowrap; }
.kb-badge.stale { background: oklch(0.6 0.22 22 / 0.10); color: var(--destructive); }
.kb-badge svg { width: 10px; height: 10px; }
.kb-archive { margin-left: auto; background: none; border: none; padding: 2px; border-radius: 6px; color: var(--muted-foreground); cursor: pointer; display: inline-grid; place-items: center; opacity: 0.5; }
.kb-card:hover .kb-archive { opacity: 1; }
.kb-archive:hover { background: var(--muted); color: var(--destructive); }
.kb-archive svg { width: 14px; height: 14px; }

/* Lead con mensaje del cliente sin responder */
.kb-card.needsreply { background: oklch(0.97 0.045 50); border-color: oklch(0.72 0.16 55 / 0.55); box-shadow: var(--shadow-soft), -3px 0 0 oklch(0.7 0.17 50) inset; padding-left: 15px; }
.kb-card.needsreply:hover { border-color: oklch(0.7 0.17 50); }
.kb-badge.reply { background: oklch(0.7 0.17 50 / 0.16); color: oklch(0.5 0.16 45); }
.kb-unread { display: inline-flex; align-items: center; gap: 5px; margin: 4px 0 2px; font-size: 11px; font-weight: 700; color: oklch(0.5 0.16 45); }
.kb-unread svg { width: 12px; height: 12px; }

/* Barra de busqueda + orden + filtros */
.pl-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; max-width: 840px; }
.pl-search { position: relative; flex: 1; min-width: 220px; display: flex; align-items: center; }
.pl-search svg { position: absolute; left: 12px; width: 16px; height: 16px; color: var(--muted-foreground); }
.pl-search input { width: 100%; padding: 9px 32px 9px 36px; border: 1px solid var(--border); border-radius: 10px; background: var(--card); font-size: 13px; }
.pl-search-clear { position: absolute; right: 8px; border: none; background: none; font-size: 18px; line-height: 1; color: var(--muted-foreground); cursor: pointer; }
.pl-sort { display: flex; align-items: center; gap: 6px; }
.pl-sort-lbl { font-size: 12px; color: var(--muted-foreground); }
.pl-sort select { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 12.5px; background: var(--card); }
.btn.pl-filt-on { border-color: var(--primary); color: var(--primary); }

.pl-filt-anchor { position: relative; }
.pl-filters { position: absolute; right: 0; top: calc(100% + 8px); z-index: 40; width: 600px; max-width: 88vw; border: 1px solid var(--border); border-radius: 12px; background: var(--card); padding: 16px 18px; box-shadow: var(--shadow-lg); }
.pl-filters-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.pl-filters-head > span { font-weight: 700; font-size: 13px; }
.pl-link { border: none; background: none; color: var(--primary); font-size: 12px; cursor: pointer; }
.pl-filt-group { margin-bottom: 12px; }
.pl-filt-lbl { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 700; color: var(--muted-foreground); margin-bottom: 7px; }
.pl-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.pl-fchip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--border); background: var(--card); font-size: 12px; cursor: pointer; color: var(--foreground); }
.pl-fchip:hover { border-color: var(--primary); }
.pl-fchip.on { background: var(--accent); border-color: var(--primary); color: var(--primary); font-weight: 600; }
.pl-fchip .dot { width: 8px; height: 8px; border-radius: 50%; }
.pl-toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }

/* ===== Agentes IA ===== */
.ag-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; max-width: 1040px; }
.ag-card { border: 1px solid var(--border); border-radius: 14px; background: var(--card); padding: 16px 18px; box-shadow: var(--shadow-soft); display: flex; flex-direction: column; gap: 6px; }
.ag-card-top { display: flex; align-items: center; justify-content: space-between; }
.ag-provider { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--border); }
.ag-provider.p-claude { background: oklch(0.95 0.05 40); color: oklch(0.5 0.16 40); }
.ag-provider.p-gemini { background: oklch(0.95 0.05 255); color: oklch(0.5 0.16 255); }
.ag-provider.p-gpt { background: oklch(0.95 0.05 160); color: oklch(0.45 0.13 160); }
.ag-name { font-weight: 700; font-size: 15px; margin-top: 4px; }
.ag-role { font-size: 12px; color: var(--muted-foreground); }
.ag-prompt { font-size: 12px; color: var(--muted-foreground); margin: 6px 0; line-height: 1.45; min-height: 34px; }
.ag-foot { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: 8px; border-top: 1px solid var(--border); }
.ag-res { font-size: 11.5px; color: var(--muted-foreground); }
.ag-switch { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.ag-switch input { opacity: 0; width: 0; height: 0; }
.ag-slider { position: absolute; inset: 0; background: var(--border); border-radius: 999px; transition: .2s; cursor: pointer; }
.ag-slider::before { content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.ag-switch input:checked + .ag-slider { background: oklch(0.6 0.16 150); }
.ag-switch input:checked + .ag-slider::before { transform: translateX(18px); }
.ag-res-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.ag-res-table th { text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted-foreground); padding: 6px 6px; border-bottom: 1px solid var(--border); }
.ag-res-table td { padding: 6px 6px; border-bottom: 1px solid var(--border); vertical-align: top; }
.form-control-sm { padding: 5px 8px; font-size: 12px; border: 1px solid var(--border); border-radius: 7px; width: 100%; background: var(--card); }
.ag-file { display: flex; flex-direction: column; gap: 4px; font-size: 11px; }
.ag-fileinput { font-size: 11px; }

/* ===== Automatizaciones (workflows) ===== */
.auto-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 16px; max-width: 980px; }
.auto-card { border: 1px solid var(--border); border-radius: 14px; background: var(--card); padding: 16px 18px; box-shadow: var(--shadow-soft); cursor: pointer; transition: border-color .15s; }
.auto-card:hover { border-color: oklch(0.55 0.22 258 / 0.4); }
.auto-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.auto-name { font-weight: 700; font-size: 14.5px; }
.auto-del-btn { background: transparent; border: 1px solid #fecaca; color: #b91c1c; border-radius: 6px; padding: 2px 8px; font-size: 14px; cursor: pointer; transition: background 0.15s; }
.auto-del-btn:hover { background: #fee2e2; }
.auto-del-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.auto-flow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.auto-trig { background: var(--accent); color: var(--primary); border-radius: 9px; padding: 7px 11px; font-size: 12px; font-weight: 600; }
.auto-arrow { color: var(--muted-foreground); }
.auto-act { background: oklch(0.95 0.05 60); color: oklch(0.5 0.14 55); border-radius: 9px; padding: 7px 11px; font-size: 12px; font-weight: 600; }
.auto-exec { font-size: 11.5px; color: var(--muted-foreground); margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.kb-route { display: flex; align-items: center; justify-content: space-between; gap: 8px; border: 1px dashed var(--border); border-radius: 8px; padding: 7px 10px; margin: 10px 0; background: var(--muted); font-size: 11.5px; }
.kb-route .codes { font-weight: 700; display: inline-flex; align-items: center; gap: 6px; }
.kb-route .codes .arr { color: var(--muted-foreground); }
.kb-route .date { color: var(--muted-foreground); font-weight: 600; display: inline-flex; align-items: center; gap: 5px; }
.kb-route .date svg { width: 11px; height: 11px; flex-shrink: 0; }
.kb-comment { font-size: 12px; color: var(--muted-foreground); line-height: 1.4; margin-bottom: 10px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.kb-foot { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding-top: 9px; border-top: 1px dashed var(--border); }
.kb-ase { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--foreground); font-weight: 600; min-width: 0; }
.kb-ase .nmtxt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kb-ase-dot { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; }
.kb-pax { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: var(--muted-foreground); font-weight: 600; white-space: nowrap; }
.kb-pax svg { width: 11px; height: 11px; }

/* ===== Ficha de lead con chat (estilo prototipo) ===== */
.pl-lead-dialog { max-width: 1400px; width: 96vw; display: flex; padding: 0; overflow: hidden; max-height: 94vh; height: 94vh; }
.pl-lead-left { flex: 1 1 55%; min-width: 0; display: flex; flex-direction: column; max-height: 94vh; }
.pl-lead-left .modal-body { flex: 1; overflow-y: auto; }
.pl-chat { flex: 1 1 45%; min-width: 0; display: flex; flex-direction: column; max-height: 94vh; border-left: 1px solid var(--border); background: var(--muted); }
.pl-chat-head { display: flex; align-items: center; gap: 10px; padding: 13px 16px; border-bottom: 1px solid var(--border); background: var(--card); }
.pl-chat-avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--gradient-violet); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex-shrink: 0; }
.pl-chat-head .nm { font-weight: 700; font-size: 13px; line-height: 1.2; }
.pl-chat-head .sub { font-size: 11px; color: var(--muted-foreground); display: flex; align-items: center; gap: 5px; margin-top: 1px; }
.pl-chat-head .sub::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: #4f8a60; box-shadow: 0 0 0 2px rgba(79,138,96,0.2); }
.pl-chat-more { display: inline-flex; align-items: center; gap: 5px; padding: 6px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--muted); font-size: 11px; color: var(--muted-foreground); cursor: default; flex-shrink: 0; }
.pl-chat-more svg { width: 12px; height: 12px; }
.pl-chat-line { margin-top: 6px; }
.pl-chat-line select { font-size: 11px; padding: 4px 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--card); width: 100%; }

/* Pestañas de la columna de datos del lead */
.pl-lead-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.pl-lead-tab { background: none; border: none; padding: 8px 14px; font-size: 13px; font-weight: 600; color: var(--muted-foreground); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.pl-lead-tab:hover { color: var(--foreground); }
.pl-lead-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Timeline de actividad */
.pl-timeline { display: flex; flex-direction: column; }
.pl-tl-item { display: flex; gap: 12px; padding: 4px 0; }
.pl-tl-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--primary); margin-top: 5px; flex-shrink: 0; position: relative; }
.pl-tl-item:not(:last-child) .pl-tl-dot::after { content: ''; position: absolute; left: 50%; top: 13px; transform: translateX(-50%); width: 2px; height: calc(100% + 8px); background: var(--border); }
.pl-tl-body { padding-bottom: 14px; }
.pl-tl-desc { font-size: 13px; color: var(--foreground); }
.pl-tl-meta { font-size: 11.5px; color: var(--muted-foreground); margin-top: 2px; }
.pl-tl-actor { font-weight: 600; color: var(--primary); }

/* Chips de cabecera del lead */
.pl-tags { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.pl-state-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: 0.02em; text-transform: uppercase; background: var(--accent); color: var(--primary); border: 1px solid var(--border); }
.pl-state-pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--primary); }
.pl-chip { background: var(--card); border: 1px solid var(--border); color: var(--muted-foreground); padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 500; display: inline-flex; align-items: center; gap: 5px; }
.pl-chip svg { width: 10px; height: 10px; }

/* Conmutador de vista Kanban / Lista */
.pl-view { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--card); }
.pl-view-btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border: none; background: none; color: var(--muted-foreground); font-size: 12.5px; font-weight: 600; cursor: pointer; }
.pl-view-btn + .pl-view-btn { border-left: 1px solid var(--border); }
.pl-view-btn svg { width: 15px; height: 15px; }
.pl-view-btn.on { background: var(--primary); color: #fff; }

/* Vista lista del tablero */
.pl-list { border: 1px solid var(--border); border-radius: 12px; background: var(--card); overflow: hidden; }
.pl-list-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.pl-list-table th { text-align: left; padding: 11px 14px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted-foreground); border-bottom: 1px solid var(--border); }
.pl-list-table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.pl-list-table tbody tr:last-child td { border-bottom: none; }
.pl-list-table tbody tr:hover { background: var(--muted); }
.pl-list-table tr.pl-row-reply { background: color-mix(in srgb, var(--destructive) 6%, transparent); }
.pl-row-tag { margin-top: 3px; font-size: 11px; font-weight: 600; color: var(--destructive); }

/* Filtros del modal de historial */
.pl-hist-filters { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.pl-hist-table th { white-space: nowrap; }

.btn-icon { background: none; border: none; padding: 5px; border-radius: 6px; color: var(--muted-foreground); cursor: pointer; display: inline-grid; place-items: center; }
.btn-icon:hover { background: var(--muted); color: var(--destructive); }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* Notas de seguimiento del lead */
.pl-notes-composer { border: 1px solid var(--border); border-radius: 10px; padding: 10px; background: var(--card); margin-bottom: 14px; }
.pl-notes-composer textarea { resize: vertical; }
.pl-notes-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; }
.pl-notes-colors { display: flex; gap: 6px; }
.pl-note-swatch { width: 20px; height: 20px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0; }
.pl-note-swatch.on { border-color: var(--foreground); box-shadow: 0 0 0 2px var(--card), 0 0 0 3px var(--foreground); }
.pl-notes-list { display: flex; flex-direction: column; gap: 10px; }
.pl-note { position: relative; border: 1px solid; border-radius: 10px; padding: 10px 30px 8px 12px; }
.pl-note-text { font-size: 13px; line-height: 1.45; color: #2a2a2a; white-space: pre-wrap; word-wrap: break-word; }
.pl-note-meta { margin-top: 6px; font-size: 11px; color: rgba(0,0,0,0.5); font-weight: 600; }
.pl-note-del { position: absolute; top: 6px; right: 8px; border: none; background: none; font-size: 17px; line-height: 1; color: rgba(0,0,0,0.35); cursor: pointer; }
.pl-note-del:hover { color: var(--destructive); }

/* Archivos del lead */
.pl-files-upload { margin-bottom: 14px; }
.pl-files-drop { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 18px; border: 1.5px dashed var(--border); border-radius: 10px; background: var(--card); color: var(--muted-foreground); font-size: 13px; font-weight: 600; cursor: pointer; }
.pl-files-drop:hover { border-color: var(--primary); color: var(--primary); }
.pl-files-drop svg { width: 18px; height: 18px; }
.pl-files-list { display: flex; flex-direction: column; gap: 8px; }
.pl-file { display: flex; align-items: center; gap: 10px; border: 1px solid var(--border); border-radius: 10px; padding: 9px 10px; background: var(--card); }
.pl-file-ico { width: 38px; height: 38px; flex: none; border-radius: 8px; background: var(--accent); color: var(--primary); display: grid; place-items: center; font-size: 10px; font-weight: 800; letter-spacing: 0.02em; }
.pl-file-info { flex: 1; min-width: 0; }
.pl-file-name { display: block; font-size: 13px; font-weight: 600; color: var(--foreground); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-file-name:hover { color: var(--primary); text-decoration: underline; }
.pl-file-meta { font-size: 11px; color: var(--muted-foreground); margin-top: 2px; }

/* ===== Conversaciones (bandeja unificada) ===== */
.cv-warn { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 18px; font-size: 13px; color: var(--muted-foreground); }
.cv-warn a { color: var(--primary); font-weight: 600; }
.cv-grid { display: grid; grid-template-columns: 320px 1fr 300px; gap: 16px; height: calc(100vh - 270px); min-height: 480px; }
@media (max-width: 1100px) { .cv-grid { grid-template-columns: 280px 1fr; } .cv-side-col { display: none; } }
.cv-back { display: none; }
@media (max-width: 768px) {
  /* Una sola columna a la vez: lista por defecto, hilo al elegir un chat. */
  .cv-grid { grid-template-columns: 1fr; height: auto; }
  .cv-list-col, .cv-thread-col { height: calc(100vh - 210px); min-height: 420px; }
  .cv-grid:not(.cv-has-active) .cv-thread-col { display: none; }
  .cv-grid.cv-has-active .cv-list-col { display: none; }
  .cv-back {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; flex: none; margin-left: -2px;
    border: 1px solid var(--border); border-radius: 9px; background: var(--card);
    color: var(--foreground); cursor: pointer;
  }
  .cv-back svg { width: 18px; height: 18px; }
}

.cv-list-col, .cv-thread-col, .cv-side-col { background: var(--card); border: 1px solid var(--border); border-radius: 14px; display: flex; flex-direction: column; overflow: hidden; }
.cv-side-col { padding: 14px; gap: 14px; overflow-y: auto; }

.cv-search { position: relative; padding: 12px; border-bottom: 1px solid var(--border); }
.cv-search svg { position: absolute; left: 22px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--muted-foreground); }
.cv-search input { width: 100%; height: 36px; border: 1px solid var(--border); border-radius: 9px; background: var(--muted); padding: 0 10px 0 32px; font-size: 12.5px; }

.cv-list { flex: 1; overflow-y: auto; }
.cv-empty, .cv-side-empty { padding: 18px; font-size: 12.5px; color: var(--muted-foreground); }
.cv-item { display: flex; align-items: flex-start; gap: 10px; width: 100%; text-align: left; background: none; border: none; border-bottom: 1px solid var(--border); padding: 11px 12px; cursor: pointer; }
.cv-item:hover { background: var(--muted); }
.cv-item.on { background: var(--accent); }
.cv-avatar { width: 38px; height: 38px; flex: none; border-radius: 50%; background: var(--gradient-violet, linear-gradient(135deg,#7c4dff,#a78bfa)); color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center; }
.cv-avatar.lg { width: 42px; height: 42px; font-size: 13px; }
.cv-item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.cv-item-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.cv-item-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cv-item-time { font-size: 10px; color: var(--muted-foreground); flex: none; }
.cv-item-last { font-size: 11.5px; color: var(--muted-foreground); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cv-item-tags { display: flex; align-items: center; gap: 6px; margin-top: 3px; }
.cv-line-tag { font-size: 9px; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700; padding: 2px 6px; border-radius: 5px; background: var(--muted); color: var(--muted-foreground); }
.cv-unread { font-size: 10px; font-weight: 700; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--destructive); color: #fff; display: grid; place-items: center; }

.cv-thread-empty, .cv-side-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: var(--muted-foreground); font-size: 13px; text-align: center; padding: 24px; }
.cv-thread-empty svg { width: 46px; height: 46px; opacity: 0.4; }
.cv-thread-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.cv-th-name { font-size: 14px; font-weight: 700; }
.cv-th-sub { font-size: 11px; color: var(--muted-foreground); }
.cv-line-select { border: 1px solid var(--border); border-radius: 8px; font-size: 11.5px; padding: 5px 8px; background: var(--card); max-width: 150px; }
.cv-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 9px; background: var(--muted); }
.cv-composer { padding: 12px; border-top: 1px solid var(--border); }
.cv-composer-box { display: flex; align-items: flex-end; gap: 8px; border: 1px solid var(--border); border-radius: 12px; background: var(--background, var(--card)); padding: 8px; }
.cv-composer-box textarea { flex: 1; border: none; background: transparent; resize: none; font-size: 13px; outline: none; max-height: 120px; }
.cv-send { width: 38px; height: 38px; flex: none; border: none; border-radius: 9px; background: var(--primary); color: #fff; display: grid; place-items: center; cursor: pointer; }
.cv-send:disabled { opacity: 0.5; cursor: not-allowed; }
.cv-send svg { width: 17px; height: 17px; }

.cv-context { border: 1px solid var(--border); border-radius: 12px; padding: 12px; }
.cv-ctx-title { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; color: var(--muted-foreground); }
.cv-ctx-name { font-size: 15px; font-weight: 700; margin-top: 3px; }
.cv-ctx-rows { margin-top: 8px; display: flex; flex-direction: column; gap: 5px; }
.cv-ctx-rows > div { display: flex; align-items: center; justify-content: space-between; font-size: 12px; }
.cv-ctx-rows span { color: var(--muted-foreground); }
.cv-copilot { border: 1px solid var(--border); border-radius: 12px; padding: 12px; }
.cv-copilot-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.cv-bot { width: 26px; height: 26px; border-radius: 7px; background: var(--gold, #e9b949); color: #3a2c00; display: grid; place-items: center; }
.cv-bot svg { width: 15px; height: 15px; }
.cv-copilot-lbl { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; color: var(--primary); }
.cv-soon { margin-left: auto; font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; padding: 2px 7px; border-radius: 999px; background: var(--muted); color: var(--muted-foreground); }
.cv-copilot-note { font-size: 11.5px; color: var(--muted-foreground); line-height: 1.5; }
.cv-copilot-note a { color: var(--primary); font-weight: 600; }
.cv-dl { display: inline-block; margin-top: 5px; font-size: 11px; font-weight: 600; text-decoration: none; opacity: 0.85; }
.pl-bubble.in .cv-dl { color: var(--primary); }
.pl-bubble.out .cv-dl { color: rgba(255,255,255,0.92); text-decoration: underline; }

/* ===== Metricas / reportes ===== */
.rep-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
@media (max-width: 900px) { .rep-grid { grid-template-columns: 1fr; } }
.rep-card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px; }
.rep-card.rep-wide { grid-column: 1 / -1; }
.rep-title { font-size: 14px; font-weight: 700; }
.rep-sub { font-size: 11.5px; color: var(--muted-foreground); margin-bottom: 12px; }
.rep-empty { font-size: 12.5px; color: var(--muted-foreground); padding: 10px 0; }

.rep-bars { display: flex; flex-direction: column; gap: 9px; }
.rep-bar-row { display: grid; grid-template-columns: 120px 1fr 38px; align-items: center; gap: 10px; }
.rep-bar-lbl { font-size: 12px; color: var(--foreground); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rep-bar-track { height: 16px; background: var(--muted); border-radius: 6px; overflow: hidden; }
.rep-bar { height: 100%; border-radius: 6px; min-width: 2px; background: var(--primary); transition: width .3s; }
.rep-bar.k-won { background: #3fae6b; }
.rep-bar.k-lost { background: #d0455f; }
.rep-bar.k-open { background: var(--primary); }
.rep-bar.k-loss { background: #d89a36; }
.rep-bar.k-dest { background: #4e80b5; }
.rep-bar-val { font-size: 12.5px; font-weight: 700; text-align: right; }

.rep-cols { display: flex; align-items: flex-end; gap: 10px; height: 200px; padding-top: 10px; }
.rep-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }
.rep-col-val { font-size: 11px; font-weight: 700; margin-bottom: 4px; }
.rep-col-bar-track { flex: 1; width: 60%; display: flex; align-items: flex-end; }
.rep-col-bar { width: 100%; min-height: 3px; background: var(--gradient-violet, linear-gradient(180deg,#7c4dff,#a78bfa)); border-radius: 6px 6px 0 0; transition: height .3s; }
.rep-col-lbl { font-size: 11px; font-weight: 600; margin-top: 6px; text-transform: capitalize; }
.rep-col-sub { font-size: 10px; color: var(--muted-foreground); }

.rep-mini-kpis { display: flex; gap: 10px; }
.rep-mini-kpis > div { flex: 1; background: var(--muted); border-radius: 10px; padding: 10px; text-align: center; }
.rep-mini-kpis .n { display: block; font-size: 20px; font-weight: 800; }
.rep-mini-kpis .l { display: block; font-size: 10.5px; color: var(--muted-foreground); text-transform: uppercase; letter-spacing: 0.04em; margin-top: 2px; }

/* ===== Servidores de IA ===== */
.ai-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; max-width: 1100px; }
.ai-card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px; }
.ai-card-head { display: flex; align-items: center; gap: 11px; }
.ai-logo { width: 40px; height: 40px; flex: none; border-radius: 11px; display: grid; place-items: center; font-size: 14px; font-weight: 800; color: #fff; background: var(--primary); }
.ai-logo.p-claude { background: #d97757; }
.ai-logo.p-gemini { background: #4e80b5; }
.ai-logo.p-gpt { background: #10a37f; }
.ai-logo.p-deepseek { background: #4d6bfe; }
.ai-name { font-size: 14.5px; font-weight: 700; }
.ai-prov { font-size: 11px; color: var(--muted-foreground); }
.ai-rows { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.ai-rows > div { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12.5px; }
.ai-rows span { color: var(--muted-foreground); }
.ai-toggle { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; margin: 6px 0 2px; cursor: pointer; }

/* Barra de cupo mensual de tokens */
.ag-quota-bar { height: 6px; border-radius: 999px; background: var(--muted); overflow: hidden; margin: 6px 0 4px; }
.ag-quota-fill { height: 100%; background: var(--primary); border-radius: 999px; transition: width .3s; }
.ag-quota-fill.over { background: var(--destructive); }

/* Editor de agente en dos columnas */
.ag-editor-cols { display: flex; gap: 18px; align-items: flex-start; }
.ag-editor-left { flex: 1; min-width: 0; }
.ag-editor-right { width: 380px; flex: none; border-left: 1px solid var(--border); padding-left: 18px; align-self: stretch; }
@media (max-width: 980px) { .ag-editor-cols { flex-direction: column; } .ag-editor-right { width: 100%; border-left: none; border-top: 1px solid var(--border); padding-left: 0; padding-top: 14px; } }

/* Toolbar de editor de texto (prompts) */
.rt-toolbar { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; padding: 5px; border: 1px solid var(--border); border-bottom: none; border-radius: 8px 8px 0 0; background: var(--muted); position: relative; }
.rt-btn { min-width: 28px; height: 26px; padding: 0 6px; border: 1px solid var(--border); border-radius: 6px; background: var(--card); cursor: pointer; font-size: 12px; line-height: 1; display: inline-grid; place-items: center; }
.rt-btn:hover { border-color: var(--primary); }
.rt-btn.on { background: var(--primary); color: #fff; }
.rt-toolbar + textarea { border-top-left-radius: 0; border-top-right-radius: 0; }
.rt-emojis { position: absolute; top: 34px; left: 5px; z-index: 5; display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 6px; box-shadow: 0 6px 20px rgba(0,0,0,0.12); }
.rt-emoji { width: 28px; height: 28px; border: none; background: none; cursor: pointer; font-size: 16px; border-radius: 6px; }
.rt-emoji:hover { background: var(--muted); }

/* Listas de prompts y recursos del agente */
.ag-list { display: flex; flex-direction: column; gap: 8px; }
.ag-item { display: flex; align-items: center; gap: 10px; border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; background: var(--card); }
.ag-item-main { flex: 1; min-width: 0; }
.ag-item-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ag-item-sub { font-size: 11.5px; color: var(--muted-foreground); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ag-rtype { flex: none; width: 38px; height: 26px; border-radius: 6px; background: var(--accent); color: var(--primary); font-size: 9.5px; font-weight: 800; display: grid; place-items: center; letter-spacing: 0.04em; }

/* Chat de prueba del agente */
.ag-test { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.ag-test-body { max-height: 380px; min-height: 160px; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; background: var(--muted); }
.ag-test-empty { color: var(--muted-foreground); font-size: 12.5px; text-align: center; margin: auto; font-style: italic; }
.ag-bubble { max-width: 80%; padding: 8px 12px; border-radius: 12px; font-size: 13px; line-height: 1.45; white-space: pre-wrap; word-wrap: break-word; }
.ag-bubble.me { align-self: flex-end; background: var(--gradient-violet, #7c4dff); color: #fff; border-bottom-right-radius: 4px; }
.ag-bubble.bot { align-self: flex-start; background: var(--card); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.ag-bubble.ag-typing { color: var(--muted-foreground); font-style: italic; }
.ag-attach { margin-top: 6px; }
.ag-attach img, .ag-attach video { max-width: 200px; max-height: 200px; border-radius: 8px; display: block; }
.ag-attach audio { max-width: 220px; }
.ag-attach a { font-size: 12px; font-weight: 600; color: var(--primary); text-decoration: none; }
.ag-bubble.bot .ag-attach a { color: var(--primary); }
.ag-attach-text { background: rgba(0,0,0,0.04); border-left: 3px solid var(--primary); border-radius: 4px; padding: 6px 8px; font-size: 12.5px; white-space: pre-wrap; }
.ag-attach-cap { font-size: 12px; margin-top: 3px; }

/* Enviar prueba a telefono */
.ag-phone { border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; margin-bottom: 10px; background: var(--card); }
.ag-phone-toggle { display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.ag-phone-row { display: flex; gap: 6px; margin-top: 8px; }
.ag-phone-row .form-control { font-size: 12px; }
.ag-test-input { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); background: var(--card); }
.ag-test-input input { flex: 1; }

.pl-chat-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 9px; }
/* Contenedor fijo (no hace scroll) para el chat: ancla el overlay de drag&drop a la vista visible */
.pl-chat-bodywrap { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
/* Overlay para arrastrar y soltar documentos sobre la conversacion (visible aunque el chat este lleno) */
.pl-chat-dropmask { display: none; position: absolute; inset: 8px; z-index: 5; border: 2px dashed var(--primary); border-radius: 12px; background: color-mix(in srgb, var(--primary) 12%, #fff); color: var(--primary); font-weight: 700; align-items: center; justify-content: center; text-align: center; pointer-events: none; }
.pl-chat-bodywrap.pl-chat-dragover .pl-chat-dropmask { display: flex; }
.pl-date-divider { text-align: center; font-size: 10px; color: var(--muted-foreground); letter-spacing: 0.1em; text-transform: uppercase; font-weight: 700; margin: 4px 0 2px; display: flex; align-items: center; gap: 10px; }
.pl-date-divider::before, .pl-date-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.pl-bubble { max-width: 80%; padding: 8px 12px; border-radius: 12px; font-size: 13px; line-height: 1.4; word-wrap: break-word; }
.pl-bubble .t { font-size: 9.5px; opacity: 0.7; margin-top: 3px; }
.pl-bubble.out { align-self: flex-end; background: var(--gradient-violet); color: #fff; border-bottom-right-radius: 4px; }
.pl-bubble.in { align-self: flex-start; background: var(--card); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.pl-chat-empty { color: var(--muted-foreground); font-size: 12px; text-align: center; margin: auto; font-style: italic; padding: 20px; }

/* Mensajes pregrabados con categorias */
.pl-chat-quick { padding: 10px 14px 6px; border-top: 1px solid var(--border); background: var(--card); }
.pl-qr-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.pl-qr-head > span { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; font-weight: 700; color: var(--muted-foreground); }
.pl-qr-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.pl-qr-tab { font-size: 10.5px; padding: 3px 9px; border-radius: 999px; color: var(--muted-foreground); font-weight: 700; border: none; background: none; cursor: pointer; letter-spacing: 0.02em; }
.pl-qr-tab:hover { color: var(--foreground); }
.pl-qr-tab.active { background: var(--primary); color: #fff; }
.pl-qr-list { display: flex; flex-wrap: wrap; gap: 6px; max-height: 116px; overflow-y: auto; }
.pl-quick-chip { font-size: 11.5px; padding: 6px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--muted); color: var(--foreground); cursor: pointer; text-align: left; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-quick-chip:hover { border-color: var(--primary); color: var(--primary); background: var(--accent); }
.pl-chat-input { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); background: var(--card); align-items: center; }
.pl-chat-input input { flex: 1; border: 1px solid var(--border); border-radius: 999px; padding: 9px 14px; font-size: 13px; min-width: 0; }
.pl-quote-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); background: var(--card); }
.pl-quote-actions .btn { font-size: 12.5px; padding: 7px 12px; }
.pl-quote-confirm { font-size: 12.5px; font-weight: 600; color: var(--foreground); }
.pl-quote-msg { font-size: 12px; color: var(--muted-foreground); }
.pl-chat-send { width: 38px; height: 38px; border-radius: 50%; background: var(--gradient-violet); color: #fff; border: none; display: grid; place-items: center; cursor: pointer; flex-shrink: 0; }
.pl-chat-send:disabled { opacity: 0.5; cursor: default; }
.pl-chat-send svg { width: 16px; height: 16px; }

/* Adjuntos */
.pl-attach { position: relative; flex-shrink: 0; }
.pl-attach-btn { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border); background: var(--muted); color: var(--muted-foreground); display: grid; place-items: center; cursor: pointer; }
.pl-attach-btn:hover { color: var(--primary); border-color: var(--primary); }
.pl-attach-btn svg { width: 16px; height: 16px; }
.pl-attach-menu { position: absolute; bottom: 44px; left: 0; background: var(--card); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,0.12); padding: 6px; display: flex; flex-direction: column; gap: 2px; z-index: 20; min-width: 150px; }
.pl-attach-item { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 7px; font-size: 12.5px; color: var(--foreground); background: none; border: none; cursor: pointer; text-align: left; }
.pl-attach-item:hover { background: var(--muted); }
.pl-attach-item svg { width: 15px; height: 15px; color: var(--muted-foreground); }
.pl-media-img { max-width: 220px; max-height: 220px; border-radius: 8px; display: block; margin-bottom: 4px; }
.pl-media-doc { display: inline-block; font-size: 12.5px; text-decoration: underline; margin-bottom: 4px; }
.pl-bubble.out .pl-media-doc { color: #fff; }

/* Toggle Datos/Chat: solo visible en movil. */
.pl-lead-mobtabs { display: none; }
@media (max-width: 880px) {
    .pl-lead-dialog { flex-direction: column; max-height: 94vh; }
    .pl-lead-mobtabs { display: flex; gap: 6px; padding: 8px; border-bottom: 1px solid var(--border); background: var(--card); flex: 0 0 auto; }
    .pl-lead-mobtabs button { flex: 1; padding: 9px; border: 1px solid var(--border); border-radius: 9px; background: var(--muted); font-weight: 700; font-size: 13px; color: var(--muted-foreground); cursor: pointer; }
    .pl-lead-mobtabs button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
    /* Mostrar solo el panel seleccionado y dejar que ocupe el alto disponible. */
    .pl-lead-dialog .pl-lead-left, .pl-lead-dialog .pl-chat { flex: 1 1 auto; max-height: none; min-height: 0; }
    .pl-lead-dialog.mob-datos .pl-chat { display: none; }
    .pl-lead-dialog.mob-chat .pl-lead-left { display: none; }
    .pl-chat { border-left: none; border-top: 1px solid var(--border); }
}

/* ===== Pipeline modal: campos por etapa ===== */
.pl-stagegroup { margin-bottom: 18px; }
.pl-stagegroup-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 800; color: var(--primary); margin-bottom: 10px; padding-bottom: 6px; border-bottom: 1px dashed var(--border); }
.pl-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pl-field.col2 { grid-column: 1 / -1; }
.pl-field-help { font-size: 11px; color: var(--muted-foreground); margin: 2px 0 6px; font-style: italic; }
.pl-multi-row { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.pl-multi-idx { flex: none; min-width: 22px; height: 22px; border-radius: 6px; background: var(--muted); color: var(--muted-foreground); font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.pl-multi-del { flex: none; width: 28px; height: 28px; border: 1px solid var(--border); border-radius: 7px; background: var(--card); color: var(--destructive); cursor: pointer; line-height: 1; font-size: 16px; }
.pl-multi-add { border: 1px dashed var(--border); border-radius: 7px; background: none; color: var(--primary); font-size: 12px; font-weight: 600; padding: 4px 10px; cursor: pointer; }
.cfg-tag { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; padding: 1px 6px; border-radius: 5px; background: var(--primary-soft); color: var(--primary); margin-left: 6px; }
/* Boton Guardar con cambios pendientes en el modal del lead: color ambar para llamar la atencion. */
.pl-save-dirty { background: #f59e0b; border: 1px solid #f59e0b; color: #1f2937; font-weight: 700; box-shadow: 0 0 0 3px rgba(245, 158, 11, .18); }
.pl-save-dirty:hover { background: #d97706; border-color: #d97706; color: #fff; }
.pl-saved-flag { font-size: 12px; font-weight: 600; color: #16a34a; display: inline-flex; align-items: center; gap: 4px; }
.pl-saved-flag::before { content: "✓"; font-weight: 700; }
/* Campo Total (solo lectura, calculado). */
.pl-total-field { background: var(--muted); font-weight: 700; color: var(--primary); }

/* Modulo Plantillas de cotizacion */
.pl-tpl-layout { display: grid; grid-template-columns: 280px 1fr; gap: 18px; align-items: start; }
.pl-tpl-list { padding: 14px; }
.pl-tpl-list-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted-foreground); margin-bottom: 8px; }
.pl-tpl-item { display: block; width: 100%; text-align: left; border: 1px solid var(--border); border-radius: 10px; background: var(--card); padding: 10px 12px; margin-bottom: 0; cursor: pointer; flex: 1; }
.pl-tpl-item.active { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.pl-tpl-item-row { display: flex; align-items: stretch; gap: 6px; margin-bottom: 8px; }
.pl-tpl-item-row.active .pl-tpl-item { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.pl-tpl-del { width: 32px; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: #b91c1c; font-size: 18px; line-height: 1; cursor: pointer; transition: all .15s; flex-shrink: 0; }
.pl-tpl-del:hover { background: #fee2e2; border-color: #fca5a5; }
.pl-tpl-item .nm { font-weight: 600; font-size: 13.5px; display: flex; align-items: center; gap: 6px; }
.pl-tpl-item .mt { font-size: 11px; color: var(--muted-foreground); margin-top: 2px; }
.pl-tpl-default { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; padding: 1px 6px; border-radius: 5px; background: var(--primary-soft); color: var(--primary); }
.pl-tpl-editor { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.pl-tpl-html { font-family: var(--bs-font-monospace, monospace); font-size: 12.5px; line-height: 1.5; white-space: pre; overflow-wrap: normal; overflow-x: auto; }
.pl-tpl-vars { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 12px; }
.pl-tpl-vars-title { font-size: 11.5px; font-weight: 700; color: var(--muted-foreground); margin-bottom: 8px; }
.pl-tpl-vars-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.pl-tpl-stage-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--primary); margin: 8px 0 5px; opacity: .85; }
.pl-tpl-var { font-size: 11.5px; background: var(--muted); border: 1px solid var(--border); border-radius: 6px; padding: 2px 7px; color: var(--primary); cursor: pointer; transition: background .12s, border-color .12s, color .12s; }
.pl-tpl-var:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.pl-tpl-preview-head { padding: 10px 14px; font-size: 12px; font-weight: 700; color: var(--muted-foreground); background: var(--card); border-bottom: 1px solid var(--border); text-transform: uppercase; letter-spacing: .04em; }
.pl-tpl-preview { width: 100%; height: 540px; border: 0; background: #fff; display: block; }
@media (max-width: 1100px) {
    .pl-tpl-layout { grid-template-columns: 1fr; }
    .pl-tpl-editor { grid-template-columns: 1fr; }
}
.pl-tpl-gallery { margin-top: 18px; padding: 18px; }
.pl-tpl-gallery-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.pl-tpl-assets { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-top: 14px; }
.pl-tpl-asset { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--card); }
.pl-tpl-asset-thumb { height: 110px; background: #f3f4f6 center/cover no-repeat; display: flex; align-items: center; justify-content: center; }
.pl-tpl-asset-thumb img { max-width: 100%; max-height: 110px; object-fit: contain; }
.pl-tpl-asset-name { font-size: 11.5px; padding: 6px 8px 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-tpl-asset-actions { display: flex; gap: 6px; padding: 6px 8px 8px; }
.pl-tpl-asset-actions .btn-sm { font-size: 11px; padding: 3px 7px; flex: 1; }
.cfg-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 0.6rem; background: var(--card); margin-bottom: 6px; }
.cfg-row .grow { flex: 1; min-width: 0; }

/* ===== Nav: insignia "en construccion" ===== */
.visal-nav-soon { margin-left: auto; font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; padding: 1px 6px; border-radius: 6px; background: var(--muted); color: var(--muted-foreground); }

/* Acordeon de la API de integracion en Mi cuenta (colapsado por defecto). */
.acct-api > summary { list-style: none; cursor: pointer; padding: 16px 20px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.acct-api > summary::-webkit-details-marker { display: none; }
.acct-api > summary::before { content: "\25B8"; color: var(--muted-foreground); margin-right: 8px; transition: transform .15s ease; }
.acct-api[open] > summary::before { transform: rotate(90deg); }
.acct-api > summary:hover { background: var(--muted); border-radius: 1.25rem; }

/* =====================================================================
   RESPONSIVE - moviles y tabletas (<= 991px): menu off-canvas + ajustes
   ===================================================================== */
@media (max-width: 991.98px) {
  /* El menu se vuelve un panel deslizable; oculto por defecto (se oculta solo). */
  .visal-sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100vh; height: 100dvh;
    width: 280px;
    z-index: 1050;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: 0 0 40px rgba(0,0,0,.18);
  }
  /* Abierto cuando el checkbox esta marcado. */
  .visal-nav-toggle:checked ~ .visal-sidebar { transform: translateX(0); }

  /* Capa oscura detras del menu abierto. */
  .visal-nav-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 1040; border: 0; }
  .visal-nav-toggle:checked ~ .visal-nav-overlay { display: block; }

  /* Topbar: hamburguesa a la izquierda + marca, usuario a la derecha. */
  .visal-topbar { justify-content: flex-start; gap: 10px; padding: 0 14px; }
  .visal-hamburger-mobile {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; margin-left: -6px;
    border-radius: 10px; cursor: pointer; color: var(--foreground);
  }
  .visal-hamburger-mobile:hover { background: var(--muted); }
  .visal-hamburger-mobile svg { width: 22px; height: 22px; }
  /* El boton "Mostrar menu" de escritorio no aplica en movil. */
  .visal-hamburger-desktop { display: none !important; }
  /* El boton "Ocultar menu" interno del sidebar tampoco en movil (ya hay overlay para cerrar). */
  .visal-nav-collapse-btn { display: none; }
  .visal-topbar-brand { display: inline-block; font-weight: 800; font-size: 15px; letter-spacing: -0.02em; }
  .visal-topbar-brand span { color: var(--primary); }
  .visal-topbar form { margin-left: auto; }            /* empuja "Salir" a la derecha */
  .visal-user-chip { display: none; }                   /* se oculta para no saturar */

  /* Mas aire util en pantallas chicas. */
  .visal-content { padding: 16px 14px; }
  .page-title { font-size: 1.5rem; }
  .module-head { flex-direction: column; align-items: flex-start; gap: 12px; }

  /* Rejillas comunes a una sola columna. */
  .ai-grid, .rep-grid, .brand-cols { grid-template-columns: 1fr !important; }

  /* Tablas anchas: que hagan scroll horizontal en vez de romper el layout. */
  .table-responsive { -webkit-overflow-scrolling: touch; }
  .visal-content .table { display: block; width: 100%; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }

  /* Modales/cuadros anchos: que quepan en la pantalla. */
  .modal-dialog { margin: 10px; }
}

/* Telefonos pequenos. */
@media (max-width: 560px) {
  .visal-topbar-brand { font-size: 14px; }
  .visal-content { padding: 14px 11px; }
  .page-title { font-size: 1.32rem; }
  .page-sub { font-size: .86rem; }
  /* Formularios de 2 columnas (lead, etc.) a una sola columna. */
  .pl-fields { grid-template-columns: 1fr; }
}

/* ====== Sub-controles de Historias (ordenes medicas, servicios, etc.) ====== */
.od-bar { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px; margin-bottom: 12px; gap: 10px; flex-wrap: wrap; }
.od-bar-left { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; color: #0f172a; }
.od-bar-right { display: flex; gap: 6px; }
.od-w-220 { max-width: 220px; }
.od-card { border: 1px solid #e2e8f0; border-radius: 8px; padding: 16px; background: #fff; }
.od-row { display: grid; grid-template-columns: repeat(12, 1fr); gap: 12px; margin-bottom: 12px; align-items: end; }
.od-f label { font-size: 11px; font-weight: 700; color: #334155; text-transform: uppercase; letter-spacing: 0.3px; margin-bottom: 4px; display: block; }
.od-c-1  { grid-column: span 1; }
.od-c-2  { grid-column: span 2; }
.od-c-3  { grid-column: span 3; }
.od-c-4  { grid-column: span 4; }
.od-c-6  { grid-column: span 6; }
.od-c-10 { grid-column: span 10; }
.od-c-11 { grid-column: span 11; }
.od-c-12 { grid-column: span 12; }
.od-posol { background: #f1f5f9; border: 1px solid #e2e8f0; border-radius: 8px; padding: 8px; }
.od-posol-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.od-mini { font-size: 10px !important; text-align: center; }
.od-posol-preview { font-size: 11px; color: #64748b; font-style: italic; text-align: center; margin-top: 6px; }
.od-input-group { display: flex; gap: 4px; }
.od-input-group > input { flex: 1; }
.od-grid-wrap { margin-top: 14px; border: 1px solid #e2e8f0; border-radius: 6px; overflow: auto; }
.od-tbl { margin: 0; font-size: 12px; }
.od-tbl thead th { background: #1565c0; color: #fff; padding: 8px 10px; font-size: 11px; font-weight: 700; text-transform: uppercase; }
.od-tbl td { padding: 8px 10px; border-bottom: 1px solid #f1f5f9; }
.od-empty-row { padding: 30px !important; font-style: italic; }
.od-action-col { display: flex; align-items: stretch; }
.od-action-add { width: 100%; align-self: stretch; height: 100%; }
