/* ═══════════════════════════════════════════════════════════════════════════
   FCMS Module 2 — lab pages (/lab, /lab/embryology, /lab/andrology, /lab/import)
   Builds on /design-system/tokens.css + /journey/static/journey.css. Colours only via tokens.
   Result flags: Normal = emerald · Low = sapphire · High = ruby · Critical LL / HH = ruby-dark, pulsing.
   ═══════════════════════════════════════════════════════════════════════════ */

/* lab sub-navigation (the pages that are not in the sidebar, e.g. the LensHooke import) */
.lab-subnav { display: flex; gap: 6px; flex-wrap: wrap; margin: -6px 0 16px; }
.lab-subnav a { border: 1.5px solid var(--border-strong); background: var(--white); color: var(--dept-deep); border-radius: 999px;
  padding: 6px 14px; font-weight: 700; font-size: 13.5px; }
.lab-subnav a.on { background: var(--dept-deep); border-color: var(--dept-deep); color: var(--white); }
.lab-subnav a:hover { border-color: var(--sapphire); }

/* result flags */
.flag { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; padding: 3px 9px; border-radius: 999px;
  font-weight: 800; font-size: 13px; letter-spacing: .04em; color: var(--white); background: var(--gray-400); }
.flag.N { background: var(--emerald); }
.flag.L { background: var(--sapphire); }
.flag.H, .flag.A { background: var(--ruby); }
.flag.LL, .flag.HH { background: var(--ruby-dark); animation: lab-critical 1.4s ease-in-out infinite; }
.flag.none { background: var(--sand-deep); color: var(--ink-soft); }
.val.N { color: var(--emerald-dark); font-weight: 700; }
.val.L { color: var(--sapphire); font-weight: 700; }
.val.H, .val.A { color: var(--ruby); font-weight: 700; }
.val.LL, .val.HH { color: var(--ruby-dark); font-weight: 800; }
tr.critical td { background: var(--ruby-muted); }
tr.critical td:first-child { box-shadow: inset 4px 0 0 var(--ruby-dark); }
@keyframes lab-critical {
  0%, 100% { box-shadow: 0 0 0 0 var(--ruby-light); opacity: 1; }
  50% { box-shadow: 0 0 0 5px var(--ruby-muted); opacity: .78; }
}
@media (prefers-reduced-motion: reduce) { .flag.LL, .flag.HH { animation: none; } }

/* WHO 2021 below / met marks (andrology) */
.who { font-size: 12.5px; font-weight: 700; border-radius: 999px; padding: 2px 8px; white-space: nowrap; }
.who.below { background: var(--ruby-muted); color: var(--ruby-dark); }
.who.met { background: var(--emerald-muted); color: var(--emerald-dark); }
.who.none { background: var(--sand); color: var(--ink-soft); }
.num-below { color: var(--ruby-dark); font-weight: 800; }
.num-met { color: var(--emerald-dark); font-weight: 700; }

/* status counts on the worklist tabs */
.tabs.lab-status-tabs { gap: 2px; }
.tabs.lab-status-tabs button { padding: 9px 11px; font-size: 14.5px; }
.tabs button .count { display: inline-block; min-width: 22px; padding: 1px 7px; margin-left: 6px; border-radius: 999px; font-size: 12.5px;
  background: var(--sand-deep); color: var(--ink); }
.tabs button.on .count { background: var(--ruby); color: var(--white); }

/* tables that may scroll sideways on a tablet */
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tablewrap table.t { min-width: 760px; }
table.t td.nowrap, table.t th.nowrap { white-space: nowrap; }
table.t tr.click { cursor: pointer; }
table.t td .sub { display: block; color: var(--ink-soft); font-size: 13px; font-weight: 500; }
table.t.compact td, table.t.compact th { padding: 7px 9px; font-size: 14px; }
table.t.sa td, table.t.sa th { padding: 6px 7px; font-size: 13.5px; }
table.t.sa td.diag { max-width: 190px; overflow-wrap: anywhere; }

/* composite form fields (div, not label) and secondary text */
.f-block { display: flex; flex-direction: column; gap: 5px; }
.f-block .f-label { font-size: 13.5px; color: var(--ink); font-weight: 700; }
.sub { display: block; color: var(--ink-soft); font-size: 13px; font-weight: 500; }

/* patient chip / picker */
.pt-chip { display: inline-flex; align-items: center; gap: 8px; border: 1.5px solid var(--border-strong); border-radius: 999px; padding: 5px 6px 5px 14px;
  background: var(--white); font-weight: 600; }
.picker { position: relative; }
.picker .hits { position: absolute; z-index: 30; left: 0; right: 0; top: 100%; margin-top: 4px; background: var(--white);
  border: 1px solid var(--border-soft); border-radius: 6px; box-shadow: var(--shadow-lg); max-height: 280px; overflow: auto; }
.picker .hits div { padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--border-soft); }
.picker .hits div:hover, .picker .hits div:focus { background: var(--gray-50); }

/* test picker */
.testgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 6px; max-height: 340px; overflow: auto;
  border: 1px solid var(--border-soft); border-radius: 6px; padding: 8px; background: var(--cream-deep); }
.testgrid label { display: flex; gap: 8px; align-items: flex-start; padding: 6px 8px; border-radius: 6px; background: var(--white);
  border: 1px solid var(--border-soft); cursor: pointer; font-size: 14px; }
