:root {
  --bg: #101418;
  --panel: #191f26;
  --line: #2a333d;
  --text: #eef2f6;
  --muted: #93a1b0;
  --accent: #29449d;        /* B Naturals brand blue */
  --accent-bright: #4a6ad4; /* lifted for text/edges on the dark ground */
  --ok: #12a150;
  --warn: #d98200;
  --bad: #d13438;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

.view { display: none; height: 100%; }
.view.active { display: block; }

/* ---------- bars ---------- */
.bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(10px + var(--safe-top)) 14px 10px;
  border-bottom: 1px solid var(--line);
}
.bar h1 { font-size: 18px; margin: 0; flex: 1; letter-spacing: .01em; }
.bar.brand { background: var(--accent); border-bottom-color: #ffffff1f; }
.logo { border-radius: 8px; display: block; }
.bar.overlay {
  position: fixed;
  top: 0; left: 0; right: 0;
  border: 0;
  background: linear-gradient(#000a, #0000);
  z-index: 3;
}
.bar.overlay.bottom {
  top: auto;
  bottom: 0;
  padding: 10px 14px calc(10px + var(--safe-bottom));
  background: linear-gradient(#0000, #000a);
  justify-content: space-between;
}

.pill {
  flex: 1;
  text-align: center;
  font-weight: 600;
  font-size: 15px;
  text-shadow: 0 1px 3px #000;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  min-width: 24px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
  font-size: 12px;
  text-align: center;
}
.badge.offline { background: var(--warn); border-color: var(--warn); color: #000; }
.badge.online { background: #1c3a24; border-color: #245e33; color: #7ee2a2; }
.hidden { display: none !important; }

/* ---------- home ---------- */
.pane { padding: 16px 14px 40px; max-width: 620px; margin: 0 auto; }
h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 18px 0 10px; }

.cards { display: grid; gap: 8px; }
.card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  text-align: left;
  font: inherit;
  cursor: pointer;
}
.card:active { background: #202834; }
.card .name { flex: 1; font-weight: 600; }
.card .meta { color: var(--muted); font-size: 13px; }

details {
  margin-top: 22px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  padding: 12px 14px;
}
summary { cursor: pointer; font-weight: 600; color: #a9baf2; }
label { display: block; margin: 14px 0 0; font-size: 13px; color: var(--muted); }
input[type=text], textarea {
  width: 100%;
  margin-top: 6px;
  padding: 11px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #0d1116;
  color: var(--text);
  font: inherit;
}
textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; resize: vertical; }
input[type=file] { margin-top: 12px; font-size: 13px; color: var(--muted); }

button { font: inherit; cursor: pointer; }
.primary {
  margin-top: 14px;
  width: 100%;
  padding: 13px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}
.primary:disabled { opacity: .55; }
.ghost {
  background: #0006;
  border: 1px solid #ffffff26;
  color: var(--text);
  border-radius: 8px;
  padding: 7px 11px;
  font-size: 14px;
  backdrop-filter: blur(6px);
}
.muted { color: var(--muted); }
.small { font-size: 12px; }
.msg { min-height: 20px; font-size: 13px; margin: 10px 0 0; }
.msg.err { color: #ff8b8f; }
.msg.ok { color: #7ee2a2; }

/* ---------- scanner ---------- */
#view-scan { position: relative; overflow: hidden; background: #000; }
#video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
#reticle {
  position: absolute;
  top: 50%; left: 50%;
  width: min(68vw, 300px);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border: 2px solid #ffffff5c;
  border-radius: 22px;
  box-shadow: 0 0 0 100vmax #00000059;
  z-index: 1;
}

/* The verdict layer is what must feel instant: it paints on the same frame
   the code is decoded, before any network call. */
.verdict {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .08s linear;
  text-align: center;
  padding: 20px;
}
.verdict.show { opacity: 1; }
.verdict.approved { background: #12a150ee; }
.verdict.expired  { background: #d98200ee; color: #1a1200; }
.verdict.invalid  { background: #d13438ee; }
#verdict-word {
  font-size: clamp(38px, 13vw, 76px);
  font-weight: 800;
  letter-spacing: .02em;
  line-height: 1;
}
.verdict .code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 15px;
  opacity: .9;
  word-break: break-all;
  max-width: 90%;
}
.verdict .sub { font-size: 14px; opacity: .85; }
