:root {
  --bg: #100f0d;
  --ink: #f6f1ea;
  --heading: #fffaf4;
  --muted: #ddd4c8;
  --line: #3d3832;
  --card: #1b1a17;
  --field: #26231f;
  --side: #0c0b0a;
  --side-2: #221f1c;
  --side-text: #f7f2eb;
  --side-muted: #d2c9bd;
  --accent: #ff7a45;
  --fill: #f4efe6;
  --fill-ink: #161412;
  --ok: #8ee0b0;
  --warn: #ffd27a;
  --bad: #ffb4ac;
  color-scheme: dark;
  font-family: Bahnschrift, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:focus-visible, select:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.app {
  display: grid;
  grid-template-columns: 248px 1fr;
  height: 100vh;
  background:
    radial-gradient(900px 420px at 100% -10%, rgba(255, 122, 69, 0.16), transparent 58%),
    var(--bg);
}

aside {
  background: var(--side);
  color: var(--side-text);
  padding: 22px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 0;
  border-right: 1px solid #2a2724;
}

.brand { padding: 4px 10px 8px; }
.brand b {
  display: block;
  font-size: 22px;
  letter-spacing: 0.14em;
  color: var(--heading);
}
.brand span { color: var(--side-muted); font-size: 13px; font-weight: 600; }
.side-back {
  display: inline-block;
  margin: 0 10px;
  color: var(--heading);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.devices { display: flex; flex-direction: column; gap: 8px; }

.dev {
  text-align: left;
  background: transparent;
  color: var(--side-text);
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 12px;
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 10px;
  align-items: center;
}
.dev:hover { background: var(--side-2); }
.dev.active {
  background: #2a221c;
  color: var(--heading);
  border-color: #6a3a28;
}
.dev.active .dev-meta { color: #f0d2c4; }
.mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: #3a342e;
  color: var(--heading);
  font-size: 13px;
  font-weight: 700;
}
.dev.active .mark { background: var(--accent); color: #1a0d08; }
.dev-name { display: block; font-size: 15px; font-weight: 700; color: var(--heading); }
.dev-meta { display: block; color: var(--side-muted); font-size: 12px; font-weight: 600; margin-top: 2px; }

.side-note {
  margin-top: auto;
  color: var(--side-muted);
  font-size: 12px;
  line-height: 1.45;
  padding: 12px;
  border-top: 1px solid #2e2c29;
}

main { overflow: auto; padding: 22px 28px 48px; }
.wrap { max-width: 1180px; }

.top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-end;
  margin-bottom: 16px;
}
.kicker {
  margin: 0 0 6px;
  color: #ffb08a;
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
}
.top h1 {
  margin: 0;
  color: var(--heading);
  font-size: 36px;
  font-weight: 680;
  letter-spacing: -0.04em;
  line-height: 1;
}
.actions { display: flex; gap: 8px; align-items: center; }

.switch {
  display: flex;
  background: #2a2622;
  border: 1px solid #4a433c;
  border-radius: 12px;
  padding: 3px;
}
.switch button {
  border: 0;
  background: transparent;
  border-radius: 9px;
  padding: 8px 14px;
  color: var(--muted);
  font-weight: 650;
}
.switch button.active {
  background: var(--fill);
  color: var(--fill-ink);
}

.btn, .btn-line {
  border-radius: 10px;
  padding: 9px 14px;
  border: 1px solid transparent;
  font-weight: 700;
}
.btn { background: var(--fill); color: var(--fill-ink); }
.btn-line { background: transparent; color: var(--heading); border-color: #6e675e; }
.btn:hover:not(:disabled) { background: #fff; }
.btn-line:hover:not(:disabled) { border-color: var(--heading); }
.btn:disabled, .btn-line:disabled {
  opacity: 1;
  cursor: not-allowed;
}
.btn:disabled { background: #3a342e; color: #d9d0c4; }
.btn-line:disabled { color: #d9d0c4; border-color: #4e4841; }

.status {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 15px;
}
.status p { margin: 0; }
.pill {
  border-radius: 999px;
  padding: 4px 10px;
  background: #322e29;
  color: var(--heading);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.pill.ok { background: #163528; color: var(--ok); }
.pill.warn { background: #3a2c12; color: var(--warn); }
.pill.bad { background: #3d1c18; color: var(--bad); }

.callout {
  background: #2c2416;
  border: 1px solid #7a6230;
  color: #ffe7bf;
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 16px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 16px;
  align-items: start;
}

.board, .rail, .sheet {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 16px;
}
.board h2, .rail h2, .sheet h2 {
  margin: 0;
  color: var(--heading);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}
.head p { margin: 6px 0 0; color: var(--muted); font-size: 14px; line-height: 1.4; }

.ranges { display: flex; gap: 6px; }
.range {
  background: var(--field);
  color: var(--heading);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 10px;
  text-align: left;
  min-width: 92px;
  font-weight: 700;
}
.range small { display: block; color: var(--muted); font-size: 12px; font-weight: 650; margin-top: 2px; }
.range.active {
  background: var(--accent);
  color: #1a0d08;
  border-color: var(--accent);
}
.range.active small { color: #3b160c; }

.slots {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.pos {
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 176px;
}
.pos.live {
  background: #2c211c;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(255, 122, 69, 0.18);
}
.pos-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.pos-n {
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--heading);
  font-weight: 700;
}
.now {
  color: #ffb08a;
  font-size: 13px;
  font-weight: 700;
  min-height: 16px;
}
.pos select, .pos input, .rail select, .rail input, select, input[type="number"], input[type="text"] {
  width: 100%;
  background: #141311;
  color: var(--heading);
  border: 1px solid #5c554c;
  border-radius: 10px;
  padding: 10px 12px;
}
option { background: #1b1a17; color: var(--heading); }
.pos select, .pos input { font-size: 18px; font-weight: 700; }
.pos-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: auto; }
.pos-actions .btn, .pos-actions .btn-line { padding: 8px 8px; }

.rail { display: flex; flex-direction: column; gap: 16px; }
.rail h2 { margin-bottom: 4px; }
.hint { margin: 0 0 10px; color: var(--muted); font-size: 14px; line-height: 1.45; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.inline { display: flex; gap: 8px; }
.inline > * { flex: 1; }

.log {
  margin: 0;
  min-height: 120px;
  max-height: 180px;
  overflow: auto;
  background: #0c0b0a;
  color: #f6f1ea;
  border: 1px solid #3d3832;
  border-radius: 12px;
  padding: 10px 12px;
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.sheet { margin-top: 0; }
.sheet + .sheet { margin-top: 16px; }
.steps {
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.steps li {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
  background: var(--field);
  color: var(--ink);
  border-radius: 14px;
  padding: 12px;
  line-height: 1.45;
}
.steps.one { grid-template-columns: 1fr; }
.num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--fill);
  color: var(--fill-ink);
  font-size: 13px;
  font-weight: 700;
}

.pins {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 8px;
  margin: 16px 0 8px;
  background: #0c0b0a;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid #3d3832;
}
.pin {
  background: #2c2925;
  color: var(--heading);
  border-radius: 10px;
  min-height: 74px;
  padding: 8px 4px;
  text-align: center;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.25;
}
.pin b { display: block; font-size: 16px; margin-bottom: 4px; color: var(--heading); }
.pin.hot { background: var(--accent); color: #1a0d08; }
.pin.hot b { color: #1a0d08; }
.pin.gnd { background: #0c6a40; color: #ffffff; }
.pin.gnd b { color: #ffffff; }
.pin.bad { background: #a61f18; color: #ffffff; }
.pin.bad b { color: #ffffff; }
.legend { color: var(--muted); font-size: 14px; margin: 0 0 8px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--heading); font-weight: 700; font-size: 13px; letter-spacing: 0.04em; text-transform: uppercase; }
td { color: var(--ink); }
code {
  font-family: Consolas, "Cascadia Mono", monospace;
  background: #141311;
  color: var(--heading);
  padding: 2px 6px;
  border-radius: 6px;
}

@media (max-width: 1080px) {
  .workspace, .steps { grid-template-columns: 1fr; }
  .slots { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; height: auto; }
  aside { border-bottom: 1px solid #2e2c29; border-right: 0; }
  .side-note { margin-top: 8px; }
  main { padding: 16px; }
  .top { flex-direction: column; align-items: stretch; }
  .slots, .pins { grid-template-columns: 1fr 1fr; }
}
