/* Component catalogue. Every page is built from these; see docs/DESIGN.md. */

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  padding: 9px 16px; border-radius: var(--r-sm); border: 1px solid var(--brand-700);
  background: var(--brand-700); color: #fff; font: inherit; font-weight: 600; font-size: var(--fs-md); line-height: 1.2;
  cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { background: var(--brand-800); border-color: var(--brand-800); text-decoration: none; color: #fff; }
.btn .icon { width: 16px; height: 16px; }
.btn.secondary { background: var(--surface); color: var(--brand-700); border-color: var(--brand-700); }
.btn.secondary:hover { background: var(--brand-50); color: var(--brand-800); }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line-control); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); border-color: var(--line-control); }
.btn.danger { background: var(--surface); color: var(--bad); border-color: var(--bad); }
.btn.danger:hover { background: var(--bad-bg); color: var(--bad); border-color: var(--bad); }
.btn.link { background: none; border-color: transparent; color: var(--brand-700); padding-left: var(--sp-2); padding-right: var(--sp-2); }
.btn.link:hover { text-decoration: underline; background: none; }
.btn.sm { padding: 5px 10px; font-size: var(--fs-sm); }
.btn.lg { padding: 12px 22px; font-size: var(--fs-lg); }
.btn.block { width: 100%; }
.btn:disabled, .btn.disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: var(--sp-6); box-shadow: var(--shadow-sm); margin-bottom: var(--sp-5);
}
.card.tight { padding: var(--sp-4); }
.card.center { text-align: center; }
.card > h2:first-child, .card > h1:first-child { margin-top: 0; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-3); flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.card-head .actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--sp-4); }
.card-grid .card { margin: 0; display: flex; flex-direction: column; }
.card-grid .card .spacer { flex: 1; }

