:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #2563eb;
  --accent-soft: #eff6ff;
  --indigo: #4338ca;
  --ok: #16a34a;
  --ok-soft: #ecfdf5;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --error: #dc2626;
  --error-soft: #fef2f2;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgb(15 23 42 / 0.08);
  --shadow-lg: 0 8px 24px rgb(15 23 42 / 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial,
    "Noto Sans", sans-serif;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1,
h2,
h3 {
  margin: 0 0 0.4em;
  line-height: 1.25;
}

h2 {
  font-size: 1.35rem;
  letter-spacing: -0.01em;
}

h3 {
  font-size: 1.05rem;
}

p {
  margin: 0 0 0.8em;
}

code,
.mono {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 0.92em;
}

.muted {
  color: var(--muted);
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--surface);
  padding: 8px 12px;
  border-radius: 0 0 var(--radius-sm) 0;
  z-index: 10;
}

.skip-link:focus {
  left: 0;
}

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgb(255 255 255 / 0.92);
  backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--line);
}

.topbar__inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 650;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.brand:hover {
  text-decoration: none;
}

.brand__mark {
  width: 34px;
  height: 34px;
  flex: none;
}

.brand__tag {
  font-weight: 400;
  font-size: 0.8rem;
  color: var(--muted);
  padding-left: 10px;
  border-left: 1px solid var(--line);
}

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

.nav__link {
  padding: 7px 13px;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 550;
  font-size: 0.93rem;
}

.nav__link:hover {
  background: var(--accent-soft);
  color: var(--accent);
  text-decoration: none;
}

.nav__link--active {
  background: var(--accent);
  color: #fff;
}

.nav__link--active:hover {
  background: var(--accent);
  color: #fff;
}

.health {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.82rem;
  color: var(--muted);
  white-space: nowrap;
}

.health__dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #cbd5e1;
}

.health__dot--ok {
  background: var(--ok);
  box-shadow: 0 0 0 3px rgb(22 163 74 / 0.15);
}

.health__dot--down {
  background: var(--error);
}

/* ---------- layout ---------- */

.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 20px 48px;
  flex: 1;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}

.card + .card {
  margin-top: 16px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.spread {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

/* ---------- controls ---------- */

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 15px;
  font: inherit;
  font-weight: 570;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  transition: filter 0.15s ease, background 0.15s ease;
}

.btn:hover:not(:disabled) {
  filter: brightness(1.06);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn:focus-visible {
  outline: 2px solid var(--indigo);
  outline-offset: 2px;
}

.btn--ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}

.btn--ghost:hover:not(:disabled) {
  background: var(--accent-soft);
  border-color: #bfdbfe;
}

.btn--danger {
  background: transparent;
  border-color: #fecaca;
  color: var(--error);
}

.btn--danger:hover:not(:disabled) {
  background: var(--error-soft);
}

.btn--sm {
  padding: 5px 10px;
  font-size: 0.86rem;
}

input[type="search"],
input[type="number"],
input[type="text"],
select {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  min-width: 0;
}

input[type="search"] {
  min-width: 160px;
}

/* Only inside a row: in a column the flex-basis would become the height. */
.row input[type="search"] {
  flex: 1 1 260px;
}

input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field > span {
  font-size: 0.82rem;
  color: var(--muted);
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 550;
  cursor: pointer;
  user-select: none;
}

.switch input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

/* ---------- alerts, badges ---------- */

.alert {
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 0.92rem;
}

.alert--info {
  background: var(--accent-soft);
  border-color: #bfdbfe;
  color: #1e3a8a;
}

.alert--success {
  background: var(--ok-soft);
  border-color: #bbf7d0;
  color: #14532d;
}

.alert--warn {
  background: var(--warn-soft);
  border-color: #fde68a;
  color: var(--warn);
}

.alert--error {
  background: var(--error-soft);
  border-color: #fecaca;
  color: #7f1d1d;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  background: #f1f5f9;
  color: var(--muted);
  white-space: nowrap;
}

.badge--ok {
  background: var(--ok-soft);
  color: #15803d;
}

.badge--warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.badge--high {
  background: var(--ok-soft);
  color: #15803d;
}

.badge--ok-score {
  background: var(--accent-soft);
  color: #1d4ed8;
}

/* ---------- dropzone / progress ---------- */

.dropzone {
  border: 2px dashed #cbd5e1;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #ffffff, #f8fafc);
  padding: 42px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.dropzone:hover,
.dropzone:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.dropzone--over {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: scale(1.005);
}

.dropzone__icon {
  width: 44px;
  height: 44px;
  margin: 0 auto 10px;
  display: block;
  color: var(--accent);
}

.dropzone__title {
  font-size: 1.05rem;
  font-weight: 620;
  margin-bottom: 4px;
}

.dropzone__hint {
  color: var(--muted);
  font-size: 0.88rem;
  margin-bottom: 14px;
}

.progress {
  appearance: none;
  width: 100%;
  height: 10px;
  border: none;
  border-radius: 999px;
  overflow: hidden;
  background: #e2e8f0;
}

.progress::-webkit-progress-bar {
  background: #e2e8f0;
  border-radius: 999px;
}

.progress::-webkit-progress-value {
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.2s ease;
}

.progress::-moz-progress-bar {
  background: var(--accent);
  border-radius: 999px;
}

.progress--indeterminate {
  position: relative;
  background: #e2e8f0;
}

.progress--indeterminate::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 40%;
  border-radius: 999px;
  background: var(--accent);
  animation: slide 1.1s ease-in-out infinite;
}

@keyframes slide {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(260%);
  }
}

