:root {
  --navy: #1f3a68;
  --navy-2: #2c4f8a;
  --accent: #e8a33d;
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #1c2433;
  --muted: #5d6b82;
  --line: #dde3ec;
  --ok: #2e7d4f;
  --err: #b3261e;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 16px;
}
header.top {
  background: var(--navy);
  color: #fff;
  padding: 14px 20px;
}
header.top .inner { max-width: 820px; margin: 0 auto; display: flex; align-items: center; gap: 12px; justify-content: space-between; }
header.top h1 { font-size: 18px; margin: 0; font-weight: 600; }
header.top .brand { font-size: 13px; opacity: .8; letter-spacing: .04em; text-transform: uppercase; }
main { max-width: 820px; margin: 0 auto; padding: 20px 16px 60px; }
.wide main, main.wide { max-width: 1100px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(20, 30, 60, .04);
}
h2 { color: var(--navy); font-size: 22px; margin: 0 0 8px; }
h3 { color: var(--navy); font-size: 17px; margin: 0 0 8px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); font-size: 14px; }
.pre { white-space: pre-wrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--navy); background: var(--navy); color: #fff;
  padding: 10px 18px; border-radius: 8px; font-size: 15px; font-weight: 600;
  cursor: pointer; text-decoration: none; font-family: inherit;
}
.btn:hover { background: var(--navy-2); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.secondary { background: #fff; color: var(--navy); }
.btn.secondary:hover { background: #eef2f8; }
.btn.danger { background: #fff; color: var(--err); border-color: var(--err); }
.btn.small { padding: 5px 10px; font-size: 13px; font-weight: 500; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }

/* Pytania */
.q { padding: 18px 0; border-top: 1px solid var(--line); }
.q:first-of-type { border-top: 0; padding-top: 4px; }
.q-text { font-weight: 600; margin-bottom: 4px; }
.q-text .req { color: var(--err); margin-left: 3px; }
.q-help { color: var(--muted); font-size: 14px; margin-bottom: 8px; }
.q.invalid .q-text { color: var(--err); }
.q .err-msg { color: var(--err); font-size: 13px; margin-top: 6px; display: none; }
.q.invalid .err-msg { display: block; }
.opts { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.opt {
  display: flex; align-items: flex-start; gap: 10px; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: 8px; cursor: pointer; background: #fff;
}
.opt:hover { border-color: var(--navy-2); }
.opt input { margin-top: 4px; accent-color: var(--navy); }
.opt.checked { border-color: var(--navy); background: #eef2f8; }
.scale { display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: 6px; margin-top: 8px; }
.scale .opt { flex-direction: column; align-items: center; text-align: center; font-size: 13px; padding: 10px 6px; }
.scale .opt input { margin: 0 0 4px; }
.scale .opt.na { background: #fafbfc; }
@media (max-width: 640px) {
  .scale { grid-template-columns: 1fr; }
  .scale .opt { flex-direction: row; text-align: left; font-size: 15px; }
  .scale .opt input { margin: 4px 0 0; }
}
textarea, input[type=text], input[type=password], input[type=email], select {
  width: 100%; font: inherit; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; color: var(--text);
}
textarea { min-height: 110px; resize: vertical; }
textarea:focus, input:focus, select:focus { outline: 2px solid #b9c8e3; border-color: var(--navy-2); }

.progress { height: 6px; background: #e3e8f0; border-radius: 99px; overflow: hidden; margin: 4px 0 16px; }
.progress > div { height: 100%; background: var(--accent); transition: width .3s; }
.nav { display: flex; gap: 10px; align-items: center; margin-top: 18px; flex-wrap: wrap; }
.save-state { font-size: 13px; color: var(--muted); }
.save-state.ok { color: var(--ok); }
.save-state.err { color: var(--err); }
.notice { border-left: 4px solid var(--accent); background: #fff8ec; padding: 10px 14px; border-radius: 6px; font-size: 14px; margin-bottom: 14px; }
.center { text-align: center; }
.big-icon { font-size: 44px; line-height: 1; margin-bottom: 10px; color: var(--ok); }
.banner { background: var(--accent); color: #1c2433; text-align: center; font-size: 14px; padding: 6px; font-weight: 600; }
.spin { display: inline-block; width: 22px; height: 22px; border: 3px solid #c9d3e3; border-top-color: var(--navy); border-radius: 50%; animation: s 1s linear infinite; }
@keyframes s { to { transform: rotate(360deg); } }

/* Admin */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.tabs button {
  background: none; border: 0; border-bottom: 3px solid transparent; padding: 10px 14px;
  font: inherit; font-weight: 600; color: var(--muted); cursor: pointer;
}
.tabs button.active { color: var(--navy); border-bottom-color: var(--accent); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.stat b { display: block; font-size: 24px; color: var(--navy); }
.stat span { font-size: 13px; color: var(--muted); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 13px; }
.table-wrap { overflow-x: auto; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.pill.nowa { background: #eef1f6; color: #4a5870; }
.pill.w_trakcie { background: #fff3dc; color: #8a5a00; }
.pill.wyslana { background: #e2f3e8; color: var(--ok); }
.qedit { border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-bottom: 10px; background: #fff; }
.qedit.sekcja { background: #f1f5fb; border-color: #c9d6ea; }
.qedit .head { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.qedit .num { font-weight: 700; color: var(--navy); min-width: 28px; }
.qedit select { width: auto; }
.qedit label.inline { display: inline-flex; gap: 6px; align-items: center; font-size: 14px; margin-right: 14px; }
.qedit .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
@media (max-width: 700px) { .qedit .grid2 { grid-template-columns: 1fr; } }
.field { margin-bottom: 12px; }
.field > label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.bar-row { display: grid; grid-template-columns: minmax(120px, 38%) 1fr 90px; gap: 10px; align-items: center; font-size: 14px; margin: 4px 0; }
.bar { height: 16px; background: #e8edf5; border-radius: 4px; overflow: hidden; }
.bar > div { height: 100%; background: var(--navy-2); }
.bar-row.na .bar > div { background: #9aa6b8; }
.bar-row .val { text-align: right; color: var(--muted); white-space: nowrap; }
.mean { font-size: 14px; margin-top: 6px; }
.open-list { max-height: 360px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.open-list div { padding: 8px 12px; border-bottom: 1px solid var(--line); font-size: 14px; white-space: pre-wrap; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #1c2433; color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 14px;
  opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 10;
}
.toast.show { opacity: 1; }
.hidden { display: none !important; }

/* Nowe typy pytań */
.opt.dim { opacity: .55; }
.opt .other-in { display: block; margin-top: 8px; width: 100%; }
.opt > span { flex: 1; }
.opt.rank { align-items: center; }
.opt.rank input { position: absolute; opacity: 0; pointer-events: none; }
.rank-no {
  flex: 0 0 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line);
  display: inline-flex; align-items: center; justify-content: center; font-size: 14px; color: #fff;
}
.opt.rank.checked .rank-no { background: var(--navy); border-color: var(--navy); }
.mrow { padding: 10px 0; border-top: 1px dashed var(--line); }
.mrow:first-of-type { border-top: 0; }
.mrow-text { font-size: 15px; margin-bottom: 6px; }
.scale.num .opt { padding: 8px 2px; font-size: 14px; font-weight: 600; }
@media (max-width: 640px) {
  .scale.num { grid-template-columns: repeat(5, 1fr); }
  .scale.num .opt { flex-direction: column; align-items: center; text-align: center; }
  .scale.num .opt input { margin: 0 0 4px; }
}
.qedit .mini { display: inline-flex; gap: 6px; align-items: center; font-size: 14px; margin-right: 14px; }
.qedit .mini input { width: 70px; padding: 5px 8px; }
.qedit .mini select { padding: 5px 8px; }

@media print {
  header.top, .tabs, .no-print, .btn { display: none !important; }
  body { background: #fff; }
  .card { break-inside: avoid; box-shadow: none; }
}
.opt { position: relative; }

/* ---- v3: strona respondenta ---- */
fieldset.q { border: 0; margin: 0; padding: 18px 0; min-width: 0; border-top: 1px solid var(--line); }
fieldset.q:first-of-type { border-top: 0; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 8px; top: 8px; background: #fff; padding: 8px 12px; z-index: 50; border-radius: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 16px; }
.chip { background: #eef2f8; color: #2c4f8a; border-radius: 99px; padding: 4px 12px; font-size: 13.5px; }
.intro p { margin: 0 0 10px; }
.intro ul { margin: 0 0 12px; padding-left: 22px; }
.intro li { margin-bottom: 6px; }
.intro-h { font-size: 15px; color: var(--navy); margin: 18px 0 8px; text-transform: none; }
.ok-notice { border-left-color: var(--ok); background: #e9f6ee; }
.warn-notice { border-left-color: var(--err); background: #fdecea; }
.btn.big { padding: 12px 24px; font-size: 16px; }
.btn.secondary { background: #fff; color: var(--navy); }
.progress-wrap { display: flex; justify-content: space-between; margin-bottom: 4px; }
.small { font-size: 13.5px; }
.center-nav { justify-content: center; }
.review { list-style: none; padding: 0; margin: 16px 0; }
.review li { margin-bottom: 8px; }
.linkish { width: 100%; text-align: left; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; font: inherit; color: inherit; }
.linkish:hover { border-color: var(--navy-2); background: #f7f9fd; }
.rev.miss .linkish { border-color: #f0b8b3; background: #fff8f7; }
.rev-t { font-weight: 600; }
.err-text { color: var(--err); }
.ok-text { color: var(--ok); }
.msg-text p { margin: 0 0 10px; }
.opt:focus-within { outline: 3px solid #9fbbe6; outline-offset: 1px; }
.btn:focus-visible, .linkish:focus-visible, textarea:focus-visible { outline: 3px solid #9fbbe6; outline-offset: 2px; }
.q .count { text-align: right; margin-top: 4px; }
mark { background: #fff1b8; }

/* ---- v4: tryb testowy, blok informacyjny, nowe typy pytań ---- */
.banner.test-banner { background: #7c3aed; color: #fff; }
.chip.test-chip { background: #7c3aed; color: #fff; font-weight: 700; }
.test-notice input { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; box-sizing: border-box; }
.q.info { border-top: 1px solid var(--line); padding: 18px 0; }
.info-block { background: #f3f6fb; border-left: 4px solid #3b6fb6; border-radius: 8px; padding: 12px 16px; }
.info-block .info-title { font-weight: 600; margin-bottom: 4px; }
.info-block p { margin: .4em 0; }
.q .soft-msg { display: none; color: #8a5a00; background: #fff6e0; border-radius: 6px; padding: 6px 10px; font-size: 13px; margin-top: 8px; }
.q.soft .soft-msg { display: block; }
.scale-ends { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-top: 4px; gap: 12px; }
.scale-ends span:last-child { text-align: right; }
.num-wrap { display: flex; align-items: center; gap: 8px; }
.num-in { width: 160px; max-width: 100%; font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; }
.num-wrap .unit { color: var(--muted); }
input.short-in, select.dd { width: 100%; font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; box-sizing: border-box; background: #fff; }
select.dd + .other-in { margin-top: 8px; }
.anon-note { font-size: 14px; }
.num-wrap input.num-in { width: 180px; flex: none; }
