/* eTVD admin UI. A plain, dense console: system fonts, square controls,
   and colour kept for meaning. Red, amber and green mark action bands
   (on the action code) and health (on a status word), and nothing else. */

:root {
  --bg: #ffffff;
  --bar: #efefef;
  --ink: #1a1a1a;
  --ink-2: #5c5c5c;
  --rule: #dcdcdc;
  --rule-2: #8f8f8f;
  --zebra: #f6f6f6;
  --link: #0645ad;
  --focus: #0645ad;
  --button: #f2f2f2;
  --button-hover: #e4e4e4;

  --red: #b3261e;
  --amber: #8a5a00;
  --green: #1e7d32;

  --tint-red: #fdecea;
  --tint-amber: #fff4d6;
  --tint-green: #e8f5e9;
  --tint-blue: #e8f0fe;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171717;
    --bar: #222222;
    --ink: #e8e8e8;
    --ink-2: #a3a3a3;
    --rule: #333333;
    --rule-2: #6e6e6e;
    --zebra: #1e1e1e;
    --link: #8ab4f8;
    --focus: #8ab4f8;
    --button: #2a2a2a;
    --button-hover: #353535;
    --red: #ff8a80;
    --amber: #e6b450;
    --green: #7bd88f;
    --tint-red: #3b1a17;
    --tint-amber: #3a2d0f;
    --tint-green: #16301c;
    --tint-blue: #172a45;
    color-scheme: dark;
  }
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 0.875rem;
  line-height: 1.4;
}

h1, h2, h3 { line-height: 1.25; margin: 0 0 0.5rem; font-weight: 600; }
h1 { font-size: 1.25rem; }
h2 { font-size: 1rem; margin-top: 1.5rem; }
h3 { font-size: 0.875rem; margin-top: 1rem; }
.panel > h2:first-child, .two-col > * > h2:first-child, .ticket-side h2:first-child { margin-top: 0; }
p { margin: 0 0 0.6rem; max-width: 90ch; }

a { color: var(--link); text-underline-offset: 0.12em; }

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

.skip { position: absolute; left: -999px; top: 0; }
.skip:focus { left: 0.5rem; top: 0.5rem; z-index: 10; background: var(--bg); padding: 0.4rem 0.8rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.id { font-variant-numeric: tabular-nums slashed-zero; }
.muted { color: var(--ink-2); }
.small { font-size: 0.8125rem; }
.nowrap { white-space: nowrap; }
.wrap-any { overflow-wrap: anywhere; }
.lede { color: var(--ink-2); }
.error-text { color: var(--red); }

/* Chrome */

.env-banner {
  padding: 0.2rem 1.25rem;
  font-weight: 600;
  color: #fff;
  background: var(--red);
}
.env-test .env-banner { color: #1a1a1a; background: #f2c037; }

.top { background: var(--bar); border-bottom: 1px solid var(--rule); padding: 0.45rem 1.25rem 0.4rem; }
.top-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 1rem; }
.brand { color: var(--ink); font-weight: 700; font-size: 1rem; text-decoration: none; }
.jump { display: flex; gap: 0.25rem; margin: 0; }
.jump input:not([type=checkbox]) { width: 11rem; }
.account { margin-left: auto; }
.account form { display: inline; margin: 0 0 0 0.6rem; }

.top nav { display: flex; flex-wrap: wrap; gap: 0.2rem 1.75rem; margin-top: 0.35rem; }
.top nav ul { display: flex; flex-wrap: wrap; gap: 0.2rem 0.9rem; list-style: none; margin: 0; padding: 0; }
.top nav a { color: var(--ink); text-decoration: none; }
.top nav a:hover { text-decoration: underline; }
.top nav a[aria-current="page"] { font-weight: 700; }

main { padding: 1rem 1.25rem 2rem; min-width: 0; }
main.bare { max-width: 22rem; margin: 8vh auto; }

.foot { padding: 0.5rem 1.25rem 1rem; border-top: 1px solid var(--rule); color: var(--ink-2); font-size: 0.8125rem; }

.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0.4rem 1rem; }
.section-head h1, .section-head h2 { margin-bottom: 0.4rem; }
.actions { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.4rem 1rem; }
.crumbs { display: flex; flex-wrap: wrap; gap: 0.2rem 1rem; margin: 0 0 0.25rem; font-size: 0.8125rem; }
.toc { display: flex; flex-wrap: wrap; gap: 0.2rem 1rem; margin-bottom: 0.6rem; }
.pager { margin-top: 0.6rem; }

/* Action bands and health. The "aspect" partial names the band for
   screen readers and colours the action code that follows it; the code's
   range already carries the band, so colour is never the only cue. */

