/*
 * Design system: SummitEHR / DataQ Health product family (tokens from the summitEHR mock-ups and eviti styles).
 * Left blue icon rail, white top bar, light grey page, white cards with washed headers and count pills.
 * Status is always a symbol or dot plus text, never colour alone. 13 px density.
 */

:root {
  --rail: #1b6fd8;
  --rail-active: #0f56b9;
  --primary: #0f62d6;
  --primary-hover: #0b53b8;
  --link: #1665d0;
  --canvas: #f3f5f8;
  --surface: #ffffff;
  --line: #e1e6ed;
  --line-strong: #c9d2de;
  --ink: #1f2733;
  --muted: #616b78;
  --count-bg: #dce9fb;
  --count-ink: #1659c2;
  --chip-bg: #e3eefc;
  --chip-ink: #1d5fbf;
  --banner: #e7f0fb;
  --tabstrip: #5f7593;

  --ok: #277843;
  --ok-bg: #e7f5ec;
  --warn: #9c5c00;
  --warn-bg: #fff3e0;
  --stop: #c62a2a;
  --stop-bg: #fdecec;
  --urgent: #e0393e;
  --medium: #f29d1b;
  --low: #1665d0;
  --pending: #e57373;

  /* Summary tile tints (dashboard top row). */
  --tile-green: #e9f7ef;
  --tile-green-ink: #2fb36b;
  --tile-blue: #eaf2fd;
  --tile-blue-ink: #1565d8;
  --tile-purple: #efedfb;
  --tile-purple-ink: #6a4bc8;
  --tile-orange: #fdf3e3;
  --tile-orange-ink: #f39a1e;
  --tile-green-count: #1e7e46;    /* white count text on these passes 4.5:1; the -ink shades do not */
  --tile-orange-count: #a85800;

  /* Thin cancer-type edges only, never fills. */
  --ca-breast: #9a3b6a;
  --ca-lung: #345f99;
  --ca-bladder: #8a6d1f;
  --ca-prostate: #2e6f6b;
  --ca-colorectal: #8a4b2a;
  --ca-gastric: #b0742a;   /* CR41 */
  --ca-heme: #7a3e8e;
  --ca-melanoma: #5c4a3a;

  /* Density (CR2). */
  --fs: 13px;
  --fs-sm: 12px;
  --gap: 10px;
  --shadow: 0 1px 3px rgba(16, 38, 74, 0.1), 0 0 1px rgba(16, 38, 74, 0.12);
  --head-wash: linear-gradient(180deg, #e3edfb 0, #f3f7fd 60%, #fff 100%);
  --age-bg: #fde5dc;
  --age-ink: #a8492c;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font: var(--fs)/1.45 'Noto Sans', 'Segoe UI', system-ui, sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-variant-numeric: tabular-nums;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

a {
  color: var(--link);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

h1,
h2,
h3 {
  font-weight: 500;
}

.muted {
  color: var(--muted);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.note {
  background: #f6f8fb;
  border: 1px solid var(--line);
  padding: 8px 12px;
  margin: 0 0 12px;
  border-radius: 4px;
}

/* ---------- form controls ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.field > label,
.field > .label {
  color: var(--ink);
}
.input,
input[type='text'],
input[type='search'],
input[type='number'],
select.s,
textarea.t {
  height: 34px;
  box-sizing: border-box;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 0 10px;
  background: #fff;
}
textarea.t {
  height: auto;
  padding: 6px 10px;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 14px;
  border: 1px solid var(--primary);
  border-radius: 4px;
  background: #fff;
  color: var(--primary);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover {
  background: #f0f6fe;
}
.btn.primary {
  background: var(--primary);
  color: #fff;
}
.btn.primary:hover {
  background: var(--primary-hover);
}
.btn.danger {
  border-color: var(--stop);
  color: var(--stop);
}
.btn[disabled] {
  opacity: 0.6;
  cursor: progress;
}
/* Circled "+" next to card titles. */
.add {
  display: inline-flex;
  padding: 0;
  border: 0;
  background: none;
  color: var(--primary);
  cursor: pointer;
  border-radius: 50%;
}
.linkbtn {
  border: 0;
  background: none;
  padding: 0;
  color: var(--link);
  cursor: pointer;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

/* ---------- page and cards ---------- */
.page {
  padding: 10px 14px 20px;
}
.page-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.page-head h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 500;
}
.page-head .sp {
  flex: 1;
}

.card {
  background: var(--surface);
  border: 1px solid #e8edf3;
  border-radius: 4px;
  box-shadow: var(--shadow);
}
/* Every card header gets the in-house white-to-light-blue wash (CR2); .wash is kept for older markup. */
.card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px 6px;
  background: var(--head-wash);
  border-radius: 4px 4px 0 0;
}
.card-head h2,
.card-head h3 {
  margin: 0;
  font-size: 14.5px;
  font-weight: 500;
}
.card-head .sp {
  flex: 1;
}
.card-body {
  padding: 4px 14px 10px;
}
/* Long lists scroll inside the card with a thin scrollbar (CR2). */
.card.scroll > .card-body {
  max-height: 360px;
  overflow-y: auto;
}
.card.scroll > .card-body,
.scroll-y {
  scrollbar-width: thin;
  scrollbar-color: #b9c4d2 transparent;
}
/* Tab header inside a card ("Scheduled 0 | Ready for Intake 0 | Ready for Exam 1"). It takes the whole header. */
.card-head:has(> .ctabs) > .sp {
  display: none;
}
.ctabs {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 13px;
  flex: 1;
  border-bottom: 1px solid var(--line);
  margin: -2px 0 -6px;
}
.ctabs button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 0 6px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--ink);
  font-size: 13.5px;
  cursor: pointer;
}
.ctabs button.on {
  color: var(--link);
  border-bottom-color: var(--primary);
}
/* Small row action icons (view, edit, print) and the peach age badge ("12d"). */
.act {
  display: inline-flex;
  padding: 3px;
  border-radius: 3px;
  color: var(--primary);
}
.act:hover {
  background: #eaf2fe;
}
.age {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: 10px;
  background: var(--age-bg);
  color: var(--age-ink);
  font-size: 11.5px;
  font-weight: 600;
}
.empty {
  color: var(--muted);
  padding: 6px 0;
}

/* Pale-blue count pill next to titles and tabs. */
.count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  box-sizing: border-box;
  border-radius: 9px;
  background: var(--count-bg);
  color: var(--count-ink);
  font-size: 11px;
  font-weight: 700;
}

