/* =========================================================
   FocusQuality — Module Audits (prototype front-end)
   Tokens repris de wwwroot/app.css (rouge marque #C57673, Inter, Libre Baskerville)
   ========================================================= */
:root {
  --fq-red-500: #C57673;
  --fq-red-600: #a85f5c;
  --fq-red-700: #8c4a48;
  --fq-maroon: #3b1a21;
  --fq-maroon-2: #52262f;
  --fq-tint: #f7ecec;

  --bg: #f6f4f3;
  --surface: #ffffff;
  --surface-2: #faf8f7;
  --text: #1b1b1b;
  --text-2: #454545;
  --muted: #7a7674;
  --border: rgba(40, 20, 20, 0.12);
  --border-2: rgba(40, 20, 20, 0.2);

  --pass: #1f7a4d;   --pass-bg: #e4f3ea;
  --reserve: #9a6200; --reserve-bg: #fff1d6;
  --fail: #b3261e;   --fail-bg: #fbe9e7;
  --info: #2f5d9e;   --info-bg: #e8effa;
  --na: #66625f;     --na-bg: #ecebea;

  --d-safety: #c2570c;
  --d-mission: #2f5d9e;
  --d-quality: #7b3f8f;

  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-display: "Libre Baskerville", Georgia, serif;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-1: 0 1px 2px rgba(40, 20, 20, 0.08);
  --shadow-2: 0 8px 24px rgba(40, 20, 20, 0.14);
  --topbar-h: 52px;
  --side-w: 236px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h1 { font-family: var(--font-display); font-size: 26px; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 650; }
p { margin: 0; }
a { color: var(--fq-red-700); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; }
svg.ico { display: inline-block; vertical-align: -0.2em; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.xs { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.92em; }
.b { font-weight: 650; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.hide { display: none !important; }

/* ---------- Shell ---------- */
.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--topbar-h); z-index: 50;
  display: flex; align-items: center; gap: 12px; padding: 0 16px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand img { height: 30px; width: auto; display: block; }
.brand .mod {
  font-family: var(--font-display); font-weight: 700; font-size: 15px;
  padding-left: 10px; border-left: 1px solid var(--border-2); color: var(--fq-maroon);
}
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.persona { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.persona select { padding: 6px 8px; font-size: 13px; max-width: 220px; }
.proto-tag {
  font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--fq-red-700); background: var(--fq-tint); border: 1px solid #e6c9c8;
  padding: 3px 8px; border-radius: 999px;
}
.hamburger { display: none; }

.sidenav {
  position: fixed; top: var(--topbar-h); bottom: 0; left: 0; width: var(--side-w);
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 14px 10px; overflow-y: auto; z-index: 40;
  display: flex; flex-direction: column; gap: 2px;
}
.nav-cta { margin-bottom: 10px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500; font-size: 14px; position: relative;
}
.nav-item:hover { background: var(--surface-2); text-decoration: none; }
.nav-item.active { background: var(--fq-tint); color: var(--fq-maroon); font-weight: 650; }
.nav-item.active::before { content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; background: var(--fq-red-500); border-radius: 0 3px 3px 0; }
.nav-item .count { margin-left: auto; font-size: 11px; font-weight: 700; background: var(--fail); color: #fff; border-radius: 999px; padding: 1px 7px; }
.nav-sep { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 14px 12px 4px; }
.nav-foot { margin-top: auto; padding: 12px; font-size: 12px; color: var(--muted); }
.scrim { display: none; }

#view { margin-left: var(--side-w); padding: calc(var(--topbar-h) + 24px) 28px 60px; min-height: 100vh; }
.page { max-width: 1240px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); font-size: 14px; margin-top: 4px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.crumb { font-size: 13px; color: var(--muted); margin-bottom: 6px; display: flex; gap: 6px; align-items: center; }

/* ---------- Layout helpers ---------- */
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-lg { display: flex; flex-direction: column; gap: 20px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.top { align-items: flex-start; }
.spacer { flex: 1; }
.sp-between { justify-content: space-between; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-1); }
.card-h { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.card-h h2, .card-h h3 { flex: 1; }
.card-b { padding: 16px; }
.card.flat { box-shadow: none; }
.card.click { cursor: pointer; transition: border-color .12s, box-shadow .12s, transform .12s; }
.card.click:hover { border-color: var(--fq-red-500); box-shadow: var(--shadow-2); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: var(--radius-sm); border: 1px solid var(--border-2);
  background: var(--surface); color: var(--text); font-weight: 600; font-size: 14px; line-height: 1.2;
  transition: background .12s, border-color .12s, transform .05s;
}
.btn:hover { background: var(--surface-2); border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--fq-red-500); border-color: var(--fq-red-500); color: #fff; }
.btn.primary:hover { background: var(--fq-red-600); border-color: var(--fq-red-600); }
.btn.dark { background: var(--fq-maroon); border-color: var(--fq-maroon); color: #fff; }
.btn.dark:hover { background: var(--fq-maroon-2); }
.btn.danger { background: var(--fail); border-color: var(--fail); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--fq-tint); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.lg { padding: 13px 22px; font-size: 16px; }
.btn.block { width: 100%; }
.btn[disabled], .btn.disabled { opacity: .45; pointer-events: none; }

/* ---------- Chips & pills ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--na-bg); color: var(--text-2); white-space: nowrap;
}
.chip.click { cursor: pointer; border: 1px solid transparent; }
.chip.click:hover { border-color: var(--border-2); }
.chip.on { background: var(--fq-maroon); color: #fff; }
.dom { background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); }
.dom::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--dc, var(--muted)); }
.dom.safety { --dc: var(--d-safety); } .dom.mission { --dc: var(--d-mission); } .dom.quality { --dc: var(--d-quality); }
.dom.off { opacity: .45; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 6px;
  font-size: 12px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; white-space: nowrap;
}
.pill.pass { background: var(--pass-bg); color: var(--pass); }
.pill.reserve, .pill.warn { background: var(--reserve-bg); color: var(--reserve); }
.pill.fail, .pill.crit { background: var(--fail-bg); color: var(--fail); }
.pill.info { background: var(--info-bg); color: var(--info); }
.pill.na, .pill.muted { background: var(--na-bg); color: var(--na); }
.pill.solid-fail { background: var(--fail); color: #fff; }
.pill.solid-pass { background: var(--pass); color: #fff; }
.pill.solid-warn { background: var(--reserve); color: #fff; }
.lvl { font-size: 11px; font-weight: 800; padding: 2px 7px; border-radius: 5px; background: var(--fq-maroon); color: #fff; letter-spacing: .04em; }
.lvl.l1 { background: #7a7674; } .lvl.l2 { background: #a85f5c; } .lvl.l3 { background: #7d2f2f; } .lvl.l4 { background: #1b1b1b; }
.sev { font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; gap: 5px; }
.sev::before { content: ""; width: 9px; height: 9px; border-radius: 2px; background: var(--sc); transform: rotate(45deg); }
.sev.minor { --sc: #b8a13b; } .sev.major { --sc: #d9781f; } .sev.critical { --sc: var(--fail); }
.recur { font-size: 11px; font-weight: 800; color: #fff; background: var(--fail); padding: 2px 7px; border-radius: 5px; text-transform: uppercase; letter-spacing: .03em; }
.lock { color: var(--fq-maroon); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--na); }
.dot.pass { background: var(--pass); } .dot.fail { background: var(--fail); } .dot.reserve { background: #d99a1f; } .dot.na { background: #c9c5c2; }

/* ---------- Forms ---------- */
label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field { display: flex; flex-direction: column; gap: 5px; }
input[type=text], input[type=number], input[type=date], input[type=search], select, textarea {
  font-family: inherit; font-size: 14px; padding: 9px 11px; border: 1px solid var(--border-2);
  border-radius: var(--radius-sm); background: #fff; color: var(--text); width: 100%;
}
textarea { resize: vertical; min-height: 64px; }
input:focus, select:focus, textarea:focus, button:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--fq-red-500); outline-offset: 1px; border-color: var(--fq-red-500);
}
input[type=checkbox], input[type=radio] { accent-color: var(--fq-red-600); width: 17px; height: 17px; }
.checkrow { display: flex; align-items: flex-start; gap: 10px; padding: 8px 0; font-weight: 500; color: var(--text); font-size: 14px; }
.hint { font-size: 12.5px; color: var(--muted); }
.req::after { content: " *"; color: var(--fail); }

.seg { display: inline-flex; border: 1px solid var(--border-2); border-radius: var(--radius-sm); overflow: hidden; background: #fff; }
.seg button { border: 0; border-right: 1px solid var(--border); background: transparent; padding: 7px 14px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--fq-maroon); color: #fff; }
.seg button:hover:not(.on) { background: var(--surface-2); }

/* ---------- KPI ---------- */
.kpi { padding: 14px 16px; }
.kpi .kpi-l { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; color: var(--muted); }
.kpi .kpi-v { font-family: var(--font-display); font-size: 30px; font-weight: 700; margin-top: 4px; line-height: 1.1; }
.kpi .kpi-s { font-size: 13px; color: var(--muted); margin-top: 4px; }
.kpi.alert .kpi-v { color: var(--fail); }
.kpi.click { cursor: pointer; }
.kpi.click:hover { border-color: var(--fq-red-500); }

/* ---------- Tables ---------- */
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: var(--fq-tint); }
.tbl .sub { font-size: 12.5px; color: var(--muted); }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tab { border: 0; background: transparent; padding: 10px 16px; font-weight: 600; font-size: 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.on { color: var(--fq-maroon); border-bottom-color: var(--fq-red-500); }

.banner { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius); border: 1px solid; font-size: 14px; }
.banner .ico { margin-top: 2px; }
.banner.warn { background: var(--reserve-bg); border-color: #efd39a; color: #5c3a00; }
.banner.danger { background: var(--fail-bg); border-color: #efb8b3; color: #6f1712; }
.banner.ok { background: var(--pass-bg); border-color: #b5dcc6; color: #12472b; }
.banner.info { background: var(--info-bg); border-color: #bcd0ee; color: #1d3a66; }
.banner b { font-weight: 700; }

.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty .ico { margin-bottom: 8px; opacity: .6; }

.bar { height: 8px; background: var(--na-bg); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--fq-red-500); border-radius: 999px; transition: width .25s ease; }
.bar.pass > i { background: var(--pass); } .bar.fail > i { background: var(--fail); } .bar.reserve > i { background: #d99a1f; }

/* ---------- Horizontal bars (charts) ---------- */
.hbar { display: grid; grid-template-columns: minmax(90px, 200px) 1fr 52px; align-items: center; gap: 10px; font-size: 13px; padding: 4px 0; }
.hbar .lab { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .val { text-align: right; font-weight: 700; }
.vbars { display: flex; align-items: flex-end; gap: 10px; height: 130px; padding-top: 10px; }
.vbars .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: stretch; height: 100%; gap: 2px; }
.vbars .col i { display: block; border-radius: 3px 3px 0 0; }
.vbars .col i.p { background: var(--pass); } .vbars .col i.r { background: #d99a1f; } .vbars .col i.f { background: var(--fail); }
.vlabels { display: flex; gap: 10px; font-size: 11.5px; color: var(--muted); text-align: center; }
.vlabels span { flex: 1; }

/* ---------- Overlays ---------- */
.overlay { position: fixed; inset: 0; background: rgba(27, 14, 16, .5); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; animation: fade .15s ease; }
.overlay.right { justify-content: flex-end; padding: 0; align-items: stretch; }
.modal { background: var(--surface); border-radius: var(--radius-lg); width: min(640px, 100%); max-height: 92vh; overflow: auto; box-shadow: var(--shadow-2); animation: pop .16s ease; }
.modal.wide { width: min(860px, 100%); }
.modal-h { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.modal-h h2 { flex: 1; font-family: var(--font-display); font-size: 18px; }
.modal-b { padding: 20px; }
.modal-f { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); position: sticky; bottom: 0; background: var(--surface); }
.drawer { background: var(--surface); width: min(600px, 100%); height: 100%; overflow-y: auto; box-shadow: var(--shadow-2); animation: slide .2s ease; display: flex; flex-direction: column; }
.drawer-h { padding: 18px 22px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 2; display: flex; gap: 12px; align-items: flex-start; }
.drawer-b { padding: 20px 22px; flex: 1; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--fq-maroon); color: #fff; padding: 11px 16px; border-radius: var(--radius); box-shadow: var(--shadow-2); font-size: 14px; max-width: 380px; animation: pop .18s ease; display: flex; gap: 10px; align-items: center; }
.toast.ok { background: var(--pass); } .toast.err { background: var(--fail); }

/* ---------- Steppers ---------- */
.steps { display: flex; gap: 0; margin: 4px 0 18px; }
.step { flex: 1; position: relative; text-align: center; font-size: 12px; color: var(--muted); padding-top: 26px; font-weight: 600; }
.step::before { content: ""; position: absolute; top: 9px; left: 0; right: 0; height: 3px; background: var(--na-bg); }
.step:first-child::before { left: 50%; } .step:last-child::before { right: 50%; }
.step::after { content: ""; position: absolute; top: 3px; left: calc(50% - 8px); width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 3px solid #cfcac8; }
.step.done { color: var(--pass); } .step.done::before { background: var(--pass); }
.step.done::after { background: var(--pass); border-color: var(--pass); }
.step.cur { color: var(--fq-maroon); } .step.cur::after { border-color: var(--fq-red-500); background: #fff; box-shadow: 0 0 0 4px var(--fq-tint); }
.step.done + .step.cur::before { background: var(--pass); }

.timeline { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid var(--border); display: flex; flex-direction: column; gap: 12px; }
.timeline li { position: relative; font-size: 13.5px; }
.timeline li::before { content: ""; position: absolute; left: -20px; top: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--fq-red-500); border: 2px solid #fff; }
.timeline .t { font-size: 12px; color: var(--muted); }

/* ---------- Hub bits ---------- */
.dom-trio { display: inline-flex; gap: 4px; }
.mini { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 6px; font-size: 11px; font-weight: 800; color: #fff; background: #c9c5c2; }
.mini.pass { background: var(--pass); } .mini.fail { background: var(--fail); } .mini.reserve { background: #d99a1f; } .mini.na { background: #c9c5c2; color: #fff; }
.alertrow { display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); align-items: flex-start; }
.alertrow:last-child { border-bottom: 0; }
.alertrow .ico { margin-top: 2px; }
.alertrow.click { cursor: pointer; } .alertrow.click:hover { background: var(--fq-tint); }
.listrow { display: flex; gap: 12px; align-items: center; padding: 11px 16px; border-bottom: 1px solid var(--border); }
.listrow:last-child { border-bottom: 0; }
.listrow.click { cursor: pointer; } .listrow.click:hover { background: var(--fq-tint); }
.hold-bar { background: var(--fail); color: #fff; padding: 10px 16px; border-radius: var(--radius); display: flex; gap: 10px; align-items: center; font-weight: 600; }

.mission-card .head { display: flex; gap: 8px; align-items: flex-start; }
.mission-card .code { font-weight: 700; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; color: var(--fq-red-700); }
.mission-card h3 { margin: 2px 0; font-size: 16px; }
.gate { display: flex; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); align-items: flex-start; }
.gate:last-child { border-bottom: 0; }
.gate .gi { width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex: none; color: #fff; background: var(--pass); }
.gate .gi.bad { background: var(--fail); } .gate .gi.warn { background: #d99a1f; }
.ctx-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px 20px; }
.ctx-grid .k { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.ctx-grid .v { font-weight: 600; }
.pick { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1.5px solid var(--border); border-radius: var(--radius); cursor: pointer; background: #fff; text-align: left; width: 100%; font: inherit; color: inherit; }
.pick:hover { border-color: var(--fq-red-500); }
.pick.on { border-color: var(--fq-red-500); background: var(--fq-tint); box-shadow: 0 0 0 3px rgba(197,118,115,.18); }
.pick.dis { opacity: .5; pointer-events: none; }
.wizard-num { width: 26px; height: 26px; border-radius: 50%; background: var(--fq-maroon); color: #fff; font-weight: 700; font-size: 13px; display: inline-flex; align-items: center; justify-content: center; margin-right: 8px; }

/* ---------- RUN (floor execution) ---------- */
.run-shell { max-width: 1180px; margin: 0 auto; }
.run-ctx { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 12px 16px; background: var(--fq-maroon); color: #fff; border-radius: var(--radius) var(--radius) 0 0; }
.run-ctx .code { font-family: ui-monospace, Menlo, monospace; font-weight: 700; }
.run-ctx .sub { opacity: .8; font-size: 13px; }
.run-ctx .btn { background: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.3); }
.run-ctx .btn:hover { background: rgba(255,255,255,.22); }
.run-progress { background: #fff; border: 1px solid var(--border); border-top: 0; padding: 10px 16px; display: flex; gap: 14px; align-items: center; }
.run-progress .bar { flex: 1; }
.run-body { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 16px; margin-top: 16px; align-items: start; }
.run-side { position: sticky; top: calc(var(--topbar-h) + 14px); max-height: calc(100vh - var(--topbar-h) - 40px); overflow-y: auto; padding: 8px; }
.qnav-sec { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; font-weight: 700; color: var(--muted); padding: 10px 8px 4px; }
.qnav { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; border: 0; background: transparent; padding: 6px 8px; border-radius: 6px; font-size: 13px; color: var(--text-2); }
.qnav:hover { background: var(--surface-2); }
.qnav.cur { background: var(--fq-tint); color: var(--fq-maroon); font-weight: 700; }
.qnav .qc { font-family: ui-monospace, Menlo, monospace; font-weight: 700; min-width: 26px; }
.qnav .qt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }

.qcard { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-1); }
.qcard-h { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 14px 18px 0; }
.qcode { font-family: ui-monospace, Menlo, monospace; font-weight: 800; color: var(--fq-red-700); font-size: 15px; }
.qmode { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.qtext { font-size: 21px; font-weight: 650; line-height: 1.3; padding: 10px 18px 6px; letter-spacing: -0.01em; }
.qhint { padding: 0 18px 14px; color: var(--text-2); font-size: 14px; }
.qsrc { padding: 0 18px 14px; font-size: 12px; color: var(--muted); }
.qwidget { margin: 0 18px 16px; padding: 14px; background: var(--surface-2); border: 1px dashed var(--border-2); border-radius: var(--radius); }
.qwidget h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 10px; display: flex; gap: 8px; align-items: center; }
.wout { margin-top: 10px; }
.qans { padding: 0 18px 18px; }
.ans { display: grid; gap: 10px; }
.ans.c3 { grid-template-columns: 1.4fr 1.4fr 1fr; }
.ans.c4 { grid-template-columns: repeat(3, 1fr) 1fr; }
.ans-btn { min-height: 60px; border-radius: var(--radius); border: 2px solid var(--border-2); background: #fff; font-size: 16px; font-weight: 750; color: var(--text-2); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; line-height: 1.15; padding: 8px; transition: transform .05s, background .1s; }
.ans-btn small { font-size: 11.5px; font-weight: 600; opacity: .85; }
.ans-btn:hover { background: var(--surface-2); }
.ans-btn:active { transform: scale(.985); }
.ans-btn.on.ok { background: var(--pass); border-color: var(--pass); color: #fff; }
.ans-btn.on.weak { background: #d99a1f; border-color: #d99a1f; color: #fff; }
.ans-btn.on.bad { background: var(--fail); border-color: var(--fail); color: #fff; }
.ans-btn.on.na { background: var(--na); border-color: var(--na); color: #fff; }
.autotag { font-size: 12px; color: var(--muted); margin-top: 8px; display: flex; gap: 6px; align-items: center; }
.ncpanel { margin-top: 14px; padding: 14px; border: 1.5px solid #efb8b3; background: #fff8f7; border-radius: var(--radius); display: flex; flex-direction: column; gap: 12px; }
.ncpanel h4 { color: var(--fail); font-size: 13px; text-transform: uppercase; letter-spacing: .05em; display: flex; gap: 6px; align-items: center; }
.sevpick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sevpick label { position: relative; display: flex; flex-direction: column; gap: 2px; padding: 9px 10px; border: 1.5px solid var(--border-2); background: #fff; border-radius: 8px; cursor: pointer; font-weight: 700; color: var(--text); }
.sevpick label small { font-weight: 500; color: var(--muted); font-size: 11.5px; }
.sevpick input { position: absolute; opacity: 0; pointer-events: none; }
.sevpick label.on { border-color: var(--fail); background: var(--fail-bg); }
.evrow { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.thumb { width: 64px; height: 64px; border-radius: 8px; object-fit: cover; border: 1px solid var(--border-2); cursor: zoom-in; }
.thumbwrap { position: relative; }
.thumbwrap button { position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%; background: var(--fail); color: #fff; border: 0; font-size: 12px; line-height: 1; padding: 0; }
.run-bar { display: flex; gap: 10px; align-items: center; margin-top: 14px; }
.run-bar .btn { min-height: 46px; }
.sw { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); font-weight: 500; cursor: pointer; }
.yn { display: inline-flex; gap: 4px; }
.yn button { min-width: 64px; padding: 8px 12px; border-radius: 8px; border: 1.5px solid var(--border-2); background: #fff; font-weight: 700; font-size: 13px; }
.yn button.on.y { background: var(--pass); border-color: var(--pass); color: #fff; }
.yn button.on.n { background: var(--fail); border-color: var(--fail); color: #fff; }
.chk-line { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.chk-line:last-child { border-bottom: 0; }
.chk-line .lbl { flex: 1; font-weight: 600; font-size: 14px; }
.chrono { font-family: ui-monospace, Menlo, monospace; font-size: 28px; font-weight: 700; letter-spacing: .03em; }
.mobile-only { display: none; }

/* ---------- Result ---------- */
.hero { border-radius: var(--radius-lg); padding: 22px 24px; color: #fff; display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.hero.pass { background: linear-gradient(135deg, #17643f, #1f7a4d); }
.hero.reserve { background: linear-gradient(135deg, #8a5600, #b07200); }
.hero.fail { background: linear-gradient(135deg, #8f1d17, #b3261e); }
.hero .big { font-family: var(--font-display); font-size: 30px; font-weight: 700; line-height: 1.1; }
.hero .why { font-size: 14px; opacity: .95; margin-top: 6px; }
.hero ul { margin: 6px 0 0; padding-left: 18px; font-size: 14px; }
.dcard { padding: 16px; }
.dcard .dh { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.dcard .dh h3 { flex: 1; }
.score-big { font-family: var(--font-display); font-size: 28px; font-weight: 700; }
.itemline { display: flex; gap: 8px; align-items: flex-start; font-size: 13.5px; padding: 6px 0; border-top: 1px solid var(--border); }
.itemline .qc { font-family: ui-monospace, Menlo, monospace; font-weight: 700; min-width: 30px; color: var(--fq-red-700); }
.conseq { display: flex; gap: 12px; padding: 12px 14px; border: 1.5px solid var(--border); border-radius: var(--radius); background: #fff; cursor: pointer; align-items: flex-start; }
.conseq.on { border-color: var(--fq-red-500); background: var(--fq-tint); }
.conseq.crit.on { border-color: var(--fail); background: var(--fail-bg); }
canvas.sig { width: 100%; height: 130px; border: 1.5px dashed var(--border-2); border-radius: var(--radius); background: #fff; touch-action: none; cursor: crosshair; display: block; }

/* ---------- History grid ---------- */
.hgrid-wrap { overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; max-height: 74vh; }
.hgrid { border-collapse: separate; border-spacing: 0; font-size: 13px; min-width: 100%; }
.hgrid th, .hgrid td { border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); padding: 6px 8px; text-align: center; background: #fff; }
.hgrid thead th { position: sticky; top: 0; z-index: 3; background: var(--fq-maroon); color: #fff; font-weight: 600; font-size: 12px; min-width: 96px; }
.hgrid .qcol { position: sticky; left: 0; z-index: 2; text-align: left; min-width: 320px; max-width: 360px; background: #fff; font-weight: 500; }
.hgrid thead .qcol { z-index: 4; background: var(--fq-maroon); }
.hgrid .secrow td { background: var(--fq-tint); font-weight: 700; text-align: left; color: var(--fq-maroon); text-transform: uppercase; font-size: 11.5px; letter-spacing: .06em; position: sticky; left: 0; }
.hcell { display: inline-flex; width: 34px; height: 26px; align-items: center; justify-content: center; border-radius: 5px; font-weight: 800; font-size: 12px; cursor: pointer; }
.hcell.C { background: var(--pass-bg); color: var(--pass); }
.hcell.NC { background: var(--fail); color: #fff; }
.hcell.NA { background: var(--na-bg); color: var(--na); }
.hcell.w { background: #ffe7b0; color: #7a4d00; }
.hcell.none { background: repeating-linear-gradient(45deg, #f0eeed, #f0eeed 4px, #fff 4px, #fff 8px); color: transparent; cursor: default; }
.hgrid tr.recur-row .qcol { box-shadow: inset 3px 0 0 var(--fail); }
.hgrid .colh small { display: block; opacity: .8; font-weight: 500; }

/* ---------- Findings board ---------- */
.board { display: grid; grid-template-columns: repeat(5, minmax(220px, 1fr)); gap: 12px; overflow-x: auto; align-items: start; }
.bcol { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; min-height: 200px; }
.bcol h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); display: flex; justify-content: space-between; margin-bottom: 8px; }
.fcard { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; cursor: pointer; font-size: 13.5px; }
.fcard:hover { border-color: var(--fq-red-500); }
.fcard.overdue { border-left: 3px solid var(--fail); }

/* ---------- Misc ---------- */
.gatesbar { display: flex; gap: 6px; }
.gatesbar i { width: 22px; height: 8px; border-radius: 4px; background: var(--na-bg); }
.gatesbar i.on { background: var(--pass); }
.gatesbar.bad i.on { background: #d99a1f; }
.switch { position: relative; width: 38px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #cfcac8; border-radius: 999px; transition: .15s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: .15s; }
.switch input:checked + span { background: var(--fq-red-500); }
.switch input:checked + span::after { transform: translateX(16px); }
.qedit-row td { vertical-align: top; }
.qedit-row input[type=text], .qedit-row select { padding: 6px 8px; font-size: 13px; }
.divider { height: 1px; background: var(--border); margin: 6px 0; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 14px; font-size: 14px; }
.kv .k { color: var(--muted); font-size: 13px; }
.lightbox img { max-width: 100%; max-height: 80vh; border-radius: 8px; display: block; margin: 0 auto; }

#print-root { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .g-main { grid-template-columns: 1fr; }
  .board { grid-template-columns: repeat(5, 240px); }
}
@media (max-width: 900px) {
  .hamburger { display: inline-flex; }
  .sidenav { transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-2); z-index: 70; }
  body.nav-open .sidenav { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 60; }
  #view { margin-left: 0; padding: calc(var(--topbar-h) + 16px) 14px 90px; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .persona span { display: none; }
  .proto-tag { display: none; }
  .brand .mod { display: none; }
  h1 { font-size: 22px; }
  .run-body { grid-template-columns: 1fr; }
  .run-side { display: none; }
  .mobile-only { display: inline-flex; }
  .qtext { font-size: 19px; }
  .run-bar { position: sticky; bottom: 0; background: var(--bg); padding: 10px 0; z-index: 5; }
  .kv { grid-template-columns: 1fr; }
  .hbar { grid-template-columns: 100px 1fr 44px; }
}
@media (max-width: 520px) {
  .g4, .g6 { grid-template-columns: 1fr 1fr; }
  .ans.c4 { grid-template-columns: repeat(3, 1fr); }
  .ans.c4 .ans-btn:last-child { grid-column: 1 / -1; min-height: 46px; }
  .sevpick { grid-template-columns: 1fr; }
  .hero .big { font-size: 24px; }
}

/* ---------- Print (rapport PDF) ---------- */
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; }
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block !important; }
  .report { font-size: 11px; color: #000; }
  .report h1 { font-size: 20px; }
  .report table { width: 100%; border-collapse: collapse; margin: 6px 0 12px; }
  .report th, .report td { border: 1px solid #999; padding: 3px 6px; text-align: left; vertical-align: top; font-size: 10.5px; }
  .report th { background: #3b1a21; color: #fff; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .report .rh { display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid #8c4a48; padding-bottom: 8px; margin-bottom: 10px; }
  .report .rh img { height: 40px; }
  .report .tag { display: inline-block; padding: 1px 7px; border-radius: 4px; font-weight: 700; font-size: 10px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .report .tag.pass { background: #e4f3ea; color: #1f7a4d; } .report .tag.fail { background: #fbe9e7; color: #b3261e; }
  .report .tag.reserve { background: #fff1d6; color: #9a6200; } .report .tag.na { background: #ecebea; color: #66625f; }
  .report h2 { font-size: 13px; margin: 12px 0 4px; color: #3b1a21; text-transform: uppercase; letter-spacing: .05em; }
  .report .sig { height: 60px; }
  .report tr { page-break-inside: avoid; }
}

.persona select { width: auto; max-width: 300px; }
.tbl .sw { white-space: nowrap; }
.tbl.tight th, .tbl.tight td { padding: 10px 9px; }
@media (max-width: 900px) { .persona select { max-width: 190px; } }
