:root {
  --bg: #fafafa;
  --fg: #222;
  --accent: #1762b1;
  --warn-bg: #fff8c4;
  --border: #ddd;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
}
* { box-sizing: border-box; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.45 system-ui, sans-serif;
  margin: 0;
}
header {
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: baseline;
  gap: 1.5rem;
  background: white;
}
header h1 { font-size: 1.1rem; margin: 0; }
header h1 a { color: var(--accent); text-decoration: none; }
header nav a { margin-right: 1rem; color: var(--fg); text-decoration: none; }
header nav a.active { color: var(--accent); font-weight: 600; border-bottom: 2px solid var(--accent); padding-bottom: 2px; }
header .who { margin-left: auto; color: #666; font-size: 0.9rem; }
main { max-width: 960px; margin: 1.5rem auto; padding: 0 1.5rem; }
main.wide { max-width: 1320px; }   /* data-dense pages (requests, bootstrap) */
h2 { margin-top: 0; }
/* Wide tables scroll inside their box instead of breaking the layout. */
.table-wrap { overflow-x: auto; }
form { margin: 1rem 0; }
input[type=text], input:not([type]) {
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.95rem;
}
textarea {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: 0.92rem/1.5 var(--mono);
  resize: vertical;
  min-height: 7rem;
  background: white;
}
textarea:focus, input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(23, 98, 177, 0.15);
}
.field-label { display: block; font-weight: 600; margin-bottom: 0.35rem; }
.form-actions { display: flex; align-items: center; gap: 0.7rem; margin-top: 0.6rem; }
button {
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: white;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
}
button:hover { filter: brightness(1.1); }
table { border-collapse: collapse; width: 100%; margin-top: 0.5rem; }
th, td { padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--border); text-align: left; }
th { color: #555; font-weight: 500; white-space: nowrap; }
tbody tr:hover { background: #f1f4f8; }
td time { white-space: nowrap; color: #444; }

/* Small status/category pills. */
.badge {
  display: inline-block;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1.4;
  border: 1px solid transparent;
}
.badge-claude     { background: #e3effb; color: #1762b1; }
.badge-scalarlm   { background: #fff2cc; color: #8a6d00; }
.badge-general    { background: #e4f4e8; color: #1a7f37; }
.badge-novel      { background: #fde7e9; color: #b00020; }
.badge-uncertain  { background: #eceff2; color: #555; }
.badge-forced     { background: #efe6fb; color: #6b3fb0; }
.badge-fast       { background: #e4f4e8; color: #1a7f37; }
.badge-balanced   { background: #fff2cc; color: #8a6d00; }
.badge-deep       { background: #fde7e9; color: #b00020; }
.label-btn.badge-fast { background: #e4f4e8; color: #1a7f37; }
.label-btn.badge-balanced { background: #fff2cc; color: #8a6d00; }
.label-btn.badge-deep { background: #fde7e9; color: #b00020; }
.status-2xx { color: #1a7f37; }
.status-3xx { color: #8a6d00; }
.status-4xx, .status-5xx { color: #b00020; font-weight: 600; }
.muted { color: #888; }

/* Dashboard metric cards. */
.metrics { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 0.5rem 0 1.25rem; }
.metric {
  background: white; border: 1px solid var(--border); border-radius: 6px;
  padding: 0.45rem 0.9rem; min-width: 6.5rem;
}
.metric-val { font-size: 1.3rem; font-weight: 600; line-height: 1.2; color: var(--fg); }
.metric-val small { font-size: 0.75rem; font-weight: 400; color: #999; }
.metric-label {
  font-size: 0.7rem; color: #777; text-transform: uppercase; letter-spacing: 0.03em;
}
/* Metric cards that link to a filtered view. */
a.metric { text-decoration: none; transition: border-color .1s, box-shadow .1s; }
a.metric:hover { border-color: var(--accent); box-shadow: 0 1px 4px rgba(23,98,177,.12); }
.metrics-caption { margin: -0.5rem 0 1rem; font-size: 0.85rem; }

/* Active-filter chips. */
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin: 0.25rem 0 0.75rem; }
.chip {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.1rem 0.55rem; border: 1px solid var(--border); border-radius: 999px;
  background: #eef2f6; color: #333; text-decoration: none; font-size: 0.82rem;
}
.chip:hover { border-color: var(--accent); }
.chip-x { color: #999; font-weight: 600; }
.chip-clear { background: none; color: #888; }
/* Filter bar: wrapping row of labelled inputs. */
.filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.9rem; }
.filter-bar label { display: inline-flex; align-items: center; gap: 0.35rem; color: #555; }
.filter-bar input[type=text], .filter-bar input[type=number], .filter-bar input:not([type]), .filter-bar select {
  font-size: 0.9rem;
}
.filter-bar .clear { margin-left: 0.2rem; font-size: 0.9rem; }

button.danger { background: #b00020; border-color: #b00020; }
button.secondary, button.example {
  background: #eef2f6; color: #333; border-color: var(--border);
}
button.example { font-size: 0.8rem; margin: 0.15rem; padding: 0.25rem 0.55rem; }
.examples { margin: 0.5rem 0; }
details.batch { margin: 1rem 0; }
details.batch > summary { cursor: pointer; padding: 0.25rem 0; }
details.revoked > summary { cursor: pointer; color: #777; margin-top: 0.5rem; }
.staged-summary { margin: 0.75rem 0; }
details.folder { margin: 0.4rem 0; }
details.folder > summary { cursor: pointer; padding: 0.25rem 0; }
details.folder table { margin-top: 0.2rem; }
code, pre { font-family: var(--mono); }
pre {
  background: white;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow-x: auto;
}
.new-token {
  background: var(--warn-bg);
  padding: 0.75rem 1rem;
  border-left: 4px solid #f0c000;
  margin: 1rem 0;
}
.err { color: #b00020; }
.ok { color: #1a7f37; }

/* Tokens: inline per-row routing-mode editor. */
.mode-form { display: inline-flex; gap: 0.3rem; align-items: center; margin: 0; }
.mode-form select { font-size: 0.85rem; padding: 0.15rem 0.3rem; }

/* Admin: inline per-row limit editing. */
.row-actions { white-space: nowrap; }
.row-actions form { display: inline; margin: 0; }
.row-actions input[type=number] {
  width: 6.5rem; padding: 0.2rem 0.35rem; font-size: 0.85rem;
  border: 1px solid var(--border); border-radius: 4px;
}

/* Sign-in / access-denied card. */
.login-card {
  max-width: 30rem; margin: 3rem auto; background: white;
  border: 1px solid var(--border); border-radius: 8px; padding: 1.5rem 1.75rem;
}
.login-card h2 { margin-top: 0; }
.google-btn {
  display: inline-flex; align-items: center; gap: 0.6rem;
  padding: 0.55rem 1.1rem; border: 1px solid var(--border); border-radius: 6px;
  background: white; color: #333; text-decoration: none; font-weight: 600;
}
.google-btn:hover { box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.google-btn .g {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.2rem; height: 1.2rem; border-radius: 50%; background: var(--accent);
  color: white; font-weight: 700; font-size: 0.85rem;
}

/* Docs viewer: sidebar + rendered Markdown. */
.docs-layout { display: flex; gap: 2rem; align-items: flex-start; }
.docs-nav { flex: 0 0 220px; position: sticky; top: 1rem; }
.docs-nav h3 { margin: 0 0 0.5rem; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: #888; }
.docs-nav ul { list-style: none; margin: 0; padding: 0; }
.docs-nav li { margin: 0.1rem 0; }
.docs-nav a { display: block; padding: 0.25rem 0.5rem; border-radius: 4px; color: var(--fg); text-decoration: none; font-size: 0.9rem; }
.docs-nav a:hover { background: #eef2f6; }
.docs-nav a.active { background: #e3effb; color: var(--accent); font-weight: 600; }
.docs-content { flex: 1 1 auto; min-width: 0; max-width: 820px; }
.markdown { line-height: 1.6; }
.markdown h1 { font-size: 1.7rem; margin: 0 0 1rem; }
.markdown h2 { font-size: 1.3rem; margin: 1.8rem 0 0.6rem; border-bottom: 1px solid var(--border); padding-bottom: 0.2rem; }
.markdown h3 { font-size: 1.1rem; margin: 1.4rem 0 0.5rem; }
.markdown p, .markdown li { color: #333; }
.markdown a { color: var(--accent); }
.markdown code { background: #f1f4f8; padding: 0.1rem 0.3rem; border-radius: 3px; font-size: 0.88em; }
.markdown pre { background: #f7f9fb; border: 1px solid var(--border); border-radius: 6px; padding: 0.8rem 1rem; overflow-x: auto; }
.markdown pre code { background: none; padding: 0; font-size: 0.85rem; }
.markdown table { border-collapse: collapse; margin: 1rem 0; }
.markdown th, .markdown td { border: 1px solid var(--border); padding: 0.4rem 0.6rem; text-align: left; }
.markdown blockquote { margin: 1rem 0; padding: 0.5rem 1rem; border-left: 4px solid #f0c000; background: var(--warn-bg); }
.markdown blockquote p { margin: 0.3rem 0; }

/* Label-for-finetuning controls on the request detail page. */
.label-form { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.label-btn {
  border: 1px solid var(--border); border-radius: 999px;
  padding: 0.2rem 0.8rem; font-size: 0.85rem; font-weight: 600; cursor: pointer;
  color: #333; background: #eef2f6;
}
.label-btn.badge-general { background: #e4f4e8; color: #1a7f37; }
.label-btn.badge-novel { background: #fde7e9; color: #b00020; }
.label-btn:hover { filter: brightness(0.97); }
.label-btn.is-current { outline: 2px solid currentColor; }
table.spans td { vertical-align: top; }
table.spans td:first-child, table.spans th:first-child { text-align: center; white-space: nowrap; }
pre.span-text {
  margin: 0; max-height: 12rem; overflow: auto; white-space: pre-wrap;
  word-break: break-word; font-size: 0.82rem;
}
a.button-link {
  display: inline-block; padding: 0.4rem 0.9rem; background: var(--accent);
  color: white; border-radius: 4px; text-decoration: none; font-size: 0.9rem;
}
a.button-link:hover { filter: brightness(1.1); }
.progress-line { margin: 0.5rem 0 0.25rem; }
progress { width: 100%; height: 1rem; }
