:root {
  --ink: #16231f;
  --muted: #52615c;
  --paper: #f6f5ef;
  --green: #007a50;
  --green-dark: #005e3d;
  --line: #d7ddd7;
  --red: #aa2e22;
  --amber: #a76600;
  --blue: #4578a1;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.55 Inter, ui-sans-serif, system-ui, sans-serif;
}

main {
  max-width: 860px;
  margin: auto;
  padding: 48px 20px 80px;
}

header { margin-bottom: 28px; }

.eyebrow {
  color: var(--green);
  font-weight: 800;
  letter-spacing: .09em;
  font-size: .78rem;
}

h1 {
  font-size: clamp(2.4rem, 7vw, 4.5rem);
  line-height: .95;
  margin: .15em 0;
}

.lede {
  font-size: 1.2rem;
  max-width: 50ch;
  color: var(--muted);
}

h2 {
  font-size: 1.16rem;
  margin: 0 0 16px;
}

.panel,
.notice {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  margin: 16px 0;
}

.notice { border-left: 5px solid var(--green); }
.small { font-size: .83rem; margin-top: 20px; }
.hint { color: var(--muted); font-size: .92rem; }

label {
  display: block;
  font-weight: 650;
  margin: 10px 0;
}

label span {
  color: var(--muted);
  font-size: .82rem;
  font-weight: 500;
}

select,
input[type=file] {
  width: 100%;
  font: inherit;
  padding: 12px;
  border: 1px solid #aeb9b2;
  border-radius: 8px;
  background: white;
}

.consent-panel label { margin-top: 0; }

.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 16px 0;
}

button,
.tab {
  border: 0;
  border-radius: 8px;
  background: var(--green);
  color: #fff;
  font: 800 1.05rem/1.2 inherit;
  padding: 16px;
  cursor: pointer;
}

button:hover { background: var(--green-dark); }
button:disabled { cursor: not-allowed; opacity: .65; }

.tab {
  background: #fff;
  color: var(--green);
  border: 1px solid var(--line);
}

.tab.active {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

.upload {
  border: 2px dashed #8ca198;
  padding: 22px;
  text-align: center;
  border-radius: 8px;
  color: var(--green);
}

.upload input {
  opacity: 0;
  height: 1px;
  padding: 0;
  border: 0;
}

.checks { display: grid; gap: 6px; }
.checks label { font-weight: 500; }

.actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.secondary {
  background: #e8eee9;
  color: var(--ink);
  border: 1px solid var(--line);
}

.secondary:hover { background: #dce5df; }

.results {
  border-top: 6px solid var(--green);
  margin-top: 32px;
}

.result-list { display: grid; gap: 10px; }

.annotated-upload { margin: 0 0 20px; }

.annotation-frame {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101816;
}

.annotation-frame img,
.annotation-frame canvas {
  display: block;
  width: 100%;
  height: auto;
}

.annotation-frame canvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.annotated-upload figcaption {
  margin-top: 8px;
  color: var(--muted);
  font-size: .86rem;
}

.result {
  border-left: 5px solid #789087;
  padding: 12px 14px;
  background: #f7faf7;
  display: flex;
  gap: 12px;
}

.result strong { display: block; }
.result span { font-size: .85rem; color: var(--muted); }
.result p { margin: .3em 0 0; }
.result.detected { border-color: var(--green); }
.result.manual_confirmed { border-color: var(--blue); }
.result.uncertain,
.result.manual_check_required { border-color: var(--amber); }
.result.missing { border-color: var(--red); background: #fff5f3; }

.status-icon {
  display: grid;
  place-items: center;
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #e8eee9;
  color: var(--ink);
  font-weight: 800;
}

.result.detected .status-icon,
.result.manual_confirmed .status-icon { background: #daf1e6; color: var(--green-dark); }
.result.missing .status-icon { background: #f9deda; color: var(--red); }
.result.uncertain .status-icon,
.result.manual_check_required .status-icon { background: #fff0d6; color: var(--amber); }

.completion {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: 8px;
}

.completion span { font-size: 1.35rem; font-weight: 900; }
.completion strong { margin-right: 5px; }
.completion.success { background: #daf1e6; color: var(--green-dark); }
.completion.action { background: #fff0d6; color: #764300; }

.warning {
  padding: 12px 14px;
  border-radius: 8px;
  background: #fff3da;
  color: #764300;
}

.camera-wrap {
  position: relative;
  overflow: hidden;
  background: #101816;
  border-radius: 8px;
  aspect-ratio: 4 / 3;
}

.camera-wrap video,
.camera-wrap canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.camera-wrap canvas { pointer-events: none; }

.live-panel .actions { margin-top: 12px; }

[hidden] { display: none !important; }

@media (max-width: 520px) {
  main { padding-top: 28px; }
  .panel,
  .notice { padding: 17px; }
  .actions { grid-template-columns: 1fr; }
  .mode-tabs { grid-template-columns: 1fr; }
}
