:root {
  --bg: #14171c;
  --panel: #1b1f27;
  --panel-2: #222733;
  --border: #2c3240;
  --text: #e6e9ef;
  --text-dim: #8b93a3;
  --accent: #5b8cff;
  --accent-soft: #2a3a63;
  --good: #46c98a;
  --bad: #ef5b5b;
  --warn: #e0a84a;
  --mono: ui-monospace, "Cascadia Code", "SFMono-Regular", Consolas, monospace;
  --sans: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
}

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

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2.5rem;
  width: min(90vw, 340px);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.login-card h1 {
  margin: 0;
  letter-spacing: 0.02em;
}

.subtitle {
  margin: -0.5rem 0 0.5rem;
  color: var(--text-dim);
  font-size: 0.85rem;
}

.login-card label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.82rem;
  color: var(--text-dim);
}

.login-card input {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.55rem 0.6rem;
  color: var(--text);
  font-size: 0.95rem;
}

.login-card button {
  margin-top: 0.5rem;
}

.error {
  background: rgba(239, 91, 91, 0.12);
  border: 1px solid var(--bad);
  color: var(--bad);
  padding: 0.5rem 0.7rem;
  border-radius: 6px;
  font-size: 0.85rem;
  margin: 0;
}

/* ---- shared controls ---- */

button {
  background: var(--accent);
  color: #0c1220;
  border: none;
  border-radius: 6px;
  padding: 0.5rem 0.9rem;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.85rem;
}
button:hover { filter: brightness(1.08); }
button:disabled { opacity: 0.4; cursor: default; }

button.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

button.danger {
  background: var(--bad);
  color: #200a0a;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.25rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-weight: 700;
  letter-spacing: 0.02em;
}
.brand-sub {
  font-weight: 400;
  color: var(--text-dim);
  font-size: 0.8rem;
  margin-left: 0.5rem;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--text-dim);
  display: inline-block;
}
.status-dot.on { background: var(--good); }
.status-dot.off { background: var(--bad); }

.user-chip {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
}

/* ---- tabs ---- */

.tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0.6rem 1.25rem 0;
  background: var(--bg);
}

.tab {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  padding: 0.55rem 1rem;
  font-weight: 600;
}
.tab.active {
  background: var(--panel);
  color: var(--text);
  border-color: var(--border);
}

main {
  padding: 1.25rem;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---- console ---- */

.log-box {
  background: #0c0f14;
  border: 1px solid var(--border);
  border-radius: 8px;
  height: 60vh;
  overflow-y: auto;
  padding: 0.75rem 0.9rem;
  font-family: var(--mono);
  font-size: 0.8rem;
  white-space: pre-wrap;
  word-break: break-word;
  color: #cfd6e4;
}

.console-form {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.console-form input {
  flex: 1;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.55rem 0.7rem;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.85rem;
}

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

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.1rem;
}
.card h3 {
  margin: 0 0 0.5rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  font-weight: 600;
}
.card pre {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.85rem;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---- load graphs ---- */

.graphs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.graph-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.1rem;
}
.graph-card h3 {
  margin: 0 0 0.6rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  font-weight: 600;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
.graph-value {
  font-family: var(--mono);
  font-size: 0.95rem;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text);
}
.graph-card canvas {
  display: block;
  width: 100%;
  height: 120px;
}

/* ---- minimap ---- */

.minimap-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
}

.minimap-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.9rem 1rem 1rem;
}
.minimap-card h3 {
  margin: 0 0 0.6rem;
  font-size: 0.82rem;
  font-family: var(--mono);
  color: var(--text);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
.minimap-card h3 .count {
  color: var(--text-dim);
  font-size: 0.72rem;
  text-transform: none;
}
.minimap-card canvas {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  height: auto;
  background: #0c0f14;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: default;
  image-rendering: pixelated;
}

/* ---- worlds ---- */

.worlds-toolbar {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}

.worlds-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.worlds-table th, .worlds-table td {
  text-align: left;
  padding: 0.55rem 0.8rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.worlds-table th {
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.worlds-table tbody tr:last-child td { border-bottom: none; }
.worlds-table td.name { font-family: var(--mono); }
.worlds-table td.protected { color: var(--text-dim); font-size: 0.75rem; }

.hint {
  color: var(--text-dim);
  font-size: 0.78rem;
  margin-top: 0.75rem;
}
