:root {
  --text: #1d2125;
  --muted: #5c6670;
  --bg: #ffffff;
  --border: #d0d5da;
  --accent: #1f5b99;
  --error-bg: #fbeaea;
  --error-text: #8a1f1f;
  --warning: #9a4a06;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.site-name { font-weight: 600; color: var(--text); text-decoration: none; }

.logout { display: flex; align-items: center; gap: 0.75rem; color: var(--muted); }

main { max-width: 60rem; margin: 0 auto; padding: 1.5rem 1rem; }

.login { max-width: 22rem; margin: 2rem auto; }
.login form { display: flex; flex-direction: column; gap: 0.35rem; }
.login input[type="text"], .login input[type="password"] {
  padding: 0.5rem;
  font: inherit;
  border: 1px solid var(--border);
  border-radius: 4px;
  margin-bottom: 0.5rem;
}
.login .checkbox { display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.75rem; }
.access { max-width: 28rem; }
.access textarea { font: inherit; padding: 0.5rem; border: 1px solid var(--border); border-radius: 4px; }
.field-error { color: var(--error-text); font-size: 0.9rem; margin: 0; }
.history-note { font-size: 0.9rem; padding: 0.5rem 0.7rem; background: #f2f4f6; border-radius: 4px; }

button {
  font: inherit;
  padding: 0.45rem 1rem;
  border: 1px solid var(--accent);
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
.logout button { background: transparent; color: var(--accent); }
.button-link {
  display: inline-block;
  padding: 0.45rem 1rem;
  border: 1px solid var(--accent);
  border-radius: 4px;
  color: var(--accent);
  text-decoration: none;
}
.button-link.primary { background: var(--accent); color: #fff; }

.flash { padding: 0.6rem 0.8rem; border-radius: 4px; }
.flash-error { background: var(--error-bg); color: var(--error-text); }
.flash-info { background: #eef3f9; }

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

.tabs { display: flex; gap: 1.25rem; margin-right: auto; margin-left: 1.5rem; }
.tabs a { color: var(--accent); text-decoration: none; padding-bottom: 0.15rem; white-space: nowrap; }
.tabs > span { white-space: nowrap; }
.tabs a[aria-current="page"] { color: var(--text); border-bottom: 2px solid var(--accent); }

/* Search form */
.search-box { display: flex; gap: 0.5rem; }
.search-box input {
  flex: 1;
  min-width: 0;
  padding: 0.55rem 0.7rem;
  font: inherit;
  border: 1px solid var(--border);
  border-radius: 4px;
}
.filters { display: flex; flex-wrap: wrap; gap: 0.75rem 1.5rem; margin: 0.9rem 0 0.4rem; }
.filters fieldset { border: 0; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.2rem 0.8rem; align-items: center; }
.filters legend { font-size: 0.85rem; font-weight: 600; color: var(--muted); padding: 0; margin-bottom: 0.2rem; }
.filters .checkbox { display: inline-flex; align-items: center; gap: 0.3rem; }
.filters .field-note { font-size: 0.85rem; color: var(--muted); }
.filters input[type="date"], .filters select { font: inherit; padding: 0.2rem 0.3rem; }
.chip { display: inline-block; margin: 0.4rem 0; padding: 0.25rem 0.7rem; background: #eef3f9; border-radius: 1rem; }

details { margin: 0.6rem 0; }
summary { cursor: pointer; color: var(--accent); }
.advanced label { display: flex; flex-direction: column; max-width: 30rem; margin: 0.4rem 0; font-size: 0.9rem; }
.advanced input { font: inherit; padding: 0.4rem; border: 1px solid var(--border); border-radius: 4px; }
.advanced label.inline { flex-direction: row; align-items: center; gap: 0.4rem; }
.advanced input.narrow { width: 4.5rem; }
.hint { color: var(--muted); font-size: 0.9rem; margin: 0.3rem 0; }
.tips dl { display: grid; grid-template-columns: max-content 1fr; gap: 0.25rem 1rem; }
.tips dt { margin: 0; }
.tips dd { margin: 0; }
code { background: #f2f4f6; padding: 0.05rem 0.3rem; border-radius: 3px; }

/* Help page */
.help { max-width: 52rem; }
.help h1 { font-size: 1.5rem; margin-bottom: 0.3rem; }
.help h2 { font-size: 1.15rem; margin: 1.8rem 0 0.5rem; }
.help li { margin: 0.35rem 0; }
.help-contents { color: var(--muted); font-size: 0.9rem; overflow-wrap: anywhere; }
.help table { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
.help th, .help td { text-align: left; vertical-align: top; padding: 0.35rem 0.6rem; border-bottom: 1px solid var(--border); }
.help th { font-size: 0.85rem; color: var(--muted); }
.help .syntax td:first-child { white-space: nowrap; }
.help .number { text-align: right; font-variant-numeric: tabular-nums; }
.help-link { font-size: 0.9rem; }

/* Results */
.summary { margin-top: 1.25rem; }
.notice { padding: 0.5rem 0.8rem; background: #fff7e0; border-radius: 4px; }
.results { list-style: none; padding: 0; margin: 0; }
.result { padding: 1rem 0; border-top: 1px solid var(--border); }
.result h2 { font-size: 1.1rem; margin: 0; }
.result h2 a { text-decoration: none; }
.meta, .links, .more-pages { color: var(--muted); font-size: 0.9rem; margin: 0.2rem 0; }
.page-hit { display: grid; grid-template-columns: 3.5rem 1fr; gap: 0.5rem; margin: 0.4rem 0; }
.page-number { font-size: 0.9rem; padding-top: 0.05rem; }
.snippet { margin: 0 0 0.3rem; }
.section { margin: 0 0 0.2rem; font-size: 0.9rem; color: var(--muted); }
.section strong { color: var(--text); font-weight: 600; }
.warning { color: var(--warning); }
mark { background: #fde68a; color: inherit; padding: 0 0.1rem; }
a { color: var(--accent); }
.pagination { display: flex; gap: 1.5rem; justify-content: center; margin: 1.5rem 0; }

@media (max-width: 40rem) {
  .help .syntax td:first-child { white-space: normal; }
  .tabs { margin-left: 0.75rem; gap: 0.75rem; }
  .page-hit { grid-template-columns: 1fr; gap: 0; }
}

/* Admin pages */
.admin h2 { font-size: 1.15rem; margin: 1.8rem 0 0.5rem; }
.admin h3 { font-size: 1.05rem; margin: 0; }
.request { overflow-wrap: anywhere; padding: 0.9rem 1rem; border: 1px solid var(--border); border-radius: 6px; margin: 0.8rem 0; }
.request .note { margin: 0.3rem 0; font-style: italic; }
.decide { display: flex; flex-direction: column; gap: 0.5rem; max-width: 30rem; margin-top: 0.6rem; }
.decide label { display: flex; flex-direction: column; font-size: 0.9rem; gap: 0.2rem; }
.decide input, .decide select, .admin-table input { font: inherit; padding: 0.35rem; border: 1px solid var(--border); border-radius: 4px; }
.buttons { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }
button.secondary { background: transparent; color: var(--accent); }
.admin-table { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
.admin-table th, .admin-table td { text-align: left; vertical-align: top; padding: 0.45rem 0.5rem; border-bottom: 1px solid var(--border); }
.admin-table th { font-size: 0.85rem; color: var(--muted); }
.admin-table form.inline { display: flex; gap: 0.3rem; }
.admin-table input[name="network"] { width: 9.5rem; }
.small { font-size: 0.85rem; }
.ips { margin: 0.3rem 0 0; padding-left: 1rem; font-size: 0.85rem; }
.badge { display: inline-block; min-width: 1.2rem; padding: 0 0.35rem; border-radius: 0.6rem; background: var(--warning); color: #fff; font-size: 0.8rem; text-align: center; }
@media (max-width: 40rem) {
  .tabs { order: 3; width: 100%; margin-left: 0; }
  .admin-table thead { display: none; }
  .admin-table tr { display: block; border-bottom: 1px solid var(--border); padding: 0.4rem 0; }
  .admin-table td { display: block; border: 0; padding: 0.15rem 0; }
}

/* Search history */
.history-page h1 { margin-bottom: 0.4rem; }
.history-page .search-box { max-width: 30rem; margin: 0.8rem 0 0.4rem; }
.history-page h2.day { font-size: 1rem; color: var(--muted); margin: 1.6rem 0 0.3rem; }
.history { list-style: none; padding: 0; margin: 0; }
.history-entry { padding: 0.6rem 0; border-top: 1px solid var(--border); }
.history-head { margin: 0; display: flex; flex-wrap: wrap; gap: 0.2rem 0.7rem; align-items: baseline; }
.history-head .query { font-weight: 600; overflow-wrap: anywhere; }
.history-head .person { font-weight: 600; }
.opened { margin: 0.3rem 0 0; padding-left: 1.1rem; font-size: 0.92rem; }
.opened li { margin: 0.15rem 0; }
.history-filters { display: flex; flex-wrap: wrap; gap: 0.6rem 1rem; align-items: flex-end; margin: 0.6rem 0 0.4rem; }
.history-filters label { display: flex; flex-direction: column; font-size: 0.85rem; color: var(--muted); gap: 0.15rem; }
.history-filters select, .history-filters input { font: inherit; padding: 0.35rem; border: 1px solid var(--border); border-radius: 4px; }
.admin-nav { display: flex; gap: 1rem; font-size: 0.95rem; margin-bottom: 0.5rem; }
.admin-nav a[aria-current="page"] { color: var(--text); font-weight: 600; text-decoration: none; }

/* Terms of use */
.modal-backdrop { position: fixed; inset: 0; z-index: 10; background: rgba(29, 33, 37, 0.55); overflow-y: auto; padding: 2rem 1rem; }
.modal { max-width: 40rem; margin: 0 auto; background: var(--bg); border-radius: 8px; padding: 1.5rem 1.75rem; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25); }
.modal h1, .terms-page h1 { font-size: 1.4rem; margin-top: 0; }
.terms-page { max-width: 40rem; }
.terms-list { padding-left: 1.3rem; }
.terms-list li { margin: 0.55rem 0; }
.modal form { margin-top: 1.2rem; }
.site-footer { max-width: 60rem; margin: 2rem auto 1.5rem; padding: 0 1rem; font-size: 0.85rem; }
.site-footer a { color: var(--muted); }
