:root {
  --bg: #0b0f17;
  --surface: #121826;
  --surface2: #1a2235;
  --border: #243049;
  --text: #e8edf7;
  --muted: #8b9ab8;
  --accent: #3b82f6;
  --accent2: #6366f1;
  --success: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 260px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.25rem;
}

.brand {
  display: flex;
  gap: .75rem;
  align-items: center;
  margin-bottom: 2rem;
}
.brand-icon {
  width: 42px; height: 42px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 10px;
  display: grid; place-items: center;
  font-size: 1.3rem;
}
.brand-icon.lg { width: 56px; height: 56px; font-size: 1.6rem; margin: 0 auto 1rem; }
.brand strong { display: block; font-size: 1rem; }
.brand span { color: var(--muted); font-size: .75rem; }

nav { display: flex; flex-direction: column; gap: .35rem; flex: 1; }
nav a {
  color: var(--muted);
  text-decoration: none;
  padding: .65rem .85rem;
  border-radius: 8px;
  font-size: .9rem;
  font-weight: 500;
}
nav a:hover, nav a.active {
  background: var(--surface2);
  color: var(--text);
}

.sidebar-footer { margin-top: auto; }

.content { flex: 1; padding: 1.5rem 2rem; overflow-y: auto; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.topbar h1 { font-size: 1.5rem; }
.topbar p { color: var(--muted); font-size: .875rem; margin-top: .25rem; }

.status-pill {
  display: flex; align-items: center; gap: .5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: .5rem 1rem;
  border-radius: 999px;
  font-size: .85rem;
}
.status-pill .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted);
}
.status-pill.online .dot { background: var(--success); box-shadow: 0 0 8px var(--success); }
.status-pill.building .dot { background: var(--warn); animation: pulse 1s infinite; }
.status-pill.error .dot { background: var(--danger); }
.status-pill.standby .dot { background: var(--muted); }
.status-pill.offline .dot { background: var(--danger); }
.status-pill.connecting .dot { background: var(--warn); animation: pulse 1s infinite; }

.brain-banner {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fca5a5;
  padding: .85rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: .9rem;
}
.brain-banner.hidden { display: none; }

.ok-text { color: var(--success); }
.warn-text { color: var(--danger); }
.panel-note { margin-top: .5rem; }

.btn:disabled { opacity: .45; cursor: not-allowed; }

.connection-badge {
  display: inline-block;
  padding: .4rem .85rem;
  border-radius: 999px;
  font-size: .85rem;
  font-weight: 600;
  margin-bottom: .85rem;
}
.connection-badge.online { background: rgba(34,197,94,.15); color: #86efac; border: 1px solid rgba(34,197,94,.35); }
.connection-badge.standby { background: rgba(148,163,184,.12); color: #cbd5e1; border: 1px solid rgba(148,163,184,.3); }
.connection-badge.connecting { background: rgba(234,179,8,.12); color: #fde68a; border: 1px solid rgba(234,179,8,.35); }
.connection-badge.offline { background: rgba(239,68,68,.12); color: #fca5a5; border: 1px solid rgba(239,68,68,.35); }

@keyframes pulse { 50% { opacity: .4; } }

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.card.wide { margin-bottom: 1rem; }
.card label { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; }
.card .value { font-size: 1.25rem; font-weight: 600; margin-top: .35rem; }
.card .value.mono { font-family: monospace; font-size: 1rem; }
.card h3 { margin-bottom: 1rem; font-size: 1rem; }

.server-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: .75rem;
}
.server-chip {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .85rem;
  cursor: pointer;
  transition: border-color .2s;
}
.server-chip:hover { border-color: var(--accent); }
.server-chip.active { border-color: var(--success); }
.server-chip strong { display: block; font-size: .9rem; }
.server-chip span { color: var(--muted); font-size: .75rem; }

.row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; margin-top: .75rem; }
.row.between { justify-content: space-between; }

.input {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: .65rem .85rem;
  font-size: .9rem;
  flex: 1;
  min-width: 200px;
}
.textarea { width: 100%; resize: vertical; font-family: inherit; }

.btn {
  border: none;
  border-radius: 8px;
  padding: .65rem 1.1rem;
  font-weight: 600;
  font-size: .875rem;
  cursor: pointer;
  transition: opacity .2s;
}
.btn:hover { opacity: .85; }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--muted); }
.btn.sm { padding: .4rem .75rem; font-size: .8rem; }
.btn.full { width: 100%; }

.hint { color: var(--muted); font-size: .8rem; margin-top: .75rem; }
.hint code { background: var(--surface2); padding: .1rem .35rem; border-radius: 4px; }

.view { display: none; }
.view.active { display: block; }

.log-box {
  background: #060a10;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  height: 420px;
  overflow-y: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: .78rem;
  line-height: 1.6;
}
.log-line { margin-bottom: .15rem; }
.log-line .ts { color: var(--muted); }
.log-line.INFO .lvl { color: var(--accent); }
.log-line.WARN .lvl { color: var(--warn); }
.log-line.ERROR .lvl { color: var(--danger); }

.toast {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: .85rem 1.25rem;
  border-radius: 10px;
  transform: translateY(120%);
  transition: transform .3s;
  z-index: 99;
}
.toast.show { transform: translateY(0); }

.login-page {
  display: grid; place-items: center;
  background: radial-gradient(ellipse at top, #141c2e, var(--bg));
}
.login-card {
  width: min(400px, 92vw);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
}
.login-card label { display: block; color: var(--muted); font-size: .8rem; margin: .75rem 0 .35rem; }
.brand-center { text-align: center; margin-bottom: 1.5rem; }
.brand-center h1 { font-size: 1.4rem; }
.brand-center p { color: var(--muted); font-size: .85rem; }
.error { color: var(--danger); font-size: .85rem; margin-top: .75rem; text-align: center; }

.operators-list { list-style: none; margin: 1rem 0 0; padding: 0; }
.operators-list li {
  display: flex; align-items: center; justify-content: space-between;
  padding: .55rem .75rem; border: 1px solid var(--border); border-radius: 8px; margin-bottom: .5rem;
}
.operators-list .muted { color: var(--muted); border: none; padding: .25rem 0; }

@media (max-width: 768px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
  nav { flex-direction: row; flex-wrap: wrap; }
  .content { padding: 1rem; }
}
