/* Pulso — sistema de diseño (extraído de "Encuestas – App del encuestador") */
:root {
  --accent: #2447D6;
  --accent-dark: #1A33A0;
  --accent-tint: #DDE3FB;
  --accent-soft: #EEF2FF;
  --bg: #F4F5F7;
  --surface: #FFFFFF;
  --text: #101828;
  --text-2: #344054;
  --muted: #475467;
  --faint: #98A2B3;
  --border: #E4E7EC;
  --border-strong: #D0D5DD;
  --chip: #F2F4F7;
  --ok: #067647;  --ok-bg: #ECFDF3;
  --err: #B42318; --err-bg: #FEF3F2; --err-line: #FDA29B;
  --warn: #B54708; --warn-bg: #FFFAEB;
  --star: #F2A900;
  --font: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: 'Space Grotesk', Inter, system-ui, sans-serif;
  --mono: ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dark); }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--font-display); margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
h2 { font-size: 20px; font-weight: 700; }
h3 { font-size: 17px; font-weight: 700; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Layout del panel ---------- */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--border); padding: 20px 14px; display: flex; flex-direction: column; gap: 22px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.brand-mark { width: 40px; height: 40px; border-radius: 12px; background: var(--accent); display: grid; place-items: center; flex-shrink: 0; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 20px; letter-spacing: -0.01em; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 12px; color: var(--muted); font-weight: 600; font-size: 14px; }
.nav a:hover { background: var(--chip); color: var(--text); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.nav svg, .btn svg { flex-shrink: 0; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.me { display: flex; align-items: center; gap: 10px; padding: 8px 6px; }
.avatar { width: 44px; height: 44px; border-radius: 999px; background: var(--accent-tint); color: var(--accent-dark); font-weight: 700; display: grid; place-items: center; font-size: 15px; flex-shrink: 0; }
.avatar.lg { width: 64px; height: 64px; font-size: 22px; }
.main { padding: 28px 36px 60px; max-width: 1180px; width: 100%; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.topbar .sub { color: var(--muted); font-size: 14px; margin-top: 4px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.mobile-bar { display: none; }

/* ---------- Componentes ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 20px; }
.card.tight { padding: 4px 16px; border-radius: 16px; }
.card + .card, .stack > * + * { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.side-right { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
.eyebrow { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 8px; display: block; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1.5px solid var(--border-strong); background: var(--surface); color: var(--text); font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--bg); color: var(--text); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }
.btn.danger { border-color: var(--err-line); color: var(--err); }
.btn.danger:hover { background: var(--err-bg); color: var(--err); }
.btn.block { width: 100%; min-height: 52px; font-size: 16px; }
.btn.sm { min-height: 36px; padding: 0 12px; border-radius: 10px; font-size: 13px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.icon { width: 44px; padding: 0; }
.btn:focus-visible, .field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible, .opt:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }

.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: var(--chip); color: var(--text-2); }
.chip.accent { background: var(--accent); color: #fff; }
.chip.tint { background: var(--accent-tint); color: var(--accent-dark); }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.err { background: var(--err-bg); color: var(--err); }

.alert { border-radius: 12px; padding: 12px 14px; font-size: 14px; margin-bottom: 16px; }
.alert.ok { background: var(--ok-bg); color: var(--ok); }
.alert.err { background: var(--err-bg); color: var(--err); }
.alert ul { margin: 0; padding-left: 18px; }

/* Formularios */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label { font-size: 14px; font-weight: 600; color: var(--text-2); }
.field input[type=text], .field input[type=password], .field input[type=email], .field input[type=number], .field input[type=date], .field select, .field textarea, .input {
  min-height: 48px; border-radius: 12px; border: 1.5px solid var(--border-strong); background: #fff; padding: 0 14px; font-size: 16px; width: 100%;
}
.field textarea { padding: 12px 14px; min-height: 96px; line-height: 1.5; resize: vertical; }
.field .hint { font-size: 12px; color: var(--muted); }
.field .error { font-size: 13px; color: var(--err); }
.field input.invalid, .field textarea.invalid { border-color: var(--err); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 500; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); margin: 0; }

/* Tablas */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 12px; border-bottom: 1px solid #F2F4F7; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Métricas */
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 4px; }
.stat b { font-family: var(--font-display); font-size: 30px; line-height: 1.1; letter-spacing: -0.02em; }
.stat span { font-size: 13px; color: var(--muted); }
.progress { height: 8px; background: var(--border); border-radius: 999px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.progress.ok > i { background: var(--ok); }

/* Barras de distribución */
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 220px) minmax(0, 1fr) 84px; gap: 12px; align-items: center; font-size: 14px; }
.bar-row .lbl { overflow: hidden; text-overflow: ellipsis; }
.bar-track { height: 14px; background: var(--chip); border-radius: 999px; overflow: hidden; }
.bar-track > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; min-width: 0; }
.bar-row .val { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; }
.spark { display: flex; align-items: flex-end; gap: 6px; height: 120px; }
.spark > div { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; height: 100%; min-width: 0; }
.spark i { display: block; width: 100%; background: var(--accent); border-radius: 6px 6px 2px 2px; min-height: 3px; }
.spark i.zero { background: var(--border); }
.spark span { font-size: 10px; color: var(--muted); white-space: nowrap; }
.spark > div:not(:nth-child(3n+1)) span { visibility: hidden; }

