/* RSUTH ID Card System — one stylesheet for every page. Served from 'self' (CSP).
   Layout: full-width fluid pages (max 1280px), white branded header, faint logo
   watermark behind every page; colours taken from the RSUTH shield logo. */
:root {
  /* From the logo: sky #00AFF0, mid blue #4587C4, caduceus red. Text colours are
     darkened versions so small text keeps AA contrast on white. */
  --navy: #0b3a66;        /* headings, header text */
  --blue: #2c6aa8;        /* links, buttons (the logo's mid blue, darkened for contrast) */
  --blue-logo: #4587c4;   /* the logo's mid blue: borders, icons */
  --sky: #00aff0;         /* the logo's sky blue: highlights, the header strip */
  --sky-soft: #e3f5fd;
  --blue-soft: #eaf2fa;
  --bg: #f4f8fc;
  --sheet: #ffffff;
  --ink: #12263a;
  --muted: #4f6478;
  --rule: #d5e2ee;
  --red: #c8202a;         /* the caduceus red: required marks, errors */
  --ok: #1d7a3e; --ok-soft: #e2f4e8;
  --warn: #8a5a00; --warn-soft: #fdf3dc;
  --bad: #b3261e; --bad-soft: #fde7e5;
  --accent: var(--blue); --accent-ink: #fff; --accent-soft: var(--blue-soft);
  --radius: 12px;
  --shadow: 0 1px 2px rgba(11, 58, 102, .06), 0 4px 16px rgba(11, 58, 102, .06);
  --shadow-lift: 0 2px 4px rgba(11, 58, 102, .08), 0 12px 28px rgba(11, 58, 102, .12);
  --page: 1280px;
  font: 16px/1.55 "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  /* Surfaces and states that change with the theme. */
  --on-blue: #ffffff;           /* text on blue buttons */
  --btn-hover: #0b3a66;
  --field-bg: #ffffff;
  --field-border: #b8cbdc;
  --fieldset-bg: rgba(255, 255, 255, .7);
  --tab-hover: #dcebf8;
  --row-hover: #f7fbff;
  --watermark: .055;
  color-scheme: light;
}
/* Dark theme: follows the device unless the header button has chosen one (data-theme). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
  --navy: #e6f0fa; --blue: #5aaef0; --blue-logo: #4f97d6; --sky: #2dc0f5;
  --sky-soft: #0f3046; --blue-soft: #16304a; --bg: #0a1520; --sheet: #112131;
  --ink: #dfe9f3; --muted: #9db2c6; --rule: #243a50; --red: #ff6b6b;
  --ok: #6fd18f; --ok-soft: #10301c; --warn: #f0c062; --warn-soft: #382b10; --bad: #ff8a80; --bad-soft: #3a1714;
  --accent-soft: var(--blue-soft);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  --shadow-lift: 0 2px 4px rgba(0, 0, 0, .35), 0 12px 28px rgba(0, 0, 0, .4);
  --on-blue: #04131f; --btn-hover: #8cc8f5;
  --field-bg: #0d1a27; --field-border: #33506b; --fieldset-bg: rgba(17, 33, 49, .6);
  --tab-hover: #1b3a57; --row-hover: #16283a; --watermark: .07;
  color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --navy: #e6f0fa; --blue: #5aaef0; --blue-logo: #4f97d6; --sky: #2dc0f5;
  --sky-soft: #0f3046; --blue-soft: #16304a; --bg: #0a1520; --sheet: #112131;
  --ink: #dfe9f3; --muted: #9db2c6; --rule: #243a50; --red: #ff6b6b;
  --ok: #6fd18f; --ok-soft: #10301c; --warn: #f0c062; --warn-soft: #382b10; --bad: #ff8a80; --bad-soft: #3a1714;
  --accent-soft: var(--blue-soft);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  --shadow-lift: 0 2px 4px rgba(0, 0, 0, .35), 0 12px 28px rgba(0, 0, 0, .4);
  --on-blue: #04131f; --btn-hover: #8cc8f5;
  --field-bg: #0d1a27; --field-border: #33506b; --fieldset-bg: rgba(17, 33, 49, .6);
  --tab-hover: #1b3a57; --row-hover: #16283a; --watermark: .07;
  color-scheme: dark;
}
@media (max-width: 640px) { :root { font-size: 15px; } }
/* The header keeps its own fixed sizes (px), so changing the body size above never changes it. */

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); min-height: 100vh; display: flex; flex-direction: column; position: relative; }
/* The RSUTH shield, faint, behind every page. */
body::before {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: url("/assets/rsuth-logo.png") no-repeat center 58% / min(62vmin, 560px) auto;
  opacity: var(--watermark);
}
body > * { position: relative; z-index: 1; }
a { color: var(--blue); text-underline-offset: 2px; }
a:hover { color: var(--navy); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .ptab:focus-visible, .tile:focus-visible {
  outline: 3px solid var(--sky); outline-offset: 2px;
}

/* ---------- header ---------- */
.topbar { background: var(--sheet); border-bottom: 1px solid var(--rule); }
.topbar::after { content: ""; display: block; height: 4px; background: linear-gradient(90deg, #00aff0, #4587c4 60%, #0b3a66); }
.topbar-inner {
  max-width: var(--page); margin: 0 auto; padding: 10px max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px));
  /* Logo left, menu centred, sign-in + theme button right. */
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px 28px; align-items: center;
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--navy); text-decoration: none; min-width: 0; justify-self: start; }
.brand img { height: 56px; width: auto; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-title { font-size: 22px; font-weight: 800; letter-spacing: .01em; }
.brand-sub { font-size: 13.5px; color: var(--muted); font-weight: 500; }
.nav { display: flex; justify-content: center; gap: 18px; overflow-x: auto; scrollbar-width: none; min-width: 0; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  color: var(--navy); text-decoration: none; padding: 8px 14px; border-radius: 999px; font-size: 16px; font-weight: 600; white-space: nowrap;
  transition: background .15s, color .15s;
}
.nav a:hover { background: var(--blue-soft); }
.nav a[aria-current="page"] { background: var(--blue); color: var(--on-blue); }
.who { font-size: 15px; display: flex; gap: 12px; align-items: center; color: var(--muted); justify-self: end; }
.who form { margin: 0; }
.who button, .who .signin {
  background: var(--sheet); color: var(--blue); border: 1.5px solid var(--blue); border-radius: 999px; padding: 6px 16px;
  font-family: inherit; font-weight: 600; font-size: 15px; line-height: 1.2; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.who button:hover, .who .signin:hover { background: var(--blue); color: var(--on-blue); }
/* Light / dark switch (like the Research Fair App): moon in light mode, sun in dark mode. */
.who .theme-toggle {
  width: 40px; height: 40px; padding: 0; display: inline-grid; place-items: center; border-radius: 50%;
  background: transparent; color: var(--navy); border: 1.5px solid var(--rule);
}
.who .theme-toggle:hover { background: var(--blue-soft); color: var(--navy); }
.theme-toggle svg { width: 20px; height: 20px; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}
@media (max-width: 760px) {
  /* Phones: logo + sign-in on one row, menu on the next. */
  .topbar-inner { display: flex; flex-wrap: wrap; gap: 6px 12px; padding-top: 8px; padding-bottom: 6px; }
  .brand { flex: 1; }
  .brand img { height: 44px; }
  .brand-title { font-size: 18px; }
  .who { margin-left: 0; }
  .who .who-name { display: none; }
  .who button, .who .signin { padding: 6px 12px; font-size: 14px; }
  .nav { order: 3; flex-basis: 100%; margin: 0 -6px; justify-content: flex-start; gap: 6px; }
  .who .theme-toggle { width: 36px; height: 36px; }
  .nav a { padding: 7px 12px; }
}
@media (max-width: 640px) { .brand-sub { font-size: 13px; } .nav a { font-size: 15px; } }
@media (max-width: 420px) { .brand-sub { display: none; } }

/* ---------- page ---------- */
main {
  width: 100%; max-width: var(--page); margin: 0 auto; flex: 1;
  padding: 28px max(16px, env(safe-area-inset-right, 0px)) 72px max(16px, env(safe-area-inset-left, 0px));
  display: flex; flex-direction: column; gap: 22px;
}
h1 { font-size: clamp(1.75rem, 1.2rem + 2vw, 2.5rem); line-height: 1.15; margin: 0; color: var(--navy); text-wrap: balance; letter-spacing: -.01em; }
h2 { font-size: 1.3rem; margin: 0 0 8px; color: var(--navy); }
h3 { font-size: 1.1rem; margin: 0 0 6px; color: var(--navy); }
.lede { color: var(--muted); margin: 0; max-width: 68ch; font-size: 1.06rem; }
.sheet { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius); padding: 22px 24px; min-width: 0; box-shadow: var(--shadow); }
@media (max-width: 640px) { .sheet { padding: 16px; } }
.narrow { max-width: 560px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; }

.flash { border-radius: var(--radius); padding: 12px 16px; font-size: .95rem; border-left: 5px solid currentColor; }
.flash.ok { background: var(--ok-soft); color: var(--ok); }
.flash.error { background: var(--bad-soft); color: var(--bad); }
.flash.info { background: var(--blue-soft); color: var(--blue); }

/* ---------- forms ---------- */
form.stack { display: flex; flex-direction: column; gap: 18px; }
fieldset { border: 1px solid var(--rule); border-radius: var(--radius); padding: 16px 18px; margin: 0; display: flex; flex-direction: column; gap: 14px; background: var(--fieldset-bg); }
legend { font-weight: 700; padding: 0 8px; color: var(--navy); font-size: 1.05rem; }
label { font-weight: 600; font-size: .95rem; display: block; margin-bottom: 6px; }
.hint { font-weight: 400; color: var(--muted); font-size: .85rem; }
input[type=text], input[type=email], input[type=tel], input[type=password], input[type=number], input[type=search], input[type=date], select, textarea {
  width: 100%; padding: 11px 13px; font: inherit; font-size: 1rem; color: var(--ink); background: var(--field-bg);
  border: 1.5px solid var(--field-border); border-radius: 8px; transition: border-color .15s, box-shadow .15s;
}
input:hover, select:hover, textarea:hover { border-color: var(--blue-logo); }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 4px var(--sky-soft); outline: none; }
input[type=file] { font: inherit; font-size: .95rem; max-width: 100%; }
input[type=file]::file-selector-button {
  font-family: inherit; font-weight: 600; font-size: .9rem; color: var(--blue); background: var(--blue-soft); border: 1.5px solid var(--blue-logo);
  border-radius: 8px; padding: 8px 14px; margin-right: 12px; cursor: pointer;
}
input[type=radio], input[type=checkbox] { width: 1.15rem; height: 1.15rem; accent-color: var(--blue); flex: none; }
textarea { min-height: 84px; }
.choice { display: flex; flex-wrap: wrap; gap: 10px 22px; }
.choice label { font-weight: 500; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; margin: 0; }
.choice label .hint { white-space: nowrap; }
.field-error { color: var(--bad); font-size: .85rem; margin-top: 6px; font-weight: 600; }
.req { color: var(--red); font-weight: 800; }
.required-note {
  margin: 0; font-size: .95rem; background: var(--sky-soft); color: var(--navy); border-radius: var(--radius);
  padding: 10px 14px; border-left: 5px solid var(--sky); max-width: 72ch;
}
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: var(--blue); color: var(--on-blue); border: 1.5px solid var(--blue);
  border-radius: 10px; padding: 12px 22px; font-family: inherit; font-weight: 700; font-size: 1rem; line-height: 1.2; cursor: pointer; text-decoration: none;
  transition: background .15s, transform .15s, box-shadow .15s; min-height: 46px;
}
.btn:hover { background: var(--btn-hover); border-color: var(--btn-hover); color: var(--on-blue); box-shadow: var(--shadow); }
.btn:active { transform: translateY(1px); }
.btn.secondary { background: var(--sheet); color: var(--blue); }
.btn.secondary:hover { background: var(--blue-soft); color: var(--navy); }
.btn.danger { background: var(--bad); border-color: var(--bad); }
.btn.warn { background: var(--warn); border-color: var(--warn); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
@media (max-width: 640px) { form .actions .btn { width: 100%; } }

/* ---------- graphical tabs: Request a card / Check status ---------- */
.ptabs { display: grid; grid-template-columns: 1fr 1fr; gap: 0; margin-bottom: -1px; }
.ptab {
  display: flex; align-items: center; gap: 14px; padding: 16px 20px; text-decoration: none; color: var(--navy);
  background: var(--blue-soft); border: 1px solid var(--rule); border-bottom-color: var(--rule);
  transition: background .15s, color .15s;
}
.ptab:first-child { border-radius: var(--radius) 0 0 0; }
.ptab:last-child { border-radius: 0 var(--radius) 0 0; border-left: 0; }
.ptab:hover { background: var(--tab-hover); color: var(--navy); }
.ptab[aria-current="page"] { background: var(--sheet); border-bottom-color: var(--sheet); box-shadow: inset 0 4px 0 var(--sky); }
.ptab-icon { flex: none; width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: var(--sheet); color: var(--blue); border: 1px solid var(--rule); }
.ptab[aria-current="page"] .ptab-icon { background: linear-gradient(135deg, #00aff0, #2c6aa8); color: #fff; border-color: transparent; }
.ptab-icon svg { width: 26px; height: 26px; }
.ptab-text { display: flex; flex-direction: column; min-width: 0; }
.ptab-title { font-weight: 800; font-size: 1.1rem; }
.ptab-sub { font-size: .85rem; color: var(--muted); }
.ptabs + .tab-panel { border-top-left-radius: 0; border-top-right-radius: 0; }
@media (max-width: 560px) {
  .ptab { flex-direction: column; text-align: center; gap: 6px; padding: 12px 8px; }
  .ptab-sub { display: none; }
  .ptab-icon { width: 40px; height: 40px; }
}

/* ---------- home ---------- */
.hero {
  display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 32px; align-items: center;
  background: linear-gradient(120deg, var(--sheet) 0%, var(--sheet) 45%, var(--sky-soft) 100%);
  border: 1px solid var(--rule); border-radius: 18px; padding: clamp(22px, 4vw, 48px); box-shadow: var(--shadow); overflow: hidden;
}
.hero-eyebrow { font-size: .8rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--blue); margin: 0 0 8px; }
.hero h1 { font-size: clamp(2rem, 1.3rem + 3vw, 3.2rem); }
.hero .lede { margin-top: 12px; font-size: 1.12rem; }
.hero-art { display: grid; place-items: center; }
.hero-art img { width: min(100%, 260px); height: auto; filter: drop-shadow(0 12px 24px rgba(11, 58, 102, .18)); }
@media (max-width: 760px) { .hero { grid-template-columns: 1fr; } .hero-art { display: none; } }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; }
.tile {
  display: flex; gap: 18px; align-items: flex-start; padding: 24px; text-decoration: none; color: var(--ink);
  background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow);
  border-top: 5px solid var(--sky); transition: transform .18s, box-shadow .18s, border-color .18s;
}
.tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); border-top-color: var(--blue); color: var(--ink); }
.tile-icon { flex: none; width: 60px; height: 60px; border-radius: 16px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #00aff0, #2c6aa8); }
.tile-icon svg { width: 32px; height: 32px; }
.tile h2 { margin-bottom: 4px; }
.tile p { margin: 0; color: var(--muted); }
.tile-go { display: inline-block; margin-top: 10px; font-weight: 700; color: var(--blue); }

.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; counter-reset: step; }
.steps li { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius); padding: 18px; counter-increment: step; position: relative; }
.steps li::before {
  content: counter(step); display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  background: var(--blue); color: var(--on-blue); font-weight: 800; margin-bottom: 10px;
}
.steps h3 { margin-bottom: 4px; }
.steps p { margin: 0; color: var(--muted); font-size: .95rem; }