.band-mark { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.band-mark + *, .b { font-weight: 600; }
.band-reject-temp + *, .band-warning + *, .b-reject-temp, .b-warning { color: var(--amber); }
.band-journey + *, .b-journey { color: var(--green); }
.band-permanent + *, .b-permanent { color: var(--red); }

.st { font-weight: 600; }
.st-ok { color: var(--green); }
.st-warn { color: var(--amber); }
.st-fail { color: var(--red); }
.st-pending, .st-off { color: var(--ink-2); }

/* Ticket */

.ticket-head { margin-bottom: 0.75rem; }
.utn { font-family: var(--mono); font-size: 1.375rem; font-weight: 600; margin: 0 0 0.2rem; }
.utn span + span { margin-left: 0.35em; }
.deny { margin: 0.1rem 0; }

.ticket-layout { display: grid; grid-template-columns: minmax(0, 1fr) 19rem; gap: 1.5rem; align-items: start; }
.ticket-side .panel { margin: 0 0 1.25rem; }

table.data tr.group th { padding-top: 0.6rem; background: var(--bg); border-bottom-color: var(--rule-2); font-weight: 600; color: var(--ink); }
td.action { min-width: 14rem; }
.note, .comment { margin-top: 0.1rem; font-size: 0.8125rem; }
.note { color: var(--ink-2); }
.comment { font-style: italic; }
.invalid-records { margin-top: 1rem; }
.invalid-records > summary { font-weight: 600; }

/* Sections, tables and lists */

.panel { margin: 1.25rem 0; }
.narrow { max-width: 40rem; }
.two-col { margin: 1.25rem 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(22rem, 1fr)); gap: 1rem 2rem; align-items: start; }
.two-col > .panel, .two-col > .table-wrap { margin: 0; }