/* Stat tiles */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--sp-3); margin-bottom: var(--sp-5); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--sp-4); }
.stat .label { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.stat .value { font-size: var(--fs-3xl); font-weight: 650; color: var(--ink); line-height: 1.1; margin-top: var(--sp-1); font-variant-numeric: tabular-nums; }
.stat .value.ok { color: var(--ok); } .stat .value.bad { color: var(--bad); } .stat .value.warn { color: var(--warn); }
.stat .hint { font-size: var(--fs-sm); color: var(--muted); margin-top: var(--sp-1); }

/* ---------- Pills / badges ---------- */
.pill {
  display: inline-block; padding: 2px 9px; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 650; line-height: 1.5;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; vertical-align: middle;
}
.pill.ok   { background: var(--ok-bg);   color: var(--ok);   border-color: var(--ok-line); }
.pill.bad  { background: var(--bad-bg);  color: var(--bad);  border-color: var(--bad-line); }
.pill.warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
.pill.info { background: var(--info-bg); color: var(--info); border-color: var(--info-line); }
.pill.brand{ background: var(--brand-100); color: var(--brand-800); border-color: #B9DCC5; }
.badge { display: inline-block; min-width: 20px; padding: 1px 6px; border-radius: var(--r-pill); font-size: 11px; font-weight: 700; text-align: center; background: var(--bad); color: #fff; }

/* ---------- Flash / alerts ---------- */
.flash, .alert {
  display: flex; align-items: flex-start; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md);
  border: 1px solid var(--info-line); background: var(--info-bg); color: var(--info); margin-bottom: var(--sp-4);
}
.flash .icon, .alert .icon { width: 18px; height: 18px; flex: 0 0 18px; margin-top: 2px; }
.flash .msg, .alert .msg { flex: 1; }
.flash.ok, .alert.ok       { background: var(--ok-bg);   color: var(--ok);   border-color: var(--ok-line); }
.flash.error, .alert.error, .alert.bad { background: var(--bad-bg);  color: var(--bad);  border-color: var(--bad-line); }
.flash.warn, .alert.warn   { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
.flash [data-dismiss] { background: none; border: 0; color: inherit; cursor: pointer; padding: 0 2px; font-size: 18px; line-height: 1; opacity: .7; }
.flash [data-dismiss]:hover { opacity: 1; }

/* Callouts inside content (Ops chapters) */
.callout { border: 1px solid var(--line); border-left: 4px solid var(--brand-700); border-radius: var(--r-md); background: var(--brand-50); padding: var(--sp-3) var(--sp-4); margin: var(--sp-3) 0; font-size: var(--fs-md); }
.callout.warning { background: var(--warn-bg); border-left-color: var(--warn); }
.callout.danger  { background: var(--bad-bg);  border-left-color: var(--bad); }
.callout.success { background: var(--ok-bg);   border-left-color: var(--ok); }
.callout.purple  { background: #F3E8FF; border-left-color: #7E22CE; }

/* ---------- Forms ---------- */
.form { max-width: 100%; }
.field { margin-bottom: var(--sp-4); }
.field > label, .field .label { display: block; font-weight: 600; font-size: var(--fs-sm); color: var(--ink); margin-bottom: var(--sp-1); }
.field .hint { font-size: var(--fs-sm); color: var(--muted); margin-top: var(--sp-1); }
.field .error { font-size: var(--fs-sm); color: var(--bad); margin-top: var(--sp-1); }
.req { color: var(--bad); margin-left: 2px; }
.req-note { font-size: var(--fs-xs); color: var(--muted); margin: 0 0 var(--sp-3); }
input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line-control); border-radius: var(--r-sm); font: inherit; color: var(--text);
  background: var(--surface); transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand-600); box-shadow: var(--focus); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: var(--focus-ring); outline-offset: 0; }
input::placeholder, textarea::placeholder { color: var(--faint); }
/* The browser's own decorations on a text box — the autofill tint and the
   red glow on a not-yet-valid email or password — made one field in a form
   look unlike the rest. Validity is reported by the page, not the box. */
input:autofill, input:-webkit-autofill { -webkit-box-shadow: 0 0 0 1000px var(--surface) inset; box-shadow: 0 0 0 1000px var(--surface) inset; -webkit-text-fill-color: var(--text); }
input:-moz-ui-invalid, input:invalid, select:invalid { box-shadow: none; }
input:-moz-ui-invalid:focus, input:invalid:focus { box-shadow: var(--focus); }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; accent-color: var(--brand-700); margin: 0; vertical-align: -3px; }
select { padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%235E6D66' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; appearance: none; }
.check { display: flex; align-items: flex-start; gap: var(--sp-2); font-weight: normal !important; margin: var(--sp-3) 0; cursor: pointer; }
.check input { margin-top: 3px; }
.sigfont { font-family: var(--font-sig); font-size: 22px !important; }
/* An acknowledgement form reproduced on the signature page (8.9.9-F). */
.ack-meta { font-size: var(--fs-xs); color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 0 0 var(--sp-2); }
.ack-ident td { padding-top: 6px; padding-bottom: 6px; }
.ack-choices { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 0 var(--sp-4); }
.ack-choices .check { margin: var(--sp-1) 0; align-items: center; flex-wrap: nowrap; }
.ack-choices .check span { display: inline-flex; align-items: center; gap: var(--sp-2); white-space: nowrap; }
.ack-other { width: clamp(6em, 40vw, 12em); padding: 3px 6px; font-size: var(--fs-sm); }
.ack-statements td label { display: block; cursor: pointer; }
.ack-statements td:last-child { width: 6.5em; }
.ack-statements td input { width: 5.5em; text-align: center; text-transform: uppercase; font-weight: 600; padding: 5px 6px; }
.form-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; margin-top: var(--sp-5); }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--sp-3); }
/* Stacked labels on a plain <form class="form"> (settings, account actions). */
.form label { display: block; margin: var(--sp-3) 0; font-weight: 600; font-size: var(--fs-sm); color: var(--ink); }
.form label input, .form label select { margin-top: var(--sp-1); font-weight: normal; }

