/* TTNCR — one stylesheet for both modules.
 *
 * O2 settled that the NCR module's visual identity is the platform's, so its
 * values win wherever the two disagreed: Segoe UI, the 1240px container, the
 * 10px/6px radii, the coloured table headers.
 *
 * The Forms module contributed two things that were not the NCR module's to
 * lose:
 *
 *   - the TOKEN VOCABULARY below. The NCR sheet had three variables and
 *     hard-coded everything else, which is why only two colours were ever
 *     themeable. These make the rest reachable.
 *   - the ACCESSIBILITY rules: a skip link, `:focus-visible` at 3px, and 44px
 *     minimum touch targets. Those are not "look", and were not traded away.
 *
 * `--primary`, `--accent` and `--bg` are deliberately absent here: base.html
 * injects them per response from org settings, which is how one deployment
 * re-brands both modules. Defining them here would shadow that.
 *
 * Eleven class names were defined in both sheets — .navbar, .card, .chip,
 * .btn and friends. Only the NCR definitions survive. Loading both files and
 * letting link order decide is not a design.
 */

:root {
  --surface: #ffffff;
  --border: #e0e0e0;
  --text: #0F3248;
  --muted: #5a6b76;
  --danger: #c62828;
  --danger-bg: #ffebee;
  --success: #2e7d32;
  --success-bg: #e8f5e9;
  --warning: #e65100;
  --warning-bg: #fff3e0;
  --focus: #2196F3;
  --radius: 4px;
}

/* Focus is always visible, and never removed for aesthetics. */
:focus-visible {
  outline: 3px solid var(--focus, #2196F3);
  outline-offset: 2px;
}

/* Skip link: the first tab stop on every page. */
.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--surface, #fff); color: var(--primary);
  padding: .75rem 1rem; z-index: 100; font-weight: bold;
}
.skip-link:focus { left: 0; }

/* Touch targets. A control smaller than this is a miss on a phone, and the
 * Forms module is used on phones on site. */
.btn, button, [type="submit"] { min-height: 44px; }

