:root {
  --bg: #0b0e14;
  --panel: #11161f;
  --border: #1e2733;
  --text: #d7e0ea;
  --muted: #7d8b9c;
  --accent: #4fd1a5;
  --danger: #ff6b6b;
  --warn: #ffc857;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

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

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

.muted { color: var(--muted); }

/* ---------- login ---------- */
.login-page {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.brand-mark { color: var(--accent); font-size: 22px; }
.brand h1 { font-size: 20px; margin: 0; letter-spacing: 0.02em; }

.login-card p { margin: 0 0 18px; font-size: 14px; }

.login-card input {
  width: 100%;
  padding: 12px 14px;
  font-size: 15px;
  color: var(--text);
  background: #0b0f16;
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
}

.login-card input:focus { border-color: var(--accent); }

.login-card button {
  width: 100%;
  margin-top: 14px;
  padding: 12px 14px;
  font-size: 15px;
  font-weight: 600;
  color: #04120c;
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.login-card button:hover { filter: brightness(1.08); }

.login-card .error {
  min-height: 18px;
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--danger);
}

/* ---------- app ---------- */
.app-page { display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 12px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.status { display: flex; align-items: center; gap: 10px; font-size: 14px; }

.dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 3px rgba(125, 139, 156, 0.15);
}

.dot-ok { background: var(--accent); box-shadow: 0 0 0 3px rgba(79, 209, 165, 0.18); }
.dot-bad { background: var(--danger); box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.18); }

.actions { display: flex; align-items: center; gap: 8px; }
.actions form { margin: 0; }

.ghost {
  font-size: 13px;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 7px 11px;
  cursor: pointer;
}

.ghost:hover { border-color: var(--accent); color: var(--accent); }
.ghost.danger:hover { border-color: var(--danger); color: var(--danger); }
.ghost.start:hover { border-color: var(--accent); color: var(--accent); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button:disabled:hover { border-color: var(--border); color: var(--text); }

/* ---------- loading overlay ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(4, 7, 11, 0.82);
  backdrop-filter: blur(3px);
}

.overlay.hidden { display: none; }

.overlay-card {
  text-align: center;
  padding: 32px 40px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}

.overlay-card p { margin: 0; font-size: 16px; }

.spinner {
  width: 44px;
  height: 44px;
  margin: 0 auto 18px;
  border: 3px solid rgba(79, 209, 165, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.overlay-sub {
  margin-top: 8px !important;
  color: var(--muted);
  font-size: 13px !important;
}

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  z-index: 60;
  max-width: min(90vw, 560px);
  padding: 10px 16px;
  font-size: 13px;
  color: #ffd7d7;
  background: #3a1518;
  border: 1px solid #7a2a30;
  border-radius: 8px;
}

.toast.hidden { display: none; }

.hidden { display: none !important; }

/* ---------- stopped screen ---------- */
.stopped-screen {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 24px;
}

.stopped-card {
  width: 100%;
  max-width: 460px;
  padding: 44px 36px;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

.stopped-icon {
  display: flex;
  justify-content: center;
  color: var(--danger);
}

.stopped-card h1 {
  margin: 16px 0 8px;
  font-size: 26px;
}

.stopped-card p { margin: 6px 0; }

.stopped-card p.muted {
  color: var(--muted);
  font-size: 14px;
}

.primary {
  margin-top: 24px;
  padding: 12px 26px;
  font-size: 15px;
  font-weight: 600;
  color: #04120c;
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.primary:hover { filter: brightness(1.08); }

/* ---------- custom confirm modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(4, 7, 11, 0.78);
  backdrop-filter: blur(3px);
}

.modal-card {
  width: 100%;
  max-width: 430px;
  padding: 26px 26px 22px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  animation: modalIn 0.16s ease-out;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.modal-card h2 {
  margin: 0 0 10px;
  font-size: 19px;
}

.modal-text {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
  white-space: pre-line;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.modal-actions .primary {
  margin-top: 0;
  padding: 10px 18px;
}

.primary.danger-btn {
  background: var(--danger);
  color: #ffffff;
}

.primary.danger-btn:hover { filter: brightness(1.08); }

main {
  flex: 1;
  min-height: 0;
  padding: 14px;
}

#console {
  height: 100%;
  margin: 0;
  padding: 16px;
  overflow: auto;
  font-family: "JetBrains Mono", "Fira Code", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  background: #080b10;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: #cfd8e3;
}

@media (max-width: 600px) {
  .topbar { padding: 10px 12px; }
  .actions { width: 100%; justify-content: flex-end; }
  main { padding: 10px; }
  #console { padding: 12px; font-size: 11.5px; }
}