.testgrid label.on { border-color: var(--sapphire); box-shadow: 0 0 0 2px var(--sapphire-muted); }
.testgrid label b { color: var(--dept-deep); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button { border: 1.5px dashed var(--border-strong); background: var(--white); border-radius: 999px; padding: 6px 12px; cursor: pointer;
  font-weight: 700; font-size: 13.5px; color: var(--dept-deep); }
.chips button:hover { border-color: var(--sapphire); border-style: solid; }

/* specimen tubes */
.tube { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border: 1px solid var(--border-soft); border-radius: 6px;
  background: var(--cream-deep); margin-bottom: 8px; }
.tube.done { background: var(--emerald-muted); border-color: var(--emerald-line); }
.tube.rejected { background: var(--ruby-muted); border-color: var(--ruby-line); }
.tube code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; font-weight: 700; }

/* section header inside a modal */
.sect { margin-top: 18px; }
.sect > h4 { margin: 0 0 8px; font-size: 15.5px; color: var(--ink); display: flex; gap: 8px; align-items: center; }
.note { background: var(--warning-muted); border: 1px solid var(--pill-warn-bg); color: var(--pill-warn-ink); border-radius: 6px; padding: 10px 12px;
  font-size: 14px; font-weight: 600; }
.note.info { background: var(--sapphire-muted); border-color: var(--pill-info-bg); color: var(--pill-info-ink); }
.note.danger { background: var(--ruby-muted); border-color: var(--ruby-line); color: var(--ruby-dark); }

/* small inputs inside tables */
.input.sm, select.input.sm { padding: 6px 8px; font-size: 14px; }
.input.w80 { width: 80px; } .input.w110 { width: 110px; } .input.w160 { width: 160px; }

/* cryo inventory tree */
.tank { border: 1px solid var(--border-soft); border-radius: 6px; margin-bottom: 12px; overflow: hidden; background: var(--white); }
.tank > .head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; background: var(--dept-deep); color: var(--white); }
.tank > .head b { font-size: 16px; }
.tank > .head .pill { background: var(--on-dark-hover); color: var(--white); }
.canister { border-top: 1px solid var(--border-soft); }
.canister > .chead { padding: 8px 14px; background: var(--sand); font-weight: 700; color: var(--ink); }
.kind-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.kind-dot.embryo { background: var(--emerald); } .kind-dot.oocyte { background: var(--ruby); } .kind-dot.sperm { background: var(--sapphire); }

/* import drop zone */
.drop { border: 2px dashed var(--border-strong); border-radius: 10px; padding: 34px 20px; text-align: center; cursor: pointer; background: var(--white); }
.drop.has { background: var(--emerald-muted); border-color: var(--emerald); }
.drop.over { border-color: var(--sapphire); background: var(--sapphire-muted); }
.drop .big-ico { font-size: 34px; }
.steps { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.steps span { padding: 6px 14px; border-radius: 999px; background: var(--sand); color: var(--ink-soft); font-weight: 700; font-size: 13.5px; }
.steps span.on { background: var(--dept-deep); color: var(--white); }
.steps span.done { background: var(--emerald-muted); color: var(--emerald-dark); }

/* read-only banner */
.ro-banner { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

@media (max-width: 1100px) {
  .main { padding: 20px 18px 50px; }
  .topbar h1 { font-size: 23px; }
}

/* lab analyzers (/lab/analyzers): gateway status dot, the needs-action badge, message detail */
.an-st { display: inline-flex; align-items: center; gap: 7px; font-weight: 700; white-space: nowrap; }
.an-dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; background: var(--gray-400); flex: none; }
.an-dot.ok { background: var(--emerald); box-shadow: 0 0 0 3px var(--emerald-muted); }
.an-dot.info { background: var(--sapphire); box-shadow: 0 0 0 3px var(--sapphire-muted); }
.an-dot.bad { background: var(--ruby); box-shadow: 0 0 0 3px var(--ruby-muted); }
.an-dot.off { background: var(--gray-400); }
.an-badge { display: inline-block; min-width: 22px; padding: 1px 8px; border-radius: 999px; background: var(--ruby); color: var(--white);
  font-weight: 800; font-size: 12.5px; text-align: center; }
.lab-subnav a .an-badge { margin-left: 6px; }
.lab-subnav a.on .an-badge { background: var(--white); color: var(--ruby-dark); }
.an-raw { background: var(--sand); border: 1px solid var(--border-strong); border-radius: 8px; padding: 10px 12px; max-height: 340px; overflow: auto;
  font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.an-small { font-size: 12.5px; }
.an-reason { font-weight: 700; color: var(--ink); }
.an-reason.bad { color: var(--ruby-dark); }
.an-reason-cell { min-width: 240px; max-width: 380px; overflow-wrap: anywhere; }
.an-sample { max-width: 260px; overflow-wrap: anywhere; }
.an-links { display: flex; gap: 10px; flex-wrap: wrap; font-family: var(--font-primary); }
.an-links a { font-weight: 700; color: var(--dept-deep); }
.an-kv { margin: 10px 0; }
.an-panel { border-left: 4px solid var(--dept-deep); margin-bottom: 12px; }
.an-confirm { margin-top: 10px; padding: 10px 12px; border: 1.5px solid var(--ruby); border-radius: 8px; background: var(--ruby-muted); }
.an-filters { gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 10px; }
.an-pager { gap: 10px; margin-top: 10px; align-items: center; flex-wrap: wrap; }
.an-form { gap: 10px 16px; }
