:root {
  color-scheme: light;
  --ink: #18202a;
  --muted: #667085;
  --line: #d9dee8;
  --paper: #f7f8fb;
  --surface: #ffffff;
  --canary: #f2b84b;
  --gazette: #2c7a7b;
  --kyleg: #3e5f99;
  --nexus: #b6485f;
  --ok: #27745f;
  --warn: #a15c22;
  --danger: #9c2f38;
  --focus: #244a85;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 64px;
  padding: 10px clamp(18px, 4vw, 44px);
  border-bottom: 1px solid var(--line);
  background: rgba(247, 248, 251, 0.94);
  backdrop-filter: blur(10px);
}

.brand-mark {
  position: relative;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.brand-mark span {
  position: absolute;
  width: 11px;
  height: 11px;
  border-radius: 50%;
}

.brand-mark span:nth-child(1) {
  left: 8px;
  top: 8px;
  background: var(--canary);
}

.brand-mark span:nth-child(2) {
  right: 8px;
  top: 14px;
  background: var(--gazette);
}

.brand-mark span:nth-child(3) {
  left: 17px;
  bottom: 8px;
  background: var(--nexus);
}

.brand {
  font-weight: 800;
  font-size: 18px;
}

.domain {
  color: var(--muted);
  font-size: 13px;
}

nav {
  margin-left: auto;
  display: flex;
  gap: 6px;
}

nav a {
  color: var(--ink);
  text-decoration: none;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 14px;
}

nav a:hover {
  background: #e9edf4;
}

main {
  width: min(1380px, calc(100vw - 36px));
  margin: 0 auto;
  padding: 28px 0 54px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 1.1fr) minmax(300px, 0.9fr);
  gap: 24px;
  align-items: end;
  padding: 20px 0 28px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--nexus);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(42px, 7vw, 76px);
  line-height: 0.95;
  letter-spacing: 0;
}

.lede {
  max-width: 760px;
  margin-bottom: 0;
  color: #3d4756;
  font-size: 18px;
}

.search-shell,
.panel,
.metric-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.search-shell {
  position: relative;
  padding: 16px;
}

.sticky-search {
  position: sticky;
  top: 76px;
  z-index: 9;
  margin-bottom: 16px;
  box-shadow: 0 10px 28px rgba(24, 32, 42, 0.08);
}

.search-shell label {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.search-label-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 8px;
}

.search-actions,
.result-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.search-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

input {
  min-width: 0;
  width: 100%;
  border: 1px solid #cbd2de;
  border-radius: 6px;
  padding: 12px 13px;
  color: var(--ink);
  font: inherit;
}

input:focus,
select:focus,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

select {
  min-width: 0;
  width: 100%;
  border: 1px solid #cbd2de;
  border-radius: 6px;
  padding: 11px 12px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  padding: 0 16px;
  background: var(--ink);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: #2b3542;
}

.button-secondary {
  min-height: 36px;
  border: 1px solid #cbd2de;
  padding: 0 11px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
}

