:root {
  --navy: #26396f;
  --orange: #d58a32;
  --ink: #182747;
  --muted: #526078;
  --line: #d7ddea;
  --field: #aeb9ce;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: #f4f6fa;
  color: var(--ink);
  font: 15px/1.5 system-ui, Arial, sans-serif;
}

header {
  background: var(--navy);
  color: white;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 18px max(20px, calc((100vw - 1060px) / 2));
  border-bottom: 5px solid var(--orange);
}
/* The logo file is square with white bands above and below; show only its middle. */
.brand { width: 170px; aspect-ratio: 2.08 / 1; overflow: hidden; flex-shrink: 0; }
.brand img { width: 100%; display: block; transform: translateY(-25%); }
h1 { font-size: clamp(22px, 3vw, 32px); margin: 0; }
header p { margin: 4px 0 0; }

main { max-width: 1100px; margin: auto; padding: 20px; }
h2 { font-size: 19px; margin: 0 0 10px; }
.muted, footer { color: var(--muted); }
p.muted { margin: 10px 0 0; font-size: 13px; }
footer { font-size: 12px; }

.panel {
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px;
  margin-bottom: 16px;
}

label { font-weight: 600; display: block; }
input, select {
  display: block;
  width: 100%;
  padding: 10px;
  border: 1px solid var(--field);
  border-radius: 6px;
  margin-top: 4px;
  font: inherit;
  background: white;
  color: var(--ink);
}
input:focus, select:focus, button:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }

.check { font-weight: 400; display: flex; gap: 8px; align-items: flex-start; margin-top: 8px; font-size: 13px; }
.check input { width: auto; margin: 3px 0 0; }

button {
  background: var(--navy);
  color: white;
  border: 1px solid var(--navy);
  border-radius: 6px;
  padding: 11px 18px;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}
button.plain { background: white; color: var(--navy); border-color: var(--field); }

.targets { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; align-items: start; }
.facts { display: flex; gap: 28px; align-items: center; flex-wrap: wrap; }
.facts input { width: auto; }
.facts strong { display: block; font-size: 20px; }
.facts button { margin-left: auto; }

/* The editor is one screen in four modes. Each mode hides what does not belong to it. */
#editor:not([data-mode=sheet]) .sheet-only,
#editor:not([data-mode=amend]) .amend-only,
#editor:not([data-mode=report]) .report-only,
#editor:not([data-mode=setup]) .setup-only,
#editor[data-mode=setup] .not-setup,
#editor[data-mode=report] .not-report { display: none !important; }

