/* Roboto (SIL Open Font License 1.1 — cho dùng thương mại, cho cắt subset; nguyên văn giấy phép ở public/fonts/LICENSE)
   Tự lưu trên máy chủ, đủ tiếng Việt để chữ ư/ê/ế… không bị font khác thay. Copyright 2011 The Roboto Project Authors. */
@font-face{font-family:Roboto;font-style:normal;font-weight:100 900;font-display:swap;src:url(/fonts/roboto-vietnamese.woff2) format("woff2");unicode-range:U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;}
@font-face{font-family:Roboto;font-style:normal;font-weight:100 900;font-display:swap;src:url(/fonts/roboto-latin-ext.woff2) format("woff2");unicode-range:U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;}
@font-face{font-family:Roboto;font-style:normal;font-weight:100 900;font-display:swap;src:url(/fonts/roboto-latin.woff2) format("woff2");unicode-range:U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;}

/* Xổ Số Xuân Lộc — trắng + đỏ + vàng (tông đỏ vàng truyền thống của ngành xổ số), mobile-first.
   Độ tương phản đã đo bằng validate_palette.js (CLAUDE.md, Quy trình #2):
   chữ trắng/#b80000 5.9:1 · chữ trắng/#8f0000 8.3:1 · số #b30000/trắng 7.0:1 · #e00000 (1.5rem đậm)/#fffbe6 4.6:1
   chữ #3b2600/nút vàng #ffd400 9.4:1 · tên đài #0a58a5/trắng 7.2:1 · nhãn #444/#f4f4f4 8.5:1 · link #b30000/trắng 7.0:1 */
