/* ==========================================================================
   Room availability and booking app - phone-first stylesheet
   Design width 360px. No framework, no external assets, no dark mode.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. THEME COLOURS
   A deployment restyles the app by editing this block only.
   All text/background pairs used below meet WCAG AA (4.5:1) with these values.
   -------------------------------------------------------------------------- */
:root {
  --accent: #E0112B;        /* headings, primary buttons, focus ring */
  --accent-fill: #E8143A;   /* optional hover for primary buttons */
  --text: #1a1a1a;          /* body text */
  --muted: #595959;         /* secondary text */
  --border: #c8c8c8;        /* lines and input borders */
  --bg: #ffffff;            /* page and card background */
  --surface: #f4f4f4;       /* subtle panels, closed cells, top bar */
  --ok: #1d6b33;            /* success text and border */
  --warn: #8a5a00;          /* caution text and border */
  --danger: #b00020;        /* errors, destructive actions */
  /* neutral and tint tones */
  --hatch: #d4d4d4;         /* hatch stripe for booked and closed cells */
  --ok-tint: #e4f3e8;
  --warn-tint: #fdf0d5;
  --danger-tint: #fdeaec;
  --info-tint: #eef1f4;
  --accent-tint: #fde6e9;   /* pale accent wash for booked cells and tiles; dark text only */
  --backdrop: rgba(0, 0, 0, 0.55);
  --on-accent: #ffffff;     /* text on accent and danger fills */
}

/* --------------------------------------------------------------------------
   2. BASE
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 1rem;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  overflow-wrap: break-word;
}

h1, h2, h3 { margin: 0 0 0.5rem; line-height: 1.25; }
h1 { font-size: 1.35rem; color: var(--accent); }
h2 { font-size: 1.1rem; margin-top: 1.25rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 0.75rem; }
a { color: var(--accent); text-decoration: underline; }
img, svg, table { max-width: 100%; }
ul, ol { margin: 0 0 0.75rem; }

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

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.center { text-align: center; }
.loading { color: var(--muted); font-style: italic; }

/* --------------------------------------------------------------------------
   3. PAGE FRAME: skip link, top bar, tabs, container, footer
   -------------------------------------------------------------------------- */
.skip-link {
  position: absolute; left: 0.5rem; top: -4rem; z-index: 100;
  padding: 0.6rem 0.9rem; background: var(--bg); color: var(--text);
  border: 2px solid var(--accent); border-radius: 4px;
}
.skip-link:focus { top: 0.5rem; }

.topbar {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 0.25rem 0.75rem;
  max-width: 46rem; margin: 0 auto;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--border);
}
.brand { margin: 0; font-weight: bold; font-size: 1.1rem; color: var(--accent); flex: 1 1 0; min-width: 0; }
.topbar #signout { margin-left: auto; white-space: nowrap; }
/* Help link and sign out share the right-hand side of the first row. */
.topbar a.help-link {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 0.5rem;
  margin-left: auto; font: inherit; font-size: 1rem; line-height: 1.2;
  color: var(--accent); text-decoration: underline; white-space: nowrap;
}
.topbar a.help-link + #signout { margin-left: 0; }
/* An auditor's nickname, between How it works and Sign out. The brand then takes the first row on
   its own, and a long nickname is shortened with an ellipsis rather than pushing the row wider. */
.topbar.has-whoami .brand { flex: 1 1 100%; }
.topbar .whoami {
  margin: 0; min-width: 0; flex: 0 1 auto;
  /* Room on the row for How it works and Sign out, so that the row never wraps. */
  max-width: calc(100% - 13rem);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 0.9rem; color: var(--muted);
}
.topbar .whoami-name { font-weight: bold; color: var(--text); }
.topbar .whoami + #signout { margin-left: 0; }
.topbar #signout, .topbar a.help-link { flex: none; }

nav.tabs { flex: 1 1 100%; order: 3; }
nav.tabs ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.25rem; }
nav.tabs li { flex: 1 1 auto; min-width: 0; }
nav.tabs a {
  display: flex; align-items: center; justify-content: center;
  min-height: 40px; padding: 0.35rem 0.6rem;
  font-size: 0.95rem; text-align: center; text-decoration: none;
  color: var(--text); border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg);
}
/* The flag on My bookings: a red dot holding the number of bookings that need the auditor. The
   link's name carries the count in words, so the colour is not the only sign. */
