:root {
  color-scheme: dark;
  --bg: #0b0c0d;
  --panel: #141618;
  --panel-2: #1a1d20;
  --border: rgba(255, 255, 255, 0.08);
  --text: #f2f4f5;
  --muted: rgba(255, 255, 255, 0.48);
  --green: #30d158;
  --red: #ff453a;
  --orange: #ff9f0a;
  --blue: #64d2ff;
  --radius: 16px;
  font-family: "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(1200px 600px at 10% -10%, rgba(48, 209, 88, 0.08), transparent),
              var(--bg);
  color: var(--text);
}

.hidden { display: none !important; }

#app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 20px 48px;
}

.login-panel {
  max-width: 420px;
  margin: 10vh auto 0;
}

.brand {
  text-align: center;
  margin-bottom: 22px;
}

.brand-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 14px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: rgba(48, 209, 88, 0.14);
  color: var(--green);
  font-weight: 800;
  letter-spacing: 0.04em;
}

h1, h2 { margin: 0; font-weight: 650; letter-spacing: -0.02em; }
.brand h1 { font-size: 2rem; }
.brand p, .muted, .hint { color: var(--muted); }
.hint { font-size: 0.86rem; margin-top: 14px; }
.small { font-size: 0.82rem; }
code {
  background: rgba(255,255,255,0.06);
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 0.85em;
}

.panel {
  background: linear-gradient(180deg, rgba(255,255,255,0.03), transparent), var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

label {
  display: grid;
  gap: 8px;
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 12px;
}

input, select, button {
  font: inherit;
}

input, select {
  width: 100%;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.05);
  color: var(--text);
  padding: 0 12px;
  outline: none;
}

input:focus {
  border-color: rgba(48, 209, 88, 0.5);
  box-shadow: 0 0 0 3px rgba(48, 209, 88, 0.12);
}

button {
  border: 0;
  border-radius: 12px;
  height: 44px;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 650;
}

button.primary {
  background: var(--green);
  color: #05240d;
  width: 100%;
}

button.primary.small {
  width: auto;
  height: 36px;
  font-size: 0.88rem;
}

button.ghost {
  background: rgba(255,255,255,0.06);
  color: var(--text);
}

button.danger {
  background: rgba(255, 69, 58, 0.18);
  color: #ffb4af;
}

button.warning {
  background: rgba(255, 159, 10, 0.16);
  color: #ffd28a;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.error {
  color: #ff8a84;
  font-weight: 600;
  font-size: 0.9rem;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
}

.stat .label { color: var(--muted); font-size: 0.82rem; }
.stat .value { font-size: 1.55rem; font-weight: 700; margin-top: 4px; }

.grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 16px;
  margin-bottom: 16px;
}

.table {
  display: grid;
  gap: 8px;
}

.row {
  display: grid;
  grid-template-columns: 1.2fr 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border-radius: 12px;
  background: rgba(255,255,255,0.03);
  border: 1px solid transparent;
}

.row:hover { border-color: var(--border); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 0.75rem;
  font-weight: 700;
  background: rgba(255,255,255,0.06);
  color: var(--muted);
}

.badge.online { background: rgba(48,209,88,0.14); color: var(--green); }
.badge.restricted { background: rgba(255,69,58,0.16); color: #ff8a84; }
.badge.offline { background: rgba(255,255,255,0.05); }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.actions button {
  height: 34px;
  font-size: 0.8rem;
  width: auto;
}

.create-form {
  margin-bottom: 14px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

.devices {
  display: grid;
  gap: 10px;
}

.device-card {
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  padding: 12px;
}

.device-card h3 {
  margin: 0 0 4px;
  font-size: 1rem;
}

.device-meta {
  color: var(--muted);
  font-size: 0.82rem;
  margin-bottom: 10px;
}

.local-account {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255,255,255,0.04);
  margin-bottom: 6px;
  font-size: 0.9rem;
}

.pin {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--blue);
  font-weight: 700;
}

.pin.missing { color: var(--muted); font-weight: 500; }

.empty {
  color: var(--muted);
  padding: 18px 8px;
  text-align: center;
}

@media (max-width: 900px) {
  .grid, .stats, .form-row {
    grid-template-columns: 1fr;
  }
  .row {
    grid-template-columns: 1fr;
  }
  .actions { justify-content: flex-start; }
}
