/* ==========================================================================
   Med Lend styles
   1. Colours and sizes      7. Badges
   2. Basics                 8. Forms
   3. Page layout            9. Messages
   4. Sidebar               10. Dialogs
   5. Buttons               11. Sign-in and sign-up pages
   6. Panels, cards, tables 12. Small screens

   Every text colour below was checked against WCAG 2.1 AA (4.5:1 for text,
   3:1 for borders of form fields and other controls). The ratio is noted
   next to each colour.
   ========================================================================== */

/* ---------- 1. Colours and sizes ---------- */
:root {
  /* Palette */
  --navy: #0B2545;          /* sidebar and headings – 14.3:1 on beige */
  --blue: #1D4ED8;          /* buttons, links, focus – 6.7:1 on white, 6.2:1 on beige */
  --beige: #FAF6EE;         /* page background (white-beige) */
  --white: #FFFFFF;         /* panels and form fields */
  --text: #1C2430;          /* body text – 14.5:1 on beige */
  --tint: #E3ECF8;          /* light blue for table headers, highlights and dividers */

  /* Shades made from the palette */
  --blue-dark: #1E40AF;     /* hover state for blue buttons – 8.7:1 with white */
  --muted: #4F5B6B;         /* hints and secondary text – 6.4:1 on beige, 5.8:1 on light blue */
  --field-border: #7A8699;  /* form field borders – 3.7:1 on white */
  --sidebar-text: #D6E2F3;  /* 11.8:1 on navy */
  --sidebar-focus: #93B4E8; /* focus ring on the navy sidebar – 7.3:1 */
  --line: #E6E0D4;          /* beige dividers between panels (decorative) */

  /* Errors, overdue and delete only. Always shown with an icon and words too. */
  --red: #B42318;           /* 6.6:1 on white */
  --red-dark: #8F1B12;
  --red-tint: #FDECEC;      /* red text on this is 5.8:1 */

  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --radius: 8px;
  --radius-large: 12px;
  --shadow: 0 1px 3px rgba(11, 37, 69, 0.08);
}

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.55;
  color: var(--text);
  background: var(--beige);
}

h1, h2, h3 { color: var(--navy); line-height: 1.25; margin: 0 0 0.5rem; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1rem; }

a { color: var(--blue); text-underline-offset: 0.15em; }
a:hover { color: var(--blue-dark); text-decoration-thickness: 2px; }

/* One clear focus outline for everything you can reach with the keyboard */
:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
}
.sidebar :focus-visible { outline-color: var(--sidebar-focus); }

/* Headings get focus from script after some actions; only show the ring for keyboard users */
h1[tabindex="-1"]:focus:not(:focus-visible) { outline: none; }

[hidden] { display: none !important; }

/* Hidden on screen but read by screen readers */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: -4rem;
  left: 1rem;
  z-index: 10;
  padding: 0.75rem 1rem;
  background: var(--white);
  color: var(--navy);
  font-weight: 700;
  border: 3px solid var(--blue);
  border-radius: var(--radius);
}
.skip-link:focus { top: 1rem; }

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

/* ---------- 3. Page layout ---------- */
.app {
  display: grid;
  grid-template-columns: 15rem minmax(0, 1fr);
  grid-template-rows: 1fr auto;   /* main area, then the footer */
  min-height: 100vh;
}
.app > .sidebar { grid-row: 1 / span 2; }
/* Paint the sidebar column navy all the way down, so long pages (and full-page screenshots) look right */
.app { background: linear-gradient(to right, var(--navy) 15rem, var(--beige) 15rem); }

.main {
  width: 100%;
  max-width: 80rem;
  padding: 2rem clamp(1rem, 3vw, 2.5rem) 3rem;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.page-header p { margin: 0; color: var(--muted); }

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 24rem), 1fr));
  gap: 0 1.5rem;
}

/* ---------- 4. Sidebar ---------- */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 1.5rem 1rem;
  background: var(--navy);
  color: var(--sidebar-text);
}

.sidebar-top { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.25rem 0.5rem;
  color: var(--white);
  font-size: 1.25rem;
  font-weight: 700;
  text-decoration: none;
}
.brand:hover { color: var(--white); }
.brand img { width: 2.25rem; height: 2.25rem; }

.nav-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.25rem; }

