:root {
  --bg: #f4f6fb; --card: #ffffff; --text: #111827; --muted: #6b7280; --line: #e5e7eb;
  --brand: #2347d4; --brand-dark: #1a37a6; --brand-soft: #eaefff;
  --ok: #15803d; --ok-soft: #e7f6ec; --warn: #b45309; --warn-soft: #fff4e0;
  --bad: #b91c1c; --bad-soft: #fdecec; --info-soft: #eef2ff;
  --radius: 12px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 4px 16px rgba(16,24,40,.06);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Devanagari", Arial, sans-serif; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
a { color: var(--brand); }
[hidden] { display: none !important; }
small, .muted { color: var(--muted); }

/* ---------- layout ---------- */
.wrap { max-width: 760px; margin: 0 auto; padding: 20px 16px 60px; }
.wide { max-width: 1280px; }
.hero { padding: 18px 0 8px; }
.hero h1 { font-size: 1.7rem; }
.hero p { margin: 0; color: var(--muted); }

form fieldset { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px 18px; margin: 16px 0; box-shadow: var(--shadow); }
legend { font-weight: 700; padding: 0 8px; font-size: 1.02rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.grid2 .full { grid-column: 1 / -1; }
@media (max-width: 620px) { .grid2 { grid-template-columns: 1fr; } }

label.field { display: block; font-size: .9rem; font-weight: 600; }
label.field > span.req { color: var(--bad); }
input[type=text], input[type=email], input[type=tel], input[type=date], input[type=search], input[type=number], select, textarea {
  width: 100%; margin-top: 4px; padding: 10px 12px; font: inherit; color: inherit; background: #fff;
  border: 1px solid #cfd5e1; border-radius: 8px; min-height: 44px;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--brand); }
input[type=file] { width: 100%; margin-top: 4px; font: inherit; }
.hint { display: block; font-weight: 400; color: var(--muted); font-size: .82rem; margin-top: 3px; }
.hp { position: absolute !important; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* radio cards */
.choice-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; }
.choice { display: flex; gap: 10px; align-items: flex-start; border: 1.5px solid #cfd5e1; border-radius: 10px; padding: 12px; cursor: pointer; background: #fff; }
.choice:hover { border-color: var(--brand); }
.choice input { margin-top: 4px; width: 18px; height: 18px; accent-color: var(--brand); flex: none; }
.choice b { display: block; }
.choice small { display: block; }
.choice:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); box-shadow: 0 0 0 1px var(--brand) inset; }

.check { display: flex; gap: 10px; align-items: flex-start; margin: 10px 0; font-size: .95rem; }
.check input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--brand); flex: none; }