nav.tabs a .nav-dot {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  min-width: 1.4rem; height: 1.4rem; margin-left: 0.4rem; padding: 0 0.3rem;
  border-radius: 999px; background: var(--danger); color: var(--on-accent);
  font-size: 0.8rem; font-weight: bold; line-height: 1;
}
nav.tabs a[aria-current="page"] {
  font-weight: bold; color: var(--accent);
  border-color: var(--accent); border-bottom-width: 4px;
}

.container { max-width: 46rem; margin: 0 auto; padding: 1rem; }

.footer {
  max-width: 46rem; margin: 1rem auto 0; padding: 0.75rem 1rem 1.5rem;
  border-top: 1px solid var(--border);
}
.footer p { margin: 0; font-size: 0.8rem; color: var(--muted); }
.footer button.report-link {
  display: flex; width: fit-content; margin: 0.25rem 0 0; padding: 0.25rem 0;
  min-height: 40px; font-size: 0.9rem; text-align: left;
}

/* --------------------------------------------------------------------------
   4. CARDS AND LISTS
   -------------------------------------------------------------------------- */
.card {
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 0.85rem; margin-bottom: 0.85rem;
}
ul.cards { list-style: none; margin: 0; padding: 0; }

/* --------------------------------------------------------------------------
   5. BUTTONS
   -------------------------------------------------------------------------- */
.btn, .btn-primary, .btn-danger, .btn-link {
  font: inherit; font-size: 1rem; line-height: 1.2; cursor: pointer;
}
.btn, .btn-primary, .btn-danger {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 40px; padding: 0.5rem 1rem; border-radius: 6px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  text-decoration: none; font-weight: bold;
  transition: background-color 0.12s;
}
.btn:hover { background: var(--surface); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-fill); border-color: var(--accent-fill); }
.btn-danger { border-color: var(--danger); color: var(--danger); background: var(--bg); }
.btn-danger:hover { background: var(--danger-tint); }
.btn-link {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0.25rem 0.5rem;
  background: none; border: 0; color: var(--accent); text-decoration: underline;
}
.btn-block { display: flex; width: 100%; }
button[disabled], .btn[disabled], .btn-primary[disabled], .btn-danger[disabled], .btn-link[disabled] {
  cursor: not-allowed; opacity: 1;
  background: var(--surface); color: var(--muted);
  border-color: var(--border); text-decoration: none; font-weight: normal;
}
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.5rem; }

/* Busy state: the spinner is absolutely placed so the button width does not change. */
button[aria-busy="true"] { position: relative; cursor: progress; opacity: 0.7; }
button[aria-busy="true"]::after {
  content: ""; position: absolute; top: 50%; right: 0.5rem;
  width: 0.9em; height: 0.9em; margin-top: -0.45em;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: btn-spin 0.8s linear infinite;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  button[aria-busy="true"]::after { display: none; }
}

/* --------------------------------------------------------------------------
   6. FORMS
   -------------------------------------------------------------------------- */
.field { margin-bottom: 0.85rem; }
.field label { display: block; margin-bottom: 0.25rem; font-weight: bold; }
.field input, .field select, .field textarea {
  display: block; width: 100%; min-height: 40px; padding: 0.5rem 0.6rem;
  font: inherit; font-size: 16px; color: var(--text); background: var(--bg);
  border: 1px solid var(--muted); border-radius: 6px;
}
.field textarea { min-height: 5.5rem; resize: vertical; }

input, select, textarea { font-size: 16px; }
select { max-width: 100%; }
input[type="date"] {
  min-width: 0; max-width: 100%; box-sizing: border-box;
  -webkit-appearance: none; appearance: none; min-height: 40px;
}
input[type="date"]::-webkit-date-and-time-value { text-align: left; }
input[type="date"]::-webkit-calendar-picker-indicator { opacity: 0.8; }

fieldset.filters {
  display: flex; flex-wrap: wrap; gap: 0.5rem 0.85rem;
  margin: 0 0 0.85rem; padding: 0.5rem 0.75rem 0.75rem;
  border: 1px solid var(--border); border-radius: 8px; min-width: 0;
}
fieldset.filters legend {
  padding: 0 0.35rem; font-size: 0.8rem; font-weight: bold;
  text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted);
}
fieldset.filters .field { margin: 0; flex: 1 1 8rem; min-width: 0; }