/* Filter bar above a table */
.filter { display: flex; gap: var(--sp-3); align-items: flex-end; flex-wrap: wrap; margin-bottom: var(--sp-4); padding: var(--sp-3) var(--sp-4); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md); }
.filter label { font-size: var(--fs-xs); font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; display: block; }
.filter label input, .filter label select { display: block; margin-top: var(--sp-1); min-width: 150px; font-size: var(--fs-md); text-transform: none; letter-spacing: 0; font-weight: normal; }
.filter .actions { display: flex; gap: var(--sp-2); align-items: center; margin-left: auto; }
.toolbar { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; margin-bottom: var(--sp-3); }
.toolbar .grow { flex: 1; min-width: 200px; }
.count { font-size: var(--fs-sm); color: var(--muted); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.table-wrap.bad { border: 2px solid var(--bad); }     /* a table of things that are wrong */
table.data, table.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
table.data th, table.table th {
  background: var(--surface-2); color: var(--muted); text-align: left; padding: 10px 12px; font-weight: 650; font-size: var(--fs-xs);
  text-transform: uppercase; letter-spacing: .06em; border-bottom: 1px solid var(--line); position: sticky; top: 0; white-space: nowrap;
}
table.data td, table.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data tbody tr:last-child td, table.table tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td, table.table tbody tr:hover td { background: var(--brand-50); }
table.data td.num, table.table td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td .actions, table.table td .actions { display: flex; gap: var(--sp-1); flex-wrap: wrap; }
.sigcell { font-family: var(--font-sig); font-size: 16px; }
.empty { text-align: center; color: var(--muted); padding: var(--sp-8) var(--sp-4); }
.empty .big { font-size: 36px; margin-bottom: var(--sp-2); color: var(--faint); }
.empty h3 { color: var(--ink); margin-bottom: var(--sp-1); }
.empty p { max-width: 48ch; margin: 0 auto var(--sp-4); }
td.empty { padding: var(--sp-6); }

/* Definition table (completion record) */
table.cert { width: 100%; border-collapse: collapse; text-align: left; margin: var(--sp-4) 0; }
table.cert th { width: 38%; color: var(--muted); font-weight: 600; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: var(--fs-sm); }
table.cert td { padding: 9px 12px; border-bottom: 1px solid var(--line); }
table.cert tr:last-child th, table.cert tr:last-child td { border-bottom: 0; }

/* Pager */
.pager { display: flex; gap: var(--sp-3); align-items: center; justify-content: center; margin-top: var(--sp-4); flex-wrap: wrap; }
.pager .btn { margin: 0; }
.pager form { display: flex; align-items: center; gap: var(--sp-2); margin-left: var(--sp-3); }
.pager form label { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); color: var(--muted); }
.pager form select { width: auto; padding: 5px 30px 5px 10px; font-size: var(--fs-sm); }

/* ---------- Progress ----------
   A native <progress class="bar"> (the `progress` macro). Vendor pseudo-elements
   must stay in separate rules: one unknown selector in a list drops the rule. */
