:root {
  --bg: #0b0e13;
  --panel: #141a23;
  --panel-2: #1a2230;
  --line: #26303f;
  --text: #e8edf3;
  --muted: #8b96a5;
  --accent: #ff9d2e;
  --cyan: #38e1ff;
  --green: #3ddc84;
  --red: #ff4d4d;
  --yellow: #ffc93d;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard", "Noto Sans KR", system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 22px;
  background: linear-gradient(180deg, #131924, #0d1219);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 14px; }
.brand-icon { font-size: 34px; }
.brand h1 { margin: 0; font-size: 20px; letter-spacing: -0.5px; }
.brand p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }

.sim-clock {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 16px;
  text-align: right;
}
.sim-clock .label { display: block; font-size: 11px; color: var(--muted); }
.sim-clock span:last-child {
  font-size: 20px; font-weight: 700; color: var(--cyan);
  font-variant-numeric: tabular-nums;
}

.alarm {
  background: linear-gradient(90deg, #5a1010, #7a1616);
  border-bottom: 2px solid var(--red);
  color: #ffe9e9;
  padding: 10px 22px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: blink 1.2s infinite;
}
.alarm.hidden { display: none; }
.alarm button {
  background: #fff; color: #7a1616; border: 0; border-radius: 6px;
  padding: 6px 12px; font-weight: 700; cursor: pointer;
}
@keyframes blink { 50% { opacity: 0.75; } }

.layout {
  display: flex;
  gap: 16px;
  padding: 16px 22px;
  flex: 1;
  min-height: 0;
}

.viewport-wrap {
  flex: 1;
  position: relative;
  background: #05070b;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  min-height: 560px;
}
#viewport { width: 100%; height: 100%; min-height: 560px; }
#viewport canvas { display: block; }
.viewport-hint {
  position: absolute; bottom: 10px; left: 12px;
  font-size: 12px; color: var(--muted);
  background: rgba(0,0,0,.55); padding: 4px 10px; border-radius: 6px;
}

.dashboard {
  width: 330px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
}
.panel h2 { margin: 0 0 10px; font-size: 14px; color: var(--accent); }
.panel .note { font-size: 12px; color: var(--muted); margin: 8px 0 0; }

.btn-row { display: flex; gap: 8px; margin-bottom: 10px; }
.btn {
  flex: 1;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 6px;
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: transform .05s, background .15s;
}
.btn:hover { background: #232e40; }
.btn:active { transform: scale(.97); }
.btn.primary { background: #0e5c46; border-color: #159a75; }
.btn.primary:hover { background: #11755a; }
.btn.danger { background: #5a1a1a; border-color: #a33333; }
.btn.danger:hover { background: #6e2020; }

.speed-row { margin-bottom: 10px; }
.speed-row label {
  display: flex; justify-content: space-between;
  font-size: 13px; margin-bottom: 6px;
}
.speed-row input[type="range"] { width: 100%; accent-color: var(--accent); }

.sensors { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sensor-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}
.sensor-card.warn { border-color: var(--yellow); }
.sensor-card.bad { border-color: var(--red); box-shadow: 0 0 8px rgba(255,77,77,.35); }
.sensor-head {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 12px; color: var(--muted); margin-bottom: 6px;
}
.sensor-head strong { font-size: 16px; color: var(--text); font-variant-numeric: tabular-nums; }
.sensor-card canvas { width: 100%; height: 56px; background: #0a0e14; border-radius: 6px; }
.sensor-sub { font-size: 10px; color: var(--muted); margin-top: 4px; }

.lamp-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.lamp {
  width: 14px; height: 14px; border-radius: 50%;
  background: #2a3342; border: 1px solid var(--line);
}
.lamp.on-green { background: var(--green); box-shadow: 0 0 8px var(--green); }
.lamp.on-yellow { background: var(--yellow); box-shadow: 0 0 8px var(--yellow); }
.lamp.on-red { background: var(--red); box-shadow: 0 0 8px var(--red); animation: blink 1s infinite; }

.foot {
  padding: 10px 22px;
  font-size: 12px; color: var(--muted);
  border-top: 1px solid var(--line);
  background: #0d1219;
}

@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .dashboard { width: 100%; }
  .viewport-wrap, #viewport { min-height: 380px; }
}
