:root {
  color-scheme: light;
  --background: #eef2f7;
  --surface: #ffffff;
  --text: #142239;
  --border: #cbd5e1;
  --accent: #1545a6;
  --selection: #e3ecff;
  --error: #a52130;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --background: #101827;
  --surface: #172235;
  --text: #edf4ff;
  --border: #3f506b;
  --accent: #a1beff;
  --selection: #243858;
  --error: #ff9caa;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--background); color: var(--text); font: 1rem/1.55 system-ui, sans-serif; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .8rem clamp(1rem, 4vw, 3rem); background: var(--surface); border-bottom: 1px solid var(--border); }
.brand, .actions { display: flex; align-items: center; gap: .65rem; }
.brand { font-weight: 750; font-size: 1.15rem; }
.mark { display: grid; place-items: center; width: 2.1rem; height: 2.1rem; border-radius: .6rem; background: var(--accent); color: var(--surface); }
.layout { display: grid; grid-template-columns: 15rem minmax(0, 1fr); min-height: calc(100vh - 4rem); }
nav { padding: 1rem; background: var(--surface); border-inline-end: 1px solid var(--border); }
nav a { display: block; color: var(--text); padding: .55rem .7rem; margin-bottom: .2rem; border-radius: .55rem; text-decoration: none; }
nav a:hover, nav a[aria-current="page"] { background: var(--selection); color: var(--accent); }
.content { padding: clamp(1rem, 4vw, 3rem); width: 100%; max-width: 87rem; }
.login { max-width: 30rem; margin: clamp(2rem, 12vh, 8rem) auto; padding: 0 1rem; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: .95rem; padding: clamp(1rem, 3vw, 1.75rem); margin-bottom: 1rem; }
h1, h2, p { margin: 0 0 .8em; }
h1 { font-size: clamp(1.55rem, 4vw, 2.35rem); line-height: 1.15; }
h2 { font-size: 1.2rem; }
.panel > :last-child, .stack > p { margin-bottom: 0; }
a { color: var(--accent); }
.tile { display: block; text-decoration: none; font-weight: 650; }
.tile:hover { border-color: var(--accent); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr)); gap: 1rem; }
.stack { display: grid; gap: .9rem; }
.form-row { display: flex; align-items: end; flex-wrap: wrap; gap: .65rem; }
label { display: grid; gap: .35rem; font-weight: 600; }
input, select, button { border: 1px solid var(--border); border-radius: .55rem; padding: .55rem .75rem; font: inherit; }
input, select { max-width: 100%; min-width: 0; color: var(--text); background: var(--background); }
.source-form textarea { min-width: 0; min-height: 3.5rem; resize: vertical; font: inherit; font-weight: 400; color: var(--text); background: var(--background); border: 1px solid var(--border); border-radius: .55rem; padding: .55rem .75rem; }
.source-form .source-enabled { display: flex; align-items: center; }
button { cursor: pointer; color: var(--surface); background: var(--accent); border-color: var(--accent); }
button.secondary { color: var(--text); background: var(--surface); border-color: var(--border); }
button:hover { filter: brightness(.9); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.error { color: var(--error); }
code { overflow-wrap: anywhere; }
.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; text-align: start; }
td, th { padding: .55rem; text-align: start; border-bottom: 1px solid var(--border); }
@media (max-width: 46rem) {
  .layout { display: block; }
  nav { display: flex; gap: .25rem; overflow-x: auto; border-inline-end: 0; border-bottom: 1px solid var(--border); padding: .5rem; }
  nav a { flex: 0 0 auto; }
  .actions button { font-size: .875rem; }
}

.preview-inline { display: flex; flex-wrap: wrap; align-items: end; gap: .75rem; margin-block: .65rem; }
.preview-inline label { margin: 0; }
.preview-inline input[type="checkbox"] { width: auto; }
.table-scroll { overflow-x: auto; }
.content article.panel { margin-block: .75rem; overflow-wrap: anywhere; }
.content textarea { display: block; width: 100%; min-height: 5rem; font: inherit; }

.document-pdf {
  width: 100%;
  height: 75vh;
  border: 0;
}

.document-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

