:root {
  --bg: #0f1115;
  --card: #171a21;
  --card-edge: #262b36;
  --text: #e8ecf3;
  --muted: #98a1b3;
  --accent: #6366f1;
  --accent-hover: #4f52e0;
  --ok: #22c55e;
  --warn: #f59e0b;
  --err: #ef4444;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: 20px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 100dvh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0 8px;
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-dot {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}

.brand h1 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -0.02em; }
.brand .sub { margin: 1px 0 0; font-size: 12px; color: var(--muted); }

.badge {
  font-size: 11px; font-weight: 600; padding: 4px 9px; border-radius: 999px;
  border: 1px solid var(--card-edge);
}
.badge-idle { color: var(--muted); }
.badge-ok { color: var(--ok); border-color: rgba(34,197,94,.35); }
.badge-busy { color: var(--warn); border-color: rgba(245,158,11,.35); }
.badge-err { color: var(--err); border-color: rgba(239,68,68,.35); }

.card {
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: var(--radius);
  padding: 16px;
}

.label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 8px; }

.select {
  width: 100%; padding: 12px 14px; border-radius: 10px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--card-edge); font-size: 15px;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px; background-repeat: no-repeat;
}
.select:focus { outline: none; border-color: var(--accent); }
.select:disabled { opacity: .5; }

.hint { font-size: 12px; color: var(--muted); margin: 8px 0 0; min-height: 14px; }

.btn {
  width: 100%; padding: 14px; border-radius: 12px; border: none;
  font-size: 15px; font-weight: 600; cursor: pointer;
  transition: background .15s, transform .05s, opacity .15s;
}
.btn:active { transform: scale(.99); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:not(:disabled):hover { background: var(--accent-hover); }

.btn-ghost {
  background: transparent; color: var(--muted);
  border: 1px solid var(--card-edge); margin-top: 12px;
}
.btn-ghost:hover { color: var(--text); border-color: var(--muted); }

.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.card-head h2 { margin: 0; font-size: 15px; font-weight: 600; }

.status-line { font-size: 13px; color: var(--muted); min-height: 18px; margin-bottom: 10px; }

.device-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }

.device {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: 10px;
  background: var(--bg); border: 1px solid var(--card-edge);
}
.device-icon {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: 9px;
  display: grid; place-items: center; font-size: 15px;
  background: rgba(99,102,241,.15); color: var(--accent);
}
.device-body { flex: 1; min-width: 0; }
.device-name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.device-meta { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.device-tag {
  flex: 0 0 auto; font-size: 11px; padding: 3px 8px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--card-edge); color: var(--muted);
}

.empty { padding: 22px 0; text-align: center; color: var(--muted); font-size: 13px; }

.foot { text-align: center; font-size: 11px; color: var(--muted); margin-top: auto; padding-top: 12px; }

@media (min-width: 600px) {
  .app { padding: 32px 20px 48px; }
  .card { padding: 20px; }
}
