:root {
  color-scheme: dark;
  --bg: #0b0d11;
  --bg-elevated: #11141a;
  --panel: #141820;
  --panel-2: #1a1f2a;
  --line: #2a3140;
  --line-strong: #3a4356;
  --text: #e8eaed;
  --muted: #8b93a7;
  --faint: #5c6578;
  --accent: #5b8def;
  --accent-soft: rgba(91, 141, 239, 0.12);
  --accent-border: rgba(91, 141, 239, 0.35);
  --ok: #3d9a6a;
  --ok-soft: rgba(61, 154, 106, 0.14);
  --warn: #c9923a;
  --warn-soft: rgba(201, 146, 58, 0.14);
  --danger: #d4655c;
  --danger-soft: rgba(212, 101, 92, 0.14);
  --radius: 6px;
  --radius-lg: 10px;
  --sidebar-w: 240px;
  --font: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
}

/* ── Shell ───────────────────────────────────────── */

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

.sidebar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  width: var(--sidebar-w);
  flex-shrink: 0;
  flex-direction: column;
  height: 100vh;
  border-right: 1px solid var(--line);
  background: var(--bg-elevated);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.1rem 1rem 1rem;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  color: var(--text);
}

.sidebar-brand img {
  width: 22px;
  height: 22px;
}

.sidebar-brand-title {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.sidebar-brand-sub {
  margin-top: 0.1rem;
  font-size: 0.7rem;
  color: var(--faint);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.85rem 0.65rem;
}

.nav-group {
  margin-bottom: 1.15rem;
}

.nav-group-label {
  padding: 0 0.55rem 0.4rem;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 2px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 0.48rem 0.6rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}

.nav-link:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
}

.nav-link.active {
  color: var(--text);
  border-color: var(--accent-border);
  background: var(--accent-soft);
}

.sidebar-foot {
  padding: 0.85rem;
  border-top: 1px solid var(--line);
}

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

.app-content {
  flex: 1;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: var(--bg);
}

.mobile-nav-link {
  flex-shrink: 0;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 0.4rem 0.7rem;
  font-size: 0.75rem;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}

.mobile-nav-link.active {
  color: var(--text);
  border-color: var(--accent-border);
  background: var(--accent-soft);
}

/* ── Surfaces (replace old glass aesthetic) ─────── */

.glass,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: none;
  backdrop-filter: none;
}

.shadow-glow {
  box-shadow: none !important;
}

.page-stack {
  --card-gap: 1rem;
}

.page-header {
  margin-bottom: 1.25rem;
}

.page-kicker {
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--faint);
}

.page-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.page-desc {
  margin: 0.4rem 0 0;
  max-width: 40rem;
  font-size: 0.9rem;
  color: var(--muted);
}

/* ── Flow / onboarding ──────────────────────────── */

.flow-steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

@media (max-width: 720px) {
  .flow-steps {
    grid-template-columns: 1fr;
  }
}

.flow-step {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.flow-step:hover {
  border-color: var(--accent-border);
  background: var(--panel-2);
}

.flow-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  flex-shrink: 0;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 600;
}

.flow-step h3 {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
}

