:root {
  --navy: #0f2547; --navy-2: #16325e; --azul: #2563eb; --azul-claro: #eef3fe; --texto: #1e293b; --tenue: #64748b;
  --borde: #e2e8f0; --fondo: #f4f6fa; --ok: #16a34a; --ok-fondo: #dcfce7; --error: #b91c1c; --error-fondo: #fee2e2;
  --ambar: #b45309; --ambar-fondo: #fef3c7; --radio: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: Inter, "Segoe UI", system-ui, sans-serif; color: var(--texto); background: var(--fondo); font-size: 15px; }
a { color: var(--azul); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; color: var(--navy); margin: 0 0 4px; }
h2 { font-size: 1.1rem; color: var(--navy); margin: 0 0 12px; }
h3 { font-size: .98rem; color: var(--navy); margin: 0 0 8px; }
.tenue { color: var(--tenue); }
small.tenue, .chico { font-size: .82rem; }

.layout { display: flex; min-height: 100vh; }
.sidebar { width: 236px; flex: 0 0 236px; background: var(--navy); color: #cbd5e1; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.marca { color: #fff; font-weight: 700; font-size: 1.08rem; padding: 22px 20px 18px; line-height: 1.2; }
.marca small { display: block; font-weight: 500; font-size: .72rem; color: #93c5fd; letter-spacing: .08em; text-transform: uppercase; margin-top: 3px; }
.menu { list-style: none; margin: 0; padding: 0 10px; flex: 1; }
.menu a { display: flex; gap: 10px; align-items: center; color: #cbd5e1; padding: 9px 12px; border-radius: 9px; font-size: .92rem; font-weight: 500; }
.menu a:hover { background: var(--navy-2); color: #fff; text-decoration: none; }
.menu a.activo { background: var(--azul); color: #fff; }
.menu svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 18px; }
.menu .sep { height: 1px; background: rgba(255,255,255,.08); margin: 10px 6px; }
.pie-menu { padding: 16px 20px; font-size: .8rem; border-top: 1px solid rgba(255,255,255,.08); }
.pie-menu button { background: none; border: 0; color: #93c5fd; padding: 0; margin-top: 4px; cursor: pointer; font: inherit; }
.contenido { flex: 1; min-width: 0; padding: 28px 32px 60px; max-width: 1240px; }

.cabecera { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.acciones { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tarjeta { background: #fff; border: 1px solid var(--borde); border-radius: var(--radio); padding: 20px; margin-bottom: 18px; }
.rejilla { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.kpis { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 20px; }
.kpi { background: #fff; border: 1px solid var(--borde); border-radius: var(--radio); padding: 16px 18px; }
.kpi b { display: block; font-size: 1.7rem; color: var(--navy); font-variant-numeric: tabular-nums; }
.kpi span { color: var(--tenue); font-size: .85rem; }

.btn { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: .9rem; font-weight: 600; border-radius: 9px; padding: 8px 14px;
  border: 1px solid var(--borde); background: #fff; color: var(--texto); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: #cbd5e1; background: #f8fafc; text-decoration: none; }
.btn-prim { background: var(--azul); border-color: var(--azul); color: #fff; }
.btn-prim:hover { background: #1d4ed8; border-color: #1d4ed8; }
.btn-peligro { color: var(--error); }
.btn-peligro:hover { background: var(--error-fondo); border-color: #fecaca; }
.btn-chico { padding: 5px 10px; font-size: .82rem; }
form.inline { display: inline; margin: 0; }

label { font-size: .85rem; font-weight: 600; color: #334155; display: block; margin-bottom: 5px; }
input[type=text], input[type=email], input[type=number], input[type=date], input[type=time], input[type=datetime-local], input[type=search], select, textarea {
  width: 100%; font: inherit; font-size: .93rem; padding: 9px 11px; border: 1px solid #cbd5e1; border-radius: 9px; background: #fff; color: var(--texto); }
input:focus, select:focus, textarea:focus { outline: 2px solid #bfdbfe; border-color: var(--azul); }
textarea { min-height: 90px; resize: vertical; }
.campo { margin-bottom: 14px; }
.fila { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 500; font-size: .9rem; margin-bottom: 8px; cursor: pointer; }
.check input { margin-top: 3px; }
.ayuda { font-size: .8rem; color: var(--tenue); margin-top: 4px; }

table.tabla { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tabla th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--tenue); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--borde); }
.tabla td { padding: 9px 10px; border-bottom: 1px solid #f1f5f9; vertical-align: top; }
.tabla tr:hover td { background: #fafbfd; }
.tabla-scroll { overflow-x: auto; }
.vacio { text-align: center; color: var(--tenue); padding: 30px 10px; }

.chip { display: inline-block; font-size: .72rem; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: #f1f5f9; color: #475569; white-space: nowrap; }
.chip-ok { background: var(--ok-fondo); color: #166534; }
.chip-azul { background: var(--azul-claro); color: #1d4ed8; }
.chip-ambar { background: var(--ambar-fondo); color: var(--ambar); }
.chip-error { background: var(--error-fondo); color: var(--error); }

.flash { padding: 11px 15px; border-radius: 10px; margin-bottom: 14px; font-size: .9rem; }
.flash-ok { background: var(--ok-fondo); color: #166534; }
.flash-error { background: var(--error-fondo); color: var(--error); }
.banda-sim { background: var(--ambar-fondo); color: var(--ambar); padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; font-size: .88rem; }

.barra { display: grid; grid-template-columns: minmax(90px, 32%) 1fr 64px; gap: 10px; align-items: center; margin: 6px 0; font-size: .88rem; }
.barra .riel { background: #f1f5f9; height: 12px; border-radius: 99px; overflow: hidden; }
.barra .riel i { display: block; height: 100%; background: var(--azul); border-radius: 99px; }
.barra span:last-child { text-align: right; font-variant-numeric: tabular-nums; color: var(--tenue); }
.textos { max-height: 230px; overflow-y: auto; margin: 0; padding: 0; list-style: none; }
.textos li { padding: 7px 10px; border-left: 3px solid #bfdbfe; background: #f8fafc; margin-bottom: 6px; border-radius: 0 8px 8px 0; font-size: .88rem; }
.progreso { background: #e2e8f0; height: 10px; border-radius: 99px; overflow: hidden; }
.progreso i { display: block; height: 100%; background: var(--ok); }

.copiar { display: flex; gap: 8px; }
.copiar input { font-family: ui-monospace, monospace; font-size: .82rem; }

/* Editor de correo */
.editor-barra { display: flex; gap: 4px; flex-wrap: wrap; padding: 6px; border: 1px solid #cbd5e1; border-bottom: 0; border-radius: 9px 9px 0 0; background: #f8fafc; }
.editor-barra button, .editor-barra select { font: inherit; font-size: .82rem; border: 1px solid transparent; background: none; border-radius: 6px; padding: 4px 8px; cursor: pointer; color: #334155; }
.editor-barra button:hover { background: #e2e8f0; }
.editor-barra select { border-color: #cbd5e1; background: #fff; }
.editor { min-height: 260px; border: 1px solid #cbd5e1; border-radius: 0 0 9px 9px; padding: 14px 16px; background: #fff; line-height: 1.6; outline: none; }
.editor:focus { border-color: var(--azul); outline: 2px solid #bfdbfe; }
.editor .var, .var { background: var(--azul-claro); color: #1d4ed8; border-radius: 4px; padding: 0 3px; font-family: ui-monospace, monospace; font-size: .85em; }
iframe.previa { width: 100%; height: 520px; border: 1px solid var(--borde); border-radius: var(--radio); background: #f1f5f9; }

/* Constructor de encuestas */
.pregunta-ed { border: 1px solid var(--borde); border-radius: var(--radio); padding: 14px 16px; margin-bottom: 12px; background: #fff; position: relative; }
.pregunta-ed.seccion { background: var(--azul-claro); border-color: #bfdbfe; }
.pregunta-ed .cab { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.pregunta-ed .num { font-weight: 700; color: var(--tenue); font-size: .82rem; min-width: 26px; }
.pregunta-ed .cab select { width: auto; }
.pregunta-ed .herr { margin-left: auto; display: flex; gap: 2px; }
.pregunta-ed .herr button { border: 0; background: none; cursor: pointer; padding: 4px 7px; border-radius: 6px; color: var(--tenue); font-size: .95rem; }
.pregunta-ed .herr button:hover { background: #f1f5f9; color: var(--texto); }
.opcion-ed { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.opcion-ed span { color: #94a3b8; width: 18px; text-align: center; }
.agregar-preg { display: flex; gap: 6px; flex-wrap: wrap; padding: 14px; border: 2px dashed #cbd5e1; border-radius: var(--radio); justify-content: center; }

.home-fab { position: fixed; right: 18px; bottom: 18px; width: 46px; height: 46px; border-radius: 50%; background: var(--navy); color: #fff;
  display: grid; place-items: center; box-shadow: 0 8px 20px rgba(15,37,71,.3); z-index: 50; }

.login-caja { max-width: 400px; margin: 10vh auto; background: #fff; border: 1px solid var(--borde); border-radius: 18px; padding: 30px; }

@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; }
  .menu { display: flex; flex-wrap: wrap; gap: 2px; padding-bottom: 10px; }
  .menu .sep { display: none; }
  .contenido { padding: 20px 16px 60px; }
}
