:root {
  --bg: #0d1117;
  --bg-card: #161b22;
  --bg-input: #0d1117;
  --border: #30363d;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #2f81f7;
  --accent-hover: #1f6feb;
  --green: #3fb950;
  --red: #f85149;
  --yellow: #d29922;
  --radius: 10px;
}

* { box-sizing: border-box; }

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

.hidden { display: none !important; }

/* ------------------------------------------------ login */

.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  width: 340px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-card h1 { margin: 0; font-size: 22px; }
.login-card .sub { margin: 0; color: var(--muted); }

input[type="password"], input[type="text"], input:not([type]) {
  width: 100%;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 9px 12px;
  font-size: 14px;
}
input:focus { outline: none; border-color: var(--accent); }

button {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
}
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: var(--accent-hover); }
button.danger:hover { border-color: var(--red); color: var(--red); }

.error { color: var(--red); font-size: 13px; margin: 0; }

/* ------------------------------------------------ topbar */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar h1 { margin: 0; font-size: 18px; }
.topbar-actions { display: flex; gap: 8px; }

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

.poll-status { color: var(--muted); font-size: 12px; margin: 0 0 12px; }

/* ------------------------------------------------ cards */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 16px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-head h2 { margin: 0; font-size: 16px; flex: 1; }

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: none;
}
.dot.running { background: var(--green); box-shadow: 0 0 6px var(--green); }
.dot.starting { background: var(--yellow); }
.dot.exited { background: var(--red); }
.dot.stopped { background: var(--muted); }

.card-meta { color: var(--muted); font-size: 12px; }

.info-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 14px;
  font-size: 13px;
}
.info-grid .k { color: var(--muted); }
.info-grid .v { word-break: break-word; }

.buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.buttons button { padding: 5px 10px; font-size: 12px; }

.status-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 220px;
  overflow: auto;
  display: none;
}
.status-box.open { display: block; }

.logs-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 11px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 240px;
  overflow: auto;
  display: none;
}
.logs-box.open { display: block; }

/* ------------------------------------------------ modal */

dialog {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  width: min(440px, 92vw);
}
dialog::backdrop { background: rgba(0,0,0,.55); }
dialog h2 { margin: 0 0 14px; font-size: 17px; }

#account-form { display: flex; flex-direction: column; gap: 10px; }
#account-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }

.checks { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.checks .check { display: flex; flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
.checks input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; }

.modal-actions { display: flex; gap: 8px; margin-top: 8px; }
