/* ==========================================================================
   Alert threshold configuration.

   Loaded after bands.css, which defines .bd-unreviewed — the notice at the top
   of this screen reuses it, because it is the same statement the chart and the
   queue make about the same thing, and two different-looking notices saying
   "nobody has signed these" would read as two different problems.

   Only existing tokens. --warn is the amber already used for "due", --stop the
   red used for "denied", --go the green for "eligible now".
   ========================================================================== */

/* ---- whose ranges: the scope picker ------------------------------------- */

.th-scopes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
}

.th-scope {
  display: flex; flex-direction: column; gap: 3px;
  text-align: left; cursor: pointer;
  padding: 11px 13px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--line);
  border-radius: var(--radius-sm);
  font: inherit; color: inherit;
}
.th-scope:hover { border-color: var(--accent); }
.th-scope.is-active {
  border-left-color: var(--accent);
  background: var(--accent-soft);
}
/* A set still in force under somebody who is no longer a provider. The row
   exists so it can be found and removed, so it has to look like a finding. */
.th-scope.is-stale { border-left-color: var(--warn); }

.th-scope-name { font-weight: 650; display: flex; align-items: center; gap: 6px; }
.th-scope-meta { font-size: 12.5px; color: var(--muted); }
.th-scope-detail { font-size: 12px; color: var(--muted); line-height: 1.45; }
.th-unsigned { color: var(--warn); font-weight: 600; }

/* ---- the notice and the legend ----------------------------------------- */

.th-notice { margin-bottom: 14px; }

.th-legend {
  font-size: 12.5px; line-height: 1.55; color: var(--ink-soft);
  background: var(--surface); border-radius: var(--radius-sm);
  padding: 9px 12px; margin: 0 0 14px;
}

/* ---- one metric -------------------------------------------------------- */

.th-rows { display: flex; flex-direction: column; gap: 12px; }

.th-row {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 13px 15px;
}

.th-row-head {
  display: flex; justify-content: space-between; align-items: baseline;
  flex-wrap: wrap; gap: 6px 14px; margin-bottom: 11px;
}
.th-metric { font-weight: 650; margin-right: 7px; }
.th-unit { font-size: 12.5px; color: var(--muted); margin-right: 8px; }
.th-row-state { font-size: 12.5px; color: var(--muted); }

/* The four boxes, in the order a value passes through them: critical low,
   warning low, warning high, critical high. The two low boxes carry an amber
   and red tint on the label so the pairing is visible without reading. */
.th-boxes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 10px;
}
.th-box { display: flex; flex-direction: column; gap: 4px; }
.th-box-label { font-size: 11.5px; color: var(--muted); font-weight: 600; }
/* styles.css already gives every input its border, radius, white background,
   padding and focus ring. Only the differences belong here -- restating the
   focus style would mean this screen's inputs focused differently from every
   other form in the app. */
.th-box input {
  padding: 7px 9px;
  font-variant-numeric: tabular-nums;
}
.th-box input:disabled { background: var(--surface); color: var(--muted); }
/* The placeholder is the inherited value, not an example. Lighter than a real
   entry so the two are never confused -- "90" typed and "90" inherited mean
   different things to the save button. */
.th-box input::placeholder { color: var(--muted); opacity: 0.65; font-style: italic; }

.th-box:nth-child(1) .th-box-label,
.th-box:nth-child(4) .th-box-label { color: var(--stop); }
.th-box:nth-child(2) .th-box-label,
.th-box:nth-child(3) .th-box-label { color: var(--warn); }

/* A metric SmartCare ships no bands for. Above the boxes, not below them:
   the point is to be read before somebody fills them in. */
.th-nobands {
  font-size: 12.5px; line-height: 1.55; color: var(--ink-soft);
  background: var(--warn-soft);
  border-radius: var(--radius-sm);
  padding: 9px 12px; margin: 0 0 11px;
}

.th-row-foot {
  display: flex; justify-content: space-between; align-items: flex-end;
  flex-wrap: wrap; gap: 10px; margin-top: 11px;
}
/* Where the shipped number came from. Small, but it is the difference between
   a range somebody chose and a range somebody accepted. */
.th-source {
  font-size: 11.5px; color: var(--muted); line-height: 1.5;
  max-width: 56ch;
}
.th-actions { display: flex; gap: 7px; flex: 0 0 auto; }

/* Tiers that can never fire. Not errors — SpO2 has no high side by design —
   so amber text rather than the error style. */
.th-gaps { font-size: 12px; color: var(--warn); line-height: 1.6; margin-top: 7px; }
.th-gaps:empty { display: none; }

.th-sign { font-size: 12px; color: var(--go); margin-top: 7px; }
.th-sign:empty { display: none; }

.th-err[hidden] { display: none; }
.th-err { margin-top: 9px; }

/* ---- the dialogs ------------------------------------------------------- */

.th-modal p { line-height: 1.6; margin: 0 0 11px; }
.th-modal .field { margin-top: 13px; }

/* Old value against new, so the person approving sees what changes rather
   than only what it becomes. */
.th-diff {
  width: 100%; border-collapse: collapse; margin: 0 0 13px;
  font-size: 13px;
}
.th-diff th {
  text-align: left; font-weight: 600; color: var(--muted);
  padding: 5px 12px 5px 0; white-space: nowrap;
  vertical-align: top; width: 1%;
}
.th-diff td {
  padding: 5px 0; font-variant-numeric: tabular-nums;
}
.th-diff tr + tr th, .th-diff tr + tr td { border-top: 1px solid var(--line); }

.th-warn {
  background: var(--warn-soft); color: var(--ink-soft);
  border-radius: var(--radius-sm); padding: 9px 12px;
  font-size: 12.5px;
}

/* ==========================================================================
   The patient page's card (thresholds_patient.js)
   ========================================================================== */

.thp-notice { margin-bottom: 14px; }

/* styles.css pads cells 18px horizontally, for a table that spans a card with
   no padding of its own. This one sits inside .card-pad, so it would be
   padded twice. Same correction devices.css makes for .dv-table. */
.thp-table { font-size: 13.5px; width: 100%; }
.thp-table thead th { padding: 8px 10px 8px 0; white-space: nowrap; }
.thp-table tbody td { padding: 10px 10px 10px 0; vertical-align: top; }
.thp-table thead th:last-child,
.thp-table tbody td:last-child { padding-right: 0; text-align: right; }

/* A range set for this patient specifically — the thing this card exists to
   show. It is the one row on the screen that is nobody's default. */
.thp-table tr.thp-own td:first-child {
  box-shadow: inset 3px 0 0 var(--accent);
  padding-left: 10px;
}

.thp-range { font-variant-numeric: tabular-nums; color: var(--ink-soft); }
.thp-unrev { color: var(--warn); }
.thp-act { white-space: nowrap; }
.thp-foot { margin: 13px 0 0; line-height: 1.6; }

/* In the editor: that this is part of an order, not a display preference. */
.thp-order {
  font-size: 12.5px; line-height: 1.55; color: var(--ink-soft);
  background: var(--accent-soft); border-radius: var(--radius-sm);
  padding: 9px 12px; margin: 14px 0 0;
}

@media (max-width: 760px) {
  /* "From" is the first thing to go: the pill repeats what the row's accent
     rule already says for a patient range, and the rest is detail. */
  .thp-table thead th:nth-child(3),
  .thp-table tbody td:nth-child(3) { display: none; }
}
