:root {
  --bg: #0b0d10;
  --bg-elev: #14181d;
  --bg-elev-2: #1c2128;
  --line: #2a313b;
  --text: #e6edf3;
  --dim: #7d8590;
  --accent: #58a6ff;
  --accent-2: #7ee787;
  --danger: #f85149;
  --warn: #d29922;
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, monospace;
}

* { box-sizing: border-box }
html, body { margin: 0; padding: 0 }
body {
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Inter", system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 20% -10%, rgba(88,166,255,.08), transparent 60%),
    radial-gradient(900px 500px at 110% 10%, rgba(126,231,135,.06), transparent 60%),
    var(--bg);
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none }
a:hover { text-decoration: underline }
.dim { color: var(--dim) }
.mono { font-family: var(--mono); font-size: 12.5px; color: var(--dim) }
.muted { color: var(--dim); font-size: 12.5px; margin: 4px 0 12px }

/* === auth === */
body.auth {
  display: grid; place-items: center;
}
.card {
  width: min(380px, 92vw);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: 0 30px 80px -30px rgba(0,0,0,.7);
}
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px }
.brand h1 { font-size: 17px; margin: 0; font-weight: 600 }
.logo {
  width: 28px; height: 28px; border-radius: 50%;
  background: conic-gradient(from 220deg, #58a6ff, #7ee787, #d29922, #58a6ff);
  filter: blur(.3px);
  box-shadow: 0 0 20px rgba(88,166,255,.4);
}
form label { display: block; margin: 12px 0; font-size: 12.5px; color: var(--dim) }
input, textarea, select {
  width: 100%; padding: 9px 11px; margin-top: 4px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 7px;
  font: inherit; font-family: inherit;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(88,166,255,.15);
}
button {
  margin-top: 8px; padding: 9px 14px;
  background: var(--accent); color: #0b0d10;
  font-weight: 600; border: 0; border-radius: 7px;
  cursor: pointer; font-family: inherit;
}
button:hover { filter: brightness(1.08) }
button.danger { background: var(--danger); color: #fff }
button.ghost, a.ghost {
  background: transparent; color: var(--text);
  border: 1px solid var(--line); padding: 7px 12px;
  border-radius: 7px;
}
.error {
  color: var(--danger); background: rgba(248,81,73,.08);
  border: 1px solid rgba(248,81,73,.3);
  padding: 8px 10px; border-radius: 7px; font-size: 13px;
  margin: 10px 0;
}

/* === topbar === */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 24px;
  background: rgba(11,13,16,.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand-mini { display: flex; align-items: center; gap: 8px; font-weight: 600 }
.brand-mini .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 12px var(--accent-2);
}
.right { display: flex; align-items: center; gap: 12px }
.who { color: var(--dim); font-size: 12.5px }

/* === dashboard layout === */
#app { padding: 24px; max-width: 1400px; margin: 0 auto }
.empty {
  text-align: center; padding: 80px 20px; color: var(--dim);
}
.empty h2 { color: var(--text); margin-bottom: 6px }

.device {
  display: grid; grid-template-columns: 320px 1fr; gap: 20px;
  margin-bottom: 24px;
}
@media (max-width: 900px) { .device { grid-template-columns: 1fr } }

.status {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  align-self: start;
}
.status-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px }
.status-head h2 { margin: 0; font-size: 16px }
.state {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--dim);
}
.state.on { background: var(--accent-2); box-shadow: 0 0 10px var(--accent-2) }
.state.off { background: var(--dim) }
dl {
  display: grid; grid-template-columns: 90px 1fr;
  gap: 6px 12px; margin: 0; font-size: 13px;
}
dt { color: var(--dim); font-size: 12px; padding-top: 1px }
dd { margin: 0 }
.bar {
  display: inline-block; vertical-align: middle;
  width: 70px; height: 6px;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 4px; overflow: hidden; margin-right: 6px;
}
.bar span {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
}

/* === control grid === */
.controls .grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}
.panel {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.panel h3 { margin: 0 0 4px; font-size: 14px }
.panel.danger { border-color: rgba(248,81,73,.4) }
.row { display: flex; align-items: center; gap: 8px }
.row input[type=checkbox] { width: auto; margin: 0 }

.radios { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 }
.chip {
  position: relative;
  padding: 6px 12px; border: 1px solid var(--line);
  border-radius: 99px; cursor: pointer; font-size: 12.5px;
}
.chip input { position: absolute; opacity: 0 }
.chip:has(input:checked) {
  background: rgba(88,166,255,.12);
  border-color: var(--accent);
  color: var(--accent);
}

.cmdlog { list-style: none; padding: 0; margin: 6px 0 0; font-size: 12.5px }
.cmdlog li {
  padding: 6px 0; border-bottom: 1px dashed var(--line);
  display: flex; gap: 8px; align-items: baseline;
}
.cmdlog li:last-child { border-bottom: 0 }
.cmdlog .badge {
  font-family: var(--mono); font-size: 10.5px;
  padding: 1px 6px; border-radius: 4px;
  background: var(--bg); border: 1px solid var(--line);
}
.cmdlog .badge.ack { color: var(--accent-2); border-color: rgba(126,231,135,.4) }
.cmdlog .badge.sent { color: var(--warn); border-color: rgba(210,153,34,.4) }
.cmdlog .badge.queued { color: var(--dim) }
