:root {
  --bg: #0f1218;
  --bg-elevated: #171b24;
  --bg-soft: #1e2430;
  --border: #2a3140;
  --text: #e8ecf4;
  --muted: #9aa3b5;
  --accent: #6ea8fe;
  --accent-strong: #3d8bfd;
  --danger: #f07178;
  --ok: #7fd99a;
  --radius: 10px;
  --font: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", "SF Mono", ui-monospace, monospace;
  --sidebar-w: 300px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
}

a {
  color: var(--accent);
}

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

.small {
  font-size: 12.5px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
  color: var(--accent);
  margin: 0 0 0.5rem;
}

/* Login */
.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(ellipse at 20% 0%, #1a2740 0%, transparent 50%),
    radial-gradient(ellipse at 80% 100%, #1a2a22 0%, transparent 45%),
    var(--bg);
}

.login-card {
  width: min(420px, 100%);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

.login-card h1 {
  margin: 0 0 0.5rem;
  font-size: 1.6rem;
  font-weight: 600;
}

.login-form {
  display: grid;
  gap: 0.9rem;
  margin-top: 1.4rem;
}

.login-form label {
  display: grid;
  gap: 0.35rem;
  font-size: 13px;
  color: var(--muted);
}

.login-form input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 0.7rem 0.8rem;
  font: inherit;
}

.login-form input:focus {
  outline: 2px solid rgba(110, 168, 254, 0.35);
  border-color: var(--accent);
}

.login-form button,
.btn {
  background: var(--accent-strong);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.7rem 1rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.login-form button:hover,
.btn:hover {
  filter: brightness(1.08);
}

.btn.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 500;
}

.btn.small-btn {
  padding: 0.35rem 0.7rem;
  font-size: 12.5px;
}

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

/* App shell */
.app-body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #3d8bfd, #2a6f4e);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.04em;
}

.brand strong {
  display: block;
  font-size: 14px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 0;
}

.sidebar {
  border-right: 1px solid var(--border);
  background: var(--bg-elevated);
  overflow: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.panel {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
}

.panel h2 {
  margin: 0 0 0.5rem;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  font-weight: 600;
}

.panel.callout {
  background: #17231c;
  border-color: #2a4535;
}

.panel.callout p {
  margin: 0;
  color: var(--muted);
}

.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-list li,
.doc-tree button,
.nav-list button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  padding: 0.4rem 0.45rem;
  border-radius: 6px;
  cursor: pointer;
}

.nav-list button:hover,
.doc-tree button:hover,
.nav-list button.active,
.doc-tree button.active {
  background: rgba(110, 168, 254, 0.12);
  color: var(--accent);
}

.doc-tree details {
  margin: 0.15rem 0;
}

.doc-tree summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 12.5px;
  padding: 0.25rem 0.2rem;
}

.main-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0.5rem 0.75rem 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.tab {
  background: transparent;
  border: none;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  padding: 0.55rem 0.9rem;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
}

.tab.active {
  color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-bottom-color: var(--bg-elevated);
  margin-bottom: -1px;
}

.pane {
  display: none;
  flex: 1;
  min-height: 0;
}

.pane.active {
  display: flex;
  flex-direction: column;
}

.doc-view {
  flex: 1;
  overflow: auto;
  padding: 1.5rem 2rem 3rem;
  max-width: 52rem;
}

.doc-view h1,
.doc-view h2,
.doc-view h3 {
  line-height: 1.25;
}

.doc-view h1 {
  font-size: 1.75rem;
  margin-top: 0;
}

.doc-view h2 {
  margin-top: 1.75rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
}

.doc-view table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13.5px;
  margin: 1rem 0;
}

.doc-view th,
.doc-view td {
  border: 1px solid var(--border);
  padding: 0.45rem 0.6rem;
  text-align: left;
  vertical-align: top;
}

.doc-view th {
  background: var(--bg-soft);
}

.doc-view code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--bg-soft);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

.doc-view pre {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.9rem 1rem;
  overflow: auto;
}

.doc-view pre code {
  background: none;
  padding: 0;
}

.doc-view blockquote {
  margin: 1rem 0;
  padding: 0.25rem 0 0.25rem 1rem;
  border-left: 3px solid var(--accent);
  color: var(--muted);
}

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

.terminal-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}

.terminal-host {
  flex: 1;
  min-height: 280px;
  padding: 0.5rem;
  background: #0b0d11;
}

.terminal-host .xterm {
  height: 100%;
}

.terminal-host .xterm-viewport {
  overflow-y: auto !important;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    max-height: 38vh;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .doc-view {
    padding: 1rem;
  }
}
