/* Màu sắc theo Cổng thông tin việc làm Hà Nội */
:root {
  --primary: #1d4c90;
  --primary-dark: #183883;
  --primary-50: #eff6ff;
  --primary-100: #dbeafe;
  --primary-200: #bfdbfe;
  --accent: #eab308;
  --danger: #ef4444;
  --ok: #16a34a;
  --text: #333333;
  --muted: #6b7280;
  --bg: #edf0f3;
  --card: #ffffff;
  --border: #e5e7eb;
  --shadow: 0 2px 10px rgba(16, 38, 84, 0.08);
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.5 Roboto, -apple-system, "Segoe UI", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.app {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  height: 100dvh;
  min-height: 560px;
}

/* ===== Đầu trang ===== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 28px;
  /* nền trắng có vệt xanh nhạt bên phải, giống phần đầu cổng thông tin */
  background:
    radial-gradient(ellipse 45% 160% at 100% 50%, var(--primary-100), transparent 70%),
    var(--card);
  border-bottom: 3px solid var(--accent);
}
.brand { display: flex; align-items: center; gap: 16px; min-width: 0; color: inherit; text-decoration: none; }
.brand-text { min-width: 0; }
.logo {
  flex: none;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: #fff;
  font-weight: 900;
  font-size: 16px;
  letter-spacing: .5px;
  box-shadow: inset 0 0 0 3px var(--card), 0 0 0 2px var(--primary);
  overflow: hidden;
}
.logo img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
/* Logo ảnh thật (chữ nhật ngang): bỏ khung tròn */
.logo.has-img {
  display: block;
  width: auto;
  height: auto;
  border-radius: 0;
  background: none;
  box-shadow: none;
  overflow: visible;
}
.logo.has-img img { display: block; width: auto; height: 68px; background: none; }.agency {
  display: flex;
  flex-wrap: wrap;
  gap: 0 8px;
  color: var(--primary);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: .3px;
}
.agency .sep { opacity: .4; }
.system-name {
  margin: 2px 0 0;
  color: var(--primary);
  font-size: clamp(20px, 2.4vw, 30px);
  font-weight: 900;
  line-height: 1.15;
  letter-spacing: .2px;
}
.clock { text-align: right; color: var(--primary); flex: none; }
.clock-time { font-size: 28px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.clock-date { font-size: 14px; color: var(--muted); }

/* ===== Thanh bước ===== */
.stepper { background: var(--primary); padding: 0 28px; }
.stepper ol {
  display: flex;
  margin: 0;
  padding: 0;
  list-style: none;
}
.stepper li {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 8px;
  color: rgba(255, 255, 255, .6);
  font-weight: 500;
  font-size: 18px;
  position: relative;
}
.stepper li + li::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 50%;
  width: 28px;
  border-top: 2px dashed rgba(255, 255, 255, .35);
}
.stepper .dot {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, .5);
  font-weight: 700;
  font-size: 15px;
}
.stepper li.active { color: #fff; }
.stepper li.active .dot { background: #fff; color: var(--primary); border-color: #fff; }
.stepper li.done { color: rgba(255, 255, 255, .9); }
.stepper li.done .dot { background: var(--accent); border-color: var(--accent); color: var(--primary-dark); font-size: 0; }
.stepper li.done .dot::after { content: "✓"; font-size: 16px; }

/* ===== Vùng nội dung ===== */
.main { position: relative; min-height: 0; padding: 20px 28px; overflow: hidden; }
.screen { display: none; height: 100%; animation: fade .25s ease-out; }
.screen.active { display: flex; flex-direction: column; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

h2 { margin: 0; color: var(--primary); font-size: 28px; font-weight: 700; }

.btn {
  font: inherit;
  font-weight: 500;
  border-radius: 10px;
  border: 2px solid transparent;
  padding: 10px 20px;
  cursor: pointer;
  transition: transform .08s, background .15s;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: #fff; color: var(--primary); border-color: var(--primary); }
.btn-ghost { background: transparent; color: var(--primary); }
.btn-ghost:hover { background: var(--primary-100); }
.btn-lg { font-size: 19px; padding: 14px 26px; }
.btn-xl { font-size: 24px; font-weight: 700; padding: 22px 30px; }

/* ===== Màn Chào mừng =====
   Mọi kích thước tính theo em, dựa trên cỡ chữ gốc --wfs của .welcome.
   app.js tự tìm --wfs lớn nhất mà nội dung vẫn vừa khung → tự co giãn theo màn hình. */
body.on-welcome .stepper { display: none; }

.welcome {
  --wfs: 16px;
  font-size: var(--wfs);
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  gap: 2.4em;
  padding: 2.2em 3em;
  border-radius: 20px;
  color: #fff;
  background:
    radial-gradient(ellipse 60% 80% at 0% 100%, rgba(234, 179, 8, .18), transparent 70%),
    radial-gradient(ellipse 70% 90% at 100% 0%, rgba(59, 130, 246, .45), transparent 70%),
    linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  box-shadow: 0 10px 30px rgba(24, 56, 131, .25);
  overflow: hidden;
}
.welcome-main, .welcome-steps { min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
.welcome-main::before, .welcome-main::after,
.welcome-steps::before, .welcome-steps::after { content: ""; margin: auto; }

.welcome-greeting {
  margin: 0;
  color: var(--accent);
  font-size: 1.3em;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
}
.welcome-title {
  margin: .25em 0 0;
  color: #fff;
  font-size: 2.75em;
  font-weight: 900;
  line-height: 1.2;
  text-wrap: balance;
}
.welcome-subtitle {
  margin: .8em 0 0;
  color: rgba(255, 255, 255, .85);
  font-size: 1.25em;
  line-height: 1.45;
}
.welcome-btn {
  align-self: flex-start;
  margin-top: 1.2em;
  padding: .7em 1.6em;
  border-radius: .55em;
  background: #fff;
  color: var(--primary);
  font-size: 1.85em;
  font-weight: 900;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25), 0 0 0 0 rgba(255, 255, 255, .6);
  animation: invite 2.4s ease-in-out infinite;
}
.welcome-btn:hover { background: #fffbea; }
@keyframes invite {
  0%, 100% { box-shadow: 0 8px 24px rgba(0, 0, 0, .25), 0 0 0 0 rgba(255, 255, 255, .55); }
  50% { box-shadow: 0 8px 24px rgba(0, 0, 0, .25), 0 0 0 14px rgba(255, 255, 255, 0); }
}
.welcome-hours {
  margin-top: 1.8em;
  padding: .75em 1em;
  border-left: 4px solid var(--accent);
  background: rgba(255, 255, 255, .08);
  border-radius: 0 10px 10px 0;
  font-size: 1.05em;
  line-height: 1.5;
}
.welcome-hours .label { font-weight: 700; margin-bottom: .15em; }

.welcome-steps {
  padding: 1.6em 1.6em;
  border-radius: 16px;
  background: rgba(255, 255, 255, .1);
  border: 1px solid rgba(255, 255, 255, .18);
}
.welcome-steps h3 { margin: 0 0 .8em; font-size: 1.3em; }
.welcome-steps ol { margin: 0; padding: 0; list-style: none; display: grid; gap: 1em; }
.welcome-steps li { display: flex; align-items: center; gap: .9em; }
.welcome-steps li .n {
  flex: none;
  width: 2.3em;
  height: 2.3em;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #fff;
  color: var(--primary);
  font-weight: 900;
  font-size: 1.2em;
}
.welcome-steps li strong { display: block; font-size: 1.15em; line-height: 1.3; }
.welcome-steps li span:not(.n) { display: block; color: rgba(255, 255, 255, .78); font-size: .92em; line-height: 1.35; }
.welcome-note { margin: 1.1em 0 0; color: rgba(255, 255, 255, .78); font-size: .88em; font-style: italic; }

/* Nút về trang chủ trên khung camera */
.home-btn {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(11, 26, 51, .7);
  color: #fff;
  font-size: 15px;
  backdrop-filter: blur(4px);
}
.home-btn:hover { background: rgba(11, 26, 51, .9); }

/* ===== Bước 1 ===== */
.scan-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  gap: 20px;
}
.camera-card, .guide-card, .info-card, .action-card, .ticket-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.camera-card { padding: 12px; display: flex; min-height: 0; }
.viewport {
  position: relative;
  flex: 1;
  border-radius: 10px;
  overflow: hidden;
  background: #0b1a33;
}
.viewport video, .viewport canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.mirror { transform: scaleX(-1); }

/* Khung ngắm 4 góc */
.frame {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(60%, 70vh);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.frame i { position: absolute; width: 22%; height: 22%; border: 5px solid #fff; }
.frame i:nth-child(1) { top: 0; left: 0; border-right: 0; border-bottom: 0; border-top-left-radius: 14px; }
.frame i:nth-child(2) { top: 0; right: 0; border-left: 0; border-bottom: 0; border-top-right-radius: 14px; }
.frame i:nth-child(3) { bottom: 0; left: 0; border-right: 0; border-top: 0; border-bottom-left-radius: 14px; }
.frame i:nth-child(4) { bottom: 0; right: 0; border-left: 0; border-top: 0; border-bottom-right-radius: 14px; }
.laser {
  position: absolute;
  left: 6%;
  right: 6%;
  height: 3px;
  background: linear-gradient(90deg, transparent, #4ade80, transparent);
  box-shadow: 0 0 10px #4ade80;
  animation: laser 2.2s ease-in-out infinite;
}
@keyframes laser { 0%, 100% { top: 8%; } 50% { top: 92%; } }

.camera-msg {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  background: #0b1a33;
  color: #dbeafe;
  text-align: center;
  font-size: 18px;
}
.camera-msg.hidden { display: none; }
.camera-msg p { margin: 0; max-width: 420px; }
.camera-msg.error { color: #fecaca; }
.camera-msg .icon { font-size: 44px; }
.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(255, 255, 255, .25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Sau khi quét được: thay khung hướng dẫn bằng khung thông tin */
.person-card { display: none; }
.reviewing .guide-card { display: none; }
.reviewing .person-card {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: clamp(16px, 3vh, 26px) clamp(20px, 2.4vw, 30px);
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border-top: 6px solid var(--ok);
  animation: fade .25s ease-out;
  overflow-y: auto;
}
/* Căn giữa theo chiều dọc nhưng không cắt nội dung khi màn hình thấp */
.person-card::before, .person-card::after { content: ""; margin: auto; }
.person-card h2 { font-size: clamp(22px, 3.4vh, 28px); }
.person-card .lead { margin-top: 6px; font-size: clamp(15px, 2.3vh, 20px); }
/* Khi đang kiểm tra: thu hẹp camera, nới rộng khung thông tin (7 trường) */
.reviewing .scan-layout { grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); }
.person-card .info {
  margin: clamp(8px, 1.6vh, 16px) 0 0;
  gap: clamp(4px, 1.1vh, 12px) 24px;
  font-size: clamp(16px, 2.5vh, 22px);
  line-height: 1.35;
}
.person-card .info dd.address { font-weight: 600; }
/* Hai nút nằm ngang: "Quét lại" bên trái, "Tiếp tục" (nút chính, to hơn) bên phải */
.person-actions {
  display: flex;
  flex-direction: row-reverse;
  gap: 12px;
  margin-top: clamp(12px, 2.2vh, 22px);
}
.person-actions .btn { flex: 1; }
.person-actions .btn-xl { flex: 1.6; font-size: clamp(19px, 3vh, 24px); padding: clamp(12px, 2.4vh, 22px) 20px; }
.person-actions .btn-lg { font-size: clamp(16px, 2.3vh, 19px); padding: clamp(10px, 2vh, 18px) 16px; }

.scan-done {
  display: none;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(11, 26, 51, .82);
  color: #fff;
  font-size: 24px;
  font-weight: 700;
}
.scan-done .tick {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--ok);
  font-size: 30px;
}
.reviewing .scan-done { display: flex; }
.reviewing .scan-state, .reviewing .laser { display: none; }
.reviewing .camera-msg { display: none; } /* camera đã tắt, chỉ hiện dấu ✓ */

/* Dòng trạng thái nổi trên camera */
.scan-state {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  border-radius: 999px;
  background: rgba(11, 26, 51, .72);
  color: #fff;
  font-size: 18px;
  font-weight: 500;
  white-space: nowrap;
  backdrop-filter: blur(4px);
}
.pulse {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 0 0 rgba(74, 222, 128, .7);
  animation: ping 1.6s infinite;
}
@keyframes ping { 70% { box-shadow: 0 0 0 10px rgba(74, 222, 128, 0); } 100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); } }

.guide-card {
  padding: clamp(16px, 3vh, 26px) clamp(20px, 2.4vw, 30px);
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 2vh, 18px);
  min-height: 0;
  overflow-y: auto;
}
.guide-card::before, .guide-card::after { content: ""; margin: auto; }
.guide-card h2 { font-size: clamp(22px, 3.4vh, 28px); }
.lead { margin: 0; font-size: clamp(16px, 2.5vh, 20px); }

/* Hai cách quét: thẻ CCCD / ứng dụng VNeID */
.method {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: clamp(10px, 1.8vh, 16px) 16px;
  border: 2px solid var(--primary-100);
  border-radius: 12px;
  background: var(--primary-50);
}
.method-illus {
  flex: none;
  width: clamp(96px, 15vh, 140px);
  height: clamp(70px, 12.5vh, 110px);
}
.method-body { min-width: 0; }
.method-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  color: var(--primary);
  font-size: clamp(17px, 2.6vh, 21px);
  font-weight: 700;
}
.method .tag {
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
}
.method-body p, .method-steps { margin: 4px 0 0; font-size: clamp(15px, 2.2vh, 17px); line-height: 1.4; }
.method-steps { padding-left: 20px; }
.method-steps li { margin: 1px 0; }
.tip { margin: 0; color: var(--muted); font-size: clamp(14px, 2.1vh, 16px); }
@media (max-height: 640px) { .guide-card .lead { display: none; } }

.qr-hint, .qr-hint-phone {
  transform-box: fill-box;
  transform-origin: center;
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 50% { transform: scale(1.08); } }

/* ===== Bước 2 ===== */
.screen-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.greeting { margin: 0 0 4px; font-size: 22px; }
.greeting strong { color: var(--primary); }

.service-grid {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr));
  grid-auto-rows: minmax(clamp(110px, 19vh, 160px), auto);
  gap: 18px;
  align-content: start;
  padding: 2px;
}
.service {
  display: flex;
  align-items: center;
  gap: clamp(14px, 2.4vh, 24px);
  text-align: left;
  padding: clamp(12px, 2.4vh, 24px) clamp(16px, 2vw, 28px);
  background: var(--card);
  border: 2px solid transparent;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font: inherit;
  color: inherit;
  cursor: pointer;
  transition: border-color .15s, transform .08s, background .15s;
}
.service:hover { border-color: var(--primary-200); background: var(--primary-50); }
.service:active { transform: scale(.98); border-color: var(--primary); }
.service .code {
  flex: none;
  width: clamp(54px, 9.5vh, 84px);
  height: clamp(54px, 9.5vh, 84px);
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: #fff;
  font-size: clamp(26px, 4.6vh, 40px);
  font-weight: 900;
}
.service .name { font-size: clamp(18px, 3vh, 24px); font-weight: 700; color: var(--primary); line-height: 1.25; }
.service .desc { margin-top: clamp(2px, .6vh, 6px); color: var(--muted); font-size: clamp(14px, 2.1vh, 17px); line-height: 1.35; }

/* ===== Bước 3: Giấy tờ cần có ===== */
#screen-docs .screen-head { margin-bottom: clamp(10px, 2vh, 18px); }
.docs-lead { margin: 4px 0 0; color: var(--muted); font-size: clamp(16px, 2.4vh, 19px); }
.docs-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  margin: 0;
  padding: 2px;
  list-style: none;
  counter-reset: doc;
  display: grid;
  grid-template-columns: repeat(var(--cols, 1), minmax(0, 1fr));
  gap: clamp(8px, 1.6vh, 14px) 18px;
  align-content: start;
}
.docs-list li {
  counter-increment: doc;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: clamp(12px, 2vh, 18px) 22px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border-left: 6px solid var(--primary);
}
.docs-list li::before {
  content: counter(doc);
  flex: none;
  width: clamp(34px, 5.5vh, 44px);
  height: clamp(34px, 5.5vh, 44px);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--primary-100);
  color: var(--primary);
  font-weight: 900;
  font-size: 20px;
}
.docs-list li.optional { border-left-color: var(--primary-200); }
.doc-name { font-size: clamp(18px, 2.8vh, 22px); font-weight: 700; line-height: 1.3; }
.doc-note { margin-top: 2px; color: var(--muted); font-size: clamp(15px, 2.2vh, 17px); }
.doc-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 10px;
  border-radius: 999px;
  background: #fef9c3;
  color: #854d0e;
  font-size: 14px;
  font-weight: 500;
  vertical-align: middle;
}
.docs-empty {
  display: none;
  flex: 1;
  align-items: center;
  justify-content: center;
  padding: 32px;
  text-align: center;
  font-size: 22px;
  color: var(--primary-dark);
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
#screen-docs.no-docs .docs-list, #screen-docs.no-docs .docs-lead { display: none; }
@media (max-height: 640px) { #screen-docs .docs-lead { display: none; } }
#screen-docs.no-docs .docs-empty { display: flex; }
.docs-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-top: clamp(12px, 2vh, 18px);
}
.docs-actions .btn-xl { min-width: 320px; padding-top: clamp(12px, 2.2vh, 20px); padding-bottom: clamp(12px, 2.2vh, 20px); }

/* ===== Bước 4a ===== */
.confirm-layout {
  flex: none;
  margin: auto 0;
  min-height: 380px;
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 20px;
  align-items: stretch;
}
.info-card { padding: 28px 32px; }
.info {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 16px 28px;
  margin: 24px 0 0;
  font-size: 23px;
}
.info dt { color: var(--muted); }
.info dd { margin: 0; font-weight: 700; overflow-wrap: anywhere; }
.info dd.hl { color: var(--primary); }
.action-card {
  padding: 28px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
}

/* ===== Bước 3b ===== */
#screen-ticket.active { align-items: center; justify-content: center; }
.ticket-card {
  width: min(680px, 100%);
  padding: 32px 44px;
  text-align: center;
  border-top: 8px solid var(--primary);
}
.ticket-label { margin: 0; color: var(--muted); font-weight: 500; letter-spacing: 1px; }
.ticket-number {
  font-size: clamp(90px, 16vh, 150px);
  font-weight: 900;
  line-height: 1.05;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
  animation: pop .4s cubic-bezier(.3, 1.6, .5, 1);
}
@keyframes pop { from { transform: scale(.6); opacity: 0; } }
.ticket-service { margin: 4px 0 0; font-size: 26px; font-weight: 700; }
.ticket-meta { margin: 4px 0 0; color: var(--muted); font-size: 18px; }
.ticket-note {
  margin: 18px 0 0;
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--primary-50);
  color: var(--primary-dark);
  font-size: 20px;
  font-weight: 500;
}
.ticket-actions { display: flex; justify-content: center; gap: 14px; margin-top: 20px; flex-wrap: wrap; }
.countdown { margin: 14px 0 0; color: var(--muted); font-size: 16px; }