:root {
  --brand: #c40000;         /* đỏ chủ đạo: nút chính, nút thứ đang chọn */
  --brand-dark: #a00000;
  --brand-deep: #8f0000;    /* thanh menu */
  --gold: #ffd400;          /* vàng: nút Quét vé/Dò vé, gạch menu, viền logo */
  --gold-ink: #3b2600;      /* chữ trên nền vàng */
  --num: #b30000;           /* số kết quả nổi bật */
  --accent: #e00000;        /* số giải ĐB */
  --ink: #222;
  --muted: #666;
  --line: #e3e3e3;
  --label: #f4f4f4;         /* nền cột tên giải */
  --bg: #fff;
  --surface: #fff;
  --ok: #15803d;
  --err: #b91c1c;
  --radius: 10px;
  /* Font số kết quả: dùng font sans — số 0 KHÔNG có gạch/chấm, đọc số vé đỡ nhầm.
     tabular-nums để các số thẳng cột. Không dùng monospace vì phần lớn có 0 gạch chéo. */
  --mono: Roboto, system-ui, -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  /* Thang tuần tự 1 màu (đỏ) cho bảng nhiệt thống kê, nhạt → đậm.
     Chữ đậm trên bậc 0–4, chữ trắng trên bậc 5–7: mọi bậc ≥ 5:1 */
  --seq-0: #fff0ee; --seq-1: #fdd5cf; --seq-2: #f9aea3; --seq-3: #f27f70;
  --seq-4: #ec6a58; --seq-5: #cf3429; --seq-6: #a51d1f; --seq-7: #7c1116;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.55 Roboto, system-ui, -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}
a { color: #b30000; }
a:hover { color: var(--brand-deep); }
h1, h2, h3 { line-height: 1.3; margin: 0 0 .5em; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .8em; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 12px; }
.small, small { font-size: .85rem; color: var(--muted); }
.muted { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Header ---------- */
.demo-bar { background: #7c2d12; color: #fff; text-align: center; padding: 8px 12px; font-size: .9rem; font-weight: 600; }
.top { background: linear-gradient(180deg, #d40808, #b80000); color: #fff; position: sticky; top: 0; z-index: 10; box-shadow: 0 2px 8px rgb(0 0 0 / .25); }
.top-in { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 6px; padding-bottom: 6px; }
.brand { display: flex; align-items: center; gap: 9px; color: #fff; text-decoration: none; font-weight: 800; font-size: 1.13rem; letter-spacing: .2px; min-width: 0; }
.brand:hover { color: #fff; }
.brand img { width: 42px; height: 42px; border-radius: 50%; border: 2px solid var(--gold); background: #900; flex: none; object-fit: cover; }
.brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; align-items: center; gap: 6px; flex: none; }
/* Nút quét vé "Dò vé" trên header dính: trang nào, cuộn tới đâu cũng thấy */
.scan-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  background: var(--gold); color: var(--gold-ink); border: 0; border-radius: 12px; padding: 4px 10px 3px;
  font: inherit; font-size: .72rem; font-weight: 800; cursor: pointer; line-height: 1.1; text-decoration: none;
}
.scan-btn svg { width: 24px; height: 24px; }
.scan-btn:hover { background: #ffdf4d; color: var(--gold-ink); }
.icon-btn { position: relative; display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 50%; color: #fff; text-decoration: none; border: 1px solid rgb(255 255 255 / .5); }
.icon-btn:hover { background: rgb(255 255 255 / .12); color: #fff; }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn .badge { position: absolute; top: -4px; right: -4px; }
.badge { background: var(--gold); color: var(--gold-ink); border-radius: 999px; padding: 0 6px; font-size: .75rem; font-weight: 800; }
.nav { background: #fff; border-bottom: 2px solid var(--brand); }
.nav-in { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.nav-in::-webkit-scrollbar { display: none; }
.nav a { color: #a00000; text-decoration: none; padding: 9px 11px; white-space: nowrap; font-weight: 700; font-size: .95rem; border-bottom: 3px solid transparent; }
.nav a:hover { color: var(--brand); background: #fff5f5; }
.nav a.on { color: var(--brand); background: #fff2f2; border-bottom-color: var(--brand); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--gold); animation: pulse 1.2s infinite; vertical-align: middle; }
@keyframes pulse { 50% { opacity: .3; } }
.live-bar { display: block; background: #fff7cc; color: #7a4b00; text-align: center; font-weight: 700; padding: 8px; text-decoration: none; border-bottom: 1px solid #ffe58a; }

/* ---------- Layout ---------- */
.main { padding-top: 12px; padding-bottom: 32px; }
.grid { display: grid; gap: 14px; }
@media (min-width: 900px) {
  .with-side { grid-template-columns: minmax(0, 1fr) 300px; align-items: start; }
  .side { position: sticky; top: 120px; }
}
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: 0 1px 4px rgb(0 0 0 / .05); }
.page-head { margin-bottom: 12px; }
.page-head p { color: var(--muted); margin: 0; }
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--muted); }
.pills { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 12px; }
.pills a { background: var(--surface); border: 1px solid #d9d9d9; border-radius: 999px; padding: 4px 12px; text-decoration: none; font-size: .9rem; }
.pills a.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.more { display: block; text-align: center; margin: 14px 0; }
.empty { text-align: center; color: var(--muted); padding: 24px 12px; }

/* 7 nút thứ trong tuần trên MỘT hàng */
.days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; margin: 0 0 12px; }
.days a { text-align: center; text-decoration: none; background: #fff; border: 1px solid #d9d9d9; border-radius: 8px; padding: 7px 0; font-weight: 700; font-size: .92rem; color: var(--brand-dark); }
.days a.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.days a.today { border-color: var(--gold); box-shadow: inset 0 -3px 0 var(--gold); }

/* ---------- Cụm Dò vé + Quét vé: ngay dưới header, trên hàng nút thứ ---------- */
.dove-bar { background: #fff; border: 1px solid var(--line); border-top: 3px solid var(--gold); border-radius: var(--radius); box-shadow: 0 1px 4px rgb(0 0 0 / .06); padding: 10px; margin-bottom: 12px; display: flex; gap: 10px; align-items: stretch; }
.dove-bar form { flex: 1; min-width: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.dove-bar form label { margin: 0; }
.dove-bar input, .dove-bar select { margin: 0; padding: 8px; font-size: .95rem; }
.dove-bar .num { font-family: var(--mono); font-weight: 800; letter-spacing: 1px; }
.dove-bar .go { padding: 8px; }
.dove-bar .scan-big {
  flex: none; width: 78px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  background: var(--gold); color: var(--gold-ink); border: 0; border-radius: 10px; font: inherit; font-weight: 800; font-size: .82rem; cursor: pointer;
}
.dove-bar .scan-big svg { width: 34px; height: 34px; }
.dove-bar .scan-big:hover { background: #ffdf4d; }
@media (min-width: 700px) {
  .dove-bar form { grid-template-columns: 1fr 1.2fr 1fr auto; align-items: center; }
}

/* ---------- Buttons & forms ---------- */
.btn { display: inline-block; background: var(--brand); color: #fff; border: 0; border-radius: 8px; padding: 10px 18px; font: inherit; font-weight: 700; cursor: pointer; text-decoration: none; text-align: center; }
.btn:hover { background: var(--brand-deep); color: #fff; }
.btn.accent { background: var(--gold); color: var(--gold-ink); }
.btn.accent:hover { background: #ffdf4d; color: var(--gold-ink); }
.btn.line { background: var(--surface); color: var(--brand); border: 1px solid var(--brand); }
.btn.small { padding: 6px 12px; font-size: .9rem; }
.btn.block { display: block; width: 100%; }
form label { display: block; font-weight: 600; font-size: .92rem; margin-bottom: 10px; }
input, select, textarea {
  display: block; width: 100%; margin-top: 4px; font: inherit; color: var(--ink);
  border: 1px solid #ccc; border-radius: 8px; padding: 9px 10px; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold); outline-offset: 1px; border-color: var(--brand-dark); }
.row { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.row3 { display: grid; gap: 10px; grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 520px) { .row3 { grid-template-columns: 1fr 1fr; } }
.hp { position: absolute; left: -9999px; }
.flash { border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; font-weight: 600; }
.flash.ok { background: #dcfce7; color: #14532d; }
.flash.err, .errors { background: #fee2e2; color: #7f1d1d; }
.errors { border-radius: 8px; padding: 10px 12px 10px 28px; margin: 0 0 12px; }

/* ---------- Bảng kết quả ---------- */
.board { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 14px; overflow: hidden; box-shadow: 0 1px 4px rgb(0 0 0 / .05); }
.board-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; padding: 8px 12px; background: linear-gradient(180deg, #c00505, #a80000); color: #fff; }
.board-head h2 { margin: 0; font-size: 1.02rem; color: #fff; }
.board-head h2 a { color: #fff; text-decoration: none; }
/* Nhãn ngày: bấm mở lịch chọn ngày khác (input date trong suốt phủ lên nhãn) */
.date-pick { position: relative; display: inline-flex; align-items: center; gap: 6px; background: #fff; border: 0; border-radius: 999px; padding: 4px 10px; font-weight: 700; color: var(--brand-dark); font-size: .92rem; cursor: pointer; }
.date-pick svg { width: 15px; height: 15px; }
.date-pick input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; margin: 0; padding: 0; border: 0; cursor: pointer; }
.table-scroll { overflow-x: auto; }
table.kq { width: 100%; border-collapse: collapse; table-layout: fixed; }
.kq th, .kq td { border-bottom: 1px solid var(--line); text-align: center; padding: 6px 4px; }
.kq td + td, .kq th + th, .kq td + th, .kq th + td { border-left: 1px solid var(--line); }
.kq thead th { font-size: .95rem; background: #fff; }
.kq thead th a { text-decoration: none; font-weight: 700; color: #0a58a5; }
.kq tbody th { font-size: .82rem; color: #444; font-weight: 600; background: var(--label); line-height: 1.15; white-space: normal; }
.kq thead th:first-child { width: 74px; }
/* Bảng một đài (XSMB, trang tỉnh): chia cột theo số lượng số của giải */
.kq.cols-1 .nums { display: grid; grid-template-columns: repeat(var(--c), 1fr); }
.kq .n { display: block; font-family: var(--mono); font-weight: 700; font-size: 1.05rem; letter-spacing: .5px; min-height: 1.6em; color: #222; }
.kq tr.t-g8 .n, .kq tr.t-g7 .n { font-size: 1.32rem; color: var(--num); }
.kq tr.t-db td { background: #fffbe6; }
.kq tr.t-db .n { color: var(--accent); font-size: 1.5rem; font-weight: 800; }
.kq tr.codes td { font-size: .85rem; color: var(--muted); }
.kq .n.wait::after { content: ""; display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
.kq .n.new { animation: flashnum 2.5s ease-out; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes flashnum { 0% { background: #fde68a; } 100% { background: transparent; } }
@media (max-width: 480px) {
  .kq .n { font-size: .98rem; letter-spacing: 0; }
  .kq tr.t-g8 .n, .kq tr.t-g7 .n { font-size: 1.18rem; }
  .kq tr.t-db .n { font-size: 1.3rem; }
  .kq.cols-4 .n { font-size: .88rem; }
  .kq thead th:first-child { width: 58px; }
  .kq tbody th { font-size: .74rem; }
}
.status { font-size: .78rem; font-weight: 600; }
.status.live { color: #ffd9a8; }
/* Chân bảng: nút Đủ số / 2 số / 3 số (ngay dưới hàng giải ĐB) + In vé dò */
.board-foot { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); padding: 8px 12px; font-size: .9rem; background: #fafafa; }
.board-foot a { text-decoration: none; font-weight: 600; }
.board-links { display: inline-flex; gap: 14px; }
.digits { display: inline-flex; border: 1px solid #c9c9c9; border-radius: 8px; overflow: hidden; }
.digits button { font: inherit; font-size: .84rem; background: #fff; color: var(--brand-dark); border: 0; padding: 5px 12px; cursor: pointer; }
.digits button + button { border-left: 1px solid #c9c9c9; }
.digits button.on { background: var(--brand); color: #fff; }

/* Loto đầu – đuôi */
details.loto { border-top: 1px solid var(--line); }
details.loto summary { cursor: pointer; padding: 9px 12px; font-weight: 600; color: var(--brand-dark); font-size: .92rem; }
.loto-wrap { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); padding: 0 12px 12px; }
table.lt { width: 100%; border-collapse: collapse; font-size: .9rem; }
.lt caption { font-weight: 700; text-align: left; padding-bottom: 4px; }
.lt th, .lt td { border: 1px solid var(--line); padding: 3px 6px; }
.lt th { width: 34px; background: var(--label); color: var(--brand-dark); }
.lt td { font-family: var(--mono); letter-spacing: 2px; }

/* ---------- Dò vé ---------- */
.tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.tabs a { padding: 7px 14px; border-radius: 8px; text-decoration: none; background: var(--surface); border: 1px solid #d9d9d9; font-weight: 600; }
.tabs a.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.result-win { border: 2px solid var(--gold); background: #fffbe6; }
.result-win .big { font-size: 1.6rem; font-weight: 800; color: var(--accent); }
.result-lose { border: 2px solid var(--line); }
.wins { list-style: none; padding: 0; margin: 8px 0; }
.wins li { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px dashed #e8c84a; }
.ticket-num { font-family: var(--mono); font-size: 1.3rem; font-weight: 800; letter-spacing: 2px; }

/* ---------- Màn hình quét vé ---------- */
.scan-overlay { position: fixed; inset: 0; z-index: 50; background: rgb(40 0 0 / .72); display: flex; align-items: center; justify-content: center; padding: 16px; }
.scan-overlay[hidden] { display: none; }
.scan-box { background: #fff; border-radius: 16px; padding: 18px; width: min(420px, 100%); text-align: center; box-shadow: 0 10px 40px rgb(0 0 0 / .35); }
.scan-box img { max-width: 100%; max-height: 220px; border-radius: 10px; margin-bottom: 10px; object-fit: contain; }
.scan-box .spin { width: 34px; height: 34px; border: 4px solid #f3d6cf; border-top-color: var(--brand); border-radius: 50%; margin: 8px auto; animation: spin .8s linear infinite; }
.scan-box .actions { display: flex; gap: 8px; justify-content: center; margin-top: 10px; flex-wrap: wrap; }

/* ---------- Vietlott ---------- */
.balls { display: flex; flex-wrap: wrap; gap: 6px; }
.ball { width: 38px; height: 38px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-family: var(--mono); background: var(--brand); color: #fff; }
.ball.bonus { background: var(--gold); color: var(--gold-ink); }
.ball.set { width: auto; min-width: 38px; padding: 0 10px; border-radius: 19px; }
.ball.hit { outline: 3px solid var(--gold); outline-offset: 2px; }
.game-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.game-row:last-child { border-bottom: 0; }
.jackpot { font-weight: 800; color: var(--accent); }

/* ---------- Bảng thông tin chung ---------- */
table.data { width: 100%; border-collapse: collapse; font-size: .95rem; }
.data th, .data td { border-bottom: 1px solid var(--line); padding: 8px 6px; text-align: left; vertical-align: top; }
.data thead th { background: var(--label); color: var(--brand-dark); }
.data td.num, .data th.num { text-align: right; font-variant-numeric: tabular-nums; }
.data .mono { font-family: var(--mono); font-weight: 700; }
.data tr.today td { background: #fffbe6; }

/* ---------- Thống kê: bảng nhiệt 00–99 ---------- */
.heat { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 2px; background: var(--surface); }
.heat .c { min-width: 0; aspect-ratio: 1 / .78; border-radius: 4px; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; font-family: var(--mono); color: var(--ink); cursor: default; }
.heat .c b { font-size: .95rem; }
.heat .c i { font-style: normal; font-size: .72rem; opacity: .85; }
.heat .c:hover, .heat .c:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
.heat .l0 { background: var(--seq-0); } .heat .l1 { background: var(--seq-1); }
.heat .l2 { background: var(--seq-2); } .heat .l3 { background: var(--seq-3); }
.heat .l4 { background: var(--seq-4); }
.heat .l5 { background: var(--seq-5); color: #fff; } .heat .l6 { background: var(--seq-6); color: #fff; }
.heat .l7 { background: var(--seq-7); color: #fff; }
@media (max-width: 480px) {
  .heat .c b { font-size: .8rem; }
  .heat .c i { font-size: .64rem; }
}
.legend { display: flex; align-items: center; gap: 6px; font-size: .82rem; color: var(--muted); margin-top: 8px; }
.legend .ramp { display: flex; gap: 2px; }
.legend .ramp span { width: 18px; height: 10px; border-radius: 2px; }
.bars { list-style: none; padding: 0; margin: 0; }
.bars li { display: grid; grid-template-columns: 22px 1fr 34px; gap: 8px; align-items: center; font-size: .9rem; padding: 2px 0; }
.bars .bar { height: 12px; background: var(--brand-dark); border-radius: 0 4px 4px 0; min-width: 2px; }
.bars .v { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.two { display: grid; gap: 14px; }
@media (min-width: 700px) { .two { grid-template-columns: 1fr 1fr; } }

/* ---------- Tài khoản ---------- */
.tk-status { font-weight: 700; font-size: .88rem; }
.tk-status.win { color: var(--accent); }
.tk-status.lose { color: var(--muted); }
.tk-status.wait { color: var(--brand-dark); }
.notes { list-style: none; padding: 0; margin: 0; }
.notes li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.notes li.unread { font-weight: 700; }

/* ---------- Admin ---------- */
.entry td { padding: 4px; }
.entry input.cell { font-family: var(--mono); font-weight: 700; text-align: center; padding: 6px 4px; margin: 2px 0; }
.entry input.cell.saved { border-color: var(--ok); background: #f0fdf4; }
.entry input.cell.bad { border-color: var(--err); background: #fef2f2; }
.admin-bar { background: #1f2937; color: #fff; font-size: .88rem; }
.admin-bar .wrap { display: flex; gap: 14px; flex-wrap: wrap; padding: 6px 12px; }
.admin-bar a { color: #e5e7eb; }

/* ---------- Footer ---------- */
.foot { background: var(--brand-deep); color: #ffd9d9; padding: 24px 0 30px; font-size: .9rem; }
.foot a { color: var(--gold); }
.foot-in { display: grid; gap: 14px; }
.foot nav { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.foot .small { color: #f3b8b8; }

/* ---------- In vé dò: trang chỉnh mẫu ---------- */
.print-editor { display: grid; gap: 14px; }
@media (min-width: 960px) { .print-editor { grid-template-columns: 380px minmax(0, 1fr); align-items: start; } .pe-preview { position: sticky; top: 120px; } }
.pe-set { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px 4px; margin: 0 0 12px; }
.pe-set legend { font-weight: 700; color: var(--brand-dark); padding: 0 4px; }
label.inline { display: flex; align-items: center; gap: 8px; font-weight: 500; margin-bottom: 8px; }
label.inline input { width: auto; margin: 0; }
input[type=range] { padding: 0; }
.pe-provinces { list-style: none; margin: 0 0 8px; padding: 0; max-height: 260px; overflow: auto; }
.pe-provinces li { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); padding: 2px 0; }
.pe-provinces li label { margin: 0; }
.pe-provinces button { font: inherit; border: 1px solid var(--line); background: #fff; border-radius: 6px; width: 34px; height: 30px; margin-left: 4px; cursor: pointer; }
/* Đài chưa được ưu tiên (chưa bấm ↑) thì ↓ không có tác dụng — làm mờ để khỏi bấm nhầm */
.pe-provinces li:not([data-pin]) button[data-move="1"] { opacity: .35; }
.pe-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.pe-preview { padding: 0; overflow: hidden; }
.pe-preview-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--label); }
#pe-frame { display: block; width: 100%; height: 75vh; min-height: 480px; border: 0; background: #eee; }

/* Số kết quả thẳng cột, 0 không gạch (font hệ thống + tabular-nums) */
.kq .n, .ticket-num, .ball, table.lt td, .data .mono, .dove-bar .num, .entry input.cell, .heat .c, .bars .mono {
  font-variant-numeric: tabular-nums;
}

/* ---------- Nút Quét vé nổi: hiện ở MỌI trang ---------- */
.scan-fab {
  position: fixed; right: 14px; bottom: 16px; z-index: 40;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  width: 62px; height: 62px; border-radius: 50%; border: 3px solid #fff; background: var(--brand); color: #fff;
  box-shadow: 0 4px 14px rgb(120 0 10 / .4); cursor: pointer; font: inherit; font-weight: 800; font-size: .66rem;
}
.scan-fab svg { width: 26px; height: 26px; }
.scan-fab:hover { background: var(--brand-deep); }
@media print { .scan-fab { display: none; } }

/* Báo trạng thái trang trực tiếp: rỗng thì ẩn hẳn */
.conn-note { margin: 0 0 8px; color: var(--err); font-weight: 600; }
.conn-note:empty { display: none; }

/* ---------- Camera quét vé: khung căn giống app dò vé ---------- */
.cam-wrap { position: relative; background: #000; border-radius: 10px; overflow: hidden; aspect-ratio: 4 / 3; }
.cam-wrap video { width: 100%; height: 100%; object-fit: cover; display: block; }
/* Khung căn: vùng tối xung quanh + 4 góc vàng, người dùng đưa vé vào giữa */
.cam-frame { position: absolute; inset: 0; box-shadow: inset 0 0 0 2000px rgb(0 0 0 / .42); }
.cam-frame::after {
  content: ''; position: absolute; left: 8%; right: 8%; top: 27%; bottom: 27%;
  box-shadow: 0 0 0 2000px rgb(0 0 0 / .42); border-radius: 8px;
}
.cam-frame span { position: absolute; width: 26px; height: 26px; border: 4px solid var(--gold); z-index: 1; }
.cam-frame span:nth-child(1) { left: 8%; top: 27%; border-right: 0; border-bottom: 0; border-radius: 8px 0 0 0; }
.cam-frame span:nth-child(2) { right: 8%; top: 27%; border-left: 0; border-bottom: 0; border-radius: 0 8px 0 0; }
.cam-frame span:nth-child(3) { left: 8%; bottom: 27%; border-right: 0; border-top: 0; border-radius: 0 0 0 8px; }
.cam-frame span:nth-child(4) { right: 8%; bottom: 27%; border-left: 0; border-top: 0; border-radius: 0 0 8px 0; }
.cam-hint { margin: 8px 0; text-align: center; font-weight: 600; color: var(--ink); }
.cam-hint.ok { color: var(--ok); }
#scan-status:empty { display: none; }

/* Nút "Quét vé để điền nhanh" trong biểu mẫu: icon nhỏ nằm cạnh chữ */
.btn.js-scan { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn.js-scan svg { width: 22px; height: 22px; flex: none; }

/* Ô sắp có kết quả: số chạy ngẫu nhiên cho tới khi số thật về.
   Từng chữ số nằm trong một ô nền xanh lá, chữ đen (chữ #111 trên nền #c8f0c8 = 15.1:1) */
.kq .n.rolling::after { content: none; }      /* tắt vòng xoay, đã có số chạy */
.kq .n.rolling i {
  display: inline-block; font-style: normal; background: #c8f0c8; color: #111;
  border-radius: 3px; padding: 0 2px; margin: 0 1px; min-width: .72em; text-align: center;
}

/* ---------- Dò vui: trò so số cuối với giải ĐB (không phải trúng thưởng) ---------- */
.check { display: flex; gap: 10px; align-items: flex-start; margin: 12px 0; font-weight: 700; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; flex: none; }
.check .small { font-weight: 400; }
/* Dùng inline-block (KHÔNG dùng flex) — flex biến từng chữ thành một ô riêng nên câu bị vỡ dòng */
.dovui {
  display: inline-block; margin-top: 6px;
  background: #fff6d8; border: 1px solid #f0d789; color: #7a4b00;
  border-radius: 8px; padding: 4px 9px; font-size: .85rem; font-weight: 700; line-height: 1.4;
}
.dovui b { color: #b35c00; }
.dovui .ico { font-size: 1.05rem; display: inline-block; margin-right: 4px; vertical-align: -2px; animation: lacvui 1.1s ease-in-out infinite; }
@keyframes lacvui { 0%, 100% { transform: rotate(-12deg); } 50% { transform: rotate(12deg); } }
@media (prefers-reduced-motion: reduce) { .dovui .ico { animation: none; } }

/* Trang trực tiếp không có cột bên: giới hạn bề ngang cụm dò vé cho bằng bảng kết quả */
@media (min-width: 900px) {
  .col-main { max-width: calc(1080px - 300px - 14px); }
}

/* Máy tính: nén bảng kết quả cho vừa một màn hình — cuộn tới hàng nút thứ là thấy
   trọn bảng đến hết nút Đủ số / 2 số / 3 số, khỏi phải cuộn thêm. */
@media (min-width: 900px) {
  .kq th, .kq td { padding: 3px 6px; }
  .kq .n { min-height: 1.35em; line-height: 1.25; }
  .board-head { padding: 7px 12px; }
  .board-foot { padding: 6px 10px; }
  .dove-bar { padding: 8px; margin-bottom: 9px; }
  .days { margin-bottom: 9px; }
  .days a { padding: 5px 0; }
}

/* ---------- Mở như ứng dụng (đã lưu về màn hình chính) ---------- */
/* Header đỏ phủ cả vùng đồng hồ/pin nhưng chừa đúng chiều cao vùng đó nên không che chữ.
   Chỉ áp dụng khi chạy dạng ứng dụng — mở trong trình duyệt vẫn như cũ. */
@media (display-mode: standalone) {
  .top { padding-top: env(safe-area-inset-top); }
  .demo-bar, .admin-bar { padding-top: calc(8px + env(safe-area-inset-top)); }
  .main { padding-bottom: calc(32px + env(safe-area-inset-bottom)); }
  .scan-fab { bottom: calc(16px + env(safe-area-inset-bottom)); }
  .foot { padding-bottom: env(safe-area-inset-bottom); }
}
/* Nền đỏ trám phần trên cùng để lúc cuộn không lộ nền trắng sau vùng đồng hồ */
html { background: var(--brand-deep); }
body { min-height: 100vh; }

/* Vuốt kéo xuống để tải lại */
.ptr {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 4px);
  transform: translate(-50%, -48px); z-index: 60;
  width: 34px; height: 34px; border-radius: 50%; background: #fff;
  box-shadow: 0 2px 8px rgb(0 0 0 / .28); display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
}
.ptr-ico { width: 17px; height: 17px; border: 2.5px solid var(--line); border-top-color: var(--brand); border-radius: 50%; }
.ptr.spin .ptr-ico { animation: spin .7s linear infinite; }

/* Vạch quét chạy qua lại trong khung — cho người dùng biết máy đang tìm mã QR */
.cam-line {
  position: absolute; left: 8%; right: 8%; top: 27%; height: 2px; z-index: 2;
  background: linear-gradient(90deg, rgb(255 212 0 / 0), var(--gold), rgb(255 212 0 / 0));
  box-shadow: 0 0 10px rgb(255 212 0 / .85);
  animation: quetvach 2.2s ease-in-out infinite;
}
@keyframes quetvach {
  0%, 100% { top: 27%; }
  50% { top: calc(73% - 2px); }
}
/* Bắt được mã rồi thì dừng vạch, đổi khung sang xanh cho biết đã xong */
.cam-frame.ok .cam-line { animation: none; opacity: 0; }
.cam-frame.ok span { border-color: #22c55e; }
@media (prefers-reduced-motion: reduce) { .cam-line { animation: none; } }
