:root {
  --accent: #c2410c;
  --ink: #1f2328;
  --muted: #5f6368;
  --line: #dadce0;
  --card: #fff;
  --danger: #b3261e;
  --ok: #137333;
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: color-mix(in srgb, var(--accent) 9%, #f6f6f4); min-height: 100vh; line-height: 1.45; }
body.admin { background: #f4f4f1; }
a { color: color-mix(in srgb, var(--accent) 80%, #000); }
h1, h2 { line-height: 1.2; }
input, textarea, select, button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .3em; padding: .5em 1em; border-radius: 999px;
  border: 1px solid var(--line); background: #fff; cursor: pointer; text-decoration: none; color: var(--ink);
  white-space: nowrap; font-size: .95rem;
}
.btn:hover { background: #f1f1ef; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(.92); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.big { padding: .65em 1.6em; font-size: 1rem; }
button.icon { border: 0; background: none; cursor: pointer; padding: .35em .5em; border-radius: 6px; color: var(--muted); font-size: 1rem; }
button.icon:hover { background: #eee; color: var(--ink); }
button.icon.danger:hover { color: var(--danger); }
button.link { border: 0; background: none; padding: 0; color: var(--muted); cursor: pointer; }
button.link:hover { text-decoration: underline; color: var(--ink); }

/* ---------- Estructura admin ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: .6rem 1.25rem; background: #fff; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 600; text-decoration: none; color: var(--ink); font-size: 1.1rem; }
.brand small { color: var(--muted); font-weight: 400; font-size: .85rem; }
.logo { display: grid; place-items: center; width: 1.8rem; height: 1.8rem; border-radius: 6px; background: #c2410c; color: #fff; font-size: 1rem; }
main { max-width: 820px; margin: 0 auto; padding: 1.25rem 1rem 4rem; }
main.narrow { max-width: 400px; padding-top: 3rem; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem 1.5rem; margin-bottom: .9rem; }
.empty { text-align: center; color: var(--muted); }
.alert { background: #fce8e6; color: var(--danger); border-radius: 8px; padding: .7rem 1rem; }
.note { background: #fff8e1; border: 1px solid #f5d77a; border-radius: 8px; padding: .6rem 1rem; font-size: .92rem; }
.hint, .muted { color: var(--muted); font-size: .9rem; }
.meta { color: var(--muted); font-size: .9rem; margin: .25rem 0 0; }
.pill { display: inline-block; padding: .05em .6em; border-radius: 999px; font-size: .8rem; font-weight: 600; }
.pill.on { background: #e6f4ea; color: var(--ok); }
.pill.off { background: #eee; color: var(--muted); }

.login h1 { margin-top: 0; }
.login h2 { font-size: 1.05rem; margin: 1.6rem 0 .4rem; }
.top-actions { display: flex; gap: .25rem; align-items: center; }
.steps { padding-left: 1.2rem; line-height: 1.5; }
.steps li { margin-bottom: .8rem; }
.qr { width: 220px; max-width: 100%; margin: .6rem 0; background: #fff; }
.qr svg { display: block; width: 100%; height: auto; }
.secret { display: inline-block; margin-top: .3rem; font-size: 1rem; letter-spacing: .05em; user-select: all; word-break: break-all; }
.login .code-input { font-size: 1.5rem; letter-spacing: .3em; text-align: center; max-width: 12rem; }
.login label, .settings label { display: block; margin-bottom: 1rem; font-size: .92rem; color: var(--muted); }
.login input, .settings input:not([type=checkbox]), .settings select, .settings textarea {
  display: block; width: 100%; margin-top: .3rem; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink);
}
.settings input[type=color] { height: 2.6rem; padding: .2rem; max-width: 6rem; }
.settings h2 { font-size: 1.1rem; margin: 0 0 1rem; }

/* Lista de formularios */
.form-item { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; border-left: 6px solid var(--accent); }
.form-item h2 { margin: 0; font-size: 1.15rem; }
.form-item h2 a { color: var(--ink); text-decoration: none; }
.form-item h2 a:hover { text-decoration: underline; }
.actions { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
details.menu { position: relative; }
details.menu summary { list-style: none; }
details.menu summary::-webkit-details-marker { display: none; }
.menu-pop { position: absolute; right: 0; top: 110%; z-index: 5; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 24px #0002; min-width: 240px; padding: .3rem 0; }
.menu-pop a, .menu-pop button { display: block; width: 100%; text-align: left; padding: .55rem 1rem; border: 0; background: none; cursor: pointer; text-decoration: none; color: var(--ink); }
.menu-pop a:hover, .menu-pop button:hover { background: #f4f4f1; }
.menu-pop .danger { color: var(--danger); }

/* Barra secundaria con pestañas */
.subnav { display: flex; align-items: center; justify-content: space-between; gap: .75rem 1rem; flex-wrap: wrap; padding: .5rem 1.25rem; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.subnav > a { color: var(--muted); text-decoration: none; font-size: .92rem; }
.subnav-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.subnav-actions form { margin: 0; }
.tabs { display: flex; gap: .25rem; }
.tab { border: 0; background: none; padding: .55rem .9rem; cursor: pointer; color: var(--muted); text-decoration: none; border-bottom: 3px solid transparent; font-weight: 500; }
.tab.active { color: var(--ink); border-bottom-color: var(--accent); }
.tabs.inline { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: .25rem; }
.count { display: inline-block; min-width: 1.5em; padding: 0 .4em; border-radius: 999px; background: #eee; font-size: .8rem; text-align: center; }
.save-state { font-size: .85rem; color: var(--muted); }
.save-state.pending { color: #8a6d00; }
.save-state.error { color: var(--danger); }

.switch { display: inline-flex !important; align-items: center; gap: .5rem; cursor: pointer; color: var(--ink) !important; }
.switch input { appearance: none; width: 2.3rem; height: 1.3rem; border-radius: 999px; background: #c8c8c8; position: relative; cursor: pointer; margin: 0; transition: background .15s; flex: none; }
.switch input::after { content: ""; position: absolute; top: .15rem; left: .15rem; width: 1rem; height: 1rem; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px #0003; }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(1rem); }

/* ---------- Editor ---------- */
.q-head { border-top: 10px solid var(--accent); }
.title-input { width: 100%; font-size: 1.9rem; border: 0; border-bottom: 1px solid transparent; padding: .2rem 0; outline: none; }
.desc-input { width: 100%; border: 0; border-bottom: 1px solid transparent; resize: none; outline: none; color: var(--muted); padding: .3rem 0; overflow: hidden; }
.title-input:focus, .desc-input:focus, .q-title:focus, .q-help:focus { border-bottom: 2px solid var(--accent); }
.q { position: relative; padding-top: 1.4rem; border-left: 6px solid transparent; transition: border-color .15s; }
.q:focus-within { border-left-color: var(--accent); box-shadow: 0 2px 10px #0001; }
.q.dragging { opacity: .4; }
.q.drop { outline: 2px dashed var(--accent); }
.q-drag { position: absolute; top: .1rem; left: 50%; transform: translateX(-50%); color: #bbb; cursor: grab; letter-spacing: -2px; font-size: .9rem; user-select: none; }
.q-row { display: flex; gap: .75rem; flex-wrap: wrap; }
.q-title { flex: 1 1 18rem; font-size: 1.05rem; padding: .7rem .8rem; background: #f6f6f4; border: 0; border-bottom: 1px solid var(--line); border-radius: 6px 6px 0 0; outline: none; }
.q-type { flex: 0 1 15rem; padding: .6rem; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.q-help { width: 100%; margin-top: .5rem; border: 0; border-bottom: 1px solid transparent; resize: none; outline: none; font-size: .92rem; color: var(--muted); padding: .3rem 0; overflow: hidden; }
.q-section { border-top: 6px solid var(--accent); }
.q-sample { margin-top: .75rem; color: #9aa0a6; border-bottom: 1px dotted #bbb; padding: .3rem 0; width: 60%; font-size: .92rem; }
.q-sample.long { width: 90%; }
.opts { margin-top: .75rem; }
.opt { display: flex; align-items: center; gap: .6rem; padding: .15rem 0; }
.opt .marker { width: 1.4rem; color: #9aa0a6; text-align: center; flex: none; }
.opt input { flex: 1; border: 0; border-bottom: 1px solid transparent; padding: .4rem 0; outline: none; }
.opt input:hover { border-bottom-color: var(--line); }
.opt input:focus { border-bottom: 2px solid var(--accent); }
.opt.add { color: var(--muted); font-size: .92rem; }
.scale-ed { display: grid; gap: .6rem; margin-top: .75rem; font-size: .92rem; }
.scale-ed select { padding: .3rem; border: 1px solid var(--line); border-radius: 6px; }
.scale-ed input { border: 0; border-bottom: 1px solid var(--line); padding: .3rem 0; outline: none; min-width: 12rem; }
.q-foot { display: flex; justify-content: flex-end; align-items: center; gap: .15rem; margin-top: 1rem; padding-top: .6rem; border-top: 1px solid #eee; }
.q-foot .sep { width: 1px; height: 1.5rem; background: var(--line); margin: 0 .6rem; }
.add-bar { display: flex; gap: .5rem; flex-wrap: wrap; justify-content: center; margin-top: 1rem; }

dialog.share { border: 0; border-radius: 12px; padding: 1.5rem; width: min(560px, calc(100vw - 2rem)); box-shadow: 0 10px 40px #0004; }
dialog.share::backdrop { background: #0006; }
dialog.share h2 { margin-top: 0; }
dialog.share label { display: block; margin-bottom: 1rem; color: var(--muted); font-size: .92rem; }
dialog .close { position: absolute; right: .8rem; top: .6rem; border: 0; background: none; font-size: 1.6rem; cursor: pointer; color: var(--muted); }
.copy-row { display: flex; gap: .5rem; margin-top: .3rem; }
.copy-row input { flex: 1; min-width: 0; padding: .5rem .7rem; border: 1px solid var(--line); border-radius: 8px; background: #f6f6f4; color: var(--ink); }

/* ---------- Respuestas ---------- */
.resp-head { border-top: 10px solid var(--accent); padding-bottom: 0; }
.resp-head h1 { margin: 0; font-size: 1.6rem; }
.summary h2 { font-size: 1.05rem; margin: 0; }
.bars { margin-top: 1rem; display: grid; gap: .5rem; }
.bar-row { display: grid; grid-template-columns: minmax(6rem, 14rem) 1fr auto; gap: .75rem; align-items: center; font-size: .92rem; }
.bar-label { overflow-wrap: anywhere; }
.bar { height: 1.1rem; background: #f1f1ef; border-radius: 4px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: 4px; min-width: 2px; }
.bar-n { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 5.5rem; text-align: right; }
.avg { margin: .75rem 0 0; }
.text-answers { list-style: none; padding: 0; margin: 1rem 0 0; display: grid; gap: .4rem; }
.text-answers li { background: #f6f6f4; border-radius: 6px; padding: .5rem .8rem; overflow-wrap: anywhere; }
.table-wrap { overflow-x: auto; padding: 0; }
.resp-table { border-collapse: collapse; width: 100%; font-size: .9rem; }
.resp-table th, .resp-table td { padding: .55rem .8rem; border-bottom: 1px solid #eee; text-align: left; vertical-align: top; min-width: 9rem; }
.resp-table th { background: #fafaf8; position: sticky; top: 0; font-weight: 600; }
.resp-table td:last-child, .resp-table th:last-child { min-width: 0; }
.resp-table form { margin: 0; }
.nowrap { white-space: nowrap; }

/* ---------- Formulario público ---------- */
.form-page { max-width: 680px; padding-top: 1.5rem; }
.f-head { border-top: 10px solid var(--accent); }
.f-head h1 { margin: 0 0 .5rem; font-size: 2rem; font-weight: 500; }
.f-desc { white-space: normal; overflow-wrap: anywhere; }
.req-note { color: var(--danger); font-size: .88rem; margin: 1rem 0 0; padding-top: .8rem; border-top: 1px solid #eee; }
.star { color: var(--danger); }
.f-section { border-top: 6px solid var(--accent); }
.f-section h2 { margin: 0 0 .4rem; font-weight: 500; }
.f-q fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.q-label { display: block; font-size: 1.05rem; font-weight: 500; padding: 0; margin-bottom: .3rem; }
.f-q .q-help { color: var(--muted); font-size: .9rem; margin: 0 0 .6rem; }
.f-q.invalid { border-color: var(--danger); }
.q-error { color: var(--danger); font-size: .88rem; margin: .7rem 0 0; }
.line { width: 100%; max-width: 100%; border: 0; border-bottom: 1px solid var(--line); padding: .5rem 0; outline: none; background: transparent; margin-top: .5rem; }
.line:focus { border-bottom: 2px solid var(--accent); }
textarea.line { resize: vertical; }
input[type=email].line, input[type=text].line, input[type=date].line { max-width: 28rem; }
.f-q select { margin-top: .5rem; padding: .6rem; border: 1px solid var(--line); border-radius: 6px; min-width: 14rem; max-width: 100%; background: #fff; }
.choices { display: grid; gap: .15rem; margin-top: .4rem; }
.choice { display: flex; align-items: center; gap: .7rem; padding: .45rem 0; cursor: pointer; }
.choice input[type=radio], .choice input[type=checkbox], .scale-pt input { accent-color: var(--accent); width: 1.15rem; height: 1.15rem; flex: none; margin: 0; }
.choice.other .other-text { margin: 0; flex: 1; max-width: 22rem; }
.scale { display: flex; align-items: flex-end; gap: .25rem; flex-wrap: wrap; margin-top: .6rem; }
.scale-pt { display: flex; flex-direction: column; align-items: center; gap: .35rem; padding: .3rem .55rem; cursor: pointer; font-size: .9rem; }
.scale-end { font-size: .88rem; color: var(--muted); padding: 0 .5rem .45rem; }
.f-submit { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-top: 1rem; }
.f-submit .hint { margin: 0; flex: 1 1 16rem; }
.preview-bar { background: #fff8e1; border: 1px solid #f5d77a; border-radius: 8px; padding: .5rem 1rem; font-size: .9rem; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

@media (max-width: 600px) {
  .card { padding: 1rem; }
  main { padding-left: .6rem; padding-right: .6rem; }
  .f-head h1 { font-size: 1.6rem; }
  .title-input { font-size: 1.5rem; }
  .bar-row { grid-template-columns: 1fr auto; }
  .bar-row .bar { grid-column: 1 / -1; grid-row: 2; }
  .subnav { padding: .5rem .75rem; }
}

/* Avisos legales: aviso corto del RGPD en el formulario, pie y páginas de privacidad y aviso legal */
.f-privacy { color: var(--muted); font-size: .85rem; line-height: 1.5; margin: 1.2rem .2rem 0; }
.legal-foot { color: var(--muted); font-size: .8rem; text-align: center; margin: 2rem 0 1rem; line-height: 1.6; }
.legal-foot a, .f-privacy a { color: inherit; }
.legal { line-height: 1.6; }
.legal h1 { margin: 0 0 .3rem; }
.legal h2 { font-size: 1.1rem; margin: 1.8rem 0 .5rem; }
.legal ul { padding-left: 1.2rem; }
.legal li { margin-bottom: .4rem; }
.legal-lang { float: right; margin: 0; font-size: .9rem; }
