/* A deliberately plain, dense style: this is an operational tool. */

/* Palette ----------------------------------------------------------------
   Every literal colour in the stylesheet lives in this block. The first
   group is the raw ramp, built around the #3d3051 base (hsl 264 26% 25%);
   the second names each one for the job it does. Rules below use only the
   semantic names. */

:root {
  /* Purple ramp ---------------------------------------------------- */
  --purple-950: #221b2f;
  --purple-900: #2c2340;
  --purple-800: #3d3051; /* the base */
  --purple-700: #4f3d7a;
  --purple-650: #5f5473;
  --purple-600: #6d4bb0;
  --purple-500: #7b6f8f;
  --purple-400: #8f80ab;
  --purple-300: #c3b8d4;
  --purple-200: #dcd5e6;
  --purple-100: #efebf5;
  --purple-75: #f3effa;
  --purple-50: #f5f3f9;
  --violet-200: #c3a9f0;
  --violet-100: #ded0f5;
  --white: #ffffff;

  /* Semantic accents, chosen to sit beside the purple rather than
     fight it: the greens and blues lean cool, the red leans magenta. */
  --green-700: #15654a;
  --green-100: #e4f3ec;
  --green-200: #b3d8c8;
  --amber-700: #7c5200;
  --amber-100: #fbf0dd;
  --orange-700: #8f3d13;
  --orange-100: #fbeee6;
  --crimson-700: #9c1f42;
  --crimson-100: #fbebef;
  --crimson-200: #e8b4c1;
  --blue-700: #3f4d7a;
  --blue-100: #e9ecf6;

  /* Surfaces ------------------------------------------------------- */
  --page: var(--purple-50);
  --surface: var(--white);
  --surface-sunken: var(--purple-100);
  --surface-hover: var(--purple-75);

  /* Text ----------------------------------------------------------- */
  --text: var(--purple-950);
  --text-muted: var(--purple-650);
  --text-faint: var(--purple-500);

  /* Lines ---------------------------------------------------------- */
  --border: var(--purple-200);
  --border-strong: var(--purple-300);
  --border-control: var(--purple-400);

  /* Accent (links, primary buttons) -------------------------------- */
  --accent: var(--purple-700);
  --accent-hover: var(--purple-800);
  --accent-active: var(--purple-900);
  --on-accent: var(--white);
  --focus-ring: var(--purple-600);
  --focus-ring-inverse: var(--violet-200);

  /* Top bar -------------------------------------------------------- */
  --topbar: var(--purple-900);
  --topbar-text: var(--white);
  --topbar-muted: var(--violet-100);

  /* Disabled ------------------------------------------------------- */
  --disabled-bg: var(--purple-100);
  --disabled-text: var(--purple-650);
  --disabled-border: var(--purple-300);

  /* Status --------------------------------------------------------- */
  --good: var(--green-700);
  --good-bg: var(--green-100);
  --good-border: var(--green-200);
  --warn: var(--amber-700);
  --warn-bg: var(--amber-100);
  --caution: var(--orange-700);
  --caution-bg: var(--orange-100);
  --bad: var(--crimson-700);
  --bad-bg: var(--crimson-100);
  --bad-border: var(--crimson-200);
  --info: var(--blue-700);
  --info-bg: var(--blue-100);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

body.centred {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem;
}

h1 {
  font-size: 1.5rem;
  margin: 0 0 1rem;
}

h2 {
  font-size: 1.15rem;
  margin: 1.75rem 0 0.75rem;
}

h3 {
  font-size: 1rem;
  margin: 1.25rem 0 0.5rem;
}

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

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

a:active {
  color: var(--accent-active);
}

/* One focus treatment everywhere, so nothing relies on the browser
   default landing on a legible colour over the purple. */
:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* Top bar ---------------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.75rem 1.5rem;
  background: var(--topbar);
  color: var(--topbar-text);
}

.topbar .brand {
  font-weight: 600;
  color: var(--topbar-text);
  text-decoration: none;
}

.topbar nav {
  display: flex;
  gap: 1.25rem;
  flex: 1;
}

.topbar nav a {
  color: var(--topbar-muted);
  text-decoration: none;
}

.topbar nav a:hover {
  color: var(--topbar-text);
}

.topbar .who {
  color: var(--topbar-muted);
  margin-right: 0.75rem;
}

/* The ring has to flip on the dark bar to stay visible. */
.topbar :focus-visible {
  outline-color: var(--focus-ring-inverse);
}

.logout {
  display: flex;
  align-items: center;
}

/* Cards ------------------------------------------------------------------ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.cards {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.card.stat {
  flex: 1 1 150px;
  margin: 0;
}

.card.stat .label {
  display: block;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.card.stat .value {
  display: block;
  font-size: 1.4rem;
  font-weight: 600;
  margin-top: 0.25rem;
}

.card.stat.bad .value {
  color: var(--bad);
}

/* A card for a record that failed validation (scan_detail). */
.card.scan.bad {
  border-color: var(--bad-border);
  background: var(--bad-bg);
}

.lookups {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;
}

.lookups .card {
  flex: 1;
}

.lookups h2 {
  margin-top: 0;
}

/* Tables ----------------------------------------------------------------- */

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

th,
td {
  text-align: left;
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  background: var(--surface-sunken);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: var(--surface-hover);
}