.checks, .radios { list-style: none; margin: 0 0 0.85rem; padding: 0; }
.checks label, .radios label {
  display: flex; align-items: center; gap: 0.6rem; min-height: 40px; padding: 0.25rem 0;
}
.checks input[type="checkbox"], .radios input[type="radio"] {
  width: 1.25rem; height: 1.25rem; flex: none; margin: 0; accent-color: var(--accent);
}

/* --------------------------------------------------------------------------
   7. MESSAGES AND PILLS
   -------------------------------------------------------------------------- */
.error, .notice, .ok-msg {
  margin: 0 0 0.85rem; padding: 0.6rem 0.75rem; border-radius: 6px;
  border: 1px solid var(--border); border-left-width: 4px;
}
.error { background: var(--danger-tint); border-color: var(--danger); color: var(--text); }
.notice { background: var(--info-tint); border-color: var(--muted); }
.ok-msg { background: var(--ok-tint); border-color: var(--ok); }

.pills { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.35rem 0; }
.pill {
  display: inline-block; padding: 0.1rem 0.6rem; border-radius: 999px;
  font-size: 0.8rem; font-weight: bold; line-height: 1.5;
  border: 1px solid var(--muted); background: var(--surface); color: var(--text);
}
.pill-scarce  { border-color: var(--danger); background: var(--danger-tint); color: var(--danger); }
.pill-limited { border-color: var(--warn);   background: var(--warn-tint);   color: var(--warn); }
.pill-open    { border-color: var(--ok);     background: var(--ok-tint);     color: var(--ok); }
.pill-state   { border-color: var(--muted);  background: var(--info-tint);   color: var(--text); }
.pill-clash   { border-color: var(--danger); background: var(--danger); color: var(--on-accent); }
.pill-requested { border-color: var(--accent); border-style: dashed; background: var(--bg); color: var(--text); }
.pill-flag    { border-color: var(--warn);   background: var(--bg);          color: var(--warn); border-style: dashed; }

/* --------------------------------------------------------------------------
   8. STEPPER, WEEK TABS, COUNTS
   -------------------------------------------------------------------------- */
ol.steps {
  list-style: none; counter-reset: step; margin: 0 0 0.85rem; padding: 0;
  display: flex; flex-wrap: wrap; gap: 0.25rem 0.75rem; font-size: 0.85rem; color: var(--muted);
}
ol.steps li { counter-increment: step; }
ol.steps li::before { content: counter(step) ". "; }
ol.steps li.current { font-weight: bold; color: var(--text); text-decoration: underline; text-underline-offset: 3px; }

.weektabs { display: flex; margin: 0 0 0.75rem; }
.weektabs button {
  flex: 1 1 0; min-width: 0; min-height: 40px; padding: 0.4rem 0.35rem;
  white-space: normal; line-height: 1.15;
  font: inherit; font-size: 0.95rem; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); cursor: pointer;
}
.weektabs button + button { border-left-width: 0; }
.weektabs button:first-child { border-radius: 6px 0 0 6px; }
.weektabs button:last-child  { border-radius: 0 6px 6px 0; }
.weektabs button[aria-pressed="true"] {
  background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: bold;
}
.weektabs button:focus-visible { position: relative; z-index: 1; }

/* --------------------------------------------------------------------------
   My week: quick-fill block (one button per morning/afternoon/evening/weekend day)
   -------------------------------------------------------------------------- */
