/* Quill Health — review console.
   Layers on top of landing.css (loaded first) for shared tokens, buttons,
   cards and the verdict palette. This file adds the console shell: topbar,
   control strip, the two-column work grid, and the verification / plausibility
   panels. Light healthcare-SaaS surface — no legacy theming. */

.console { background: var(--bg); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }
kbd {
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 11px;
  background: var(--bg-2); border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 5px; padding: 1px 5px; color: var(--ink-2);
}

/* --- topbar --- */
.c-top {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 22px;
  padding: 11px clamp(14px, 3vw, 28px);
  background: rgba(245, 248, 251, .9);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.c-readout { display: flex; gap: 20px; margin-left: 8px; }
.c-readout .kv { display: flex; flex-direction: column; line-height: 1.25; }
.c-readout i { font-style: normal; font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.c-readout b { font-size: 13.5px; font-weight: 600; color: var(--ink); font-family: ui-monospace, Menlo, monospace; }
.c-readout b.ok { color: var(--affirm); }
.c-account { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.acct-chip {
  font-size: 13px; font-weight: 600; color: var(--teal-ink);
  background: var(--teal-wash); border: 1px solid #cfe8e5;
  padding: 5px 12px; border-radius: 20px; max-width: 260px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.btn.sm { padding: 7px 13px; font-size: 13.5px; }

/* --- control strip --- */
.c-controls {
  display: flex; align-items: flex-end; gap: 20px; flex-wrap: wrap;
  padding: 16px clamp(14px, 3vw, 28px);
  background: var(--paper); border-bottom: 1px solid var(--line);
}
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.field input, .field select {
  font: inherit; font-size: 14.5px; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--bg);
  color: var(--ink); min-width: 220px;
}
.field input:focus, .field select:focus {
  outline: 2px solid var(--teal); outline-offset: 0; border-color: var(--teal); background: #fff;
}
.ctrl-hint { margin: 0 0 2px; font-size: 13px; color: var(--muted); }

/* --- work grid --- */
.c-grid {
  max-width: 1280px; margin: 0 auto;
  padding: clamp(16px, 3vw, 28px);
  display: grid; grid-template-columns: 1fr 400px; gap: 20px; align-items: start;
}
.c-left, .c-right { display: flex; flex-direction: column; gap: 20px; min-width: 0; }

/* card overrides for console density */
.card.pad { padding: 20px; }
.card-hd { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.card-hd.pad-x { padding: 18px 20px 0; margin-bottom: 12px; }
.card-hd h2 { font-family: var(--serif); font-weight: 600; font-size: 18px; margin: 0; }
.card-hd .btn, .card-hd .lang-toggle { margin-left: auto; }
.tag {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--teal-ink); background: var(--teal-wash); padding: 3px 9px; border-radius: 6px;
}
.row { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.row.wrap { flex-wrap: wrap; }

textarea {
  width: 100%; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px; line-height: 1.55; padding: 13px; resize: vertical;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
  color: var(--ink); box-sizing: border-box;
}
textarea:focus { outline: 2px solid var(--teal); outline-offset: 0; border-color: var(--teal); background: #fff; }
#fhir { min-height: 200px; }
#draft { min-height: 340px; font-family: var(--sans); font-size: 14.5px; line-height: 1.7; }

.statusline { font-size: 13.5px; color: var(--muted); }

/* --- worklist --- */
.worklist { display: flex; flex-direction: column; gap: 6px; }
.empty { color: var(--muted); font-size: 14px; margin: 4px 0; }
.wl-row {
  display: grid; grid-template-columns: 74px 1fr auto auto; gap: 10px; align-items: center;
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--bg); cursor: pointer; font-size: 13.5px;
  transition: border-color .12s ease, background .12s ease;
}
.wl-row:hover, .wl-row:focus-visible { border-color: var(--teal); background: #fff; }
.wl-id { font-family: ui-monospace, monospace; font-size: 12px; color: var(--muted); }
.wl-pt { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wl-type { color: var(--ink-2); font-size: 12.5px; }
.wl-status { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 2px 7px; border-radius: 5px; }
.wl-status.s-draft { background: var(--bg-2); color: var(--muted); }
.wl-status.s-signed { background: var(--affirm-wash); color: #0a6f4c; }
.wl-verdict { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 5px; }
.wl-verdict.v-ok { background: var(--affirm-wash); color: #0a6f4c; }
.wl-verdict.v-cond { background: var(--conditional-wash); color: #8a5a12; }
.wl-verdict.v-rev { background: var(--review-wash); color: #a3251c; }

/* --- patient meta --- */
.pt-meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pt-meta > span {
  display: flex; flex-direction: column; gap: 2px; padding: 10px 12px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 9px;
  font-size: 15px; font-weight: 600; color: var(--ink);
}
.pt-meta b { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

/* --- facts --- */
.facts { display: flex; flex-direction: column; gap: 14px; }
.fact-group h4 { margin: 0 0 6px; font-size: 12.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--teal-ink); }
.fact-group ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.fact-group li { font-size: 13.5px; color: var(--ink-2); display: flex; gap: 8px; }
.fid {
  font-family: ui-monospace, monospace; font-size: 11.5px; font-weight: 700; color: var(--teal-ink);
  background: var(--teal-wash); border: 1px solid #cfe8e5; padding: 0 6px; border-radius: 20px;
  height: fit-content; flex-shrink: 0;
}

/* --- draft review overlay --- */
.review {
  min-height: 340px; padding: 14px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; font-size: 14.5px; line-height: 1.7; white-space: pre-wrap;
}
.review .chip {
  font-family: ui-monospace, monospace; font-size: 11px; font-weight: 600; color: var(--teal-ink);
  background: var(--teal-wash); border: 1px solid #cfe8e5; padding: 0 6px; border-radius: 20px; margin: 0 1px;
}
.review mark.bad { background: var(--review-wash); color: #a3251c; padding: 1px 4px; border-radius: 4px; }
.lang-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.lang {
  font: inherit; font-size: 13px; font-weight: 600; padding: 6px 12px; cursor: pointer;
  background: var(--paper); border: none; color: var(--ink-2);
}
.lang.active { background: var(--teal); color: #fff; }

/* --- verdict panel --- */
.verdict { padding-bottom: 18px; }
.verdict-banner {
  display: flex; align-items: center; gap: 10px; margin: 0 20px 16px;
  padding: 13px 16px; border-radius: 10px; font-weight: 700; font-size: 16px;
  background: var(--bg-2); color: var(--ink);
}
.verdict-banner .v-icon { width: 18px; height: 18px; flex-shrink: 0; }
.verdict-banner.affirmative { background: var(--affirm-wash); color: #0a6f4c; }
.verdict-banner.conditional { background: var(--conditional-wash); color: #8a5a12; }
.verdict-banner.review { background: var(--review-wash); color: #a3251c; }

.checks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 0 20px; }
.chk {
  display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 10px 6px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--bg); text-align: center;
}
.chk i { font-style: normal; font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.chk b { font-size: 18px; line-height: 1; }
.chk.pass b { color: var(--affirm); }
.chk.fail b { color: var(--review); }
.chk.pass { border-color: #bfe6d5; }
.chk.fail { border-color: #f3cfca; }

.score-row {
  display: flex; justify-content: space-between; margin: 0 20px; padding: 11px 0;
  border-bottom: 1px solid var(--line-2); font-size: 14px;
}
.score-row:first-of-type { margin-top: 14px; }
.score-row span:last-child { font-weight: 700; font-family: ui-monospace, monospace; }

.vgroup { margin: 14px 20px 0; }
.vg-hd { font-size: 12.5px; font-weight: 700; margin-bottom: 6px; color: var(--ink-2); }
.vg-hd.affirm { color: #0a6f4c; }
.vg-hd.conditional { color: #8a5a12; }
.vg-hd.review { color: #a3251c; }
.vgroup ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.vgroup li { font-size: 13px; color: var(--ink-2); padding: 7px 10px; background: var(--bg); border: 1px solid var(--line); border-radius: 7px; }
#vg-unverified li { background: var(--review-wash); border-color: #f3cfca; color: #8a251c; }
/* Grounded values are many and terse — render as compact wrapping chips inside a
   capped, scrollable area so the reassurance list never dominates the panel. */
.grounded-list { flex-direction: row !important; flex-wrap: wrap; gap: 5px;
  max-height: 116px; overflow-y: auto; padding: 2px; }
.grounded-list li {
  font-family: ui-monospace, Menlo, monospace; font-size: 11.5px; padding: 2px 8px;
  border-radius: 20px; background: var(--affirm-wash); border-color: #cdeadd; color: #0a5e42;
}
.vg-count { font-weight: 400; color: var(--muted); }

.sign { margin: 18px 20px 0; width: calc(100% - 40px); }
.sign-state { margin: 10px 20px 0; font-size: 13px; color: var(--muted); }
.sign-state.signed { color: #0a6f4c; font-weight: 600; }

/* --- plausibility panel --- */
.plaus { padding-bottom: 16px; }
.plaus-banner {
  margin: 0 20px 8px; padding: 11px 14px; border-radius: 9px;
  font-weight: 700; font-size: 14.5px; background: var(--affirm-wash); color: #0a6f4c;
}
.plaus-banner.advisory { background: var(--conditional-wash); color: #8a5a12; }
.plaus-banner.warning { background: var(--review-wash); color: #a3251c; }
.plaus-list { list-style: none; margin: 8px 20px 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.plaus-list li { font-size: 13px; padding: 8px 11px; border-radius: 7px; background: var(--bg); border: 1px solid var(--line); }
.plaus-list li .pcode { font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--conditional); display: block; margin-bottom: 2px; }
.plaus-list li.warn .pcode { color: var(--review); }

/* --- notice --- */
.notice { background: var(--bg-2); }
.notice-h { font-size: 14px !important; color: var(--ink) !important; margin-bottom: 8px !important; }
.notice p { margin: 0; font-size: 13px; color: var(--ink-2); }

/* --- settings dialog extras --- */
.set-row { display: flex; justify-content: space-between; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--line-2); font-size: 14.5px; }
.set-row span { color: var(--muted); }
.set-row b { font-weight: 600; }
.set-row b.ok { color: var(--affirm); }
.set-check { display: flex; align-items: center; gap: 9px; margin: 16px 0; font-size: 14.5px; color: var(--ink-2); }
.set-foot { margin: 12px 0 0; font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--line-2); padding-top: 14px; }

/* --- high-contrast verdict mode (a11y toggle) --- */
body.hc .verdict-banner.affirmative, body.hc .plaus-banner { background: #063d2a; color: #fff; }
body.hc .verdict-banner.conditional, body.hc .plaus-banner.advisory { background: #6b4708; color: #fff; }
body.hc .verdict-banner.review, body.hc .plaus-banner.warning { background: #8a1710; color: #fff; }
body.hc .chk.pass b { color: #063d2a; }
body.hc .chk.fail b { color: #8a1710; }

/* --- responsive: tablet (768–1024) and phones --- */
@media (max-width: 1024px) {
  .c-grid { grid-template-columns: 1fr; }
  .c-right { flex-direction: row; flex-wrap: wrap; }
  .c-right > .card { flex: 1 1 300px; }
}
@media (max-width: 720px) {
  .c-readout { display: none; }
  .c-controls { gap: 14px; }
  .field input, .field select { min-width: 0; width: 100%; }
  .field { flex: 1 1 100%; }
  .c-right { flex-direction: column; }
  .pt-meta { grid-template-columns: repeat(2, 1fr); }
}

/* --- print: only the draft, clean --- */
@media print {
  .c-top, .c-controls, #input-panel, #worklist-panel, #facts-panel,
  .c-right, .lang-toggle, .row, .skip { display: none !important; }
  .c-grid { display: block; padding: 0; }
  #draft-panel { border: none; box-shadow: none; padding: 0; }
  #draft { border: none; min-height: auto; font-family: Georgia, serif; }
  @page { margin: 18mm 16mm; }
}
