:root {
  --bg: #e8edf1;
  --panel: #ffffff;
  --panel-2: #f6f8fa;
  --ink: #16202a;
  --muted: #637282;
  --line: #c9d2da;
  --blue: #1769aa;
  --green: #15845b;
  --amber: #c87811;
  --red: #c2352a;
  --dark: #263746;
  --shadow: 0 12px 28px rgba(28, 43, 58, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #d8e0e7 0%, var(--bg) 45%, #dce4ea 100%);
  color: var(--ink);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
}

button,
input {
  font: inherit;
}

button {
  min-height: 48px;
  border: 1px solid #9fb0bf;
  border-radius: 6px;
  background: linear-gradient(180deg, #ffffff, #dfe8ef);
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

button:active {
  transform: translateY(1px);
}

button.primary {
  border-color: #0c548e;
  background: linear-gradient(180deg, #2384ce, #155f9a);
  color: #fff;
}

button.danger {
  border-color: #92271f;
  background: linear-gradient(180deg, #dd4a3e, #a72f27);
  color: #fff;
}

.hmi {
  width: min(1360px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 86px;
  padding: 14px 18px;
  border: 1px solid #aebbc6;
  border-radius: 8px;
  background: var(--dark);
  color: #fff;
  box-shadow: var(--shadow);
}

.topbar h1,
.topbar p,
.section-title h2,
.axis-head h2 {
  margin: 0;
}

.topbar h1 {
  font-size: 30px;
  line-height: 1.15;
}

.topbar p {
  margin-top: 6px;
  color: #d5dde4;
}

.status-strip {
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  gap: 8px 12px;
  min-width: 170px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
}

#clock {
  grid-column: 1 / -1;
  color: #dce7ef;
  font-variant-numeric: tabular-nums;
}

.lamp {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(21, 132, 91, 0.22), 0 0 16px rgba(21, 132, 91, 0.85);
}

.lamp-run {
  background: var(--amber);
  box-shadow: 0 0 0 3px rgba(200, 120, 17, 0.24), 0 0 16px rgba(200, 120, 17, 0.85);
}

.lamp-alarm {
  background: var(--red);
  box-shadow: 0 0 0 3px rgba(194, 53, 42, 0.22), 0 0 16px rgba(194, 53, 42, 0.85);
}

.axis-panel {
  display: grid;
  grid-template-columns: repeat(5, minmax(160px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.axis-card,
.recipe-panel,
.preview-panel,
.table-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.axis-card {
  padding: 12px;
}

.axis-card.fixed {
  border-color: #d5a54e;
}

.axis-head,
.section-title,
.progress,
.mode-row,
.action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.axis-head h2 {
  font-size: 22px;
}

.servo-on {
  padding: 4px 8px;
  border-radius: 999px;
  background: #dff4eb;
  color: #0f6f4b;
  font-size: 13px;
  font-weight: 700;
}

.axis-pos {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 12px 0;
  padding: 10px;
  border: 1px solid #b8c4cf;
  border-radius: 6px;
  background: #101820;
  color: #39e390;
  font-size: 28px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.axis-pos small {
  color: #b8e6cd;
  font-size: 14px;
}

.jog-row {
  display: grid;
  grid-template-columns: 56px 1fr 56px;
  gap: 8px;
}

.jog {
  font-size: 28px;
}

.work-area {
  display: grid;
  grid-template-columns: minmax(420px, 0.85fr) minmax(520px, 1.15fr);
  gap: 14px;
  margin-top: 14px;
}

.recipe-panel,
.preview-panel,
.table-panel {
  padding: 14px;
}

.section-title {
  min-height: 48px;
  margin-bottom: 12px;
}

.section-title h2 {
  font-size: 24px;
}

.section-title span {
  color: var(--muted);
  font-weight: 700;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: #40505f;
  font-weight: 700;
}

input[type="number"] {
  width: 100%;
  min-height: 48px;
  padding: 8px 10px;
  border: 1px solid #aebbc6;
  border-radius: 6px;
  background: #fbfcfd;
  color: var(--ink);
  font-size: 20px;
  font-weight: 700;
}

.mode-row {
  justify-content: flex-start;
  margin: 14px 0;
}

.check {
  display: inline-flex;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  min-height: 40px;
}

.check input {
  width: 22px;
  height: 22px;
}

.action-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
}

.tray-wrap {
  min-height: 360px;
  border: 1px solid #aebbc6;
  border-radius: 8px;
  background: #eef3f6;
  overflow: hidden;
}

canvas {
  display: block;
  width: 100%;
  height: 360px;
}

.progress {
  margin-top: 12px;
}

.progress strong {
  min-width: 84px;
  color: var(--blue);
  font-size: 24px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

meter {
  flex: 1;
  height: 22px;
}

.table-panel {
  margin-top: 14px;
}

.table-scroll {
  max-height: 270px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid #d9e0e6;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

th {
  position: sticky;
  top: 0;
  background: #edf2f6;
  color: #3a4a59;
  z-index: 1;
}

th:first-child,
td:first-child {
  text-align: center;
}

tr.active-row {
  background: #fff6df;
  color: #8c5600;
  font-weight: 800;
}

@media (max-width: 980px) {
  .axis-panel,
  .work-area {
    grid-template-columns: 1fr;
  }

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

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 620px) {
  .hmi {
    padding: 10px;
  }

  .axis-panel,
  .form-grid,
  .action-row {
    grid-template-columns: 1fr;
  }

  .topbar h1 {
    font-size: 24px;
  }
}