.nav-link {
  display: block;
  padding: 0.7rem 0.85rem;
  border-left: 4px solid transparent;
  border-radius: var(--radius);
  color: var(--sidebar-text);
  font-weight: 500;
  text-decoration: none;
}
.nav-link:hover { background: rgba(255, 255, 255, 0.08); color: var(--white); }
/* The current page is marked by a bar, a background and bold text, not colour alone */
.nav-link[aria-current="page"] {
  background: rgba(255, 255, 255, 0.12);
  border-left-color: var(--tint);
  color: var(--white);
  font-weight: 700;
}

.sidebar-footer { margin-top: auto; padding-top: 1rem; border-top: 1px solid rgba(255, 255, 255, 0.2); }
.signed-in-as { margin: 0 0 0.75rem; padding: 0 0.5rem; font-size: 0.875rem; }
.signed-in-as strong { display: block; color: var(--white); }

.sidebar .menu-toggle { display: none; }

/* ---------- 5. Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 2.75rem;   /* 44px, big enough to tap */
  padding: 0.55rem 1.1rem;
  border: 2px solid transparent;
  border-radius: var(--radius);
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-primary { background: var(--blue); color: var(--white); }
.btn-primary:hover:not(:disabled) { background: var(--blue-dark); color: var(--white); }

.btn-secondary { background: var(--white); color: var(--blue); border-color: var(--blue); }
.btn-secondary:hover:not(:disabled) { background: var(--tint); color: var(--blue-dark); }

.btn-danger { background: var(--red); color: var(--white); }
.btn-danger:hover:not(:disabled) { background: var(--red-dark); }

.btn-small { min-height: 2.25rem; padding: 0.35rem 0.75rem; font-size: 0.9rem; }
.btn-wide { width: 100%; margin-top: 0.5rem; }

.btn-signout {
  width: 100%;
  justify-content: flex-start;
  background: transparent;
  color: var(--sidebar-text);
  border-color: rgba(255, 255, 255, 0.5);
}
.btn-signout:hover { background: rgba(255, 255, 255, 0.1); color: var(--white); }

.btn-link {
  padding: 0;
  background: none;
  border: none;
  font: inherit;
  font-weight: 600;
  color: var(--blue);
  text-decoration: underline;
  cursor: pointer;
}

/* Spinning circle shown inside a button while it is working */
.spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 6. Panels, cards and tables ---------- */
.panel {
  margin-bottom: 1.5rem;
  padding: 1.25rem 1.5rem;
  background: var(--white);
  border: 1px solid var(--tint);
  border-radius: var(--radius-large);
  box-shadow: var(--shadow);
}
.panel-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.panel-header h2 { margin: 0; }

/* Dashboard number cards */
.stat-grid {
  list-style: none;
  margin: 0 0 1.5rem;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 1rem;
}
.stat-card {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1.1rem 1.25rem;
  background: var(--white);
  border: 1px solid var(--tint);
  border-top: 5px solid var(--navy);
  border-radius: var(--radius-large);
  box-shadow: var(--shadow);
}
.stat-card.is-available, .stat-card.is-borrowed, .stat-card.is-requests { border-top-color: var(--blue); }
.stat-card.is-overdue { border-top-color: var(--red); }
.stat-label { color: var(--muted); font-weight: 600; font-size: 0.95rem; }
.stat-value { color: var(--navy); font-size: 2.25rem; font-weight: 700; line-height: 1.1; }
.stat-card a { margin-top: 0.25rem; font-size: 0.9rem; font-weight: 600; }

.simple-list { list-style: none; margin: 0; padding: 0; }
.simple-list li {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--tint);
}
.simple-list li:last-child { border-bottom: none; }
.simple-list .meta { width: 100%; color: var(--muted); font-size: 0.9rem; }

.empty { margin: 0; color: var(--muted); }

/* Equipment cards on the Borrow page */
.item-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr));
  gap: 1rem;
}
.item-grid .empty { grid-column: 1 / -1; }
.item-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1rem 1.1rem;
  background: var(--white);
  border: 1px solid var(--tint);
  border-radius: var(--radius);
}
.item-card h3, .item-card p { margin: 0; }
.item-card .sub { color: var(--muted); font-size: 0.875rem; }
.item-card-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-top: auto;
  padding-top: 0.75rem;
}