/* Category chip ("General", "Patient Reminder"). */
.chip {
  display: inline-flex;
  align-items: center;
  height: 21px;
  padding: 0 10px;
  border-radius: 11px;
  background: var(--chip-bg);
  color: var(--chip-ink);
  font-size: var(--fs-sm);
  white-space: nowrap;
}
.chip.green {
  background: #e3f6ea;
  color: #1f9d55;
}

/* List rows inside cards (tasks, encounters). */
.rows > .row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
}
.rows > .row:last-child {
  border-bottom: 0;
}
.row .grow {
  flex: 1;
  min-width: 0;
}
.row .sub {
  color: var(--ink);
  margin-top: 2px;
  font-size: var(--fs-sm);
}
.row .sub.muted {
  color: var(--muted);
}
.sep {
  color: var(--line-strong);
  margin: 0 6px;
}

/* ---------- tables (tasks / report style) ---------- */
table {
  border-collapse: collapse;
  width: 100%;
}
th {
  background: #f1f3f6;
  text-align: left;
  font-weight: 600;
  font-size: 12.5px;
  padding: 7px 10px;
  white-space: nowrap;
}
td {
  padding: 6px 10px;
  height: 22px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
tr.click {
  cursor: pointer;
}
tr.click:hover td {
  background: #f4f8fe;
}
.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
/* Status dot plus text. */
.status::before {
  content: '';
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--dot, var(--muted));
}
.status.pending {
  --dot: var(--pending);
}
.status.ok {
  --dot: var(--ok);
}
.status.info {
  --dot: var(--primary);
}
.empty-row td {
  text-align: center;
  color: var(--muted);
  border-bottom: 0;
}