:root {
  --muted: #52647a;
  --divider: #e2e9f0;
  --soft: #f5f8fc;
}
:root[data-theme="dark"] {
  --muted: #b0bed3;
  --divider: #2d3c53;
  --soft: #1d2a40;
}
body { font-size: .92rem; }
.layout { grid-template-columns: 12rem minmax(0, 1fr); }
.content { max-width: none; padding: clamp(.8rem, 2.2vw, 2rem); }
.top { padding-inline: clamp(1rem, 2.2vw, 2rem); }
.analytics-heading { display: flex; align-items: start; justify-content: space-between; flex-wrap: wrap; gap: 1rem; }
.analytics-heading h1 { margin: .35rem 0 .55rem; }
.analytics-actions, .identity-line { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; }
.identity-line, .muted, small { color: var(--muted); }
.back-link { color: var(--muted); text-decoration: none; }
.back-link:hover { text-decoration: underline; }
.control { display: inline-block; padding: .45rem .75rem; background: var(--surface); border: 1px solid var(--border);
  border-radius: .5rem; color: var(--accent); text-decoration: none; white-space: nowrap; }
.analytics-tabs { display: flex; gap: .2rem; overflow: auto; padding: .45rem; border: 1px solid var(--divider);
  border-radius: .7rem; margin: 1.2rem 0; }
.analytics-tabs a { margin: 0; padding: .45rem .7rem; white-space: nowrap; }
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr)); gap: .75rem; margin-bottom: 1rem; }
.metric { background: var(--surface); color: var(--text); text-decoration: none; border: 1px solid var(--divider);
  border-radius: .75rem; display: grid; padding: .85rem 1rem; }