/* Wide tables scroll inside this box instead of making the page scroll sideways */
.table-wrap {
  position: relative; /* keeps hidden screen reader text inside the box */
  overflow-x: auto;
  background: var(--white);
  border: 1px solid var(--tint);
  border-radius: var(--radius);
}

table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
th, td {
  padding: 0.75rem 1rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--tint);
}
thead th {
  background: var(--tint);
  color: var(--navy);
  font-weight: 650;
  white-space: nowrap;
}
tbody th { font-weight: 600; }
tbody tr:last-child > * { border-bottom: none; }
td.empty { padding: 2rem 1rem; text-align: center; }
td.cell-actions { white-space: nowrap; }
td.cell-actions .btn + .btn { margin-left: 0.4rem; }
.code { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sub { display: block; margin-top: 0.15rem; color: var(--muted); font-size: 0.85rem; font-weight: 400; }

/* Sortable column headings are real buttons */
.sort-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.15rem 0.25rem;
  margin: -0.15rem -0.25rem;
  background: none;
  border: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.sort-btn:hover { text-decoration: underline; }
.sort-icon { font-size: 0.75rem; }

/* Search and filter bar above a list */
.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 1rem; }
.toolbar .field { flex: 1 1 12rem; margin: 0; }
.toolbar .field:first-child { flex-grow: 2; }
.toolbar .checkbox { margin-bottom: 0.7rem; }
.toolbar-actions { display: flex; flex: 0 0 auto; gap: 0.5rem; }

.filter-group { margin: 0 0 1rem; padding: 0; border: none; }
.filter-group legend { margin-bottom: 0.4rem; font-weight: 600; }
.segmented { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.segmented label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 2.75rem;
  padding: 0.5rem 0.9rem;
  background: var(--white);
  border: 2px solid var(--field-border);
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
}
.segmented input { width: 1.1rem; height: 1.1rem; margin: 0; accent-color: var(--blue); }
.segmented label:has(input:checked) { background: var(--tint); border-color: var(--blue); }
.segmented label:has(input:focus-visible) { outline: 3px solid var(--blue); outline-offset: 2px; }

.results-summary { margin: 1rem 0 0.5rem; color: var(--muted); font-weight: 500; }

/* ---------- 7. Badges (always an icon and a word, never colour alone) ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.6rem;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 650;
  white-space: nowrap;
}
.badge-available { background: var(--tint); color: var(--navy); }                 /* 13.6:1 */
.badge-borrowed { background: var(--blue); color: var(--white); }                          /* 7.1:1 */
.badge-overdue { background: var(--red); color: var(--white); }                              /* 6.6:1 */
.badge-unavailable { background: var(--red-tint); color: var(--red); border-color: var(--red); } /* 5.8:1 */
.badge-requested { background: var(--white); color: var(--navy); border-color: var(--blue); }        /* 15.4:1 */
.badge-completed { background: var(--white); color: var(--muted); border-color: var(--field-border); }

/* ---------- 8. Forms ---------- */
.field { margin-bottom: 1.1rem; }
.field > label, .field legend { display: block; margin-bottom: 0.3rem; font-weight: 600; }
.field fieldset { margin: 0; padding: 0; border: none; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr)); gap: 0 1.25rem; }
.required { color: var(--red); }
.optional { color: var(--muted); font-weight: 400; }
.hint { display: block; margin: 0 0 0.35rem; color: var(--muted); font-size: 0.9rem; }

input[type="text"], input[type="tel"], input[type="password"], input[type="search"],
input[type="date"], input[type="number"], select, textarea {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.55rem 0.75rem;
  font: inherit;
  color: var(--text);
  background: var(--white);
  border: 2px solid var(--field-border);
  border-radius: var(--radius);
}
textarea { min-height: 5.5rem; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--blue); outline-offset: 1px; }
select:disabled { background: var(--beige); color: var(--muted); }

.radio-list { display: grid; gap: 0.5rem; }
.radio-list label, .checkbox { display: flex; align-items: center; gap: 0.6rem; font-weight: 500; cursor: pointer; }
.radio-list input, .checkbox input { width: 1.25rem; height: 1.25rem; margin: 0; accent-color: var(--blue); }

