:root {
  --green: #73a329;
  --orange: #ee6422;
  --ink: #24272d;
  --muted: #667085;
  --line: #d9dee6;
  --bg: #eaeaea;
  --panel: #ffffff;
  --soft: #f6f8fa;
  --dark: #3e4147;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  min-height: 100vh;
}

.side-menu {
  background: var(--panel);
  margin: 14px 7px;
  border-radius: 5px;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.brand {
  height: 54px;
  display: grid;
  place-items: center;
  color: var(--green);
  font-weight: 700;
  border-bottom: 1px solid var(--line);
  margin-bottom: 8px;
}

.nav-link {
  height: 62px;
  border-radius: 5px;
  display: grid;
  place-items: center;
  color: var(--ink);
  text-decoration: none;
  gap: 2px;
}

.nav-link span {
  font-size: 13px;
}

.nav-link .material-symbols-outlined {
  font-size: 26px;
}

.nav-link:hover,
.nav-link.active {
  color: #fff;
  background: var(--green);
}

.main {
  margin: 14px 14px 14px 4px;
  overflow: hidden;
}

.topbar {
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 10px;
}

.title h1 {
  font-size: 22px;
  margin: 0;
  font-weight: 600;
}

.title p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.status-strip {
  display: flex;
  gap: 8px;
  align-items: center;
}

.pill {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 5px;
  padding: 8px 10px;
  min-width: 118px;
  font-size: 13px;
}

.pill strong {
  display: block;
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
}

.panel {
  background: var(--panel);
  border-radius: 5px;
  min-height: calc(100vh - 92px);
  overflow: auto;
}

.panel-pad {
  padding: 18px;
}

.grid {
  display: grid;
  gap: 12px;
}

.grid.cols-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.grid.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.metric {
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 14px;
  background: var(--soft);
}

.metric label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

.metric strong {
  font-size: 24px;
  font-weight: 600;
}

.metric small {
  color: var(--muted);
}

.section-title {
  font-size: 15px;
  margin: 22px 0 10px;
  color: var(--muted);
  font-weight: 600;
}

.program-summary {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(420px, 1.2fr);
  gap: 12px;
}

.station-list,
.event-list {
  border: 1px solid var(--line);
  border-radius: 5px;
  overflow: hidden;
}

.row {
  display: grid;
  grid-template-columns: 90px 1fr 120px 120px;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.row:last-child {
  border-bottom: 0;
}

.row.header {
  background: var(--soft);
  color: var(--green);
  font-weight: 700;
}

.flow-map {
  min-height: 320px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fbfcfd;
  position: relative;
  overflow: hidden;
}

.flow-map svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.flow-node {
  position: absolute;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 5px;
}

.flow-node img {
  width: 34px;
  height: 34px;
}

.keypad-wrap {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 130px);
}

.keypad {
  background: #9da1a7;
  width: min(900px, 100%);
  aspect-ratio: 9 / 5;
  border: #e4e5e9 1px solid;
  border-radius: 10px;
  display: grid;
  grid-template-columns: 250px 1fr;
}

.lights {
  padding: 220px 0 0 48px;
  color: #e4e5e9;
  font-size: 13px;
}

.light-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.light {
  width: 12px;
  height: 12px;
  background: #404145;
}

.light.on {
  background: var(--green);
}

.display-row {
  display: flex;
  justify-content: center;
  margin-top: 70px;
}

.side-key {
  width: 100px;
  height: 70px;
  background: var(--dark);
  border: #acafb6 3px solid;
}

.side-key.left {
  border-radius: 40px 0 0 40px;
}

.side-key.right {
  border-radius: 0 40px 40px 0;
}

.lcd {
  width: 305px;
  height: 70px;
  margin: 0 3px;
  background: #a9deff;
  border: var(--dark) 3px solid;
  color: var(--dark);
  font-family: "Courier New", monospace;
  font-size: 22px;
  line-height: 30px;
  padding: 4px 18px;
  white-space: pre;
}

.keys {
  margin: 40px auto 0;
  width: 480px;
  height: 260px;
  border: #acafb6 3px solid;
  background: var(--dark);
  border-radius: 40px;
  display: grid;
  grid-template-columns: repeat(5, 60px);
  gap: 16px 22px;
  justify-content: center;
  align-content: center;
}

.key {
  width: 60px;
  height: 60px;
  border: 0;
  border-radius: 7px;
  background: #fff;
  cursor: pointer;
}

.key:hover {
  outline: 3px solid var(--green);
}

.key.empty {
  background: var(--dark);
  cursor: default;
}

.action-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.btn {
  border: 1px solid #555;
  color: #555;
  background: #fff;
  border-radius: 5px;
  min-height: 38px;
  padding: 0 16px;
  cursor: pointer;
}

.btn:hover,
.btn.active {
  color: #fff;
  background: var(--green);
  border-color: var(--green);
}

.btn.primary {
  color: #fff;
  background: var(--orange);
  border-color: var(--orange);
}

.editor {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: 14px;
}

.form-panel {
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 14px;
  background: var(--soft);
}

.field {
  margin-bottom: 12px;
}

.field label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 5px;
}

.field input,
.field select {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0 10px;
  background: #fff;
}

.valve-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
}

.valve-toggle {
  min-height: 34px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 5px;
  cursor: pointer;
}

.valve-toggle.selected {
  border-color: var(--green);
  background: #eef7e7;
  color: #375a12;
  font-weight: 700;
}

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

  .side-menu {
    flex-direction: row;
    margin: 8px;
    overflow-x: auto;
  }

  .nav-link {
    min-width: 84px;
  }

  .main {
    margin: 0 8px 8px;
  }

  .topbar,
  .program-summary,
  .editor {
    grid-template-columns: 1fr;
    display: grid;
    height: auto;
  }

  .grid.cols-4,
  .grid.cols-3 {
    grid-template-columns: 1fr 1fr;
  }

  .keypad {
    transform: scale(0.72);
  }
}
