:root {
  --ink: #222f3b;
  --ink-soft: #454f66;
  --muted: #6b7387;
  --navy: #222f3b;
  --navy-2: #34435a;
  --accent: #7992d8;
  --accent-soft: #eef1fb;
  --sky: #e3e9fa;
  --sky-2: #eef1fb;
  --cream: #f6f5f0;
  --paper: #f5f5f5;
  --gold: #d99b45;
  --gold-soft: #fff1d9;
  --rose: #c96f66;
  --rose-soft: #fae9e6;
  --green: #2f8f5b;
  --green-soft: #e2f5ea;
  --line: #dcdcdc;
  --line-dark: #c2c2c2;
  --white: #ffffff;
  --shadow-sm: 0 1px 2px rgba(28, 35, 51, .05), 0 8px 24px rgba(28, 35, 51, .05);
  --shadow-md: 0 16px 50px rgba(28, 35, 51, .14);
  --radius: 18px;
  --radius-sm: 12px;
  --sidebar: 260px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: "Poppins", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }
svg { display: block; }

.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar);
  display: flex;
  flex-direction: column;
  padding: 26px 18px 18px;
  background: #eef1f6;
  border-right: 1px solid var(--line);
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 0 10px 25px; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; color: var(--white); background: var(--navy); border-radius: 12px; }
.brand-mark svg, .brand-mark img { width: 23px; }
.brand strong, .brand small { display: block; }
.brand strong { font: 700 19px/1.1 "Poppins", sans-serif; letter-spacing: -.02em; }
.brand small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.nav-label { margin: 11px 12px 8px; color: #868da3; font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.main-nav { display: grid; gap: 3px; }
.nav-item { display: flex; align-items: center; gap: 11px; min-height: 45px; padding: 0 12px; color: var(--ink-soft); border-radius: 11px; font-size: 13.5px; font-weight: 600; transition: .18s ease; cursor: pointer; }
.nav-item:hover { color: var(--navy); background: rgba(255,255,255,.65); }
.nav-item.active { color: var(--navy); background: var(--white); box-shadow: 0 1px 8px rgba(28,35,51,.06); }
.nav-item svg { width: 19px; height: 19px; }
.avatar { display: grid; place-items: center; flex: 0 0 auto; width: 36px; height: 36px; color: var(--white); background: var(--navy); border: 0; border-radius: 50%; font-size: 11px; font-weight: 700; }
.avatar.small { width: 32px; height: 32px; }
#portal-link-slot { margin-top: auto; }
.portal-link { display: flex; align-items: center; gap: 8px; padding: 10px 12px; color: var(--muted); border-radius: 10px; font-size: 12px; font-weight: 600; transition: .15s ease; }
.portal-link:hover { color: var(--navy); background: rgba(255,255,255,.65); }
.portal-link svg { width: 15px; height: 15px; }
.user-menu { display: grid; grid-template-columns: 36px 1fr; align-items: center; gap: 10px; width: 100%; padding: 14px 10px 2px; text-align: left; background: transparent; border: 0; cursor: pointer; }
.user-menu strong, .user-menu small { display: block; }
.user-menu strong { font-size: 12px; }
.user-menu small { margin-top: 2px; color: var(--muted); font-size: 10px; }

.mobile-header { display: none; }
.icon-button { display: grid; place-items: center; width: 38px; height: 38px; background: var(--white); border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }

#app-main { min-height: 100vh; margin-left: var(--sidebar); padding: 38px 46px 70px; outline: none; }
.page { width: min(1180px, 100%); margin: 0 auto; animation: pageIn .28s ease both; }
@keyframes pageIn { from { opacity: 0; transform: translateY(5px); } }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 28px; flex-wrap: wrap; }
.eyebrow { display: inline-flex; align-items: center; gap: 7px; margin: 0 0 8px; color: var(--navy-2); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.eyebrow::before { content: ""; width: 18px; height: 2px; background: var(--accent); }
h1, h2, h3, h4 { margin: 0; font-family: "Poppins", sans-serif; letter-spacing: -.025em; }
h1 { max-width: 760px; font-size: clamp(28px, 4vw, 40px); line-height: 1.1; }
h2 { font-size: 21px; line-height: 1.2; }
h3 { font-size: 15px; line-height: 1.3; }
.lead { max-width: 660px; margin: 11px 0 0; color: var(--muted); font-size: 14.5px; line-height: 1.6; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin: 30px 0 15px; }
.section-heading p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card { padding: 20px; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card.compact { padding: 16px; }
.card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.card p { color: var(--muted); font-size: 13px; line-height: 1.55; }
.card p:last-child { margin-bottom: 0; }

.hero-panel {
  position: relative; overflow: hidden; display: grid; grid-template-columns: 1.2fr .8fr; gap: 22px; padding: 30px;
  color: var(--white); border-radius: 22px; box-shadow: var(--shadow-md);
  background:
    linear-gradient(115deg, rgba(255,255,255,.06) 0%, transparent 38%),
    linear-gradient(295deg, rgba(255,255,255,.045) 0%, transparent 42%),
    var(--navy);
}
.hero-panel h1 { max-width: 600px; font-size: clamp(26px, 3.5vw, 38px); color: var(--white); }
.hero-panel p { max-width: 600px; margin: 12px 0 20px; color: #cdd7f5; font-size: 13.5px; line-height: 1.6; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.hero-aside { position: relative; z-index: 1; display: flex; align-items: center; justify-content: center; gap: 14px; }
.hero-stat { text-align: center; }
.hero-stat strong { display: block; font: 700 30px/1 "Poppins", sans-serif; }
.hero-stat span { display: block; margin-top: 4px; color: #b7c3ea; font-size: 11px; }

.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px; color: var(--white); background: var(--navy); border: 1px solid var(--navy); border-radius: 11px; font-size: 13px; font-weight: 700; cursor: pointer; transition: .18s ease; }
.button:hover { background: #171f28; transform: translateY(-1px); }
.button.secondary { color: var(--navy); background: var(--white); border-color: var(--line-dark); }
.button.secondary:hover { background: var(--sky-2); }
.button.light { color: var(--white); background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.28); }
.button.light:hover { background: rgba(255,255,255,.2); }
.button.danger { color: var(--rose); background: var(--white); border-color: var(--rose-soft); }
.button.danger:hover { color: var(--white); background: var(--rose); border-color: var(--rose); }
.button:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.button svg { width: 16px; height: 16px; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.pill.gold { color: #7a5216; background: var(--gold-soft); }
.pill.green { color: #185c39; background: var(--green-soft); }
.pill.rose { color: #8a3d36; background: var(--rose-soft); }
.pill.sky { color: var(--navy-2); background: var(--sky); }

/* Tablero de contactos (kanban) */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(240px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 8px; }
.board-column { display: flex; flex-direction: column; gap: 10px; padding: 12px; background: var(--sky-2); border-radius: var(--radius-sm); min-height: 160px; }
.board-column-header { display: flex; align-items: center; justify-content: space-between; padding: 0 4px; }
.board-column-header strong { font-size: 12.5px; }
.board-column-header span { color: var(--muted); font-size: 11px; }
.contact-card { padding: 12px; background: var(--white); border: 1px solid var(--line); border-radius: 12px; cursor: pointer; transition: .15s ease; }
.contact-card:hover { border-color: var(--navy-2); box-shadow: var(--shadow-sm); }
.contact-card strong { display: block; font-size: 13px; }
.contact-card small { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.contact-card select { margin-top: 8px; width: 100%; padding: 5px 7px; font-size: 11px; border: 1px solid var(--line-dark); border-radius: 8px; background: var(--white); }

/* Laboratorio de mensajes */
textarea.field { width: 100%; min-height: 160px; padding: 14px; color: var(--ink); background: var(--white); border: 1px solid var(--line-dark); border-radius: var(--radius-sm); font-size: 13.5px; line-height: 1.55; resize: vertical; }
textarea.field:focus, input.field:focus, select.field:focus { outline: 2px solid var(--navy-2); outline-offset: 1px; }
input.field, select.field { width: 100%; padding: 10px 12px; color: var(--ink); background: var(--white); border: 1px solid var(--line-dark); border-radius: 10px; font-size: 13.5px; }
label.field-label { display: block; margin-bottom: 6px; color: var(--ink-soft); font-size: 12px; font-weight: 700; }

.score-bar-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; margin-bottom: 10px; }
.score-bar-row:last-child { margin-bottom: 0; }
.score-bar-label { font-size: 12.5px; color: var(--ink-soft); }
.score-bar-track { grid-column: 1 / -1; height: 8px; background: var(--sky-2); border-radius: 20px; overflow: hidden; }
.score-bar-fill { height: 100%; background: var(--navy-2); border-radius: 20px; transition: width .3s ease; }
.score-value { font-size: 12px; font-weight: 700; color: var(--navy); }

.global-score { display: flex; align-items: center; gap: 14px; padding: 16px; background: var(--sky-2); border-radius: var(--radius-sm); }
.global-score strong { font: 700 32px/1 "Poppins", sans-serif; color: var(--navy); }
.global-score span { color: var(--muted); font-size: 12px; }

/* Progreso / gamificación */
.xp-widget { display: flex; align-items: center; gap: 16px; }
.xp-widget .avatar { width: 52px; height: 52px; font-size: 15px; }
.streak-flame { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; color: #7a5216; background: var(--gold-soft); border-radius: 20px; font-size: 12.5px; font-weight: 700; }
.badge-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.badge-chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; background: var(--sky-2); border-radius: 20px; font-size: 12px; font-weight: 600; color: var(--navy); }

/* Toast + modal */
.toast-region { position: fixed; right: 20px; bottom: 20px; z-index: 60; display: grid; gap: 8px; }
.toast { padding: 12px 16px; color: var(--white); background: var(--ink); border-radius: 10px; font-size: 13px; box-shadow: var(--shadow-md); animation: pageIn .2s ease both; }
.toast.error { background: #7a2e2e; }
.toast.success { background: #1f5b41; }

#modal-root:empty { display: none; }
.modal-backdrop { position: fixed; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(20,24,38,.5); z-index: 50; }
.modal-panel { width: min(520px, 100%); max-height: 90vh; overflow-y: auto; padding: 24px; background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow-md); }
.modal-panel .card-header { margin-bottom: 16px; }
.field-group { display: grid; gap: 12px; margin-bottom: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

.modal-section { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.interaction-list { display: grid; gap: 8px; margin: 10px 0 16px; }
.interaction-item { padding: 10px 12px; background: var(--sky-2); border-radius: 10px; }
.interaction-item-head { display: flex; align-items: center; justify-content: space-between; font-size: 12.5px; font-weight: 700; }
.interaction-item p { margin: 6px 0 0; color: var(--ink-soft); font-size: 12.5px; line-height: 1.5; }
.interaction-item small { display: block; margin-top: 6px; color: var(--muted); font-size: 10.5px; }
.interaction-form { margin-top: 4px; }

.empty-state { padding: 30px; text-align: center; color: var(--muted); background: var(--sky-2); border-radius: var(--radius-sm); font-size: 13px; }

/* Gimnasio de llamadas */
.call-live-status { display: flex; align-items: center; gap: 10px; font: 700 20px "Poppins", sans-serif; color: var(--navy); }
.call-live-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--rose); animation: callPulse 1.4s ease-in-out infinite; }
@keyframes callPulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .45; transform: scale(.8); } }

@media (max-width: 960px) {
  .sidebar { display: none; }
  .mobile-header { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; background: var(--paper); border-bottom: 1px solid var(--line); }
  .mobile-brand { font: 700 16px "Poppins", sans-serif; }
  .mobile-brand small { margin-left: 4px; color: var(--muted); font-size: 10px; font-weight: 600; }
  #app-main { margin-left: 0; padding: 26px 18px 60px; }
  .grid.two, .grid.three, .grid.four { grid-template-columns: 1fr; }
  .hero-panel { grid-template-columns: 1fr; }
}
