/* ==========================================================================
   GCM staff dashboard — the review queue
   --------------------------------------------------------------------------
   No build step, no framework, no client JS. Plain CSS served static. The base
   below is shared with portal/src/public/styles.css deliberately: the two apps
   are used by the same people on the same screens and should not disagree
   about what a focus ring looks like.

   ACCESSIBILITY NOTES THAT ARE LOAD-BEARING (this estate has been audited
   before and these are the things that were wrong last time):
     - every interactive target is at least 44x44 CSS px;
     - :focus-visible is a 3px outline with a 2px offset, never `outline: none`;
     - status is a WORD plus a colour, never a colour alone — a colour-only
       badge is unreadable to a colour-blind reviewer and invisible in print;
     - no `white-space: nowrap` on anything that holds user text — that was the
       cause of a horizontal-overflow finding on the gatormobility prototype,
       and here the "user text" is a patient's name;
     - flex/grid children get `min-width: 0` so long words wrap instead of
       forcing the page wider than the viewport (same audit);
     - the wide audit table scrolls INSIDE its own container, so the page body
       never scrolls sideways.
   ========================================================================== */

:root {
  --ink: #14212b;
  --ink-soft: #43525e;
  --line: #c3ced6;
  --line-strong: #8c9aa5;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --brand: #10513f;
  --brand-dark: #0a3a2c;
  --accent: #b4531a;
  --danger: #a01b1b;
  --danger-bg: #fdf1f1;
  --focus: #0b5cd5;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Focus: one rule, everywhere, and deliberately loud. */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 2px;
}

.wrap { max-width: 54rem; margin: 0 auto; padding: 0 1rem; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--panel);
  color: var(--ink);
  padding: 0.75rem 1rem;
  z-index: 10;
}
.skip-link:focus { left: 0; }

/* ---------- header ---------- */
.site-header { background: var(--brand); color: #fff; }
.header-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0;
  min-width: 0; /* see header note: lets the text wrap rather than overflow */
}
.brand-mark {
  background: #fff;
  color: var(--brand);
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.4rem 0.5rem;
  border-radius: 4px;
  flex: none;
}
.brand-text { font-weight: 600; line-height: 1.25; min-width: 0; }
.brand-sub { font-weight: 400; font-size: 0.85rem; opacity: 0.9; }

.account { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; min-width: 0; }
.account-name { margin: 0; font-size: 0.9rem; min-width: 0; overflow-wrap: anywhere; }
.signout { margin: 0; }

/* ---------- nav ---------- */
.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  list-style: none;
  margin: 0 auto;
  padding: 0.25rem 1rem;
  max-width: 54rem;
}
.nav a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 0.9rem;
  color: var(--brand-dark);
  text-decoration: none;
  font-weight: 600;
  border-bottom: 3px solid transparent;
}
.nav a:hover { text-decoration: underline; }
/* aria-current is the accessible signal; the underline is the visual echo of
   it. Styling from the attribute keeps the two from drifting apart. */
.nav a[aria-current="page"] { border-bottom-color: var(--accent); }

/* ---------- main ---------- */
main { padding: 1.5rem 1rem 3rem; }
main:focus { outline: none; }

h1 { font-size: 1.6rem; line-height: 1.25; margin: 0 0 0.35rem; }
h2 { font-size: 1.15rem; margin: 2rem 0 0.5rem; }
.lede { color: var(--ink-soft); margin: 0 0 1.5rem; max-width: 44rem; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.notice {
  border-left: 5px solid var(--accent);
  background: #fff8f2;
  padding: 0.9rem 1rem;
  margin: 0 0 1.5rem;
  border-radius: 0 4px 4px 0;
}

/* ---------- forms ---------- */
fieldset.field { border: 0; padding: 0; margin: 0 0 1.25rem; }
fieldset.field legend { padding: 0; font-weight: 600; margin-bottom: 0.25rem; }

.field { margin: 0 0 1.25rem; }
.field > label { display: block; font-weight: 600; margin-bottom: 0.25rem; }
.req { font-weight: 400; color: var(--ink-soft); }
.opt { font-weight: 400; color: var(--ink-soft); }
.hint { margin: 0 0 0.4rem; font-size: 0.9rem; color: var(--ink-soft); }

input[type="text"], input[type="password"], input[type="tel"],
input[type="email"], input[type="date"], input[type="file"], select, textarea {
  display: block;
  width: 100%;
  min-height: 44px;             /* target size */
  padding: 0.55rem 0.65rem;
  font: inherit;
  color: var(--ink);
  background: #fff;
  border: 2px solid var(--line-strong);
  border-radius: 4px;
}
textarea { min-height: 7rem; resize: vertical; }
input[type="file"] { padding: 0.5rem; }

.field-invalid input, .field-invalid select, .field-invalid textarea {
  border-color: var(--danger);
}
.field-error {
  margin: 0 0 0.4rem;
  color: var(--danger);
  font-weight: 600;
}
/* The word "Error:" carries the meaning for anyone who cannot see the colour
   or the border. It is never display:none'd. */
.err-word { text-decoration: underline; }

.radio { display: flex; align-items: center; gap: 0.6rem; min-height: 44px; }
.radio input[type="radio"] { width: 22px; height: 22px; flex: none; margin: 0; }
.radio label { font-weight: 400; padding: 0.5rem 0; flex: 1 1 auto; min-width: 0; }

.checkbox { display: flex; align-items: flex-start; gap: 0.6rem; min-height: 44px; }
.checkbox input[type="checkbox"] { width: 22px; height: 22px; flex: none; margin-top: 0.6rem; }
.checkbox label { font-weight: 400; padding: 0.5rem 0; min-width: 0; }

.grid-2 { display: grid; gap: 0 1rem; grid-template-columns: 1fr; }
@media (min-width: 40rem) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-width: 44px;
  padding: 0.6rem 1.25rem;
  font: inherit;
  font-weight: 600;
  color: #fff;
  background: var(--brand);
  border: 2px solid var(--brand);
  border-radius: 4px;
  cursor: pointer;
}
.btn:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-quiet {
  background: transparent;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.7);
}
.btn-quiet:hover { background: rgba(255, 255, 255, 0.15); }

