:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #08111f;
  color: #e8eef7;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: radial-gradient(circle at top, #10223a 0, #08111f 42%, #050b14 100%);
}

button, input, select { font: inherit; }

.app {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 40px;
}

.topbar,
.device-bar,
.panel {
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(9, 18, 32, 0.82);
  box-shadow: 0 18px 55px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(14px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px;
  border-radius: 22px;
}

.brand { display: flex; align-items: center; gap: 16px; }
.logo {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: linear-gradient(135deg, #38bdf8, #22d3ee);
  color: #06111e;
  font-weight: 900;
  letter-spacing: 0.04em;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 4px; font-size: clamp(1.45rem, 3vw, 2rem); }
h2 { margin-bottom: 6px; font-size: 1.2rem; }
h3 { margin-bottom: 10px; }
p { margin-bottom: 0; color: #9fb0c5; line-height: 1.55; }

.connection-strip { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 7px 11px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.88);
  color: #cbd5e1;
  font-size: 0.85rem;
}

.dot { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 14px rgba(34, 197, 94, 0.7); }
.dot.warning { background: #f59e0b; box-shadow: 0 0 14px rgba(245, 158, 11, 0.7); }
.dot.danger { background: #ef4444; box-shadow: 0 0 14px rgba(239, 68, 68, 0.7); }

.device-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 320px) auto;
  align-items: center;
  gap: 14px;
  margin-top: 18px;
  padding: 16px 18px;
  border-radius: 18px;
}
.device-bar strong, .device-bar span { display: block; }
.device-bar span { margin-top: 3px; color: #94a3b8; font-size: 0.88rem; }

select,
.control-input {
  width: 100%;
  border: 1px solid #334155;
  border-radius: 11px;
  background: #0b1424;
  color: #e2e8f0;
  padding: 10px 12px;
  outline: none;
}
select:focus,
.control-input:focus { border-color: #38bdf8; box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.12); }

.button {
  border: 1px solid #334155;
  border-radius: 11px;
  background: #111c2e;
  color: #dbeafe;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 700;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}
.button:hover { transform: translateY(-1px); border-color: #64748b; }
.button.primary { border-color: transparent; background: linear-gradient(135deg, #38bdf8, #22d3ee); color: #06111e; }

.dashboard-content { margin-top: 18px; }
.panel { overflow: hidden; border-radius: 20px; }
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 20px 22px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
}
.panel-body { padding: 22px; }

.empty-state {
  border: 1px dashed #334155;
  border-radius: 14px;
  padding: 24px;
  color: #94a3b8;
  text-align: center;
}

.controls-list { display: grid; gap: 10px; }
.dynamic-group-title {
  margin: 20px 0 4px;
  padding-top: 8px;
  color: #bae6fd;
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.dynamic-group-title:first-child { margin-top: 0; }

.control-row {
  display: grid;
  grid-template-columns: minmax(150px, 0.8fr) minmax(220px, 1.6fr) minmax(80px, 0.5fr);
  align-items: center;
  gap: 18px;
  min-height: 62px;
  padding: 12px 14px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.64);
}
.control-name { font-weight: 700; color: #dce8f7; }
.control-editor { min-width: 0; }
.control-value { color: #7dd3fc; font-variant-numeric: tabular-nums; text-align: right; overflow-wrap: anywhere; }
.control-slider { width: 100%; accent-color: #38bdf8; }
.control-checkbox { width: 20px; height: 20px; accent-color: #38bdf8; }

.footer-note { margin-top: 18px; color: #64748b; text-align: center; font-size: 0.82rem; }
.footer-note code { color: #94a3b8; }

.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  place-items: center;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(5px);
}
.loading-screen.active { display: grid; }
.loading-card {
  display: flex;
  align-items: center;
  gap: 16px;
  width: min(440px, calc(100% - 32px));
  padding: 20px;
  border: 1px solid #334155;
  border-radius: 18px;
  background: #0b1424;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.4);
}
.loading-card strong, .loading-card span { display: block; }
.loading-card span { margin-top: 3px; color: #94a3b8; font-size: 0.88rem; }
.spinner {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border: 3px solid #1e293b;
  border-top-color: #38bdf8;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 780px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .connection-strip { justify-content: flex-start; }
  .device-bar { grid-template-columns: 1fr; }
  .panel-header { align-items: flex-start; flex-direction: column; }
  .control-row { grid-template-columns: 1fr; gap: 8px; }
  .control-value { text-align: left; }
}
