:root {
  --cabinet: #5f655d;
  --cabinet-dark: #3e443f;
  --screen: #13d2c7;
  --screen-deep: #0faaa2;
  --ink: #1f2628;
  --paper: #f4efe5;
  --accent: #f4a23a;
  --danger: #b41111;
  --ok: #0f8f55;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  background:
    radial-gradient(circle at 12% 18%, rgba(255, 232, 175, 0.34), transparent 28rem),
    linear-gradient(135deg, #202823 0%, #596158 48%, #222926 100%);
}

button,
input,
select {
  font: inherit;
}

.shell {
  display: grid;
  grid-template-columns: minmax(760px, 1fr) 390px;
  gap: 28px;
  width: min(1680px, 96vw);
  margin: 28px auto;
}

.machine {
  position: relative;
  display: grid;
  grid-template-columns: 110px minmax(640px, 1fr) 170px;
  grid-template-rows: repeat(3, minmax(120px, auto));
  align-items: center;
  gap: 26px;
  min-height: 560px;
  padding: 54px 34px;
  border: 8px solid #242924;
  border-radius: 24px;
  background:
    linear-gradient(145deg, rgba(255,255,255,0.13), transparent 28%),
    var(--cabinet);
  box-shadow: 0 28px 70px rgba(0,0,0,0.46), inset 0 2px 0 rgba(255,255,255,0.22);
}

.panel {
  grid-column: 2;
  grid-row: 1 / 4;
  min-width: 0;
  width: 100%;
  border: 20px solid #151818;
  border-radius: 12px;
  background: #111;
  box-shadow: inset 0 0 0 2px #30363a, 0 8px 22px rgba(0,0,0,0.45);
}

.panel-top {
  display: grid;
  grid-template-columns: 1fr 140px 1fr 130px;
  align-items: center;
  min-height: 76px;
  padding: 0 16px;
  border-bottom: 2px solid #243335;
  background: linear-gradient(#e9e3db, #cac5bf);
  font-size: 29px;
}

.panel-top strong {
  text-align: center;
  font-size: 46px;
  font-weight: 500;
}

.set-button {
  min-height: 56px;
  border: 2px solid #a96c2b;
  background: linear-gradient(#ffc876, #e2872b);
}

.hmi-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr 0.7fr 1.1fr 1.1fr 0.8fr;
  min-height: 290px;
  background: var(--screen);
  border-bottom: 4px solid #087870;
}

.hmi-grid > * {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 72px;
  padding: 8px;
  border-right: 2px solid #087870;
  border-bottom: 2px solid #087870;
  text-align: center;
  font-size: 27px;
}

.hmi-grid label {
  justify-content: flex-start;
  padding-left: 22px;
}

.hmi-grid input {
  width: 100%;
  border: 0;
  color: var(--ink);
  background: rgba(255,255,255,0.18);
  text-align: center;
  font-size: 28px;
}

.hmi-grid button {
  border: 0;
  background: rgba(255,255,255,0.16);
  color: #355;
}

.soft-keys {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
  padding: 22px;
  background: var(--screen);
}

.soft-keys button {
  min-height: 58px;
  border: 4px solid #2460a7;
  background: linear-gradient(#ece4d4, #c9bba9);
  color: #183f75;
  font-size: 24px;
}

.beacon,
.round,
.mushroom {
  border-radius: 999px;
  border: 5px solid #222;
  box-shadow: inset 0 7px 18px rgba(255,255,255,0.4), inset 0 -10px 24px rgba(0,0,0,0.38), 0 6px 14px rgba(0,0,0,0.36);
}

.beacon {
  width: 86px;
  height: 86px;
  margin: 24px auto;
}

#redLamp {
  grid-column: 1;
  grid-row: 1;
}

#greenLamp {
  grid-column: 1;
  grid-row: 2;
}

#stopBtn {
  grid-column: 1;
  grid-row: 3;
}

.beacon-red {
  background: #4c0d0d;
}

.beacon-red.on {
  background: #ff1717;
  box-shadow: 0 0 28px 8px rgba(255,0,0,0.75), inset 0 7px 18px rgba(255,255,255,0.5);
}

.beacon-green {
  background: #103d25;
}

.beacon-green.on {
  background: #18bc69;
  box-shadow: 0 0 26px 7px rgba(36,255,146,0.48), inset 0 7px 18px rgba(255,255,255,0.5);
}

.round {
  display: block;
  width: 92px;
  height: 92px;
  margin: 24px auto;
  background: #b71919;
  color: var(--paper);
  font-weight: 700;
}

.round.green {
  background: #158d53;
}

.right-controls {
  grid-column: 3;
  grid-row: 1 / 4;
  display: flex;
  flex-direction: column;
  gap: 20px;
  align-items: center;
}

.mushroom {
  width: 132px;
  height: 132px;
  background: #8f1515;
  color: var(--paper);
  padding: 20px;
  font-weight: 700;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.toolbar,
.card,
.status-line {
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 18px;
  background: rgba(245, 241, 230, 0.92);
  box-shadow: 0 18px 50px rgba(0,0,0,0.25);
}

.toolbar {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  padding: 14px;
}

.card {
  padding: 18px;
}

.card h2 {
  margin: 0 0 14px;
  font-size: 22px;
}

.card label {
  display: block;
  margin: 10px 0;
}

.card input[type="number"],
select {
  width: 100%;
  margin-top: 6px;
  padding: 10px;
  border: 1px solid #bcb3a3;
  border-radius: 10px;
  background: #fffaf0;
}

.card button,
.toolbar select {
  padding: 10px 12px;
}

.signals {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-family: "Courier New", monospace;
  font-size: 13px;
}

th,
td {
  padding: 8px;
  border-bottom: 1px solid #d4caba;
  text-align: left;
}

.status-line {
  padding: 14px 16px;
}

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

  .machine {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: auto auto auto;
    min-height: auto;
    padding: 28px 18px;
  }

  #redLamp {
    grid-column: 1;
    grid-row: 1;
  }

  #greenLamp {
    grid-column: 2;
    grid-row: 1;
  }

  #stopBtn {
    grid-column: 3;
    grid-row: 1;
  }

  .panel {
    grid-column: 1 / -1;
    grid-row: 2;
    overflow-x: auto;
  }

  .right-controls {
    grid-column: 1 / -1;
    grid-row: 3;
    flex-direction: row;
    justify-content: center;
  }
}

@media (max-width: 760px) {
  .shell {
    width: min(100vw - 20px, 100%);
    margin: 10px auto;
  }

  .machine {
    grid-template-columns: repeat(3, minmax(86px, 1fr));
    gap: 14px;
    border-width: 5px;
  }

  .panel-top,
  .hmi-grid,
  .soft-keys {
    min-width: 680px;
  }

  .hmi-grid > * {
    font-size: 22px;
  }

  .soft-keys button {
    font-size: 20px;
  }

  .mushroom {
    width: 112px;
    height: 112px;
  }
}
