:root {
  --red: #c8102e;
  --navy: #00205b;
  --navy-deep: #001433;
  --blue: #0057b8;
  --gold: #c6a15b;
  --ink: #1b1b1b;
  --muted: #3d4a5c;
  --line: #d5dbe3;
  --paper: #f4f7fb;
  --hero: #e7eef6;
  --white: #ffffff;
  --focus: #ffdd00;
  --max: 1120px;
  --font: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

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

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--white);
  font-size: 1.0625rem;
  line-height: 1.5;
}

img { display: block; max-width: 100%; height: auto; }

button,
input,
select,
textarea { font: inherit; }

a { color: var(--blue); }

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

.skip-link {
  position: absolute;
  left: 0.75rem;
  top: -4rem;
  z-index: 1200;
  background: var(--focus);
  color: var(--ink);
  font-weight: 700;
  padding: 0.55rem 0.8rem;
  text-decoration: none;
}

.skip-link:focus { top: 0.5rem; }

.wrap {
  width: min(var(--max), calc(100% - 2rem));
  margin-inline: auto;
}

.fiction-banner {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--red);
  color: var(--white);
  font-weight: 700;
  font-size: 1.25rem;
  line-height: 1.35;
  text-align: center;
  padding: 0.9rem 1.25rem;
}

.fiction-banner p { margin: 0 auto; max-width: 62rem; }

.masthead { background: var(--white); border-bottom: 1px solid var(--line); }

.masthead-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem 1.5rem;
  padding: 0.85rem 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  color: var(--navy);
  text-decoration: none;
  min-width: 0;
}

.brand-text { min-width: 0; }

.brand img { width: min(220px, 46vw); height: auto; flex: none; }