.quickfill { max-width: 36rem; margin: 0.5rem 0 0.75rem; }
.quickfold { max-width: 36rem; margin: 0.75rem 0; }
.quickfold > summary { cursor: pointer; font-weight: bold; min-height: 44px; display: flex; align-items: center; }
.quickfold > summary::-webkit-details-marker { display: none; }
.quickfold > summary::before { content: '\25B8'; margin-right: 0.5rem; }
.quickfold[open] > summary::before { content: '\25BE'; }
.dayfill { max-width: 36rem; margin: 0 0 0.75rem; }
.dayfill #days-title { margin: 0 0 0.25rem; }
.df-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.25rem; }
.df-btn { min-height: 44px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0.25rem; line-height: 1.1; }
.df-name { font-weight: bold; font-size: 0.9rem; }
.df-num { font-size: 0.8rem; }
.df-btn[aria-pressed="true"]:not([disabled]) { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.df-btn[aria-pressed="true"]:not([disabled]):hover { background: var(--accent-fill); border-color: var(--accent-fill); }
.quickfill #quick-title { margin: 0 0 0.25rem; }
.qf-row { display: grid; grid-template-columns: 2.6rem repeat(3, minmax(0, 1fr)); gap: 0.25rem; align-items: stretch; margin: 0 0 0.25rem; }
.qf-row.qf-weekend { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.qf-day { display: flex; align-items: center; font-weight: bold; font-size: 0.9rem; min-width: 0; }
.qf-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 0; min-height: 44px; padding: 0.25rem 0.2rem; line-height: 1.15; text-align: center;
}
.qf-part { font-weight: bold; font-size: 0.9rem; }
.qf-range { font-weight: normal; font-size: 0.75rem; white-space: nowrap; }
.qf-btn[aria-pressed="true"]:not([disabled]) { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.qf-btn[aria-pressed="true"]:not([disabled]):hover { background: var(--accent-fill); border-color: var(--accent-fill); }

.counts { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; margin: 0 0 0.75rem; font-size: 0.9rem; color: var(--muted); }
.counts .stat strong { color: var(--text); font-size: 1.1rem; margin-right: 0.25rem; }

/* --------------------------------------------------------------------------
   9. AVAILABILITY GRID (must fit 360px with no horizontal scroll)
   -------------------------------------------------------------------------- */
.grid-wrap { width: 100%; max-width: 100%; margin: 0 0 0.85rem; }
table.avail { table-layout: fixed; width: 100%; border-collapse: collapse; }
table.avail th, table.avail td { border: 1px solid var(--border); padding: 0; text-align: center; }
table.avail th.day { padding: 0.25rem 0; font-weight: normal; background: var(--surface); line-height: 1.2; }
table.avail th.day .dname { display: block; font-size: 0.75rem; font-weight: bold; }
table.avail th.day .ddate { display: block; font-size: 0.75rem; color: var(--muted); }
table.avail th:first-child { width: 2.4rem; }
table.avail th.hour {
  width: 2.4rem; padding: 0; font-size: 0.8rem; font-weight: bold;
  color: var(--muted); background: var(--surface);
}
.cell {
  display: flex; align-items: center; justify-content: center;
  width: 100%; min-height: 2.5rem; height: 100%; margin: 0; padding: 0;
  font: inherit; font-size: 1rem; font-weight: bold; color: var(--text);
  background: var(--bg); border: 0; border-radius: 0; cursor: pointer;
}
button.cell:hover { background: var(--surface); }
button.cell:focus-visible { position: relative; z-index: 2; outline-offset: -3px; }
button.cell[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
button.cell[aria-pressed="true"]::after { content: "\2713"; font-size: 1.1rem; line-height: 1; }
button.cell[aria-pressed="true"]:hover { background: var(--accent-fill); }
.cell.booked, .cell.booked:hover {
  background: repeating-linear-gradient(45deg, var(--hatch) 0, var(--hatch) 4px, var(--bg) 4px, var(--bg) 8px);
  color: var(--text); cursor: not-allowed;
}
span.cell.closed {
  background: repeating-linear-gradient(135deg, var(--surface) 0, var(--surface) 5px, var(--hatch) 5px, var(--hatch) 6px);
  cursor: default;
}

/* --------------------------------------------------------------------------
   10. ROOM CARDS AND BOOKING CARDS
   -------------------------------------------------------------------------- */
.room-card h3 { display: inline; margin-right: 0.4rem; }
.room-card .code { font-family: "Courier New", Courier, monospace; font-size: 0.85rem; color: var(--muted); }
.room-meta { margin: 0.25rem 0; font-size: 0.85rem; color: var(--muted); }
.run { margin: 0.35rem 0; font-weight: bold; }
.room-card .btn-primary { margin-top: 0.35rem; }

.booking-card.clash { border-left: 4px solid var(--danger); }
.booking-card.past { color: var(--muted); background: var(--surface); }
.booking-card .when { margin: 0.25rem 0; font-weight: bold; }
.booking-card .partner { margin: 0.25rem 0; }

/* --------------------------------------------------------------------------
   11. DIALOG (bottom sheet on phones, centred from 600px)
   -------------------------------------------------------------------------- */
dialog.sheet {
  position: fixed; inset: auto 0 0 0; margin: 0 auto;
  width: 100%; max-width: min(32rem, 100vw); box-sizing: border-box;
  max-height: 90vh; max-height: 90dvh;
  overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  padding: 1rem; padding-bottom: max(1rem, env(safe-area-inset-bottom));
  color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-bottom: 0; border-radius: 14px 14px 0 0;
}
dialog.sheet::backdrop { background: var(--backdrop); }
dialog.sheet:not([open]) { display: none; }
html:has(dialog[open]) { overflow: hidden; }

/* Fallback for browsers without native dialog: script adds .dialog-fallback and [open]. */
dialog.sheet.dialog-fallback[open] {
  display: block; position: fixed; inset: auto 0 0 0; margin: 0 auto; z-index: 1000;
  box-shadow: 0 0 0 100vmax var(--backdrop);
}
dialog.dialog-fallback:not([open]) { display: none; }

@media (min-width: 600px) {
  dialog.sheet {
    inset: 0; margin: auto; height: fit-content;
    border: 1px solid var(--border); border-radius: 12px;
  }
  .container { padding: 1.5rem 1rem; }
}

/* --------------------------------------------------------------------------
   12. SIGN-IN PAGE
   -------------------------------------------------------------------------- */
main.container.signin { max-width: 22rem; margin-top: 10vh; }
#code {
  font-size: 1.4rem; letter-spacing: 0.15em; text-transform: uppercase; text-align: center;
}

/* --------------------------------------------------------------------------
   13. WIDE CONTAINER (coordinator pages)
   The top bar and footer keep their 46rem width; only the content widens.
   -------------------------------------------------------------------------- */
.container.container-wide { max-width: 64rem; }

/* --------------------------------------------------------------------------
   14. COORDINATOR AND AUDITOR NAVIGATION (wrap, no horizontal scroll)
   Six coordinator links (three rows of two at 360px, one row from 600px) or four
   auditor links: two per row at 360px.
   -------------------------------------------------------------------------- */
nav.tabs-coordinator li, nav.tabs-auditor li { flex: 1 1 40%; }
nav.tabs-coordinator a, nav.tabs-auditor a { min-height: 40px; overflow-wrap: anywhere; }
@media (min-width: 600px) {
  nav.tabs-coordinator li { flex: 1 1 0; }
}
/* Auditor links (four to six): a two-column grid at phone width. An odd last link spans both columns. */
nav.tabs-auditor ul { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.25rem; }
nav.tabs-auditor li, nav.tabs-auditor a { min-width: 0; }
nav.tabs-auditor li:last-child:nth-child(odd) { grid-column: 1 / -1; }
nav.tabs-auditor.tabs-5 { --n: 5; }
nav.tabs-auditor.tabs-6 { --n: 6; }
@media (min-width: 600px) {
  nav.tabs-auditor ul { grid-template-columns: repeat(var(--n, 5), minmax(0, 1fr)); }
  nav.tabs-auditor li:last-child:nth-child(odd) { grid-column: auto; }
}

/* --------------------------------------------------------------------------
   15. ROOMS LIST (S5)
   -------------------------------------------------------------------------- */
.h3 { font-size: 1rem; margin: 0 0 0.25rem; }
.filters-form { margin: 0; }
fieldset.filters .field-wide { flex: 1 1 100%; }
ul.room-list { list-style: none; margin: 0; padding: 0; }
.room-row h2.h3 { margin-top: 0; }
.room-row .code { font-family: "Courier New", Courier, monospace; font-size: 0.85rem; font-weight: normal; color: var(--muted); }
.error-text { color: var(--danger); font-size: 0.85rem; font-weight: bold; margin: 0.25rem 0; }

/* Room states: each differs by tint and border style as well as by its text. */
.pill.state-not_scheduled     { background: var(--bg);          border-color: var(--muted);  color: var(--text); }
.pill.state-booked            { background: var(--info-tint);   border-color: var(--accent); color: var(--text); border-width: 2px; }
.pill.state-part_complete     { background: var(--warn-tint);   border-color: var(--ok);     color: var(--text); border-style: dotted; border-width: 2px; }
.pill.state-complete          { background: var(--ok-tint);     border-color: var(--ok);     color: var(--ok); }
.pill.state-not_possible      { background: var(--warn-tint);   border-color: var(--warn);   color: var(--warn); }
.pill.state-coordinator_arranged { background: var(--info-tint); border-color: var(--muted); color: var(--text); border-style: double; border-width: 3px; }
.pill.state-out_of_scope      { background: var(--surface);     border-color: var(--muted);  color: var(--muted); border-style: dashed; }

/* --------------------------------------------------------------------------
   16. ROOM PAGE (S6)
   -------------------------------------------------------------------------- */
p.back { margin: 0 0 0.5rem; }
h1 .code { font-family: "Courier New", Courier, monospace; font-size: 0.85rem; font-weight: normal; color: var(--muted); }

dl.facts { display: grid; grid-template-columns: minmax(6rem, 9rem) 1fr; gap: 0.35rem 0.75rem; margin: 0 0 0.85rem; }
dl.facts dt { font-weight: bold; margin: 0; }
dl.facts dd { margin: 0; min-width: 0; }
@media (max-width: 380px) {
  dl.facts { grid-template-columns: 1fr; gap: 0; }
  dl.facts dd { margin-bottom: 0.5rem; }
}

table.avail.roomweek td { height: 2.2rem; min-height: 2.2rem; overflow: hidden; vertical-align: middle; background: var(--bg); }
table.avail.roomweek td.rw-free { background: var(--bg); }
table.avail.roomweek td.rw-free.rw-marked { text-align: center; box-shadow: inset 0 0 0 2px var(--accent-tint); }
table.avail.roomweek td.rw-none { background: var(--surface); }
table.avail.roomweek td.rw-closed { background: var(--surface); }
table.avail.roomweek td.rw-closed .cell { min-height: 2.2rem; }
table.avail.roomweek td.rw-busy {
  background: repeating-linear-gradient(45deg, var(--hatch) 0, var(--hatch) 4px, var(--bg) 4px, var(--bg) 8px);
}
.rw-mark { display: inline-block; padding: 0 0.15rem; font-weight: bold; font-size: 0.8rem; line-height: 1.2; color: var(--text); background: var(--bg); border-radius: 2px; }
table.avail.roomweek td.rw-booked { background: var(--accent-tint); border: 2px solid var(--accent); }
table.avail.roomweek td.rw-booked.rw-clash { background: var(--danger-tint); border: 3px solid var(--danger); }
.rw-labels { display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 0.62rem; line-height: 1.1; font-weight: bold; color: var(--text); overflow: hidden; }
.rw-labels span { display: block; max-width: 100%; overflow: hidden; text-overflow: clip; white-space: nowrap; }

.visit.card { margin-bottom: 0.6rem; }
.visit .when { margin: 0 0 0.25rem; font-weight: bold; }
.visit-cancelled { color: var(--muted); background: var(--surface); }
.visit-cancelled .when { font-weight: normal; text-decoration: line-through; }

/* --------------------------------------------------------------------------
   17. DASHBOARD (S7)
   -------------------------------------------------------------------------- */
.dash-section { margin: 0 0 1.5rem; }
.dash-section > h2 { margin-top: 0; }

ul.stat-tiles {
  list-style: none; margin: 0 0 0.5rem; padding: 0;
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.5rem;
}
@media (min-width: 600px) { ul.stat-tiles { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 900px) { ul.stat-tiles { grid-template-columns: repeat(7, 1fr); } }
li.stat-tile {
  display: flex; flex-direction: column; justify-content: space-between; min-width: 0;
  padding: 0.6rem 0.65rem; border: 1px solid var(--muted); border-radius: 8px;
  background: var(--info-tint); color: var(--text);
}
.stat-n { font-size: 1.8rem; font-weight: bold; line-height: 1.1; }
.stat-l { font-size: 0.85rem; line-height: 1.25; }
li.stat-tile.state-not_scheduled { background: var(--bg); }
li.stat-tile.state-booked { border-color: var(--accent); border-width: 2px; }
li.stat-tile.state-part_complete { background: var(--warn-tint); border-color: var(--ok); border-style: dotted; border-width: 2px; }
li.stat-tile.state-complete { background: var(--ok-tint); border-color: var(--ok); }
li.stat-tile.state-not_possible { background: var(--warn-tint); border-color: var(--warn); }
li.stat-tile.state-coordinator_arranged { border-style: double; border-width: 3px; }
li.stat-tile.state-out_of_scope { background: var(--surface); border-style: dashed; color: var(--muted); }

.clash-card { border-left: 4px solid var(--danger); }

.table-wrap { max-width: 100%; overflow-x: auto; margin: 0 0 0.85rem; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
table.data caption { text-align: left; }
table.data th, table.data td { padding: 0.4rem 0.5rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
table.data thead th { font-weight: bold; border-bottom: 2px solid var(--text); background: var(--bg); white-space: nowrap; }
table.data tbody th { font-weight: bold; }
table.data tbody tr:nth-child(even) { background: var(--surface); }
table.data.compact { font-size: 0.85rem; }
table.data.compact th, table.data.compact td { padding: 0.25rem 0.35rem; }

dialog.sheet.sheet-wide { max-width: min(56rem, 100vw); }

/* --------------------------------------------------------------------------
   18. AUDITORS (S8)
   -------------------------------------------------------------------------- */
.auditor-card { padding: 0.85rem; }
.inline-fields { display: flex; flex-wrap: wrap; gap: 0.5rem 0.85rem; margin-bottom: 0.5rem; }
.inline-fields .field { flex: 1 1 8rem; min-width: 0; margin-bottom: 0.35rem; }
.inline-fields .field.field-wide { flex: 2 1 14rem; }
.code-msg {
  font-size: 1.5rem; font-weight: bold; letter-spacing: 0.15em;
  text-align: center; padding: 0.85rem 0.75rem; overflow-wrap: anywhere;
}

/* --------------------------------------------------------------------------
   19. ROOMS AND BOOKINGS (S9) AND UPLOAD (S10)
   -------------------------------------------------------------------------- */
section.card > h2 { margin-top: 0; }
.field input[type="file"] {
  min-height: 40px; padding: 0.4rem 0.5rem; max-width: 100%; background: var(--surface);
}
.field input[type="file"]::file-selector-button {
  font: inherit; font-weight: bold; min-height: 32px; margin-right: 0.6rem; padding: 0.25rem 0.75rem;
  color: var(--text); background: var(--bg); border: 1px solid var(--muted); border-radius: 6px; cursor: pointer;
}
.field input[type="date"] { max-width: 100%; min-width: 0; appearance: none; -webkit-appearance: none; }

/* --------------------------------------------------------------------------
   20. SECURITY SCHEDULE AND PRINT
   -------------------------------------------------------------------------- */
body.print-page .container { padding-top: 1rem; }
table.data.schedule { font-size: 0.9rem; }
table.data.schedule th, table.data.schedule td { border: 1px solid var(--border); }

@media print {
  .topbar, .skip-link, .footer, .no-print, button, .btn, .btn-primary, .btn-danger, .btn-link { display: none !important; }
  html, body { color: #000; background: #fff; font-size: 11pt; }
  .container, .container.container-wide { max-width: none; width: 100%; margin: 0; padding: 0; }
  a { color: #000; text-decoration: none; }
  h1 { color: #000; }
  .card { border-color: #000; }
  .table-wrap { overflow: visible; }
  table.data { font-size: 10pt; }
  table.data th, table.data td { border: 1px solid #000; color: #000; background: #fff !important; }
  table.data thead { display: table-header-group; }
  table.data tr { break-inside: avoid; page-break-inside: avoid; }
}

/* --------------------------------------------------------------------------
   21. LOAD FAILURE, HELP PAGE, PROBLEM REPORTS
   -------------------------------------------------------------------------- */
.load-failed { margin-top: 1rem; }
.load-failed .btn, .load-failed .btn-primary { margin-top: 0.5rem; }

article.help { line-height: 1.5; }
article.help p.lead { font-size: 1.05rem; }
article.help section { margin-top: 1.25rem; }
article.help ol.help-steps, article.help ul { padding-left: 1.25rem; }
article.help li { margin-bottom: 0.4rem; }

#report .small.muted, dialog.sheet#report p.small { margin: 0 0 0.75rem; }
.report-card p.report-meta { margin: 0 0 0.35rem; font-size: 0.85rem; color: var(--muted); }
.report-card p.report-text { margin: 0 0 0.5rem; overflow-wrap: anywhere; white-space: pre-wrap; }
.report-card .pill-open { border-color: var(--warn); background: var(--warn-tint); color: var(--warn); }
.report-card .pill-resolved { border-color: var(--muted); background: var(--info-tint); color: var(--text); }
.report-filters { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0 0 0.75rem; }
.report-filters .btn { min-width: 0; }
.report-filters .btn[aria-pressed="true"] {
  background: var(--accent); border-color: var(--accent); color: var(--on-accent);
}
.report-count { margin: 0 0 0.75rem; font-size: 0.85rem; color: var(--muted); }

/* --------------------------------------------------------------------------
   22. REDUCED MOTION
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* ---- Auditor time allocation (trial): My time (/time) and Auditors' time (/time-admin) ---- */
.weeknav { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin: 0.5rem 0; }
.weeknav .week-label { margin: 0; font-weight: bold; flex: 1 1 auto; min-width: 0; }

.field-row { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.field-row .field { flex: 1 1 8rem; min-width: 0; }

.time-form { margin-top: 1.25rem; }
.time-row p { margin: 0.2rem 0; }

.claim-withdrawn, .claim-rejected { color: var(--muted); background: var(--surface); }

.pill-time-pending   { border-color: var(--warn);   background: var(--warn-tint);   color: var(--warn); }
.pill-time-approved  { border-color: var(--ok);     background: var(--ok-tint);     color: var(--ok); }
.pill-time-rejected  { border-color: var(--danger); background: var(--danger-tint); color: var(--danger); }
.pill-time-withdrawn { border-color: var(--muted);  background: var(--surface);     color: var(--text); }

/* Checkbox grid; .checks .check outranks the older ".checks label" rule so the 2.75rem touch target applies. */
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); gap: 0.35rem 0.75rem; }
.check, .checks .check { display: flex; align-items: center; gap: 0.4rem; font-weight: normal; min-height: 2.75rem; }
.check input, .checks .check input[type="checkbox"] { width: 1.25rem; height: 1.25rem; }

fieldset.field { border: 0; padding: 0; margin: 0 0 0.85rem; min-width: 0; }
fieldset.field legend { font-weight: bold; padding: 0; margin-bottom: 0.25rem; }

#lim h3, #cl-title { margin-top: 1rem; }

/* --------------------------------------------------------------------------
   16. AUDITOR DASHBOARD
   -------------------------------------------------------------------------- */
#dash .card > h2:first-child { margin-top: 0; }
.dash-action { border-left: 4px solid var(--danger); }
ul.plain { list-style: none; margin: 0; padding: 0; }
ul.plain li { margin: 0 0 0.4rem; }
ul.plain a { display: block; padding: 0.35rem 0; }
.my-dash { table-layout: fixed; }
.my-dash th, .my-dash td { white-space: normal; overflow-wrap: anywhere; }
table.data.my-dash thead th { white-space: normal; }
.my-dash th:nth-child(n+2), .my-dash td { width: 28%; }
.my-dash tr.sub th { font-weight: normal; padding-left: 1.25rem; color: var(--muted); }

/* Upload: the drop zone for the timetable report */
.dropzone { border: 2px dashed var(--muted); border-radius: 8px; padding: 0.75rem; margin-bottom: 0.85rem; }
.dropzone.dragging { border-color: var(--accent); background: var(--info-tint); }
.dropzone .field { margin-bottom: 0; }
.dropzone p { margin-top: 0; }
fieldset.weeks-pick { border: 0; padding: 0; margin: 0 0 0.5rem; min-width: 0; }
fieldset.weeks-pick legend { font-weight: bold; margin-bottom: 0.25rem; padding: 0; }
details.card > summary, #rules-box > summary { cursor: pointer; font-weight: bold; min-height: 40px; display: flex; align-items: center; }
#files-box { margin-bottom: 1rem; }