/* ---------- error summary ---------- */
.error-summary {
  border: 3px solid var(--danger);
  background: var(--danger-bg);
  padding: 1rem 1.25rem;
  margin: 0 0 1.5rem;
  border-radius: 4px;
}
.error-summary:focus { outline: 3px solid var(--focus); outline-offset: 2px; }
.error-summary-title { margin: 0 0 0.5rem; font-size: 1.05rem; color: var(--danger); }
.error-summary ul { margin: 0; padding-left: 1.2rem; }
.error-summary a { color: var(--danger); font-weight: 600; }

/* ---------- confirmation ---------- */
.confirm {
  border: 3px solid var(--brand);
  background: #f1f8f5;
  padding: 1.25rem;
  border-radius: 4px;
  margin-bottom: 1.5rem;
}
.reference {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.05rem;
  overflow-wrap: anywhere;
}

/* ---------- attestation ---------- */
.attestation {
  border: 1px solid var(--line);
  background: #fbfcfd;
  padding: 1rem;
  border-radius: 4px;
  margin-bottom: 1.25rem;
}
.attestation p { margin: 0 0 0.75rem; }

/* ---------- footer ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  background: #fff;
  padding: 1.25rem 0 2.5rem;
  margin-top: 2rem;
}
.emergency { margin: 0 0 0.5rem; }
.legal { margin: 0; color: var(--ink-soft); font-size: 0.9rem; }

/* ---------- login ---------- */
.login-panel { max-width: 26rem; }

