:root {
  --red: #d01012;
  --yellow: #ffd500;
  --plate: #1b2530;
  --ink: #1c2330;
  --panel: #ffffff;
  --line: #e6e8ec;
  --muted: #7a8190;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: #eef0f3;
  min-height: 100vh;
}

header {
  background: var(--red);
  color: #fff;
  padding: 1.1rem 1.4rem;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.18);
  display: flex;
  align-items: center;
  gap: 0.9rem;
}
.logo {
  display: flex; gap: 4px;
}
.logo span {
  width: 16px; height: 16px; border-radius: 3px;
  background: var(--yellow);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.18), 0 0 0 2px rgba(0,0,0,0.08);
}
.logo span::after {
  content: ""; display: block; width: 7px; height: 7px;
  margin: 2px auto 0; border-radius: 50%;
  background: rgba(0, 0, 0, 0.12);
}
header h1 { font-size: 1.35rem; letter-spacing: 0.2px; }
header p { font-size: 0.85rem; opacity: 0.9; margin-top: 1px; }

.layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 1.1rem;
  padding: 1.1rem;
  max-width: 1200px;
  margin: 0 auto;
  align-items: start;
}
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.panel h2 {
  font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--muted); margin-bottom: 0.75rem;
}

/* inventory */
.part {
  display: grid;
  grid-template-columns: 44px 1fr auto 44px;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--line);
}
.part:last-child { border-bottom: 0; }
.part-icon {
  width: 44px; height: 28px;
  background: #eef1f4; border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
}
.part-icon svg { width: 36px; height: 22px; }
.part-name { font-weight: 600; font-size: 0.92rem; }
.part-sub { font-size: 0.72rem; color: var(--muted); }
.part-count { display: flex; align-items: center; gap: 4px; }
.part-count input {
  width: 46px; text-align: center; font-size: 0.95rem; font-weight: 600;
  border: 1px solid var(--line); border-radius: 7px; padding: 4px 2px;
  -moz-appearance: textfield;
}
.part-count input::-webkit-outer-spin-button,
.part-count input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
button.step {
  width: 26px; height: 26px; border: 0; border-radius: 7px;
  background: var(--ink); color: #fff; font-size: 1.1rem; line-height: 1;
  cursor: pointer; font-weight: 700;
}
button.step:hover { background: #2c3647; }
.part-used {
  font-size: 0.78rem; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums;
}
.part-used.over { color: var(--red); font-weight: 700; }

/* controls */
.controls { margin-top: 0.9rem; display: flex; flex-direction: column; gap: 0.6rem; }
.row { display: flex; gap: 0.5rem; align-items: center; }
select, .btn {
  font: inherit; border-radius: 9px; border: 1px solid var(--line);
  padding: 0.5rem 0.7rem; background: #fff; cursor: pointer;
}
.btn-primary {
  background: var(--yellow); border-color: #d8b400; font-weight: 700;
  flex: 1; box-shadow: 0 2px 0 #c9a800;
}
.btn-primary:hover { filter: brightness(1.03); }
.btn-primary:disabled { opacity: 0.6; cursor: default; }
.opt { display: flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; color: #3a4250; }

/* canvas / output */
.stage { padding: 0; overflow: hidden; }
#canvas {
  width: 100%;
  height: 540px;
  display: block;
  border-radius: 13px;
}
.stats {
  display: flex; flex-wrap: wrap; gap: 0.45rem;
  padding: 0.7rem 1rem; min-height: 1rem;
}
.badge {
  font-size: 0.8rem; background: #eef1f4; color: #3a4250;
  border-radius: 999px; padding: 0.25rem 0.7rem;
}
.badge b { color: var(--ink); }
.badge.ok { background: #e3f7ec; color: #1f8a4c; }
.badge.warn { background: #fdecec; color: var(--red); }

.note {
  font-size: 0.74rem; color: var(--muted); padding: 0 1rem 0.9rem;
  line-height: 1.5;
}
.note a { color: #1f6fd6; }