.notice { margin-top: 12px; padding: 12px 14px; border-radius: 10px; background: var(--info-soft); border: 1px solid #c7d2fe; white-space: pre-line; font-size: .95rem; }
.notice.warn { background: var(--warn-soft); border-color: #fcd9a0; }

.preview { margin-top: 8px; display: flex; align-items: center; gap: 12px; }
.preview img { width: 84px; height: 112px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.preview .fname { font-size: .85rem; color: var(--muted); word-break: break-all; }

/* ---------- buttons / messages ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 18px; font: inherit; font-weight: 600; color: var(--text); background: #fff; border: 1px solid #cfd5e1; border-radius: 10px; cursor: pointer; text-decoration: none; }
.btn:hover { background: #f3f4f8; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { background: #fff; border-color: #f0b4b4; color: var(--bad); }
.btn.danger:hover { background: var(--bad-soft); }
.btn.small { min-height: 34px; padding: 0 12px; font-size: .88rem; border-radius: 8px; }
.btn.block { width: 100%; min-height: 50px; font-size: 1.05rem; }
.msg { margin: 12px 0; padding: 12px 14px; border-radius: 10px; font-size: .95rem; }
.msg.error { background: var(--bad-soft); color: var(--bad); border: 1px solid #f3c1c1; }
.msg.ok { background: var(--ok-soft); color: var(--ok); border: 1px solid #b7e3c5; }
.done-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px 22px; text-align: center; box-shadow: var(--shadow); margin-top: 20px; }
.done-card .tick { font-size: 2.6rem; }
.ref { display: inline-block; font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 700; background: var(--brand-soft); padding: 4px 10px; border-radius: 8px; }
.foot { text-align: center; color: var(--muted); font-size: .82rem; margin-top: 30px; }

/* ---------- overlay / sign-in ---------- */
.overlay { position: fixed; inset: 0; background: rgba(15,23,42,.72); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; }
.auth-card { background: #fff; border-radius: 16px; padding: 28px 24px; max-width: 380px; width: 100%; text-align: center; }
.auth-card #gbtn { display: flex; justify-content: center; margin-top: 16px; min-height: 44px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #111827; color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 80; max-width: 90vw; font-size: .92rem; box-shadow: var(--shadow); }
.toast.error { background: var(--bad); }
.toast.ok { background: var(--ok); }

/* ---------- admin ---------- */
.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; justify-content: space-between; padding: 12px 0; }
.topbar h1 { font-size: 1.3rem; margin: 0; }
.topbar .right { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin: 8px 0 14px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 1.5rem; line-height: 1.1; }
.stat span { color: var(--muted); font-size: .82rem; }
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.tab { background: none; border: 0; padding: 10px 16px; font: inherit; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; cursor: pointer; }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.filters select, .filters input { width: auto; margin: 0; min-height: 38px; padding: 6px 10px; }
.filters input[type=search] { min-width: 220px; }
.tablewrap { background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: auto; box-shadow: var(--shadow); }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
th { background: #f8fafc; position: sticky; top: 0; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); z-index: 1; }
tbody tr:hover { background: #f8faff; }
tr.clickable { cursor: pointer; }
td.wrapcell { white-space: normal; min-width: 160px; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 700; background: #eef0f4; color: #374151; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--brand-soft); color: var(--brand); }
.bulkbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; background: var(--brand-soft); border: 1px solid #c7d2fe; padding: 8px 12px; border-radius: 10px; margin-bottom: 10px; }
.bulkbar input[type=date] { width: auto; margin: 0; min-height: 36px; }
.empty { padding: 30px; text-align: center; color: var(--muted); }

.modalback { position: fixed; inset: 0; background: rgba(15,23,42,.55); z-index: 40; overflow: auto; padding: 24px 12px; display: flex; justify-content: center; align-items: flex-start; }
.modal { background: #fff; width: 100%; max-width: 900px; border-radius: 16px; padding: 20px 22px 24px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal .head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.modal .cols { display: grid; grid-template-columns: 220px 1fr; gap: 20px; }
@media (max-width: 720px) { .modal .cols { grid-template-columns: 1fr; } }
.modal .side img { width: 100%; max-width: 220px; border-radius: 10px; border: 1px solid var(--line); display: block; margin-bottom: 10px; }
.modal .side canvas { width: 100%; border: 1px solid var(--line); border-radius: 8px; margin-top: 8px; }
.modal h3 { font-size: 1rem; margin-top: 14px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.kv { font-size: .85rem; color: var(--muted); margin: 2px 0; }
.kv b { color: var(--text); }
.progress { height: 8px; background: #e5e7eb; border-radius: 99px; overflow: hidden; margin: 8px 0; }
.progress > i { display: block; height: 100%; background: var(--brand); width: 0; transition: width .2s; }

/* ---------- scanner ---------- */
.scanwrap { max-width: 560px; margin: 0 auto; padding: 12px 14px 40px; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 10px 0; }
.seg button { min-height: 48px; border: 2px solid #cfd5e1; background: #fff; border-radius: 10px; font: inherit; font-weight: 700; cursor: pointer; }
.seg button.active { background: var(--brand); border-color: var(--brand); color: #fff; }
#reader { width: 100%; border-radius: 12px; overflow: hidden; background: #000; min-height: 200px; }
.manual { display: flex; gap: 8px; margin: 10px 0; }
.manual input { margin: 0; text-transform: uppercase; }
.result { border-radius: 16px; padding: 16px; margin-top: 12px; text-align: center; color: #fff; }
.result.good { background: var(--ok); }
.result.bad { background: var(--bad); }
.result.warn { background: var(--warn); }
.result.ready { background: var(--brand); }
.result .big { font-size: 1.35rem; font-weight: 800; }
.result .person { background: #fff; color: var(--text); border-radius: 12px; padding: 12px; margin-top: 12px; display: flex; gap: 12px; text-align: left; align-items: center; }
.result .person img { width: 84px; height: 112px; object-fit: cover; border-radius: 8px; background: #eee; flex: none; }
.result .person .nm { font-size: 1.2rem; font-weight: 800; }
.result .warnline { background: rgba(255,255,255,.2); border-radius: 8px; padding: 6px 10px; margin-top: 8px; font-weight: 700; }
.counter { display: flex; gap: 8px; margin: 6px 0; }
.counter div { flex: 1; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px; text-align: center; }
.counter b { display: block; font-size: 1.3rem; }
