:root {
  --bg: #ffffff;
  --fg: #16191d;
  --muted: #5d6570;
  --line: #dde1e6;
  --card: #f6f8fa;
  --accent: #0b5cd8;
  --warn: #8a4b00;
  --danger: #b3261e;
  --tap: 48px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418;
    --fg: #e8eaed;
    --muted: #9aa3ad;
    --line: #2a2f36;
    --card: #1a1f25;
    --accent: #6ea8fe;
    --warn: #e0a458;
    --danger: #f2857c;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 1rem 1rem 4rem;
}

a { color: var(--accent); }

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--card);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { font-weight: 700; text-decoration: none; color: var(--fg); }
.bar nav { display: flex; align-items: center; gap: 1rem; }
.inline { display: inline; margin: 0; }

button, input, textarea, select { font: inherit; }

button {
  min-height: var(--tap);
  padding: 0 1.1rem;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.linkish {
  background: none;
  color: var(--accent);
  min-height: auto;
  padding: 0;
  font-weight: 500;
}
.linkish.danger { color: var(--danger); }

input[type=search], input[type=text], input[type=password], input:not([type]),
textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--fg);
}

textarea { min-height: 5rem; }

/* Search */
.searchbar {
  display: flex;
  gap: 0.5rem;
  margin: 1rem 0;
}
.searchbar input { flex: 1; font-size: 1.05rem; }

.count { color: var(--muted); font-size: 0.9rem; margin: 0.5rem 0; }

.results { list-style: none; margin: 0; padding: 0; }
.results li { margin-bottom: 0.6rem; }

.card {
  display: flex;
  gap: 0.85rem;
  align-items: center;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  text-decoration: none;
  color: inherit;
}
.card.discontinued { opacity: 0.6; }

.thumb { flex: 0 0 72px; height: 72px; }
.thumb img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--bg);
}
.noimage {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border-radius: 6px;
  border: 1px dashed var(--line);
  color: var(--muted);
}

.card .body { display: flex; flex-direction: column; min-width: 0; }
.pn { font-weight: 700; font-variant-numeric: tabular-nums; }
.desc { overflow-wrap: anywhere; }
.meta { color: var(--muted); font-size: 0.85rem; }

/* Part detail */
.back { margin: 0 0 0.5rem; }

.pn-block {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
}
.pn-block .label {
  flex-basis: 100%;
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.pn-big {
  font-size: 1.6rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.copy.small { min-height: 36px; padding: 0 0.7rem; font-size: 0.85rem; }

.desc-full { font-size: 1.1rem; }
.warn { color: var(--warn); font-weight: 600; }

.facts { display: grid; grid-template-columns: auto 1fr; gap: 0.35rem 1rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}
.gallery img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
}
.gallery figure { margin: 0; display: flex; flex-direction: column; gap: 0.3rem; }

/* Forms and admin */
.stack { display: flex; flex-direction: column; gap: 0.4rem; }
.stack label { font-weight: 600; margin-top: 0.6rem; }
.stack button { margin-top: 1rem; align-self: flex-start; }
.checkbox { display: flex; align-items: center; gap: 0.5rem; font-weight: 500; }
.checkbox input { width: auto; min-height: auto; }

.login { display: flex; flex-direction: column; gap: 0.6rem; max-width: 320px; margin: 3rem auto; }

.hint { color: var(--muted); font-size: 0.9rem; }
.empty { color: var(--muted); }
.actions { margin: 1rem 0; }

.flashes {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: var(--card);
}

.stats { list-style: none; display: flex; gap: 1.5rem; padding: 0; flex-wrap: wrap; }

table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 0.5rem 0.4rem; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; }

input[type=file] {
  width: 100%;
  padding: 0.6rem 0;
}

/* Camera / library upload controls. The real <input> is hidden and driven by
   its label, so it can look like a proper tap target on a phone. */
.uploaders { display: flex; gap: 0.6rem; flex-wrap: wrap; margin: 0.5rem 0; }
.uploaders form { margin: 0; }

label.button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: var(--tap);
  padding: 0 1.1rem;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}
label.button.secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}
label.button.camera::before { content: "\1F4F7"; font-size: 1.1rem; }
label.button.busy { opacity: 0.6; pointer-events: none; }

/* Which role you are signed in as decides what is on the page, so it is worth
   showing rather than leaving people to infer it. */
.rolechip {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
}

.note {
  margin: 1rem 0;
  padding: 0.75rem 1rem;
  border: 1px solid var(--line);
  border-left: 4px solid var(--muted);
  border-radius: 8px;
  background: var(--card);
}
.note h2 {
  margin: 0 0 0.35rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.note p { margin: 0; white-space: pre-wrap; }
.note.coordinator { border-left-color: var(--warn); }