/* ---------- data ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--rule); vertical-align: top; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; background: var(--blue-soft); }
tbody tr:hover { background: var(--row-hover); }
td.num, .mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-variant-numeric: tabular-nums; }

.pill { display: inline-block; font-size: .8rem; font-weight: 700; padding: 3px 11px; border-radius: 999px; background: var(--blue-soft); color: var(--blue); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }

dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0; }
dl.facts dt { color: var(--muted); font-size: .9rem; }
dl.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.photo { width: 150px; aspect-ratio: 4 / 5; object-fit: cover; border-radius: 10px; border: 1px solid var(--rule); max-width: 100%; background: var(--bg); }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.timeline li { border-left: 4px solid var(--sky); padding-left: 12px; }
.timeline li.superseded { border-left-color: var(--rule); color: var(--muted); }
.code-big {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: clamp(1.6rem, 1.1rem + 2vw, 2.2rem); letter-spacing: .06em;
  color: var(--navy); background: var(--sky-soft); border: 2px dashed var(--sky); border-radius: var(--radius); padding: 14px 18px; text-align: center; margin: 8px 0;
}
.verdict { border-radius: var(--radius); padding: 18px 20px; font-size: 1.15rem; font-weight: 700; border-left: 6px solid currentColor; }
.verdict.ok { background: var(--ok-soft); color: var(--ok); }
.verdict.bad { background: var(--bad-soft); color: var(--bad); }
.verdict.warn { background: var(--warn-soft); color: var(--warn); }

/* ---------- footer ---------- */
footer.foot { border-top: 1px solid var(--rule); background: var(--sheet); }
.foot-inner {
  max-width: var(--page); margin: 0 auto; padding: 16px max(16px, env(safe-area-inset-right, 0px)) calc(16px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; color: var(--muted); font-size: .85rem;
}
.foot-inner img { height: 28px; width: auto; }

/* Fixed prefix in front of an input (staff ID: RSUTH/PP/ + 4 digits) */
.prefixed { display: flex; align-items: stretch; }
.prefixed .prefix {
  display: flex; align-items: center; padding: 0 12px; background: var(--blue-soft); color: var(--navy); font-weight: 700;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; border: 1.5px solid var(--field-border); border-right: 0; border-radius: 8px 0 0 8px; white-space: nowrap;
}
.prefixed input { border-radius: 0 8px 8px 0; min-width: 0; letter-spacing: .08em; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }

/* Settings → Departments */
.dept-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 8px; align-items: start; }
.dept-list > li { border: 1px solid var(--rule); border-radius: 10px; background: var(--sheet); align-self: start; }
.dept-list summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; cursor: pointer; list-style: none; }
.dept-list summary::-webkit-details-marker { display: none; }
.dept-list summary::after { content: "▾"; color: var(--muted); }
.dept-list details[open] summary::after { content: "▴"; }
.dept-list details[open] { padding-bottom: 12px; }
.dept-list details[open] summary { border-bottom: 1px solid var(--rule); }
.dept-name { font-weight: 600; }
.rank-list { margin: 6px 0; padding: 0 10px 0 34px; display: flex; flex-direction: column; gap: 2px; }
.rank-list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: .92rem; }
.rank-add { padding: 6px 12px 0; flex-wrap: nowrap; }
.rank-add input { min-width: 0; }
.rank-add .btn { white-space: nowrap; flex: none; }
.dept-remove-form { padding: 8px 12px 0; text-align: right; }
.dept-list form { margin: 0; }
.dept-remove { background: none; border: 1px solid transparent; color: var(--bad); font: inherit; font-size: .85rem; font-weight: 600; padding: 4px 10px; border-radius: 8px; cursor: pointer; }
.dept-remove:hover { border-color: var(--bad); background: var(--bad-soft); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* Reprint fee note, shown only when "A replacement" is chosen */
.fee-note { margin: 0; padding: 10px 14px; border-radius: 10px; background: var(--warn-soft); color: var(--ink); border-left: 5px solid var(--warn); }

[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- Phase 3: collection, dashboard ---------- */
/* The signature pad stays white in both themes: the ink is dark and the PNG is kept as signed. */
.sigpad { display: block; width: 100%; max-width: 520px; aspect-ratio: 13 / 4; background: #fff; border: 1px dashed var(--field-border); border-radius: 8px; touch-action: none; cursor: crosshair; }
.check-list { display: flex; flex-direction: column; gap: 10px; }
.check-list label { font-weight: 400; display: flex; gap: 10px; align-items: flex-start; margin: 0; }
.check-list input { width: 20px; height: 20px; margin-top: 1px; flex: none; }
.photo-large { width: 200px; height: auto; align-self: flex-start; aspect-ratio: 4 / 5; object-fit: cover; border-radius: 8px; border: 1px solid var(--rule); max-width: 100%; background: var(--bg); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius); padding: 12px 14px; min-width: 0; }
.stat .n { display: block; font-size: 28px; font-weight: 700; color: var(--navy); font-variant-numeric: tabular-nums; line-height: 1.15; }
.stat .l { display: block; font-size: 13px; color: var(--muted); }
.stat.warn { border-color: var(--warn); }
.stat.warn .n { color: var(--warn); }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filters > div { min-width: 0; }
.filters label { font-size: 13px; }
.danger-zone { border-color: var(--bad); }
.role-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 6px 14px; }
.role-grid label { font-weight: 400; display: flex; gap: 8px; align-items: center; margin: 0; }
td.actions-cell form { display: inline; }
.check-list label > span { flex: 1; min-width: 0; }

/* ---------- officer sign-in: navy guidance panel + clean sign-in card ---------- */
/* Soft geometric shapes behind the split card; the logo watermark (body::before) still shows through. */
main:has(.auth-stage) { overflow-x: clip; }
.auth-stage { position: relative; flex: 1; display: grid; place-items: center; padding: 12px 0 8px; isolation: isolate; }
.auth-stage::before, .auth-stage::after {
  content: ""; position: absolute; z-index: -1; pointer-events: none;
  clip-path: polygon(25% 3%, 75% 3%, 100% 50%, 75% 97%, 25% 97%, 0 50%);
}
.auth-stage::before { width: 300px; height: 260px; left: -70px; top: -10px; background: linear-gradient(135deg, var(--sky-soft), transparent 75%); }
.auth-stage::after { width: 380px; height: 330px; right: -90px; bottom: -40px; background: linear-gradient(315deg, var(--blue-soft), transparent 75%); }
.auth {
  width: 100%; max-width: 1060px; display: grid; grid-template-columns: 1.08fr 1fr;
  background: var(--sheet); border: 1px solid var(--rule); border-radius: 20px; overflow: hidden; box-shadow: var(--shadow-lift);
}
/* The guidance panel stays navy in both themes. */
.auth-info {
  position: relative; color: #dce9f6; padding: 44px 44px 40px; display: flex; flex-direction: column; gap: 18px;
  background: url("/assets/hex-pattern.svg") no-repeat right -40px bottom -150px / 460px auto, linear-gradient(160deg, #0d3b68 0%, #0a2a4c 55%, #081d36 100%);
}
.auth-info h1 { color: #fff; font-size: clamp(1.6rem, 1.2rem + 1.4vw, 2.2rem); }
.auth-badge {
  margin: 0; align-self: flex-start; font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: #bfe9fb; background: rgba(0, 175, 240, .14); border: 1px solid rgba(0, 175, 240, .4); border-radius: 999px; padding: 5px 12px;
}
.auth-badge span { color: #00aff0; font-size: 10px; vertical-align: 2px; margin-right: 4px; }
.auth-lead { margin: 0; font-size: 1.02rem; color: #c3d6ea; max-width: 46ch; }
.auth-points { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 16px; }
.auth-points li { display: flex; gap: 14px; align-items: flex-start; font-size: .95rem; line-height: 1.5; }
.auth-points strong { color: #fff; }
.auth-icon {
  flex: none; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px;
  background: rgba(69, 135, 196, .22); border: 1px solid rgba(94, 200, 245, .35); color: #5ec8f5;
}
.auth-icon svg { width: 20px; height: 20px; }
.auth-foot { margin: auto 0 0; padding-top: 14px; border-top: 1px solid rgba(255, 255, 255, .12); font-size: .92rem; color: #c3d6ea; }
.auth-foot a { color: #5ec8f5; font-weight: 600; }
.auth-foot a:hover { color: #fff; }
.auth-panel { display: grid; place-items: center; padding: 44px 40px; }
.auth-card { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 14px; }
.auth-card h2 { font-size: 1.75rem; margin: 0; }
.auth-sub { margin: -8px 0 6px; color: var(--muted); }
.auth-card form.stack { gap: 16px; }
.password-field { position: relative; }
.password-field input { padding-right: 52px; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; display: grid; place-items: center;
  background: transparent; border: 0; border-radius: 8px; color: var(--muted); cursor: pointer;
}
.pw-toggle:hover { background: var(--blue-soft); color: var(--navy); }
.pw-toggle svg { width: 20px; height: 20px; }
.pw-toggle .eye-closed, .pw-toggle.is-showing .eye-open { display: none; }
.pw-toggle.is-showing .eye-closed { display: block; }
.auth-submit { width: 100%; margin-top: 4px; font-size: 1.05rem; }
.auth-help { border-top: 1px solid var(--rule); padding-top: 14px; font-size: .9rem; color: var(--muted); }
.auth-help p { margin: 0; }
.auth-help strong { color: var(--navy); }
@media (max-width: 860px) {
  /* Phones and small tablets: the sign-in card first, the guidance underneath. */
  .auth { grid-template-columns: 1fr; border-radius: 16px; }
  .auth-panel { order: -1; padding: 28px 20px; }
  .auth-info { padding: 28px 20px; background-size: 380px auto, auto; background-position: right -60px bottom -60px, 0 0; }
  .auth-stage::before, .auth-stage::after { display: none; }
}

/* ---------- officer side menu ---------- */
/* Signed-in officers: menu button + logo on the left, the side menu instead of header links.
   Wide screens: the menu sits beside the page (the button hides it, remembered).
   Phones (with JS): it slides over the page; without JS it simply sits above the page. */
.topbar-inner.officer { grid-template-columns: auto 1fr auto; max-width: none; gap: 8px 16px; }
.nav-toggle {
  width: 42px; height: 42px; padding: 0; display: inline-grid; place-items: center; flex: none; cursor: pointer;
  background: transparent; color: var(--navy); border: 1.5px solid var(--rule); border-radius: 10px;
}
.nav-toggle:hover { background: var(--blue-soft); }
.nav-toggle svg { width: 22px; height: 22px; }
.shell { flex: 1; display: flex; min-width: 0; }
.shell > main { min-width: 0; }
.sidenav { flex: none; width: 264px; background: var(--sheet); border-right: 1px solid var(--rule); }
.sidenav-inner {
  position: sticky; top: 0; max-height: 100vh; overflow-y: auto; padding: 16px 12px 20px;
  display: flex; flex-direction: column; gap: 10px;
}
.sidenav-head { display: flex; align-items: center; justify-content: space-between; padding: 0 12px; min-height: 32px; }
.sidenav-head > span { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.sidenav-close {
  width: 36px; height: 36px; padding: 0; display: grid; place-items: center; cursor: pointer;
  background: transparent; color: var(--navy); border: 0; border-radius: 8px;
}
.sidenav-close:hover { background: var(--blue-soft); }
.sidenav-close svg { width: 20px; height: 20px; }
.sidenav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.sidenav nav a, .sidenav summary {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; min-height: 44px;
  color: var(--navy); text-decoration: none; font-size: 15px; font-weight: 600; cursor: pointer; transition: background .15s, color .15s;
}
.sidenav nav a:hover, .sidenav summary:hover { background: var(--blue-soft); color: var(--navy); }
.sidenav nav a svg, .sidenav summary svg { width: 20px; height: 20px; flex: none; color: var(--blue-logo); }
.sidenav nav a[aria-current="page"] { background: var(--blue); color: var(--on-blue); box-shadow: var(--shadow); }
.sidenav nav a[aria-current="page"] svg { color: currentColor; }
.sidenav-more { margin-top: 2px; }
.sidenav summary { list-style: none; }
.sidenav summary::-webkit-details-marker { display: none; }
.sidenav summary .chev { margin-left: auto; width: 18px; height: 18px; transition: transform .2s; color: var(--muted); }
.sidenav-more[open] .chev { transform: rotate(180deg); }
.sidenav-more ul { margin: 4px 0 4px 22px; padding-left: 10px; border-left: 2px solid var(--rule); }
.sidenav-more a { font-weight: 500; font-size: 14.5px; padding: 8px 10px; min-height: 40px; }
.sidenav-user { display: none; }
@media (min-width: 1024px) {
  .nav-collapsed .sidenav { display: none; }
  .sidenav-close { display: none; }   /* the header's menu button hides it here */
}
@media (max-width: 1023.98px) {
  .shell { flex-direction: column; }
  .sidenav { width: auto; border-right: 0; border-bottom: 1px solid var(--rule); }
  .sidenav-inner { position: static; max-height: none; }
  /* With JS: a drawer over the page, closed until the menu button opens it. */
  .js .sidenav {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 50; width: min(300px, 86vw); border-bottom: 0;
    border-right: 1px solid var(--rule); box-shadow: var(--shadow-lift);
    transform: translateX(-100%); visibility: hidden; transition: transform .25s ease, visibility .25s;
  }
  .js.nav-open .sidenav { transform: none; visibility: visible; }
  .js .sidenav-inner { height: 100%; overflow-y: auto; padding-top: max(16px, env(safe-area-inset-top, 0px)); }
  .js .sidenav-user {
    display: flex; flex-direction: column; gap: 2px; margin-top: auto; padding: 14px 12px 0;
    border-top: 1px solid var(--rule); font-size: 13.5px; color: var(--muted);
  }
  .sidenav-user strong { color: var(--navy); font-size: 14.5px; }
  .sidenav-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(4, 19, 31, .5); }
  .topbar-inner.officer .nav-toggle { width: 40px; height: 40px; }
}

/* Users page: Delete asks "are you sure?" in place (a <details>, so no script is needed). */
.users-table td.actions-cell { min-width: 150px; }
.users-table td.actions-cell > * + * { margin-top: 8px; }
.users-table td.actions-cell form, .users-table td.actions-cell .confirm-delete { display: block; }
.confirm-delete > summary { list-style: none; }
.confirm-delete > summary::-webkit-details-marker { display: none; }
.confirm-delete[open] > summary { background: var(--sheet); color: var(--bad); }
.confirm-box {
  margin-top: 8px; padding: 10px 12px; max-width: 280px; font-size: .9rem; border-radius: 10px;
  background: var(--bad-soft); border: 1px solid var(--bad); display: flex; flex-direction: column; gap: 8px;
}
.confirm-box p { margin: 0; color: var(--ink); }

/* Reprint fee: where to pay and the receipt upload (Check status), receipts to check (Payments). */
.pay-box { border-top: 4px solid var(--sky); }
.pay-steps { margin: 0 0 6px; padding-left: 1.3rem; display: flex; flex-direction: column; gap: 12px; }
.pay-steps .hint { margin: 6px 0 0; }
.account {
  display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 8px 0 0; padding: 12px 16px;
  background: var(--sky-soft); border-radius: 10px; border-left: 5px solid var(--sky); max-width: 460px;
}
.account dt { color: var(--muted); }
.account dd { margin: 0; font-weight: 700; color: var(--navy); }
.account dd.mono { font-size: 1.15rem; letter-spacing: .04em; }
.facts.compact { margin-top: 8px; font-size: .9rem; }
.pay-actions { white-space: nowrap; }
.pay-actions .btn { margin: 0 0 6px; }

/* ---------- officer home: waiting work, the card journey, roles ---------- */
.hero-compact { grid-template-columns: 1fr; padding-bottom: 8px; }
.work { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.work-item {
  display: flex; flex-direction: column; gap: 4px; padding: 16px 18px; border-radius: var(--radius);
  background: var(--sheet); border: 1px solid var(--rule); border-left: 5px solid var(--sky);
  box-shadow: var(--shadow); color: var(--ink); text-decoration: none; transition: transform .15s, box-shadow .15s;
}
.work-item:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); color: var(--ink); }
.work-n { font-size: 2.3rem; font-weight: 800; line-height: 1; color: var(--navy); font-variant-numeric: tabular-nums; }
.work-l { font-weight: 600; }
.work-go { font-size: .85rem; font-weight: 700; color: var(--blue); }
.work-item.is-clear { border-left-color: var(--rule); box-shadow: none; }
.work-item.is-clear .work-n { color: var(--muted); }
.work-item.is-clear .work-go { color: var(--muted); font-weight: 600; }

.journey { margin-top: 24px; }
.journey-steps {
  list-style: none; margin: 16px 0 0; padding: 0 0 6px; display: flex; gap: 0; overflow-x: auto;
  scroll-snap-type: x proximity;
}
.journey-step { flex: 1 0 76px; position: relative; scroll-snap-align: start; }
.journey-step::before {   /* the line joining the steps */
  content: ""; position: absolute; top: 21px; left: 0; right: 0; height: 3px; background: var(--rule);
}
.journey-step:first-child::before { left: 50%; }
.journey-step:last-child::before { right: 50%; }
.journey-step.is-mine::before { background: linear-gradient(90deg, var(--rule), var(--sky), var(--rule)); }
.journey-step button {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%;
  padding: 0 4px 8px; background: none; border: 0; cursor: pointer; color: var(--muted); font: inherit; text-align: center;
}
.journey-dot {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; font-weight: 800;
  background: var(--sheet); border: 3px solid var(--rule); color: var(--muted); transition: transform .15s, background .15s;
}
.journey-step.is-mine .journey-dot { border-color: var(--sky); color: var(--navy); background: var(--sky-soft); }
.journey-title { font-size: .85rem; font-weight: 600; line-height: 1.25; }
.journey-you { font-size: .7rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--on-blue); background: var(--blue); border-radius: 999px; padding: 1px 8px; }
.journey-step button[aria-selected="true"] { color: var(--ink); }
.journey-step button[aria-selected="true"] .journey-dot { background: var(--blue); border-color: var(--blue); color: var(--on-blue); transform: scale(1.08); }
.journey-step button:hover .journey-dot { transform: scale(1.08); }
.journey-panel { margin-top: 14px; padding: 16px 18px; border-radius: var(--radius); background: var(--blue-soft); }
.journey-panel h3 { margin: 0 0 10px; }

.roles-guide { margin-top: 24px; }
.role-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 16px; }
.role-tabs button {
  font: inherit; font-weight: 700; padding: 8px 16px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--field-border); background: var(--sheet); color: var(--blue);
}
.role-tabs button[aria-selected="true"] { background: var(--blue); border-color: var(--blue); color: var(--on-blue); }
.role-panel h3 { margin: 0; }
.role-panel + .role-panel { margin-top: 24px; }
.role-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-top: 14px; }
.role-col { border: 1px solid var(--rule); border-radius: var(--radius); padding: 14px 16px; background: var(--sheet); min-width: 0; }
.role-col h4 { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; font-size: 1rem; }
.role-ico { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; color: var(--on-blue); background: var(--blue); flex: none; }
.role-ico.is-warn { background: var(--warn); }
.role-ico svg { width: 18px; height: 18px; }
.role-list, .role-can { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.role-list li { padding-left: 22px; position: relative; }
.role-list li::before { content: ""; position: absolute; left: 4px; top: .55em; width: 8px; height: 8px; border-radius: 50%; background: var(--sky); }
.role-list.is-limits li::before { background: var(--warn); border-radius: 2px; }
.role-can a { display: block; padding: 8px 12px; border-radius: 8px; background: var(--blue-soft); font-weight: 600; text-decoration: none; }
.role-can a:hover { background: var(--tab-hover); }
@media (max-width: 640px) { .work-n { font-size: 1.9rem; } }
/* Narrow screens: the journey runs top to bottom instead of across. */
@media (max-width: 900px) {
  .journey-steps { flex-direction: column; overflow: visible; }
  .journey-step { flex: none; }
  .journey-step::before { top: 0; bottom: 0; left: 21px; right: auto; width: 3px; height: auto; }
  .journey-step:first-child::before { top: 50%; left: 21px; }
  .journey-step:last-child::before { bottom: 50%; right: auto; }
  .journey-step.is-mine::before { background: linear-gradient(180deg, var(--rule), var(--sky), var(--rule)); }
  .journey-step button { flex-direction: row; text-align: left; padding: 4px 0; gap: 12px; }
  .journey-title { font-size: .95rem; }
}

/* ---------- audit log ---------- */
.audit-filters .audit-q { flex: 1 1 260px; }
.audit-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.audit-table td { vertical-align: top; }
.audit-table .nowrap { white-space: nowrap; }
.audit-detail { font-size: .88rem; min-width: 220px; overflow-wrap: anywhere; }
.audit-detail > div + div { margin-top: 2px; }
.audit-json { margin: 6px 0 0; padding: 8px 10px; border-radius: 8px; background: var(--blue-soft); font-size: .8rem; white-space: pre-wrap; overflow-wrap: anywhere; max-width: 520px; }

/* ---------- card photo position (/cards/:id/photo) ---------- */
.frame-editor { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.frame-circle { position: relative; width: min(320px, 100%); aspect-ratio: 1; border-radius: 50%; overflow: hidden;
  background: #fff; border: 3px solid #1a6fb3; cursor: grab; touch-action: none; user-select: none; }
.frame-circle.dragging { cursor: grabbing; }
.frame-circle:focus-visible { outline: 3px solid var(--focus, #f5b301); outline-offset: 3px; }
.frame-circle img, .card-mock-circle img { position: absolute; max-width: none; pointer-events: none; }
.frame-zoom { display: flex; align-items: center; gap: 10px; width: min(320px, 100%); }
.frame-zoom input { flex: 1; }
.card-mock { position: relative; width: min(260px, 100%); margin: 0 auto 10px; background: #fff;
  border-radius: 12px; overflow: hidden; box-shadow: 0 2px 10px rgba(0, 0, 0, .18); }
.card-mock[data-no-art] { border: 1px dashed var(--rule); }
.card-mock-art { position: absolute; inset: 0; width: 100%; height: 100%; }
.card-mock-circle { position: absolute; border-radius: 50%; overflow: hidden; background: #fff; }
.saved-circle { display: block; border-radius: 50%; background: #fff; }
.photo-thumb { display: block; width: 44px; height: 44px; border-radius: 50%; background: #fff; border: 1px solid var(--rule); }
