/* RNvestigate: plain hospital-record style.
   PLACEHOLDER PALETTE: the group's colours arrive Dec 3. Change only this block. */
:root {
  --brand: #2f4b66;          /* header, primary button */
  --brand-ink: #ffffff;
  --page: #eef0f2;
  --panel: #ffffff;
  --line: #c9ced4;
  --ink: #1d232a;
  --muted: #5b6570;
  --head: #e3e7eb;           /* panel title strip, table header */
  --focus: #1f6feb;
  --danger: #a32020;
  --backup: #8a5a00;
  --backup-bg: #fff3d6;
  /* ESI colours are conventional cues, not brand colours. */
  --esi-1: #a32020; --esi-2: #c25400; --esi-3: #a07800; --esi-4: #2e7d32; --esi-5: #1f5fa8;
  --radius: 3px;
  --font: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--page); color: var(--ink); font: 15px/1.4 var(--font); }

/* Header */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: var(--brand); color: var(--brand-ink); }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border: 2px solid var(--brand-ink);
  border-radius: var(--radius); font-weight: 700; font-size: 13px; }
.brand-name { font-weight: 700; font-size: 17px; }
.brand-sub { font-size: 12px; opacity: .85; }
.topbar-status { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.status { padding: 3px 8px; border-radius: var(--radius); font-size: 12px; font-weight: 600; white-space: nowrap; }
.status-ok { background: rgba(255,255,255,.15); }
.status-backup { background: var(--backup-bg); color: var(--backup); border: 1px solid var(--backup); }

.notice { padding: 6px 16px; background: var(--head); border-bottom: 1px solid var(--line);
  font-size: 13px; color: var(--muted); }

/* Two columns on laptop, one on tablet portrait and phone */
.layout { display: grid; gap: 16px; padding: 16px; max-width: 1280px; margin: 0 auto;
  grid-template-columns: 1fr; }
@media (min-width: 960px) { .layout { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); } }
.column { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
form { display: flex; flex-direction: column; gap: 16px; }

/* Panels */
.panel { margin: 0; padding: 0 12px 12px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); min-width: 0; }
.panel-title { display: block; width: calc(100% + 24px); margin: 0 -12px 10px; padding: 6px 12px;
  background: var(--head); border-bottom: 1px solid var(--line);
  font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
fieldset.panel > legend.panel-title { float: left; }   /* lets the legend sit inside the border */
fieldset.panel > legend.panel-title + * { clear: both; }

/* Fields */
.field { display: flex; flex-direction: column; gap: 3px; margin-bottom: 10px; font-size: 13px; color: var(--muted); }
.field > span { font-weight: 600; }
.req { font-style: normal; font-weight: 400; font-size: 11px; color: var(--danger); margin-left: 4px; }
input, select, textarea { width: 100%; padding: 7px 8px; border: 1px solid var(--line); border-radius: var(--radius);
  font: inherit; font-size: 16px; /* 16px stops iOS zooming on focus */ color: var(--ink); background: #fff; }
input[readonly], textarea[readonly] { background: #f6f7f8; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
textarea { resize: vertical; }
.grid-4 { display: grid; gap: 0 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.invalid { border-color: var(--danger); }

/* ESI selector */
.esi-group { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.esi { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px;
  border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; text-align: center; min-height: 44px; }
.esi input { position: absolute; opacity: 0; pointer-events: none; }
.esi b { font-size: 20px; }
.esi span { font-size: 11px; color: var(--muted); line-height: 1.15; }
.esi:has(input:focus-visible) { outline: 2px solid var(--focus); }
.esi-1 b { color: var(--esi-1); } .esi-2 b { color: var(--esi-2); } .esi-3 b { color: var(--esi-3); }
.esi-4 b { color: var(--esi-4); } .esi-5 b { color: var(--esi-5); }
.esi:has(input:checked) { border-width: 2px; padding: 7px 3px; background: var(--head); }
.esi-1:has(input:checked) { border-color: var(--esi-1); } .esi-2:has(input:checked) { border-color: var(--esi-2); }
.esi-3:has(input:checked) { border-color: var(--esi-3); } .esi-4:has(input:checked) { border-color: var(--esi-4); }
.esi-5:has(input:checked) { border-color: var(--esi-5); }

/* Buttons */
.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.btn { min-height: 40px; padding: 8px 16px; border: 1px solid var(--line); border-radius: var(--radius);
  background: #fff; color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.form-error { margin: 0; color: var(--danger); font-weight: 600; }

/* Record tables: scroll sideways on a phone instead of squashing */
.table-wrap { overflow-x: auto; }
.record-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.record-table th { text-align: left; padding: 5px 8px; background: var(--head); border: 1px solid var(--line);
  font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.record-table td { padding: 6px 8px; border: 1px solid var(--line); vertical-align: top; }
.empty, .muted { color: var(--muted); font-style: italic; }

.gate { padding: 8px 10px; margin-bottom: 10px; border: 1px dashed var(--esi-1); border-radius: var(--radius); font-size: 14px; }
.gate p { margin: 0 0 6px; }
.switch { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; cursor: pointer; }
.switch input { width: auto; }

.warnings { margin: 0; padding-left: 18px; }
.warnings li:not(.empty) { color: var(--danger); font-weight: 600; }
.warnings li.empty { list-style: none; margin-left: -18px; }

.footer { padding: 12px 16px 24px; text-align: center; font-size: 12px; color: var(--muted); }

@media print {
  .topbar, .actions, .notice { display: none; }
  body { background: #fff; }
}
