/* ---------------------------------------------------------------------------
   Patient Inferences panel.

   Every selector is prefixed .infr- — the app already uses .inf- and
   .inferences- for the MARTAR scrub screen, so a shared prefix would have
   collided. Nothing here restyles an existing class; deleting this file
   removes the panel's appearance and nothing else.

   The panel sits above the record modal (z=200) and the Attributes modal
   (z=220). Two tabs: a dense per-treatment list, and the per-patient evidence
   behind it. The supply colours carry the finding, so they hold their pastel
   fill in both themes and only their ink is nudged.
   --------------------------------------------------------------------------- */

.infr-open-btn { margin-left: 6px; }

.infr-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: none;
  align-items: stretch;
  justify-content: center;
  z-index: 240;
  padding: 32px 20px;
}
.infr-backdrop.active { display: flex; }
.infr-frame {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}
.infr-header {
  padding: 12px 18px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.infr-header h3 { margin: 0; font-size: calc(13.5px * var(--ui-font-scale, 1)); font-weight: 700; color: #1e293b; }
.infr-header .meta { font-size: calc(11px * var(--ui-font-scale, 1)); color: #6b7280; margin-top: 2px; }

/* --- tab strip -------------------------------------------------------- */
.infr-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 14px 0;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  flex-wrap: wrap;
}
.infr-tab {
  border: 1px solid transparent;
  border-bottom: none;
  background: transparent;
  padding: 7px 14px;
  border-radius: 7px 7px 0 0;
  font-size: calc(11.5px * var(--ui-font-scale, 1));
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.infr-tab:hover { background: #eef2f7; color: #1e293b; }
.infr-tab.is-active {
  background: #fff;
  border-color: #e2e8f0;
  color: #1e293b;
  margin-bottom: -1px;
  padding-bottom: 8px;
}
.infr-tab-n {
  font-size: calc(10px * var(--ui-font-scale, 1));
  font-weight: 700;
  background: #e2e8f0;
  color: #334155;
  border-radius: 9px;
  padding: 0 6px;
  min-width: 18px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.infr-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 18px 20px;
  background: #fff;
  color: #1e293b;
  font-size: calc(12px * var(--ui-font-scale, 1));
}

/* --- headline stats --------------------------------------------------- */
.infr-headline {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.infr-stat {
  border: 1px solid #e2e8f0;
  border-radius: 9px;
  padding: 8px 12px;
  background: #f8fafc;
}
.infr-stat-n {
  font-size: calc(17.5px * var(--ui-font-scale, 1));
  font-weight: 800;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.infr-stat-l {
  font-size: calc(9.5px * var(--ui-font-scale, 1));
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 700;
  color: #6b7280;
  margin-top: 2px;
}
/* One tone scale, used by the stat tiles and the row verdict pills alike, so
   "bad" looks the same wherever it appears. */
.infr-tone-ok    { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.infr-tone-warn  { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.infr-tone-bad   { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.infr-tone-info  { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.infr-tone-plain { background: #f8fafc; border-color: #e2e8f0; color: #475569; }
.infr-stat.infr-tone-ok    .infr-stat-n { color: #166534; }
.infr-stat.infr-tone-warn  .infr-stat-n { color: #92400e; }
.infr-stat.infr-tone-bad   .infr-stat-n { color: #991b1b; }
.infr-stat.infr-tone-info  .infr-stat-n { color: #1e40af; }

/* --- prose ------------------------------------------------------------ */
.infr-lede {
  margin: 0 0 12px;
  font-size: calc(11px * var(--ui-font-scale, 1));
  line-height: 1.6;
  color: #475569;
  border-left: 3px solid #cbd5e1;
  padding-left: 10px;
}
.infr-h {
  margin: 16px 0 8px;
  font-size: calc(11px * var(--ui-font-scale, 1));
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #c2410c;
  border-bottom: 1px solid #fed7aa;
  padding-bottom: 4px;
}
.infr-sub { font-size: calc(11px * var(--ui-font-scale, 1)); color: #64748b; margin: 4px 0; line-height: 1.5; }
.infr-why { font-size: calc(10.5px * var(--ui-font-scale, 1)); color: #94a3b8; }
.infr-warn-text { color: #92400e; }
.infr-none, .infr-empty { font-size: calc(11px * var(--ui-font-scale, 1)); color: #94a3b8; padding: 6px 0; }
.infr-loading, .infr-error {
  padding: 26px 10px; text-align: center; font-size: calc(12px * var(--ui-font-scale, 1)); color: #64748b;
}
.infr-error { color: #991b1b; }
.infr-advisory {
  margin: 18px 0 0;
  padding-top: 10px;
  border-top: 1px dashed #e2e8f0;
  font-size: calc(11px * var(--ui-font-scale, 1));
  color: #94a3b8;
  font-style: italic;
}
.infr-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: calc(11px * var(--ui-font-scale, 1)); }

/* --- filter chips ----------------------------------------------------- */
.infr-chiprow { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.infr-chip-btn {
  border: 1px solid #e2e8f0;
  background: #fff;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: calc(11px * var(--ui-font-scale, 1));
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.infr-chip-btn:hover { background: #f1f5f9; }
.infr-chip-btn.is-active { background: #1e293b; border-color: #1e293b; color: #fff; }
.infr-chip-btn.is-active .infr-tab-n { background: #475569; color: #fff; }

/* --- record rows ------------------------------------------------------ */
.infr-row {
  border: 1px solid #e2e8f0;
  border-radius: 9px;
  padding: 9px 11px;
  margin-bottom: 8px;
  background: #fff;
}
.infr-row-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 6px;
}
.infr-row-name {
  font-weight: 700;
  font-size: calc(11.5px * var(--ui-font-scale, 1));
  color: #1e293b;
  overflow-wrap: anywhere;
}
.infr-row-tags {
  display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end;
}
.infr-tag {
  font-size: calc(9.5px * var(--ui-font-scale, 1)); font-weight: 700; background: #f1f5f9; color: #475569;
  border-radius: 4px; padding: 2px 6px; white-space: nowrap;
}
.infr-tag-time { background: #f0faf4; color: #0f3d26; }
.infr-tag-merge { background: #f5f3ff; color: #5b21b6; }
/* The sheet filed one order under two categories — shown, not silently picked. */
.infr-tag.is-split { background: #fef3c7; color: #92400e; }

/* An order whose shifts disagree keeps a visible edge — the disagreement is
   the reason the merge is safe to do at all. */
.infr-row.has-diff { border-left: 3px solid #fcd34d; }
.infr-diff-note { display: block; font-size: calc(10.5px * var(--ui-font-scale, 1)); color: #92400e; margin-bottom: 4px; }
.infr-shift-diff { list-style: none; margin: 0; padding: 0; }
.infr-shift-diff li {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  padding: 3px 0;
  border-bottom: 1px dashed #f1f5f9;
}
.infr-verdict {
  font-size: calc(9.5px * var(--ui-font-scale, 1));
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 2px 7px;
  white-space: nowrap;
}

/* label / value lines inside a row */
.infr-row-line {
  display: grid;
  grid-template-columns: 74px 1fr;
  gap: 8px;
  align-items: baseline;
  padding: 3px 0;
  font-size: calc(11px * var(--ui-font-scale, 1));
}
.infr-row-label {
  font-size: calc(9.5px * var(--ui-font-scale, 1));
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 700;
  color: #94a3b8;
}
.infr-row-val { color: #475569; }
@media (max-width: 640px) {
  .infr-row-line { grid-template-columns: 1fr; }
  .infr-two-col { grid-template-columns: 1fr; }
}

/* --- supply chips ----------------------------------------------------- */
.infr-sup-row { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.infr-sup {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  max-width: 260px;
  border: 1px solid #e2e8f0;
  border-left-width: 3px;
  border-radius: 5px;
  padding: 2px 7px;
  font-size: calc(10.5px * var(--ui-font-scale, 1));
  cursor: default;
}
.infr-sup-code {
  font-family: ui-monospace, Menlo, monospace;
  font-size: calc(9.5px * var(--ui-font-scale, 1));
  font-weight: 700;
  white-space: nowrap;
}
.infr-sup-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.infr-sup-weak { font-weight: 800; opacity: 0.75; }
.infr-sup.is-weak { border-left-style: dashed; }

/* Colour semantics — the whole point of the reconcile view. */
.infr-c-red   { border-left-color: #ef4444; background: #fef2f2; color: #991b1b; }
.infr-c-green { border-left-color: #22c55e; background: #f0fdf4; color: #166534; }
.infr-c-blue  { border-left-color: #3b82f6; background: #eff6ff; color: #1e40af; }
.infr-c-grey  { border-left-color: #cbd5e1; background: #f8fafc; color: #475569; }
.infr-key {
  display: inline-block;
  border-left: 3px solid;
  border-radius: 4px;
  padding: 0 6px;
  font-size: calc(10px * var(--ui-font-scale, 1));
  font-weight: 700;
}

.infr-mode, .infr-dropped {
  font-size: calc(9.5px * var(--ui-font-scale, 1));
  font-weight: 700;
  border-radius: 3px;
  padding: 1px 6px;
  white-space: nowrap;
}
.infr-mode-weak { background: #fef3c7; color: #92400e; text-transform: uppercase; }
.infr-dropped   { background: #f1f5f9; color: #94a3b8; }
.infr-more { display: inline; }
.infr-more > summary {
  display: inline-block;
  cursor: pointer;
  font-size: calc(10px * var(--ui-font-scale, 1));
  font-weight: 700;
  color: #475569;
  background: #f1f5f9;
  border-radius: 4px;
  padding: 2px 7px;
  list-style: none;
}
.infr-more > summary::-webkit-details-marker { display: none; }
.infr-more[open] > summary { background: #e2e8f0; }
.infr-more[open] .infr-sup-row { margin-top: 4px; }

.infr-kw {
  font-size: calc(10px * var(--ui-font-scale, 1));
  background: #f1f5f9;
  color: #334155;
  border-radius: 4px;
  padding: 1px 6px;
  margin-right: 3px;
}
.infr-kw.is-missed { background: #fef3c7; color: #92400e; font-weight: 700; }

/* --- patient tab ------------------------------------------------------ */
.infr-two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.infr-daybar { display: flex; gap: 26px; }
.infr-big {
  font-size: calc(23.5px * var(--ui-font-scale, 1));
  font-weight: 800;
  line-height: 1.1;
  color: #1e293b;
  font-variant-numeric: tabular-nums;
}
.infr-census-row { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.infr-census-code {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: calc(10.5px * var(--ui-font-scale, 1));
  font-weight: 700;
  color: #94a3b8;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 2px 6px;
}
.infr-census-code.is-active { color: #166534; border-color: #bbf7d0; background: #f0fdf4; }

.infr-checks { list-style: none; margin: 0; padding: 0; }
.infr-checks li {
  display: grid;
  grid-template-columns: 16px 1fr;
  gap: 6px;
  align-items: baseline;
  padding: 4px 0;
  border-bottom: 1px solid #f1f5f9;
  font-size: calc(11px * var(--ui-font-scale, 1));
}
.infr-check-mark { font-weight: 800; }
.infr-checks li.is-ok  .infr-check-mark { color: #16a34a; }
.infr-checks li.is-bad .infr-check-mark { color: #dc2626; }
.infr-check-label { font-weight: 600; display: block; }
.infr-check-detail { grid-column: 2; color: #64748b; font-size: calc(10.5px * var(--ui-font-scale, 1)); }

/* --- funnel ----------------------------------------------------------- */
.infr-funnel {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 8px;
}
.infr-funnel-step {
  border: 1px solid #e2e8f0;
  border-radius: 7px;
  padding: 5px 10px;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  min-width: 88px;
}
.infr-funnel-step.is-furthest { border-color: #86efac; background: #f0fdf4; }
.infr-funnel-sheet { font-size: calc(11px * var(--ui-font-scale, 1)); font-weight: 700; }
.infr-funnel-n { font-size: calc(10px * var(--ui-font-scale, 1)); color: #64748b; }
.infr-funnel-billed { font-size: calc(9.5px * var(--ui-font-scale, 1)); font-weight: 700; color: #1e40af; }
.infr-funnel-arrow { color: #cbd5e1; font-weight: 700; }

/* --- tables ----------------------------------------------------------- */
.infr-table {
  width: 100%;
  border-collapse: collapse;
  font-size: calc(11px * var(--ui-font-scale, 1));
  margin: 4px 0 10px;
  display: block;
  overflow-x: auto;
}
.infr-table th {
  text-align: left;
  font-size: calc(9.5px * var(--ui-font-scale, 1));
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6b7280;
  border-bottom: 1px solid #e2e8f0;
  padding: 5px 8px;
  white-space: nowrap;
}
.infr-table td {
  padding: 5px 8px; border-bottom: 1px solid #f1f5f9; vertical-align: top;
}

/* --- forms & lists ---------------------------------------------------- */
.infr-add-supply, .infr-signoff {
  display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 4px;
}
.infr-add-supply input, .infr-signoff input {
  flex: 1 1 160px;
  min-width: 120px;
  padding: 6px 9px;
  border: 1px solid #d6dadf;
  border-radius: 6px;
  font-size: calc(11px * var(--ui-font-scale, 1));
  background: #fff;
  color: #1e293b;
}
.infr-blue-list, .infr-signoff-list {
  list-style: none; margin: 0; padding: 0; font-size: calc(11px * var(--ui-font-scale, 1));
}
.infr-blue-list li, .infr-signoff-list li {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  padding: 5px 0; border-bottom: 1px solid #f1f5f9;
}
.infr-mini {
  font-size: calc(10px * var(--ui-font-scale, 1));
  font-weight: 700;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #334155;
  border-radius: 5px;
  padding: 2px 7px;
  cursor: pointer;
}
.infr-mini:hover { background: #f1f5f9; }
.infr-mini-danger { color: #991b1b; border-color: #fecaca; }

/* --- dark theme -------------------------------------------------------
   The app's switch stamps data-theme on the root and must win over the OS
   preference in both directions, so each rule is written twice — the same
   convention the rest of the app's stylesheets use. The colour-carrying
   classes keep their pastel fills: the colour *is* the finding. */
@media (prefers-color-scheme: dark) {
  .infr-frame, .infr-body, .infr-row { background: #0f172a; }
  .infr-header, .infr-tabs { background: #111c33; border-bottom-color: #1e293b; }
  .infr-header h3, .infr-body, .infr-row-name, .infr-big { color: #e2e8f0; }
  .infr-tab.is-active { background: #0f172a; border-color: #1e293b; color: #e2e8f0; }
  .infr-row, .infr-stat, .infr-funnel-step, .infr-census-code { border-color: #1e293b; }
  .infr-stat, .infr-funnel-step { background: #111c33; }
  .infr-chip-btn, .infr-add-supply input, .infr-signoff input, .infr-mini,
  .infr-more > summary { background: #0b1425; color: #e2e8f0; border-color: #334155; }
  .infr-c-red, .infr-c-green, .infr-c-blue, .infr-c-grey,
  .infr-verdict, .infr-stat.infr-tone-ok, .infr-stat.infr-tone-warn,
  .infr-stat.infr-tone-bad, .infr-stat.infr-tone-info,
  .infr-census-code.is-active { color: #0f172a; }
}
[data-theme="dark"] .infr-frame,
[data-theme="dark"] .infr-body,
[data-theme="dark"] .infr-row { background: #0f172a; }
[data-theme="dark"] .infr-header,
[data-theme="dark"] .infr-tabs { background: #111c33; border-bottom-color: #1e293b; }
[data-theme="dark"] .infr-header h3,
[data-theme="dark"] .infr-body,
[data-theme="dark"] .infr-row-name,
[data-theme="dark"] .infr-big { color: #e2e8f0; }
[data-theme="dark"] .infr-tab.is-active {
  background: #0f172a; border-color: #1e293b; color: #e2e8f0;
}
[data-theme="dark"] .infr-row,
[data-theme="dark"] .infr-stat,
[data-theme="dark"] .infr-funnel-step,
[data-theme="dark"] .infr-census-code { border-color: #1e293b; }
[data-theme="dark"] .infr-stat,
[data-theme="dark"] .infr-funnel-step { background: #111c33; }
[data-theme="dark"] .infr-chip-btn,
[data-theme="dark"] .infr-add-supply input,
[data-theme="dark"] .infr-signoff input,
[data-theme="dark"] .infr-mini,
[data-theme="dark"] .infr-more > summary {
  background: #0b1425; color: #e2e8f0; border-color: #334155;
}
[data-theme="dark"] .infr-c-red,
[data-theme="dark"] .infr-c-green,
[data-theme="dark"] .infr-c-blue,
[data-theme="dark"] .infr-c-grey,
[data-theme="dark"] .infr-verdict,
[data-theme="dark"] .infr-stat.infr-tone-ok,
[data-theme="dark"] .infr-stat.infr-tone-warn,
[data-theme="dark"] .infr-stat.infr-tone-bad,
[data-theme="dark"] .infr-stat.infr-tone-info,
[data-theme="dark"] .infr-census-code.is-active { color: #0f172a; }
[data-theme="light"] .infr-frame,
[data-theme="light"] .infr-body { background: #fff; color: #1e293b; }
[data-theme="light"] .infr-header,
[data-theme="light"] .infr-tabs { background: #f8fafc; }
