:root {
  --bg: #f5f5f5;
  --ink: #303841;
  --muted: rgba(48, 56, 65, 0.68);
  --line: rgba(48, 56, 65, 0.14);
  --unit: #fff;
  --ok: #76abae;
  --warn: #ff5722;
  --miss: #303841;
  --rail: #fff;
  --radius: 8px;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Outfit, "Segoe UI", Tahoma, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

button,
select,
input,
textarea {
  font: inherit;
  color: inherit;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.bar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 20px;
  align-items: center;
  padding: 16px 22px 12px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sig {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  background: var(--ok);
  color: #fff;
  border: 1px solid var(--ok);
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 1.15rem;
}

h1 {
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1.1;
}

.stats {
  display: flex;
  justify-content: center;
  gap: 28px;
}

.meter {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.meter b {
  font-size: 1.7rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.meter span {
  color: var(--muted);
  font-size: 13px;
}

.meter.home b { color: var(--ok); }
.meter.misplaced b { color: var(--warn); }
.meter.missing b { color: var(--miss); }

.clock-block {
  text-align: right;
}

.clock {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.rule {
  margin: 0;
  padding: 8px 22px 0;
  color: var(--muted);
  font-size: 13px;
}

.stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 300px);
  gap: 18px;
  align-items: start;
  padding: 14px 18px 28px;
  width: 100%;
}

.shelves {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.shelf-tools {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.add-product {
  background: var(--ink);
  color: #fff;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  padding: 9px 14px;
  font-weight: 700;
  cursor: pointer;
}

.unit {
  background: var(--unit);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(48, 56, 65, 0.06);
  min-width: 0;
  padding: 14px 14px 16px;
  display: grid;
  grid-template-columns: 148px minmax(0, 1fr);
  column-gap: 16px;
  row-gap: 10px;
  align-items: start;
}

.unit-top {
  grid-row: 1 / span 2;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 4px;
  min-height: 100%;
}

.unit-index {
  font-size: 2rem;
  font-weight: 700;
  line-height: 0.9;
  letter-spacing: -0.04em;
}

.unit h2 {
  font-size: 1.15rem;
  font-weight: 700;
}

.reader {
  color: var(--muted);
  font-size: 12px;
}

.ledge {
  grid-column: 2;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  min-width: 0;
  overflow: hidden;
}

.goods {
  min-height: 72px;
  max-height: 280px;
  overflow: auto;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 8px;
}

.empty-plank {
  color: var(--muted);
  font-size: 13px;
  padding: 18px 4px 28px;
}

.token,
.reg {
  text-align: left;
  color: inherit;
}

.token {
  position: relative;
  flex: 1 1 150px;
  max-width: 190px;
  background: #fff;
  border-radius: var(--radius);
  border-inline-start: 4px solid var(--ok);
}

.token .pick {
  width: 100%;
  min-height: 64px;
  padding: 22px 8px 8px;
  border: 0;
  background: transparent;
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  color: inherit;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-start;
  gap: 3px;
}

.token.foreign {
  background: color-mix(in srgb, var(--warn) 12%, #fff);
  border-inline-start-color: var(--warn);
}

.token-name,
.reg-name {
  font-weight: 700;
  font-size: 13.5px;
}

.token-meta,
.reg-meta {
  font-size: 11px;
  color: var(--muted);
}

.token-meta.ok,
.reg-meta.home { color: var(--ink); }

.token-meta.warn,
.token-here,
.reg-meta.misplaced { color: var(--warn); }

.reg-meta.missing { color: var(--miss); }

.catalog {
  grid-column: 2;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.catalog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.add-shelf {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: var(--radius);
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.registry {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 8px;
  max-height: 320px;
  overflow: auto;
}

.reg {
  width: auto;
  flex: 1 1 190px;
  max-width: 260px;
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.reg .pick {
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  min-width: 0;
  padding: 0;
}

.edit-name {
  border: 0;
  background: transparent;
  color: var(--ok);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: var(--radius);
}

.token .edit-name {
  position: absolute;
  top: 6px;
  inset-inline-end: 6px;
  z-index: 1;
}

.reg-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.reg:last-child {
  border-bottom: 1px solid var(--line);
}

.lamp {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
}

.lamp.misplaced { background: var(--warn); }
.lamp.missing { background: var(--miss); }

.token.selected,
.reg.selected {
  outline: 1px solid var(--ink);
  outline-offset: 2px;
}

.token:hover,
.reg:hover {
  background: var(--bg);
}

.token.foreign:hover {
  background: color-mix(in srgb, var(--warn) 18%, #fff);
}

.rail {
  background: var(--rail);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(48, 56, 65, 0.06);
  padding: 14px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 12px;
  min-width: 0;
}

.rail h2 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.ticket {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.ticket-no {
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1;
}

.ticket.misplaced .ticket-no,
.ticket.misplaced .where { color: var(--warn); }

.ticket.missing .ticket-no,
.ticket.missing .where { color: var(--miss); }

.ticket h3 {
  font-size: 1rem;
  margin: 2px 0;
}

.ticket p {
  color: var(--muted);
  font-size: 12.5px;
}

.where {
  font-weight: 700;
  font-size: 13px !important;
}

.calm,
.quiet {
  color: var(--muted);
  font-size: 13px;
}

.log-item {
  display: grid;
  grid-template-columns: 8px 1fr;
  gap: 2px 8px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}

.log-item::before {
  content: "";
  width: 8px;
  height: 8px;
  margin-top: 4px;
  border-radius: 50%;
  background: var(--muted);
  grid-column: 1;
  grid-row: 1 / span 2;
}

.log-time,
.log-text {
  grid-column: 2;
}

.log-item.home::before { background: var(--ok); }
.log-item.misplaced::before { background: var(--warn); }
.log-item.missing::before { background: var(--miss); }

.log-time {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.log-text {
  font-size: 13px;
}

.sim label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 10px;
  min-width: 0;
}

select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 10px;
  font-weight: 500;
}

.actions {
  display: flex;
  gap: 8px;
  margin-top: 22px;
}

button[type="submit"],
.ghost {
  padding: 9px 12px;
  border-radius: var(--radius);
  cursor: pointer;
}

button[type="submit"] {
  background: var(--ink);
  color: #fff;
  border: 1px solid var(--ink);
  font-weight: 700;
}

.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
}

.danger {
  margin-inline-start: auto;
  background: transparent;
  color: var(--warn);
  border: 1px solid var(--warn);
  border-radius: var(--radius);
  padding: 9px 12px;
  font-weight: 700;
  cursor: pointer;
}

button:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible,
.pick:focus-visible,
.edit-name:focus-visible {
  outline: 2px solid var(--ok);
  outline-offset: 2px;
}

.sim-note {
  min-height: 2.6em;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.editor {
  width: min(480px, calc(100% - 32px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 12px 40px rgba(48, 56, 65, 0.18);
}

.editor::backdrop {
  background: rgba(48, 56, 65, 0.35);
}

.editor h2 {
  font-size: 1.15rem;
}

.editor label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
  font-size: 12px;
  font-weight: 600;
}

.editor input,
.editor textarea {
  width: 100%;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 10px;
  font-weight: 500;
}

.editor textarea {
  min-height: 148px;
  resize: vertical;
}

.field-hint {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.editor .actions {
  margin-top: 16px;
}

.editor .sim-note {
  min-height: 0;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 860px) {
  .stage {
    grid-template-columns: 1fr;
  }

  .rail {
    position: static;
  }
}

@media (max-width: 800px) {
  .bar {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .stats,
  .clock-block {
    justify-content: flex-start;
    text-align: left;
  }

  .unit {
    grid-template-columns: 1fr;
  }

  .unit-top,
  .ledge,
  .catalog {
    grid-column: 1;
    grid-row: auto;
  }
}
