/* Bulsan Stock – giao diện quầy quà. Phẳng, ưu tiên điện thoại, chữ to, nút lớn. */
:root {
  color-scheme: light;
  --bg: #f1f5f9;
  --card: #ffffff;
  --fg: #0f172a;
  --muted: #475569;
  --line: #d9e0e8;
  --primary: #1e293b;
  --on-primary: #ffffff;
  --accent: #047857;      /* xanh lá: nút chính, đã ghi */
  --accent-bg: #ecfdf5;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;
  --warn: #92400e;
  --warn-bg: #fffbeb;
  --ring: #2563eb;
  --radius: 12px;
  --gap: 12px;
  --tabs-h: 64px;
  --font: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; background: var(--bg); color: var(--fg);
  font: 400 16px/1.5 var(--font);
  padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 16px);
}
h1, h2 { margin: 0 0 8px; line-height: 1.25; font-weight: 700; }
h1 { font-size: 22px; } h2 { font-size: 20px; }
p { margin: 0; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono { font-variant-numeric: tabular-nums; letter-spacing: .02em; font-weight: 600; }
.muted { color: var(--muted); }
.strong { font-weight: 700; }
.center { text-align: center; }

.ic { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ic.xl { width: 44px; height: 44px; }

/* Đầu trang */
.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; background: var(--primary); color: var(--on-primary);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; flex-wrap: wrap; }
.badge { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.badge.warn { background: #fde68a; color: #78350f; }
.me {
  display: flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 12px; border-radius: 999px;
  border: 1px solid rgba(255,255,255,.35); background: transparent; color: inherit; font: 600 15px var(--font); cursor: pointer;
  max-width: 50%;
}
.me span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Dải tồn */
.strip {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; width: 100%; padding: 8px 12px; border: 0;
  border-bottom: 1px solid var(--line); background: var(--card); cursor: pointer; font: inherit; color: inherit; text-align: left;
}
.strip .chip { min-width: 0; }
.strip .chip b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; }
.strip .chip span { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.strip .chip.low b { color: var(--warn); }
.strip .chip.out b { color: var(--danger); }

main { max-width: 560px; margin: 0 auto; padding: 16px; }
.view { display: flex; flex-direction: column; gap: var(--gap); }
.step { display: flex; flex-direction: column; gap: var(--gap); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.login { display: flex; flex-direction: column; gap: 6px; margin-top: 8vh; }
.login .btn { margin-top: 10px; }

label { font-weight: 600; font-size: 15px; }
input, select {
  width: 100%; min-height: 48px; padding: 10px 12px; border: 1px solid #94a3b8; border-radius: 10px;
  font: 500 17px var(--font); color: var(--fg); background: #fff;
}
input:focus-visible, select:focus-visible, button:focus-visible, .shoot:focus-within, .switch:focus-within {
  outline: 3px solid var(--ring); outline-offset: 2px;
}

/* Nút */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 18px;
  border-radius: 10px; border: 1px solid transparent; font: 600 16px var(--font); cursor: pointer;
  transition: background-color .15s ease, opacity .15s ease;
}
.btn.big { min-height: 56px; font-size: 17px; width: 100%; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: #065f46; }
.btn.ghost { background: var(--card); color: var(--fg); border-color: #94a3b8; }
.btn.ghost:hover { background: #e2e8f0; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.icon { min-height: 44px; min-width: 44px; padding: 0; background: transparent; color: var(--fg); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.actions { display: flex; gap: 10px; }
#v-issue .actions {   /* luôn thấy nút Tiếp tục / Xác nhận, không phải cuộn */
  position: sticky; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom)); z-index: 3;
  margin: 0 -16px; padding: 10px 16px; background: var(--bg); border-top: 1px solid var(--line);
}
.actions .btn { flex: 1; }
.actions .btn.big { flex: 2; }

/* Thông báo */
.msg { padding: 10px 12px; border-radius: 10px; font-weight: 600; font-size: 15px; border-left: 4px solid; }
.msg.err { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }
.msg.warn { background: var(--warn-bg); color: var(--warn); border-color: #d97706; }
.msg.info { background: #eff6ff; color: #1e3a8a; border-color: #3b82f6; }
.msg.ok { background: var(--accent-bg); color: var(--accent); border-color: var(--accent); }

/* Chụp bill */
.shoot {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 46vh;
  border-radius: 16px; background: var(--primary); color: #fff; cursor: pointer; text-align: center; padding: 24px;
}
.shoot .ic.xl { width: 64px; height: 64px; }
.shoot-t { font-size: 26px; font-weight: 700; }
.shoot-s { font-size: 15px; opacity: .85; max-width: 260px; }

.reading { position: relative; border-radius: var(--radius); overflow: hidden; background: #000; max-height: 50vh; display: flex; justify-content: center; }
.reading img { max-width: 100%; max-height: 50vh; opacity: .55; object-fit: contain; }
.spinner { position: absolute; top: 50%; left: 50%; width: 48px; height: 48px; margin: -24px; border-radius: 50%;
  border: 5px solid rgba(255,255,255,.35); border-top-color: #fff; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Kết quả lớn */
.banner { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 28px 16px; border-radius: 16px; text-align: center; font-size: 17px; }
.banner h2 { font-size: 26px; margin: 4px 0; }
.banner.bad { background: var(--danger); color: #fff; }
.banner.good { background: var(--accent); color: #fff; }

/* Điều kiện */
.cond-head { display: flex; gap: 12px; align-items: flex-start; }
.cond-head > div { flex: 1; min-width: 0; }
.thumb { flex: none; width: 72px; height: 96px; padding: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #000; cursor: zoom-in; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid2 > div { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.switch {
  display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 0 14px; background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; cursor: pointer; font-size: 17px;
}
.switch input { width: 26px; height: 26px; min-height: 0; flex: none; accent-color: var(--accent); }
.bingo { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.bingo:empty { display: none; }
.bingo h3 { margin: 0; font-size: 15px; }
.bingo .row { display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; align-items: center; font-size: 14px; }
.bingo .row img, .bingo .row .ph { width: 44px; height: 44px; border-radius: 6px; object-fit: cover; background: #e2e8f0; }
.bingo .tag { font-weight: 700; margin-right: 4px; }
.bingo .yes, .bingo .no { font-size: 13px; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.bingo .yes { background: var(--accent-bg); color: var(--accent); }
.bingo .no { background: #f1f5f9; color: var(--muted); }

/* Chọn quà */
.gift-head { display: flex; align-items: center; gap: 8px; }
.gift-head h2 { margin: 0; flex: 1; }
.gifts { display: flex; flex-direction: column; gap: 10px; }
.gift {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 72px; padding: 12px 14px; text-align: left;
  background: var(--card); border: 2px solid var(--line); border-radius: 14px; font: inherit; color: inherit; cursor: pointer;
}
.gift .g-name { flex: 1; min-width: 0; font-weight: 700; font-size: 16px; }
.gift .g-name small { display: block; font-weight: 500; font-size: 13px; color: var(--muted); }
.gift .g-left { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.gift .dot { width: 24px; height: 24px; border-radius: 50%; border: 2px solid #94a3b8; flex: none; }
.gift[aria-checked="true"] { border-color: var(--accent); background: var(--accent-bg); }
.gift[aria-checked="true"] .dot { border: 7px solid var(--accent); }
.gift:disabled { opacity: .55; cursor: not-allowed; background: #f8fafc; }
.gift:disabled .g-name small { color: var(--danger); }

/* Lịch sử & tồn */
.totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.totals .t { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.totals .t b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.totals .t span { font-size: 13px; color: var(--muted); }
.totals .t.all { grid-column: 1 / -1; background: var(--primary); color: #fff; border-color: var(--primary); }
.totals .t.all span { color: #cbd5e1; }
.list { display: flex; flex-direction: column; gap: 8px; }
.item { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 4px; }
.item .l1 { display: flex; justify-content: space-between; gap: 8px; font-weight: 700; }
.item .l2 { font-size: 14px; color: var(--muted); }
.item.huy .l1, .item.huy .l2 { text-decoration: line-through; color: #94a3b8; }
.item .tag-huy { align-self: flex-start; font-size: 12px; font-weight: 700; color: var(--danger); background: var(--danger-bg); padding: 2px 8px; border-radius: 999px; text-decoration: none; }
.item .btn { align-self: flex-start; min-height: 44px; }
.empty { text-align: center; color: var(--muted); padding: 24px 0; }
.stock .big-n { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; }
.pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; margin-left: 6px; vertical-align: middle; }
.pill.low { background: var(--warn-bg); color: var(--warn); }
.pill.out { background: var(--danger-bg); color: var(--danger); }
#s-form { display: flex; flex-direction: column; gap: 6px; }

/* Thanh điều hướng dưới */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: grid; grid-template-columns: repeat(3, 1fr);
  height: calc(var(--tabs-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--card); border-top: 1px solid var(--line);
}
.tabs button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border: 0; background: none;
  font: 600 13px var(--font); color: var(--muted); cursor: pointer;
}
.tabs button[aria-current="page"] { color: var(--accent); }
.tabs button[aria-current="page"] .ic { stroke-width: 2.5; }

/* Lớp phủ & hộp thoại */
.overlay { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; padding: 24px; background: rgba(15,23,42,.88); }
.overlay .card { max-width: 360px; display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--fg); }
.overlay .ic.xl { color: var(--danger); }
.dlg { border: 0; border-radius: 16px; padding: 20px; width: min(92vw, 420px); }
.dlg::backdrop { background: rgba(15,23,42,.6); }
.dlg p { margin-bottom: 16px; font-size: 17px; }
.dlg.img { padding: 8px; width: 96vw; max-height: 94vh; }
.dlg.img img { width: 100%; height: auto; display: block; margin-bottom: 8px; }
.dlg.img .btn { width: 100%; }
.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 12px); z-index: 15;
  max-width: 520px; margin: 0 auto; padding: 12px 16px; border-radius: 12px; background: var(--primary); color: #fff; font-weight: 600; text-align: center;
}

@media (min-width: 900px) { main { padding-top: 24px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; } }

/* Phản hồi khi chạm (không đổi kích thước, không xô lệch bố cục) */
.btn:not(:disabled):active, .gift:not(:disabled):active, .shoot:active, .tabs button:active, .strip:active, .me:active { opacity: .82; }

/* ===================== ĐỢT 2 ===================== */
/* Bảng màu (phương án A – nền sáng, xanh hải quân; đổi sang B chỉ cần đổi khối biến này) */
:root {
  --bg: #f8fafc; --card: #ffffff; --fg: #020617; --muted: #475569; --line: #cbd5e1;
  --primary: #0f172a; --on-primary: #ffffff;
  --action: #0369a1; --action-hover: #075985; --on-action: #ffffff;   /* nút chính */
  --accent: #047857; --accent-bg: #ecfdf5;                            /* đã xong */
  --danger: #b91c1c; --danger-bg: #fef2f2;                            /* bị chặn */
  --warn: #78350f; --warn-bg: #fef3c7; --warn-line: #d97706;          /* cần kiểm, nhắc việc */
  --hold: #0f172a; --hold-on: #fde68a;                                /* người khác đang giữ */
  --field-line: #64748b;
}
/* Màu riêng của từng quà: --g là nền, --og là chữ trên nền. Luôn đi kèm ký hiệu chữ. */
.g-WONJIN { --g: #9333ea; --og: #ffffff; } .g-VC50 { --g: #9a3412; --og: #ffffff; } .g-VC100 { --g: #db2777; --og: #ffffff; }
.g-VCFOOD { --g: #4d7c0f; --og: #ffffff; } .g-TUIMU { --g: #0891b2; --og: #0b1220; }
.g-PAD_WHITE { --g: #ca8a04; --og: #0b1220; } .g-PAD_COOL { --g: #1d4ed8; --og: #ffffff; }
/* Bộ màu quà đã qua kiểm tra: mọi cặp cách nhau đủ xa với mắt thường (ΔE ≥ 17); người mù màu dựa vào ký hiệu chữ luôn đi kèm. */

html { touch-action: manipulation; }          /* iPhone: không phóng to khi chạm đúp */
input, select, textarea, button { font-size: max(16px, 1em); }   /* iPhone: dưới 16px sẽ tự phóng to khi chạm vào ô */
input, select { border: 1.5px solid var(--field-line); font-size: 17px; }
input[type="date"] { -webkit-appearance: none; appearance: none; min-width: 0; }
.btn.primary { background: var(--action); color: var(--on-action); }
.btn.primary:hover { background: var(--action-hover); }
.btn.ghost { border: 1.5px solid var(--field-line); }
.danger-text { color: var(--danger); }
.tabs button[aria-current="page"] { color: var(--action); }

.top-r { display: flex; align-items: center; gap: 6px; min-width: 0; }
.icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 999px; flex: none;
  border: 1px solid rgba(255,255,255,.35); background: transparent; color: inherit; cursor: pointer; }
.icon-btn[aria-pressed="false"] { opacity: .6; }
.me { max-width: 40vw; }

/* Dải tồn: 7 quà, mỗi quà một ô màu + ký hiệu */
.strip { grid-template-columns: repeat(7, 1fr); gap: 4px; padding: 6px 8px; }
.strip .chip { background: var(--g); color: var(--og); border-radius: 8px; text-align: center; font-weight: 700; font-size: 11px; line-height: 1.2; padding: 4px 0; }
.strip .chip b { font-size: 14px; color: inherit; }
.strip .chip.low { outline: 3px solid var(--warn-line); outline-offset: -3px; }
.strip .chip.out { background: #e2e8f0; color: #475569; text-decoration: line-through; }
.strip .chip.low b, .strip .chip.out b { color: inherit; }
.gchip { display: inline-grid; place-items: center; min-width: 30px; height: 22px; padding: 0 6px; border-radius: 6px;
  background: var(--g, #e2e8f0); color: var(--og, #0f172a); font-size: 12px; font-weight: 700; vertical-align: middle; }

/* Thông báo: 3 mức, chữ to, nháy 3 nhịp khi mới hiện */
.alert { display: block; padding: 12px 14px; border-radius: 12px; font-weight: 700; font-size: 18px; line-height: 1.35; border-left: 8px solid; }
.alert.block { background: var(--danger); color: #fff; border-color: #7f1d1d; }
.alert.check { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
.alert.remind { background: var(--warn-bg); color: var(--warn); border: 3px dashed var(--warn-line); text-align: center; font-size: 22px; padding: 16px; }
.alert.ok { background: var(--accent-bg); color: var(--accent); border-color: var(--accent); font-size: 16px; }
.alert:not([hidden]), .banner, .done-gift { animation: flash .45s ease-in-out 3; }
@keyframes flash { 0%, 100% { opacity: 1; transform: none; } 50% { opacity: .45; transform: scale(.985); } }
.hint { font-size: 15px; color: var(--muted); text-align: center; }

.banner h2 { font-size: 28px; }
.banner.bad { background: var(--danger); }
.banner.hold { background: var(--hold); color: var(--hold-on); border: 6px solid var(--warn-line); }
.banner .ic.xl { width: 64px; height: 64px; }

/* Khay ảnh */
.tray { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.shot { position: relative; background: var(--card); border: 1.5px solid var(--line); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; }
.shot img { width: 100%; height: 150px; object-fit: cover; background: #000; display: block; }
.shot .num { position: absolute; top: 6px; left: 6px; background: var(--primary); color: #fff; font-weight: 700; font-size: 13px; padding: 2px 8px; border-radius: 999px; }
.shot-act { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 6px; }
.shot-act .btn { min-height: 44px; padding: 0 6px; font-size: 16px; }
label.btn { cursor: pointer; }

/* Chọn quà: ô màu + ký hiệu */
.gift .dot { display: none; }
.gift .code { width: 48px; height: 48px; border-radius: 12px; background: var(--g); color: var(--og); display: grid; place-items: center; font-weight: 700; font-size: 16px; flex: none; }
.gift[aria-checked="true"] { border-color: var(--g); background: var(--card); box-shadow: inset 0 0 0 3px var(--g); }
.gift:disabled .code { filter: grayscale(1); }
.gift:disabled .g-name small { color: var(--danger); font-weight: 600; }
.gift .g-name small { font-size: 14px; }

/* Đã ghi */
.okline { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 20px; color: var(--accent); }
.okline .ic { width: 30px; height: 30px; }
.done-gift { background: var(--g, var(--accent)); color: var(--og, #fff); border-radius: 16px; padding: 22px 14px; text-align: center; }
.done-gift small { font-weight: 600; font-size: 16px; opacity: .95; }
.done-gift h2 { margin: 4px 0 0; font-size: 34px; line-height: 1.15; }

/* Bàn phím điện thoại đang mở: ẩn thanh dưới, hàng nút sát đáy */
body.kb .tabs, body.kb .toast { display: none; }
body.kb #v-issue .actions { bottom: 0; }

@media (prefers-reduced-motion: reduce) { .alert:not([hidden]), .banner, .done-gift { animation: none; } }

/* Chọn quà: đủ 7 quà trong một màn hình điện thoại, không phải cuộn */
.gifts { gap: 7px; }
.gift { min-height: 58px; padding: 7px 12px; }
.gift .code { width: 42px; height: 42px; font-size: 15px; }
.gift .g-name { font-size: 16px; line-height: 1.25; }
.gift-head h2 { white-space: nowrap; }
#gift-bill { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

.me { font-size: 16px; }
