:root {
  color-scheme: dark;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: #0c1018;
  color: #eef2fa;
  --panel: #131a26;
  --line: #293347;
  --muted: #a2aec4;
  --accent: #67e8bc;
  --reserve: #ac9afd;
}

* { box-sizing: border-box; }
body { margin: 0; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 22px max(24px, calc((100% - 1200px) / 2));
  background: #101620;
  border-bottom: 1px solid var(--line);
}
.brand, .source, .controls { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: 11px;
  color: var(--accent);
  background: #19352f;
  font-size: 29px;
}
h1, h2, p { margin: 0; }
h1 { font-size: clamp(21px, 3vw, 28px); letter-spacing: -.035em; }
h2 { font-size: 17px; }
.source, .speed, .notice, .panel-heading > span, .metric > span, .legend, .empty { color: var(--muted); font-size: 14px; }
main { width: min(1200px, calc(100% - 48px)); margin: 24px auto 40px; }
.transport, .metric, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.transport { display: grid; grid-template-columns: auto minmax(140px, 1fr) auto; gap: 24px; align-items: center; padding: 16px; }
button, select, .file-button {
  font: inherit;
  font-size: 14px;
  border: 1px solid #36445c;
  border-radius: 8px;
  padding: 9px 12px;
  color: #eef2fa;
  background: #1c2636;
}
button, select, .file-button { cursor: pointer; }
button:hover:not(:disabled), select:hover, .file-button:hover { border-color: var(--accent); }
button:disabled { opacity: .52; cursor: default; }
button:focus-visible, select:focus-visible, input:focus-visible, .file-button:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.primary { background: var(--accent); color: #0b231c; border-color: var(--accent); font-weight: 700; }
.file-button { position: relative; white-space: nowrap; }
.file-button input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.timeline-label { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 13px; color: var(--muted); }
output, strong, .sales-price, .legend b { font-variant-numeric: tabular-nums; }
output { color: #eef2fa; }
input[type=range] { width: 100%; margin: 8px 0 0; accent-color: var(--accent); cursor: pointer; }
.speed { display: flex; align-items: center; gap: 8px; }
.notice { min-height: 20px; margin: 10px 0; }
.notice.error { color: #ffadb2; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.metric { padding: 16px 18px; }
.metric strong { display: block; margin-top: 5px; font-size: clamp(24px, 3vw, 34px); letter-spacing: -.04em; }
.profit { color: var(--accent); }
.profit.negative, .sales-price.negative { color: #ffadb2; }
.grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 14px; }
.panel { padding: 16px 18px; min-width: 0; }
.panel-heading { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 6px 12px; margin-bottom: 14px; }
#chart { display: block; width: 100%; height: 218px; }
ul, ol { list-style: none; margin: 0; padding: 0; }
.machines li, .sales li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 39px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.machines li:last-child, .sales li:last-child { border-bottom: 0; }
.machine-status, .sale-detail { color: var(--muted); font-size: 13px; }
.machine-status.working, .sales-price { color: var(--accent); }
.machine-status::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: currentColor; margin-right: 7px; }
.warehouse { display: grid; grid-template-columns: repeat(auto-fit, minmax(18px, 1fr)); gap: 5px; }
.warehouse span { height: 24px; border-radius: 4px; border: 1px solid #394761; background: #1c2636; }
.warehouse .stock { background: var(--accent); border-color: var(--accent); }
.warehouse .reserve { border-color: var(--reserve); background: repeating-linear-gradient(135deg, #332c55 0 5px, #9d8ce6 5px 9px); }
.legend, .materials { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 12px; }
.legend b { color: #eef2fa; margin-left: 3px; }
.legend > span::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; background: #52617a; }
.legend .stock::before { background: var(--accent); }
.legend .reserve::before { background: var(--reserve); }
.materials li { background: #1c2636; border-radius: 6px; padding: 4px 8px; font-size: 13px; }
.sales-price { white-space: nowrap; }
.sale-detail { display: block; margin-top: 2px; }

.setup { margin-bottom: 14px; }
.setup form { display: grid; grid-template-columns: 1.2fr 1.3fr .8fr 1fr auto; gap: 12px; align-items: end; }
.setup label { display: grid; gap: 6px; min-width: 0; color: var(--muted); font-size: 13px; }
.setup select, .setup input { width: 100%; min-width: 0; }
.setup input {
  font: inherit;
  font-size: 14px;
  border: 1px solid #36445c;
  border-radius: 8px;
  padding: 9px 12px;
  color: #eef2fa;
  background: #1c2636;
}

@media (max-width: 830px) {
  .setup form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .setup button { justify-self: start; }
  .transport { grid-template-columns: 1fr auto; gap: 14px; }
  .timeline { grid-column: 1 / -1; grid-row: 2; }
  .grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .topbar { padding: 14px; flex-wrap: wrap; }
  .source { flex-wrap: wrap; }
  main { width: calc(100% - 24px); margin-top: 14px; }
  .transport { grid-template-columns: 1fr; }
  .timeline { grid-column: auto; grid-row: auto; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .metric, .panel { padding: 13px; }
}