/* A field with a problem gets a thicker red border, a warning icon and a message */
[aria-invalid="true"] { border-color: var(--red) !important; border-width: 3px !important; }
.field-error { display: flex; gap: 0.35rem; margin: 0 0 0.35rem; color: var(--red); font-weight: 600; font-size: 0.92rem; }
.field-error::before { content: "⚠"; }

/* Extra fields that only appear after a certain choice */
.conditional {
  margin-bottom: 1.1rem;
  padding: 0.85rem 1rem 0.1rem;
  background: var(--beige);
  border-left: 4px solid var(--blue);
  border-radius: 0 var(--radius) var(--radius) 0;
}

/* List of problems at the top of a form */
.error-summary {
  margin-bottom: 1.25rem;
  padding: 1rem 1.25rem;
  background: var(--white);
  border: 3px solid var(--red);
  border-radius: var(--radius);
}
.error-summary h2, .error-summary h3 { margin-bottom: 0.4rem; color: var(--red); font-size: 1.05rem; }
.error-summary ul { margin: 0; padding-left: 1.25rem; }
.error-summary a { color: var(--red); font-weight: 600; }

.form-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 0.5rem; }

/* ---------- 9. Messages ---------- */
.flash {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  padding: 0.9rem 1rem;
  border: 2px solid;
  border-radius: var(--radius);
  font-weight: 500;
}
.flash p { flex: 1; margin: 0; }
.flash a { color: inherit; font-weight: 700; }
.flash-success { background: var(--tint); border-color: var(--blue); color: var(--navy); }
.flash-error { background: var(--red-tint); border-color: var(--red); color: var(--red-dark); }
.flash-close { padding: 0 0.25rem; background: none; border: none; font: inherit; font-weight: 700; color: inherit; text-decoration: underline; cursor: pointer; }

/* ---------- 10. Dialogs (pop-up forms) ---------- */
dialog {
  width: min(40rem, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  padding: 0;
  overflow: auto;
  color: var(--text);
  border: none;
  border-radius: var(--radius-large);
  box-shadow: 0 20px 50px rgba(11, 37, 69, 0.35);
}
dialog.dialog-wide { width: min(56rem, calc(100vw - 2rem)); }
dialog.dialog-small { width: min(30rem, calc(100vw - 2rem)); }
dialog::backdrop { background: rgba(11, 37, 69, 0.6); }

.dialog-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: var(--white);
  border-bottom: 1px solid var(--tint);
}
.dialog-header h2 { margin: 0; }
.dialog-body { padding: 1.25rem 1.5rem 1.5rem; }
.dialog-close {
  width: 2.75rem;
  height: 2.75rem;
  background: none;
  border: 2px solid transparent;
  border-radius: var(--radius);
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text);
  cursor: pointer;
}
.dialog-close:hover { background: var(--tint); }

/* ---------- 11. Sign-in and sign-up pages ---------- */
.signin-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  min-height: 100vh;
}
.signin-brand {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1.5rem;
  padding: 3rem clamp(1.5rem, 5vw, 4rem);
  background: var(--navy);
  color: var(--sidebar-text);
}
.signin-brand .brand { padding: 0; font-size: 1.75rem; }
.signin-brand .brand img { width: 3rem; height: 3rem; }
.signin-brand p { max-width: 30rem; font-size: 1.15rem; }
.signin-features { display: grid; gap: 0.75rem; margin: 0; padding: 0; list-style: none; }
.signin-features li { display: flex; align-items: center; gap: 0.75rem; }
.signin-features li::before { content: ""; flex-shrink: 0; width: 0.6rem; height: 0.6rem; border-radius: 50%; background: var(--tint); }

.signin-main { display: flex; align-items: center; justify-content: center; padding: 2rem 1rem; }
.signin-card {
  width: 100%;
  max-width: 27rem;
  padding: 2rem;
  background: var(--white);
  border: 1px solid var(--tint);
  border-radius: var(--radius-large);
  box-shadow: var(--shadow);
}
.signin-card h1 { font-size: 1.6rem; }
.switch-link { margin: 1.25rem 0 0; text-align: center; }

.demo-note {
  margin-top: 1.5rem;
  padding: 0.85rem 1rem;
  background: var(--beige);
  border-left: 4px solid var(--blue);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 0.92rem;
}
.demo-note p { margin: 0; }