/* TTNCR — theme colours are injected as CSS custom properties from org settings */
* { box-sizing: border-box; }
body {
  font-family: 'Segoe UI', Calibri, system-ui, sans-serif;
  margin: 0; background: var(--bg, #f4f6f9); color: #2b2b2b; font-size: 15px;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- layout ---------- */
.navbar {
  display: flex; align-items: center; gap: 18px;
  background: var(--primary); color: #fff; padding: 10px 22px;
}
.navbar-brand { display: flex; align-items: center; gap: 12px; font-weight: 600; font-size: 17px; }
.navbar-brand img { height: 34px; background: #fff; border-radius: 4px; padding: 2px 6px; }
.navbar-panel {
  display: flex; align-items: center; justify-content: space-between;
  gap: 18px; flex: 1; min-width: 0;
}
.navbar-menu { display: flex; gap: 4px; flex-wrap: wrap; min-width: 0; }
.navbar-menu a {
  color: #fff; padding: 8px 14px; border-radius: 6px; font-weight: 500;
  white-space: nowrap;
}
.navbar-menu a:hover, .navbar-menu a.active { background: rgba(255,255,255,.15); text-decoration: none; }
.navbar-user { color: #d6dbe8; font-size: 13px; display: flex; align-items: center; gap: 10px; }
.navbar-user a { color: #fff; }

/* The ☰ button. Never shown on a wide screen, and carries the `hidden`
   attribute in the markup until app.js removes it — with JavaScript off the
   panel stays open and there is no dead button to press. */
.nav-toggle {
  display: none; align-items: center; gap: 8px; margin-left: auto;
  background: rgba(255,255,255,.14); color: #fff; border: none;
  border-radius: 8px; padding: 10px 14px; font: inherit; font-weight: 600;
  cursor: pointer; min-height: 44px;
}
.nav-toggle-bars, .nav-toggle-bars::before, .nav-toggle-bars::after {
  display: block; width: 20px; height: 2px; background: #fff; border-radius: 2px;
}
.nav-toggle-bars { position: relative; }
.nav-toggle-bars::before, .nav-toggle-bars::after { content: ""; position: absolute; left: 0; }
.nav-toggle-bars::before { top: -6px; }
.nav-toggle-bars::after { top: 6px; }
.nav-toggle[aria-expanded="true"] { background: rgba(255,255,255,.28); }

/* Errors from a background (HTMX) request that the page could not otherwise
   show. Pinned so it is seen even when the failure happens far down a form. */
.app-error {
  position: sticky; top: 0; z-index: 20;
  background: #fdecec; border-bottom: 1px solid #f2b8b8; color: #8f1c1c;
  padding: 11px 18px; font-size: 14px; font-weight: 600;
}
.container { max-width: 1240px; margin: 24px auto; padding: 0 20px; }
.footer { text-align: center; color: #8a8f98; font-size: 12.5px; padding: 26px 0 34px; }

/* ---------- cards & tables ---------- */
.card { background: #fff; border: 1px solid #e3e7ee; border-radius: 10px; padding: 18px 20px; margin-bottom: 18px; }
.card h2, .card h3 { margin-top: 0; color: var(--primary); }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th {
  text-align: left; background: var(--primary); color: #fff; padding: 8px 10px;
  position: sticky; top: 0; font-weight: 600;
}
table.data td { padding: 8px 10px; border-bottom: 1px solid #eceff4; vertical-align: top; }
table.data tr:hover td { background: #f6f9fc; }
.result-count { color: #6a7078; font-size: 13px; margin: 8px 0; }

/* ---------- chips & pills ---------- */
.chip {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; color: #fff; white-space: nowrap;
}
.pill-overdue { background: #dc3545; color: #fff; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 700; }
.age-green { color: #1d7a34; font-weight: 600; }
.age-amber { color: #b57700; font-weight: 600; }
.age-red { color: #c22333; font-weight: 700; }

/* ---------- forms ---------- */
label { display: block; font-weight: 600; font-size: 13px; margin: 10px 0 4px; color: #40454d; }
input[type=text], input[type=number], input[type=date], input[type=email],
input[type=password], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid #ccd3dd; border-radius: 6px;
  font: inherit; background: #fff;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.field-help { font-size: 12px; color: #7a808a; margin-top: 2px; }
.field-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 4px 22px; }
.field-grid .full { grid-column: 1 / -1; }
.checks { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 6px; }
.checks label { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; margin: 0; }

/* ---------- buttons ---------- */
.btn {
  display: inline-block; border: none; border-radius: 6px; cursor: pointer;
  padding: 9px 16px; font: inherit; font-weight: 600;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-secondary { background: #e7ebf1; color: #333; }
.btn-danger { background: #dc3545; color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn:hover { filter: brightness(1.1); }
.actions-row { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; align-items: center; }

/* ---------- notices ---------- */
.notice { background: #e7f6ec; border: 1px solid #b7e2c4; color: #1d6b33; padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }
.error { background: #fdecec; border: 1px solid #f2b8b8; color: #a02020; padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }

/* ---------- NCR form sections ----------
   A completed NCR is a long read. Sections need to announce themselves, and
   within a section the entered data — not the field label — needs to be the
   thing the eye lands on. */
.section {
  background: #fff; border: 1px solid #dfe4ec; border-left: 4px solid var(--primary);
  border-radius: 10px; margin-bottom: 20px; overflow: hidden;
}
.section-header {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 13px 18px; border-bottom: 1px solid #e4e9f0;
  background: #f5f7fb;                                   /* fallback */
  background: color-mix(in srgb, var(--primary) 7%, #fff);
  color: var(--primary); font-weight: 700;
  font-size: 17px; letter-spacing: .01em;
}
.section-body { padding: 16px 18px 20px; }

/* Locked sections: say "read-only" through the header, and leave the content
   at full contrast — fading the data made completed records harder to read. */
.section-locked { border-left-color: #c3c9d4; }
.section-locked .section-header { background: #f2f4f7; color: #5c6472; }
.locked-label { font-size: 12px; color: #8a919c; font-weight: 600; white-space: nowrap; }

/* Field labels recede to quiet tags; the answer carries the weight. */
.section .field-grid > div > label {
  font-size: 11.5px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: #8a919c; margin: 0 0 4px;
}
.section .field-grid > div { margin-bottom: 12px; }
label .req { color: #c0392b; margin-left: 3px; }

/* Read-only values. white-space: pre-wrap is load-bearing — without it the
   line breaks in a 5 Whys chain or a three-part timeline collapse into one
   run-on paragraph the moment a record locks. */
.readonly-value {
  white-space: pre-wrap; overflow-wrap: anywhere;
  font-size: 15px; line-height: 1.5; color: #1f2933;
  padding: 2px 0 7px; border-bottom: 1px solid #f0f3f7; min-height: 1.6em;
}
.readonly-value:empty::before { content: "\2014"; color: #b6bcc6; }

/* Contextual guidance inside a section (e.g. the RCA method note). */
.method-note {
  background: #fff8e6; border: 1px solid #f0ddb0; color: #6b5310;
  padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 13.5px;
}
.method-note b { color: #57430c; }

/* Fields hidden by a conditional rule (see app.js). Grid children need this
   stated explicitly. */
[hidden] { display: none !important; }
.status-bar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: #fff; border: 1px solid #e3e7ee; border-radius: 10px;
  padding: 12px 18px; margin-bottom: 16px;
}

/* ---------- queues ---------- */
.queue { border-left: 4px solid var(--accent); }
.queue h3 { margin: 0 0 8px; }

/* ---------- approval chain ---------- */
.signoff-chain { display: flex; gap: 12px; flex-wrap: wrap; }
.signoff-step {
  flex: 1 1 200px; border: 1px solid #e0e5ec; border-radius: 8px; padding: 12px;
}
.signoff-step.done { border-color: #28a745; background: #f2fbf4; }
.signoff-step.current { border-color: var(--accent); background: #f0fafc; }
.signoff-step .who { font-size: 13px; color: #555; }

/* ---------- timeline ---------- */
.timeline-entry { border-left: 3px solid var(--accent); padding: 4px 0 10px 12px; margin-left: 6px; }
.timeline-entry .meta { font-size: 12.5px; color: #7a808a; }

/* ---------- dashboard ---------- */
.tile-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.tile {
  background: #fff; border: 1px solid #e3e7ee; border-radius: 10px; padding: 16px;
  text-align: center; cursor: pointer;
}
.tile:hover { border-color: var(--accent); }
.tile .num { font-size: 34px; font-weight: 800; color: var(--primary); }
.tile .lbl { color: #6a7078; font-size: 13px; font-weight: 600; }
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }
.chart-card { background: #fff; border: 1px solid #e3e7ee; border-radius: 10px; padding: 14px; }
.chart-card h4 { margin: 0 0 8px; color: var(--primary); }

/* ---------- filters ---------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 10px; }
.filters > div { min-width: 140px; }
.filters label { margin-top: 0; }

/* ---------- login / supplier ---------- */
.auth-box { max-width: 420px; margin: 8vh auto; }
.auth-box .card { padding: 28px; }
.brand-block { text-align: center; margin-bottom: 14px; }
.brand-block img { max-height: 54px; }

/* ---------- attachments ---------- */
.attachment-list { list-style: none; padding: 0; margin: 8px 0; }
.attachment-list li { padding: 4px 0; font-size: 13.5px; }
.attachment-list img.thumb { max-height: 60px; border-radius: 4px; vertical-align: middle; margin-right: 8px; }

/* Photographs and video as a strip of previews. A row of filenames tells you
   nothing about which photo is which; a thumbnail tells you at a glance. */
.attachment-grid {
  list-style: none; padding: 0; margin: 10px 0 4px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 12px;
}
.attachment-tile {
  display: block; border: 1px solid #e3e7ee; border-radius: 8px; overflow: hidden;
  background: #f6f8fb; text-decoration: none; color: inherit;
}
.attachment-tile:hover { border-color: var(--accent); text-decoration: none; }
.attachment-tile img {
  display: block; width: 100%; height: 104px; object-fit: cover; background: #e9edf3;
}
.attachment-video {
  display: flex; align-items: center; justify-content: center;
  height: 104px; font-size: 30px; color: #fff; background: #384252;
}
.attachment-caption {
  display: block; padding: 6px 8px; font-size: 12px; line-height: 1.3;
  overflow-wrap: anywhere; color: #4a515b;
}
.attachment-save { font-size: 11.5px; display: inline-block; margin-top: 3px; }

/* Full-screen viewer. Built in app.js and appended to the body, so it is not
   trapped inside the section that HTMX swaps out from under it. */
.lightbox {
  position: fixed; inset: 0; z-index: 100; display: flex;
  align-items: center; justify-content: center; flex-direction: column;
  background: rgba(12, 16, 22, .92); padding: 12px;
}
.lightbox[hidden] { display: none !important; }
/* The frame takes whatever height the bar leaves, rather than the media being
   sized against a guessed bar height that changes when the name wraps. */
.lightbox-frame {
  flex: 1; min-height: 0; width: 100%;
  display: flex; align-items: center; justify-content: center;
}
.lightbox img, .lightbox video {
  max-width: 100%; max-height: 100%;
  object-fit: contain; border-radius: 6px; background: #000;
}
.lightbox-bar {
  display: flex; align-items: center; justify-content: flex-end;
  flex-wrap: wrap; gap: 8px 16px;
  width: 100%; max-width: 900px; padding: 12px 6px 4px;
  color: #eef1f5; font-size: 13.5px;
}
/* Wide enough and it all sits on one line; on a phone the filename claims the
   first line and the buttons drop below it, rather than being squeezed. */
.lightbox-name { flex: 1 1 240px; }
.lightbox-bar a { color: #8fd8ff; }
.lightbox-close {
  background: rgba(255,255,255,.16); color: #fff; border: none; border-radius: 8px;
  padding: 10px 16px; font: inherit; font-weight: 600; cursor: pointer; min-height: 44px;
}
.lightbox-name { overflow-wrap: anywhere; }

/* The native file input is a poor target on a phone and its label cannot be
   styled, so it is hidden inside a proper button-sized label. Hidden with
   opacity rather than display:none — a display:none input is skipped by some
   mobile browsers and by the keyboard. */
.attach-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 14px; }
.file-pick { position: relative; overflow: hidden; display: inline-flex; align-items: center; margin: 0; }
.file-pick input[type=file] {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; cursor: pointer;
}
.file-chosen { font-size: 13px; color: #6a7078; }
.attach-hint { flex-basis: 100%; font-size: 12px; color: #7a808a; }

/* ---------- admin ---------- */
.admin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.admin-tile { display: block; background: #fff; border: 1px solid #e3e7ee; border-radius: 10px; padding: 18px; }
.admin-tile:hover { border-color: var(--accent); text-decoration: none; }
.admin-tile b { color: var(--primary); display: block; margin-bottom: 6px; }
details.row-editor { border-bottom: 1px solid #eef1f5; padding: 8px 0; }
details.row-editor summary { cursor: pointer; font-weight: 600; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 4px 14px; }

/* ---------- phones and small tablets ----------
   860px rather than 720: the bar runs out of room for five links plus the
   user's name well before a phone's width, and on an iPhone the last items
   were being cut off entirely. */
@media (max-width: 860px) {
  .navbar { flex-wrap: wrap; gap: 10px; padding: 8px 14px; }
  .navbar-brand { font-size: 16px; }
  .nav-toggle { display: inline-flex; }

  /* Stacked, and collapsed ONLY once app.js has added .nav-collapsible.
     Hiding it unconditionally would mean that if app.js failed to load — a
     bad deploy, a cached 404, JavaScript off — there would be no menu at all
     and no way to reach one. The panel stays open unless something is there
     to open it again. */
  .navbar-panel {
    display: flex; flex-basis: 100%; flex-direction: column;
    align-items: stretch; gap: 4px; padding-bottom: 6px;
  }
  .navbar.nav-collapsible .navbar-panel { display: none; }
  .navbar.nav-collapsible.nav-open .navbar-panel { display: flex; }
  .navbar-menu { flex-direction: column; gap: 2px; }
  /* 44px is the smallest reliably tappable target on a phone. */
  .navbar-menu a { padding: 12px 14px; min-height: 44px; display: flex; align-items: center; }
  .navbar-user {
    justify-content: space-between; padding: 12px 14px; min-height: 44px;
    border-top: 1px solid rgba(255,255,255,.18); margin-top: 6px; font-size: 14px;
  }

  .container { margin: 12px auto; padding: 0 14px; }

  /* One field per row — two columns at 280px each never fitted a phone, so
     the second column was being squeezed to nothing. */
  .field-grid { grid-template-columns: 1fr; }
  .section-body { padding: 14px 14px 18px; }
  .section-header { padding: 12px 14px; font-size: 16px; }

  /* Wide tables scroll sideways inside their card instead of forcing the
     whole page sideways. */
  .card { padding: 14px; overflow-x: auto; }
  table.data { min-width: 560px; }

  /* Comfortable tap targets and no iOS auto-zoom: Safari zooms the page when
     it focuses an input whose text is under 16px. */
  input[type=text], input[type=number], input[type=date], input[type=email],
  input[type=password], select, textarea { font-size: 16px; padding: 10px 12px; }
  .btn { padding: 11px 18px; min-height: 44px; }
  .btn-sm { padding: 9px 14px; min-height: 40px; }
  .actions-row { gap: 8px; }
}


/* ---- Forms module ---------------------------------------------------- */


* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

/* Focus is always visible — never removed for aesthetics (PRD NFR-ACC-2). */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

a { color: var(--accent); }
a:hover { color: var(--primary); }

/* Skip link: first tab stop on every page. */
.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--surface); color: var(--primary);
  padding: .75rem 1rem; z-index: 100; font-weight: bold;
}
.skip-link:focus { left: 0; }
.container-narrow { max-width: 460px; }

h1, h2, h3 { color: var(--primary); line-height: 1.25; }
h1 { font-size: 1.65rem; margin: 0 0 1rem; }
h2 { font-size: 1.3rem; margin: 1.75rem 0 .75rem; }

.muted { color: var(--muted); font-size: .9rem; }

/* ---------- Forms ---------- */
.field { margin-bottom: 1.1rem; }
/* The label above an input — but never the label *wrapping* a checkbox or radio.
   `.field label` scores 0,1,1 and `.checkbox` only 0,1,0, so the group labels
   used to come out bold, block and carrying a .3rem bottom margin that
   `.checkbox`'s `font-weight: normal` could not win against however it was
   ordered. Excluded by :not() rather than by `>` because geolocation and the
   audit filters nest their labels a level deeper inside .field. */
.field label:not(.checkbox):not(.radio) {
  display: block; font-weight: bold; margin-bottom: .3rem;
}
.field .help { display: block; color: var(--muted); font-size: .85rem; margin-bottom: .35rem; }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=datetime-local], input[type=url], textarea, select {
  width: 100%; padding: .6rem .7rem; font: inherit; color: var(--text);
  background: #fff; border: 1px solid #b6c0c7; border-radius: var(--radius);
  min-height: 44px;                      /* touch target (PRD MO-1) */
}
textarea { min-height: 7rem; }
.btn-block { display: block; width: 100%; }

/* Mandatory marker carries text as well as colour (PRD NFR-ACC-3). */
.required-marker { color: var(--danger); font-weight: bold; }
.required-note { font-size: .85rem; color: var(--muted); }

/* ---------- Messages: icon + text, never colour alone ---------- */
.message { padding: .8rem 1rem; border-radius: var(--radius); margin-bottom: 1rem;
           border-left: 5px solid; display: flex; gap: .6rem; align-items: flex-start; }
.message .label { font-weight: bold; }
.message-error   { background: var(--danger-bg);  border-color: var(--danger);  color: #7f1d1d; }
.message-success { background: var(--success-bg); border-color: var(--success); color: #1b4d1f; }
.message-warning { background: var(--warning-bg); border-color: var(--warning); color: #7a3e00; }

/* ---------- Tables: TTConfirm's minimalistBlack, white on dark header ------- */
table.minimalistBlack {
  border: 1px solid var(--primary); width: 100%; border-collapse: collapse;
  background: var(--surface);
}
table.minimalistBlack td, table.minimalistBlack th {
  border: 1px solid var(--primary); padding: .6rem .8rem; text-align: left;
}
table.minimalistBlack thead th { background: var(--primary); color: #fff; font-weight: bold; }
table.minimalistBlack tbody tr:nth-child(even) { background: #f6f8fa; }
.table-scroll { overflow-x: auto; }        /* wide tables scroll, the page never does */

/* ---------- MFA ---------- */
.qr { background: #fff; padding: 1rem; border: 1px solid var(--border);
      display: inline-block; border-radius: var(--radius); }
.qr svg { display: block; width: 200px; height: 200px; }
.secret-key { font-family: monospace; font-size: 1.05rem; letter-spacing: .08em;
              background: var(--bg); padding: .5rem .7rem; border-radius: var(--radius);
              word-break: break-all; display: inline-block; }
.code-list { font-family: monospace; font-size: 1.05rem; columns: 2; list-style: none;
             padding: 0; margin: 1rem 0; }
.code-list li { padding: .25rem 0; break-inside: avoid; }
input.code-input { font-family: monospace; font-size: 1.3rem; letter-spacing: .3em;
                   text-align: center; }

.login-header { text-align: center; margin-bottom: 1.5rem; }
.login-header img { max-height: 56px; width: auto; }

.divider { display: flex; align-items: center; gap: .75rem; margin: 1.25rem 0;
           color: var(--muted); font-size: .85rem; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ---------- Mobile: single column below 768px (PRD MO-1) ---------- */
@media (max-width: 768px) {
  .navbar { padding: .5rem 1rem; }
  .navbar-menu { order: 3; width: 100%; gap: 1rem; }
  .container { padding: 1rem .9rem 2.5rem; }
  .card { padding: 1.1rem; }
  .code-list { columns: 1; }
}

/* ---------- Accessibility helpers ---------- */
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Form rendering (preview and fill) ---------- */
.form-section { background: var(--surface); border: 1px solid var(--border);
                border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.25rem; }
.form-section h2 { margin-top: 0; }
.section-toggle { background: none; border: 0; font: inherit; color: var(--primary);
                  cursor: pointer; padding: 0; display: flex; gap: .5rem; align-items: center; }
.display-field { background: #f6f8fa; border-left: 4px solid var(--accent);
                 padding: .8rem 1rem; margin-bottom: 1.1rem; border-radius: var(--radius); }
.display-label { margin: 0 0 .4rem; font-size: 1rem; }
.display-content img { max-width: 100%; height: auto; }
.display-content svg { max-width: 260px; height: auto; }
.markdown-preview { border: 1px dashed var(--border); padding: .6rem;
                    margin-top: .4rem; min-height: 2rem; border-radius: var(--radius); }
.input-prefix { display: flex; align-items: stretch; }
.input-prefix .prefix { background: var(--bg); border: 1px solid #b6c0c7; border-right: 0;
                        padding: .6rem .7rem; display: flex; align-items: center;
                        border-radius: var(--radius) 0 0 var(--radius); font-weight: bold; }
.input-prefix input { border-radius: 0 var(--radius) var(--radius) 0; }
.radio-row { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.radio, .checkbox { display: flex; align-items: center; gap: .45rem;
                    font-weight: normal; margin: 0; min-height: 44px; }
.checkbox-group { display: flex; flex-direction: column; gap: .2rem; }

/* 44px rows exist for fingers (PRD MO-1). On a pointer device they are simply
   dead space — a four-role list runs to 200px of mostly nothing — so the rows
   tighten where the requirement does not apply. 28px keeps the target above the
   24px WCAG 2.5.8 minimum, and the whole row is clickable, not just the box. */
@media (pointer: fine) {
  .radio, .checkbox { min-height: 28px; }
  .checkbox-group { gap: 0; }
}
.geo-row { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: .6rem; }
.geo-row > div { flex: 1; min-width: 140px; }
fieldset.field { border: 1px solid var(--border); border-radius: var(--radius);
                 padding: .8rem 1rem; margin-bottom: 1.1rem; }
fieldset.field legend { font-weight: bold; padding: 0 .4rem; }

/* Forms nested in a table cell — the per-row editors on Admin → Users and
   Admin → Roles. The row border already separates one control from the next, so
   full form spacing on top of it reads as a gap rather than as structure. */
td .field { margin-bottom: .55rem; }
td fieldset.field { padding: .45rem .7rem; margin-bottom: .55rem; }
td fieldset.field legend { font-size: .9rem; }
td .field .help { margin-bottom: .2rem; }
td details { margin-top: .5rem; }
td details > summary { padding: .2rem 0; }

/* Errors carry text and an icon, never colour alone (PRD NFR-ACC-3). */
.field-error input, .field-error textarea, .field-error select { border-color: var(--danger); border-width: 2px; }
.field-error-text { display: block; color: var(--danger); font-size: .875rem;
                    font-weight: bold; margin-top: .25rem; }
.field-error-text::before { content: "⚠ "; }

/* ---------- Builder ---------- */
.builder-actions { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center;
                   margin-bottom: 1.25rem; }
.builder-section { background: var(--surface); border: 1px solid var(--border);
                   border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
.builder-section-head { display: flex; justify-content: space-between;
                        align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.builder-section-head h3 { margin: 0; }
.builder-section.dragging { opacity: .45; }
.section-title { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.builder-fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.field-list { list-style: none; padding: 0; margin: .75rem 0; }
.field-row { border: 1px solid var(--border); border-radius: var(--radius);
             padding: .5rem .7rem; margin-bottom: .4rem; background: #fbfcfd; }
.field-row.dragging { opacity: .45; }
.field-row.retired { opacity: .6; }
.field-row-head { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.field-row-label { font-weight: bold; flex: 1; min-width: 8rem; }
.drag-handle { cursor: grab; color: var(--muted); font-size: 1.1rem; }
.field-key { background: var(--bg); padding: .1rem .4rem; border-radius: 3px;
             font-size: .8rem; }
.chip-display { background: var(--muted); }
.move-controls { display: flex; gap: .2rem; }
.icon-button { min-width: 34px; min-height: 34px; border: 1px solid var(--border);
               background: #fff; border-radius: var(--radius); cursor: pointer;
               color: var(--primary); }
.icon-button:disabled { opacity: .35; cursor: not-allowed; }
.link-button { background: none; border: 0; padding: 0; font: inherit;
               color: var(--accent); text-decoration: underline; cursor: pointer;
               min-height: 44px; }
.link-button.danger { color: var(--danger); }
.field-properties summary, .builder-section-head details summary {
  cursor: pointer; color: var(--accent); padding: .4rem 0; }
.add-field { display: flex; gap: .5rem; align-items: flex-end; flex-wrap: wrap; }
.add-field select { width: auto; min-width: 14rem; }
.add-field label { display: block; font-weight: bold; }

@media (max-width: 768px) {
  .builder-actions { flex-direction: column; align-items: stretch; }
  .geo-row { flex-direction: column; }
}

/* ---------- Library ---------- */
.card-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.form-card { background: var(--surface); border: 1px solid var(--border);
             border-radius: var(--radius); padding: 1.1rem; }
.form-card h3 { margin: 0 0 .4rem; }
.form-card h4 { margin: 1rem 0 .3rem; font-size: .9rem; color: var(--muted); }
.mini-list { list-style: none; padding: 0; margin: 0; }
.mini-list li { padding: .3rem 0; display: flex; gap: .5rem; align-items: center;
                flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.mini-list li:last-child { border-bottom: 0; }
.chip-draft { background: var(--muted); }
.chip-submitted { background: var(--success); }
.chip-amended { background: var(--warning); }

/* ---------- Filling in ---------- */
.save-state { font-size: .85rem; color: var(--muted); }
.save-ok { color: var(--success); font-weight: bold; }
.save-warn { color: var(--warning); font-weight: bold; }
.save-failed { color: var(--danger); font-weight: bold; }
.attachment { gap: .6rem; }
.thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 3px;
         border: 1px solid var(--border); }

/* ---------- Viewing ---------- */
.value-row { display: flex; gap: 1rem; padding: .55rem 0;
             border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.value-row:last-child { border-bottom: 0; }
.value-label { font-weight: bold; flex: 0 0 240px; }
.value-content { flex: 1; min-width: 12rem; }

/* ---------- Lists ---------- */
.filter-row { display: flex; gap: .8rem; flex-wrap: wrap; align-items: flex-end; }
.filter-row .field { margin-bottom: 0; flex: 1; min-width: 150px; }
.pagination { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: 1rem; }
.pagination a, .pagination .current { padding: .45rem .75rem; border: 1px solid var(--border);
                                      border-radius: var(--radius); text-decoration: none;
                                      min-width: 44px; text-align: center; }
.pagination .current { background: var(--primary); color: #fff; font-weight: bold; }

@media (max-width: 768px) {
  .value-label { flex: 1 1 100%; }
  .filter-row .field { min-width: 100%; }
}

/* ---------- Offline ---------- */
.offline-banner { padding: .7rem 1rem; font-size: .92rem; text-align: center;
                  border-bottom: 1px solid var(--border); }
.offline-banner.hidden { display: none; }
.offline-banner.offline { background: var(--warning-bg); color: #7a3e00;
                          border-bottom-color: var(--warning); }
.offline-banner.syncing { background: #e3f2fd; color: #0d3c61;
                          border-bottom-color: var(--focus); }
.offline-banner.warn { background: var(--danger-bg); color: #7f1d1d;
                       border-bottom-color: var(--danger); }
.offline-banner a { color: inherit; font-weight: bold; }

/* Offline-only forms are still fillable; anything needing the network is not. */
body.is-offline .needs-network { opacity: .5; pointer-events: none; }
.form-card.offline-ready::after { content: "Available offline"; display: block;
                                  margin-top: .5rem; font-size: .78rem;
                                  color: var(--success); font-weight: bold; }

/* Admin menu in the navigation bar (stage 1.9). A <details> rather than a
   scripted dropdown: it works before Alpine loads, works with JavaScript off,
   and is keyboard-operable without any ARIA of our own. */
.nav-menu { position: relative; display: inline-block; }
.nav-menu > summary { cursor: pointer; list-style: none; color: #fff; }
.nav-menu > summary::-webkit-details-marker { display: none; }
.nav-menu > summary::after { content: " ▾"; }
.nav-menu > summary:hover, .nav-menu > summary:focus-visible { text-decoration: underline; }
.nav-menu-items {
  position: absolute; z-index: 40; top: 1.9rem; left: 0; min-width: 12rem;
  background: var(--primary); border: 1px solid rgba(255,255,255,.25);
  border-radius: var(--radius); padding: .5rem 0; display: flex; flex-direction: column;
  box-shadow: 0 6px 18px rgba(0,0,0,.25);
}
.nav-menu-items a { padding: .4rem 1rem; }
@media (max-width: 700px) {
  /* On a phone the bar already wraps; a floating panel would sit over content. */
  .nav-menu-items { position: static; box-shadow: none; border: 0; padding: .25rem 0 .25rem 1rem; }
}

/* Sortable table headings (submissions list). The heading itself is the link, so
   the whole cell is the target rather than a few words inside it. */
.minimalistBlack th a.sort-link { color: #fff; text-decoration: none;
  display: flex; align-items: center; gap: .4rem; justify-content: space-between; }
.minimalistBlack th a.sort-link:hover,
.minimalistBlack th a.sort-link:focus-visible { text-decoration: underline; color: #fff; }
/* The inactive indicator is dimmed rather than hidden: a control that appears
   only on hover is invisible to anyone on a touch screen or a keyboard. */
.sort-arrow { font-size: .8em; opacity: .45; }
.sort-current .sort-arrow { opacity: 1; }

/* Repeatable sections (stage 2.5). Each row is boxed so it reads as one record
   rather than as a run of unrelated fields. */
.repeat-row { border: 1px solid var(--border); border-radius: var(--radius);
              padding: .9rem 1rem .3rem; margin-bottom: .9rem; background: #fbfcfd; }
.repeat-row-heading { margin: 0 0 .7rem; font-size: 1rem; color: var(--primary); }
.repeat-controls { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center;
                   margin-bottom: .5rem; }

/* Display rules in the builder (stage 2.2). */
.rule-row { background: var(--bg); border-left: 3px solid var(--accent);
            padding: .4rem .7rem; margin: .3rem 0; border-radius: var(--radius); }
/* ---------------------------------------------------------------------------
   List views: the cards/list switch and the column picker.

   Both lists in the Forms module (the library and the submissions list) share
   these. Everything here works with scripting off — `<details>` opens the
   picker, and the picker is a plain GET form — for the same reason the sort
   links are anchors: this module is used on site, on whatever browser is to
   hand.
   --------------------------------------------------------------------------- */
.list-toolbar { display: flex; gap: 1rem; flex-wrap: wrap;
                align-items: flex-start; justify-content: space-between;
                margin-bottom: 1rem; }

.view-switch { display: flex; gap: .4rem; }
/* The current view is marked by weight and a filled background, not by colour
   alone, and carries aria-current in the markup. */
.view-switch .is-current { background: var(--primary); color: #fff;
                           border-color: var(--primary); font-weight: bold; }

.column-picker { border: 1px solid var(--border); border-radius: var(--radius);
                 background: var(--surface); }
.column-picker > summary { cursor: pointer; padding: .55rem .9rem;
                           font-weight: bold; min-height: 44px;
                           display: flex; align-items: center; gap: .4rem; }
.column-picker > summary .muted { font-weight: normal; }
.column-picker-form { padding: 0 .9rem .9rem; }
.column-picker fieldset { border: 0; padding: 0; margin: 0; }
.column-picker-list { list-style: none; padding: 0; margin: 0 0 .8rem;
                      display: grid; gap: .1rem;
                      grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.column-picker-list .checkbox { align-items: flex-start; padding: .3rem 0; }
.column-picker-list .checkbox input { margin-top: .25rem; }
.column-picker-list .help { display: block; }
/* A fixed column is shown disabled rather than omitted: leaving it out would
   read as an oversight, and dimming it says "this one is not yours to turn
   off" without pretending the choice exists. */
.column-picker-list .is-fixed { opacity: .65; }
.column-picker-actions { display: flex; gap: .8rem; flex-wrap: wrap;
                         align-items: center; }

/* The action cell. Without nowrap the button wraps to two lines as soon as the
   table is narrow, which reads as a broken control rather than a tight column. */
.cell-action { white-space: nowrap; }

/* Numbers right-aligned so columns of counts can be compared down the page;
   prose capped so one long description cannot push every other column off. */
.cell-number { text-align: right; font-variant-numeric: tabular-nums; }
.cell-prose { max-width: 32em; }

/* A retired lookup value still listed, so it can be brought back. Struck
   through *and* labelled in words in its own cell — never styling alone. */
.row-retired { opacity: .7; }
.row-retired code { text-decoration: line-through; }