.metric > span { color: var(--muted); }
.metric > strong { color: var(--accent); font-size: 1.8rem; font-variant-numeric: tabular-nums; }
a.metric:hover { border-color: var(--accent); }
.analytics-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.facts { display: grid; grid-template-columns: minmax(6.5rem, max-content) minmax(0, 1fr); gap: .45rem .8rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.activity { display: grid; grid-template-columns: minmax(5.5rem, max-content) minmax(0, 1fr); gap: .65rem;
  padding: .45rem 0; border-bottom: 1px solid var(--divider); }
.activity:last-child { border-bottom: 0; }
.activity > span { color: var(--muted); }
.evidence-row { padding: .5rem 0; border-bottom: 1px solid var(--divider); }
.evidence-row > p:first-of-type, .timeline-event > p:first-of-type { margin-top: .55rem; }
summary { cursor: pointer; }
.filters { display: flex; gap: .55rem; flex-wrap: wrap; align-items: end; margin: .5rem 0 .9rem; }
.filters label { min-width: 0; max-width: min(100%, 15rem); color: var(--muted); font-size: .82rem; }
.filters input, .filters select, .filters button { padding: .42rem .6rem; min-height: 2.25rem; font-size: .88rem; }
.data-table { overflow: auto; background: var(--surface); border: 1px solid var(--divider); border-radius: .65rem; margin-bottom: 1rem; }
.data-table th, .data-table td { padding: .42rem .65rem; border-color: var(--divider); vertical-align: top; }
.data-table thead th { background: var(--soft); color: var(--muted); font-size: .8rem; }
.data-table tbody tr:hover { background: var(--soft); }
.data-table small { display: block; margin-top: .1rem; }
.data-table .numeric { text-align: right; }
.case-number, .nowrap { white-space: nowrap; }
.case-number { font-weight: 650; }
.side-list { min-width: 10rem; max-width: 22rem; overflow-wrap: anywhere; }
.pill { display: inline-block; padding: .05rem .4rem; border-radius: .35rem; background: var(--selection); color: var(--accent);
  font-size: .78rem; margin: 0 .15rem .1rem 0; }
.attention { color: var(--error); }
.group-row th { background: var(--soft); font-weight: 650; }
.compact-panel { padding: .55rem .8rem; }
.document-actions { min-width: 8rem; }
.document-actions[open] { width: min(22rem, 45vw); }
.document-actions p { overflow-wrap: anywhere; margin-top: .5rem; }
.detail-title { font-size: clamp(1.35rem, 2.5vw, 2rem); margin-block: .35rem; }
.graph-shell, .timeline-shell { background: var(--surface); border: 1px solid var(--divider); border-radius: .7rem;
  overflow: hidden; margin-bottom: 1rem; }
.graph-toolbar { padding: .55rem .75rem; display: flex; flex-wrap: wrap; align-items: end; gap: .55rem; border-bottom: 1px solid var(--divider); }
.graph-toolbar button, .graph-toolbar select { padding: .3rem .65rem; }
.legend { display: flex; flex-wrap: wrap; gap: .35rem .8rem; align-self: center; color: var(--muted); font-size: .8rem; }
.dot { display: inline-block; width: .65rem; height: .65rem; border-radius: 50%; margin-right: .25rem; background: var(--role-color); }
.plaintiff { --role-color: #2367ae; }
.respondent { --role-color: #b2533e; }
.third { --role-color: #20766f; }
.applicant { --role-color: #7555ad; }
.other { --role-color: #62748a; }
.mixed { --role-color: #9a7352; }
.graph-view { height: min(54vh, 34rem); min-height: 19rem; background-color: var(--soft);
  background-image: radial-gradient(var(--border) 1px, transparent 1px); background-size: 18px 18px; }
.graph-view svg { width: 100%; height: 100%; touch-action: none; cursor: grab; }
.graph-view svg:active { cursor: grabbing; }
.graph-view text { text-anchor: middle; font-size: 12px; fill: white; font-weight: 650; }
.graph-node circle { fill: var(--role-color); stroke: var(--surface); stroke-width: 1.5; }
.graph-node:hover circle, .graph-node:focus circle { stroke: var(--text); stroke-width: 3; }
.graph-edges line { stroke: var(--role-color); stroke-opacity: .43; }
.graph-subject circle { fill: #173969; }
.graph-subject text:last-child { fill: var(--text); }
.graph-selection { padding: .65rem .8rem; margin: 0; }
.timeline-chart { overflow-x: auto; }
.timeline-table { width: max-content; min-width: 100%; }
.timeline-table th, .timeline-table td { width: 6rem; min-width: 6rem; text-align: center; }
.timeline-table th:first-child { position: sticky; left: 0; background: var(--soft); min-width: 9rem; text-align: left; }
.timeline-table thead th { background: var(--soft); }
.timeline-point { padding: .15rem .55rem; min-width: 2rem; border-radius: 1rem; }
.timeline-list { margin-top: .8rem; }
@media (max-width: 62rem) {
  .analytics-columns { grid-template-columns: 1fr; gap: 0; }
  .layout { grid-template-columns: 10rem minmax(0, 1fr); }
}
@media (max-width: 46rem) {
  .analytics-tabs { margin-block: .9rem; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric { padding: .65rem; }
  .activity { grid-template-columns: 1fr; gap: .1rem; }
  .analytics-tabs a { padding: .4rem .55rem; }
}

.pdf-workspace { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 1rem; }
.pdf-pane, .pdf-info { min-width: 0; height: calc(100dvh - 13rem); min-height: 25rem; }
.pdf-pane { display: flex; flex-direction: column; overflow: hidden; background: var(--surface);
  border: 1px solid var(--divider); border-radius: .75rem; }
.pdf-pane:fullscreen { height: 100dvh; width: 100vw; border-radius: 0; }
.pdf-toolbar, .pdf-form { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.pdf-toolbar { padding: .5rem; border-bottom: 1px solid var(--divider); }
.pdf-toolbar label { display: flex; align-items: center; font-size: .8rem; }
.pdf-toolbar input { width: 4.6rem; }
.pdf-toolbar button, .pdf-toolbar input, .pdf-toolbar .control { padding: .35rem .5rem; }
.pdf-paper { flex: 1; overflow: auto; background: var(--selection); padding: .6rem; }
.pdf-paper img { display: block; width: 100%; margin: auto; background: white; color: #142239; }
.pdf-pane:fullscreen img { max-width: 65rem; }
.pdf-info { overflow: auto; padding: .85rem 1rem; }
.pdf-info pre { padding: .7rem; background: var(--soft); border-radius: .5rem; font: .87rem/1.5 system-ui, sans-serif; }
.pdf-info #pdf-search-results { max-height: 14rem; overflow: auto; }
@media (max-width: 62rem) {
  .pdf-workspace { grid-template-columns: 1fr; }
  .pdf-info { height: auto; min-height: 0; }
}

.asset-indicators { display: flex; gap: .45rem; flex-wrap: wrap; margin-bottom: .8rem; }
.asset-indicators > * { padding: .28rem .55rem; border: 1px solid var(--divider); background: var(--surface);
  color: var(--text); border-radius: .45rem; }
.asset-evidence + .asset-evidence { border-top: 1px solid var(--divider); margin-top: 1rem; }
.asset-evidence h4 { margin: .65rem 0; }
blockquote { margin: .55rem 0; padding: .45rem .7rem; border-inline-start: 3px solid var(--border); overflow-wrap: anywhere; }
.property-edge { --role-color: #8d4a70; }
.graph-edges .property-edge { stroke-dasharray: 5 4; stroke-opacity: .8; }

#girbo-charts canvas { max-width: 100%; height: auto; }

.test-contour-banner {
  background: #ffcf42;
  color: #251700;
  text-align: center;
  padding: .6rem 1rem;
  font-weight: 800;
  letter-spacing: .08em;
}
