/* mobile-first, system font stack — NF-004 ≤500ms 4G paint target */
:root {
  --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --max-w: 900px;
  --space: 1rem;
  --radius: 4px;
  --border: #d0d0d0;
  --muted: #666;
  --accent: #0057b8;
  --accent-hover: #003d82;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  font-family: var(--font);
  font-size: clamp(0.875rem, 2.5vw, 1rem);
  line-height: 1.5;
  margin: 0;
  padding: var(--space);
  color: #1a1a1a;
  background: #fff;
}

main {
  max-width: var(--max-w);
  margin: 0 auto;
}

h1 {
  font-size: clamp(1.25rem, 4vw, 1.75rem);
  margin: 0 0 var(--space);
}

h2 {
  font-size: clamp(1rem, 3vw, 1.375rem);
  margin: 1.5rem 0 0.5rem;
}

h3 {
  font-size: clamp(0.9rem, 2.5vw, 1.125rem);
  margin: 1rem 0 0.25rem;
}

nav {
  margin-bottom: var(--space);
}

nav a {
  margin-right: 1rem;
}

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

a:hover {
  text-decoration: underline;
}

table {
  width: 100%;
  border-collapse: collapse;
  overflow-x: auto;
  display: block;
}

th,
td {
  text-align: left;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th {
  font-weight: 600;
  background: #f5f5f5;
}

input,
select,
textarea,
button {
  font-family: var(--font);
  font-size: inherit;
}

input[type="text"],
input[type="search"],
input[type="date"],
select,
textarea {
  padding: 0.375rem 0.5rem;
  border: 1px solid #bbb;
  border-radius: var(--radius);
  width: 100%;
}

button,
input[type="submit"] {
  display: inline-block;
  padding: 0.375rem 0.75rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
}

button:hover,
input[type="submit"]:hover {
  background: var(--accent-hover);
}

form {
  margin: var(--space) 0;
}

fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  margin: 0 0 var(--space);
}

legend {
  font-weight: 600;
  padding: 0 0.25rem;
}

label {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.875rem;
}

svg {
  max-width: 100%;
  height: auto;
  display: block;
}

footer {
  margin-top: 2rem;
  padding-top: var(--space);
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.8125rem;
}

.badge {
  display: inline-block;
  padding: 0.125rem 0.375rem;
  border-radius: var(--radius);
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-short {
  background: #fde68a;
  color: #78350f;
}

.badge-long {
  background: #dbeafe;
  color: #1e3a5f;
}

.trend-up {
  color: #15803d;
}

.trend-down {
  color: #b91c1c;
}

.rank {
  color: var(--muted);
  font-weight: 600;
}

.error {
  color: #b91c1c;
  background: #fee2e2;
  border: 1px solid #fca5a5;
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  margin-bottom: var(--space);
}

@media (min-width: 600px) {
  body {
    padding: 1.5rem 2rem;
  }

  input[type="text"],
  input[type="search"],
  input[type="date"],
  select {
    width: auto;
  }

  table {
    display: table;
  }
}

.topnav {
  padding: 0.6em 1em;
  background: #f5f5f5;
  border-bottom: 1px solid #ddd;
  font-size: 0.95em;
}
.topnav a {
  color: #0366d6;
  text-decoration: none;
  margin-right: 0.2em;
}
.topnav a:hover {
  text-decoration: underline;
}
.link-button {
  background: none;
  border: none;
  color: #d73a49;
  cursor: pointer;
  font: inherit;
  padding: 0;
}
.link-button:hover {
  text-decoration: underline;
}

.flash {
  padding: 0.6em 1em;
  background: #d4edda;
  border: 1px solid #c3e6cb;
  color: #155724;
  border-radius: 4px;
  margin: 1em 0;
}

.scan-log {
  background: #1e1e1e;
  color: #d4d4d4;
  padding: 1em;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85em;
  line-height: 1.4;
  max-height: 70vh;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  border-radius: 4px;
}