.button-secondary:hover {
  background: #eef2f7;
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  width: fit-content;
  border-radius: 6px;
  padding: 0 12px;
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.button-link:hover {
  background: #2b3542;
}

.suggest-wrap {
  position: relative;
  min-width: 0;
}

.suggest-box {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 40px rgba(24, 32, 42, 0.16);
}

.suggest-item {
  display: block;
  width: 100%;
  min-height: 42px;
  border: 0;
  border-radius: 0;
  padding: 8px 11px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  font-weight: 600;
}

.suggest-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.filter-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(11, minmax(110px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.source-health-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin: 0 0 18px;
  padding-bottom: 4px;
}

.health-chip {
  flex: 0 0 auto;
  display: grid;
  gap: 2px;
  min-width: 178px;
  padding: 9px 11px;
  border: 1px solid #cfe6dc;
  border-left: 4px solid var(--ok);
  border-radius: 8px;
  background: #f3faf7;
}

.health-chip.is-warning {
  border-color: #f0d1aa;
  border-left-color: var(--warn);
  background: #fff8ee;
}

.health-chip strong {
  font-size: 12px;
}

.health-chip span {
  color: var(--muted);
  font-size: 12px;
}

.metric-card {
  min-height: 124px;
  padding: 13px;
}

.metric-source {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.metric-value {
  margin: 12px 0 2px;
  font-size: 25px;
  font-weight: 800;
  line-height: 1;
}

.metric-label,
.metric-error {
  color: var(--muted);
  font-size: 13px;
}

.metric-error,
.error {
  color: #9c2f38;
}

.is-muted {
  background: #fbf3f3;
}

.split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}

.panel {
  min-width: 0;
  padding: 16px;
}

.currentness {
  margin-bottom: 18px;
}

.search-results-panel {
  margin-bottom: 18px;
}

.status-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 10px;
}

.status-pill {
  display: grid;
  gap: 2px;
  min-height: 68px;
  padding: 10px;
  border-left: 3px solid var(--ok);
  background: #f3faf7;
}

.status-pill.is-warning {
  border-left-color: var(--warn);
  background: #fff8ee;
}

.status-pill strong {
  font-size: 13px;
}

.status-pill span {
  color: var(--muted);
  font-size: 13px;
}

.result-row a {
  color: var(--ink);
  text-decoration: none;
}

.result-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.result-tab {
  min-height: 38px;
  border: 1px solid #cbd2de;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
}

.result-tab:hover,
.result-tab.is-active {
  border-color: #9aa7ba;
  background: #e9edf4;
}

.result-tab span {
  color: var(--muted);
  font-weight: 700;
}

.result-row a:hover {
  text-decoration: underline;
}

.summary-grid {
  display: grid;
  grid-template-columns: minmax(120px, 0.35fr) 1fr;
  gap: 8px 14px;
  margin: 0;
}

.summary-grid dt {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: capitalize;
}

.summary-grid dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 14px;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 5px 9px;
  border: 1px solid #cbd2de;
  border-radius: 6px;
  background: #f7f9fc;
  color: #334155;
  font-size: 13px;
  text-decoration: none;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 14px;
}

.panel-heading h2 {
  margin-bottom: 0;
  font-size: 20px;
}

