:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --border: #2d3a4d;
  --text: #e7ecf3;
  --muted: #8b9cb3;
  --accent: #ff6b35;
  --accent-hover: #ff8555;
  --success: #3dd68c;
  --danger: #f25f5c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

.header {
  padding: 1.5rem 1.25rem 0.5rem;
  border-bottom: 1px solid var(--border);
}

.header h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
}

.subtitle {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.main {
  max-width: 640px;
  margin: 0 auto;
  padding: 1.25rem;
}

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

.status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.summary {
  font-weight: 600;
}

.muted {
  color: var(--muted);
  font-size: 0.85rem;
}

.devices {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.device-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
}

.device-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.device-card h2 {
  margin: 0;
  font-size: 1.1rem;
  word-break: break-all;
}

.health-badge {
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.health-badge.health-online {
  background: rgba(61, 214, 140, 0.15);
  color: var(--success);
}

.health-badge.health-late {
  background: rgba(255, 193, 7, 0.15);
  color: #ffc107;
}

.health-badge.health-unknown,
.health-badge.health-offline {
  background: rgba(139, 156, 179, 0.15);
  color: var(--muted);
}

.device-card.health-late {
  border-color: rgba(255, 193, 7, 0.45);
}

.meta {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.35rem 1rem;
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.meta dt {
  color: var(--muted);
  margin: 0;
}

.meta dd {
  margin: 0;
  font-weight: 500;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

button {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 0.55rem 1rem;
  font-weight: 600;
  transition: background 0.15s;
}

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

.btn-on {
  background: var(--success);
  color: #0a1a12;
}

.btn-on:hover:not(:disabled) {
  filter: brightness(1.08);
}

.btn-off {
  background: var(--border);
  color: var(--text);
}

.btn-off:hover:not(:disabled) {
  background: #3d4f66;
}

.btn-blink {
  background: var(--accent);
  color: #1a0a04;
}

.btn-blink:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-ping {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

.btn-ping:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--muted);
}

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

.empty code {
  display: block;
  margin-top: 0.5rem;
  padding: 0.5rem;
  background: var(--surface);
  border-radius: 6px;
  font-size: 0.8rem;
  word-break: break-all;
}

.hidden {
  display: none !important;
}

.toast {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  font-size: 0.9rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 100;
}

.toast.ok {
  border-color: var(--success);
}

.toast.err {
  border-color: var(--danger);
}
