/* SOPs: the library list, a single SOP to read or print, and the editor */
.sopgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 14px; align-items: start; }
.sopgroup .sechead .n, .sopdrafts .sechead .n, .soprevs .sechead .n, .soparch summary .n { margin-left: 4px; color: var(--muted); font-weight: 600; }
.soplist { list-style: none; margin: 0; padding: 0; }
.soplist li + li { border-top: 1px solid var(--divider); }
.soplist a { display: flex; flex-direction: column; gap: 2px; padding: 10px 8px; margin: 0 -8px; border-radius: 8px; color: var(--ink); text-decoration: none; min-height: 44px; justify-content: center; }
.soplist a:hover { background: var(--row-hover); }
.soplist a:hover b { text-decoration: underline; }
.soplist b { font-weight: 650; }
.soplist .small { line-height: 1.4; }
.sopnone { margin: 8px 0 16px; }
.soparch { margin-top: 14px; padding-top: 12px; padding-bottom: 12px; }
.soparch summary { cursor: pointer; font-weight: 700; color: var(--grey-ink); font-size: 0.875rem; min-height: 32px; display: list-item; }
.soparch .soplist { margin-top: 6px; }

/* One SOP */
.sopacts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 auto 12px; max-width: 820px; }
.sopacts .link { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; }
.sopacts .link svg { width: 16px; height: 16px; }
.sopacts .btn svg { width: 16px; height: 16px; }
.sopsp { flex: 1 1 auto; }
.sopdoc { max-width: 820px; margin: 0 auto; padding: 28px 32px 32px; }
.soparea { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin: 0 0 4px; }
.sopdoc h1 { font-size: 1.5rem; line-height: 1.25; font-weight: 800; color: var(--brand); margin: 0; }
.sopmeta { margin: 4px 0 18px; }
.sopflag { background: var(--amber-bg); color: var(--ink); border-radius: 8px; padding: 8px 12px; margin: 0 0 14px; font-size: 0.875rem; }