progress.bar { display: block; width: 100%; height: 8px; margin: var(--sp-3) 0; border: 0; border-radius: var(--r-pill); overflow: hidden; background: var(--line); color: var(--brand-500); -webkit-appearance: none; appearance: none; }
progress.bar::-webkit-progress-bar { background: var(--line); border-radius: var(--r-pill); }
progress.bar::-webkit-progress-value { background: var(--brand-500); border-radius: var(--r-pill); }
progress.bar::-moz-progress-bar { background: var(--brand-500); border-radius: var(--r-pill); }
progress.bar.ok { color: var(--ok); }
progress.bar.ok::-webkit-progress-value { background: var(--ok); }
progress.bar.ok::-moz-progress-bar { background: var(--ok); }
progress.bar.warn { color: #D97706; }
progress.bar.warn::-webkit-progress-value { background: #D97706; }
progress.bar.warn::-moz-progress-bar { background: #D97706; }
progress.bar.bad { color: #DC2626; }
progress.bar.bad::-webkit-progress-value { background: #DC2626; }
progress.bar.bad::-moz-progress-bar { background: #DC2626; }

/* ---------- Modal ---------- */
dialog.modal { border: 0; border-radius: var(--r-lg); padding: 0; max-width: min(560px, calc(100vw - 32px)); width: 100%; box-shadow: var(--shadow-lg); color: var(--text); }
dialog.modal::backdrop { background: rgba(0,34,17,.5); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: var(--fs-lg); }
.modal-body { padding: var(--sp-5); }
.modal-foot { display: flex; justify-content: flex-end; gap: var(--sp-2); padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }

/* ---------- Toasts ---------- */
.toasts { position: fixed; right: var(--sp-4); bottom: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-2); z-index: 60; max-width: min(380px, calc(100vw - 32px)); }
.toast { background: var(--ink); color: #fff; padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md); box-shadow: var(--shadow-md); opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; font-size: var(--fs-sm); }
.toast.show { opacity: 1; transform: none; }
.toast-error { background: var(--bad); }
.toast-ok { background: var(--ok); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: var(--sp-1); box-shadow: inset 0 -1px 0 var(--line); margin-bottom: var(--sp-4); overflow-x: auto; }   /* an inset shadow, not a border: the active underline overlays it without overflowing (a border and a -1px margin drew a scrollbar) */
.tabs a { padding: var(--sp-2) var(--sp-3); color: var(--muted); font-weight: 600; font-size: var(--fs-sm); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.active { color: var(--brand-700); border-bottom-color: var(--brand-700); }

/* ---------- Layout utilities ---------- */
.row { display: flex; gap: var(--sp-3); align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: var(--sp-3); }
.grow { flex: 1; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; } .mt-4 { margin-top: var(--sp-4); } .mb-4 { margin-bottom: var(--sp-4); }
.right { text-align: right; } .center { text-align: center; }
.nowrap { white-space: nowrap; }
.icon { display: inline-block; width: 1em; height: 1em; vertical-align: -0.15em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

/* ---------- Training: program list ---------- */
.program { display: flex; flex-direction: column; }
.program .program-title { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-2); }
.program .program-title .icon { width: 22px; height: 22px; color: var(--brand-700); }
.program .program-title h2 { margin: 0; font-size: var(--fs-lg); }
.program .desc { color: var(--muted); font-size: var(--fs-sm); margin-bottom: var(--sp-3); }
.program .status-list { list-style: none; margin: 0 0 var(--sp-3); padding: 0; font-size: var(--fs-sm); }
.program .status-list li { display: flex; justify-content: space-between; gap: var(--sp-3); align-items: center; padding: var(--sp-2) 0; border-top: 1px solid var(--line); }
.program .status-list li span:first-child { flex: 1; }
.program .foot { margin-top: auto; display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }

/* ---------- Training: slides ---------- */
.train-head { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.counter { color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.slide { min-height: 300px; max-height: 68vh; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--sp-6); background: var(--surface); }
.slide h2 { font-size: var(--fs-xl); }
.purpose { line-height: 1.55; font-size: var(--fs-lg); }
.slide .scope { color: var(--muted); font-size: var(--fs-md); margin-top: var(--sp-1); }
.slide .lab, .chapter-audience .lab, .chapter-body .lab, .chapter-kp .lab { color: var(--brand-700); font-weight: 650; }
.slide .subh { font-size: var(--fs-lg); color: var(--brand-800); margin: var(--sp-4) 0 var(--sp-1); border-bottom: 1px solid var(--line); padding-bottom: 3px; }
.pts { margin: var(--sp-2) 0 var(--sp-1); line-height: 1.6; padding-left: 22px; }
.pts li { margin-bottom: 5px; }
.nav { display: flex; justify-content: space-between; gap: var(--sp-2); margin-top: var(--sp-4); flex-wrap: wrap; }
.nav > div { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.narrate { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--sp-2) var(--sp-3); margin: var(--sp-2) 0 var(--sp-3); font-size: var(--fs-sm); }
.narrate .nlabel { font-weight: 650; color: var(--brand-800); }
.narrate .nopt { display: flex; align-items: center; gap: 5px; color: var(--text); }
.narrate select { width: auto; padding: 4px 28px 4px 8px; font-size: var(--fs-xs); max-width: 200px; }
.narrate .nstate { color: var(--brand-700); font-weight: 600; margin-left: auto; }

/* ---------- Training: quiz & result ---------- */
.qblock { border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--sp-4) var(--sp-5); margin: var(--sp-3) 0; background: var(--surface); }
.qtext { font-weight: 600; margin-bottom: var(--sp-2); color: var(--ink); }
.qn { color: var(--brand-700); }
.opt { display: flex; align-items: flex-start; gap: var(--sp-2); font-weight: normal; padding: 7px var(--sp-2); cursor: pointer; border-radius: var(--r-sm); }
.opt:hover { background: var(--brand-50); }
.opt input { margin-top: 3px; }
.score { font-size: 56px; font-weight: 700; margin: var(--sp-2) 0; line-height: 1; letter-spacing: -0.02em; }
.score.ok { color: var(--ok); } .score.bad { color: var(--bad); }
.pass-msg { color: var(--ok); font-weight: 600; } .fail-msg { color: var(--bad); }
.seal { width: 64px; height: 64px; border-radius: 50%; background: var(--ok-bg); color: var(--ok); font-size: 32px; line-height: 64px; margin: 0 auto var(--sp-3); font-weight: 700; }

/* ---------- Training: chapters (every program) ---------- */
.toc-part { font-size: var(--fs-xs); color: var(--muted); margin: var(--sp-5) 0 var(--sp-1); text-transform: uppercase; letter-spacing: .08em; font-weight: 650; }
.toc { list-style: none; margin: 0; padding: 0; }
.toc li { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) var(--sp-1); border-bottom: 1px solid var(--line); font-size: var(--fs-md); }
.toc li:last-child { border-bottom: 0; }
.toc a { font-weight: 500; }
.toc .spacer { margin-left: auto; }
.chapter-num { display: inline-block; min-width: 28px; text-align: center; background: var(--brand-700); color: #fff; font-size: var(--fs-xs); font-weight: 650; padding: 3px 6px; border-radius: var(--r-pill); flex-shrink: 0; }
.chapter-num.todo { background: var(--line-strong); color: var(--ink); }
.chapter-meta { color: var(--muted); font-size: var(--fs-sm); margin: 2px 0 var(--sp-3); }
.chapter-audience { background: var(--brand-50); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--sp-3) var(--sp-4); margin: var(--sp-3) 0; }
.chapter-body { line-height: 1.6; font-size: var(--fs-md); }
.chapter-body h2 { font-size: var(--fs-lg); color: var(--brand-800); margin: var(--sp-5) 0 var(--sp-2); border-bottom: 1px solid var(--line); padding-bottom: 3px; }
.chapter-body h3 { font-size: var(--fs-md); color: var(--brand-800); margin: var(--sp-4) 0 var(--sp-1); }
.chapter-body ul, .chapter-body ol { margin: var(--sp-2) 0; padding-left: 24px; }
.chapter-body li { margin-bottom: 5px; }
.chapter-body .data-table { width: 100%; border-collapse: collapse; margin: var(--sp-3) 0; font-size: var(--fs-sm); }
.chapter-body .data-table th { background: var(--surface-2); color: var(--muted); text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); }
.chapter-body .data-table td { padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
.chapter-body .badge { display: inline-block; padding: 2px 9px; border-radius: var(--r-pill); font-size: 11px; font-weight: 700; background: var(--info-bg); color: var(--info); min-width: 0; }
.chapter-body .badge.low { background: var(--ok-bg); color: var(--ok); }
.chapter-body .badge.med { background: var(--warn-bg); color: var(--warn); }
.chapter-body .badge.high { background: var(--bad-bg); color: var(--bad); }
.chapter-kp { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--sp-3) var(--sp-4); margin: var(--sp-4) 0; }
.chapter-kp .lab { font-size: var(--fs-sm); }
.chapter-kp ul { margin: var(--sp-1) 0 0; padding-left: 22px; line-height: 1.6; }
/* Content classes carried over from the standalone equipment programs, so the
   converted chapter HTML renders under the design system's tokens. */
.chapter-body .badge.crit { background: #3D1A5C; color: #E8D5FF; }
.chapter-body .step-list { counter-reset: steps; list-style: none; padding-left: 0; margin: var(--sp-3) 0; }
.chapter-body .step-list li { counter-increment: steps; display: flex; gap: var(--sp-3); margin-bottom: var(--sp-3); align-items: flex-start; }
.chapter-body .step-list li::before { content: counter(steps); background: var(--brand-700); color: #fff; font-size: var(--fs-xs); font-weight: 700; width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.chapter-body .doc-ref { color: var(--muted); font-size: var(--fs-sm); font-style: italic; }
.chapter-body .video-embed { position: relative; width: 100%; max-width: 720px; aspect-ratio: 16 / 9; margin: var(--sp-3) 0; }
.chapter-body .video-embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 1px solid var(--line); border-radius: var(--r-md); }
.chapter-body .video-embed.tall { max-width: 100%; aspect-ratio: auto; height: min(820px, 80vh); }
.chapter-body .load-chart-visual { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; margin: var(--sp-4) 0; font-size: var(--fs-sm); }
.chapter-body .lc-header { background: var(--brand-800); color: #fff; padding: 8px 10px; text-align: center; font-weight: 700; font-size: var(--fs-xs); letter-spacing: .5px; }
.chapter-body .lc-cell { background: var(--surface); padding: 10px; text-align: center; }
.chapter-body .lc-cell.safe-zone { background: var(--ok-bg); color: var(--ok); font-weight: 600; }
.chapter-body .lc-cell.caution-zone { background: var(--warn-bg); color: var(--warn); font-weight: 600; }
.chapter-body .lc-cell.danger-zone { background: var(--bad-bg); color: var(--bad); font-weight: 600; }
.chapter-body .lc-val { font-size: var(--fs-xl); font-weight: 700; display: block; line-height: 1; }
.chapter-body .lc-lbl { font-size: 10px; color: var(--muted); margin-top: 3px; display: block; }
.chapter-body .angle-diagram { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--sp-4); margin: var(--sp-4) 0; display: flex; gap: var(--sp-6); flex-wrap: wrap; }
.chapter-body .angle-item { text-align: center; flex: 1; min-width: 120px; }
.chapter-body .ang-val { font-size: var(--fs-3xl); font-weight: 700; color: var(--brand-800); line-height: 1.1; }
.chapter-body .ang-lbl { font-size: var(--fs-xs); color: var(--muted); }
.chapter-body .ang-cap { font-size: var(--fs-sm); font-weight: 600; margin-top: var(--sp-1); }
.chapter-body .ang-cap.safe { color: var(--ok); }
.chapter-body .ang-cap.caution { color: var(--warn); }
.chapter-body .ang-cap.danger { color: var(--bad); }

/* ---------- Training: printable inspection checklist ---------- */
.inspect-group { border: 1px solid var(--line); border-radius: var(--r-md); margin-bottom: var(--sp-4); overflow: hidden; }
.inspect-group > h3 { background: var(--surface-2); border-bottom: 1px solid var(--line); margin: 0; padding: var(--sp-2) var(--sp-4); font-size: var(--fs-md); color: var(--brand-800); display: flex; justify-content: space-between; gap: var(--sp-3); }
.inspect-group > h3 .count { color: var(--muted); font-weight: 500; font-size: var(--fs-xs); }
.inspect-head, .inspect-item { display: grid; grid-template-columns: 1fr repeat(3, 72px); align-items: center; gap: var(--sp-2); padding: 6px var(--sp-4); }
.inspect-head { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 650; border-bottom: 1px solid var(--line); }
.inspect-head span:not(:first-child), .inspect-item .mark { text-align: center; }
.inspect-item { border-bottom: 1px solid var(--line); font-size: var(--fs-sm); }
.inspect-item:last-child { border-bottom: 0; }
.inspect-item:nth-child(even) { background: var(--surface-2); }
.inspect-item .mark input { margin: 0; }
.inspect-sign { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--sp-4); margin-top: var(--sp-4); }
@media (max-width: 640px) {
  .inspect-head, .inspect-item { grid-template-columns: 1fr repeat(3, 52px); padding-left: var(--sp-3); padding-right: var(--sp-3); }
  .chapter-body .load-chart-visual { font-size: var(--fs-xs); grid-template-columns: 1fr; }
  .emp-tools input[type=search] { min-width: 0; width: 100%; }
  .toolbar .grow { min-width: 0; }
  .activity .when { min-width: 0; }
}

.savebar { display: flex; align-items: center; gap: var(--sp-3); margin-top: var(--sp-4); position: sticky; bottom: 0; background: var(--surface); padding: var(--sp-3) 0; border-top: 1px solid var(--line); }

/* ---------- Manual record page ---------- */
.emp-tools { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; margin: var(--sp-4) 0 var(--sp-2); }
.emp-tools input[type=search] { min-width: 240px; width: auto; }
.emp-list { max-height: 400px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--r-md); }
.emp-list table.data th { position: sticky; top: 0; }
.emp-list td label { display: block; cursor: pointer; font-weight: normal; }
.tag-warn { font-size: var(--fs-xs); color: var(--warn); white-space: nowrap; }
.selcount { font-size: var(--fs-sm); color: var(--muted); }

/* ---------- Accounts page details ---------- */
.acct-actions { display: flex; flex-direction: column; gap: var(--sp-1); }
.acct-actions form { margin: 0; }
.inline-form { display: flex; gap: var(--sp-1); align-items: center; flex-wrap: wrap; }
.inline-form input, .inline-form select { width: auto; padding: 5px 8px; font-size: var(--fs-sm); }
.inline-form select { padding-right: 28px; }
details.tracks summary { cursor: pointer; font-weight: 500; }
details.tracks .check { margin: var(--sp-1) 0; font-size: var(--fs-sm); }

/* ---------- Compliance Tracker (Phase 2) ---------- */
.hidden { display: none !important; }

/* Two equal panels that stack on narrow screens: dashboard cards, the employee
   profile/requirements pair, the settings columns. */
.dash-cols { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); align-items: start; }
/* A grid item's min-width is its content's by default, so a table in a card
   would push its column past the viewport. Let the column shrink; the table
   scrolls inside .table-wrap instead. */
.dash-cols > * { min-width: 0; }
.dash-cols > .card { margin: 0; }

/* Department / assignment tags inside a table cell. */
.tag { display: inline-block; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 1px 7px; font-size: var(--fs-xs); color: var(--muted); margin: 1px 2px 1px 0; }
.tag.primary { border-color: var(--brand-700); color: var(--brand-800); font-weight: 600; background: var(--brand-50); }

/* Category colour chip. The colour is per record, so it arrives as the fill of
   an inline SVG circle; everything around it is tokenised. */
.cat-dot { display: inline-block; width: 9px; height: 9px; margin-right: 6px; vertical-align: middle; }
/* Signal-word dot on an inventory tag (SDS locations page). */
.signal-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.signal-dot.ok { background: var(--ok); }
.signal-dot.warn { background: var(--warn); }
.signal-dot.bad { background: var(--bad); }

/* Per-employee training completeness in a table cell. */
.minibar { min-width: 120px; }
.minibar progress.bar { margin: 0 0 3px; }

/* Checkbox grid for assigning departments. */
.checkgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--sp-1) var(--sp-3); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--sp-3); background: var(--surface-2); }
.checkgrid .check { margin: 0; font-size: var(--fs-sm); }

