:root {
  --bg: #f7f7f5;
  --panel: #ffffff;
  --text: #171717;
  --muted: #666a73;
  --line: #dddeda;
  --brand: #12685f;
  --brand-2: #1f8a70;
  --accent: #f3b23c;
  --danger: #b42318;
  --success: #087443;
  color-scheme: light;
}

:root.dark {
  --bg: #111312;
  --panel: #191c1b;
  --text: #f4f2ec;
  --muted: #a7aaa6;
  --line: #2d312f;
  --brand: #5ed0bd;
  --brand-2: #79ddb2;
  --accent: #f1be5b;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
}
a { color: inherit; text-decoration: none; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 14px clamp(18px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(16px);
}
.brand, .topbar nav { display: flex; align-items: center; gap: 12px; }
.brand { font-weight: 750; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  color: white;
  background: var(--brand);
}
.topbar nav a { color: var(--muted); font-size: 14px; }
.shell { width: min(1120px, calc(100% - 32px)); margin: 0 auto; padding: 34px 0 64px; }
.hero, .admin-head {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  padding: 34px 0;
}
.eyebrow { margin: 0 0 8px; color: var(--brand); font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; }
h1 { margin: 0; font-size: clamp(32px, 5vw, 58px); line-height: 1.02; letter-spacing: 0; max-width: 880px; }
h2 { margin: 0 0 12px; font-size: 24px; }
h3 { margin: 24px 0 12px; font-size: 17px; }
.lede { max-width: 780px; color: var(--muted); font-size: 18px; }
.tabs {
  display: inline-flex;
  padding: 4px;
  gap: 4px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
}
.tabs a { padding: 10px 14px; border-radius: 6px; color: var(--muted); font-weight: 650; }
.tabs a.active { background: var(--text); color: var(--bg); }
.search-panel, .answer, .auth-card, .upload-panel {
  margin-top: 24px;
  padding: 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}
label { display: grid; gap: 8px; font-weight: 700; color: var(--text); }
input, textarea {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--bg);
  font: inherit;
}
textarea { resize: vertical; }
.search-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; margin-top: 10px; align-items: end; }
button, .button {
  min-height: 48px;
  padding: 0 18px;
  border: 0;
  border-radius: 8px;
  background: var(--brand);
  color: white;
  font-weight: 760;
  cursor: pointer;
  transition: transform .18s ease, background .18s ease;
}
button:hover, .button:hover { transform: translateY(-1px); background: var(--brand-2); }
.button.secondary { display: inline-flex; align-items: center; background: transparent; color: var(--text); border: 1px solid var(--line); }
.icon-button { width: 44px; min-height: 44px; padding: 0; border-radius: 8px; }
.results-head { display: flex; justify-content: space-between; gap: 16px; color: var(--muted); margin: 24px 0 10px; }
.result-card {
  display: block;
  margin-top: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  animation: rise .22s ease both;
}
.result-link:hover {
  border-color: color-mix(in srgb, var(--brand) 52%, var(--line));
  transform: translateY(-1px);
}
.result-meta { color: var(--brand); font-weight: 760; margin-bottom: 10px; }
.snippet { color: var(--text); white-space: normal; }
.open-pdf { margin-top: 12px; color: var(--muted); font-size: 14px; font-weight: 700; }
mark { background: color-mix(in srgb, var(--accent) 42%, transparent); color: inherit; padding: 1px 3px; border-radius: 4px; }
.pagination { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; }
.pagination a {
  min-width: 40px;
  padding: 8px 12px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}
.pagination a.active { color: white; background: var(--brand); border-color: var(--brand); }
.auth-card { max-width: 440px; margin: 42px auto; }
.auth-card form, .upload-panel form { display: grid; gap: 16px; margin-top: 18px; }
.alert { padding: 14px 16px; border-radius: 8px; margin: 18px 0; border: 1px solid var(--line); background: var(--panel); }
.alert.error { color: var(--danger); }
.alert.success { color: var(--success); }
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.stats-grid div {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}
.stats-grid span { display: block; color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.stats-grid strong { display: block; font-size: 22px; overflow-wrap: anywhere; }
.documents-list { display: grid; gap: 10px; }
.document-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
}
.document-row strong,
.document-row span { display: block; }
.document-row span { color: var(--muted); font-size: 14px; }
.document-row form { margin: 0; }
.status-pill {
  padding: 7px 10px;
  border-radius: 999px;
  color: var(--success);
  background: color-mix(in srgb, var(--success) 12%, transparent);
  font-weight: 800;
}
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (max-width: 720px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .hero, .admin-head, .results-head { flex-direction: column; }
  .search-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr; }
  .document-row { align-items: stretch; flex-direction: column; }
  h1 { font-size: 34px; }
}
