:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #1b1f24;
  --muted: #5d6673;
  --border: #dde1e6;
  --accent: #2459d6;
  --accent-text: #ffffff;
  --red: #c4322b;
  --red-soft: #fbe9e8;
  --blue: #2459d6;
  --green: #1f8a4c;
  --amber: #b26a00;
  --amber-soft: #fff3dc;
  --green-soft: #e3f4ea;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 1px 3px rgb(16 24 40 / 8%);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418;
    --surface: #1a1e24;
    --surface-2: #232830;
    --text: #e6e9ed;
    --muted: #98a1ad;
    --border: #2e343d;
    --accent: #5b8cff;
    --accent-text: #0b0e12;
    --red: #ff6b61;
    --red-soft: #3a1d1b;
    --blue: #5b8cff;
    --green: #45c37b;
    --amber: #f0a73a;
    --amber-soft: #3a2c14;
    --green-soft: #17311f;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

button, input { font: inherit; color: inherit; }

button, .ghost {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 7px;
  padding: 6px 12px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
button:hover:not(:disabled), .ghost:hover { background: var(--surface-2); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.primary:hover:not(:disabled) { filter: brightness(1.08); background: var(--accent); }
button.danger { color: var(--red); }
.ghost { border-color: transparent; background: transparent; color: var(--muted); }

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 6px;
  background: linear-gradient(135deg, var(--red) 0 50%, var(--blue) 50% 100%);
}
.who { display: flex; align-items: center; gap: 8px; color: var(--muted); }

main { max-width: 1100px; margin: 0 auto; padding: 24px 16px 64px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* Login */
.login { max-width: 360px; margin: 64px auto; padding: 28px; display: grid; gap: 14px; }
.login h1 { margin: 0 0 4px; font-size: 22px; }
.login label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.login input {
  padding: 9px 11px; border: 1px solid var(--border); border-radius: 7px; background: var(--bg); font-size: 15px;
}
.login input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.error { color: var(--red); margin: 0; }
.banner { background: var(--red-soft); color: var(--red); padding: 10px 14px; border-radius: 8px; }

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 28px 0 12px; flex-wrap: wrap; }
.section-head h2 { margin: 0; font-size: 18px; }
.hint { color: var(--muted); font-size: 13px; }
.empty { color: var(--muted); padding: 18px; text-align: center; border: 1px dashed var(--border); border-radius: var(--radius); }

/* Environments */
.env-list { display: grid; gap: 14px; }
.env { padding: 16px 18px; display: grid; gap: 12px; }
.env-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.env-id { font-weight: 700; font-size: 17px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.env-scenario { color: var(--muted); }
.env-meta { display: flex; gap: 6px 16px; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
.env-actions { display: flex; gap: 8px; margin-left: auto; }
.env-error { background: var(--red-soft); color: var(--red); padding: 8px 12px; border-radius: 7px; font-size: 13px; overflow-wrap: anywhere; }

.pill { font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.pill.ready { background: var(--green-soft); color: var(--green); }
.pill.failed { background: var(--red-soft); color: var(--red); }
.pill.busy { background: var(--amber-soft); color: var(--amber); }
.pill.busy::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: currentColor; animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.25; } }

.vm-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.vm-table td { padding: 7px 8px; border-top: 1px solid var(--border); vertical-align: middle; }
.vm-table td:last-child { text-align: right; }
.vm-name { font-weight: 600; }
.vm-host { color: var(--muted); font-size: 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.vm-nets { color: var(--muted); font-size: 13px; }
.vm-login { font-size: 13px; overflow-wrap: anywhere; }
.vm-login code, .console-login code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: 0 5px;
}
.power { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.power::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.power.running::before { background: var(--green); }
.power.missing::before { background: var(--red); }

/* Scenarios */
.scenario-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.scenario { padding: 16px 18px; display: grid; gap: 10px; align-content: start; }
.scenario h3 { margin: 0; font-size: 16px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.scenario p { margin: 0; color: var(--muted); font-size: 14px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-size: 12px; padding: 1px 8px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); }
.chip.internet { border-color: var(--accent); color: var(--accent); }
.scenario-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; }

/* Console page */
.console-page { height: 100vh; display: flex; flex-direction: column; overflow: hidden; background: #000; }
.console-bar {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; flex-wrap: wrap;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.console-state { flex: 1 1 240px; min-width: 0; color: var(--muted); font-size: 13px; }
.console-state.bad { color: var(--red); }
.console-login { font-size: 13px; color: var(--muted); }
.console-screen { flex: 1; min-height: 0; }

@media (max-width: 640px) {
  .topbar { padding: 10px 16px; }
  .env-actions { margin-left: 0; width: 100%; }
  .vm-nets { display: none; }
}