/* ===== Chân trang, thông báo ===== */
.footer {
  padding: 8px 28px;
  text-align: center;
  font-size: 14px;
  color: var(--muted);
  background: var(--card);
  border-top: 1px solid var(--border);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 56px;
  transform: translate(-50%, 20px);
  max-width: calc(100% - 32px);
  padding: 14px 24px;
  border-radius: 12px;
  background: #b91c1c;
  color: #fff;
  font-size: 18px;
  font-weight: 500;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .2);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.flash {
  position: fixed;
  inset: 0;
  background: #22c55e;
  opacity: 0;
  pointer-events: none;
  transition: opacity .4s ease-out;
}
.flash.on { opacity: .25; transition: none; }

/* ===== Màn hình nhỏ / dọc (dự phòng) ===== */
/* Màn hình thấp (laptop, trình duyệt có thanh công cụ): thu gọn đầu trang */
@media (max-height: 760px) {
  .header { padding-top: 8px; padding-bottom: 8px; }
  .logo { width: 52px; height: 52px; }
  .logo.has-img img { height: 54px; }
  .system-name { font-size: clamp(18px, 2.1vw, 26px); }
  .stepper li { padding: 8px; }
  .main { padding-top: 14px; padding-bottom: 14px; }
}

@media (max-width: 860px), (orientation: portrait), (max-height: 500px) {
  .app { height: auto; min-height: 100dvh; }
  .main { overflow: visible; }
  .scan-layout, .confirm-layout { grid-template-columns: minmax(0, 1fr); }
  .service-grid { grid-template-columns: minmax(0, 1fr); }
  .welcome { grid-template-columns: minmax(0, 1fr); }
  .camera-card { aspect-ratio: 4 / 3; }
  .stepper li { font-size: 14px; }
  .clock { display: none; }
  .header, .stepper, .main { padding-left: 16px; padding-right: 16px; }
}