.simple-page { max-width: 36rem; margin: 15vh auto; }

/* ---------- 12. Small screens ---------- */

/* Tablets and phones: the sidebar becomes a bar at the top with a Menu button */
@media (max-width: 52rem) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto; background: var(--beige); }
  .app > .sidebar { grid-row: auto; }
  .sidebar { position: static; height: auto; gap: 0; padding: 0.75rem 1rem; }
  .sidebar .menu-toggle { display: inline-flex; background: transparent; color: var(--white); border-color: rgba(255, 255, 255, 0.6); }
  .sidebar-nav, .sidebar-footer { display: none; }
  .sidebar.is-open .sidebar-nav, .sidebar.is-open .sidebar-footer { display: block; margin-top: 0.75rem; }
  .main { padding-top: 1.5rem; }
  h1 { font-size: 1.5rem; }

  .signin-page { grid-template-columns: minmax(0, 1fr); }
  .signin-brand { gap: 0.75rem; padding: 1.5rem; }
  .signin-brand p { margin: 0; font-size: 1rem; }
  .signin-features { display: none; }
}

/* Phones */
@media (max-width: 36rem) {
  .panel { padding: 1rem; }
  .signin-card { padding: 1.5rem 1.25rem; }
  .dialog-header, .dialog-body { padding-left: 1rem; padding-right: 1rem; }
  .page-header .btn { width: 100%; }
  .stat-value { font-size: 1.85rem; }
}

/* Windows high contrast mode */
@media (forced-colors: active) {
  .badge, .btn, .flash, .stat-card { border: 1px solid CanvasText; }
  .nav-link[aria-current="page"] { outline: 2px solid CanvasText; }
}

/* ---------- 13. Weekly loans chart (dashboard) ---------- */
.chart { margin: 0; }
.chart svg { display: block; width: 100%; height: auto; max-height: 14rem; }
.chart .bar { fill: var(--blue); }
.chart .chart-axis { stroke: var(--field-border); stroke-width: 1; }
.chart .chart-value { fill: var(--navy); font-size: 12px; font-weight: 700; }
.chart .chart-label { fill: var(--muted); font-size: 11px; }
.chart figcaption { margin-top: 0.5rem; color: var(--muted); font-size: 0.9rem; }

/* ---------- 14. Equipment pictures ---------- */
.item-card img {
  display: block;
  width: calc(100% + 2.2rem);
  max-width: none;
  height: auto;
  aspect-ratio: 16 / 10;
  object-fit: contain;          /* show the whole product, never cut off */
  padding: 0.5rem;
  background: var(--white);
  border-bottom: 1px solid var(--tint);
  margin: -1rem -1.1rem 0.5rem;
  border-radius: var(--radius) var(--radius) 0 0;
}
.item-card { overflow: hidden; }

/* ---------- 15. Equipment photos in tables and forms ---------- */
.name-with-photo { display: flex; align-items: flex-start; gap: 0.75rem; }
.name-with-photo img { flex-shrink: 0; width: 3rem; height: auto; aspect-ratio: 16 / 10; object-fit: contain; background: var(--white); border-radius: 4px; }
.photo-preview { display: block; width: 10rem; height: auto; aspect-ratio: 16 / 10; object-fit: contain; background: var(--white); margin-bottom: 0.75rem; border-radius: var(--radius); }
input[type="file"] { max-width: 100%; font: inherit; }
input[type="file"]::file-selector-button {
  margin-right: 0.75rem; padding: 0.5rem 0.9rem; font: inherit; font-weight: 600;
  color: var(--blue); background: var(--white); border: 2px solid var(--blue); border-radius: var(--radius); cursor: pointer;
}

