/* SSi Forms. The .sheet rules reproduce the HR paper form; the rest is the staff side. */
:root {
  --ink: #1d2433;
  --muted: #5d6778;
  --line: #d5dbe5;
  --bg: #eef1f5;
  --navy: #1f3864;
  --orange: #ed7d31;
  --scale: #dce6f2;
  --error: #b42318;
  --ok: #1a7f4b;
  --paper-font: Calibri, Carlito, "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; }
body.public { background: #e6eaf0; }
a { color: var(--navy); }
.muted { color: var(--muted); }
.form-error { color: var(--error); font-weight: 600; margin: 4px 0; }
.form-error:empty { display: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ------------------------------------------------------------------ the paper form */
.sheet {
  background: #fff; color: #000; font-family: var(--paper-font); font-size: 15px; line-height: 1.3;
  max-width: 840px; margin: 20px auto; padding: 30px 32px 18px;
  border: 5px double var(--orange); box-shadow: 0 1px 4px rgba(16, 24, 40, .08);
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.qms { display: grid; grid-template-columns: 36% 1fr 31%; gap: 1px; background: #000; border: 1px solid #000; margin: 0 3%; }
.qms > div { background: #fff; padding: 4px 8px; }
.qms-logo { grid-row: 1 / 5; display: flex; align-items: center; justify-content: center; }
.qms-logo img { width: 88%; height: auto; }
.qms-sys { grid-column: 2 / 4; text-align: center; font-weight: 700; font-size: 1.12em; }
.qms-title { grid-column: 2 / 4; text-align: center; font-size: 1.1em; }
.qms-title strong { color: var(--orange); margin-left: .4em; }
.qms-doc, .qms-eff { grid-column: 2; }
.qms-page, .qms-rev { grid-column: 3; }
.sheet .form-heading { text-align: center; font-size: 1em; font-weight: 700; text-decoration: underline; margin: 28px 0 20px; }

.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0 28px; }
.fields-col { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; gap: .5em; align-items: baseline; min-height: 1.5em; }
.field-label { font-weight: 700; white-space: nowrap; }
.field-value { flex: 1; min-width: 0; }
.line-input {
  width: 100%; font: inherit; color: inherit; background: #fafcff; padding: 3px 4px;
  border: 0; border-bottom: 1px solid #8a94a6; border-radius: 0;
}
.line-input:focus { outline: 2px solid #9db6dc; outline-offset: 1px; background: #fff; }
.line-input[readonly] { background: transparent; border-bottom-color: transparent; }
.line-input + .line-input { margin-top: 6px; }

.sheet .sec h2 { display: flex; gap: 2.4em; font-size: 1em; font-weight: 700; margin: 26px 0 4px; }
.sheet .sec h2 .n { min-width: 1em; }

.ratings { width: 100%; border-collapse: collapse; table-layout: fixed; }
.ratings col.c-letter { width: 4.5%; }
.ratings col.c-q { width: 28%; }
.ratings col.c-opt { width: 13.5%; }
.ratings td, .ratings th { border: 1px solid #000; padding: 3px 6px; font-weight: 700; text-align: left; vertical-align: middle; }
.ratings tr.scale th { background: var(--scale); text-align: center; }
.ratings td.opt { position: relative; text-align: center; padding: 0; font-weight: 400; }
.ratings .opt-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ratings.fill label { display: flex; align-items: center; justify-content: center; min-height: 30px; cursor: pointer; }
.ratings.fill input { width: 18px; height: 18px; margin: 0; accent-color: var(--navy); cursor: pointer; }
.ratings.fill td.opt:hover { background: #f3f7fc; }
.ratings.fill td.opt:has(input:checked) { background: #e6eefa; }
.ratings tr.missing > * { background: #fdecea; }
.ratings tr.missing .letter, .ratings tr.missing .qtext { color: var(--error); }
.ratings .tick { font-size: 1.2em; font-weight: 700; line-height: 1; }
.ratings td.count { padding: 3px 4px; }
.ratings td.count .n { font-weight: 700; }
.ratings td.count .pct { margin-left: .4em; font-size: .82em; color: #4b5565; }
.ratings td.count.zero .n { font-weight: 400; color: #98a2b3; }

.written { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid #000; }
.wcol + .wcol { border-left: 1px solid #000; }
.whead { display: block; font-weight: 700; padding: 4px 6px; border-bottom: 1px solid #000; min-height: 2.7em; }
.wcol textarea { display: block; width: 100%; min-height: 220px; border: 0; resize: vertical; font: inherit; padding: 6px; background: #fafcff; }
.wcol textarea:focus { outline: 2px solid #9db6dc; outline-offset: -2px; background: #fff; }
.wbody { min-height: 200px; padding: 6px; white-space: pre-wrap; overflow-wrap: anywhere; }
.answers { list-style: none; margin: 0; padding: 0; }
.answers li { padding: 6px 0; border-bottom: 1px solid #e3e7ee; }
.answers li:last-child { border-bottom: 0; }
.answers p { margin: 0; white-space: pre-wrap; }
.answers .who { font-size: .82em; color: var(--muted); }

.signs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-top: 46px; align-items: end; }
.sign { display: flex; flex-direction: column; gap: 3px; }
.sign:nth-child(2) { text-align: center; }
.sign:nth-child(3) { text-align: right; }
.sign-label { font-weight: 700; }
.sig { display: flex; flex-direction: column; }
.sig-name { font-style: italic; font-size: 1.05em; }
.sig-at, .sig-note { font-size: .8em; color: #4b5565; }
.sheet-foot { display: grid; grid-template-columns: 1fr auto 1fr; margin-top: 40px; font-style: italic; font-size: .85em; }
.sheet-foot > :first-child { grid-column: 2; }
.sheet-foot .tpl { text-align: right; font-weight: 700; font-size: .85em; align-self: end; }

.submit-bar { max-width: 840px; margin: 0 auto 48px; padding: 0 2px; display: flex; flex-direction: column; align-items: flex-start; gap: 12px; }
.confirm { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; cursor: pointer; }
.confirm input { width: 20px; height: 20px; margin: 1px 0 0; flex: none; accent-color: var(--navy); }

.notice { max-width: 520px; margin: 12vh auto; background: #fff; padding: 32px 28px; border-radius: 12px; border: 1px solid var(--line); text-align: center; }
.notice-logo { width: 220px; max-width: 70%; margin-bottom: 18px; }
.notice h1 { font-size: 22px; margin: 0 0 8px; }

/* ------------------------------------------------------------------ staff side */
.bar { display: flex; align-items: center; gap: 16px; padding: 10px 20px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; color: var(--ink); text-decoration: none; }
.brand img { height: 28px; width: auto; }
.menu { margin-left: auto; display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; }
.menu a { color: var(--ink); text-decoration: none; font-weight: 600; }
.menu a:hover { color: var(--navy); text-decoration: underline; }
.menu .who { color: var(--muted); font-size: 14px; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 20px; }
.wrap h1 { font-size: 24px; margin: 0 0 6px; }
.wrap h2 { font-size: 17px; margin: 0 0 6px; }
.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 10px; }
.meta { margin: 0; color: var(--muted); }
.card { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; margin: 14px 0; }
.card.narrow { max-width: 380px; margin: 60px auto; }
.card.note { border-color: #f4b183; background: #fff8f2; }
.card.empty { text-align: center; color: var(--muted); }
.card label { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: 14px; margin-bottom: 12px; }
.card input, .card select, .card textarea { font: inherit; font-weight: 400; color: var(--ink); padding: 8px 10px; border: 1px solid #b8c1cf; border-radius: 6px; background: #fff; }
.card input:focus, .card select:focus, .card textarea:focus { outline: 2px solid #9db6dc; outline-offset: 0; border-color: #6f8fc2; }
.card textarea { font-family: ui-monospace, Consolas, monospace; font-size: 13.5px; }
.hint { font-weight: 400; font-size: 13px; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.span2 { grid-column: 1 / -1; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px;
  border: 1px solid #b8c1cf; border-radius: 7px; background: #fff; color: var(--ink);
  font: inherit; font-size: 14px; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn:hover { background: #f3f5f9; }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { background: #172b4f; }
.btn.big { font-size: 17px; padding: 12px 30px; }
.btn.armed { background: var(--error); border-color: var(--error); color: #fff; }
.btn:disabled { opacity: .5; cursor: default; }
button.link { background: none; border: 0; padding: 0; font: inherit; color: var(--navy); text-decoration: underline; cursor: pointer; }
button.link.armed { color: var(--error); font-weight: 600; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 12px 0; }
.spacer { flex: 1; }
.row-actions { display: flex; gap: 14px; white-space: nowrap; }
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
.list th { text-align: left; font-size: 12.5px; font-weight: 600; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.list td { padding: 10px 12px; border-bottom: 1px solid #edf0f4; vertical-align: top; }
.list tr:last-child td { border-bottom: 0; }
.list .num { text-align: right; font-variant-numeric: tabular-nums; }
.list input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--navy); }
tr.link-row { cursor: pointer; }
tr.link-row:hover td { background: #f7f9fc; }
.chip { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.chip.open { background: #e3f4ea; color: var(--ok); }
.chip.closed { background: #eef0f3; color: var(--muted); }
.signed { color: var(--ok); white-space: nowrap; }
.linkcard { display: flex; align-items: center; gap: 22px; }
canvas.qr { width: 168px; height: 168px; flex: none; image-rendering: pixelated; border: 1px solid var(--line); }
code.url { display: inline-block; word-break: break-all; background: #f3f5f9; padding: 3px 7px; border-radius: 4px; font-size: 13.5px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 22px 0 12px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--muted); font-weight: 600; text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a.on { color: var(--ink); border-bottom-color: var(--orange); }
.wrap .sheet { margin: 12px auto 28px; }
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 16px); opacity: 0; pointer-events: none; z-index: 20;
  max-width: calc(100vw - 32px); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.overlay { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; background: rgba(20, 26, 38, .86); }
.overlay-card { background: #fff; border-radius: 14px; padding: 26px 36px; text-align: center; max-width: 94vw; max-height: 96vh; overflow: auto; }
.overlay-card h2 { font-size: 26px; margin: 10px 0 2px; }
.overlay-logo { width: 240px; max-width: 60vw; }
.overlay-subject { font-size: 19px; font-weight: 600; margin: 0 0 10px; }
.overlay canvas.qr { width: min(55vh, 80vw); height: min(55vh, 80vw); border: 0; }
.overlay-url { font-size: 16px; margin: 6px 0; }

/* ------------------------------------------------------------------ phones */
@media (max-width: 680px) {
  .sheet { margin: 0; padding: 14px 12px 14px; border-width: 4px; font-size: 15px; box-shadow: none; }
  .qms { margin: 0; grid-template-columns: 1fr auto; font-size: 13px; }
  .qms-logo { grid-row: auto; grid-column: 1 / 3; padding: 8px; }
  .qms-logo img { width: 62%; }
  .qms-sys, .qms-title { grid-column: 1 / 3; }
  .qms-doc, .qms-eff { grid-column: 1; }
  .qms-page, .qms-rev { grid-column: 2; }
  .sheet .form-heading { margin: 20px 0 14px; }
  .fields { grid-template-columns: 1fr; gap: 12px; }
  .sheet-fill .field { flex-direction: column; align-items: stretch; gap: 4px; }
  .sheet-fill .line-input { font-size: 16px; padding: 9px 10px; border: 1px solid #9aa3b2; border-radius: 6px; }
  .sheet-fill .line-input[readonly] { border-color: transparent; padding-left: 0; }
  .sheet .sec h2 { gap: .8em; margin-top: 22px; }

  .ratings, .ratings tbody, .ratings tr, .ratings td, .ratings th { display: block; border: 0; }
  .ratings colgroup, .ratings tr.scale { display: none; }
  .ratings tr.q { display: grid; grid-template-columns: repeat(10, 1fr); gap: 8px 6px; padding: 12px 0; border-bottom: 1px solid #d5dbe5; }
  .ratings tr.q > .letter { grid-column: 1; padding: 0; }
  .ratings tr.q > .qtext { grid-column: 2 / -1; padding: 0; }
  .ratings tr.q > .opt { grid-column: span 2; grid-row: 2; }
  .ratings .opt-text { position: static; width: auto; height: auto; overflow: visible; clip: auto; white-space: normal; display: block; font-size: 12.5px; line-height: 1.15; font-weight: 600; }
  .ratings.fill label { flex-direction: column; min-height: 50px; padding: 4px 2px; border: 1px solid #b8c1cf; border-radius: 8px; background: #fff; }
  .ratings.fill input { position: absolute; opacity: 0; pointer-events: none; }
  .ratings.fill td.opt:hover, .ratings.fill td.opt:has(input:checked) { background: none; }
  .ratings.fill label:has(input:checked) { background: var(--navy); border-color: var(--navy); color: #fff; }
  .ratings.fill label:has(input:focus-visible) { outline: 3px solid #f4b183; outline-offset: 1px; }
  .ratings tr.missing > * { background: none; }
  .ratings tr.missing { background: #fdecea; margin: 0 -6px; padding: 12px 6px; }
  .ratings.view td.opt, .ratings.counts td.opt { padding: 4px 2px; border: 1px solid #e3e7ee; border-radius: 8px; }
  .ratings.view td.opt.on { background: #e6eefa; border-color: #9db6dc; }
  .ratings.view td.opt .opt-text { font-size: 11px; color: #4b5565; font-weight: 400; }
  .ratings td.count .pct { display: block; margin: 0; }

  .written { grid-template-columns: 1fr; }
  .wcol + .wcol { border-left: 0; border-top: 1px solid #000; }
  .wcol textarea { font-size: 16px; min-height: 150px; }
  .signs { grid-template-columns: 1fr; gap: 14px; margin-top: 28px; }
  .sign:nth-child(n) { text-align: left; }
  .sheet-foot { grid-template-columns: 1fr; text-align: center; gap: 4px; margin-top: 28px; }
  .sheet-foot > :first-child { grid-column: 1; }
  .sheet-foot .tpl { text-align: center; }
  .submit-bar { padding: 16px 14px 0; }
  .btn.big { width: 100%; }

  .bar { flex-wrap: wrap; padding: 10px 14px; }
  .menu { margin-left: 0; width: 100%; }
  .wrap { padding: 14px; }
  .head { flex-direction: column; }
  .grid2 { grid-template-columns: 1fr; }
  .linkcard { flex-direction: column; align-items: flex-start; }
}

/* ------------------------------------------------------------------ print: one A4 page per form */
@page { size: A4; margin: 9mm; }
@media print {
  body, body.public, body.staff { background: #fff; }
  .no-print, .bar, .toast, .submit-bar, .actions, .linkcard, .tabs { display: none !important; }
  .wrap { max-width: none; padding: 0; }
  .wrap .sheet, .sheet { max-width: none; margin: 0; box-shadow: none; font-size: 12.5px; padding: 18px 22px 10px; break-after: page; }
  .sheet:last-of-type { break-after: auto; }
  .ratings tr, .answers li { break-inside: avoid; }
  .wbody { min-height: 150px; }
  .signs { margin-top: 30px; }
  .sheet-foot { margin-top: 24px; }
}
