:root {
  --bg: #141210;
  --bg-2: #1c1916;
  --ink: #f4efe6;
  --muted: #9a9084;
  --line: #2c2722;
  --accent: #f5c518;
  --accent-ink: #1a1508;
  --ok: #7dce9a;
  --bad: #e07a6a;
  --warn: #e0b35c;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "IBM Plex Sans", sans-serif;
}

button,
input {
  font: inherit;
}

.hidden {
  display: none !important;
}

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 400px at 20% -10%, #3a2a08 0%, transparent 55%),
    var(--bg);
}

.login-card,
.card,
dialog {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
}

.login-card {
  width: min(420px, 100%);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 600;
}

h1,
h2,
h3 {
  margin: 0 0 8px;
  font-weight: 600;
}

.muted {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  margin: 14px 0;
}

input {
  background: #12100e;
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 10px;
  padding: 10px 12px;
}

button {
  background: var(--accent);
  color: var(--accent-ink);
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 600;
  cursor: pointer;
}

button.ghost,
.file-btn.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

button.danger {
  background: #5c221c;
  color: #f6d7d2;
}

button.danger:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.error {
  color: var(--bad);
  min-height: 1.2em;
}

.shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.rail {
  border-right: 1px solid var(--line);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.brand {
  display: flex;
  gap: 10px;
  align-items: center;
}

.bib {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  display: grid;
  place-items: center;
  font-family: "IBM Plex Mono", monospace;
  font-weight: 500;
}

.brand small {
  display: block;
  color: var(--muted);
}

.event-list {
  display: grid;
  gap: 6px;
  overflow: auto;
  flex: 1;
  align-content: start;
}

.event-list button {
  background: transparent;
  color: var(--ink);
  text-align: left;
  border: 1px solid transparent;
  font-weight: 500;
  height: 40px;
  padding: 0 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-list button.active,
.event-list button:hover {
  border-color: var(--line);
  background: #241f1a;
}

.rail-foot {
  margin-top: auto;
}

.main {
  padding: 22px 28px 48px;
}

.top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 22px;
}

.pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-family: "IBM Plex Mono", monospace;
}

.pill.ready,
.pill.inferred {
  color: var(--ok);
}
.pill.failed {
  color: var(--bad);
}
.pill.processing,
.pill.uploading,
.pill.queued,
.pill.training {
  color: var(--warn);
}

.pill.detector-ready {
  color: var(--ok);
}

.detector-box {
  margin: 12px 0;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #12100e;
}

.detector-box strong {
  display: block;
  font-size: 14px;
}

.detector-box p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.detector-box.busy {
  border-color: var(--warn);
}

.detector-box.ok {
  border-color: var(--ok);
}

.detector-box.error {
  border-color: var(--bad);
}

.grid.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

.stat b {
  display: block;
  font-size: 22px;
  margin-top: 4px;
}

.panels {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 14px;
  margin-bottom: 14px;
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.file-btn {
  display: inline-flex;
  align-items: center;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 600;
  cursor: pointer;
}

.progress {
  height: 8px;
  background: #12100e;
  border-radius: 99px;
  overflow: hidden;
  margin: 12px 0;
}

#upload-bar {
  height: 100%;
  width: 0;
  background: var(--accent);
}

.log,
.batch-box,
.table {
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  white-space: pre-wrap;
}

.stack label {
  margin: 8px 0;
}

.thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.thumbs figure {
  margin: 0;
  background: #12100e;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.thumbs img {
  width: 100%;
  height: 90px;
  object-fit: cover;
  display: block;
}

.thumbs figcaption {
  padding: 6px 8px;
  font-size: 11px;
  color: var(--muted);
}

.bib-grade {
  margin: 16px 0 0;
  font-size: 13px;
  font-weight: 600;
}

.bib-grade:first-child {
  margin-top: 12px;
}

.gallery-card {
  margin-bottom: 14px;
}

.gallery-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.gallery-search {
  margin: 0;
  flex: 1 1 220px;
  justify-content: flex-end;
}

.gallery-search input {
  max-width: 160px;
}

.gallery-head h3 {
  margin-bottom: 4px;
}

.pills button {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  height: auto;
}

.pills button.active {
  border-color: var(--accent);
  color: var(--accent);
}

.gallery-select {
  margin: 0 0 4px;
  align-items: center;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.photo-card {
  margin: 0;
  background: #12100e;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  cursor: pointer;
  padding: 0;
  position: relative;
}

.photo-card.selected {
  border-color: var(--accent);
}

.photo-card:hover,
.photo-card:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.photo-check {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 1;
  margin: 0;
  padding: 4px;
  background: rgba(20, 18, 16, 0.72);
  border-radius: 6px;
  cursor: pointer;
}

.photo-check input {
  margin: 0;
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.photo-card img,
.photo-ph {
  width: 100%;
  height: 140px;
  object-fit: cover;
  display: block;
  background: #0c0b0a;
}

.photo-ph {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
}

.photo-card .meta {
  padding: 8px;
  display: grid;
  gap: 6px;
}

.photo-card .name {
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo-card .bibs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 18px;
}

.photo-card .bib-tag {
  font-size: 10px;
  font-family: "IBM Plex Mono", monospace;
  background: #241f1a;
  border-radius: 999px;
  padding: 2px 6px;
}

.gallery-pager {
  margin-top: 12px;
}

.gallery-pager .ghost {
  padding: 6px 12px;
}

.photo-dialog {
  width: min(920px, 96vw);
  max-height: 92vh;
  overflow: auto;
}

.photo-dialog img {
  width: 100%;
  max-height: 64vh;
  object-fit: contain;
  background: #0c0b0a;
  border-radius: 10px;
  display: block;
}

.plate-stage {
  position: relative;
  user-select: none;
  cursor: crosshair;
}

.plate-rect {
  position: absolute;
  border: 2px solid var(--accent);
  background: rgba(245, 197, 24, 0.2);
  pointer-events: none;
}

.plate-rect.number-rect {
  border-color: #7dce9a;
  background: rgba(125, 206, 154, 0.22);
}

.photo-dialog #photo-dialog-meta {
  margin-top: 12px;
  font-size: 13px;
  line-height: 1.5;
}

.photo-card .bib-tag.confirmed,
.bib-choice.confirmed {
  border-color: var(--accent);
  color: var(--accent-ink);
  background: var(--accent);
}

.teach {
  margin-top: 12px;
}

.teach-choices {
  margin: 8px 0 12px;
  display: grid;
  gap: 10px;
}

.person-slot {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  background: #161310;
}

.person-slot-head {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.bib-choice {
  background: #241f1a;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-family: "IBM Plex Mono", monospace;
  font-weight: 500;
  height: auto;
}

.bib-choice:hover {
  border-color: var(--accent);
}

.photo-dialog menu a {
  color: var(--accent);
  align-self: center;
  margin-right: auto;
}

.table div {
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

dialog {
  border: 1px solid var(--line);
  color: var(--ink);
}

menu {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0;
  margin: 12px 0 0;
}

label.inline {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

label.inline input {
  width: 72px;
}

@media (max-width: 980px) {
  .shell {
    grid-template-columns: 1fr;
  }
  .grid.stats,
  .panels {
    grid-template-columns: 1fr;
  }
  .rail {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}