.spinner {
  width: 15px;
  height: 15px;
  border: 2px solid #cbd5e1;
  border-top-color: var(--accent);
  border-radius: 50%;
  display: inline-block;
  vertical-align: -2px;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- table ---------- */

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.table th {
  text-align: left;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 600;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.table td {
  padding: 10px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

.table tr:last-child td {
  border-bottom: none;
}

.table tbody tr:hover {
  background: #f8fafc;
}

.table .actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.doc-name {
  font-weight: 570;
  word-break: break-word;
}

/* ---------- search layout ---------- */

.search-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.doc-panel {
  position: sticky;
  top: 74px;
}

.doc-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  max-height: 60vh;
  overflow: auto;
}

.doc-row {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  padding: 8px 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.doc-row:hover {
  background: #f8fafc;
}

.doc-row--disabled {
  opacity: 0.55;
  cursor: default;
}

.doc-row input {
  margin-top: 3px;
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
  flex: none;
}

.doc-row__body {
  min-width: 0;
}

.doc-row__name {
  display: block;
  font-weight: 550;
  word-break: break-word;
}

.doc-row__meta {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
}

.doc-row__body .badge {
  margin-top: 3px;
}

.hit {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 13px 15px;
  box-shadow: var(--shadow);
}

.hit + .hit {
  margin-top: 10px;
}

.hit__head {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 7px;
}

.hit__doc {
  font-weight: 620;
}

.hit__snippet {
  margin: 0 0 6px;
}

.hit__snippet mark {
  background: #fef08a;
  color: inherit;
  border-radius: 3px;
  padding: 0 1px;
}

.hit details {
  font-size: 0.88rem;
  color: #334155;
}

.hit summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 550;
}

.summary {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 0.88rem;
  color: var(--muted);
}

.summary strong {
  color: var(--ink);
}

/* ---------- misc ---------- */

.empty-state {
  text-align: center;
  padding: 34px 18px;
  color: var(--muted);
}

.empty-state h3 {
  color: var(--ink);
}

.help {
  font-size: 0.87rem;
  color: var(--muted);
}

.hint {
  font-size: 0.85rem;
  color: var(--warn);
}

.hint:empty {
  display: none;
}

.help ol,
.help ul {
  margin: 6px 0 0;
  padding-left: 20px;
}

.id-line {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  font-size: 0.88rem;
}

.id-line code {
  background: #f1f5f9;
  padding: 3px 7px;
  border-radius: 6px;
  word-break: break-all;
}

.footer {
  border-top: 1px solid var(--line);
  background: var(--surface);
  margin-top: auto;
}

.footer__inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 20px;
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--muted);
}

.footer__inner p {
  margin: 0;
}

.footer__meta {
  display: flex;
  gap: 8px;
  align-items: center;
}

.noscript {
  margin: 0;
  padding: 12px 20px;
  background: var(--warn-soft);
  color: var(--warn);
  text-align: center;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 900px) {
  .topbar__inner {
    flex-wrap: wrap;
    gap: 10px;
  }

  .brand__tag {
    display: none;
  }

  .nav {
    order: 3;
    width: 100%;
    margin-left: 0;
    overflow-x: auto;
  }

  .health {
    margin-left: auto;
  }

  .search-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .row input[type="search"] {
    flex: 1 1 100%;
    width: 100%;
  }

  .doc-panel {
    position: static;
  }

  .doc-list {
    max-height: 40vh;
  }

  .table thead {
    display: none;
  }

  .table,
  .table tbody,
  .table tr,
  .table td {
    display: block;
    width: 100%;
  }

  .table tr {
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    margin-bottom: 10px;
    background: var(--surface);
  }

  .table td {
    border: none;
    padding: 4px 0;
  }

  .table td[data-label]::before {
    content: attr(data-label) ": ";
    color: var(--muted);
    font-size: 0.8rem;
  }

  .table .actions {
    justify-content: flex-start;
    margin-top: 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}


/* ---------- preview modal ---------- */

.modal {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  width: min(900px, 92vw);
  max-height: 88vh;
  box-shadow: 0 24px 64px rgb(15 23 42 / 0.25);
}

.modal::backdrop {
  background: rgb(15 23 42 / 0.45);
}

.modal__inner {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 20px;
  max-height: 88vh;
}

.modal__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.modal__body {
  overflow: auto;
  min-height: 120px;
}

.modal__text {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 0.86rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
}

.modal__frame {
  width: 100%;
  height: 64vh;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
}


.link-quiet {
  color: var(--muted);
  font-size: 0.92rem;
  padding: 0 2px;
}

.link-quiet:hover {
  color: var(--accent);
  text-decoration: none;
}

.modal--narrow {
  width: min(560px, 92vw);
}

.kv-list {
  gap: 2px;
}

.kv {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.88rem;
}

.kv:last-child {
  border-bottom: none;
}

.kv__key {
  color: var(--muted);
}

/* ---------- login ---------- */
.login {
  max-width: 380px;
  margin: 8vh auto 0;
}

.login form .field input {
  width: 100%;
}
