:root {
  color-scheme: dark;
  --bg: #0a0a0a;
  --panel: #101010;
  --panel-2: #1a1a1a;
  --line: #272727;
  --line-strong: #404040;
  --text: #fafafa;
  --muted: #a3a3a3;
  --accent: #3b82f6;
  --accent-dark: #172554;
  --warn: #fbbf24;
  --danger: #ef4444;
  --has-started: ;
}

.hidden-unless-started {
  display: none;
}

:root[style*="--has-started: initial"] .hidden-unless-started {
  display: contents;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font:
    15px/1.55 Inter,
    ui-sans-serif,
    system-ui,
    sans-serif;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--line);
  background: #171717;
}

.assessment-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #171717;
  padding: 10px 16px;
}

.assessment-title {
  min-width: 265px;
}

.header-inner,
main {
  margin: 0 auto;
  width: min(1560px, calc(100% - 28px));
}

.header-inner {
  width: 100%;
}

.brand {
  min-width: 240px;
}

.eyebrow {
  color: #60a5fa;
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

h1 {
  margin: 1px 0 0;
  font-size: clamp(17px, 2vw, 24px);
  line-height: 1.15;
}

.status {
  display: grid;
  grid-template-columns: auto minmax(90px, 180px) auto auto;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

progress {
  width: 100%;
  accent-color: var(--accent);
}

#save-status,
#timer {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

main {
  padding: 14px 0 90px;
}

.hero {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr;
  gap: 16px;
  margin-bottom: 18px;
}

.panel,
section {
  box-shadow: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: color-mix(in srgb, var(--panel) 96%, transparent);
}

.panel {
  padding: 20px;
}

.panel h2,
section h2 {
  margin: 0 0 8px;
  font-size: 20px;
}

.panel p {
  margin: 8px 0;
}

.notice {
  border-left: 3px solid var(--warn);
  padding-left: 12px;
  color: #f3dfb8;
}

.section-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
  border: 1px solid var(--line);
  background: #171717;
  padding: 8px;
}

.section-nav a,
button,
.button {
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--panel-2);
  padding: 9px 12px;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
}

.section-nav a:hover,
button:hover,
.button:hover {
  border-color: #404040;
  background: #262626;
}

button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #161a0c;
}

button.danger {
  color: var(--danger);
}

#start-assessment {
  padding: 16px 24px;
  width: 100%;
  font-weight: 800;
  font-size: 18px;
}

#delivery-status {
  margin-top: 10px;
  color: var(--muted);
}

section {
  margin: 12px 0;
  padding: 20px;
  scroll-margin-top: 122px;
}

section > p:first-of-type {
  color: var(--muted);
}

h3 {
  margin: 26px 0 8px;
  color: var(--accent);
  font-size: 16px;
}

h4 {
  margin: 0 0 6px;
  font-size: 15px;
}

.grid-2,
.grid-3 {
  display: grid;
  gap: 14px;
}

.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field,
.question {
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--panel-2);
  padding: 14px;
}

.question {
  margin: 10px 0;
}

label {
  display: block;
  font-weight: 700;
}

label span,
.hint {
  color: var(--muted);
  font-weight: 400;
  font-size: 13px;
}

input[type="text"],
input[type="number"],
input[type="date"],
textarea,
select {
  margin-top: 7px;
  border: 1px solid #454c42;
  border-radius: 4px;
  background: #11130f;
  padding: 10px;
  width: 100%;
  color: var(--text);
  font: inherit;
}

textarea {
  min-height: 110px;
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid #60a5fa;
  outline-offset: -1px;
}

.choices {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.choices label {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-weight: 500;
}

.choices input {
  margin-top: 5px;
  accent-color: var(--accent);
}

.table-wrap {
  border: 1px solid var(--line);
  border-radius: 2px;
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 670px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 9px 11px;
  text-align: left;
  white-space: nowrap;
}

th {
  background: #262626;
  color: #f5f5f5;
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

.formula {
  border-radius: 8px;
  background: #11130f;
  padding: 10px 12px;
  color: #dce5d7;
  font-family: ui-monospace, monospace;
}

.tag {
  display: inline-block;
  margin: 2px 4px 2px 0;
  border: 1px solid #404040;
  border-radius: 99px;
  padding: 2px 8px;
  color: #d4d4d4;
  font-size: 12px;
}

.application-window {
  margin: 14px 0;
  border: 1px solid #3a3c3f;
  border-radius: 6px;
  background: #101010;
  overflow: hidden;
}

.window-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid #272727;
  background: #1a1a1a;
  padding: 10px;
}

.window-title {
  margin-right: auto;
  font-weight: 800;
}

.date-chip {
  border: 1px solid #2563eb;
  border-radius: 3px;
  background: #1e3a8a;
  padding: 5px 8px;
  font-size: 13px;
}

.barn-level {
  margin: 12px;
  border: 1px solid #3a3c3f;
  border-radius: 6px;
  background: #101010;
  overflow: hidden;
}

.barn-level-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid #3a3c3f;
  background: #1a1a1a;
  padding: 12px;
}

