/* Voucher Grab × TMT — giao diện (không phụ thuộc CDN) */
:root {
  --green-900: #002912; --green-800: #002D14; --green-700: #00461E; --green-600: #003818;
  --grab: #00B14F; --grab-hover: #009642;
  --gold-light: #E8CA8B; --gold: #C9A25B; --gold-dark: #9D7637;
  --bg: #F2F6F3; --text: #0F2418; --muted: #64748B; --line: #E2E8E4;
  --red: #DC2626; --red-bg: #FEF2F2; --amber: #B45309; --amber-bg: #FFFBEB; --blue: #1D4ED8; --blue-bg: #EFF6FF;
  --ok-bg: #ECFDF5; --ok: #047857;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; -webkit-font-smoothing: antialiased; }
a { color: var(--green-700); }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ---------- buttons & inputs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid transparent; border-radius: 10px; padding: 9px 14px; font: inherit; font-weight: 600; font-size: 13px; cursor: pointer; transition: background .15s; text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--grab); color: #fff; } .btn-primary:hover { background: var(--grab-hover); }
.btn-dark { background: var(--green-700); color: #fff; } .btn-dark:hover { background: var(--green-600); }
.btn-ghost { background: #fff; color: #334155; border-color: #CBD5E1; } .btn-ghost:hover { background: #F8FAFC; }
.btn-gold { background: var(--amber-bg); color: var(--amber); border-color: #FCD34D; }
.btn-danger { background: var(--red-bg); color: var(--red); border-color: #FECACA; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.btn-block { width: 100%; padding: 12px; }
.link { background: none; border: 0; padding: 0; font: inherit; font-size: 12px; font-weight: 600; color: var(--green-700); cursor: pointer; }
.link:hover { text-decoration: underline; } .link.red { color: var(--red); } .link.amber { color: var(--amber); }

label { display: block; font-size: 13px; font-weight: 600; color: #334155; }
label > input, label > select, label > textarea { margin-top: 6px; }
input, select, textarea { width: 100%; padding: 10px 12px; border: 1px solid #CBD5E1; border-radius: 10px; font: inherit; font-size: 14px; background: #fff; color: var(--text); outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--green-700); box-shadow: 0 0 0 3px rgba(0, 177, 79, .15); }
input.code { text-transform: uppercase; font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 700; letter-spacing: .5px; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--green-700); margin: 0; flex-shrink: 0; }
.req { color: var(--red); }
.check { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border-radius: 12px; background: var(--ok-bg); border: 1px solid #A7F3D0; font-weight: 500; font-size: 12.5px; line-height: 1.5; cursor: pointer; }
.stack > * + * { margin-top: 14px; }
.row { display: flex; gap: 8px; align-items: center; }
.row > .grow { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 760px) { .grid2, .grid3 { grid-template-columns: 1fr; } .grid4 { grid-template-columns: 1fr 1fr; } }

/* ---------- alerts ---------- */
.alert { padding: 10px 12px; border-radius: 10px; font-size: 12.5px; font-weight: 500; border: 1px solid; line-height: 1.5; }
.alert-err { background: var(--red-bg); color: #B91C1C; border-color: #FECACA; }
.alert-ok { background: var(--ok-bg); color: var(--ok); border-color: #A7F3D0; }
.alert-warn { background: var(--amber-bg); color: var(--amber); border-color: #FDE68A; }
.alert-info { background: var(--blue-bg); color: var(--blue); border-color: #BFDBFE; }

/* ---------- login ---------- */
.login-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; background: radial-gradient(120% 100% at 10% 0%, #005C28 0%, #003818 55%, #00210E 100%); }
.login-card { width: 100%; max-width: 420px; background: #fff; border-radius: 18px; overflow: hidden; box-shadow: 0 20px 50px rgba(0,0,0,.35); }
.login-head { padding: 26px 22px; text-align: center; background: radial-gradient(120% 100% at 10% 0%, #005C28 0%, #003818 55%, #00210E 100%); border-bottom: 2px solid var(--gold); color: #fff; }
.login-head h1 { margin: 12px 0 4px; font-size: 17px; letter-spacing: .5px; }
.login-head p { margin: 0; color: var(--gold-light); font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px; font-weight: 600; }
.logo-lg { height: 28px; max-width: 100%; }
.login-form { padding: 24px; }
.keybox { background: #0F172A; color: #A7F3D0; padding: 12px; border-radius: 10px; word-break: break-all; white-space: pre-wrap; font-size: 13px; }

/* ---------- app shell ---------- */
.topbar { position: sticky; top: 0; z-index: 30; background: var(--green-800); color: #fff; border-bottom: 1px solid rgba(201,162,91,.4); }
.topbar-inner { max-width: 1280px; margin: 0 auto; padding: 0 16px; height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand img { height: 22px; }
.pill-gold { font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 99px; background: rgba(201,162,91,.18); color: var(--gold-light); border: 1px solid rgba(201,162,91,.4); white-space: nowrap; }
.userbox { text-align: right; line-height: 1.25; }
.userbox b { font-size: 12.5px; display: block; } .userbox span { font-size: 11px; color: var(--gold-light); }
.icon-btn { background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.15); color: #fff; border-radius: 9px; padding: 7px 10px; cursor: pointer; font: inherit; font-size: 12px; font-weight: 600; }
.icon-btn:hover { background: rgba(255,255,255,.18); }
@media (max-width: 640px) { .pill-gold, .userbox { display: none; } }

.tabs { position: sticky; top: 58px; z-index: 20; background: #fff; border-bottom: 1px solid var(--line); box-shadow: 0 1px 3px rgba(0,0,0,.04); }
.tabs-inner { max-width: 1280px; margin: 0 auto; padding: 8px 12px; display: flex; gap: 6px; overflow-x: auto; }
.tab { flex-shrink: 0; background: none; border: 0; padding: 9px 14px; border-radius: 10px; font: inherit; font-weight: 600; font-size: 13px; color: #475569; cursor: pointer; }
.tab:hover { background: #F1F5F9; }
.tab.active { background: var(--green-700); color: #fff; box-shadow: 0 2px 8px rgba(0,70,30,.25); }

main { max-width: 1280px; margin: 0 auto; padding: 20px 16px 60px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 1px 2px rgba(0,0,0,.03); padding: 20px; }
.card + .card { margin-top: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap; padding-bottom: 12px; margin-bottom: 16px; border-bottom: 1px solid #F1F5F9; }
.card-head h2 { margin: 0; font-size: 17px; color: var(--green-600); }
.card-head h3 { margin: 0; font-size: 14px; color: var(--green-600); }
.card-head p { margin: 3px 0 0; font-size: 12px; color: var(--muted); }
.section-title { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin: 0 0 10px; }
.layout { display: grid; grid-template-columns: 7fr 5fr; gap: 18px; align-items: start; }
@media (max-width: 980px) { .layout { grid-template-columns: 1fr; } }
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.b-available { background: #F1F5F9; color: #475569; }
.b-issued { background: #DBEAFE; color: #1E40AF; }
.b-used { background: #D1FAE5; color: #065F46; }
.b-expired { background: #FEE2E2; color: #991B1B; }
.b-void { background: #E5E7EB; color: #374151; text-decoration: line-through; }
.b-unit { background: var(--ok-bg); color: var(--green-700); border: 1px solid #A7F3D0; }
.b-pending { background: var(--amber-bg); color: var(--amber); } .b-matched { background: #D1FAE5; color: #065F46; } .b-mismatch { background: #FEE2E2; color: #991B1B; }

/* ---------- voucher card (giữ nhận diện bản demo) ---------- */
.vcard { position: relative; overflow: hidden; border-radius: 18px; padding: 22px; color: #fff; border: 1px solid rgba(201,162,91,.5); box-shadow: 0 10px 30px rgba(0,40,18,.25);
  background: radial-gradient(120% 100% at 10% 0%, #005C28 0%, #003818 55%, #00210E 100%); }
.vcard::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(135deg, rgba(232,202,139,.08) 0%, transparent 45%, rgba(0,177,79,.08) 100%); }
.vcard > * { position: relative; z-index: 1; }
.vcard-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 14px; }
.vcard-top img { height: 18px; }
.vcard-badge { font-size: 11px; font-weight: 700; padding: 2px 10px; border-radius: 99px; background: rgba(255,255,255,.15); color: var(--gold-light); border: 1px solid rgba(201,162,91,.5); }
.vcard-title { text-align: center; font-size: 11.5px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; }
.vcard-pill { display: flex; justify-content: center; margin: 10px 0; }
.vcard-pill span { background: #fff; color: var(--green-600); border: 2px solid var(--gold); border-radius: 99px; padding: 5px 14px; font-weight: 800; font-family: ui-monospace, Menlo, monospace; font-size: 14px; }
.gold-text { background: linear-gradient(180deg, #F3DCAA 0%, #D4AE6A 55%, #B18743 100%); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.vcard-value { text-align: center; font-size: 36px; font-weight: 800; letter-spacing: -.5px; }
.vcard-model { text-align: center; margin-top: 6px; font-size: 11px; }
.vcard-model b { background: #fff; color: var(--green-600); padding: 2px 10px; border-radius: 99px; border: 1px solid var(--gold); }
.vcard-cond { margin-top: 14px; padding: 10px 12px; border-radius: 12px; background: rgba(0,0,0,.2); border: 1px solid rgba(201,162,91,.4); font-size: 11px; line-height: 1.6; }
.vcard-cond b { color: var(--gold-light); text-transform: uppercase; }
.vcard-foot { display: flex; justify-content: space-between; margin-top: 10px; padding-top: 8px; border-top: 1px solid rgba(255,255,255,.1); font-size: 11px; color: var(--gold-light); gap: 8px; }

/* ---------- info panels ---------- */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 600; }
.mini-list > div { padding: 10px; border-radius: 10px; background: #F8FAFC; border: 1px solid #EEF2F7; font-size: 12px; }
.mini-list > div + div { margin-top: 8px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -20px; }
table { width: 100%; border-collapse: collapse; }
th { background: #F8FAFC; text-align: left; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 14px; border-bottom: 1px solid #F1F5F9; font-size: 13px; vertical-align: top; }
tr:hover td { background: #FAFCFB; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding-top: 12px; font-size: 12px; color: var(--muted); }
.filters { display: grid; grid-template-columns: 2fr repeat(4, 1fr); gap: 10px; }
@media (max-width: 900px) { .filters { grid-template-columns: 1fr 1fr; } }

/* ---------- stats ---------- */
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.kpi small { font-size: 12px; color: var(--muted); font-weight: 600; } .kpi b { display: block; font-size: 26px; margin-top: 4px; color: var(--green-600); } .kpi span { font-size: 11.5px; color: var(--muted); }
.bar { height: 8px; background: #EEF2F7; border-radius: 99px; overflow: hidden; display: flex; min-width: 120px; }
.bar i { display: block; height: 100%; }
.bar .s-used { background: var(--grab); } .bar .s-issued { background: #2563EB; } .bar .s-expired { background: #F87171; } .bar .s-avail { background: #CBD5CE; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); margin-bottom: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* ---------- modal & toast ---------- */
.modal { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-box { background: #fff; border-radius: 16px; width: 100%; max-width: 520px; max-height: 92vh; overflow: auto; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.modal-box.wide { max-width: 760px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; background: var(--green-600); color: #fff; position: sticky; top: 0; z-index: 1; }
.modal-head h3 { margin: 0; font-size: 15px; }
.modal-head button { background: none; border: 0; color: #fff; font-size: 22px; cursor: pointer; line-height: 1; }
.modal-body { padding: 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 0 18px 18px; }
#toasts { position: fixed; top: 14px; right: 14px; z-index: 80; display: flex; flex-direction: column; gap: 8px; max-width: 380px; }
.toast { padding: 12px 14px; border-radius: 12px; color: #fff; font-size: 13px; font-weight: 500; box-shadow: 0 8px 24px rgba(0,0,0,.2); animation: fadeIn .2s ease-out; }
.toast.success { background: var(--green-700); } .toast.error { background: var(--red); } .toast.warning { background: #D97706; } .toast.info { background: #111827; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
#qr-reader { width: 100%; min-height: 260px; background: #0F172A; border-radius: 12px; overflow: hidden; }

/* ---------- print sheet (QR) ---------- */
#print-area { display: none; }
@media print {
  @page { size: A4; margin: 8mm; }
  body.printing > *:not(#print-area) { display: none !important; }
  body.printing { background: #fff; }
  body.printing #print-area { display: block; }
}
.print-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4mm; }
.ptile { border: 1px dashed #999; border-radius: 3mm; padding: 3mm; display: flex; gap: 3mm; align-items: center; page-break-inside: avoid; break-inside: avoid; font-size: 8.5pt; color: #000; }
.ptile img { width: 24mm; height: 24mm; image-rendering: pixelated; }
.ptile b { display: block; font-family: ui-monospace, Menlo, monospace; font-size: 9.5pt; }
.ptile small { display: block; font-size: 7.5pt; color: #333; }
@media (max-width: 640px) {
  .topbar-inner { padding: 0 10px; gap: 6px; }
  .brand img { height: 15px; }
  .icon-btn { padding: 6px 8px; font-size: 11px; }
  .card { padding: 16px; } .table-wrap { margin: 0 -16px; }
}
