* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: #0d0f14;
  color: #cdd6e0;
  font-family: 'Segoe UI', 'Roboto', system-ui, sans-serif;
  font-size: 14px;
  padding: 16px;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

#app {
  max-width: 1100px;
  width: 100%;
  background: #161b22;
  border-radius: 16px;
  padding: 20px 24px 28px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.7);
  border: 1px solid #2d3540;
  transition: all 0.2s;
}

/* ===== 头部 ===== */
.header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 20px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid #2d3540;
}

.header .title {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.header .title .badge {
  font-size: 12px;
  background: #2d3540;
  padding: 2px 10px;
  border-radius: 20px;
  font-weight: 400;
  color: #8b9bb5;
}

.header .conn {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
}

.header .conn .status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

.status .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  transition: 0.2s;
}

.dot.on {
  background: #3fb950;
  box-shadow: 0 0 8px #3fb95088;
}

.dot.off {
  background: #6e7681;
}

.dot.err {
  background: #da3633;
  box-shadow: 0 0 8px #da363388;
}

.btn {
  background: #2d3540;
  border: none;
  color: #cdd6e0;
  padding: 6px 16px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: 0.15s;
  font-weight: 500;
  white-space: nowrap;
}

.btn:hover {
  background: #3d4655;
}

.btn:active {
  transform: scale(0.97);
}

.btn.primary {
  background: #238636;
  color: #fff;
}

.btn.primary:hover {
  background: #2ea043;
}

.btn.danger {
  background: #b62324;
  color: #fff;
}

.btn.danger:hover {
  background: #da3633;
}

.btn.small {
  padding: 4px 12px;
  font-size: 12px;
}

.btn:disabled {
  opacity: 0.4;
  pointer-events: none;
}

select,
input[type='number'],
input[type='text'] {
  background: #0d1117;
  border: 1px solid #30363d;
  color: #cdd6e0;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: 0.15s;
  min-width: 50px;
}

select:focus,
input:focus {
  border-color: #58a6ff;
  box-shadow: 0 0 0 3px #1f6feb33;
}

select option {
  background: #161b22;
}

input[type='number'] {
  width: 60px;
}

input[type='text'] {
  min-width: 70px;
}

.port-select {
  max-width: 180px;
}

.baud-select {
  max-width: 100px;
}

@media (max-width: 700px) {
  .header .conn {
    margin-left: 0;
    width: 100%;
    justify-content: flex-start;
  }

  .panels {
    grid-template-columns: 1fr;
  }

  .panel .field {
    flex-wrap: wrap;
  }

  .panel .field .actions {
    margin-left: 0;
    width: 100%;
    justify-content: flex-start;
  }

  .panel .gpio-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .cmd-row {
    flex-direction: column;
    align-items: stretch;
  }

  .cmd-row .cmd-btns {
    justify-content: flex-start;
  }

  #app {
    padding: 14px 12px 20px;
  }

  .terminal-wrap .term-header {
    flex-wrap: wrap;
    gap: 4px;
  }

  .terminal-wrap .term-header .header-right {
    flex-wrap: wrap;
  }

  .sense-grid {
    font-size: 11px;
  }
}

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid #2d3540;
  border-top-color: #58a6ff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.mt-1 {
  margin-top: 4px;
}

.flex {
  display: flex;
  align-items: center;
  gap: 6px;
}

.gap-1 {
  gap: 4px;
}

.text-muted {
  color: #6e7681;
  font-size: 12px;
}

.w-full {
  width: 100%;
}

.hidden {
  display: none !important;
}