.brand-name {
  display: block;
  font-size: clamp(1.2rem, 2vw, 1.55rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.05;
  color: var(--navy);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-url {
  display: block;
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.masthead-tools {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.masthead-tools form { margin: 0; flex: none; }

.who {
  font-weight: 700;
  color: var(--navy);
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-toggle {
  display: none;
  align-items: center;
  background: var(--white);
  color: var(--navy);
  border: 2px solid var(--navy);
  border-radius: 4px;
  font-weight: 700;
  padding: 0.45rem 0.7rem;
  cursor: pointer;
}

.main-nav { background: var(--navy); }

.main-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.main-nav a {
  display: block;
  color: var(--white);
  text-decoration: none;
  font-weight: 600;
  padding: 0.85rem 1rem;
}

.main-nav a:hover,
.main-nav a:focus-visible { background: #12356f; }

.main-nav a[aria-current="page"] { box-shadow: inset 0 -4px 0 var(--gold); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--navy);
  color: var(--white);
  border: 2px solid var(--navy);
  border-radius: 4px;
  font-weight: 700;
  text-decoration: none;
  padding: 0.65rem 1rem;
  cursor: pointer;
}

.btn:hover { background: #00337a; }

.btn-secondary {
  background: var(--white);
  color: var(--navy);
}

.btn-secondary:hover { background: var(--paper); }

.hero {
  background: linear-gradient(180deg, var(--hero) 0%, #f7f9fc 100%);
  border-bottom: 1px solid var(--line);
  padding: 2.4rem 0 2rem;
}

.hero h1,
.page h1 {
  margin: 0 0 0.45rem;
  color: var(--navy);
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.lede { margin: 0 0 1rem; max-width: 42rem; font-size: 1.15rem; }

.page { padding: 1.75rem 0 3rem; }

.page h2 { color: var(--navy); margin: 0 0 0.5rem; }

.role-list { margin: 0.5rem 0 0; padding-left: 1.2rem; }

.hint { color: var(--muted); }

.mono {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.92em;
  overflow-wrap: anywhere;
}

.flash {
  margin: 1rem 0 0;
  background: var(--hero);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.75rem 1rem;
}

.panel {
  max-width: 38rem;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1.25rem 1.3rem 1.4rem;
}

.form-error {
  margin: 0 0 0.6rem;
  color: var(--red);
  font-weight: 700;
}

.identity {
  display: grid;
  gap: 0.8rem;
  margin: 1.2rem 0 0;
}

.identity div {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.75rem 0.9rem;
}

.identity dt {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.identity dd {
  margin: 0.2rem 0 0;
  font-weight: 700;
  color: var(--navy);
  overflow-wrap: anywhere;
}

.site-footer {
  background: var(--navy-deep);
  color: #e7edf5;
  padding-top: 2rem;
}

.site-footer a { color: #ffffff; }

.footer-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 1.5rem;
  padding-bottom: 1.5rem;
}

.footer-logo {
  display: inline-flex;
  background: var(--white);
  border-radius: 6px;
  padding: 0.45rem 0.65rem;
  margin-bottom: 0.75rem;
}

.footer-logo img { width: min(220px, 100%); }

.site-footer h2 {
  color: var(--white);
  font-size: 1rem;
  margin: 0 0 0.55rem;
}

.site-footer p { margin: 0 0 0.55rem; }

.site-footer ul { list-style: none; margin: 0; padding: 0; }

.site-footer li + li { margin-top: 0.35rem; }

.footer-base {
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  padding: 0.85rem 0 1.4rem;
}

.footer-base p { margin: 0; }

@media (max-width: 800px) {
  .footer-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .fiction-banner { font-size: 1rem; padding: 0.75rem 1rem; }
  .menu-toggle { display: inline-flex; }
  .main-nav { display: none; }
  .main-nav.is-open { display: block; }
  .main-nav ul { flex-direction: column; }
  .masthead-inner {
    flex-wrap: wrap;
    align-items: center;
    row-gap: 0.75rem;
  }
  .brand { flex: 1 1 100%; }
  .brand img { width: 120px; }
  .brand-name,
  .brand-url {
    overflow: visible;
    text-overflow: unset;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .masthead-tools {
    flex: 1 1 100%;
    justify-content: flex-end;
    flex-wrap: wrap;
  }
  .who {
    max-width: none;
    flex: 1 1 auto;
    margin-right: auto;
  }
  .masthead-tools .btn,
  .menu-toggle { white-space: nowrap; padding: 0.45rem 0.65rem; }
}

/* ---- Evidence and property ---- */

.btn-row { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 0 0 1.25rem; }
.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.92rem; }
.hint.small { font-size: 0.92rem; margin: 0.4rem 0 0; }
.opt { color: var(--muted); font-weight: 400; font-size: 0.92em; }

.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin: 0 0 1.75rem; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 1rem 1.1rem; }
.card h2 { font-size: 1.15rem; }
.card p { margin: 0; }

.panel.wide { max-width: 52rem; }
.panel h3 { margin: 0 0 0.6rem; color: var(--navy); font-size: 1.05rem; }
.panel.notice { border-left: 6px solid var(--gold); margin-bottom: 1.25rem; }

/* forms */
.field { display: flex; flex-direction: column; gap: 0.3rem; margin: 0 0 0.85rem; min-width: 0; }
.field label { font-weight: 700; color: var(--navy); font-size: 0.97rem; }
.field.grow { flex: 1 1 14rem; }
.field.check { justify-content: flex-end; }
.field.check label { font-weight: 600; display: flex; gap: 0.4rem; align-items: center; }
input[type="text"], input[type="search"], input[type="datetime-local"], input:not([type]),
select, textarea {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 2px solid #8a97a8;
  border-radius: 4px;
  background: var(--white);
  color: var(--ink);
}
input[type="checkbox"] { width: 1.15rem; height: 1.15rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.1rem; }
.form-grid .span2 { grid-column: 1 / -1; }
.filters { display: flex; flex-wrap: wrap; gap: 0 0.9rem; align-items: flex-end; margin: 0 0 1rem; }
.filters .field:not(.grow) { flex: 0 1 11rem; }

/* tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; margin: 0 0 1rem; }
table.data { width: 100%; border-collapse: collapse; background: var(--white); }
table.data th, table.data td { text-align: left; padding: 0.6rem 0.8rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data th { background: var(--paper); color: var(--navy); font-size: 0.85rem; letter-spacing: 0.03em; text-transform: uppercase; white-space: nowrap; }
table.data tr:last-child td { border-bottom: 0; }
table.data .num { text-align: right; }
table.data td form { margin: 0; }

/* status badges */
.badge { display: inline-block; padding: 0.15rem 0.55rem; border-radius: 999px; font-size: 0.85rem; font-weight: 700; white-space: nowrap; border: 1px solid transparent; }
.badge-lg { font-size: 1rem; padding: 0.3rem 0.8rem; }
.badge-with_officer { background: #fff4d6; color: #5c4300; border-color: #e3c46c; }
.badge-in_store { background: #e1f3e6; color: #0d4a22; border-color: #8cc9a0; }
.badge-checked_out { background: #e3ecfb; color: #00337a; border-color: #94b3e6; }
.badge-disposal_pending, .badge-d-requested, .badge-d-authorised { background: #fde7ea; color: #7a0a1e; border-color: #e59aa6; }
.badge-disposed, .badge-d-completed { background: #e8ebf0; color: #2c3747; border-color: #b3bcc9; }
.badge-d-rejected { background: #f1e8f6; color: #4a1d63; border-color: #c4a4d6; }

/* dashboard */
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.75rem; margin: 0 0 1.5rem; }
.stat { display: block; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 0.8rem 0.9rem; text-decoration: none; color: var(--navy); }
.stat:hover { background: var(--hero); }
.stat-n { display: block; font-size: 1.9rem; font-weight: 700; line-height: 1.1; }
.stat-l { display: block; font-size: 0.9rem; font-weight: 600; color: var(--muted); }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { padding: 0.5rem 0; border-bottom: 1px solid var(--line); }
.feed-when { display: inline-block; min-width: 9.5rem; color: var(--muted); font-size: 0.92rem; }

/* item page */
.item-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.item-head h1 { margin-bottom: 0.2rem; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.7rem; margin: 0.5rem 0 1rem; }
.facts div { background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 0.6rem 0.8rem; }
.facts .wide { grid-column: 1 / -1; }
.facts dt { color: var(--muted); font-size: 0.8rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.facts dd { margin: 0.15rem 0 0; font-weight: 600; color: var(--navy); overflow-wrap: anywhere; }
.actions { display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: 1rem; margin: 0 0 1rem; }
.actions .panel { max-width: none; }

.timeline { list-style: none; margin: 0.5rem 0 0; padding: 0 0 0 1.2rem; border-left: 3px solid var(--line); }
.ev { position: relative; padding: 0 0 1.1rem 1rem; }
.ev::before { content: ""; position: absolute; left: -1.78rem; top: 0.3rem; width: 0.8rem; height: 0.8rem; border-radius: 50%; background: var(--navy); border: 2px solid var(--white); }
.ev-audit_discrepancy::before, .ev-disposal_rejected::before { background: var(--red); }
.ev-disposed::before { background: var(--muted); }
.ev-stored::before, .ev-moved::before, .ev-audit_check::before { background: #1e7b3c; }
.ev-when { color: var(--muted); font-size: 0.92rem; margin-left: 0.4rem; }
.ev-who, .ev-hash { color: var(--muted); font-size: 0.9rem; }
.ev-move { font-weight: 600; color: var(--navy); }

/* disposals */
.disposal-list { display: grid; gap: 1rem; }
.disposal p { margin: 0.4rem 0; }
.inline-forms { display: flex; flex-wrap: wrap; gap: 0.75rem 1.25rem; align-items: flex-end; }
.inline-forms form { display: flex; gap: 0.6rem; align-items: flex-end; flex: 1 1 18rem; margin: 0; }
.inline-forms .field { margin: 0; }

/* scan */
.camera { max-width: 38rem; margin: 1rem 0; }
.camera video { width: 100%; border-radius: 8px; background: #000; }

/* label */
.label-sheet { margin-top: 1.25rem; }
.label { width: 100mm; border: 2px solid var(--ink); border-radius: 4px; padding: 3mm; background: var(--white); color: #000; font-size: 10pt; line-height: 1.25; }
.label-head { display: flex; align-items: center; gap: 2.5mm; border-bottom: 1px solid #000; padding-bottom: 2mm; margin-bottom: 2mm; }
.label-head span { display: block; font-size: 8pt; }
.label-body { display: flex; gap: 3mm; align-items: flex-start; }
.label-qr { width: 30mm; height: 30mm; flex: none; }
.label-ref { font-family: ui-monospace, Consolas, monospace; font-weight: 700; font-size: 12pt; margin-bottom: 1mm; }
.label-meta { font-size: 8pt; margin-top: 0.8mm; }
.label-bar { width: 100%; height: 12mm; margin-top: 2mm; }

@media (max-width: 800px) {
  .cards, .stats { grid-template-columns: 1fr 1fr; }
  .facts { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .cards, .stats, .facts, .form-grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
  .feed-when { display: block; }
}
@media print {
  .site-header, .site-footer, .no-print, .skip-link, .flash { display: none !important; }
  .page { padding: 0; }
  .label-sheet { margin: 0; }
  .label { border-width: 1px; }
}