.panel-heading span {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.rail-list {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.rail-list:last-child {
  margin-bottom: 0;
}

.rail-list h3,
.result-group h3 {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
}

.rail-item,
.result-row {
  display: grid;
  gap: 2px;
  padding: 10px;
  border-left: 3px solid #c8d1df;
  background: #f9fafc;
}

.results-list {
  display: grid;
  gap: 10px;
}

.result-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  padding: 12px;
  border: 1px solid #e0e5ee;
  border-left: 4px solid #c8d1df;
  border-radius: 8px;
  background: #fbfcfe;
}

.result-card-title {
  margin-bottom: 4px;
  overflow-wrap: anywhere;
  font-size: 16px;
  font-weight: 800;
}

.result-card-title a {
  color: var(--ink);
  text-decoration: none;
}

.result-card-title a:hover {
  text-decoration: underline;
}

.result-card p {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 7px;
  border: 1px solid #d7deea;
  border-radius: 6px;
  background: #fff;
  color: #405065;
  font-size: 12px;
  font-weight: 700;
}

.badge-source {
  border-color: #d8e2f5;
  background: #f2f6fd;
}

.badge-provenance {
  max-width: 100%;
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
}

.badge-confidence.is-high {
  border-color: #b7ddcf;
  background: #eefaf5;
  color: var(--ok);
}

.badge-confidence.is-medium {
  border-color: #eacb9e;
  background: #fff8ee;
  color: var(--warn);
}

.badge-confidence.is-low {
  border-color: #e7bdc2;
  background: #fff4f5;
  color: var(--danger);
}

mark {
  border-radius: 4px;
  padding: 0 2px;
  background: #ffe6a6;
  color: inherit;
}

.rail-item strong,
.result-row strong {
  overflow-wrap: anywhere;
  font-size: 14px;
}

.rail-item span,
.result-row span,
.empty {
  color: var(--muted);
  font-size: 13px;
}

.relationship-map {
  position: relative;
  min-height: 230px;
  margin-bottom: 14px;
  border: 1px solid #e0e5ee;
  border-radius: 8px;
  background:
    linear-gradient(#edf1f6 1px, transparent 1px),
    linear-gradient(90deg, #edf1f6 1px, transparent 1px),
    #fbfcfe;
  background-size: 28px 28px;
}

.relationship-map::before,
.relationship-map::after {
  content: "";
  position: absolute;
  left: 22%;
  right: 22%;
  top: 50%;
  height: 2px;
  background: #9aa7ba;
  transform: rotate(-13deg);
}

.relationship-map::after {
  transform: rotate(18deg);
}

.node {
  position: absolute;
  display: grid;
  place-items: center;
  width: 92px;
  height: 42px;
  border-radius: 8px;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 10px 24px rgba(24, 32, 42, 0.15);
}

.canary {
  left: 8%;
  top: 22%;
  background: var(--canary);
  color: #3b2c13;
}

.gazette {
  left: 12%;
  bottom: 18%;
  background: var(--gazette);
}

.kyleg {
  right: 10%;
  top: 20%;
  background: var(--kyleg);
}

.nexus-node {
  right: 18%;
  bottom: 18%;
  background: var(--nexus);
}

.body-copy {
  color: #3d4756;
}

.note {
  padding: 10px;
  border-left: 3px solid var(--warn);
  background: #fff8ee;
  color: #563613;
  font-size: 14px;
}

.bridge-panel,
.deferred-note {
  margin-bottom: 18px;
}

.severity-error,
.severity-critical {
  border-left-color: var(--danger);
  background: #fff4f5;
}

.severity-warning {
  border-left-color: var(--warn);
  background: #fff8ee;
}

.severity-info {
  border-left-color: var(--kyleg);
  background: #f2f6fd;
}

.drawer[hidden] {
  display: none;
}

.drawer {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  justify-content: flex-end;
  background: rgba(24, 32, 42, 0.32);
}

.drawer-panel {
  width: min(560px, 100vw);
  height: 100%;
  overflow-y: auto;
  padding: 18px;
  border-left: 1px solid var(--line);
  background: #fff;
  box-shadow: -20px 0 50px rgba(24, 32, 42, 0.18);
}

.drawer-close {
  float: right;
  margin-bottom: 10px;
}

.drawer-section {
  clear: both;
  display: grid;
  gap: 12px;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.result-group {
  min-width: 0;
}

.table-shell {
  overflow-x: auto;
  border: 1px solid #e0e5ee;
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 10px;
  border-bottom: 1px solid #e7ebf2;
  text-align: left;
  vertical-align: top;
}

th {
  background: #f3f6fa;
  color: #465265;
  font-weight: 800;
}

td {
  overflow-wrap: anywhere;
}

tr:last-child td {
  border-bottom: 0;
}

@media (max-width: 1120px) {
  .metrics-grid {
    grid-template-columns: repeat(4, minmax(130px, 1fr));
  }

  .results-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
  }

  nav {
    display: none;
  }

  main {
    width: min(100vw - 24px, 1380px);
    padding-top: 14px;
  }

  .workspace,
  .split {
    grid-template-columns: 1fr;
  }

  .search-row {
    grid-template-columns: 1fr;
  }

  .sticky-search {
    top: 64px;
  }

  .search-label-row,
  .result-card {
    grid-template-columns: 1fr;
  }

  .search-label-row {
    align-items: flex-start;
    flex-direction: column;
  }

  button {
    min-height: 44px;
  }

  .metrics-grid,
  .results-grid,
  .status-row,
  .summary-grid,
  .filter-row {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 46px;
  }

  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }
}