.table-wrap { overflow-x: auto; margin: 0.25rem 0 0.75rem; }
table { border-collapse: collapse; width: 100%; }
table.data { font-size: 0.8125rem; }
table.data th, table.data td { text-align: left; padding: 0.2rem 0.5rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
table.data thead th { font-weight: 600; white-space: nowrap; border-bottom-color: var(--rule-2); }
table.data tbody th { font-weight: 400; }
table.data tbody tr:nth-child(even) { background: var(--zebra); }
/* Wrapping anywhere shrinks a column to nothing on a phone, so long text keeps a readable width and the table scrolls instead. */
table.data td.wrap-any { min-width: 12rem; }
.num { text-align: right !important; }
tr.is-undone td { color: var(--ink-2); }
tr.is-undone td a { color: var(--ink-2); }
tr.is-undone .action-cell { text-decoration: line-through; }
tr.is-muted td { color: var(--ink-2); }
tr.total th, tr.total td { font-weight: 600; }
.narrow-table { max-width: 30rem; }
td.empty, p.empty { color: var(--ink-2); }

table.kv { width: auto; }
table.kv th { text-align: left; font-weight: 400; color: var(--ink-2); padding: 0.1rem 1rem 0.1rem 0; white-space: nowrap; vertical-align: top; }
table.kv td { padding: 0.1rem 0; }

.kv-list { margin: 0; }
.kv-list div { display: grid; grid-template-columns: 9.5rem minmax(0, 1fr); gap: 0.5rem; padding: 0.12rem 0; }
.kv-list dt { color: var(--ink-2); }
.kv-list dd { margin: 0; }

.figures { display: flex; flex-wrap: wrap; gap: 0.2rem 1.5rem; margin: 0.25rem 0 0.75rem; }
.figures div { display: flex; gap: 0.35rem; }
.figures dt { color: var(--ink-2); }
.figures dd { margin: 0; font-weight: 600; }

.roles { margin: 0 0 0.75rem; }
.roles div { display: grid; grid-template-columns: 5rem minmax(0, 1fr); gap: 0.5rem; }
.roles dt { font-weight: 600; }
.roles dd { margin: 0; color: var(--ink-2); }

.tag { font-size: 0.75rem; padding: 0 0.25rem; border: 1px solid var(--rule-2); color: var(--ink-2); white-space: nowrap; }
.plain { margin: 0; padding-left: 1.1rem; }

pre { margin: 0.3rem 0; padding: 0.4rem 0.5rem; background: var(--zebra); border: 1px solid var(--rule); overflow: auto; font-size: 0.8125rem; }
pre.barcode { white-space: pre-wrap; overflow-wrap: anywhere; }
pre, code, textarea.id { font-family: var(--mono); }
details > summary { cursor: pointer; color: var(--link); margin: 0.25rem 0; }
table.data details > summary { margin: 0; }

/* Forms */

form { margin: 0 0 0.75rem; }
label { display: flex; flex-direction: column; gap: 0.15rem; font-weight: 600; }
label.check { flex-direction: row; align-items: center; gap: 0.4rem; font-weight: 400; }
.hint { font-weight: 400; font-size: 0.8125rem; color: var(--ink-2); }
input, select, textarea, button, .button { font: inherit; }
input:not([type=checkbox]):not([type=file]):not([type=radio]), select, textarea {
  width: 100%;
  padding: 0.2rem 0.35rem;
  border: 1px solid var(--rule-2);
  border-radius: 0;
  background: var(--bg);
  color: var(--ink);
  font-weight: 400;
}
textarea { resize: vertical; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; display: flex; flex-direction: column; gap: 0.6rem; }
fieldset + fieldset { margin-top: 0.75rem; }
.two-col > fieldset { margin: 0; }
legend { font-weight: 600; font-size: 1rem; padding: 0 0 0.4rem; }

.stack { display: flex; flex-direction: column; gap: 0.6rem; align-items: stretch; }
.stack > button { align-self: flex-start; }
.inline { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
.inline label { flex-direction: row; align-items: center; gap: 0.35rem; white-space: nowrap; }
.inline input:not([type=file]) { width: auto; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 0.6rem; }
.wide { max-width: 72rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: 0.5rem 0.6rem; margin: 0.25rem 0; }

.search { display: flex; flex-direction: column; gap: 0.4rem; max-width: 60rem; }
.search > button { align-self: flex-start; }
.search p { margin: 0; }
.utn-field input { font-family: var(--mono); font-size: 1rem; max-width: 18rem; }

.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.4rem 0.5rem; margin: 0 0 0.6rem; }
.filters label { flex: 0 1 9rem; min-width: 6.5rem; }

button, .button {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border: 1px solid var(--rule-2);
  border-radius: 0;
  background: var(--button);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  line-height: 1.4;
  white-space: nowrap;
}
button:hover, .button:hover { background: var(--button-hover); }
button.primary { font-weight: 600; border-color: var(--ink); }
button.danger { color: var(--red); border-color: var(--red); }
button.link { background: none; border: 0; padding: 0; color: var(--link); text-decoration: underline; text-underline-offset: 0.12em; }
button.link.danger { color: var(--red); }

.flash { padding: 0.35rem 0.6rem; margin: 0 0 0.75rem; border: 1px solid var(--rule-2); }
.flash p, .flash ul { margin: 0.1rem 0; }
.flash-ok { background: var(--tint-green); border-color: var(--green); }
.flash-error { background: var(--tint-red); border-color: var(--red); }
.flash-warn { background: var(--tint-amber); border-color: var(--amber); }
.flash-info { background: var(--tint-blue); border-color: var(--link); }

.secret { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; padding: 0.5rem; border: 1px solid var(--rule-2); background: var(--zebra); margin: 0.5rem 0 0.75rem; }
.secret code { font-size: 1rem; overflow-wrap: anywhere; flex: 1 1 20rem; }

.danger-zone { margin-top: 1.5rem; padding-top: 0.75rem; border-top: 1px solid var(--rule); }
.danger-zone h2 { margin-top: 0; }

.error-page { max-width: 40rem; }

.login { display: flex; flex-direction: column; gap: 0.75rem; }
.login-head h1 { margin: 0; }
.login-head p { margin: 0; color: var(--ink-2); }

/* Narrow screens */

@media (max-width: 1000px) {
  .ticket-layout { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 700px) {
  .top, main, .foot { padding-left: 0.75rem; padding-right: 0.75rem; }
  .account { margin-left: 0; width: 100%; }
  .jump { flex: 1; }
  .jump input:not([type=checkbox]) { width: auto; flex: 1; }
  .kv-list div { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .two-col { grid-template-columns: minmax(0, 1fr); }
}

/* Devices */

.hl-ok { color: var(--green); }
.hl-warn { color: var(--amber); }
.hl-fail { color: var(--red); }
.dev-status { font-size: 0.875rem; font-weight: 600; }
.dev-active { color: var(--green); }
.dev-suspended { color: var(--amber); }
.dev-registered, .dev-retired { color: var(--ink-2); }
h1 .dev-status { margin-left: 0.4rem; vertical-align: middle; }
.checks a[aria-current="page"] { font-weight: 700; }

/* Enrolment labels. They stay dark on light in every colour scheme,
   because scanners need dark modules on a light background. */

.enrol-labels { display: flex; flex-wrap: wrap; gap: 1rem; margin: 1rem 0; }
.enrol-label { width: 17rem; padding: 0.75rem; border: 1px solid var(--rule-2); background: #ffffff; color: #1a1a1a; break-inside: avoid; }
.enrol-label p { margin: 0 0 0.2rem; }
.enrol-asset { font-size: 1.25rem; font-weight: 700; }
.enrol-name { font-size: 0.8125rem; }
.enrol-label svg.qr { display: block; width: 12rem; max-width: 100%; height: auto; margin: 0.4rem auto; }
.enrol-typed { margin: 0.3rem 0; }
.enrol-typed div { display: flex; gap: 0.5rem; align-items: baseline; }
.enrol-typed dt { color: #5c5c5c; min-width: 2.5rem; }
.enrol-typed dd { margin: 0; font-family: var(--mono); font-size: 1rem; overflow-wrap: anywhere; }
.enrol-expiry { font-size: 0.75rem; color: #5c5c5c; }

@media print {
  .env-banner, .top, .foot, .skip, .flash, .no-print { display: none !important; }
  body { background: #ffffff; color: #1a1a1a; }
  main { padding: 0; }
  .enrol-labels { gap: 3mm; margin: 0; }
  .enrol-label { width: 62mm; padding: 3mm; border: 1px dashed #8f8f8f; }
  .enrol-label svg.qr { width: 30mm; }
}
