:root {
  --bg: #080b14;
  --bg-nav: #101525;
  --card: #141b2d;
  --card-elevated: #1b243b;
  --border: #2b3553;
  --purple: #8b5cf6;
  --violet: #a78bfa;
  --blue: #38bdf8;
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;
  --text: #f8fafc;
  --text-dim: #94a3b8;
  --text-muted: #64748b;
  --font-display: "Space Grotesk", system-ui, sans-serif;
  --font-body: "Plus Jakarta Sans", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(circle at 12% 10%, rgba(139, 92, 246, 0.14), transparent 36%), var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
}

body.reduced-motion * {
  transition: none !important;
  animation: none !important;
}

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

.sidebar {
  width: 280px;
  background: var(--bg-nav);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  max-height: 100vh;
  position: sticky;
  top: 0;
}

.brand-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.22), rgba(56, 189, 248, 0.1));
}

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.brand-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
}

.brand-sub {
  font-size: 0.76rem;
  color: var(--blue);
  font-family: var(--font-mono);
}

.sidebar-nav {
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-group-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 10px 10px 4px;
  font-family: var(--font-mono);
}

.nav-item {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-dim);
  padding: 9px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
}

.nav-item:hover {
  background: rgba(139, 92, 246, 0.12);
  color: var(--text);
}

.nav-item.active {
  background: rgba(139, 92, 246, 0.22);
  border-color: rgba(167, 139, 250, 0.45);
  color: var(--text);
  font-weight: 600;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(16, 21, 37, 0.88);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 20;
  flex-wrap: wrap;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.25rem;
}

.safety-chip {
  font-size: 0.73rem;
  color: var(--violet);
  font-family: var(--font-mono);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.main-content {
  padding: 20px;
  max-width: 1240px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: rgba(20, 27, 45, 0.92);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
}

.hero-card {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.22), rgba(16, 21, 37, 0.96), rgba(56, 189, 248, 0.14));
  border: 1px solid rgba(167, 139, 250, 0.45);
}

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }

.stat-card {
  background: var(--card-elevated);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
}

.stat-val {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--blue);
}

.stat-label { font-size: 0.8rem; color: var(--text-dim); }

.btn-primary, .btn-outline, .tab-btn, .chip-btn {
  border-radius: 10px;
  font-family: var(--font-body);
  font-weight: 600;
  cursor: pointer;
  min-height: 40px;
  padding: 8px 14px;
  font-size: 0.88rem;
}

.btn-primary {
  background: linear-gradient(135deg, var(--purple), #6d28d9);
  color: var(--text);
  border: none;
}

.btn-outline {
  background: var(--card-elevated);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.18);
  color: #fca5a5;
  border: 1px solid var(--red);
  border-radius: 10px;
  padding: 8px 14px;
  cursor: pointer;
}

.chip-row, .tabs-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip-btn, .tab-btn {
  background: var(--card-elevated);
  color: var(--text-dim);
  border: 1px solid var(--border);
  min-height: 36px;
  padding: 6px 12px;
}

.chip-btn.active, .tab-btn.active {
  background: rgba(139, 92, 246, 0.25);
  color: var(--text);
  border-color: var(--purple);
}

.input, .textarea, .select {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-family: var(--font-body);
  font-size: 0.92rem;
}

.textarea.mono, .code-block {
  font-family: var(--font-mono);
  font-size: 0.84rem;
}

.code-block {
  background: #05070e;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  overflow-x: auto;
  white-space: pre-wrap;
  color: #bae6fd;
  margin: 8px 0;
}

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-family: var(--font-mono);
  border: 1px solid var(--border);
}

.badge.Critical, .badge.MISSING { color: #fda4af; border-color: var(--red); background: rgba(239, 68, 68, 0.15); }
.badge.High, .badge.WARN { color: #fcd34d; border-color: var(--amber); background: rgba(245, 158, 11, 0.15); }
.badge.Medium, .badge.Low { color: #7dd3fc; border-color: var(--blue); background: rgba(56, 189, 248, 0.15); }
.badge.PASS, .badge.Done { color: #86efac; border-color: var(--green); background: rgba(34, 197, 94, 0.15); }

.progress-track {
  width: 100%;
  height: 8px;
  background: var(--card-elevated);
  border-radius: 999px;
  overflow: hidden;
  margin: 8px 0;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--purple), var(--blue));
}

.terminal-box {
  background: #04070f;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 0.83rem;
  color: #86efac;
  max-height: 260px;
  overflow-y: auto;
  white-space: pre-wrap;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(4, 7, 15, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}

.modal-card {
  width: 100%;
  max-width: 560px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px;
  max-height: 85vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.stack-form, .stack-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.field-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.86rem;
  color: var(--text-dim);
}

.search-results {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 320px;
  overflow-y: auto;
}

.search-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--card-elevated);
  border: 1px solid var(--border);
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  color: var(--text);
}

.icon-btn {
  background: var(--card-elevated);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  min-width: 40px;
  min-height: 40px;
  cursor: pointer;
  font-size: 1.2rem;
}

.toast {
  position: fixed;
  bottom: 74px;
  right: 20px;
  background: var(--card-elevated);
  border: 1px solid var(--purple);
  color: var(--text);
  padding: 12px 16px;
  border-radius: 12px;
  z-index: 60;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

.error-text { color: #fca5a5; font-size: 0.86rem; }
.muted { color: var(--text-dim); font-size: 0.88rem; }
.full-width { width: 100%; }
.hidden { display: none !important; }
.mobile-only { display: none; }
.mobile-bottom-nav { display: none; }

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    left: -300px;
    top: 0;
    bottom: 0;
    z-index: 40;
    transition: left 0.2s ease;
  }
  .sidebar.open { left: 0; }
  .mobile-only { display: inline-flex; align-items: center; justify-content: center; }
  .main-content { padding: 14px 14px 80px; }
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-nav);
    border-top: 1px solid var(--border);
    z-index: 30;
    justify-content: space-around;
    padding: 6px;
  }
  .bottom-nav-btn {
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 0.74rem;
    min-height: 44px;
    padding: 4px 8px;
    border-radius: 8px;
    cursor: pointer;
  }
  .bottom-nav-btn.active {
    color: var(--blue);
    background: rgba(139, 92, 246, 0.16);
    font-weight: 600;
  }
}