/* Scrolling employee picker on the bulk-record page. */
.picklist { max-height: 380px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.picklist .pick { margin: 0; padding: 7px var(--sp-3); border-bottom: 1px solid var(--line); align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); }
.picklist .pick:last-child { border-bottom: 0; }
.picklist .pick:hover { background: var(--brand-50); }
.picklist .pick input { margin-top: 0; }

/* Status legend above the matrix. */
.legend { display: flex; gap: var(--sp-4); flex-wrap: wrap; align-items: center; font-size: var(--fs-sm); color: var(--muted); margin: 0 0 var(--sp-3); }
.legend span { display: flex; align-items: center; gap: var(--sp-1); }
.legend .key { width: 12px; height: 12px; border-radius: 3px; border: 1px solid var(--line-strong); }
.legend .key.ok { background: var(--ok-bg); border-color: var(--ok-line); }
.legend .key.warn { background: var(--warn-bg); border-color: var(--warn-line); }
.legend .key.bad { background: var(--bad-bg); border-color: var(--bad-line); }
.legend .key.none { background: var(--surface-2); }

/* The compliance matrix: rotated requirement headings and a frozen name column
   so a wide grid stays readable while it scrolls sideways. */
table.matrix { width: auto; min-width: 0; }
table.matrix th.rot { height: 132px; width: 44px; padding: 0; vertical-align: bottom; }
table.matrix th.rot > div { writing-mode: vertical-rl; transform: rotate(180deg); padding: var(--sp-2) 3px; font-size: var(--fs-xs); font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--ink); white-space: nowrap; }
table.matrix th.rot a { color: inherit; }
table.matrix th.namehd, table.matrix th.name { position: sticky; left: 0; z-index: 2; background: var(--surface); text-align: left; }
table.matrix th.namehd { z-index: 3; }
table.matrix th.name { min-width: 180px; font-weight: 600; white-space: nowrap; padding: 10px 12px; border-bottom: 1px solid var(--line); box-shadow: 1px 0 0 var(--line); text-transform: none; letter-spacing: 0; font-size: var(--fs-sm); }
table.matrix tbody tr:hover th.name { background: var(--brand-50); }
table.matrix td.cell { text-align: center; font-weight: 700; padding: 0; }
table.matrix td.cell a { display: block; padding: 10px 4px; color: inherit; text-decoration: none; }
table.matrix td.cell.current  { background: var(--ok-bg);   color: var(--ok); }
table.matrix td.cell.expiring { background: var(--warn-bg); color: var(--warn); }
table.matrix td.cell.expired  { background: var(--bad-bg);  color: var(--bad); }
table.matrix td.cell.missing  { background: var(--surface-2); color: var(--faint); }
table.matrix td.cell.na { background: var(--bg); }