.flow-step p {
  margin: 0.25rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.empty-state {
  text-align: center;
  padding: 2.5rem 1.25rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
}

.empty-state h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.empty-state p {
  margin: 0.5rem auto 0;
  max-width: 28rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.65rem;
}

@media (max-width: 800px) {
  .stat-row {
    grid-template-columns: repeat(2, 1fr);
  }
}

.stat {
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.12s ease;
}

.stat:hover {
  border-color: var(--line-strong);
}

.stat-label {
  font-size: 0.72rem;
  color: var(--muted);
}

.stat-value {
  margin-top: 0.25rem;
  font-family: var(--mono);
  font-size: 1.35rem;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.stat.high .stat-value { color: #f0a09a; }
.stat.medium .stat-value { color: #e0c08a; }
.stat.info .stat-value { color: #a8c0f0; }

/* ── Forms & buttons ────────────────────────────── */

.mono {
  font-family: var(--mono);
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 0.55rem 0.9rem;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 550;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.btn:hover {
  background: #6b9af5;
}

.btn.secondary {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}

.btn.secondary:hover {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.03);
}

.btn.ok {
  background: var(--ok);
  color: #fff;
}

.btn.ok:hover {
  background: #48ab78;
}

.btn.danger {
  background: transparent;
  border-color: rgba(212, 101, 92, 0.4);
  color: #f0b0aa;
}

.btn.danger:hover {
  background: var(--danger-soft);
}

.btn:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.field-label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
}

.field-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
  padding: 0.6rem 0.75rem;
  color: var(--text);
  font-family: inherit;
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.12s ease;
}

.field-input::placeholder {
  color: var(--faint);
}

.field-input:focus {
  border-color: var(--accent);
}

/* ── Tables ─────────────────────────────────────── */

.tbl,
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.tbl th,
.tbl td,
.data-table th,
.data-table td {
  border-bottom: 1px solid var(--line);
  text-align: left;
  padding: 0.65rem 0.75rem;
  vertical-align: top;
}

.tbl th,
.data-table th {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.68rem;
  font-weight: 600;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
}

.link-accent {
  color: #9bb6f5;
  font-weight: 550;
  text-decoration: none;
}

.link-accent:hover {
  color: #c2d2fa;
  text-decoration: underline;
}

/* ── Badges ─────────────────────────────────────── */

.badge,
.badge-info,
.badge-low,
.badge-medium,
.badge-high {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  border: 1px solid var(--line);
  padding: 0.15rem 0.45rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: lowercase;
  letter-spacing: 0.01em;
}

.badge.info,
.badge-info {
  background: var(--accent-soft);
  color: #b7cbff;
  border-color: var(--accent-border);
}

.badge.low,
.badge-low {
  background: var(--ok-soft);
  color: #8fd4b0;
  border-color: rgba(61, 154, 106, 0.35);
}

.badge.medium,
.badge-medium {
  background: var(--warn-soft);
  color: #e8c48a;
  border-color: rgba(201, 146, 58, 0.35);
}

.badge.high,
.badge-high {
  background: var(--danger-soft);
  color: #f0b0aa;
  border-color: rgba(212, 101, 92, 0.4);
}

.badge.skip,
.badge-skip {
  background: rgba(140, 147, 167, 0.12);
  color: #a8b0c0;
  border-color: rgba(140, 147, 167, 0.35);
}

/* ── Misc legacy helpers ────────────────────────── */

.pre {
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  padding: 0.75rem 0.9rem;
  white-space: pre-wrap;
  word-break: break-word;
  overflow: auto;
  font-family: var(--mono);
  font-size: 0.78rem;
}

.alert {
  border-radius: var(--radius);
  border: 1px solid rgba(212, 101, 92, 0.4);
  background: var(--danger-soft);
  color: #f0b0aa;
  padding: 0.75rem 0.9rem;
  margin-bottom: 0.85rem;
}

.finding,
.finding-item,
.step-card {
  margin-top: 0.65rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  padding: 0.85rem;
}

.finding-top {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.finding-title {
  font-weight: 600;
}

.scrollbar-thin::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.scrollbar-thin::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 4px;
}

.scrollbar-thin::-webkit-scrollbar-track {
  background: transparent;
}

/* Soften leftover Tailwind “pill / glass” density on older pages */
.rounded-3xl {
  border-radius: var(--radius-lg) !important;
}

.rounded-2xl {
  border-radius: var(--radius) !important;
}

.rounded-full.border {
  border-radius: 4px !important;
}

/* ── Funny logo loader (long navigations / heavy pages) ── */

.pepa-loader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(11, 13, 17, 0.72);
  backdrop-filter: blur(2px);
}

.pepa-loader[hidden] {
  display: none !important;
}

.pepa-loader-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 1.5rem 1.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
}

.pepa-loader-logo {
  width: 72px;
  height: 72px;
  object-fit: contain;
  animation: pepa-wobble-spin 1.1s linear infinite;
  filter: drop-shadow(0 0 12px rgba(91, 141, 239, 0.35));
}

.pepa-loader-text {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.pepa-loader-sub {
  font-size: 0.75rem;
  color: var(--muted);
}

@keyframes pepa-wobble-spin {
  0% {
    transform: rotate(0deg) scale(1) rotateX(0deg);
  }
  25% {
    transform: rotate(90deg) scale(1.08) rotateX(12deg);
  }
  50% {
    transform: rotate(180deg) scale(0.94) rotateX(0deg);
  }
  75% {
    transform: rotate(270deg) scale(1.08) rotateX(-12deg);
  }
  100% {
    transform: rotate(360deg) scale(1) rotateX(0deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .pepa-loader-logo {
    animation: pepa-pulse 1.4s ease-in-out infinite;
  }
  @keyframes pepa-pulse {
    0%, 100% { opacity: 0.7; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.05); }
  }
}
