* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: #0f172a;
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
}
a { color: inherit; }

.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 12px 16px; background: #1e293b;
}
.bar.bottom { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
.brand { font-weight: 700; letter-spacing: .02em; }
.pill { font-size: 12px; padding: 3px 10px; border-radius: 999px; background: #334155; }
.pill.online { background: #166534; }
.pill.offline { background: #9a3412; }

.btn {
  display: inline-block; border: 0; border-radius: 10px; padding: 14px 20px;
  font: inherit; font-weight: 600; background: #2563eb; color: #fff; text-decoration: none; cursor: pointer;
}
.btn.small { padding: 8px 12px; font-size: 14px; }
.btn.danger { background: #b91c1c; margin-top: 24px; }
[hidden] { display: none !important; }

.scanner { position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; padding: 16px; gap: 12px; }
#reader { width: 100%; max-width: 480px; border-radius: 12px; overflow: hidden; background: #000; min-height: 240px; }
#reader video { width: 100% !important; display: block; }
.status { text-align: center; color: #94a3b8; margin: 0; min-height: 1.4em; }
.status.warn { color: #fbbf24; }
.status.error { color: #f87171; }

.tick {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; background: rgba(5, 46, 22, .92); padding: 24px; z-index: 10;
}
.tick svg { width: 140px; height: 140px; }
.tick circle { fill: #16a34a; }
.tick path { fill: none; stroke: #fff; stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.tick.notsaved { background: rgba(30, 41, 59, .95); }
.tick.notsaved circle { fill: #64748b; }
.notsaved-detail { font-size: 16px; color: #cbd5e1; text-align: center; }
.tick-value { font-size: 20px; font-weight: 600; text-align: center; word-break: break-all; max-width: 100%; }

.list { flex: 1; padding: 16px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid #334155; vertical-align: top; }
th { color: #94a3b8; font-weight: 600; }
td.value { word-break: break-all; font-weight: 600; }
td small { color: #64748b; display: block; font-size: 11px; font-weight: 400; word-break: break-all; }

.who { display: flex; flex-direction: column; min-width: 0; }
.who small { color: #94a3b8; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-right { display: flex; align-items: center; gap: 8px; }
.btn.ghost { background: transparent; border: 1px solid #475569; }
.banner { display: block; padding: 12px 16px; background: #b45309; color: #fff; font-weight: 600; text-decoration: none; text-align: center; }

.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 700; background: #334155; }
.tag.in { background: #166534; }
.tag.out { background: #1d4ed8; }
.tag.bad { background: #991b1b; }
.tag.muted { background: #334155; color: #94a3b8; }

.login { flex: 1; width: 100%; max-width: 420px; margin: 0 auto; padding: 24px 16px; display: flex; flex-direction: column; gap: 16px; }
.login h1 { margin: 0; font-size: 22px; }
.login form { display: flex; flex-direction: column; gap: 14px; }
.login label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: #cbd5e1; }
.login input {
  font: inherit; font-size: 16px; padding: 12px; border-radius: 10px;
  border: 1px solid #475569; background: #0b1222; color: #e2e8f0;
}
.login .btn:disabled { opacity: .6; }
.login .status { text-align: left; }

.confirm {
  position: absolute; inset: 0; z-index: 11; display: flex; flex-direction: column; justify-content: center;
  gap: 16px; padding: 24px; background: rgba(69, 26, 3, .95); text-align: center;
}
.confirm p { font-size: 20px; font-weight: 600; margin: 0 0 8px; line-height: 1.35; }
.confirm .btn { padding: 18px 20px; font-size: 18px; }
.confirm .btn.ghost { border-color: #fbbf24; }

.tick-dir { font-size: 28px; font-weight: 800; letter-spacing: .08em; padding: 2px 18px; border-radius: 10px; background: #fff; color: #14532d; }
.tick-dir.out { color: #1e3a8a; }
.tick.reject { background: rgba(127, 29, 29, .95); }
.tick.reject circle { fill: #dc2626; }
.reason-other { display: flex; gap: 8px; }
.reason-other input {
  flex: 1; min-width: 0; font: inherit; font-size: 16px; padding: 12px; border-radius: 10px; border: 1px solid #fbbf24; background: #1c1917; color: #fff;
}
.confirm .btn + .btn { margin-top: 0; }

.banner.warn { background: #92400e; font-weight: 500; text-align: left; }
.lastsync { display: block; color: #94a3b8; font-size: 12px; }
.confirm.manual { justify-content: flex-start; overflow-y: auto; }
.confirm.manual input {
  font: inherit; font-size: 17px; padding: 12px; border-radius: 10px; border: 1px solid #fbbf24; background: #1c1917; color: #fff;
}
.manual-results { display: flex; flex-direction: column; gap: 6px; }
.manual-results button { text-align: left; background: #1e293b; border: 1px solid #334155; }
.manual-results small { display: block; color: #94a3b8; font-weight: 400; }
.manual-pick p { font-size: 20px; margin: 4px 0 10px; }
.manual-dirs { display: flex; gap: 10px; }
.manual-dirs .btn { flex: 1; font-size: 18px; padding: 16px; }
.manual-dirs .btn.expected { outline: 3px solid #fbbf24; }
.reason-list { display: flex; flex-direction: column; gap: 16px; }