/* ---------- 16. Patient issues and conversation ---------- */
.back-link { margin: 0 0 0.75rem; }
.issue-details { white-space: pre-line; margin: 0; }
.messages { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; }
.message article {
  padding: 1rem 1.1rem;
  background: var(--white);
  border: 1px solid var(--tint);
  border-left: 5px solid var(--field-border);
  border-radius: var(--radius);
}
.message-doctor article { border-left-color: var(--blue); background: #F5F8FD; }
.message h3 { margin: 0; font-size: 1rem; }
.message-role { font-weight: 500; color: var(--muted); font-size: 0.9rem; }
.message .sub { margin: 0.1rem 0 0.5rem; }
.message-body { white-space: pre-line; margin: 0; }
.recommended { margin-top: 1rem; padding-top: 0.75rem; border-top: 1px solid var(--tint); }
.recommended h4 { margin: 0 0 0.5rem; font-size: 0.95rem; color: var(--navy); }
.recommended-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.recommended-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; }
.recommended-list img { width: 4rem; height: auto; aspect-ratio: 16 / 10; object-fit: contain; background: var(--white); border-radius: 4px; }
.recommended-name { flex: 1 1 10rem; font-weight: 600; }
.recommend { margin: 0 0 1rem; padding: 0; border: none; }
.recommend > legend { font-weight: 600; margin-bottom: 0.3rem; }
#recommend-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); gap: 0.75rem 1.5rem; }
.recommend-group { margin: 0; padding: 0; border: none; display: grid; gap: 0.4rem; }
.recommend-group legend { font-weight: 650; color: var(--navy); margin-bottom: 0.3rem; }
.sub-inline { color: var(--muted); font-size: 0.85rem; font-weight: 400; }

/* Label and value pairs, e.g. the facts about an issue */
.summary-list { display: grid; grid-template-columns: max-content 1fr; gap: 0.4rem 1.25rem; margin: 0 0 1rem; }
.summary-list dt { font-weight: 600; color: var(--muted); }
.summary-list dd { margin: 0; }
@media (max-width: 36rem) {
  .summary-list { grid-template-columns: 1fr; gap: 0.1rem; }
  .summary-list dd { margin-bottom: 0.5rem; }
}
.recommend-group .checkbox { align-items: flex-start; }
.recommend-group .checkbox input { margin-top: 0.15rem; }

/* ---------- 17. Accessibility page and its links ---------- */
.info-header {
  padding: 0.75rem max(1rem, env(safe-area-inset-left, 0px));
  background: var(--navy);
}
.info-header .brand { display: inline-flex; }
.info-header :focus-visible { outline-color: var(--sidebar-focus); }
.info-page { max-width: 48rem; margin: 0 auto; padding: 2rem clamp(1rem, 4vw, 2.5rem) 3rem; }
.info-page h2 { margin-top: 2rem; }
.info-page ul { padding-left: 1.25rem; }
.info-page li + li { margin-top: 0.35rem; }
.info-page .table-wrap { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); }
caption { padding: 0.75rem 1rem; text-align: left; font-weight: 600; color: var(--navy); }

/* ---------- 18. Feedback ---------- */
.feedback-form { margin: 1.5rem 0; }
.feedback-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; }
.feedback-item {
  padding: 1rem 1.1rem;
  background: var(--white);
  border: 1px solid var(--tint);
  border-left: 5px solid var(--field-border);
  border-radius: var(--radius);
}
.feedback-item.is-new { border-left-color: var(--blue); }   /* the "New" badge says it in words too */
.feedback-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem; }
.feedback-top h3 { margin: 0; font-size: 1rem; }
.feedback-message { white-space: pre-line; margin: 0.5rem 0 0.75rem; overflow-wrap: anywhere; }

/* ---------- 19. How to use (show/hide steps) ---------- */
.how-to { margin-top: 0.25rem; }
.how-to summary {
  display: list-item;       /* keeps the browser's open/closed arrow */
  padding-block: 0.6rem;    /* about 44px high, easy to tap */
  color: var(--blue);
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}
.how-to summary:hover { color: var(--blue-dark); }
.how-to ol { margin: 0.25rem 0 0.5rem; padding-left: 1.25rem; display: grid; gap: 0.35rem; }
.how-to-note { color: var(--muted); font-size: 0.875rem; }
.how-to-list { display: grid; gap: 0.25rem; margin-top: 1rem; }

/* ---------- 20. Footer (on every page) ---------- */
.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  padding: 1.25rem clamp(1rem, 3vw, 2.5rem);
  border-top: 1px solid var(--line);
  color: var(--muted);          /* 6.4:1 on the beige page */
  font-size: 0.9rem;
}
.site-footer p { margin: 0; }
.footer-links { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; margin: 0; padding: 0; list-style: none; }
.footer-links a { display: inline-block; padding-block: 0.6rem; }   /* about 44px to tap */