/* ===== Điện thoại (người dân tự dùng trên máy mình) =====
   Bố cục một cột, cuộn dọc, chữ và nút vừa ngón tay. Kiosk/máy tính bảng không bị ảnh hưởng. */
@media (max-width: 600px), (max-height: 500px) {
  body { font-size: 15px; }
  h2 { font-size: 21px; }
  .btn-xl { font-size: 19px; padding: 15px 18px; }
  .btn-lg { font-size: 17px; padding: 12px 18px; }
  .screen { height: auto; }
  .main { padding: 12px; }

  /* Đầu trang gọn: logo nhỏ, chỉ giữ tên trung tâm và tên hệ thống */
  .header { padding: 8px 12px; gap: 10px; border-bottom-width: 2px; }
  .brand { gap: 10px; }
  .logo.has-img img { height: 40px; }
  .logo { width: 40px; height: 40px; font-size: 11px; }
  .agency { font-size: 10.5px; letter-spacing: 0; }
  #parentAgency, .agency .sep { display: none; }
  .system-name { font-size: 15px; letter-spacing: 0; }

  /* Thanh bước: chỉ hiện chữ của bước đang làm, các bước khác chỉ còn số */
  .stepper { padding: 0 8px; }
  .stepper li { font-size: 0; gap: 0; padding: 8px 2px; }
  .stepper li.active { flex: 2.6; font-size: 13.5px; gap: 6px; white-space: nowrap; }
  .stepper .dot { width: 26px; height: 26px; font-size: 13px; }
  .stepper li + li::before { left: -10px; width: 20px; }

  /* Màn Chào mừng: cỡ chữ cố định (app.js không tự co giãn trên điện thoại) */
  .welcome { --wfs: 15px; gap: 1.4em; padding: 1.5em 1.25em; border-radius: 16px; }
  .welcome-main, .welcome-steps { overflow: visible; }
  .welcome-title { font-size: 1.85em; }
  .welcome-subtitle { font-size: 1.05em; }
  .welcome-btn { align-self: stretch; margin-top: 1.1em; font-size: 1.35em; padding: .75em 1em; }
  .welcome-hours { margin-top: 1.2em; font-size: .95em; }
  .welcome-steps { padding: 1.2em 1.1em; }

  /* Bước 1 */
  .scan-layout { gap: 12px; }
  .camera-card { aspect-ratio: 1; padding: 8px; }
  .frame { width: 68%; }
  .frame i { border-width: 4px; }
  .scan-state { bottom: 12px; padding: 8px 14px; font-size: 14px; }
  .home-btn { top: 8px; left: 8px; padding: 6px 12px; font-size: 14px; }
  .camera-msg { font-size: 15px; padding: 16px; }
  .guide-card, .reviewing .person-card { padding: 18px 16px; gap: 12px; }
  .guide-card::before, .guide-card::after, .person-card::before, .person-card::after { display: none; }
  .guide-card h2, .person-card h2 { font-size: 21px; }
  .lead, .person-card .lead { font-size: 15px; }
  .method { gap: 12px; padding: 10px 12px; }
  .method-illus { width: 76px; height: 58px; }
  .method-title { font-size: 16px; }
  .method-body p, .method-steps, .tip { font-size: 14px; }
  /* Đã đọc được CCCD: ẩn camera để thông tin và nút hiện ngay trên màn hình */
  .reviewing .scan-layout { grid-template-columns: minmax(0, 1fr); }
  .reviewing .camera-card { display: none; }
  .person-card .info { margin-top: 12px; gap: 6px 14px; font-size: 16px; }
  .person-actions { flex-direction: column; gap: 10px; margin-top: 16px; }
  .person-actions .btn, .person-actions .btn-xl, .person-actions .btn-lg { flex: none; width: 100%; }
  .person-actions .btn-xl { font-size: 19px; padding: 15px 18px; }
  .person-actions .btn-lg { font-size: 16px; padding: 12px 16px; }

  /* Bước 2–3: nút quay lại lên đầu, danh sách một cột */
  .screen-head { flex-direction: column; align-items: stretch; gap: 10px; margin-bottom: 14px; }
  .screen-head > .btn { order: -1; align-self: flex-start; padding: 6px 14px; font-size: 15px; }
  .greeting { font-size: 16px; }
  .service-grid { grid-auto-rows: auto; gap: 10px; overflow: visible; }
  .service { gap: 14px; padding: 14px; }
  .service .code { width: 48px; height: 48px; border-radius: 12px; font-size: 24px; }
  .service .name { font-size: 17px; }
  .service .desc { font-size: 14px; }
  .docs-lead { font-size: 15px; }
  .docs-list { grid-template-columns: minmax(0, 1fr); gap: 10px; overflow: visible; }
  .docs-list li { gap: 12px; padding: 12px 14px; border-left-width: 5px; }
  .docs-list li::before { width: 32px; height: 32px; font-size: 16px; }
  .doc-name { font-size: 16px; }
  .doc-note { font-size: 14px; }
  .doc-badge { font-size: 12px; }
  .docs-empty { padding: 20px; font-size: 17px; }
  .docs-actions { flex-direction: column-reverse; align-items: stretch; gap: 10px; margin-top: 14px; }
  .docs-actions .btn-xl { min-width: 0; padding-top: 15px; padding-bottom: 15px; }

  /* Bước 4 */
  .confirm-layout { min-height: 0; margin: 0; gap: 12px; }
  .info-card { padding: 18px 16px; }
  .info { margin-top: 14px; gap: 8px 14px; font-size: 16px; }
  .action-card { padding: 16px; gap: 10px; }
  #screen-ticket.active { justify-content: flex-start; }
  .ticket-card { padding: 22px 16px; border-top-width: 6px; }
  .ticket-label { font-size: 14px; }
  .ticket-number { font-size: 96px; }
  .ticket-service { font-size: 19px; }
  .ticket-meta { font-size: 14px; }
  .ticket-note { margin-top: 14px; padding: 10px 12px; font-size: 15px; }
  .ticket-actions { flex-direction: column; gap: 10px; }
  .ticket-actions .btn { width: 100%; }
  .countdown { font-size: 14px; }

  .footer { padding: 8px 12px; font-size: 12px; }
  .toast { bottom: 20px; padding: 12px 16px; font-size: 15px; }
}
/* Điện thoại xoay ngang: khung camera không cao quá màn hình */
@media (max-height: 500px) {
  .camera-card { aspect-ratio: auto; height: 82dvh; }
}

