/* Bolonö Quartier — the design canvas's look: IBM Plex, a cool off-white ground, Guinean green, amber only
   for "never printed". Phone-first; on a wide screen the app sits in a 480px column. */

:root {
  --ground: #F4F6F5;
  --surface: #FFFFFF;
  --ink: #14201A;
  --muted: #4A5852;
  --line: #D5DDD8;
  --line-soft: #E8EDEA;
  --input: #9AA9A1;
  --green: #0B5D3B;
  --green-deep: #08442B;
  --green-tint: #E3EFE8;
  --green-on-dark: #DCEBE2;
  --blue-ink: #1F3F6B;
  --blue-tint: #E4ECF7;
  --amber-ink: #6B4A00;
  --amber-tint: #FFF3D1;
  --amber: #8A5A00;
  --red: #A32638;
  --red-ink: #8A1F11;
  --dark: #0E1512;
  --dark-panel: #14201A;
  --mint: #6FD3A0;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--ground); color: var(--ink); font-family: "IBM Plex Sans", system-ui, sans-serif; -webkit-text-size-adjust: 100%; }
a { color: var(--green); }
a:hover { color: var(--green-deep); }
button, input { font: inherit; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.app { max-width: 480px; margin: 0 auto; min-height: 100vh; background: var(--ground); box-shadow: 0 0 0 1px var(--line-soft); }
.screen { min-height: 100vh; display: flex; flex-direction: column; }
.screen.center { align-items: center; justify-content: center; }
.content { display: flex; flex-direction: column; gap: 20px; padding: 20px 16px 28px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 10px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }

.h1 { margin: 0; font-size: 22px; font-weight: 700; }
.h1.big { font-size: 28px; line-height: 1.2; letter-spacing: -0.02em; }
.h2 { margin: 0; font-size: 16px; font-weight: 600; }
p { margin: 0; line-height: 1.5; }
.muted { color: var(--muted); }
.small { font-size: 13px; line-height: 1.45; }
.center { text-align: center; }
.mono { font-family: "IBM Plex Mono", ui-monospace, monospace; font-weight: 500; overflow-wrap: anywhere; }
/* Codes break only at their own separators: after a "-" in the agents' form, at a space in the public one. */
.code, [data-testid=issued-structured], [data-testid=issued-numeric], [data-testid=result-code] { overflow-wrap: normal; word-break: normal; }
.big { font-size: 16px; }
.strong { font-weight: 600; }
.grow { flex-grow: 1; }

/* ---- app bar & stepper */
.appbar { display: flex; align-items: center; gap: 8px; padding: 12px 12px 12px 4px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 2; }
.appbar.dark { background: transparent; border: 0; color: #fff; position: static; }
.back { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; color: inherit; flex-shrink: 0; }
.back-spacer { width: 12px; }
.appbar-text { display: flex; flex-direction: column; flex-grow: 1; min-width: 0; }
.appbar-title { font-size: 17px; font-weight: 600; }
.appbar-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip { font-size: 13px; font-weight: 600; color: var(--green); background: var(--green-tint); border-radius: 999px; padding: 4px 10px; flex-shrink: 0; }
.stepper { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; padding: 12px 16px 0; }
.step { display: flex; flex-direction: column; gap: 6px; }
.step-bar { height: 4px; border-radius: 2px; background: #C9D3CD; }
.step-bar.on { background: var(--green); }
.step-label { font-size: 12px; color: var(--muted); }
.step-label.on { font-weight: 600; color: var(--green); }

/* ---- cards & rows */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.card.rows { padding: 2px 14px; }
.card.amber { background: var(--amber-tint); border-color: transparent; color: #3D2A00; }
.row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); font-size: 14px; }
.row:last-child { border-bottom: 0; }
.row .k { color: var(--muted); flex-shrink: 0; }
.row .v { font-weight: 500; text-align: right; overflow-wrap: anywhere; }
.row.stack { flex-direction: column; align-items: stretch; gap: 4px; }
.row.stack .v { text-align: left; line-height: 1.45; }
.card.amber .row .k { color: #3D2A00; }
.row-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; font-size: 14px; }

/* ---- form fields */
.field { display: flex; flex-direction: column; gap: 6px; border: 0; margin: 0; padding: 0; min-width: 0; }
.field label, .field legend { font-size: 13px; font-weight: 600; padding: 0; }
.field legend { margin-bottom: 6px; }
.field input { min-height: 48px; width: 100%; border: 1px solid var(--input); border-radius: 10px; padding: 0 12px; font-size: 16px; background: var(--surface); color: var(--ink); }
.field input:focus { outline: 2px solid var(--green); outline-offset: 1px; border-color: var(--green); }
.field input.invalid { border-color: var(--red); }
.field-error { font-size: 13px; color: var(--red); }
.error-box { background: #FBE9EB; color: var(--red-ink); border-radius: 10px; padding: 12px 14px; font-size: 14px; line-height: 1.45; }
.label-row { display: flex; justify-content: flex-end; margin-bottom: -4px; }
.badge { display: inline-block; font-size: 11px; font-weight: 600; border-radius: 6px; padding: 3px 7px; white-space: nowrap; }
.badge.blue { color: var(--blue-ink); background: var(--blue-tint); }
.badge.amber { color: var(--amber-ink); background: var(--amber-tint); }
.badge.green { color: var(--green); background: var(--green-tint); }
.badge.red { color: #fff; background: var(--red); }
.seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--input); border-radius: 10px; overflow: hidden; background: var(--surface); }
.seg.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.seg button { min-height: 44px; border: 0; border-right: 1px solid var(--input); background: var(--surface); color: var(--ink); font-size: 14px; cursor: pointer; }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--green); color: #fff; font-weight: 600; }
.check { display: flex; gap: 12px; align-items: flex-start; font-size: 14px; line-height: 1.45; }
.check input { width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--green); flex-shrink: 0; }

/* ---- buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; border-radius: 12px; padding: 0 16px; font-size: 16px; font-weight: 600; text-decoration: none; cursor: pointer; border: 1px solid transparent; text-align: center; }
.btn.small { min-height: 44px; font-size: 14px; padding: 0 14px; }
.btn.primary { background: var(--green); color: #fff; }
.btn.primary:hover { background: var(--green-deep); color: #fff; }
.btn.primary:disabled { background: #8FB3A2; cursor: not-allowed; }
.btn.secondary { background: var(--surface); color: var(--green); border-color: var(--green); font-size: 14px; min-height: 48px; }
.btn.secondary:disabled { color: #8FB3A2; border-color: #8FB3A2; }
.btn.ghost { background: transparent; color: #fff; border-color: #4F6359; font-size: 14px; min-height: 48px; }
.btn.link { background: none; border: 0; color: var(--green); min-height: 44px; font-size: 15px; }
.btn.danger { background: var(--red); color: #fff; }
.btn.link.danger { background: none; color: var(--red-ink); font-size: 14px; font-weight: 500; }
.footer-bar { margin-top: auto; padding: 16px; background: var(--surface); border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; position: sticky; bottom: 0; }

/* ---- residence number panel */
.code-panel { display: flex; flex-direction: column; gap: 8px; background: var(--dark-panel); color: #fff; border-radius: 14px; padding: 16px; }
.code-panel.muted-panel { background: var(--line-soft); color: var(--muted); font-size: 14px; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: #B9CBC1; }
.eyebrow.dark { color: var(--muted); }
.eyebrow-sub { font-size: 12px; line-height: 1.5; color: #B9CBC1; }
.divider { height: 1px; background: #3A4A42; }
.code { font-size: 16px; line-height: 1.5; }
.code.big { font-size: 19px; letter-spacing: 0.02em; }

/* ---- map */
.map { position: relative; height: 168px; border-radius: 14px; overflow: hidden; background: #DDE6E0; border: 1px solid #C9D3CD; }
.map.empty { display: flex; align-items: center; justify-content: center; padding: 16px; text-align: center; font-size: 14px; }
.map-tiles { position: absolute; width: 768px; height: 768px; }
.map-tiles img { position: absolute; width: 256px; height: 256px; }
.map-pin { position: absolute; left: 50%; top: 50%; width: 22px; height: 22px; margin: -22px 0 0 -11px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: var(--green); box-shadow: 0 0 0 3px #fff; }
.map-credit { position: absolute; right: 6px; bottom: 4px; font-size: 10px; background: rgba(255,255,255,0.85); padding: 1px 5px; border-radius: 4px; color: var(--ink); }

/* ---- issued */
.hero { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.hero-mark { width: 56px; height: 56px; border-radius: 50%; background: var(--green); display: flex; align-items: center; justify-content: center; }
.hero-mark.red { background: var(--red); }
.qr-card { padding: 20px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.qr { width: 220px; height: 220px; image-rendering: pixelated; }
/* 37 and 34 monospace characters: sized to stay on one line in a 390px-wide phone. */
.qr-card [data-testid=issued-structured], .qr-card [data-testid=issued-numeric] { font-size: 14px; }
.danger-zone { border-top: 1px solid var(--line); padding-top: 12px; }
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; text-decoration: none; color: var(--ink); min-height: 52px; }

/* ---- home */
.home { padding: 32px 20px 24px; gap: 28px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 44px; height: 44px; border-radius: 12px; background: var(--green); display: flex; align-items: center; justify-content: center; }
.brand-name { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.role-card { display: flex; flex-direction: column; gap: 14px; padding: 20px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.role-card.primary { background: var(--green); color: #fff; border-color: var(--green); }
.role-card.primary:hover { color: #fff; background: var(--green-deep); }
.role-icon { width: 48px; height: 48px; border-radius: 12px; background: rgba(255,255,255,0.14); display: flex; align-items: center; justify-content: center; }
.role-icon.light { background: var(--green-tint); }
.role-title { font-size: 20px; font-weight: 600; margin-bottom: 4px; }
.role-text { font-size: 14px; line-height: 1.45; color: var(--green-on-dark); }
.role-text.muted { color: var(--muted); }
.home-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; }

/* ---- scan */
.screen.dark { background: var(--dark); color: #fff; }
.scan-body { flex-grow: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px; padding: 0 24px; }
.viewfinder { position: relative; width: 260px; height: 260px; border-radius: 20px; background: #1C2722; overflow: hidden; display: flex; align-items: flex-end; justify-content: center; }
.viewfinder.as-button { border: 0; color: inherit; cursor: pointer; padding: 0; }
.viewfinder .camera { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.corners { position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(var(--mint), var(--mint)) top left / 44px 4px no-repeat, linear-gradient(var(--mint), var(--mint)) top left / 4px 44px no-repeat,
    linear-gradient(var(--mint), var(--mint)) top right / 44px 4px no-repeat, linear-gradient(var(--mint), var(--mint)) top right / 4px 44px no-repeat,
    linear-gradient(var(--mint), var(--mint)) bottom left / 44px 4px no-repeat, linear-gradient(var(--mint), var(--mint)) bottom left / 4px 44px no-repeat,
    linear-gradient(var(--mint), var(--mint)) bottom right / 44px 4px no-repeat, linear-gradient(var(--mint), var(--mint)) bottom right / 4px 44px no-repeat; }
.viewfinder-text { position: relative; margin: 0 16px 18px; font-size: 13px; color: #B9CBC1; text-align: center; line-height: 1.45; }
.scan-title { font-size: 18px; font-weight: 600; }
.scan-sub { font-size: 14px; line-height: 1.5; color: #B9CBC1; }
.scan-actions { display: flex; flex-direction: column; gap: 12px; padding: 16px 16px 24px; }
.offline-note { display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,0.06); border-radius: 12px; padding: 12px 14px; font-size: 13px; line-height: 1.4; color: var(--green-on-dark); }
.paste { display: flex; gap: 8px; }
.paste input { flex-grow: 1; min-width: 0; min-height: 44px; border-radius: 10px; border: 1px solid #4F6359; background: #1C2722; color: #fff; padding: 0 12px; font-size: 15px; }

/* ---- result banners */
.banner { border-radius: 16px; padding: 18px; display: flex; flex-direction: column; gap: 10px; color: #fff; }
.banner.ok { background: var(--green); }
.banner.warn { background: var(--amber); }
.banner.fail { background: var(--red); }
.banner-head { display: flex; align-items: center; gap: 12px; }
.banner-mark { width: 44px; height: 44px; border-radius: 50%; background: rgba(255,255,255,0.18); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.banner-title { font-size: 20px; font-weight: 700; }
.banner-sub { font-size: 13px; line-height: 1.45; opacity: 0.92; }
.banner-code { opacity: 0.85; }

@media (min-width: 560px) { body { padding: 24px 0; } .app { border-radius: 18px; overflow: hidden; min-height: calc(100vh - 48px); } .screen { min-height: calc(100vh - 48px); } }

.danger-zone > div { display: flex; flex-direction: column; align-items: center; }
