:root {
  --bg: #0f1115; --panel: #151922; --border: #262c3a; --text: #e6e9ef;
  --muted: #8a93a6; --accent: #4c9aff; --good: #3fb950; --warn: #d29922; --bad: #f85149;
  --sb-w: 380px; --sb-w-collapsed: 0px;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  display: grid;
  grid-template-columns: var(--sb-w) 1fr;
  grid-template-rows: 100%;
  font: 14px/1.45 system-ui, -apple-system, sans-serif;
  background: var(--bg); color: var(--text);
  transition: grid-template-columns .2s ease;
}
body.collapsed { grid-template-columns: var(--sb-w-collapsed) 1fr; }

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--panel); border-right: 1px solid var(--border);
  overflow: hidden; display: flex; flex-direction: column; min-width: 0;
}
body.collapsed .sidebar { border-right: none; }
.sb-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px; border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; white-space: nowrap; }
.muted { color: var(--muted); font-weight: 400; font-size: 12px; }
.sb-scroll { overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 12px; }

.badge { padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; background: #333a48; white-space: nowrap; }
.badge.running { background: var(--good); color: #06120a; }
.badge.provisioning { background: var(--warn); color: #1a1200; }
.badge.stopping { background: var(--bad); color: #1a0605; }

.card { background: #10141c; border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.card h2 { margin: 0 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0 0 10px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-family: ui-monospace, monospace; word-break: break-all; font-size: 12px; }

.counts { display: flex; gap: 8px; margin-bottom: 10px; }
.count { flex: 1; text-align: center; background: #0c0f15; border: 1px solid var(--border); border-radius: 8px; padding: 6px; }
.count span { display: block; font-size: 22px; font-weight: 700; }
.count label { color: var(--muted); font-size: 10px; text-transform: uppercase; }
.loadstats { margin-bottom: 10px; font-size: 12px; }
.loadstats b { font-weight: 600; }

table { width: 100%; border-collapse: collapse; margin-bottom: 10px; }
th, td { text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--border); font-size: 12px; }
th { color: var(--muted); font-weight: 600; }
td.connected-true { color: var(--good); }

.row.actions { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.row.actions label { display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: var(--muted); }
.row.actions input {
  width: 100%; padding: 6px 8px; border-radius: 6px; border: 1px solid var(--border);
  background: #0c0f15; color: var(--text); font-size: 13px;
}
.row.actions button { padding: 7px 10px; border-radius: 6px; border: 1px solid var(--border); background: #0c0f15; color: var(--text); cursor: pointer; white-space: nowrap; }
.row.actions .grow { flex: 1; }
button.primary { background: var(--accent); border-color: var(--accent); color: #061220; font-weight: 600; }
button.ghost { background: transparent; }
button.warn { color: var(--warn); }
.hint { font-size: 11px; color: var(--muted); }

.events { max-height: 180px; overflow-y: auto; margin: 0; padding-left: 16px; }
.events li { margin-bottom: 4px; font-family: ui-monospace, monospace; font-size: 11px; color: var(--muted); }

/* ---------- Toggle ---------- */
.toggle {
  position: fixed; top: 12px; left: var(--sb-w); z-index: 10;
  transform: translateX(-50%);
  width: 44px; height: 44px; border-radius: 50%;
  border: 2px solid var(--accent); background: var(--panel); color: var(--accent);
  font-size: 18px; line-height: 1; font-weight: 700;
  cursor: pointer; box-shadow: 0 3px 12px rgba(0,0,0,.55);
  transition: left .2s ease, transform .2s ease, background .15s ease, color .15s ease;
}
.toggle:hover { background: var(--accent); color: #061220; }
/* Collapsed: sit flush to the left edge so the whole button stays on-screen. */
body.collapsed .toggle { left: 0; transform: translateX(2px); }

/* ---------- Stage (native Locust UI) ---------- */
.stage { position: relative; background: #fff; min-width: 0; }
#locust-frame { width: 100%; height: 100%; border: 0; display: block; }
.locust-empty {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px; color: #555; text-align: center; padding: 24px;
}
.locust-empty code { background: #f0f0f0; padding: 1px 5px; border-radius: 4px; }
#locust-frame.loaded ~ .locust-empty { display: none; }

/* ---------- Auth: sidebar footer + standalone login page ---------- */
.hidden { display: none !important; }
/* Signed-in account row pinned to the bottom of the sidebar. */
.sb-foot {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 10px 14px; border-top: 1px solid var(--border); font-size: 12px;
}
.sb-foot button { padding: 5px 10px; border-radius: 6px; border: 1px solid var(--border); background: #0c0f15; color: var(--text); cursor: pointer; }
.sb-foot button:hover { border-color: var(--accent); }

/* Standalone login page (served at /login). */
body.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
  background: radial-gradient(1200px 520px at 50% -10%, #1a2030, var(--bg));
  padding: 24px;
}
.login-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 32px 36px; display: flex; flex-direction: column; align-items: center;
  gap: 14px; text-align: center; width: 100%; max-width: 360px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}
.login-card .brand { font-size: 20px; }
.login-error { color: var(--bad); font-size: 12px; }
.login-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); text-align: left; width: 100%; }
.login-field input {
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); padding: 8px 10px; font-size: 14px;
}
.login-field input:focus { outline: none; border-color: var(--accent); }
.login-card .primary { width: 100%; }
.login-divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 11px; width: 100%; }
.login-divider::before, .login-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.login-form { display: flex; flex-direction: column; gap: 10px; width: 100%; }
#google-block { display: flex; justify-content: center; }