/* ===== Phiếu in 80mm ===== */
.print-ticket { display: none; }

@media print {
  @page { size: 80mm auto; margin: 0; }
  body { background: #fff; }
  .app, .toast, .flash { display: none !important; }
  .print-ticket {
    display: block;
    width: 72mm;
    margin: 0 auto;
    padding: 4mm 0 6mm;
    color: #000;
    font: 11pt/1.35 Roboto, Arial, sans-serif;
    text-align: center;
  }
  .pt-small { font-size: 8.5pt; }
  .pt-unit { font-size: 10pt; font-weight: 700; }
  .pt-rule { border-top: 1px dashed #000; margin: 3mm 0; }
  .pt-title { font-size: 12pt; font-weight: 700; letter-spacing: .5px; }
  .pt-number { font-size: 54pt; font-weight: 900; line-height: 1.1; }
  .pt-service { font-size: 12pt; font-weight: 700; }
  .pt-info { width: 100%; border-collapse: collapse; text-align: left; font-size: 10pt; }
  .pt-info td { padding: 0.6mm 0; vertical-align: top; }
  .pt-info td:first-child { width: 20mm; }
  .pt-note { font-size: 9.5pt; font-style: italic; }
  .pt-docs-title { text-align: left; font-size: 10pt; font-weight: 700; }
  .pt-docs { margin: 1mm 0 0; padding-left: 5mm; text-align: left; font-size: 9.5pt; }
  .pt-docs li { margin: 0.5mm 0; }
}