/* Category heading above each group of recurring items. */
.group-title { display: flex; align-items: center; font-size: var(--fs-sm); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: var(--sp-5) 0 var(--sp-2); }

.colorinput { width: 64px; height: 40px; padding: 3px; }
.center-actions { justify-content: center; }

/* Roster print view: the on-screen table is fine, print just needs it tight. */
@media print {
  .print-roster { font-size: 10pt; }
  .table-wrap { border: 0; overflow: visible; }
  .no-print, .tabs { display: none !important; }
}

/* ---------------------------------------------------------------- SDS ----
   GHS pictograms, hazard statements, the search result card and the printed
   binder. Added by Phase 3; everything else on the SDS pages is the shared
   catalogue above. */
.ghs { display: inline-block; width: 34px; height: 34px; flex-shrink: 0; vertical-align: middle; }
.pics { display: inline-flex; gap: var(--sp-1); flex-wrap: wrap; align-items: center; }
.pics.sm .ghs { width: 24px; height: 24px; }
.pic-grid .check { align-items: center; gap: var(--sp-2); }
.pic-grid .ghs { width: 26px; height: 26px; }

.haz-list { list-style: none; margin: var(--sp-2) 0 0; padding: 0; font-size: var(--fs-sm); }
.haz-list li { display: flex; gap: var(--sp-2); padding: 2px 0; }
.haz-list .code { color: var(--brand-700); font-weight: 600; flex-shrink: 0; }

