:root {
  --ink: #1f2933;
  --muted: #5f6f7f;
  --line: #d8dee6;
  --surface: #ffffff;
  --surface-2: #f5f7fa;
  --accent: #b4232a;
  --accent-2: #176b87;
  --ok: #28714f;
}

html {
  font-size: 15px;
  min-height: 100%;
}

body {
  margin-bottom: 64px;
  color: var(--ink);
  background: #eef2f5;
}

a {
  color: var(--accent-2);
}

.navbar-brand {
  font-weight: 700;
  letter-spacing: 0;
}

.app-container {
  padding-top: 28px;
  padding-bottom: 44px;
}

.workspace-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}

.workspace-header h1 {
  margin: 0;
  font-size: 2rem;
  font-weight: 700;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.stats-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(92px, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.stats-strip div {
  min-width: 0;
  padding: 10px 12px;
  background: var(--surface);
}

.stats-strip span {
  display: block;
  font-size: 1.2rem;
  font-weight: 700;
}

.stats-strip small {
  color: var(--muted);
  white-space: nowrap;
}

.crawl-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.crawl-status {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
}

.crawl-status strong,
.crawl-status small {
  display: block;
}

.crawl-status small,
.crawl-message {
  color: var(--muted);
}

.crawl-message {
  padding-left: 10px;
  border-left: 1px solid var(--line);
}

.status-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--ok);
}

.status-dot.is-running {
  background: var(--accent-2);
  box-shadow: 0 0 0 4px rgba(23, 107, 135, .14);
}

.status-dot.is-failed {
  background: var(--accent);
}

.crawl-actions {
  display: grid;
  grid-template-columns: minmax(260px, 360px) auto;
  gap: 10px;
}

.crawl-actions .form-select {
  border-color: #c9d2dc;
  border-radius: 8px;
}

.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px auto;
  gap: 10px;
  margin-bottom: 18px;
}

.search-row .form-control,
.search-row .form-select {
  border-color: #c9d2dc;
  border-radius: 8px;
}

.btn {
  border-radius: 8px;
}

.btn-primary {
  border-color: var(--accent);
  background: var(--accent);
}

.btn-primary:hover,
.btn-primary:focus {
  border-color: #8f1b21;
  background: #8f1b21;
}

.results-shell {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.results-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}

.results-toolbar strong {
  color: var(--ink);
}

.results-toolbar time {
  white-space: nowrap;
}

.result-list {
  display: grid;
}

.result-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.result-item:last-child {
  border-bottom: 0;
}

.result-kicker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 7px;
}

.result-kicker span {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border: 1px solid #cad6df;
  border-radius: 999px;
  color: #334b5f;
  background: #f6fafc;
  font-size: .82rem;
}

.result-item h2 {
  margin: 0 0 6px;
  font-size: 1.08rem;
  font-weight: 700;
}

.result-item p {
  margin: 0;
}

.subject {
  color: #334155;
}

.reference {
  margin-top: 6px !important;
  color: #475569;
  font-size: .92rem;
}

.delict {
  margin-top: 8px !important;
  color: var(--ok);
}

.snippet {
  margin-top: 10px !important;
  color: var(--muted);
}

.result-actions {
  display: flex;
  align-items: start;
  gap: 8px;
  white-space: nowrap;
}

.empty-state {
  padding: 34px 16px;
  text-align: center;
}

.empty-state h2 {
  font-size: 1.25rem;
}

.footer {
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 64px;
  line-height: 64px;
  background: #fff;
}

.document-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.document-header h1 {
  margin: 0 0 6px;
  font-size: 1.45rem;
  font-weight: 700;
}

.document-header p {
  margin: 0;
}

.document-actions {
  display: flex;
  flex-wrap: wrap;
  align-content: start;
  justify-content: end;
  gap: 8px;
  white-space: nowrap;
}

.document-meta {
  display: grid;
  gap: 1px;
  overflow: hidden;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.document-meta div {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 16px;
  padding: 12px 14px;
  background: var(--surface);
}

.document-meta strong {
  color: #334b5f;
}

.pdf-viewer {
  height: min(78vh, 820px);
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.pdf-viewer iframe {
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 8px;
}

.text-preview {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.text-preview h2 {
  margin: 0 0 14px;
  font-size: 1.1rem;
}

.text-preview article {
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.text-preview article span {
  color: var(--accent-2);
  font-size: .82rem;
  font-weight: 700;
}

.text-preview article p {
  margin: 6px 0 0;
  color: #334155;
}

.json-block {
  min-height: 60vh;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111827;
  color: #e5edf5;
  font-size: .9rem;
  white-space: pre-wrap;
}

@media (max-width: 900px) {
  .workspace-header {
    align-items: stretch;
    flex-direction: column;
  }

  .crawl-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .stats-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .search-row,
  .crawl-actions,
  .result-item,
  .results-toolbar {
    grid-template-columns: 1fr;
  }

  .search-row,
  .crawl-actions,
  .results-toolbar,
  .result-item {
    display: grid;
  }

  .result-actions {
    flex-wrap: wrap;
  }

  .document-header,
  .document-meta div {
    grid-template-columns: 1fr;
  }

  .document-header {
    flex-direction: column;
  }

  .document-actions {
    justify-content: start;
  }
}