/* The rendered body (also used by the editor preview) */
.sopbody { font-size: 0.9375rem; line-height: 1.6; color: var(--ink); overflow-wrap: anywhere; }
.sopbody > * + * { margin-top: 10px; }
.sopbody h2 { font-size: 1.125rem; font-weight: 800; color: var(--brand); margin-top: 24px; padding-top: 14px; border-top: 1px solid var(--divider); }
.sopbody h3 { font-size: 0.9375rem; font-weight: 800; color: var(--grey-ink); margin-top: 18px; }
.sopbody > h2:first-child, .sopbody > h3:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.sopbody p, .sopbody li { max-width: 72ch; }
.sopbody ul, .sopbody ol { padding-left: 1.5em; margin-bottom: 0; }
.sopbody li + li { margin-top: 6px; }
.sopbody ol.sopsteps { list-style: none; padding-left: 0; }
.sopsteps > li { display: grid; grid-template-columns: 30px minmax(0, 1fr); align-items: start; }
.sopn { justify-self: start; display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 6px; margin-top: 1px; border-radius: 11px; background: var(--ink); color: var(--surface); font-size: 0.75rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.sopt { min-width: 0; }
.soppartn { display: none; }
.sopkey { display: inline-block; font-family: inherit; font-weight: 600; font-size: 0.8125em; line-height: 1.3; padding: 0 6px; margin: 0 1px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; background: var(--surface); color: var(--ink); white-space: nowrap; vertical-align: 1px; }
.sopfinal { margin-top: 24px; padding: 14px 18px 16px; border-left: 4px solid var(--ink); border-radius: 0 8px 8px 0; background: var(--surface2); }
.sopbody .sopfinal h2.sopfinalh { margin: 0 0 8px; padding: 0; border: 0; font-size: 1.0625rem; }
.sopfinal > * + * { margin-top: 8px; }
.sopbody ul.sopfinallist { list-style: none; padding-left: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px 24px; }
.sopbody .sopfinallist li + li { margin-top: 0; }
.sopdraftlede { margin: -2px 0 6px; }
.sopbody ul { list-style: disc; }
.sopbody ul > li::marker { color: var(--muted); }
.sopbody b { font-weight: 700; }
.sopnote { border-left: 3px solid var(--blue-btn); background: var(--blue-tint); color: var(--ink); border-radius: 0 8px 8px 0; padding: 10px 14px; max-width: 72ch; }
.sopcheck { background: var(--amber-bg); color: var(--ink); border-radius: 4px; padding: 0 4px; font-weight: 650; }

/* Editor */
.sopedit .sechead { font-size: 1rem; margin-bottom: 14px; }
.sopfields { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 0 16px; }
.sopwrite { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.sopedit textarea { width: 100%; font: 0.875rem/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; resize: vertical; min-height: 360px; }
.sophelp { margin-top: 6px; line-height: 1.9; }
.sophelp code { font: 0.75rem ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--chip-bg); color: var(--grey-ink); border-radius: 4px; padding: 1px 5px; white-space: nowrap; }
.sopprevwrap { border: 1px solid var(--line); border-radius: var(--r-ctl); background: var(--surface2); padding: 12px 16px 16px; min-height: 120px; max-height: 640px; overflow: auto; }
.sopprevlab { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }
.sopedit .formact { margin-top: 16px; }

@media (max-width: 899px) {
  .sopwrite { grid-template-columns: minmax(0, 1fr); }
  .sopedit textarea { min-height: 260px; }
}
@media (max-width: 640px) {
  .sopgrid { grid-template-columns: minmax(0, 1fr); }
  .sopfields { grid-template-columns: minmax(0, 1fr); }
  .sopdoc { padding: 20px 16px 24px; }
  .sopdoc h1 { font-size: 1.3rem; }
  .sopacts .btn { min-height: 44px; }
}

/* Drafts, reviews and SOPs from a video */
.sopvidoff { margin: -4px 0 12px; }
.sopdrafts { margin-bottom: 14px; }
.sopdrafts .kdue { margin-left: 6px; }
.sopflag.sopai { display: flex; gap: 8px; align-items: flex-start; background: var(--blue-tint); }
.sopflag.sopai.bad { background: var(--amber-bg); }
.sopflag.sopai svg { width: 18px; height: 18px; flex: 0 0 auto; margin-top: 2px; color: var(--blue-btn); }
.sopempty { margin: 8px 0 0; }
.sopprinthead, .sopprintfoot, .sopphr { display: none; }
.soprev, .soprevs { max-width: 820px; margin: 0 auto 12px; }
.soprevs { margin-top: 14px; }
.soprev { border-left: 4px solid var(--blue-btn); }
.soprev .sechead, .soprevs .sechead { font-size: 1rem; margin: 0 0 6px; }
.soprev .kdue { margin-left: 4px; }
.soprevnote { margin: 8px 0 0; padding: 8px 12px; background: var(--surface2); border-radius: 8px; font-size: 0.875rem; color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere; }
.soprev .formact { margin-top: 12px; flex-wrap: wrap; }
.soprvform { margin-top: 10px; }
.soprvform textarea { width: 100%; resize: vertical; }
.soprvlist { list-style: none; margin: 0; padding: 0; }
.soprvrow { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 10px 0; }
.soprvrow + .soprvrow { border-top: 1px solid var(--divider); }
.soprvmain { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.soprvresp { margin-top: 4px; padding: 6px 10px; border-left: 3px solid var(--line); font-size: 0.875rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.soprvst { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; text-align: right; }
.sopsenddlg { width: min(460px, calc(100% - 32px)); top: 8vh; max-height: 86vh; overflow-y: auto; overscroll-behavior: contain; }
.sopwho { border: 0; padding: 0; margin: 0; min-width: 0; }
.sopwho legend { font-weight: 700; font-size: 0.875rem; margin-bottom: 4px; }
.sopwho ul { list-style: none; margin: 0; padding: 0; max-height: 260px; overflow-y: auto; }
.sopwhorow { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 4px 6px; border-radius: 8px; cursor: pointer; }
.sopwhorow:hover { background: var(--row-hover); }
.sopwhorow > span:last-child { display: flex; flex-direction: column; }
.sopwhorow.off { cursor: default; opacity: 0.7; }
.sopwhorow input { width: 18px; height: 18px; margin: 0; flex: 0 0 auto; }
.sopsenddlg .fld input[type="date"], .sopsenddlg .fld input[type="text"] { width: 100%; }
.sopvidform { max-width: 820px; margin: 0 auto; }
.sopvidform .sechead { font-size: 1rem; margin-bottom: 4px; }
.sopvidlede { margin: 0 0 14px; }
.sopvidform .sopfields + .fld { margin-top: 12px; }
.sopvidform .lab { display: block; font-weight: 600; font-size: 0.875rem; margin-bottom: 6px; }
.sopvidform .fld .sopvfile { display: inline-flex; width: auto; margin: 0; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; border: 1px dashed var(--input-strong, var(--line)); border-radius: var(--r-ctl); cursor: pointer; font-weight: 600; position: relative; }
.sopvfile:hover { background: var(--row-hover); }
.sopvfile:focus-within { outline: 2px solid var(--blue-btn); outline-offset: 2px; }
.sopvfile svg { width: 18px; height: 18px; }
.sopvfile input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.sopvfile.off { opacity: 0.6; cursor: default; }
.sopvname { display: inline-block; margin-left: 10px; overflow-wrap: anywhere; }
.sopvidform .hint { display: block; margin-top: 4px; }
.sopvidform .sopflag { margin: 12px 0 0; }
.sopvprog { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.sopvprog progress { flex: 1 1 auto; height: 10px; accent-color: var(--blue-btn); }
.sopvidform .formact { margin-top: 16px; }
.soppage .phact .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.soppage .phact { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
@media (max-width: 640px) {
  .soprvrow { grid-template-columns: auto minmax(0, 1fr); }
  .soprvst { grid-column: 2; align-items: flex-start; text-align: left; flex-direction: row; gap: 8px; }
  .sopvname { display: block; margin: 6px 0 0; }
  .sopsenddlg.swdlg { top: auto; bottom: 0; left: 0; right: 0; width: auto; transform: none; border-radius: 16px 16px 0 0; max-height: 90vh; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
}

/* Print: just the SOP, laid out like the staff how-to guides (A4): a dark band with the MCP logo and "Staff how-to",
   the area label, a serif title, the intro in grey, "Part one" headings over a thin rule, numbered circles, a warm-grey
   "Check before you finish" panel, and a footer with the month it was last updated. */
@media print {
  @page { size: A4 portrait; margin: 14mm 0 12mm; }
  @page :first { margin-top: 0; }
  html:has(.sopdoc) body > :not(#app), html:has(.sopdoc) #app > :not(main),
  html:has(.sopdoc) .side, html:has(.sopdoc) .topbar, html:has(.sopdoc) .wa-root, .sopnoprint { display: none !important; }
  html:has(.sopdoc), html:has(.sopdoc) body { background: #FFFFFF !important; }
  html:has(.sopdoc) .app { display: block !important; min-height: 0; padding: 0 !important; margin: 0 !important; background: none !important; }
  html:has(.sopdoc) main { padding: 0 !important; margin: 0 !important; max-width: none !important; outline: none !important; box-shadow: none !important; border: 0 !important; }
  html:has(.sopdoc) #main::after { content: none !important; }
  .soppage { max-width: none; padding: 0 !important; margin: 0 !important; }
  .sopdoc { max-width: none; border: 0 !important; border-radius: 0 !important; box-shadow: none !important; padding: 0 16mm !important; margin: 0 !important; background: none !important; color: #212121;
    font-size: 10.5pt; font-variant-ligatures: no-common-ligatures; font-feature-settings: "liga" 0; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .sopdoc .sopflag { display: none; }

  .sopprinthead { display: flex; align-items: center; justify-content: space-between; gap: 10mm; margin: 0 -16mm 8mm; padding: 7.5mm 16mm 6.5mm; background: #212121; color: #FFFFFF; }
  .sopprinthead img { display: block; height: 13mm; width: auto; filter: invert(1); }
  .sopphr { display: flex; flex-direction: column; align-items: flex-end; gap: 2.2mm; font-size: 7.5pt; letter-spacing: 0.24em; text-transform: uppercase; color: #E6E6E6; text-align: right; }

  .soparea { font-size: 7.5pt; font-weight: 600; letter-spacing: 0.24em; color: #444444; margin: 0 0 3mm; }
  .sopdoc h1 { font-family: Georgia, "Times New Roman", Times, serif; font-weight: 700; font-size: 23pt; line-height: 1.15; letter-spacing: -0.005em; color: #212121; margin: 0 0 2.5mm; }
  .sopmeta { display: none; }
  .sopbody { color: #212121; font-size: 10.5pt; line-height: 1.5; }
  .sopbody > * + * { margin-top: 2.6mm; }
  .sopbody p, .sopbody li { max-width: none; }
  .sopbody .sopintro { color: #555555; font-size: 10.5pt; line-height: 1.55; max-width: 150mm; margin-bottom: 5mm; }

  .sopbody h2 { font-family: Georgia, "Times New Roman", Times, serif; font-weight: 700; font-size: 14pt; line-height: 1.25; color: #212121; margin-top: 5.5mm; padding-top: 5mm; border-top: 0.6pt solid #CFCFCF; }
  .sopbody > h2:first-child { margin-top: 0; padding-top: 5mm; border-top: 0.6pt solid #CFCFCF; }
  .sopbody .sopintro + h2 { margin-top: 0; }
  .soppartn { display: inline; font-style: italic; font-weight: 400; font-size: 11pt; color: #555555; margin-right: 2.5mm; }
  .sopbody h2.soppart + * { margin-top: 4.5mm; }
  .sopbody h3 { font-size: 10.5pt; font-weight: 700; color: #212121; margin-top: 5mm; }
  .sopbody h2, .sopbody h3 { break-after: avoid; page-break-after: avoid; }

  .sopbody ol.sopsteps > li + li { margin-top: 2.2mm; }
  .sopn { min-width: 5mm; height: 5mm; padding: 0 1.4mm; border-radius: 2.5mm; margin-top: 0.1mm; background: #212121; color: #FFFFFF; font-size: 7.5pt; font-weight: 700; }
  .sopsteps > li { grid-template-columns: 7.6mm minmax(0, 1fr); }
  .sopbody ul { padding-left: 5mm; }
  .sopbody ul > li::marker { color: #555555; }
  .sopkey { border-color: #9E9E9E; background: #FFFFFF; color: #212121; font-size: 8.5pt; padding: 0 1.4mm; border-radius: 1.4mm; border-bottom-width: 0.8pt; }
  .sopbody li, .sopnote, .sopbody p, .sopfinal { break-inside: avoid; page-break-inside: avoid; orphans: 3; widows: 3; }

  .sopnote { background: #F3F0EC; border-left: 1.2mm solid #212121; border-radius: 0; padding: 3mm 4.5mm; font-size: 9.5pt; color: #333333; max-width: none; }
  .sopfinal { margin-top: 6.5mm; padding: 5mm 7mm 6mm; background: #F3F0EC; border-left: 1.2mm solid #212121; border-radius: 0; }
  .sopbody .sopfinal h2.sopfinalh { font-family: Georgia, "Times New Roman", Times, serif; font-size: 13pt; font-weight: 700; color: #212121; margin: 0 0 2.5mm; padding: 0; border: 0; }
  .sopfinal > * + * { margin-top: 2.5mm; }
  .sopbody ul.sopfinallist { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 3mm 8mm; padding: 0 !important; font-size: 10pt; line-height: 1.45; }
  .sopfinallist > li { list-style: none; }

  .sopcheck { background: none; border: 0.5pt dashed #9E9E9E; border-radius: 1mm; padding: 0 1mm; color: #333333; font-weight: 600; }
  .sopprintfoot { display: block; margin-top: 7mm; padding-top: 3mm; border-top: 0.6pt solid #CFCFCF; color: #555555; break-inside: avoid; page-break-inside: avoid; }
  .sopfootrow { display: flex; justify-content: space-between; gap: 8mm; margin: 0; font-size: 8pt; color: #444444; }
  .sopfootnote { margin: 1.5mm 0 0; font-size: 7pt; color: #777777; }
}
.soppage .small { font-size: 0.875rem; }
