:root {
  --bg: #080d1a;
  --surface: #10182b;
  --surface-2: #16223b;
  --border: #24324f;
  --text: #eef2ff;
  --muted: #94a3b8;
  --primary: #38bdf8;
  --primary-dark: #0284c7;
  --success: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 12px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}
code {
  background: rgba(56, 189, 248, 0.12);
  color: #7dd3fc;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 0.88em;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error-text { color: #fca5a5; font-size: 0.9rem; }
.full { width: 100%; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.brand-badge {
  display: inline-block;
  align-self: flex-start;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  background: rgba(56, 189, 248, 0.14);
  color: var(--primary);
}
.login-card h1 { margin: 0; font-size: 1.45rem; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(8, 13, 26, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-left strong { display: block; font-size: 1rem; }
.topbar-left small { display: block; font-size: 0.78rem; }
.logo-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 12px var(--primary);
}

.tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.tab {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
}
.tab.active {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

.container { max-width: 1440px; margin: 0 auto; padding: 20px 24px 48px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.stat-card span { font-size: 0.8rem; color: var(--muted); display: block; }
.stat-card strong { font-size: 1.6rem; display: block; margin-top: 4px; }

.split-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 16px;
  align-items: start;
}
@media (max-width: 960px) {
  .split-layout { grid-template-columns: 1fr; }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.panel h2 { margin: 0 0 12px; font-size: 1.1rem; }
.panel h3 { margin: 0 0 8px; font-size: 0.98rem; }
.panel-header { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }

.device-list { display: flex; flex-direction: column; gap: 8px; max-height: 70vh; overflow-y: auto; }
.device-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.device-card:hover, .device-card.selected { border-color: var(--primary); }
.device-card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.device-card-title { font-weight: 600; font-size: 0.95rem; }
.device-card-meta { font-size: 0.8rem; color: var(--muted); margin-top: 4px; display: flex; gap: 8px; flex-wrap: wrap; }

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}
.dot.on { background: var(--success); box-shadow: 0 0 8px var(--success); }
.dot.off { background: #64748b; }

.badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
}
.badge-active { background: rgba(34, 197, 94, 0.16); color: #4ade80; }
.badge-warning { background: rgba(245, 158, 11, 0.18); color: #fbbf24; }
.badge-locked { background: rgba(239, 68, 68, 0.2); color: #f87171; }
.badge-info { background: rgba(56, 189, 248, 0.15); color: #7dd3fc; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 0.85rem; }
.field > span { color: var(--muted); font-weight: 500; }
input, select, textarea {
  width: 100%;
  background: #0b1222;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 11px;
  font: inherit;
}
input[type="color"] { padding: 3px; height: 38px; cursor: pointer; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); }

.btn {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 9px 14px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
}
.btn:hover { filter: brightness(1.1); }
.btn-primary { background: var(--primary-dark); border-color: var(--primary); }
.btn-danger { background: rgba(239, 68, 68, 0.18); border-color: var(--danger); color: #fecaca; }
.btn-success { background: rgba(34, 197, 94, 0.18); border-color: var(--success); color: #bbf7d0; }
.btn-warn { background: rgba(245, 158, 11, 0.18); border-color: var(--warn); color: #fde68a; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 10px; font-size: 0.8rem; }

.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 720px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.subtabs { display: flex; gap: 8px; border-bottom: 1px solid var(--border); padding-bottom: 10px; margin: 14px 0; flex-wrap: wrap; }
.subtab {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 600;
}
.subtab.active { background: rgba(56, 189, 248, 0.14); border-color: var(--primary); color: var(--primary); }

.detail-section { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 14px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 0.88rem; cursor: pointer; }
.checkbox-row input { width: auto; }

.code-box {
  background: #060a14;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
  white-space: pre-wrap;
  word-break: break-all;
}

.screenshot-preview {
  max-width: 100%;
  max-height: 360px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #000;
}

.cmd-log { display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; }
.cmd-item {
  background: #0b1222;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.82rem;
}
.empty-state { padding: 48px 16px; text-align: center; }

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: #0f172a;
  border: 1px solid var(--primary);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 10px;
  z-index: 999;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}
.small-list { padding-left: 18px; display: flex; flex-direction: column; gap: 6px; font-size: 0.86rem; }