/* Tarjetas de encuesta (como la lista de la app) */
.survey-card { display: flex; flex-direction: column; gap: 12px; color: var(--text); }
.survey-card:hover { color: var(--text); border-color: var(--accent); }
.survey-card .t { font-family: var(--font-display); font-size: 19px; line-height: 1.2; font-weight: 700; }
.survey-card .foot { display: flex; align-items: center; justify-content: space-between; border-top: 1px solid #F2F4F7; padding-top: 12px; font-size: 13px; color: var(--muted); }

/* Lista de preguntas */
.qlist > div { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-bottom: 1px solid #F2F4F7; }
.qlist > div:last-child { border-bottom: 0; }
.qn { width: 24px; height: 24px; border-radius: 999px; background: var(--chip); color: var(--text-2); font-size: 12px; font-weight: 700; display: grid; place-items: center; flex-shrink: 0; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; min-width: 0; font-family: var(--mono); font-size: 13px !important; min-height: 44px; }
.api-line { font-size: 12px; color: var(--muted); font-family: var(--mono); }
.nps { display: flex; gap: 6px; flex-wrap: wrap; }
.nps span { background: var(--chip); border-radius: 10px; padding: 6px 10px; font-size: 13px; }
.quote { background: var(--bg); border-radius: 10px; padding: 8px 12px; font-size: 14px; margin-top: 6px; }
.pager { margin-top: 16px; display: flex; gap: 8px; justify-content: center; align-items: center; font-size: 14px; }
.pager nav > div:first-child { display: none; }
.pager svg { width: 18px; height: 18px; }
.pager span[aria-current] span { background: var(--accent); color: #fff; }
.pager a, .pager span span { padding: 6px 10px; border-radius: 8px; }
.pager nav div:last-child > span, .pager nav div:last-child > a { display: inline-flex; }
.pager p { display: none; }

/* ---------- Constructor de preguntas ---------- */
.qb { border: 1px solid var(--border); border-radius: 16px; background: #fff; overflow: hidden; margin-bottom: 12px; }
.qb-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: #FAFAFB; border-bottom: 1px solid var(--border); }
.qb-head .qn { background: var(--accent-tint); color: var(--accent-dark); }
.qb-head select { min-height: 38px; border-radius: 10px; border: 1.5px solid var(--border-strong); padding: 0 10px; background: #fff; font-size: 14px; font-weight: 600; }
.qb-body { padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.qb-body .input { min-height: 44px; font-size: 15px; }
.opts { display: flex; flex-direction: column; gap: 8px; }
.opt-row { display: flex; gap: 8px; align-items: center; }
.opt-row .input { flex: 1; }
.qb-actions { margin-left: auto; display: flex; gap: 4px; }
.add-q { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }

/* ---------- Login ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.auth-pane { padding: 56px 24px; display: flex; align-items: center; justify-content: center; }
.auth-form { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 24px; }
.auth-hero { background: var(--accent); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: center; gap: 20px; }
.auth-hero h2 { font-size: 36px; line-height: 1.1; letter-spacing: -0.02em; }
.auth-hero p { opacity: .85; max-width: 440px; font-size: 17px; line-height: 1.5; }
.auth-hero ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 10px; }
.auth-hero li { display: flex; gap: 10px; align-items: center; }
.demo { border-top: 1px solid var(--border); padding-top: 18px; display: flex; flex-direction: column; gap: 10px; }
.demo-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.demo-grid button { min-height: 56px; text-align: left; border: 1px solid var(--border-strong); background: #fff; border-radius: 12px; padding: 8px 12px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; }
.demo-grid button b { font-size: 14px; } .demo-grid button span { font-size: 12px; color: var(--muted); }

/* ---------- Encuesta pública (mismo lenguaje visual que la app) ---------- */
.public { max-width: 640px; margin: 0 auto; padding: 24px 20px 60px; display: flex; flex-direction: column; gap: 18px; }
.public .q { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.public .q.has-error { border-color: var(--err); }
.public .q h3 { font-size: 19px; font-weight: 600; line-height: 1.3; }
.public .req { color: var(--err); }
.opt { display: flex; align-items: center; gap: 12px; min-height: 54px; padding: 12px 14px; border-radius: 14px; border: 1.5px solid var(--border-strong); background: #fff; cursor: pointer; font-size: 16px; }
.opt input { width: 22px; height: 22px; accent-color: var(--accent); margin: 0; flex-shrink: 0; }
.opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.opts-col { display: flex; flex-direction: column; gap: 10px; }
.seg { display: grid; gap: 8px; }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: grid; place-items: center; height: 52px; border-radius: 12px; border: 1.5px solid var(--border-strong); background: #fff; font-weight: 600; font-size: 17px; }
.seg input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.seg.binary span { height: 80px; border-radius: 16px; }
.stars { display: flex; gap: 6px; justify-content: center; flex-direction: row-reverse; }
.stars input { position: absolute; opacity: 0; }
.stars label { cursor: pointer; width: 52px; height: 52px; display: grid; place-items: center; }
.stars label svg { width: 42px; height: 42px; fill: none; stroke: var(--faint); stroke-width: 1.6; stroke-linejoin: round; }
.stars input:checked ~ label svg, .stars label:hover svg, .stars label:hover ~ label svg { fill: var(--star); stroke: #C27C00; }
.stars input:focus-visible + label { outline: 2px solid var(--accent); border-radius: 12px; }
.ends { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--muted); }
.public-foot { text-align: center; font-size: 12px; color: var(--muted); }
.center-card { max-width: 520px; margin: 12vh auto; padding: 0 20px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.badge-lg { width: 72px; height: 72px; border-radius: 999px; display: grid; place-items: center; }

@media (max-width: 1000px) {
  .grid.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.side-right { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px 14px; gap: 8px; }
  .side .nav { flex-direction: row; flex-wrap: wrap; order: 3; width: 100%; }
  .side-foot { margin: 0 0 0 auto; flex-direction: row; align-items: center; }
  .side-foot .me > div:last-child { display: none; }
  .main { padding: 20px 16px 48px; }
  .grid.c2, .grid.c3, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-hero { display: none; }
  .bar-row { grid-template-columns: minmax(70px, 120px) minmax(0, 1fr) 70px; }
  h1 { font-size: 24px; }
}
@media print { .side, .actions { display: none; } .shell { display: block; } }