.product { background: white; border: 1px solid var(--field); border-radius: 8px; margin-bottom: 22px; overflow: hidden; box-shadow: 0 2px 6px rgba(24, 39, 71, .1); }
.bookhead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  background: var(--navy);
  color: white;
  print-color-adjust: exact;
  -webkit-print-color-adjust: exact;
}
.bookhead strong { overflow-wrap: anywhere; font-size: 17px; }
.bookhead span { margin-right: auto; opacity: .85; }
.fields { display: grid; grid-template-columns: 1.6fr repeat(5, 1fr); gap: 12px; padding: 14px; align-items: start; }
.hint { display: block; font-weight: 400; font-size: 12px; color: var(--muted); margin-top: 3px; }
.results { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; padding: 12px 14px; background: #fffaf2; border-bottom: 1px solid var(--line); border-left: 5px solid var(--orange); }
.results strong { display: block; font-size: 20px; }

.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: #f4f6fa; }
td input { margin: 0; padding: 7px 8px; min-width: 76px; }
td input:not([type=number]) { min-width: 150px; }
.ranges td:first-child input { max-width: 240px; }
.games td:first-child, .games td:nth-child(8), .ranges td:nth-child(4), .ranges td:nth-child(5) { font-weight: 650; }
.sales { display: flex; gap: 6px; align-items: center; }
.product .add { margin: 8px 14px 12px; }
.product .warnings { margin: 0 14px; }
.product .warnings:not(:empty) { margin-bottom: 12px; }
table.list td:last-child { text-align: right; }

/* A field that cannot be typed in reads as plain text. */
input:read-only:not(:disabled) { border-color: transparent; background: transparent; padding-left: 0; appearance: textfield; }
input:read-only::-webkit-inner-spin-button { -webkit-appearance: none; }
input:disabled, select:disabled { background: #eef1f6; }
/* Typed in place of the calculated or set-up figure. The id keeps the colour on a report, where the field is read only. */
#editor input.edited { background: #fdebd3; border-color: var(--orange); padding-left: 8px; }
#addProduct { margin-bottom: 8px; }

.summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.summary div { background: #e6ebf6; padding: 14px; border-radius: 8px; }
.summary strong { display: block; font-size: clamp(19px, 3vw, 28px); overflow-wrap: anywhere; }
.summary small { color: var(--muted); }
/* Good and bad figures: green and red text, and a tint behind the ones that matter most. */
.gain { color: #14713a; }
.loss { color: #b3161f; }
td.gain, td.loss { font-weight: 700; }
td.gain, .summary div:has(.gain), .results div:has(.gain) { background: #dff3e5; }
td.loss, .summary div:has(.loss), .results div:has(.loss) { background: #fbdfe0; }
.results div { padding: 6px 10px; border-radius: 6px; }
td.gain, td.loss, .summary div, .results div { print-color-adjust: exact; -webkit-print-color-adjust: exact; }

.warnings, .insights { margin: 0; padding: 0; list-style: none; }
.warnings li {
  background: #fdf1e0;
  border-left: 5px solid var(--orange);
  color: #6b4514;
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 8px;
}
.warnings:not(:empty) { margin-bottom: 16px; }
.insights li { padding: 9px 0; border-top: 1px solid var(--line); }
.insights li:first-child { border-top: 0; padding-top: 0; }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row input { flex: 1 1 240px; width: auto; margin: 0; }
button.small { padding: 5px 11px; font-size: 13px; }
.saved { list-style: none; margin: 14px 0 0; padding: 0; }
.saved li { display: flex; gap: 10px; align-items: center; padding: 9px 0; border-top: 1px solid var(--line); }
.saved span { flex: 1; font-weight: 600; overflow-wrap: anywhere; }
.saved small { color: var(--muted); }
.saved select, .row select { width: auto; margin: 0; }
#attempts input { width: 220px; margin: 0; padding: 7px 8px; }

/* Operators fill in run sheets. What sets a session up is hidden from them, and the rules refuse it too. */
.operator .manage-only { display: none !important; }

#venueSearch { margin: 0; }
.tabs { display: flex; gap: 8px; margin-bottom: 14px; }
#attemptsTab .row { margin-top: 12px; }
.tabs [aria-selected=true] { background: var(--navy); color: white; border-color: var(--navy); }
/* A list in a box: a heading bar, then rows with a line between them and every second one shaded. */
.list { border: 1px solid var(--field); border-radius: 8px; overflow: hidden; margin-top: 14px; }
.listhead { display: flex; justify-content: space-between; padding: 7px 14px; background: #e6ebf6; font-size: 12px; font-weight: 600; color: var(--muted); }
.list > .saved { margin: 0; }
.list > .saved > li { padding: 10px 14px; }
.list > .saved > li:first-child { border-top: 0; }
.list > .saved > li:nth-child(even) { background: #f8f9fc; }
/* A venue's details open under its row. */
.saved li { flex-wrap: wrap; }
.venue { flex-basis: 100%; background: #f4f6fa; border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.venue .saved { margin: 8px 0; }
.venue .saved li:first-child { border-top: 0; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 4px 0 18px; }

@media (max-width: 860px) {
  .targets { grid-template-columns: 1fr; }
  .fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .summary, .results { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 520px) {
  header { gap: 12px; padding: 14px; }
  .brand { width: 110px; }
  header p { font-size: 12px; }
  main { padding: 14px 12px; }
  .panel { padding: 14px; }
}

/* Paper shows the run sheet or report as text: no buttons, and fields without their boxes. */
@media print {
  @page { margin: 12mm; }
  body { background: white; font-size: 10pt; }
  header { padding: 10px 14px; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  header p, .no-print { display: none !important; }
  main { padding: 0; max-width: none; }
  #title { margin: 14px 0 8px; font-size: 16pt; }
  .panel, .product { box-shadow: none; }
  .panel { border: 0; padding: 0; }
  input { border-color: transparent !important; background: transparent !important; padding: 0 !important; min-width: 0 !important; appearance: textfield; }
  input::-webkit-calendar-picker-indicator { display: none; }
  input::placeholder { color: transparent; }
  input.edited { font-weight: 650; text-decoration: underline; }
  th, td { padding: 3px 6px; white-space: normal; }
  .scroll { overflow: visible; }
  tr, .summary div, .warnings li { break-inside: avoid; }
  .results, .summary div, .warnings li, th { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .summary { grid-template-columns: repeat(4, 1fr); }
  .summary strong { font-size: 16pt; }
  footer { margin-top: 14px; font-size: 9pt; }
}
