body {
  background-color: #121212;
  color: #e0e0e0;
  font-family: monospace;
  padding: 20px;
  margin: 0;
}

.shell {
  max-width: 600px;
  margin: 0 auto;
}

/* Header */
header {
  border-bottom: 1px solid #444;
  margin-bottom: 20px;
  padding-bottom: 10px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  grid-template-areas: "left title right";
  align-items: center;
  gap: 12px;
}

header h1 {
  grid-area: title;
  justify-self: center;
  margin: 0;
  font-size: 1.2rem;
  color: #c8f542;
}

#homeBtn {
  grid-area: left;
  justify-self: start;
  text-decoration: none;
  font-size: 0.85rem;
  text-align: center;
}

@media (max-width: 480px) {
  header {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "title title"
      "left right";
  }
}

/* Form & Inputs */
.section {
  margin-bottom: 20px;
}

.label {
  font-size: 0.8rem;
  color: #aaa;
  margin-bottom: 5px;
  text-transform: uppercase;
}

.row {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

input {
  background: #222;
  border: 1px solid #555;
  color: #fff;
  padding: 6px 10px;
  font-family: monospace;
}

.btn {
  background: #333;
  border: 1px solid #555;
  color: #fff;
  padding: 6px 12px;
  cursor: pointer;
  font-family: monospace;
}
.btn:hover { background: #444; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { border-color: #c8f542; color: #c8f542; }
.btn.primary:hover { background: #c8f542; color: #000; }
.btn.danger { border-color: #ff4545; color: #ff4545; }
.btn.selected { border-color: #42c8f5; color: #42c8f5; }
.btn.connected { border-color: #c8f542; color: #c8f542; }

/* Device Selection List */
.device-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 10px;
}
.device-item {
  background: #222;
  border: 1px solid #444;
  color: #fff;
  padding: 8px 12px;
  cursor: pointer;
  text-align: left;
  font-family: monospace;
  font-size: 0.8rem;
}
.device-item:hover {
  background: #333;
}
.device-item.selected {
  border-color: #c8f542;
  color: #c8f542;
  cursor: default;
}
#deviceList.has-selection .device-item:not(.selected) {
  display: none;
}

/* State & Status Bar */
.state-bar {
  background: #1e1e1e;
  padding: 10px;
  border: 1px solid #333;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}
.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #555;
  flex-shrink: 0;
}
.dot.active {
  background: #0f0;
  animation: pulse 1.8s infinite;
}
.dot.error {
  background: #f00;
}
.dot.waiting {
  background: #fa0;
}

@keyframes pulse {
  0%,
  100% { opacity: 1 }
  50% { opacity: .35 }
}

#stateText {
  color: #aaa;
  font-size: 0.9rem;
}

/* Stats Grid*/
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.stat-box {
  background: #1a1a1a;
  border: 1px solid #333;
  padding: 8px 10px;
}
.stat-label {
  font-size: 0.6rem;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 4px;
}
.stat-value {
  font-size: 0.9rem;
  color: #c8f542;
  font-weight: bold;
}

#chInfo {
  font-size: 0.65rem;
  color: #888;
  align-self: center;
}

/* Console Log */
.log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 5px;
}
.log-header .label {
  margin-bottom: 0;
}
.clear-log-btn {
  padding: 3px 8px;
  font-size: 0.7rem;
}

#log {
  background: #000;
  border: 1px solid #333;
  height: 150px;
  overflow-y: auto;
  padding: 10px;
  font-size: 0.8rem;
  line-height: 1.4;
}
.ts { color: #666; }
.ok { color: #c8f542; }
.err { color: #f00; }
.inf { color: #0af; }
