:root {
  --bg: #0f1420;
  --surface: #171e2e;
  --surface-2: #1f2838;
  --border: #2a3448;
  --text: #e6ebf5;
  --muted: #8b97ad;
  --accent: #3b82f6;
  --accent-hover: #2f6fe0;
  --online: #22c55e;
  --offline: #64748b;
  --danger: #ef4444;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
.error { color: var(--danger); font-size: 13px; min-height: 18px; }

/* Login */
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px;
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login-card h1 { margin: 0; font-size: 22px; }
.login-card p { margin: 0 0 8px; }

input, button {
  font: inherit;
  border-radius: 9px;
  border: 1px solid var(--border);
  padding: 11px 13px;
}
input {
  background: var(--surface-2);
  color: var(--text);
  outline: none;
}
input:focus { border-color: var(--accent); }
input[type="search"] { min-width: 220px; }

button {
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  font-weight: 600;
}
button:hover { background: var(--accent-hover); }
button.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 500;
}
button.ghost:hover { background: var(--surface-2); }

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: wrap;
}
.brand { font-size: 18px; font-weight: 700; }
.brand span { color: var(--accent); }
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

main { padding: 20px; max-width: 1100px; margin: 0 auto; }

/* Stats */
.stats { display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 18px;
  min-width: 120px;
}
.stat .n { font-size: 24px; font-weight: 700; }
.stat .l { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }

/* Grupos e máquinas */
.group { margin-bottom: 22px; }
.group-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.group-count {
  background: var(--surface-2);
  border-radius: 20px;
  padding: 1px 9px;
  font-size: 12px;
  color: var(--muted);
}
.machines {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.machine {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.machine-head { display: flex; align-items: center; gap: 8px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--offline); flex: none; }
.dot.on { background: var(--online); box-shadow: 0 0 0 3px rgba(34,197,94,.2); }
.machine-host { font-weight: 600; font-size: 15px; }
.machine-meta { color: var(--muted); font-size: 12px; line-height: 1.5; }
.machine-actions { margin-top: 4px; }
.machine-actions button { width: 100%; padding: 9px; }
.machine-actions button:disabled { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 60px 20px;
  border: 1px dashed var(--border);
  border-radius: 12px;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 50;
}
.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.modal-card h2 { margin: 0; font-size: 18px; }
.checkbox { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.checkbox input { width: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