/* Respect a user's stated preference for less motion / high contrast. */
@media (prefers-contrast: more) {
  :root { --line: #000; --line-strong: #000; --ink-soft: #222; }
}

/* ==========================================================================
   Dashboard-specific
   ========================================================================== */

.wrap { max-width: 68rem; }   /* wider than the portal: this is a table view */

.role-tag {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.05rem 0.4rem;
  border: 1px solid currentColor;
  border-radius: 2px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ---------- filters ---------- */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
}
.filter {
  display: inline-flex;
  align-items: center;
  min-height: 44px;          /* tap target */
  padding: 0 0.9rem;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  background: var(--panel);
  color: var(--ink);
  text-decoration: none;
}
.filter-active {
  /* ★ Not colour alone: aria-current is set on the same element, and the
     border weight changes as well as the fill. */
  background: var(--brand);
  border-color: var(--brand-dark);
  color: #fff;
  font-weight: 600;
}

/* ---------- tables ---------- */
.table-scroll {
  /* ★ The wide table scrolls inside this, so the PAGE never scrolls sideways. */
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
table.queue {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--line);
  margin-bottom: 1.25rem;
}
table.queue th,
table.queue td {
  text-align: left;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  /* ★ No nowrap. A long surname or practice name must wrap. */
  overflow-wrap: anywhere;
}
table.queue thead th {
  background: #eef2f5;
  border-bottom: 2px solid var(--line-strong);
  font-size: 0.92rem;
}
table.queue tbody tr:nth-child(even) { background: #fafbfc; }
table.queue tbody tr:hover { background: #f0f5f3; }
.cell-name a { font-weight: 600; }
.cell-num { text-align: right; font-variant-numeric: tabular-nums; }
.cell-year { font-variant-numeric: tabular-nums; }
.cell-id { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.82rem; }
.cell-detail { font-size: 0.85rem; }
.cell-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.row-inactive { opacity: 0.72; }

/* ---------- status badges ---------- */
.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 2px;
  border: 1px solid;
  font-size: 0.85rem;
  font-weight: 600;
}
.badge-received  { background: #fff4e6; border-color: var(--accent);      color: #7a3610; }
.badge-in_review { background: #e9f0fb; border-color: var(--focus);       color: #0a3f92; }
.badge-accepted  { background: #e8f4ee; border-color: var(--brand);       color: var(--brand-dark); }
.badge-rejected  { background: var(--danger-bg); border-color: var(--danger); color: var(--danger); }

/* ---------- detail ---------- */
.breadcrumb { margin: 1rem 0 0.5rem; }
.detail-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}
.detail-head h1 { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.detail-sub { color: var(--ink-soft); margin-top: 0.25rem; }

.dl { margin: 0; }
.dl-row {
  display: grid;
  grid-template-columns: 12rem 1fr;
  gap: 0.5rem 1rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--line);
}
.dl-row:last-child { border-bottom: 0; }
.dl-row dt { font-weight: 600; color: var(--ink-soft); min-width: 0; }
.dl-row dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 34rem) {
  .dl-row { grid-template-columns: 1fr; gap: 0.1rem; }
}

.note {
  /* ★ pre-wrap, not innerHTML. Line breaks from the referring office survive;
     nothing they typed is interpreted as markup. */
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: #fbfcfd;
  border-left: 4px solid var(--line-strong);
  padding: 0.75rem 1rem;
  margin: 0;
}

.docs { list-style: none; margin: 0 0 0.75rem; padding: 0; }
.docs li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--line);
  min-width: 0;
  overflow-wrap: anywhere;
}
.docs li:last-child { border-bottom: 0; }
.doc-meta { display: block; color: var(--ink-soft); font-size: 0.85rem; }

.status-form fieldset { border: 0; margin: 0; padding: 0; }
.status-form legend { font-weight: 600; padding: 0 0 0.5rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.btn-accepted  { background: var(--brand); border-color: var(--brand-dark); color: #fff; }
.btn-rejected  { background: var(--danger-bg); border-color: var(--danger); color: var(--danger); }
.inline-form { display: inline-block; margin: 0; }

/* ---------- pager ---------- */
.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 1rem 0 2rem;
}
.pager-count { margin: 0; color: var(--ink-soft); }
.btn-disabled {
  opacity: 0.5;
  cursor: default;
}

/* ---------- the one-time credential panel ---------- */
.issued {
  border: 2px solid var(--accent);
  background: #fffaf4;
  padding: 1rem 1.25rem;
  margin: 1rem 0 1.5rem;
}
.issued h2 { margin-top: 0; }
.credentials { margin: 0.5rem 0; }
.credentials code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.1rem;
  background: #fff;
  border: 1px solid var(--line-strong);
  padding: 0.15rem 0.4rem;
  /* ★ Selectable and wrappable: this gets read aloud and copied by hand. */
  overflow-wrap: anywhere;
}
.credentials .password { letter-spacing: 0.06em; }

/* ---------- audit table ---------- */
.audit { font-size: 0.92rem; }
.actor-kind, .action-raw, .entity-kind {
  display: block;
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  overflow-wrap: anywhere;
}
.kv { display: inline-block; margin-right: 0.6rem; }
.kv-k { color: var(--ink-soft); }
.kv-v { font-weight: 600; }
.muted { color: var(--ink-soft); }

/* ---------- misc ---------- */
.empty { color: var(--ink-soft); font-style: normal; padding: 1rem 0; }
.notice {
  border-left: 4px solid var(--brand);
  background: #eef5f2;
  padding: 0.75rem 1rem;
  margin: 0 0 1rem;
}
.fineprint { color: var(--ink-soft); font-size: 0.9rem; }
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;   /* allowed: this text is never displayed */
  border: 0;
}

/* ==========================================================================
   Overrides of the shared base
   --------------------------------------------------------------------------
   ★ `.btn-quiet` in the portal's base is drawn for the DARK header bar: white
   text on transparent. The dashboard uses quiet buttons on white panels too
   (the pager, "Disable", "New password"), where that rule renders white text on
   a white background — invisible, and a contrast failure rather than a styling
   nitpick. So the base rule is redefined for light surfaces and the header
   treatment is re-scoped to the header, where it belongs. These come last on
   purpose: same specificity, later wins.
   ========================================================================== */
.btn-quiet {
  background: var(--panel);
  color: var(--brand-dark);
  border-color: var(--line-strong);
}
.btn-quiet:hover { background: #eef2f5; }

.site-header .btn-quiet {
  background: transparent;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.7);
}
.site-header .btn-quiet:hover { background: rgba(255, 255, 255, 0.15); }

.btn-primary { background: var(--brand); border-color: var(--brand-dark); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }

.btn-disabled {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0.6rem 1.25rem;
  border: 2px solid var(--line);
  border-radius: 4px;
  background: var(--panel);
  color: var(--ink-soft);
  font-weight: 600;
}

.panel-narrow { max-width: 32rem; margin-left: auto; margin-right: auto; }

/* A vertical form. `gap` rather than margins so a field added later inherits
   the spacing instead of needing to be remembered. */
.stack { display: flex; flex-direction: column; gap: 1rem; align-items: flex-start; }
.stack .field { width: 100%; }

/* Quiet buttons inside a table cell are secondary actions: smaller padding,
   but the 44px minimum height is kept — it is a tap target on a tablet at a
   workbench, not decoration. */
.cell-actions .btn { padding: 0.4rem 0.7rem; font-size: 0.9rem; }