/* Search results and the Updates page share one card shape. */
.sds-result { margin-bottom: var(--sp-3); }
.sds-result-head { display: flex; gap: var(--sp-4); align-items: flex-start; flex-wrap: wrap; }
.sds-result-body { flex: 1; min-width: 220px; }
.sds-result-body h2, .sds-result-body h3 { margin: 0; font-size: var(--fs-lg); }
.sds-result-body .sub { margin: 2px 0 var(--sp-2); }
.sds-result .meta { display: flex; gap: var(--sp-4); flex-wrap: wrap; align-items: center; margin: 0; font-size: var(--fs-sm); color: var(--muted); }
.sds-result .meta b { color: var(--text); }
.sds-result .meta b.ok { color: var(--ok); }
.sds-result .meta b.bad { color: var(--bad); }
.sds-result .actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: flex-start; margin-left: auto; }
.sds-result .actions form { margin: 0; }
.sds-result.outdated { border-color: var(--bad-line); }
.sds-placed { margin: var(--sp-3) 0 0; }

/* Dashboard: signal-word bars and the activity feed. */
.bar-row { margin: var(--sp-3) 0; }
.bar-label { display: flex; justify-content: space-between; font-size: var(--fs-sm); margin-bottom: 4px; }
.activity { list-style: none; margin: 0; padding: 0; }
.activity li { display: flex; gap: var(--sp-4); padding: var(--sp-2) 0; border-bottom: 1px solid var(--line); font-size: var(--fs-sm); }
.activity li:last-child { border-bottom: 0; }
.activity .when { color: var(--muted); min-width: 96px; flex-shrink: 0; }

