* { box-sizing: border-box; }
:root {
  color-scheme: dark;
  --surface-primary: #0A0A0A;
  --surface-card: #18181B;
  --surface-card-soft: #27272A;
  --fg-primary: #f8fafc;
  --fg-secondary: #A1A1AA;
  --line: rgba(161, 161, 170, 0.28);
  --accent-primary: #A855F7;
  --accent-primary-rgb: 168, 85, 247;
  --rounded-md: 8px;
  --rounded-lg: 12px;
  --accent-green: #22c55e;
  --accent-yellow: #facc15;
  --accent-red: #fb7185;
  --accent-purple: #A855F7;
}
body {
  margin: 0;
  background: var(--surface-primary);
  color: var(--fg-primary);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 248px;
  padding: 28px 20px;
  background: rgba(10, 10, 10, 0.94);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.brand { font-weight: 800; letter-spacing: 0.02em; margin-bottom: 18px; }
a { color: var(--fg-secondary); text-decoration: none; padding: 10px 12px; border-radius: var(--rounded-md); }
a:hover, a:focus { color: var(--fg-primary); background: rgba(var(--accent-primary-rgb), 0.14); }
a:focus-visible,
button:focus-visible,
.button:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(var(--accent-primary-rgb), 0.22);
}
.shell { margin-left: 248px; max-width: 1440px; padding: 32px; }
.hero, .panel { border: 1px solid var(--line); background: rgba(24, 24, 27, 0.9); border-radius: var(--rounded-lg); padding: 28px; margin-bottom: 24px; box-shadow: 0 18px 48px rgba(0,0,0,0.3); }
.eyebrow { color: var(--accent-primary); font-family: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace; text-transform: uppercase; letter-spacing: .08em; }
h1, h2, h3 { margin: 0 0 12px; }
p { color: var(--fg-secondary); line-height: 1.65; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card { background: var(--surface-card); border: 1px solid var(--line); border-radius: var(--rounded-lg); padding: 18px; min-height: 140px; }
.card header { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.badge { border-radius: 999px; padding: 4px 9px; border: 1px solid currentColor; font-family: "Geist Mono", ui-monospace, monospace; font-size: 12px; white-space: nowrap; }
.badge.ok { color: var(--accent-green); }
.badge.warn { color: var(--accent-yellow); }
.badge.fail { color: var(--accent-red); }
.badge.info { color: var(--accent-primary); }
.meta, .mono { font-family: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--fg-secondary); }
.table { width: 100%; border-collapse: collapse; overflow: hidden; border-radius: var(--rounded-md); }
th, td { text-align: left; padding: 14px; border-bottom: 1px solid var(--line); color: var(--fg-secondary); }
th { color: var(--fg-primary); background: rgba(148, 163, 184, 0.08); }
button, .button { border: 1px solid var(--line); color: var(--fg-primary); background: rgba(var(--accent-primary-rgb), 0.16); border-radius: var(--rounded-md); padding: 10px 14px; margin: 4px 6px 4px 0; font-weight: 700; }
button.warn { background: rgba(250, 204, 21, .12); color: var(--accent-yellow); }
button.danger { background: rgba(251, 113, 133, .12); color: var(--accent-red); }
.timeline { border-left: 2px solid var(--accent-primary); padding-left: 18px; display: grid; gap: 12px; }
.step { background: rgba(161, 161, 170, .1); border-radius: var(--rounded-md); padding: 12px; }
.closure { display: grid; gap: 12px; }
.closure-row { display: grid; grid-template-columns: 180px repeat(5, 1fr); gap: 8px; align-items: stretch; }
.closure-row > div { border: 1px solid var(--line); border-radius: var(--rounded-md); padding: 10px; color: var(--fg-secondary); font-size: 13px; }
.closure-row .head { color: var(--fg-primary); font-weight: 700; background: rgba(var(--accent-primary-rgb), .12); }
@media (max-width: 980px) { .sidebar { position: static; width: auto; } .shell { margin-left: 0; padding: 18px; } .grid, .grid.three { grid-template-columns: 1fr; } .closure-row { grid-template-columns: 1fr; } }

.tab-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 18px;
}

.tab-bar span {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--fg-secondary);
  background: rgba(148, 163, 184, 0.08);
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
}

.registry-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.registry-header p { margin: 0; }

.reg-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.kpi-card,
.source-table,
.overview-card,
.action-bar {
  background: var(--surface-card);
  border: 1px solid var(--line);
  border-radius: var(--rounded-lg);
  padding: 18px;
}

.kpi-card h3,
.overview-card h3,
.action-bar h3 {
  margin-bottom: 8px;
}

.kpi-card p:last-child,
.overview-card p:last-child,
.overview-card ul:last-child,
.action-bar p:last-child,
.action-bar ul:last-child {
  margin-bottom: 0;
}

.source-table { overflow-x: auto; }

.entity-rows {
  display: grid;
  gap: 16px;
  margin: 18px 0;
}

.entity-row {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
  gap: 18px;
  min-height: 0;
}

.entity-side {
  display: grid;
  gap: 12px;
  align-content: start;
}

.action-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.split-workbench {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(0, 1.6fr);
  gap: 18px;
}

.candidate-list,
.decision-panel {
  min-height: 0;
}

.candidate-item {
  border: 1px solid var(--line);
  border-radius: var(--rounded-md);
  padding: 12px;
  margin-top: 12px;
  background: rgba(148, 163, 184, 0.08);
}

.candidate-item.selected {
  border-color: var(--accent-primary);
  background: rgba(var(--accent-primary-rgb), 0.14);
}

.candidate-item header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.decision-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.decision-grid article,
.lineage-node {
  border: 1px solid var(--line);
  border-radius: var(--rounded-md);
  padding: 12px;
  background: rgba(10, 10, 10, 0.36);
}

.lineage-graph {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 12px;
  overflow-x: auto;
}

.lineage-node {
  display: grid;
  gap: 8px;
  min-width: 150px;
  position: relative;
}

.lineage-node.ok {
  border-color: rgba(34, 197, 94, 0.62);
}

.lineage-node.warn,
.lineage-node.info {
  border-color: rgba(168, 85, 247, 0.62);
}

.lineage-node.fail {
  border-color: rgba(251, 113, 133, 0.62);
}

@media (max-width: 980px) {
  .registry-header,
  .entity-row,
  .split-workbench,
  .decision-grid,
  .lineage-graph {
    grid-template-columns: 1fr;
  }

  .registry-header {
    flex-direction: column;
  }

  .reg-kpis {
    grid-template-columns: 1fr;
  }
}