.barn-level-header h3 {
  margin: 0 auto 0 0;
  color: white;
  font-size: 22px;
}

.metric-box {
  border: 1px solid #404040;
  border-radius: 5px;
  background: #272727;
  padding: 7px 9px;
  min-width: 105px;
}

.metric-box span {
  display: block;
  color: #d4d4d4;
  font-size: 11px;
}

.metric-box strong {
  display: block;
  margin-top: 2px;
  font:
    700 14px ui-monospace,
    monospace;
}

.metric-box.warn {
  border-color: #a16207;
  background: #713f123f;
}

.metric-box.error {
  border-color: #b91c1c;
  background: #7f1d1d66;
}

.utilisation {
  position: relative;
  min-width: 145px;
}

.utilisation progress {
  height: 24px;
}

.utilisation span {
  display: grid;
  position: absolute;
  place-items: center;
  inset: 0;
  color: white;
  font:
    700 12px ui-monospace,
    monospace;
  text-shadow: 0 1px 2px black;
}

.bin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
  gap: 12px;
  padding: 12px;
}

.bin-card {
  border: 1px solid #272727;
  border-radius: 6px;
  background: #0a0a0a;
  padding: 10px;
}

.bin-card.warn {
  border-color: #854d0e;
  background: #42200640;
}

.bin-card.error {
  border-color: #991b1b;
  background: #450a0a66;
}

.bin-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 9px;
  font-weight: 800;
  font-size: 20px;
}

.bin-title .utilisation {
  flex: 1;
}

.level-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.level-box {
  border: 1px solid #404040;
  border-radius: 5px;
  background: #272727;
  padding: 8px;
}

.level-box label,
.level-box > span:first-child {
  display: block;
  margin-bottom: 5px;
  color: #d4d4d4;
  font-weight: 650;
  font-size: 12px;
}

.level-value {
  border: 1px solid #404040;
  border-radius: 4px;
  background: #0a0a0a;
  padding: 6px 8px;
  font-family: ui-monospace, monospace;
}

.level-box input {
  margin: 0;
  font-family: ui-monospace, monospace;
}

.ordering-shell {
  margin-top: 14px;
  overflow-x: auto;
}

.ordering-table {
  min-width: 1060px;
  font-size: 13px;
}

.ordering-table th,
.ordering-table td {
  border-right: 1px solid #272727;
  padding: 8px;
}

.ordering-table .group-row td {
  background: #171717;
  font-weight: 800;
}

.ordering-table .order-cell {
  color: #fde047;
  font-family: ui-monospace, monospace;
}

.ordering-table .total-row td {
  background: #052e1666;
  font-weight: 800;
}

.ordering-table input {
  margin: 0;
  padding: 6px;
  min-width: 82px;
  color: #fde047;
  font-family: ui-monospace, monospace;
}

.level-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding: 10px;
  color: #d4d4d4;
  font-size: 13px;
}

.legend-safe {
  color: #22c55e;
}

.legend-warning {
  color: #eab308;
}

.legend-danger {
  color: #ef4444;
}

.truck-builder {
  margin: 12px 0;
  border: 1px solid #272727;
  background: #101010;
  padding: 12px;
}

.truck-builder-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.compartment-rack {
  display: grid;
  grid-template-columns: repeat(10, minmax(64px, 1fr));
  gap: 4px;
  min-width: 760px;
}

.compartment {
  border: 1px solid #404040;
  background: #1a1a1a;
  padding: 7px;
  min-height: 76px;
  text-align: center;
}

.compartment strong {
  display: block;
  color: #d4d4d4;
  font-size: 11px;
}

.compartment span {
  display: block;
  margin-top: 12px;
  color: #737373;
  font-family: ui-monospace, monospace;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
}

#submit-message {
  min-height: 24px;
  color: var(--accent);
  font-weight: 700;
}

.required::after {
  content: " Required";
  color: var(--warn);
  font-weight: 800;
  font-size: 11px;
  text-transform: uppercase;
}

@media (max-width: 760px) {
  .assessment-bar {
    flex-direction: column;
    align-items: flex-start;
  }
  .status {
    margin: 0;
    width: 100%;
  }
  .hero,
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }
  section {
    padding: 18px;
  }
}

@media print {
  .app-header,
  .section-nav,
  .actions,
  #submit-message {
    display: none !important;
  }
  body {
    background: white;
    color: black;
  }
  .panel,
  section,
  .field,
  .question {
    break-inside: avoid;
    box-shadow: none;
    border-color: #aaa;
    background: white;
  }
  input,
  textarea,
  select {
    background: white;
    color: black;
  }
}