/* The one-field "add an area" form under each facility. */
.inline-add { display: flex; gap: var(--sp-2); margin-top: var(--sp-3); flex-wrap: wrap; }
.inline-add input { flex: 1 1 200px; }

/* Hazard-statement language picker: a filter bar with a single control. */
.lang-picker { display: flex; align-items: flex-end; gap: var(--sp-2); margin: 0 0 var(--sp-3); }
.lang-picker label { display: flex; flex-direction: column; gap: 4px; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.card-head .lang-picker { margin: 0; }

.binder-section { margin-bottom: var(--sp-6); break-inside: avoid; }
.binder-section h2 { font-size: var(--fs-lg); border-bottom: 2px solid var(--brand-700); padding-bottom: 4px; margin: 0 0 2px; }
.binder-section .sub { margin: 0 0 var(--sp-3); }
.sds-url { font-size: var(--fs-xs); word-break: break-all; max-width: 220px; }

@media print {
  /* A printed binder is a reference document: pictograms and long URLs both
     have to survive the trip to paper. */
  .ghs { width: 20px; height: 20px; }
  .sds-url { max-width: none; font-size: 7pt; }
  .binder-section table.data { font-size: 9pt; }
  .lang-picker, .inline-add { display: none !important; }
}

@media (max-width: 860px) {
  .dash-cols { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .card { padding: var(--sp-4); border-radius: var(--r-md); }
  .filter .actions { margin-left: 0; width: 100%; }
  .filter label input, .filter label select { min-width: 0; width: 100%; }
  .filter label { flex: 1 1 140px; }
  .score { font-size: 44px; }
  .slide { padding: var(--sp-4); max-height: none; }
  .nav .btn { flex: 1 1 auto; }
}

/* ---- Phase 5: Home and admin ---- */
.home-section { font-size: var(--fs-lg); margin: var(--sp-6) 0 var(--sp-3); }
.home-section:first-of-type { margin-top: 0; }
a.stat { display: block; color: inherit; text-decoration: none; }
a.stat:hover { border-color: var(--brand-500); text-decoration: none; }
.quick-search { display: flex; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.quick-search input[type=search] { flex: 1; min-width: 0; }
table.data tr.inactive td { opacity: .6; }
table.data th.w-check { width: 34px; }
details.tracks summary.dirty { font-weight: 600; }
