:root {
  --font-sans: "IBM Plex Sans", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;

  --bg: #0f1115;
  --bg-elevated: #161a21;
  --bg-soft: #1c222c;
  --border: #2a3140;
  --border-strong: #3a4458;
  --text: #e8ecf3;
  --text-muted: #8b95a8;
  --text-faint: #5f6b7f;
  --accent: #6b8cae;
  --accent-soft: rgba(107, 140, 174, 0.15);
  --success: #6f9e7f;
  --warning: #c4a35a;
  --danger: #c47a7a;
  --radius: 8px;
  --radius-sm: 6px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --sidebar-w: 220px;
  --topbar-h: 88px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

a {
  color: var(--accent);
}

#app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--border);
  background: var(--bg-elevated);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 30;
  pointer-events: auto;
}

#modal-root:empty {
  pointer-events: none;
}

#modal-root:not(:empty) {
  pointer-events: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #2a3548, #1a2030);
  border: 1px solid var(--border-strong);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-text strong {
  font-weight: 600;
  font-size: 14px;
}

.brand-text span {
  color: var(--text-muted);
  font-size: 12px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  text-align: left;
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
  width: 100%;
  cursor: pointer;
  position: relative;
  z-index: 1;
}

.nav-item:hover {
  background: var(--bg-soft);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--text);
}

.sidebar-footer {
  margin-top: auto;
  padding: 0 8px;
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: var(--topbar-h);
  padding: 20px 28px 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(22, 26, 33, 0.9), rgba(15, 17, 21, 0.4));
}

.topbar > div:first-child {
  min-width: 0;
  flex: 1;
}

.topbar h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.page-sub {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.45;
  max-width: 44rem;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.view-root {
  padding: 20px 28px 40px;
  flex: 1;
}

.muted {
  color: var(--text-muted);
}

.faint {
  color: var(--text-faint);
}

.mono {
  font-family: var(--font-mono);
  font-size: 12px;
}

@media (max-width: 900px) {
  #app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .nav {
    flex-direction: row;
    flex-wrap: wrap;
  }
}
