:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-border: #272b35;
  --text: #e8e9ed;
  --muted: #8a8f9c;
  --accent: #5b8cff;
  --good: #3ecf8e;
  --bad: #ef5a5a;
  --warn: #e8b339;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ---- login ---- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.login-box {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 2rem;
  width: min(360px, 100%);
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}
.login-box h1 { margin: 0 0 0.5rem; font-size: 1.3rem; text-align: center; }
.login-box input {
  padding: 0.7em 0.9em;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  background: #0c0e12;
  color: var(--text);
  font-size: 1rem;
}
.login-box button {
  padding: 0.7em;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  font-size: 1rem;
}
.login-box button:hover { filter: brightness(1.1); }
.error { color: var(--bad); margin: 0; font-size: 0.9rem; text-align: center; }

/* ---- app shell ---- */
.app { max-width: 1200px; margin: 0 auto; padding: 1rem clamp(1rem, 3vw, 2rem) 3rem; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0 1.2rem;
}
.topbar h1 { font-size: 1.4rem; margin: 0; }
button.ghost {
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--text);
  padding: 0.5em 1em;
  border-radius: 8px;
  cursor: pointer;
}
button.ghost:hover { border-color: var(--accent); }

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 1.2rem;
  margin-top: 1.2rem;
}
.panel h2 { margin: 0 0 0.9rem; font-size: 1.05rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }

/* ---- stats ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.8rem;
}
.stat-tile {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 1rem;
}
.stat-tile .label { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }
.stat-tile .value { font-size: 1.6rem; font-weight: 700; margin-top: 0.2rem; }
.stat-tile .sub { color: var(--muted); font-size: 0.8rem; margin-top: 0.2rem; }

/* ---- links ---- */
.links-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.6rem;
}
.links-grid a {
  display: block;
  background: #0c0e12;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 0.8em 1em;
  color: var(--text);
  text-decoration: none;
  font-size: 0.92rem;
}
.links-grid a:hover { border-color: var(--accent); }

/* ---- consoles ---- */
.console-tabs { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.9rem; }
.console-tab {
  padding: 0.5em 0.9em;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: #0c0e12;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: 0.4em;
}
.console-tab.active { color: var(--text); border-color: var(--accent); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; }
.status-dot.active { background: var(--good); }
.status-dot.inactive, .status-dot.exited { background: var(--muted); }
.status-dot.failed { background: var(--bad); }

.console-panel { display: none; }
.console-panel.active { display: block; }
.console-head { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; margin-bottom: 0.6rem; flex-wrap: wrap; }
.console-actions { display: flex; gap: 0.4rem; }
.console-actions button {
  background: #0c0e12;
  border: 1px solid var(--panel-border);
  color: var(--text);
  padding: 0.4em 0.8em;
  border-radius: 7px;
  cursor: pointer;
  font-size: 0.82rem;
}
.console-actions button:hover { border-color: var(--accent); }
.console-actions button.danger:hover { border-color: var(--bad); color: var(--bad); }

.console-log {
  background: #0a0b0e;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 0.8rem;
  height: 420px;
  overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
  white-space: pre-wrap;
  word-break: break-word;
  color: #c8ccd6;
}
.console-note { color: var(--warn); font-size: 0.82rem; margin-bottom: 0.5rem; }

.console-input-row { display: flex; gap: 0.5rem; margin-top: 0.6rem; }
.console-input-row input {
  flex: 1;
  background: #0c0e12;
  border: 1px solid var(--panel-border);
  color: var(--text);
  border-radius: 8px;
  padding: 0.6em 0.8em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
}
.console-input-row button {
  background: var(--accent);
  border: none;
  color: #fff;
  padding: 0.6em 1.2em;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
}

@media (max-width: 520px) {
  .console-log { height: 300px; }
}
