/* ============================================================
   Wallet scanner — field tool styling.
   Scanner: dark, high-contrast for outdoor use, big tap targets.
   Sheet/gate: light, dense, readable for managers.
   Type: system stack (instant, no webfont load on mobile data);
   wallet digits in monospace so they're easy to verify.
============================================================ */

:root {
  --ink: #0f1117;
  --ink-2: #1a1d27;
  --ink-3: #252936;
  --line: #333949;
  --text: #f4f5f7;
  --muted: #9aa0ae;
  --magenta: #e6197d;     /* primary action — ties to the bKash cards */
  --magenta-press: #c01368;
  --green: #1fab66;
  --amber: #e0a008;
  --red: #e0473a;
  --radius: 14px;
  --tap: 56px;            /* minimum touch target */
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; }
.mono { font-family: ui-monospace, "SF Mono", "Roboto Mono", Menlo, Consolas, monospace; }
.muted { color: var(--muted); }
.err { color: var(--red); }

button, .btn {
  font: inherit; font-weight: 600; cursor: pointer;
  border: none; border-radius: var(--radius);
  min-height: var(--tap); padding: 0 20px;
  background: var(--magenta); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  text-decoration: none; gap: 8px;
}
button:active, .btn:active { background: var(--magenta-press); }
button:disabled { opacity: .5; }
.btn.ghost { background: transparent; border: 1.5px solid var(--line); color: var(--text); }
.btn.block, button.block { width: 100%; }
:focus-visible { outline: 3px solid var(--magenta); outline-offset: 2px; }

/* ---------------- Scanner (dark) ---------------- */
.scan-body { background: var(--ink); color: var(--text); min-height: 100vh; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 16px; background: var(--ink-2);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5;
}
.topbar .dh { font-weight: 700; }
.topbar .meta { font-size: 13px; color: var(--muted); display: flex; gap: 14px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--green); margin-right: 5px; vertical-align: middle; }
.dot.off { background: var(--red); }

.screen { max-width: 560px; margin: 0 auto; padding: 18px 16px 40px; }
.screen.hidden { display: none; }
h1 { font-size: 22px; margin: 6px 0 2px; }

/* Setup form */
.field { margin: 16px 0; }
.field label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 6px; }
select, input[type="text"], input[type="tel"], input[type="password"] {
  width: 100%; min-height: var(--tap); font: inherit;
  background: var(--ink-3); color: var(--text);
  border: 1.5px solid var(--line); border-radius: var(--radius); padding: 0 14px;
}

/* Camera */
.camera-wrap { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 3/4; }
.camera-wrap video { width: 100%; height: 100%; object-fit: cover; display: block; }
.guide {
  position: absolute; inset: 12% 14% 26%; border: 3px solid rgba(255,255,255,.85);
  border-radius: 12px; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35);
  pointer-events: none;
}
.guide::after {
  content: "Number"; position: absolute; left: 0; right: 0; bottom: -34px;
  height: 30px; border: 2px dashed var(--magenta); border-radius: 8px;
  color: var(--magenta); font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; letter-spacing: .08em;
}
.hint { text-align: center; color: var(--muted); font-size: 14px; margin: 14px 0; }
.controls { display: flex; gap: 12px; margin-top: 16px; }
.controls .capture { flex: 1; }
.controls .icon-btn { width: var(--tap); padding: 0; }

.busy { text-align: center; color: var(--magenta); font-weight: 600; margin-top: 14px; }
.busy.hidden { display: none; }

/* Confirm screen */
.readout { background: var(--ink-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin: 14px 0; }
.readout .wallet-big {
  font-size: 30px; letter-spacing: .14em; font-weight: 700; text-align: center;
  background: var(--ink-3); border: 1.5px solid var(--line); border-radius: 12px;
  padding: 14px; width: 100%; color: var(--text);
}
.readout .wallet-big.bad { border-color: var(--red); }
.row { display: flex; gap: 12px; margin-top: 14px; }
.row > * { flex: 1; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--ink-2); border: 1px solid var(--line); border-left: 5px solid var(--green);
  color: var(--text); padding: 14px 18px; border-radius: 12px; max-width: 90vw;
  box-shadow: 0 10px 30px rgba(0,0,0,.5); z-index: 30;
}
.toast.bad { border-left-color: var(--amber); }
.toast.hidden { display: none; }
.toast b { display: block; }

/* ---------------- Gate + Sheet (light) ---------------- */
.gate-body, .sheet-body {
  background: #f4f5f7; color: #16181d;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
}
.gate { max-width: 360px; margin: 16vh auto; background: #fff; padding: 28px; border-radius: 16px; box-shadow: 0 8px 30px rgba(0,0,0,.08); }
.gate h1 { margin-top: 0; }
.gate input { background: #fff; color: #16181d; border: 1.5px solid #d4d7de; margin-bottom: 12px; }
.gate button { width: 100%; }

.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 18px 20px; background: #fff; border-bottom: 1px solid #e3e5ea; flex-wrap: wrap; }
.sheet-head h1 { margin: 0; font-size: 20px; }
.sheet-actions { display: flex; gap: 10px; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; padding: 14px 20px; background: #fff; border-bottom: 1px solid #e3e5ea; }
.filters select, .filters input { background: #fff; color: #16181d; border: 1.5px solid #d4d7de; min-height: 44px; width: auto; flex: 1 1 140px; }
.filters button { min-height: 44px; }

.table-wrap { overflow-x: auto; padding: 0 20px 20px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; margin-top: 12px; background: #fff; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid #eceef2; white-space: nowrap; }
th { position: sticky; top: 0; background: #fafbfc; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: #6b7280; }
tr.row-unmatched td { background: #fff7ed; }
td.empty { text-align: center; color: #9aa0ae; padding: 40px; white-space: normal; }
.pager { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 20px 30px; }
.pager a { padding: 8px 12px; border: 1px solid #d4d7de; border-radius: 8px; text-decoration: none; color: #16181d; }
.pager a.on { background: var(--magenta); color: #fff; border-color: var(--magenta); }
.sheet-head .btn { min-height: 44px; }

/* ---- Scanner status + diagnostic preview ---- */
.scan-status { text-align: center; font-size: 14px; font-weight: 600; margin: 10px 0 0; color: var(--muted); }
.scan-status.ok  { color: var(--green); }
.scan-status.bad { color: var(--amber); }
.crop-preview {
  display: block; width: 100%; margin: 14px 0 6px; border-radius: 10px;
  border: 1px solid var(--line); background: #fff; image-rendering: pixelated;
}
.ocr-raw { font-size: 12px; word-break: break-all; margin: 4px 0 0; }