td.number {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

tr.bad,
tbody tr.bad:hover {
  background: var(--bad-bg);
}

.bad-heading {
  color: var(--bad);
}

/* Scans ------------------------------------------------------------------ */

.action {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  font-size: 0.85rem;
  white-space: nowrap;
}

.action-information {
  background: var(--info-bg);
  color: var(--info);
}

.action-accepted {
  background: var(--good-bg);
  color: var(--good);
}

.action-warning {
  background: var(--warn-bg);
  color: var(--warn);
}

.action-temporary {
  background: var(--caution-bg);
  color: var(--caution);
}

.action-permanent {
  background: var(--bad-bg);
  color: var(--bad);
}

.scan dl {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.35rem 1.5rem;
  margin: 0.75rem 0 0;
}

.scan dl > div {
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px dotted var(--border-strong);
  padding-bottom: 0.2rem;
}

.scan dt {
  color: var(--text-muted);
  min-width: 11rem;
}

.scan dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.scan .description {
  color: var(--text-muted);
  margin: 0.25rem 0 0;
}

.notes {
  color: var(--bad);
  margin: 0.5rem 0;
}

.tag {
  display: inline-block;
  padding: 0.05rem 0.35rem;
  border: 1px solid var(--border-control);
  border-radius: 3px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.tag.bad {
  color: var(--bad);
  border-color: var(--bad);
}

.tag.ok {
  color: var(--good);
  border-color: var(--good);
}

/* Which keyset opened a barcode -------------------------------------------
   Deliberately loud. A test barcode decodes perfectly and is not a ticket, so
   the difference has to be visible before anything else on the page - colour
   alone would not do it, hence the label and the sentence beneath. */

.keyset {
  margin: 1rem 0;
  padding: 0.6rem 0.8rem;
  border: 1px solid;
  border-left-width: 5px;
  border-radius: 4px;
}

.keyset h2 {
  margin: 0 0 0.2rem;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.keyset p {
  margin: 0;
  font-size: 0.85rem;
}

.keyset.live {
  color: var(--good);
  background: var(--good-bg);
  border-color: var(--good-border);
}

.keyset.test {
  color: var(--caution);
  background: var(--caution-bg);
  border-color: var(--caution);
}

/* A barcode's fields ------------------------------------------------------
   In the barcode's own order. The meaning leads; the value as the barcode
   carries it trails, muted, for comparing against the specification. */

table.barcode-fields td {
  overflow-wrap: anywhere;
}

table.barcode-fields td.field-name {
  width: 18rem;
  color: var(--text-muted);
}

table.barcode-fields .raw {
  margin-left: 0.4rem;
  color: var(--text-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
}

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

label {
  display: block;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}

input,
select,
textarea {
  width: 100%;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border-control);
  border-radius: 4px;
  font: inherit;
  background: var(--surface);
  color: inherit;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-faint);
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--accent);
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  border-color: var(--accent);
  outline-offset: 1px;
}

/* Native checkboxes, radios and the like follow the accent. */
input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--accent);
}

input:disabled,
select:disabled,
textarea:disabled {
  background: var(--disabled-bg);
  border-color: var(--disabled-border);
  color: var(--disabled-text);
  cursor: not-allowed;
}

button {
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--accent);
  border-radius: 4px;
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  cursor: pointer;
}

button:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

button:active {
  background: var(--accent-active);
  border-color: var(--accent-active);
}

button:disabled {
  background: var(--disabled-bg);
  border-color: var(--disabled-border);
  color: var(--disabled-text);
  cursor: not-allowed;
}

button.link {
  background: none;
  border: none;
  color: var(--topbar-muted);
  padding: 0;
  text-decoration: underline;
}

button.link:hover,
button.link:active {
  background: none;
  border-color: transparent;
  color: var(--topbar-text);
}

button.link.danger {
  color: var(--bad);
}

button.link.danger:hover,
button.link.danger:active {
  background: none;
  color: var(--bad);
  text-decoration-thickness: 2px;
}

button.link:disabled {
  background: none;
  border-color: transparent;
  color: var(--disabled-text);
  text-decoration: none;
}

.form .row {
  display: flex;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.form .row > div {
  flex: 1;
}

.form fieldset {
  margin-bottom: 0.75rem;
}

/* A field standing alone rather than in a .row gets the gap a row would give
   it. The gap belongs after the control, not after its label, which stays
   close to what it labels. Block, so the margin collapses into a following
   .actions rather than doubling up. */
.form > input,
.form > select,
.form > textarea {
  display: block;
  margin-bottom: 0.75rem;
}

/* The row of buttons at the foot of a form whose last field stands alone
   rather than in a .row, which would otherwise have supplied the gap. */
.actions {
  margin-top: 0.75rem;
}

fieldset {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.5rem 0.75rem;
}

legend {
  font-size: 0.82rem;
  color: var(--text-muted);
}

label.check,
.checks label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-right: 1rem;
  color: inherit;
  font-size: 0.9rem;
}

label.check input,
.checks input {
  width: auto;
}

.filters {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
}

.filters > div {
  flex: 1 1 140px;
}

.filters button {
  flex: 0 0 auto;
}

/* First and next page links below a scan listing. */
.pager {
  display: flex;
  gap: 1.5rem;
  margin-top: 1rem;
}

.login {
  width: min(360px, 90vw);
}

.login h1 {
  font-size: 1.2rem;
}

.login label {
  margin-top: 0.75rem;
}

.login button {
  width: 100%;
  margin-top: 1rem;
}

/* Messages --------------------------------------------------------------- */

.error {
  background: var(--bad-bg);
  border: 1px solid var(--bad-border);
  color: var(--bad);
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
}

.ok {
  background: var(--good-bg);
  border: 1px solid var(--good-border);
  color: var(--good);
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
}

.empty {
  color: var(--text-muted);
  font-style: italic;
}
