:root {
  --bg: #0b0d12;
  --panel: #15171d;
  --panel-2: #1d2028;
  --line: #343946;
  --muted: #9ba4b6;
  --text: #eef2ff;
  --blue: #9dbbff;
  --blue-strong: #4b7ddd;
  --green: #37d16c;
  --orange: #ffb36b;
  --red: #ffaaa2;
  --shadow: rgba(0, 0, 0, 0.36);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 78% 18%, rgba(61, 117, 220, 0.16), transparent 28rem),
    linear-gradient(135deg, #0b0d12, #12151c 60%, #0a0b0f);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

button:hover {
  transform: translateY(-1px);
}

.app {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: rgba(19, 21, 27, 0.92);
  padding: 24px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px 24px;
  color: var(--blue);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.brand-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  background: #10131a;
  color: var(--blue);
}

.section-label,
.eyebrow,
.module-title,
.readout span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.sidebar h1 {
  margin: 0;
  padding: 0 24px 24px;
  color: var(--blue);
  font-size: 1.35rem;
  line-height: 1.25;
  text-transform: uppercase;
}

.section-label {
  padding: 0 24px 10px;
}

.machine-list {
  display: grid;
  gap: 4px;
}

.machine {
  width: 100%;
  border: 0;
  border-left: 4px solid transparent;
  background: transparent;
  color: #cbd3e6;
  cursor: pointer;
  padding: 16px 24px;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.78rem;
  font-weight: 800;
}

.machine::before {
  content: "≋";
  margin-right: 12px;
  color: #dce5ff;
}

.machine:hover,
.machine.active {
  border-left-color: var(--blue);
  background: var(--blue-strong);
  color: #071021;
}

.panel {
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 74px;
  border: 1px solid var(--line);
  background: rgba(21, 23, 29, 0.86);
  padding: 18px 22px;
  box-shadow: 0 16px 40px var(--shadow);
}

.topbar h2 {
  margin: 4px 0 0;
  color: var(--blue);
  font-size: clamp(1.35rem, 2vw, 2.25rem);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.eyebrow {
  margin: 0;
}

.status-pill {
  border: 1px solid rgba(55, 209, 108, 0.7);
  color: var(--green);
  background: rgba(55, 209, 108, 0.08);
  padding: 10px 16px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.status-pill.running {
  border-color: rgba(157, 187, 255, 0.72);
  color: var(--blue);
  background: rgba(157, 187, 255, 0.1);
}

.status-pill.alert {
  border-color: rgba(255, 170, 162, 0.74);
  color: var(--red);
  background: rgba(255, 170, 162, 0.1);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(300px, 420px) 1fr;
  gap: 18px;
  margin-top: 18px;
  min-width: 0;
}

.controls,
.readouts {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.module,
.readout {
  border: 1px solid var(--line);
  background: rgba(20, 22, 28, 0.92);
  box-shadow: 0 16px 40px var(--shadow);
  min-width: 0;
}

.module {
  padding: 20px;
}

.module-title {
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
  padding-bottom: 14px;
  color: #cbd6ef;
}

.field,
.range-field {
  display: grid;
  gap: 8px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
}

.field {
  position: relative;
}

.field input {
  width: 100%;
  border: 1px solid var(--line);
  background: #0d0f14;
  color: var(--blue);
  outline: none;
  padding: 13px 60px 13px 14px;
  text-align: right;
  font-weight: 900;
}

.field small {
  position: absolute;
  left: 14px;
  bottom: 14px;
  color: var(--muted);
  text-transform: none;
}

.machine-preview {
  display: grid;
  min-height: 250px;
  align-content: end;
  gap: 22px;
}

.screw {
  position: relative;
  height: 80px;
  overflow: hidden;
  border: 1px solid #252b38;
  background: #0d0f14;
}

.screw span {
  position: absolute;
  top: 28px;
  width: 86px;
  height: 24px;
  border: 3px solid var(--blue);
  border-left: 0;
  border-radius: 0 40px 40px 0;
  opacity: 0.65;
}

.screw span:nth-child(1) { left: -20px; }
.screw span:nth-child(2) { left: 42px; }
.screw span:nth-child(3) { left: 104px; }
.screw span:nth-child(4) { left: 166px; }
.screw span:nth-child(5) { left: 228px; }

.screw.running span {
  animation: screwMove 0.8s linear infinite;
}

@keyframes screwMove {
  from { transform: translateX(0); }
  to { transform: translateX(62px); }
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.actions .primary {
  grid-column: 1 / -1;
}

button {
  min-height: 48px;
  border: 1px solid var(--line);
  cursor: pointer;
  font-weight: 900;
  text-transform: uppercase;
}

.primary {
  background: var(--blue);
  color: #0d1c3b;
}

.secondary {
  background: #0d0f14;
  color: #dbe4f8;
}

.danger {
  background: var(--red);
  color: #661812;
}

.weld-models {
  display: grid;
  gap: 18px;
}

.weld-models .field {
  margin-top: 0;
}

.weld-models .field input {
  padding-right: 14px;
  text-align: left;
  text-transform: none;
}

.model-list {
  display: grid;
  gap: 10px;
  max-height: 360px;
  overflow: auto;
  padding-right: 4px;
}

.empty-state {
  margin: 0;
  border: 1px dashed var(--line);
  color: var(--muted);
  padding: 16px;
  text-align: center;
}

.model-item {
  display: grid;
  gap: 12px;
  border: 1px solid #2d3340;
  background: #0d0f14;
  padding: 14px;
}

.model-item strong {
  display: block;
  color: var(--text);
  font-size: 0.98rem;
}

.model-item span {
  display: block;
  color: var(--blue);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.model-item dl {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.model-item div {
  min-width: 0;
}

.model-item dt {
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.model-item dd {
  margin: 4px 0 0;
  color: #f5f7ff;
  font-size: 0.82rem;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toggle-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 20px;
}

.toggle {
  min-height: 44px;
  background: #0d0f14;
  color: #cbd3e6;
  font-size: 0.76rem;
}

.toggle.active {
  border-color: rgba(55, 209, 108, 0.7);
  color: var(--green);
  background: rgba(55, 209, 108, 0.08);
}

.range-field {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.range-field input {
  grid-column: 1 / -1;
  accent-color: var(--blue);
}

.range-field strong {
  color: var(--blue);
  font-size: 1.15rem;
}

.readouts {
  grid-template-columns: repeat(3, minmax(190px, 1fr));
}

.readout {
  display: grid;
  min-height: 210px;
  padding: 22px;
  align-content: center;
  gap: 28px;
}

.readout strong {
  color: #f5f7ff;
  display: block;
  max-width: 100%;
  overflow: hidden;
  font-size: clamp(1.55rem, 2.4vw, 2.85rem);
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
  text-align: right;
  white-space: nowrap;
}

.readout small {
  color: var(--muted);
  font-size: 0.9rem;
}

.bar {
  width: 100%;
  height: 4px;
  background: #252832;
  overflow: hidden;
}

.bar i {
  display: block;
  max-width: 100%;
  width: 30%;
  height: 100%;
  background: var(--blue);
  transition: width 0.25s ease;
}

.accent strong {
  color: var(--orange);
}

.accent .bar i {
  background: var(--orange);
}

.warm .bar i {
  background: var(--red);
}

.fan-card,
.light-card {
  min-height: 230px;
}

.fan-visual {
  position: relative;
  justify-self: end;
  width: 84px;
  height: 84px;
  border: 2px solid var(--line);
  border-radius: 50%;
}

.fan-visual::before {
  content: "";
  position: absolute;
  inset: 32px;
  border-radius: 50%;
  background: var(--blue);
}

.fan-visual span {
  position: absolute;
  left: 38px;
  top: 7px;
  width: 10px;
  height: 34px;
  border-radius: 20px 20px 4px 4px;
  background: var(--blue);
  transform-origin: 4px 35px;
}

.fan-visual span:nth-child(2) {
  transform: rotate(120deg);
}

.fan-visual span:nth-child(3) {
  transform: rotate(240deg);
}

.fan-visual.spinning {
  animation: fanSpin 0.85s linear infinite;
}

@keyframes fanSpin {
  to { transform: rotate(360deg); }
}

.lamp {
  justify-self: end;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: #292312;
  box-shadow: 0 0 0 rgba(255, 197, 91, 0);
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.lamp.on {
  background: #ffd36f;
  box-shadow: 0 0 52px rgba(255, 195, 88, 0.68);
}

@media (max-width: 980px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .machine-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workspace {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .panel {
    padding: 14px;
  }

  .topbar,
  .toggle-row,
  .actions,
  .model-item dl {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
    gap: 16px;
  }

  .readouts {
    grid-template-columns: 1fr;
  }

  .machine-list {
    grid-template-columns: 1fr;
  }
}
