:root {
  --bg: #141210;
  --panel: #1e1b18;
  --panel-2: #262220;
  --line: #38322d;
  --ink: #f2ede7;
  --muted: #a49a90;
  --accent: #e0a34a;
  --good: #7fb069;
  --warn: #d98c5f;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  padding-bottom: 3rem;
}

header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1rem 0.5rem;
}

h1 { font-size: 1.1rem; margin: 0; letter-spacing: 0.02em; }

.health { font-size: 0.75rem; color: var(--muted); text-align: right; }
.health .bad { color: var(--warn); }

.tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0 1rem;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 5;
}

.tabs button {
  flex: 1;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  padding: 0.7rem 0.3rem;
  font: inherit;
  cursor: pointer;
}

.tabs button.active { color: var(--ink); border-bottom-color: var(--accent); }

.pill {
  background: var(--accent);
  color: #1b1508;
  border-radius: 999px;
  padding: 0 0.4rem;
  font-size: 0.72rem;
  font-weight: 600;
}
.pill:empty, .pill.zero { display: none; }

main { padding: 1rem; max-width: 720px; margin: 0 auto; }
.tab { display: none; }
.tab.active { display: block; }

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

.shoot {
  display: block;
  text-align: center;
  padding: 1.6rem;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
}

.tray { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 0.8rem 0; }
.tray img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }

button, .btn {
  font: inherit;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink);
  padding: 0.55rem 0.9rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

button:disabled { opacity: 0.4; cursor: default; }

.primary {
  width: 100%;
  background: var(--accent);
  border-color: var(--accent);
  color: #1b1508;
  font-weight: 600;
  margin-top: 0.5rem;
}

.primary.ghost { background: none; color: var(--accent); }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem;
  margin-bottom: 0.9rem;
}

.card h3 { margin: 0 0 0.2rem; font-size: 1rem; }
.card .meta { color: var(--muted); font-size: 0.82rem; }

.shots { display: flex; gap: 0.4rem; margin-bottom: 0.6rem; }
.shots img { width: 84px; height: 84px; object-fit: cover; border-radius: 8px; }

.ocr {
  font-size: 0.8rem;
  color: var(--muted);
  background: var(--panel-2);
  border-radius: 8px;
  padding: 0.5rem 0.6rem;
  margin: 0.6rem 0;
  word-break: break-word;
}
.ocr b { color: var(--ink); font-weight: 600; }

.cand {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  padding: 0.5rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 0.4rem;
  cursor: pointer;
}
.cand.sel { border-color: var(--accent); background: var(--panel-2); }
.cand img { width: 48px; height: 48px; object-fit: cover; border-radius: 5px; background: var(--panel-2); }
.cand .score { margin-left: auto; color: var(--muted); font-size: 0.75rem; white-space: nowrap; }

.row {
  display: flex;
  gap: 0.7rem;
  align-items: center;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--line);
}
.row img { width: 46px; height: 46px; object-fit: cover; border-radius: 5px; background: var(--panel-2); flex: none; }
.row .grow { flex: 1; min-width: 0; }
.row .grow > div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .right { flex: none; width: 104px; text-align: right; }
.row .val { font-variant-numeric: tabular-nums; font-weight: 600; }
.row .right small { display: block; color: var(--muted); font-size: 0.66rem; line-height: 1.3; }
.row .right select { width: 100%; margin-top: 0.25rem; font-size: 0.78rem; padding: 0.2rem; text-align: right; }

select, input[type="search"], textarea {
  font: inherit;
  background: var(--panel-2);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.45rem 0.5rem;
}

.toolbar { display: flex; gap: 0.5rem; margin-bottom: 0.8rem; }
.toolbar input { flex: 1; min-width: 0; }

.summary {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.summary div {
  flex: 1;
  min-width: 100px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.7rem;
}
.summary b { display: block; font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.summary span { color: var(--muted); font-size: 0.75rem; }

.actions { display: flex; gap: 0.5rem; margin-top: 0.6rem; flex-wrap: wrap; }
.actions button { flex: 1; }

.status-failed { color: var(--warn); }
.status-identified { color: var(--good); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.2rem;
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  z-index: 20;
}

.spin { display: inline-block; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Livewire additions ---------------------------------------------- */
[wire\:loading] { display: none; }
.cand input[type="radio"] { margin-top: 0.35rem; accent-color: var(--accent); }
.cand label { display: flex; gap: 0.6rem; align-items: flex-start; width: 100%; cursor: pointer; }
.busy { opacity: 0.5; pointer-events: none; }
.err { color: var(--warn); font-size: 0.8rem; margin: 0.4rem 0; }
input[type="file"] { color: var(--muted); font-size: 0.8rem; }

[x-cloak] { display: none !important; }

/* --- merged scan + review feed ------------------------------------- */
.card.latest { border-color: var(--accent); }
.card .right small { display: block; color: var(--muted); font-size: 0.66rem; line-height: 1.3; }
details.picker { margin: 0.5rem 0; }
details.picker > summary { cursor: pointer; padding: 0.35rem 0; color: var(--muted); }
details.picker > summary:hover { color: var(--ink); }
details.picker button { margin-top: 0.4rem; }

/* --- staged photo thumbnails (label + run-out) -------------------- */
.tray .thumb { position: relative; display: inline-flex; flex-direction: column; align-items: center; gap: 2px; }
.tray .thumb img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.tray .thumb button {
  position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; padding: 0;
  border-radius: 999px; border: 1px solid var(--line); background: var(--panel-2);
  color: var(--ink); font-size: 13px; line-height: 1; cursor: pointer;
}
.tray .thumb em { font-style: normal; font-size: 0.66rem; color: var(--muted); }
.shoot input:disabled { cursor: not-allowed; }

/* --- auth (login / register) ------------------------------------- */
main.auth { max-width: 380px; }
main.auth > h1 { font-size: 1.1rem; letter-spacing: 0.02em; margin: 0 0 1rem; }
.field { display: block; margin-bottom: 0.7rem; }
.field > span { display: block; color: var(--muted); font-size: 0.8rem; margin-bottom: 0.25rem; }
input[type="text"], input[type="email"], input[type="password"] {
  font: inherit; width: 100%;
  background: var(--panel-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; padding: 0.5rem 0.6rem;
}
.checkline { display: flex; align-items: center; gap: 0.4rem; color: var(--muted); font-size: 0.85rem; margin: 0.4rem 0 0.2rem; }
.checkline input { accent-color: var(--accent); }
.auth-alt { text-align: center; margin-top: 1rem; }
.auth-alt a { color: var(--accent); }

/* sign-out control in the header */
.signout { background: none; border: 0; padding: 0; margin-left: 0.6rem; font: inherit; font-size: 0.75rem; color: var(--muted); cursor: pointer; text-decoration: underline; }
.signout:hover { color: var(--ink); }
.signout-form { display: inline; }
