:root {
  color-scheme: light;
  --color-primary: #4f46e5;
  --color-primary-hover: #4338ca;
  --color-secondary: #10b981;
  --color-neutral: #71717a;
  --color-background: #f7f4ed;
  --color-surface: #fffdf8;
  --color-surface-strong: #ffffff;
  --color-text-primary: #18181b;
  --color-text-secondary: #52525b;
  --color-text-muted: #71717a;
  --color-border: #e7e5df;
  --color-border-strong: #d8d4c9;
  --color-success: #15803d;
  --color-warning: #a16207;
  --color-error: #b91c1c;
  --font-display: "General Sans", "DM Sans", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-body: "DM Sans", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --radius-control: 6px;
  --radius-card: 12px;
  --radius-pill: 999px;
  --topbar-height: 58px;
  --sidebar-width: 244px;
  --content-max-width: 1080px;
  --focus-ring: 0 0 0 3px rgba(79, 70, 229, 0.16);
  --shadow-hover: 0 10px 30px rgba(24, 24, 27, 0.08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 84% 10%, rgba(79, 70, 229, 0.08), transparent 28rem),
    var(--color-background);
  color: var(--color-text-primary);
  font-family: var(--font-body);
  font-size: 15px;
  letter-spacing: -0.01em;
}

body::before {
  content: "";
  position: fixed;
  inset: 78px 28px auto auto;
  width: min(42vw, 540px);
  height: min(42vw, 540px);
  pointer-events: none;
  opacity: 0.44;
  background-image: radial-gradient(var(--color-primary) 1px, transparent 1px);
  background-size: 18px 18px;
  mask-image: radial-gradient(circle, #000 0 46%, transparent 72%);
  z-index: -1;
}

body::after {
  content: "";
  position: fixed;
  inset: auto auto 46px 38px;
  width: 260px;
  height: 260px;
  pointer-events: none;
  opacity: 0.24;
  background-image: radial-gradient(var(--color-secondary) 1px, transparent 1px);
  background-size: 16px 16px;
  mask-image: radial-gradient(circle, #000 0 42%, transparent 72%);
  z-index: -1;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 20px;
  border-bottom: 1px solid var(--color-border);
  background: rgba(255, 253, 248, 0.9);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-width: 196px;
  color: var(--color-text-primary);
  font-family: var(--font-display);
  font-weight: 700;
  text-decoration: none;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 31px;
  height: 31px;
  border-radius: var(--radius-control);
  background: var(--color-primary);
  color: #ffffff;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
}

.nav-links a {
  height: 32px;
  display: inline-flex;
  align-items: center;
  border-radius: var(--radius-control);
  color: var(--color-text-secondary);
  font-size: 13px;
  font-weight: 500;
  padding: 0 10px;
  text-decoration: none;
}
.nav-links a:hover { background: rgba(79, 70, 229, 0.06); color: var(--color-primary); }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.search-field {
  width: 238px;
  height: 34px;
  display: flex;
  align-items: center;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  background: var(--color-surface-strong);
  color: var(--color-text-muted);
  padding: 0 12px;
  font-size: 13px;
}
.search-field::before {
  content: "⌘K";
  margin-right: 10px;
  color: #a1a1aa;
  font-size: 11px;
}

.workspace {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: calc(100vh - var(--topbar-height));
}

.sidebar {
  position: sticky;
  top: var(--topbar-height);
  align-self: start;
  min-height: calc(100vh - var(--topbar-height));
  border-right: 1px solid var(--color-border);
  padding: 24px 16px;
  background: rgba(247, 244, 237, 0.82);
}

.sidebar-group + .sidebar-group { margin-top: 26px; }
.sidebar-label {
  margin: 0 0 8px;
  color: var(--color-text-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar-item {
  height: 36px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 11px;
  border-radius: var(--radius-control);
  color: var(--color-text-secondary);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
}
.sidebar-item span { width: 16px; color: var(--color-neutral); text-align: center; }
.sidebar-item:hover { background: rgba(79, 70, 229, 0.06); color: var(--color-primary); }
.sidebar-item.active { background: var(--color-primary); color: #ffffff; }
.sidebar-item.active span { color: #ffffff; }

.position-card {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-top: 30px;
  padding: 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  background: var(--color-surface);
}
.avatar {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-control);
  background: rgba(16, 185, 129, 0.12);
  color: #047857;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
}
.position-card strong, .position-card small { display: block; }
.position-card strong { font-family: var(--font-display); font-size: 13px; }
.position-card small { margin-top: 2px; color: var(--color-text-muted); font-size: 12px; }

.content-shell {
  width: 100%;
  max-width: var(--content-max-width);
  padding: 28px 34px 36px;
}

.page-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

h1, h2, h3, p { margin-top: 0; }
h1 {
  margin-bottom: 0;
  color: var(--color-text-primary);
  font-family: var(--font-display);
  font-size: clamp(42px, 5vw, 72px);
  font-weight: 700;
  line-height: 0.96;
  letter-spacing: -0.055em;
}
h2 {
  margin-bottom: 0;
  color: var(--color-text-primary);
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: -0.035em;
}
h3 {
  margin-bottom: 8px;
  color: var(--color-text-primary);
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.25;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--color-primary);
  font-size: 11px;
  font-weight: 700;
  line-height: 16px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.muted { color: var(--color-text-muted); line-height: 1.45; }
.public-link, a { color: var(--color-primary); }
.public-link {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 10px;
  text-decoration: none;
}
.public-link:hover { border-color: rgba(79, 70, 229, 0.32); color: var(--color-primary); }

.onboarding-banner {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
  padding: 13px 14px 13px 16px;
  border: 1px solid rgba(79, 70, 229, 0.18);
  border-radius: var(--radius-card);
  background:
    linear-gradient(90deg, rgba(79, 70, 229, 0.08), rgba(255, 253, 248, 0.82)),
    var(--color-surface);
}
.onboarding-banner strong {
  display: block;
  margin-bottom: 2px;
  color: var(--color-text-primary);
  font-family: var(--font-display);
  font-size: 15px;
}
.onboarding-banner span { color: var(--color-text-secondary); font-size: 13px; }
.banner-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.banner-actions span {
  border: 1px solid rgba(16, 185, 129, 0.22);
  border-radius: var(--radius-pill);
  background: rgba(16, 185, 129, 0.08);
  color: #047857;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 9px;
}

.hero-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; margin-bottom: 16px; }
.wide-panel + .wide-panel { margin-top: 16px; }

.panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  padding: 18px;
}
.panel:hover { box-shadow: var(--shadow-hover); }
.safety-panel { border-color: rgba(79, 70, 229, 0.28); }
.safety-panel.violation { border-color: rgba(185, 28, 28, 0.34); box-shadow: var(--focus-ring); }

.card-header-row {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.card-header-row.split { align-items: end; }
.card-header-row.split .muted { max-width: 360px; margin-bottom: 0; }
.header-pill {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  background: #ffffff;
  color: var(--color-text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 9px;
}

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(238px, 1fr)); gap: 10px; }
.grid.compact { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(292px, 1fr)); gap: 12px; }

.card, .metric {
  background: var(--color-surface-strong);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  padding: 14px;
  overflow-wrap: anywhere;
}
.card:hover, .metric:hover { border-color: var(--color-border-strong); box-shadow: var(--shadow-hover); }
.metric .label, .card .label {
  display: block;
  color: var(--color-text-muted);
  font-size: 12px;
  line-height: 1.35;
  margin-bottom: 6px;
  overflow-wrap: anywhere;
}
.metric .value {
  color: var(--color-text-primary);
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.value.bad { color: var(--color-error); }
.source-metric { grid-column: span 2; }

button, .refresh-button {
  height: 34px;
  border: 1px solid var(--color-primary);
  border-radius: var(--radius-control);
  background: var(--color-primary);
  color: #ffffff;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 700;
  padding: 0 13px;
  cursor: pointer;
}
button:hover, .refresh-button:hover { background: var(--color-primary-hover); border-color: var(--color-primary-hover); }
button:focus-visible, .refresh-button:focus-visible, a:focus-visible { outline: none; box-shadow: var(--focus-ring); }
button:disabled { opacity: 0.62; cursor: wait; }

.badge-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.badge {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  background: #ffffff;
  color: var(--color-text-muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  padding: 4px 8px;
}
.badge.ok { border-color: rgba(16, 185, 129, 0.22); background: rgba(16, 185, 129, 0.08); color: #047857; }
.badge.warn { border-color: rgba(161, 98, 7, 0.22); background: rgba(161, 98, 7, 0.07); color: var(--color-warning); }
.badge.bad { border-color: rgba(185, 28, 28, 0.22); background: rgba(185, 28, 28, 0.07); color: var(--color-error); }

.kv { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin: 8px 0; color: var(--color-text-muted); font-size: 13px; }
.kv strong { color: var(--color-text-primary); font-weight: 700; text-align: right; }

pre {
  white-space: pre-wrap;
  max-height: 260px;
  overflow: auto;
  margin: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  background: #fbfaf6;
  color: var(--color-text-primary);
  padding: 12px;
  font-size: 12px;
  line-height: 1.45;
}

ul { padding-left: 19px; margin-bottom: 0; }
li { margin: 8px 0; color: var(--color-text-secondary); line-height: 1.45; }
.notes li::marker { color: var(--color-primary); }

footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--color-text-muted);
  font-size: 12px;
  padding: 20px 0 0;
}

@media (max-width: 1080px) {
  .workspace { grid-template-columns: 1fr; }
  .sidebar { position: static; min-height: auto; border-right: 0; border-bottom: 1px solid var(--color-border); }
  .sidebar-group { display: inline-block; vertical-align: top; min-width: 220px; margin-right: 16px; }
  .position-card { max-width: 280px; }
  .content-shell { max-width: none; }
  .hero-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .topbar { height: auto; min-height: var(--topbar-height); flex-wrap: wrap; padding: 12px; gap: 12px; }
  .brand { min-width: auto; }
  .nav-links { order: 3; width: 100%; overflow-x: auto; }
  .topbar-actions { width: 100%; }
  .search-field { flex: 1; min-width: 0; }
  .content-shell { padding: 22px 16px 28px; }
  .page-header, .onboarding-banner, footer { align-items: flex-start; flex-direction: column; }
  h1 { font-size: 44px; }
  .card-header-row.split { align-items: start; flex-direction: column; }
  .grid, .grid.compact, .cards { grid-template-columns: 1fr; }
  .source-metric { grid-column: auto; }
}
