:root {
  --blue: #009fe3;
  --red: #ef3340;
  --green: #00a86b;
  --yellow: #f7c600;
  --ink: #172033;
  --muted: #667085;
  --line: #d8dee8;
  --soft: #f5f8fb;
  --white: #ffffff;
  --radius: 8px;
  font-family: "Nunito", "Aptos Rounded", "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--white);
}

button,
input,
select {
  font: inherit;
}

.splash {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  color: var(--white);
  background: var(--blue);
  font-size: clamp(1.7rem, 6vw, 3.5rem);
  font-weight: 900;
  transition: opacity 280ms ease, visibility 280ms ease;
}

.splash div {
  display: grid;
  gap: 8px;
  justify-items: center;
}

.splash strong {
  font: inherit;
}

.splash span {
  font-size: clamp(0.78rem, 2vw, 1rem);
  font-weight: 800;
  opacity: 0.86;
}

.splash.hidden {
  visibility: hidden;
  opacity: 0;
}

.topbar {
  display: flex;
  gap: 20px;
  align-items: flex-end;
  justify-content: space-between;
  padding: 24px clamp(16px, 3vw, 36px) 18px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: clamp(1.45rem, 3vw, 2.4rem);
  line-height: 1.05;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.stat {
  min-width: 92px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--soft);
}

.stat strong {
  display: block;
  font-size: 1.05rem;
}

.stat span {
  color: var(--muted);
  font-size: 0.75rem;
}

.layout {
  padding: 16px clamp(12px, 3vw, 36px) 36px;
}

.search-panel {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 14px 0;
  background: var(--white);
}

.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 190px;
  gap: 10px;
}

input,
select {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--ink);
}

input {
  width: 100%;
  padding: 0 14px;
}

select {
  padding: 0 10px;
}

.tabs {
  display: flex;
  gap: 6px;
  margin-top: 12px;
  border-bottom: 1px solid var(--line);
}

.tab {
  min-height: 40px;
  padding: 0 14px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.tab.active {
  border-color: var(--blue);
  color: var(--ink);
  font-weight: 800;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 16px;
  align-items: start;
}

.table-wrap,
.gazette-list,
.detail,
canvas {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 205px);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}

.acts-wrap {
  max-height: 280px;
  margin: 12px 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.acts-table {
  min-width: 760px;
  font-size: 0.78rem;
}

.acts-table th,
.acts-table td {
  padding: 8px;
}

.acts-table td:nth-child(3) {
  min-width: 260px;
  color: #344054;
}

.source-pill {
  display: inline-flex;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 900;
}

.source-pill.body {
  background: #e9f8f1;
  color: #067447;
}

.source-pill.summary {
  background: #fff7cc;
  color: #8a6400;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  background: var(--soft);
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

tr {
  cursor: pointer;
}

tr:hover,
tr.selected {
  background: #eef9ff;
}

.type {
  display: inline-flex;
  min-width: 88px;
  justify-content: center;
  padding: 3px 7px;
  border-radius: 999px;
  color: var(--ink);
  background: var(--soft);
  font-size: 0.78rem;
  font-weight: 800;
}

.type.PERSON { background: #e8f7ff; color: #006c9b; }
.type.MONEY { background: #e9f8f1; color: #067447; }
.type.DOCUMENT { background: #fff7cc; color: #8a6400; }
.type.INSTITUTION { background: #ffe9eb; color: #aa1f2b; }
.type.ACT { background: #f2eafa; color: #6941c6; }

.detail {
  position: sticky;
  top: 112px;
  max-height: calc(100vh - 130px);
  overflow: auto;
  padding: 14px;
}

.detail h2 {
  margin: 0 0 4px;
  font-size: 1.1rem;
}

.detail h3 {
  margin: 16px 0 8px;
  font-size: 0.95rem;
}

.detail p {
  margin: 0 0 10px;
  color: var(--muted);
}

.mention {
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.facts {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}

.fact {
  display: grid;
  gap: 5px;
  padding: 10px;
  border: 1px solid #b7e6fb;
  border-left: 4px solid var(--blue);
  border-radius: var(--radius);
  background: #f3fbff;
}

.fact.compact {
  grid-template-columns: minmax(0, 1fr) auto;
}

.fact-label {
  width: fit-content;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--blue);
  color: var(--white);
  font-size: 0.72rem;
  font-weight: 900;
}

.fact strong {
  line-height: 1.25;
}

.fact span,
.fact small {
  color: var(--muted);
}

.relations {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.relation {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
}

.relation strong,
.relation small {
  display: block;
}

.relation small {
  margin-top: 3px;
  color: var(--muted);
}

.relation-kind {
  display: inline-flex;
  width: fit-content;
  margin-bottom: 5px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--ink);
  font-size: 0.7rem;
  font-weight: 900;
}

.relation-kind.HAS_ROLE {
  background: #e8f7ff;
  color: #006c9b;
}

.relation-kind.ASSIGNED_TO {
  background: #ffe9eb;
  color: #aa1f2b;
}

.relation-kind.ISSUES_ACT {
  background: #fff7cc;
  color: #8a6400;
}

.relation-kind.ACT_MENTIONS {
  background: #e9f8f1;
  color: #067447;
}

.mention button,
.gazette button,
.fact button,
.relation button {
  min-height: 32px;
  border: 1px solid var(--blue);
  border-radius: var(--radius);
  color: var(--blue);
  background: var(--white);
  cursor: pointer;
}

.mention-title {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 5px;
  font-weight: 800;
}

.context {
  color: #344054;
  font-size: 0.9rem;
  line-height: 1.35;
}

.gazette-list {
  max-height: calc(100vh - 205px);
  overflow: auto;
}

.gazette {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.gazette:hover,
.gazette.selected {
  background: #f6fbef;
}

.gazette strong {
  display: block;
}

.gazette span {
  color: var(--muted);
  font-size: 0.84rem;
}

.page-box {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--soft);
  white-space: pre-wrap;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.35;
}

.graph-tools {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 10px;
  color: var(--muted);
}

canvas {
  width: 100%;
  height: min(68vh, 720px);
  display: block;
  cursor: grab;
  touch-action: none;
}

canvas:active {
  cursor: grabbing;
}

mark {
  padding: 0 2px;
  border-radius: 3px;
  background: var(--yellow);
}

.empty {
  padding: 22px;
  color: var(--muted);
}

@media (max-width: 840px) {
  .topbar {
    display: block;
  }

  .stats {
    justify-content: flex-start;
    margin-top: 14px;
  }

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

  .detail {
    position: static;
    max-height: none;
  }

  .table-wrap,
  .gazette-list {
    max-height: none;
  }
}
