:root {
  color-scheme: dark;
  --bg: #0b0d12;
  --bg-elevated: #10131b;
  --panel: #141822;
  --panel-hover: #171c27;
  --border: #232838;
  --border-soft: #1b202c;
  --text: #eceef3;
  --muted: #8b93a7;
  --muted-soft: #5f6779;
  --accent: #6366f1;
  --accent-hover: #7476f3;
  --accent-soft: rgba(99, 102, 241, 0.14);
  --danger: #f43f5e;
  --danger-soft: rgba(244, 63, 94, 0.13);
  --ok: #22c55e;
  --ok-soft: rgba(34, 197, 94, 0.13);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  background-image: radial-gradient(circle at 15% 0%, rgba(99, 102, 241, 0.08), transparent 45%);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 880px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 5rem;
}

.center-wrap {
  max-width: 380px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 2rem 1.25rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 2rem;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  flex-shrink: 0;
}

.brand-name {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 0.35rem;
}

h2 {
  font-size: 0.78rem;
  margin: 0 0 1rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

p.subtitle {
  color: var(--muted);
  margin: 0 0 1.75rem;
  font-size: 0.92rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}

label {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0 0 0.4rem;
  font-weight: 500;
}

label.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text);
  cursor: pointer;
  font-weight: 400;
  font-size: 0.9rem;
}

.field {
  margin-bottom: 1rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select {
  width: 100%;
  padding: 0.65rem 0.75rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.92rem;
  transition: border-color 0.15s ease;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
}

input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

button {
  cursor: pointer;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.6rem 1.1rem;
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--accent);
  color: white;
  transition: background 0.15s ease, opacity 0.15s ease;
}

button:hover {
  background: var(--accent-hover);
}

button.secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

button.secondary:hover {
  background: var(--panel-hover);
  border-color: var(--muted-soft);
}

button.danger {
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
}

button.danger:hover {
  background: var(--danger-soft);
}

button.link-button {
  background: none;
  border: none;
  color: var(--accent);
  padding: 0;
  font-weight: 500;
}

button.link-button:hover {
  color: var(--accent-hover);
  background: none;
}

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

button.block {
  width: 100%;
}

.row {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

th,
td {
  text-align: left;
  padding: 0.6rem 0.5rem;
  border-bottom: 1px solid var(--border-soft);
}

th {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

tr:last-child td {
  border-bottom: none;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}

.badge.running {
  background: var(--ok-soft);
  color: var(--ok);
}
.badge.stopped {
  background: var(--danger-soft);
  color: var(--danger);
}
.badge.unknown {
  background: rgba(139, 147, 167, 0.14);
  color: var(--muted);
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.alert {
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-top: 0.75rem;
  display: none;
}

.alert.show {
  display: block;
}

.alert.error {
  background: var(--danger-soft);
  color: #fca5b3;
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.alert.success {
  background: var(--ok-soft);
  color: #86efac;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.hint {
  color: var(--muted-soft);
  font-size: 0.78rem;
  margin-top: 0.4rem;
  line-height: 1.4;
}

.tabs {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 1.25rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.25rem;
}

.tabs button {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 0.5rem;
  border-radius: 6px;
}

.tabs button:hover {
  background: transparent;
  color: var(--text);
}

.tabs button.active {
  background: var(--accent);
  color: white;
}

.device-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  margin-bottom: 0.85rem;
  background: var(--bg-elevated);
}

.device-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.device-name {
  font-size: 1rem;
  font-weight: 600;
}

.device-actions {
  display: flex;
  gap: 0.4rem;
}

.details-toggle {
  margin-top: 0.6rem;
}

.details-toggle > summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.8rem;
  list-style: none;
  user-select: none;
}

.details-toggle > summary::-webkit-details-marker {
  display: none;
}

.details-toggle > summary::before {
  content: "▸ ";
  display: inline-block;
  transition: transform 0.15s ease;
}

.details-toggle[open] > summary::before {
  content: "▾ ";
}

.details-body {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-soft);
}

.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--muted);
}

.empty-state-title {
  color: var(--text);
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

a.link {
  color: var(--accent);
  text-decoration: none;
}

a.link:hover {
  text-decoration: underline;
}

.muted {
  color: var(--muted);
}

.divider {
  border: none;
  border-top: 1px solid var(--border-soft);
  margin: 1.25rem 0;
}

.help-box {
  background: var(--accent-soft);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1rem;
  font-size: 0.83rem;
  color: var(--text);
  margin-top: 0.75rem;
}

.help-box ol {
  margin: 0.5rem 0 0;
  padding-left: 1.1rem;
}

.help-box li {
  margin-bottom: 0.3rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--panel-hover);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.25rem 0.55rem 0.25rem 0.7rem;
  font-size: 0.78rem;
}

.chip button {
  background: none;
  border: none;
  color: var(--muted);
  padding: 0;
  font-size: 0.9rem;
  line-height: 1;
}

.chip button:hover {
  color: var(--danger);
  background: none;
}
