/* 30-day medical bay view. Reads palette variables from the console's :root.
   Colour rule: green / amber / red mean status and nothing else. Chart ink is
   neutral; cyan marks things you can click. */

.mb {
  --ok: #10b981;
  --watch: #f59e0b;
  --alert: #ef4444;
  --nodata: #64748b;
  --ink: #e2e8f0;
  --ink-2: #94a3b8;
  --ink-3: #64748b;
  --line: #222f47;
  --surface: #121826;
  --surface-2: #182234;
  --accent: #38bdf8;

  flex: 1;
  grid-template-columns: 340px minmax(0, 1fr) 320px;
  grid-template-areas: "strip strip strip" "body main checkin";
  gap: 16px;
  padding: 16px 20px 24px;
  align-items: start;
  align-content: start; /* on tall screens, keep rows at content height instead of stretching the strip row */
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
  user-select: text;
}
@media (max-width: 1480px) {
  .mb {
    grid-template-columns: 340px minmax(0, 1fr);
    grid-template-rows: auto auto 1fr;
    grid-template-areas: "strip strip" "body main" "checkin main";
  }
}
@media (max-width: 1000px) {
  .mb {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    grid-template-areas: "strip" "main" "checkin" "body";
  }
}

/* Day strip: pinned under the console header so the control never moves while content below reflows */
.mb-strip {
  grid-area: strip;
  position: sticky;
  top: 52px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  box-shadow: 0 6px 16px rgba(11, 15, 25, 0.9);
}
.mb-strip-label { flex: none; width: 196px; text-align: center; font-size: 13px; white-space: nowrap; }
.mb-days { flex: 1; display: grid; grid-template-columns: repeat(30, minmax(0, 1fr)); gap: 2px; min-width: 0; }
.mb-day {
  height: 26px;
  border: 0;
  border-radius: 3px;
  background: rgba(100, 116, 139, 0.22);
  color: var(--ink-2);
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 0;
  cursor: pointer;
  overflow: hidden;
}
.mb-day.s-green { background: rgba(16, 185, 129, 0.28); }
.mb-day.s-amber { background: rgba(245, 158, 11, 0.45); color: var(--ink); }
.mb-day.s-red { background: rgba(239, 68, 68, 0.5); color: var(--ink); }
.mb-day.is-edited { text-decoration: underline; }
.mb-day:hover, .mb-day:focus-visible { outline: 1px solid var(--accent); outline-offset: 0; }
.mb-day.is-selected { outline: 2px solid #fff; outline-offset: 0; color: #fff; font-weight: 700; }
@media (max-width: 760px) {
  .mb-strip { flex-wrap: wrap; }
  .mb-days { order: 5; flex-basis: 100%; }
}

.mb-area-body { grid-area: body; }
.mb-area-checkin { grid-area: checkin; }
.mb-main { grid-area: main; display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.mb-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}
.mb-h-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.mb-h {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.mb-num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.mb-muted { color: var(--ink-2); }
.mb-small { font-size: 12px; }

/* Status vocabulary: always a dot plus a word, never colour alone */
.mb-status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.mb-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--nodata); flex: none; }
.mb-status.s-green > .mb-dot, .mb-axis.s-green .mb-dot, .mb-dot.s-green { background: var(--ok); }
.mb-status.s-amber > .mb-dot, .mb-axis.s-amber .mb-dot, .mb-dot.s-amber { background: var(--watch); }
.mb-status.s-red > .mb-dot, .mb-axis.s-red .mb-dot, .mb-dot.s-red { background: var(--alert); }
.s-green.mb-status { color: #6ee7b7; }
.s-amber.mb-status { color: #fcd34d; }
.s-red.mb-status { color: #fca5a5; }
.s-unknown.mb-status { color: var(--ink-2); }

/* ---- Verdict ---------------------------------------------------------- */
.mb-verdict { border-left: 4px solid var(--nodata); padding: 20px; }
.mb-verdict.s-green { border-left-color: var(--ok); }
.mb-verdict.s-amber { border-left-color: var(--watch); }
.mb-verdict.s-red { border-left-color: var(--alert); }
.mb-verdict-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.mb-headline {
  font-family: var(--font-header);
  font-size: 26px;
  line-height: 1.2;
  font-weight: 600;
  color: var(--text-white);
  margin: 10px 0 4px;
  text-wrap: balance;
}
.mb-actions { list-style: none; margin: 16px 0 0; display: grid; gap: 8px; counter-reset: act; }
.mb-actions li {
  counter-increment: act;
  display: grid;
  grid-template-columns: 26px 1fr auto;
  gap: 10px;
  align-items: start;
  background: var(--surface-2);
  border-radius: 6px;
  padding: 10px 12px;
}
.mb-actions li::before {
  content: counter(act);
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: 50%;
  width: 24px; height: 24px;
  display: grid; place-items: center;
  font-size: 12px;
}
.mb-who {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  white-space: nowrap;
}
.mb-findings { margin-top: 16px; display: grid; gap: 6px; }
.mb-finding { border-top: 1px solid var(--line); }
.mb-finding summary {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0 8px;
  cursor: pointer;
  list-style: none;
  font-weight: 500;
}
.mb-finding summary::-webkit-details-marker { display: none; }
.mb-finding summary::after { content: 'Why'; margin-left: auto; font-size: 12px; color: var(--accent); }
.mb-finding[open] summary::after { content: 'Hide'; }
.mb-finding-body { padding: 0 0 12px 19px; display: grid; gap: 8px; color: var(--ink-2); font-size: 13px; }
.mb-finding-body ol { padding-left: 18px; color: var(--ink); display: grid; gap: 4px; }
.mb-source { border-left: 2px solid var(--line); padding-left: 10px; }
.mb-source a, .mb-link { color: var(--accent); text-decoration: none; }
.mb-source a:hover, .mb-link:hover { text-decoration: underline; }
.mb-refusal { border-left: 2px solid var(--watch); padding-left: 10px; color: var(--ink); }

/* ---- Axis strip ------------------------------------------------------- */
/* Always one row of seven; only phone widths wrap, to a 4 + 3 grid */
.mb-axes { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 700px) { .mb-axes { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.mb-axis {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  text-align: left;
  color: inherit;
  font: inherit;
  cursor: pointer;
  min-width: 0;
}
.mb-axis:hover, .mb-axis:focus-visible { border-color: var(--accent); outline: none; }
.mb-axis-label { font-size: 12px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mb-axis-score { font-size: 22px; font-weight: 600; color: var(--text-white); line-height: 1.2; display: flex; align-items: center; gap: 8px; }
.mb-axis-bar { height: 4px; border-radius: 2px; background: var(--surface-2); margin: 10px 0; overflow: hidden; }
.mb-axis-bar i { display: block; height: 100%; border-radius: 2px; background: var(--nodata); }
.s-green .mb-axis-bar i { background: var(--ok); }
.s-amber .mb-axis-bar i { background: var(--watch); }
.s-red .mb-axis-bar i { background: var(--alert); }
.mb-axis-note { font-size: 13px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- Body figure ------------------------------------------------------ */
.mb-body { display: grid; grid-template-columns: 112px 1fr; gap: 14px; align-items: center; }
.mb-figure svg { width: 100%; height: auto; display: block; }
.mb-organ { cursor: pointer; outline: none; }
.mb-figure .shape { vector-effect: non-scaling-stroke; }
.mb-backing .shape { fill: var(--surface); stroke: none; }
/* Regions cut from the silhouette have no outline of their own; selection deepens the fill instead. */
.mb-figure .mb-clipped .mb-organ .shape, .mb-figure .mb-clipped .mb-organ.is-selected .shape { stroke: none; }
.mb-clipped .mb-organ:hover .shape, .mb-clipped .mb-organ.is-selected .shape { fill: rgba(148, 163, 184, 0.4); }
.mb-clipped .mb-organ.s-green:hover .shape, .mb-clipped .mb-organ.s-green.is-selected .shape { fill: rgba(16, 185, 129, 0.42); }
.mb-clipped .mb-organ.s-amber:hover .shape, .mb-clipped .mb-organ.s-amber.is-selected .shape { fill: rgba(245, 158, 11, 0.55); }
.mb-clipped .mb-organ.s-red:hover .shape, .mb-clipped .mb-organ.s-red.is-selected .shape { fill: rgba(239, 68, 68, 0.6); }
.mb-organ .shape { fill: rgba(100, 116, 139, 0.18); stroke: var(--nodata); stroke-width: 1.5; transition: fill 0.15s, stroke-width 0.15s; }
.mb-organ.s-green .shape { fill: rgba(16, 185, 129, 0.16); stroke: var(--ok); }
.mb-organ.s-amber .shape { fill: rgba(245, 158, 11, 0.28); stroke: var(--watch); }
.mb-organ.s-red .shape { fill: rgba(239, 68, 68, 0.34); stroke: var(--alert); }
.mb-organ:hover .shape, .mb-organ:focus-visible .shape { stroke-width: 2.5; }
.mb-organ.is-selected .shape { stroke-width: 3; stroke: #fff; }
.mb-regions { list-style: none; display: grid; gap: 2px; }
.mb-region-btn {
  width: 100%;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: none; border: 1px solid transparent; border-radius: 6px;
  padding: 6px 8px;
  color: var(--ink); font: inherit; font-size: 13px; text-align: left;
  cursor: pointer;
}
.mb-region-btn:hover, .mb-region-btn:focus-visible { background: var(--surface-2); outline: none; }
.mb-region-btn.is-selected { background: var(--surface-2); border-color: var(--line); }
.mb-detail { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); display: grid; gap: 8px; }
.mb-detail h3 { font-size: 15px; font-weight: 600; display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.mb-metric { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 6px 0; border-top: 1px dashed var(--line); }
.mb-metric-help { grid-column: 1 / -1; font-size: 12px; color: var(--ink-2); }

/* ---- Check-in form ---------------------------------------------------- */
.mb-badge { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink-2); white-space: nowrap; }
.mb-badge.is-yours { color: var(--accent); border-color: rgba(56, 189, 248, 0.5); }
.mb-badge.is-due { color: #fcd34d; border-color: rgba(245, 158, 11, 0.5); }
.mb-quote { font-size: 13px; color: var(--ink-2); font-style: italic; margin-bottom: 12px; }
.mb-form { display: grid; gap: 14px; }
.mb-field { display: grid; gap: 6px; border: 0; min-width: 0; }
.mb-field > label, .mb-field > legend { font-size: 13px; font-weight: 500; color: var(--ink); padding: 0; }
.mb-field .hint { font-weight: 400; color: var(--ink-2); font-size: 12px; }
.mb-input {
  background: #0b0f19;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text-white);
  font: inherit;
  font-family: var(--font-mono);
  padding: 7px 10px;
  width: 100%;
  min-width: 0;
}
.mb-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.mb-inline { display: flex; align-items: center; gap: 8px; }
.mb-inline .mb-input { width: 96px; }
.mb-seg { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.mb-seg label, .mb-chips label { position: relative; cursor: pointer; }
.mb-seg input, .mb-chips input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.mb-seg span, .mb-chips span {
  display: block; text-align: center;
  border: 1px solid var(--line); border-radius: 6px;
  padding: 6px 0;
  font-family: var(--font-mono); font-size: 13px; color: var(--ink-2);
  background: #0b0f19;
}
.mb-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.mb-chips span { padding: 5px 10px; font-family: var(--font-sans); border-radius: 999px; }
.mb-seg input:checked + span, .mb-chips input:checked + span { background: rgba(56, 189, 248, 0.16); border-color: var(--accent); color: var(--text-white); }
.mb-seg input:focus-visible + span, .mb-chips input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
.mb-seg-ends { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-3); }
.mb-manual summary { cursor: pointer; color: var(--accent); font-size: 13px; }
.mb-manual-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; margin-top: 10px; }
.mb-manual-grid label { font-size: 12px; color: var(--ink-2); display: grid; gap: 4px; }
.mb-notes { font-family: var(--font-sans); resize: vertical; min-height: 64px; line-height: 1.4; }
.mb-form-foot { display: flex; align-items: center; justify-content: flex-end; gap: 10px; font-size: 12px; color: var(--ink-2); }
.mb-btn {
  background: none; border: 1px solid var(--line); border-radius: 6px;
  color: var(--ink); font: inherit; font-size: 12px; padding: 5px 10px; cursor: pointer;
}
.mb-btn:hover:not(:disabled), .mb-btn:focus-visible { border-color: var(--accent); outline: none; }
.mb-btn:disabled { opacity: 0.4; cursor: default; }

/* ---- Chart ------------------------------------------------------------ */
.mb-chart { position: relative; }
.mb-chart svg { display: block; width: 100%; cursor: pointer; }
.mb-chart text { font-family: var(--font-sans); font-size: 11px; fill: var(--ink-2); }
.mb-chart .t-title { font-size: 12px; fill: var(--ink); font-weight: 500; }
.mb-chart .t-val { font-family: var(--font-mono); font-size: 12px; fill: var(--ink); }
.mb-tip {
  position: absolute; top: 0; left: 0;
  pointer-events: none;
  background: #0b0f19; border: 1px solid var(--line); border-radius: 6px;
  padding: 8px 10px; font-size: 12px; min-width: 170px; max-width: 300px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  display: none; z-index: 5;
}
.mb-tip-note { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); color: var(--ink); font-style: italic; line-height: 1.4; }
.mb-tip b { display: block; margin-bottom: 4px; color: var(--text-white); }
.mb-tip div { display: flex; justify-content: space-between; gap: 14px; color: var(--ink-2); }
.mb-tip div span:last-child { color: var(--ink); font-family: var(--font-mono); }
.mb-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--ink-2); }
.mb-trends-head { flex-wrap: wrap; justify-content: flex-start; gap: 6px 20px; }
.mb-trends-head #mb-streak { margin-left: auto; white-space: nowrap; }
.mb-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.mb-disclaimer { font-size: 12px; color: var(--ink-3); }
