:root {
  --bg: #0f1115; --card: #181b22; --line: #262a33; --text: #e7e9ee; --muted: #8b92a1;
  --on: #2fb36d; --off: #3a3f4b; --warn: #e0a43a; --err: #e5534b; --bar: #4c8dff;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.4 system-ui, -apple-system, Segoe UI, Roboto, sans-serif; }
main { max-width: 760px; margin: 0 auto; padding: 16px; }
h1 { font-size: 20px; margin: 0; }
header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
button { font: inherit; cursor: pointer; }
.link { background: none; border: 0; color: var(--muted); text-decoration: underline; }

#login form { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; max-width: 320px; }
input { font: inherit; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--text); }
#login button { padding: 10px; border: 0; border-radius: 8px; background: var(--bar); color: #fff; }
.error { color: var(--err); white-space: pre-line; margin: 8px 0; }
.error:empty { display: none; }

.system { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.metric { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.metric .label { color: var(--muted); font-size: 12px; }
.metric .value { font-weight: 600; margin: 2px 0 6px; font-variant-numeric: tabular-nums; }
.meter { height: 6px; border-radius: 3px; background: var(--off); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--bar); }
.meter i.high { background: var(--warn); }

.group { background: var(--card); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; }
.group-head { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.group-info { flex: 1; min-width: 0; cursor: pointer; }
.group-name { font-weight: 600; }
.group-meta { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--off); margin-right: 6px; vertical-align: 1px; }
.dot.on { background: var(--on); }
.dot.partial { background: var(--warn); }
.dot.failed { background: var(--err); }
.badge { font-size: 11px; color: var(--warn); border: 1px solid var(--warn); border-radius: 4px; padding: 0 4px; margin-left: 6px; }

.units { border-top: 1px solid var(--line); padding: 4px 14px 8px; }
.unit { display: flex; align-items: center; gap: 10px; padding: 8px 0; font-size: 13px; }
.unit + .unit { border-top: 1px dashed var(--line); }
.unit-info { flex: 1; min-width: 0; }
.unit-name { font-family: ui-monospace, monospace; overflow-wrap: anywhere; }
.unit-meta { color: var(--muted); }

.switch { position: relative; width: 52px; height: 30px; flex: none; border: 0; border-radius: 15px; background: var(--off); transition: background .15s; padding: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch[aria-checked="true"] { background: var(--on); }
.switch[aria-checked="true"]::after { transform: translateX(22px); }
.switch.small { width: 42px; height: 24px; }
.switch.small::after { width: 18px; height: 18px; }
.switch.small[aria-checked="true"]::after { transform: translateX(18px); }
.switch:disabled { opacity: .5; cursor: wait; }

.note { color: var(--muted); font-size: 12px; margin-top: 16px; }

@media (max-width: 480px) {
  .system { grid-template-columns: 1fr 1fr; }
  .system .metric:last-child { grid-column: span 2; }
}