/* ---------- status pills (symbol + text) ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 8px;
  border-radius: 10px;
  font-size: 11.5px;
  white-space: nowrap;
  background: #eef1f5;
  color: var(--muted);
}
.pill.ok {
  color: var(--ok);
  background: var(--ok-bg);
}
.pill.warn {
  color: var(--warn);
  background: var(--warn-bg);
}
.pill.stop {
  color: var(--stop);
  background: var(--stop-bg);
}
.pill.info {
  color: var(--chip-ink);
  background: var(--chip-bg);
}

/* ---------- tab row with counts (tasks page) ---------- */
.tabrow {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 24px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 8px;
}
.tabrow a,
.tabrow button {
  background: none;
  border: 0;
  font: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 2px 7px;
  color: var(--ink);
  border-bottom: 3px solid transparent;
  text-decoration: none;
}
.tabrow a.on,
.tabrow button.on {
  color: var(--link);
  border-bottom-color: var(--primary);
}

/* ---------- summary tiles grid ---------- */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--gap);
  margin-bottom: var(--gap);
}
.grid3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--gap);
  align-items: start;
}
.stack {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}
@media (max-width: 1100px) {
  .grid3 {
    grid-template-columns: 1fr;
  }
}

/* ---------- gate dialog (Angular CDK dialog pane) ---------- */
.gate-dialog-pane {
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 12px 40px rgba(16, 38, 74, 0.25);
  overflow: hidden;
}
.nant-link-dialog-pane {
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 12px 40px rgba(16, 38, 74, 0.25);
  overflow: hidden;
}
.gate-backdrop {
  background: rgba(20, 30, 45, 0.45);
}

/* The "Why?" evidence drawer (D5): full height on the right. */
.why-pane {
  background: #fff;
  box-shadow: -8px 0 30px rgba(16, 38, 74, 0.25);
  overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

/* Links inside rows of text are underlined, so they don't rely on colour alone (WCAG 1.4.1; C6 accessibility pass). */
.grow a:not(.btn), .sub a:not(.btn), p a:not(.btn) {
  text-decoration: underline;
  text-decoration-color: rgba(22, 101, 208, 0.45);
  text-underline-offset: 2px;
}

/* ================= Form, layout and blocked-reason helpers (same density and tokens) ================= */

.btn.sm {
  height: 26px;
  padding: 0 10px;
  font-size: 12.5px;
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Forms in cards: label above field, laid out in a responsive grid. */
.form {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 8px 12px;
  align-items: end;
}
.form .field.wide {
  grid-column: 1 / -1;
}
.form label {
  font-size: var(--fs-sm);
  color: var(--muted);
}
input[type='date'],
input[type='datetime-local'],
input[type='time'],
select,
textarea {
  height: 32px;
  box-sizing: border-box;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 0 8px;
  background: #fff;
}
textarea {
  height: auto;
  min-height: 56px;
  padding: 6px 8px;
}
.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
}
.checks label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--ink);
}

/* Blocked-reason list shown in place (SPEC section 8: blocked actions show why, never a hidden button). */
.blocked {
  margin: 6px 0;
  padding: 8px 12px;
  border-left: 3px solid var(--stop);
  background: var(--stop-bg);
  border-radius: 0 4px 4px 0;
}
.blocked.warn {
  border-left-color: var(--warn);
  background: var(--warn-bg);
}
.blocked.ok {
  border-left-color: var(--ok);
  background: var(--ok-bg);
}
.blocked ul {
  margin: 4px 0 0;
  padding-left: 18px;
}

/* Study hold banner across the top of study pages. */
.hold-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: var(--gap);
  padding: 9px 14px;
  border-radius: 4px;
  background: var(--stop);
  color: #fff;
  font-weight: 500;
}

/* Key/value lists. */
.kv {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 14px;
  margin: 4px 0;
}
.kv dt {
  color: var(--muted);
}
.kv dd {
  margin: 0;
}

.grid2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--gap);
  align-items: start;
}
@media (max-width: 1100px) {
  .grid2 {
    grid-template-columns: 1fr;
  }
}
.num {
  text-align: right;
}
.mono {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12px;
}
pre.json {
  max-height: 360px;
  overflow: auto;
  margin: 0;
  padding: 8px 10px;
  background: #f6f9f9;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 11.5px;
}
