/* CSS จาก index.html */
:root { color-scheme: light dark; }
[hidden] { display: none !important; }
body { font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif; margin: 0; }
.wrap { max-width: 720px; margin: 0 auto; padding: 16px; box-sizing: border-box; }
.card { border: 1px solid #e5e7eb; border-radius: 16px; padding: 20px; box-sizing: border-box; }
.brand { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 16px; }
.logo { height: 100px; width: auto; display: block; object-fit: contain; }
.title { font-size: 1.5rem; font-weight: 700; margin: 0 0 12px; }
.muted { color: #6b7280; font-size: 0.95rem; }
.row { display: grid; grid-template-columns: 1fr auto; gap: 14px; margin-top: 20px; }
.btn-group { display: flex; gap: 8px; }
input[type="text"] { font-size: 1rem; padding: 12px 14px; border: 1px solid #d1d5db; border-radius: 12px; width: 100%; box-sizing: border-box; min-width: 0; }
button { padding: 12px 16px; border: 0; border-radius: 12px; cursor: pointer; font-weight: 600; box-sizing: border-box; }
.btn { background: #111827; color: #fff; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn--secondary { background: #6b7280; color: #fff; }
.btn .icon { width: 18px; height: 18px; display: block; fill: currentColor; }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.result { margin-top: 22px; }
.grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
.item { border: 1px solid #e5e7eb; border-radius: 12px; padding: 14px 16px; }
.label { font-size: 0.85rem; color: #6b7280; }
.value { font-size: 1.05rem; font-weight: 600; margin-top: 2px; }
.sn { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.badge { display: inline-block; padding: 6px 10px; font-size: .85rem; border-radius: 999px; background: #f3f4f6; }
.badge--ok { background: #10b981; color: #fff; }
.badge--expired { background: #ef4444; color: #fff; }
.loading { display: flex; align-items: center; gap: 8px; color: #6b7280; margin-top: 16px; }
.spinner { width: 16px; height: 16px; border: 2px solid #e5e7eb; border-top-color: #111827; border-radius: 999px; animation: spin 1s linear infinite; }
.center { text-align: center; }
.fade { animation: fade .2s ease-in-out; }
@keyframes fade { from { opacity: .0; transform: translateY(6px);} to { opacity: 1; transform: translateY(0);} }
@keyframes spin { to { transform: rotate(360deg);} }
@media (max-width: 520px) { 
  .wrap { padding: 12px; }
  .card { padding: 16px; }
  .row { grid-template-columns: 1fr; gap: 12px; } 
  .btn-group { flex-direction: row; }
  .btn { flex: 1; }
  input[type="text"] { font-size: 1rem; }
  .title { font-size: 1.3rem; }
  .logo { height: 80px; }
  .qr-modal__content { width: 95vw; max-height: 85vh; }
  .qr-modal__header, .qr-modal__body, .qr-modal__footer { padding: 16px; }
}
@media (max-width: 400px) {
  .wrap { padding: 8px; }
  .card { padding: 12px; }
  input[type="text"] { font-size: 16px; padding: 10px 12px; }
  .btn { padding: 10px 14px; font-size: 0.95rem; }
  .title { font-size: 1.2rem; }
  .logo { height: 70px; }
  .qr-modal__content { width: 98vw; max-height: 90vh; }
  .qr-modal__header, .qr-modal__body, .qr-modal__footer { padding: 12px; }
}
.footer { margin-top: 32px; font-size: .9rem; color: #6b7280; text-align: center; }
.photo { border: 1px solid #e5e7eb; border-radius: 12px; padding: 14px 16px; }
.photo__img { width: 100%; max-height: 360px; object-fit: contain; border-radius: 8px; background: #f9fafb; }
.photo__caption { font-size: 0.85rem; color: #6b7280; margin-top: 8px; }

/* QR Scanner Modal */
.qr-modal { position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; }
.qr-modal__backdrop { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.8); }
.qr-modal__content { position: relative; background: #fff; border-radius: 16px; max-width: 500px; width: 90vw; max-height: 80vh; display: flex; flex-direction: column; overflow: hidden; }
.qr-modal__header { display: flex; align-items: center; justify-content: space-between; padding: 20px; border-bottom: 1px solid #e5e7eb; }
.qr-modal__header h3 { margin: 0; font-size: 1.25rem; font-weight: 600; }
.qr-modal__close { background: none; border: none; padding: 8px; cursor: pointer; border-radius: 8px; color: #6b7280; }
.qr-modal__close:hover { background: #f3f4f6; }
.qr-modal__body { flex: 1; padding: 20px; display: flex; flex-direction: column; align-items: center; min-height: 300px; }
.qr-reader { width: 100%; max-width: 420px; border-radius: 12px; overflow: hidden; background: #000; position: relative; aspect-ratio: 3 / 4; display:flex; align-items:center; justify-content:center; }
/* Force internal scan region + video to center & fill */
#qr-reader__scan_region { width:100% !important; height:100% !important; display:flex; align-items:center; justify-content:center; position:relative; }
#qr-reader__scan_region video { width:100% !important; height:100% !important; object-fit:cover; }
#qr-reader__dashboard_section_csr { display:none !important; }
.qr-status { margin-top: 16px; color: #6b7280; text-align: center; }
.qr-modal__footer { padding: 20px; border-top: 1px solid #e5e7eb; display: flex; justify-content: center; gap: 12px; }
.qr-controls { width:100%; margin-top:14px; }
.qr-controls__row { display:flex; align-items:center; gap:8px; margin-top:6px; }
.qr-label { font-size:0.75rem; color:#6b7280; text-transform:uppercase; letter-spacing:.5px; }
.qr-select { flex:1; padding:8px 10px; border:1px solid #d1d5db; border-radius:8px; font-size:.85rem; background:#fff; }
.btn--xs { padding:6px 10px; font-size:.7rem; }
.qr-focus-status { font-size:.75rem; color:#111827; background:#f3f4f6; padding:4px 8px; border-radius:6px; }