/* ==========================================================================
   ระบบอ่านบัตรประชาชน — สไตล์ชีตหลัก
   แนวคิด: หยิบยืมโทนสีจากตัวบัตรประชาชนไทยจริง (น้ำเงินราชการ + ทองตราครุฑ)
   มาออกแบบเป็นหน้าจอ "เครื่องอ่านบัตรดิจิทัล" ให้ความรู้สึกเป็นทางการแต่ทันสมัย
   ========================================================================== */

:root {
  --navy-900: #0F2148;
  --navy-800: #16305E;
  --navy-700: #1F3F73;
  --navy-600: #2A5090;
  --gold-500: #C9A227;
  --gold-400: #DDBB4C;
  --gold-300: #E9CE7C;
  --cream-100: #F7F4EC;
  --cream-50: #FCFBF7;
  --ink-900: #16181D;
  --ink-600: #565B66;
  --ink-400: #8A8F99;
  --line-200: #E4E1D6;
  --success-600: #1E8E5A;
  --success-100: #E4F5EC;
  --danger-600: #C0392B;
  --danger-100: #FBEAE8;
  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 9px;
  --shadow-soft: 0 20px 60px -20px rgba(15, 33, 72, 0.35);
  --shadow-pop: 0 30px 80px -24px rgba(15, 33, 72, 0.55);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "Prompt", "Segoe UI", sans-serif;
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(201, 162, 39, 0.10), transparent 60%),
    radial-gradient(1000px 700px at 110% 10%, rgba(31, 63, 115, 0.14), transparent 55%),
    var(--cream-100);
  color: var(--ink-900);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 32px;
  background: linear-gradient(135deg, var(--navy-900), var(--navy-700));
  color: var(--cream-50);
  box-shadow: var(--shadow-soft);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-emblem {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--gold-300), var(--gold-500) 70%);
  display: grid;
  place-items: center;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.35);
  flex-shrink: 0;
}

.brand-emblem svg { width: 20px; height: 20px; fill: var(--navy-900); }

.brand-text .title { font-weight: 600; font-size: 17px; letter-spacing: 0.2px; }
.brand-text .subtitle { font-size: 12.5px; color: rgba(247,244,236,0.65); font-weight: 300; }

.status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 400;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.14);
  padding: 7px 14px;
  border-radius: 999px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-link {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 400;
  color: rgba(247,244,236,0.85);
  text-decoration: none;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid transparent;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.topbar-link:hover { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.14); }
.topbar-link svg { width: 15px; height: 15px; }

.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--success-600);
  box-shadow: 0 0 0 3px rgba(30,142,90,0.25);
  animation: pulse-dot 2.4s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 3px rgba(30,142,90,0.25); }
  50%      { box-shadow: 0 0 0 6px rgba(30,142,90,0.12); }
}

/* ---------- Hero / scanner ---------- */
.hero {
  max-width: 980px;
  margin: 0 auto;
  padding: 56px 24px 40px;
  text-align: center;
}

.eyebrow {
  display: inline-block;
  font-size: 12.5px;
  letter-spacing: 1.5px;
  font-weight: 500;
  color: var(--navy-700);
  background: rgba(31,63,115,0.08);
  border: 1px solid rgba(31,63,115,0.14);
  padding: 6px 14px;
  border-radius: 999px;
  margin-bottom: 18px;
}

.hero h1 {
  font-size: clamp(28px, 4vw, 40px);
  font-weight: 600;
  margin: 0 0 10px;
  color: var(--navy-900);
  letter-spacing: -0.2px;
}

.hero p.lead {
  font-size: 15.5px;
  font-weight: 300;
  color: var(--ink-600);
  max-width: 560px;
  margin: 0 auto 44px;
  line-height: 1.7;
}

/* ---- signature illustration: card reader slot ---- */
.scanner {
  position: relative;
  width: min(420px, 90%);
  margin: 0 auto 36px;
  padding-top: 46px;
}

.scanner-device {
  position: relative;
  height: 190px;
  border-radius: 20px 20px 34px 34px;
  background: linear-gradient(160deg, var(--navy-800), var(--navy-900));
  box-shadow: var(--shadow-pop);
  overflow: visible;
}

.scanner-slot {
  position: absolute;
  top: 34px;
  left: 50%;
  transform: translateX(-50%);
  width: 86%;
  height: 10px;
  border-radius: 6px;
  background: #060E22;
  box-shadow: inset 0 3px 6px rgba(0,0,0,0.6);
}

.scanner-led {
  position: absolute;
  top: 18px;
  right: 26px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold-400);
  box-shadow: 0 0 10px 2px rgba(221,187,76,0.7);
}

.id-card {
  position: absolute;
  top: -46px;
  left: 50%;
  width: 230px;
  height: 145px;
  transform: translateX(-50%);
  border-radius: 12px;
  background: linear-gradient(160deg, var(--cream-50), #EFEAD9);
  box-shadow: 0 18px 36px -14px rgba(15,33,72,0.45), 0 0 0 1px rgba(15,33,72,0.06);
  overflow: hidden;
  animation: float 4.5s ease-in-out infinite;
}

.id-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 30px;
  background: linear-gradient(90deg, var(--navy-800), var(--navy-700));
}

.id-card::after {
  content: "";
  position: absolute;
  top: 42px; left: 14px;
  width: 46px; height: 56px;
  border-radius: 6px;
  background: linear-gradient(160deg, #DCE4F2, #B9C6DE);
}

.id-card .id-lines {
  position: absolute;
  top: 46px; left: 68px; right: 14px;
}
.id-card .id-lines span {
  display: block;
  height: 6px;
  border-radius: 3px;
  background: rgba(22,24,29,0.14);
  margin-bottom: 8px;
}
.id-card .id-lines span:nth-child(1) { width: 90%; }
.id-card .id-lines span:nth-child(2) { width: 70%; }
.id-card .id-lines span:nth-child(3) { width: 80%; background: rgba(201,162,39,0.4); }

.id-card .chip {
  position: absolute;
  bottom: 16px; left: 14px;
  width: 26px; height: 19px;
  border-radius: 4px;
  background: linear-gradient(160deg, var(--gold-300), var(--gold-500));
}

.scan-line {
  position: absolute;
  left: 6%;
  width: 88%;
  height: 3px;
  top: -46px;
  border-radius: 3px;
  background: linear-gradient(90deg, transparent, var(--gold-400), transparent);
  opacity: 0;
  box-shadow: 0 0 14px 2px rgba(221,187,76,0.55);
}

body.is-scanning .id-card { animation: none; top: -14px; transition: top 0.6s var(--ease-out); }
body.is-scanning .scan-line {
  opacity: 1;
  animation: scan-sweep 1.15s ease-in-out infinite;
}

@keyframes scan-sweep {
  0%   { top: -40px; }
  50%  { top: 88px; }
  100% { top: -40px; }
}

@keyframes float {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50%      { transform: translateX(-50%) translateY(-6px); }
}

.scan-button {
  font-family: inherit;
  font-size: 15.5px;
  font-weight: 500;
  color: var(--cream-50);
  background: linear-gradient(135deg, var(--navy-700), var(--navy-900));
  border: none;
  padding: 15px 34px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 16px 32px -12px rgba(15,33,72,0.55);
  transition: transform 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out);
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.scan-button:hover { transform: translateY(-2px); box-shadow: 0 20px 40px -14px rgba(15,33,72,0.6); }
.scan-button:active { transform: translateY(0); }
.scan-button:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.scan-button svg { width: 18px; height: 18px; }

.hint {
  margin-top: 14px;
  font-size: 12.5px;
  color: var(--ink-400);
  font-weight: 300;
}

/* ---------- 3-step usage guide ---------- */
.steps {
  max-width: 640px;
  margin: 0 auto 56px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
}
.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}
.step-icon {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--cream-50);
  border: 1px solid var(--line-200);
  display: grid;
  place-items: center;
  color: var(--navy-700);
  box-shadow: 0 8px 20px -12px rgba(15,33,72,0.3);
}
.step-icon svg { width: 20px; height: 20px; }
.step-label {
  font-size: 12.5px;
  font-weight: 400;
  color: var(--ink-600);
  text-align: center;
  line-height: 1.4;
}
.step-divider {
  flex: 0 0 40px;
  height: 1px;
  background: linear-gradient(90deg, var(--line-200), var(--gold-400), var(--line-200));
  margin: 0 4px 26px;
}
@media (max-width: 560px) {
  .steps { align-items: flex-start; }
  .step-label { font-size: 11.5px; }
  .step-divider { flex-basis: 20px; }
}

/* ---------- Page-load entrance ---------- */
.topbar, .hero > *, .steps, .history {
  animation: fade-up 0.6s var(--ease-out) both;
}
.hero .eyebrow { animation-delay: 0.02s; }
.hero h1 { animation-delay: 0.08s; }
.hero p.lead { animation-delay: 0.14s; }
.scanner { animation: fade-up 0.7s var(--ease-out) both 0.2s; }
.scan-button { animation: fade-up 0.6s var(--ease-out) both 0.3s; }
.hero label.hint { animation: fade-up 0.6s var(--ease-out) both 0.36s; }
.hero p.hint { animation: fade-up 0.6s var(--ease-out) both 0.4s; }
.steps { animation-delay: 0.44s; }
.history { animation-delay: 0.5s; }

@keyframes fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- History list ---------- */
.history {
  max-width: 720px;
  margin: 0 auto 64px;
  padding: 0 24px;
}
.history h2 {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-600);
  margin: 0 0 14px;
  letter-spacing: 0.2px;
}
.history-empty {
  border: 1px dashed var(--line-200);
  border-radius: var(--radius-md);
  padding: 22px;
  text-align: center;
  color: var(--ink-400);
  font-size: 13.5px;
  font-weight: 300;
}
.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--cream-50);
  border: 1px solid var(--line-200);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 10px;
  animation: item-in 0.35s var(--ease-out);
}
@keyframes item-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.history-item .who { font-size: 14px; font-weight: 500; }
.history-item .when { font-size: 12px; color: var(--ink-400); font-weight: 300; }

/* ==========================================================================
   Popup / Modal — glassmorphism, ทันสมัย, เปิด-ปิดด้วยแอนิเมชันนุ่มนวล
   ========================================================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 18, 38, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s var(--ease-out);
  z-index: 100;
}
.modal-overlay.is-open { opacity: 1; pointer-events: auto; }

.modal {
  width: 100%;
  max-width: 460px;
  background: rgba(252, 251, 247, 0.92);
  border: 1px solid rgba(255,255,255,0.6);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  padding: 30px 28px 26px;
  transform: scale(0.94) translateY(10px);
  opacity: 0;
  transition: transform 0.3s var(--ease-out), opacity 0.3s var(--ease-out);
  max-height: 86vh;
  overflow-y: auto;
}
.modal-overlay.is-open .modal { transform: scale(1) translateY(0); opacity: 1; }

.modal-close {
  position: absolute;
  top: 16px; right: 16px;
  width: 32px; height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(15,33,72,0.06);
  color: var(--ink-600);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.2s ease;
}
.modal-close:hover { background: rgba(15,33,72,0.12); }
.modal-close svg { width: 15px; height: 15px; }
.modal { position: relative; }

/* --- loading modal --- */
.modal-loading { text-align: center; padding-top: 12px; }
.loading-rings { width: 64px; height: 64px; margin: 0 auto 20px; position: relative; }
.loading-rings span {
  position: absolute; inset: 0;
  border-radius: 50%;
  border: 3px solid transparent;
  border-top-color: var(--gold-500);
  animation: spin 1.1s linear infinite;
}
.loading-rings span:nth-child(2) { inset: 9px; border-top-color: var(--navy-700); animation-duration: 1.5s; animation-direction: reverse; }
@keyframes spin { to { transform: rotate(360deg); } }

.modal-loading h3 { font-size: 17px; font-weight: 500; margin: 0 0 6px; }
.modal-loading p { font-size: 13.5px; color: var(--ink-600); font-weight: 300; margin: 0; }
.loading-dots span {
  display: inline-block;
  animation: dot-pulse 1.2s ease-in-out infinite;
}
.loading-dots span:nth-child(2) { animation-delay: 0.15s; }
.loading-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes dot-pulse { 0%, 60%, 100% { opacity: 0.25; } 30% { opacity: 1; } }

/* --- result modal: mini replica of the ID card --- */
.result-card {
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: 0 10px 30px -12px rgba(15,33,72,0.35);
  margin-bottom: 20px;
  border: 1px solid var(--line-200);
}
.result-card-head {
  background: linear-gradient(120deg, var(--navy-900), var(--navy-700));
  color: var(--cream-50);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.result-card-head .badge {
  width: 26px; height: 26px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--gold-300), var(--gold-500) 70%);
  flex-shrink: 0;
  display: grid;
  place-items: center;
}
.check-draw {
  width: 15px; height: 15px;
  stroke-dasharray: 24;
  stroke-dashoffset: 24;
  animation: draw-check 0.5s var(--ease-out) 0.15s forwards;
}
@keyframes draw-check {
  to { stroke-dashoffset: 0; }
}
.result-card-head .t1 { font-size: 12px; font-weight: 300; opacity: 0.75; }
.result-card-head .t2 { font-size: 14.5px; font-weight: 500; }

.result-card-body {
  background: var(--cream-50);
  padding: 18px;
  display: flex;
  gap: 16px;
}
.result-photo {
  width: 82px; height: 100px;
  border-radius: 8px;
  background: #E9E5D8 center/cover no-repeat;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(15,33,72,0.08);
  display: grid;
  place-items: center;
  color: var(--ink-400);
}
.result-photo svg { width: 30px; height: 30px; opacity: 0.5; }

.result-fields { flex: 1; min-width: 0; }
.result-fields dl { margin: 0; }
.result-fields .row { display: flex; gap: 8px; padding: 4px 0; font-size: 13px; }
.result-fields .row + .row { border-top: 1px dashed var(--line-200); }
.result-fields dt { flex: 0 0 78px; color: var(--ink-400); font-weight: 300; }
.result-fields dd { margin: 0; font-weight: 500; color: var(--ink-900); word-break: break-word; }

.modal-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-secondary, .btn-primary {
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  border-radius: 999px;
  padding: 10px 18px;
  cursor: pointer;
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.btn-secondary { background: rgba(15,33,72,0.07); color: var(--navy-800); }
.btn-secondary:hover { background: rgba(15,33,72,0.12); }
.btn-primary { background: var(--navy-800); color: var(--cream-50); box-shadow: 0 10px 20px -10px rgba(15,33,72,0.6); }
.btn-primary:hover { transform: translateY(-1px); }

/* --- error modal --- */
.modal-error { text-align: center; padding-top: 8px; }
.error-icon {
  width: 56px; height: 56px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: var(--danger-100);
  display: grid;
  place-items: center;
}
.error-icon svg { width: 26px; height: 26px; color: var(--danger-600); }
.modal-error h3 { font-size: 17px; font-weight: 500; margin: 0 0 8px; color: var(--danger-600); }
.modal-error p { font-size: 13.5px; color: var(--ink-600); font-weight: 300; line-height: 1.6; margin: 0 0 22px; }

footer.page-footer {
  text-align: center;
  padding: 24px;
  font-size: 12px;
  color: var(--ink-400);
  font-weight: 300;
}

/* ---------- Responsive ---------- */
@media (max-width: 560px) {
  .topbar { padding: 14px 18px; }
  .brand-text .subtitle { display: none; }
  .hero { padding: 40px 16px 24px; }
  .result-card-body { flex-direction: column; }
  .result-photo { width: 100%; height: 150px; }
}

/* ---------- Accessibility ---------- */
:focus-visible {
  outline: 2px solid var(--navy-700);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

/* ==========================================================================
   หน้าแรก (index.php) — split hero: หัวข้อ+ปุ่มด้านซ้าย, badge วงแหวนด้านขวา
   ========================================================================== */

.home-split {
  max-width: 1040px;
  margin: 0 auto;
  padding: 68px 24px 40px;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 48px;
  align-items: center;
}
@media (max-width: 860px) {
  .home-split { grid-template-columns: 1fr; padding-top: 48px; text-align: center; }
}

.home-left h1 {
  font-size: clamp(30px, 4vw, 44px);
  font-weight: 600;
  color: var(--navy-900);
  margin: 18px 0 16px;
  line-height: 1.28;
  letter-spacing: -0.2px;
}
.home-left p.lead {
  font-size: 15.5px;
  font-weight: 300;
  color: var(--ink-600);
  line-height: 1.75;
  margin: 0 0 32px;
  max-width: 460px;
}
@media (max-width: 860px) {
  .home-left p.lead { margin-left: auto; margin-right: auto; }
}

.home-actions {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 34px;
}
@media (max-width: 860px) { .home-actions { justify-content: center; } }

.btn-home-primary, .btn-home-secondary {
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 500;
  padding: 14px 26px;
  border-radius: 999px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: transform 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out), background 0.2s ease;
}
.btn-home-primary {
  background: linear-gradient(135deg, var(--navy-700), var(--navy-900));
  color: var(--cream-50);
  box-shadow: 0 16px 32px -14px rgba(15,33,72,0.55);
}
.btn-home-primary:hover { transform: translateY(-2px); box-shadow: 0 20px 40px -16px rgba(15,33,72,0.6); }
.btn-home-secondary {
  background: transparent;
  color: var(--navy-800);
  border: 1.5px solid var(--gold-500);
}
.btn-home-secondary:hover { background: rgba(201,162,39,0.08); transform: translateY(-2px); }
.btn-home-primary svg, .btn-home-secondary svg { width: 16px; height: 16px; }

.home-features { display: flex; flex-direction: column; gap: 12px; }
@media (max-width: 860px) { .home-features { align-items: center; } }
.home-feature {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--ink-600);
  font-weight: 300;
}
.home-feature svg { width: 16px; height: 16px; color: var(--navy-700); flex-shrink: 0; }

.home-badge-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
}
@media (max-width: 860px) { .home-badge-wrap { order: -1; margin-bottom: -8px; } }

.home-badge {
  position: relative;
  width: 260px;
  height: 260px;
  flex-shrink: 0;
}
.home-badge .ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px dashed var(--gold-400);
  animation: spin-slow 40s linear infinite;
}
.home-badge .ring.r2 {
  inset: 26px;
  border-style: solid;
  border-color: var(--line-200);
  animation: none;
}
@keyframes spin-slow { to { transform: rotate(360deg); } }

.home-badge .core {
  position: absolute;
  inset: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--navy-700), var(--navy-900));
  display: grid;
  place-items: center;
  color: var(--cream-50);
  box-shadow: 0 26px 54px -20px rgba(15,33,72,0.55);
}
.home-badge .core svg { width: 60px; height: 60px; }

.home-badge .dot {
  position: absolute;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--gold-500);
  box-shadow: 0 0 0 4px var(--cream-100);
  top: 6px; left: 50%;
  transform: translateX(-50%);
}

/* ==========================================================================
   ผังการทำงาน (webflow.php) — timeline แนวตั้งแสดงลำดับขั้นตอนของเวอร์ชันเว็บ
   ========================================================================== */

.flow-page {
  max-width: 640px;
  margin: 0 auto;
  padding: 48px 24px 80px;
}
.flow-page h1 {
  font-size: clamp(24px, 3.5vw, 32px);
  font-weight: 600;
  color: var(--navy-900);
  margin: 0 0 10px;
}
.flow-page p.lead {
  font-size: 14.5px;
  font-weight: 300;
  color: var(--ink-600);
  line-height: 1.75;
  margin: 0 0 40px;
  max-width: 520px;
}

.flow-legend {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 36px;
  font-size: 12.5px;
  color: var(--ink-600);
  font-weight: 300;
}
.flow-legend-item { display: flex; align-items: center; gap: 8px; }
.flow-legend-swatch { width: 22px; height: 0; border-top: 2px solid var(--navy-700); }
.flow-legend-swatch.dashed { border-top: 2px dashed var(--gold-500); }

.flow-step {
  display: flex;
  gap: 18px;
  align-items: flex-start;
}
.flow-marker {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 0 0 44px;
}
.flow-dot {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--navy-700), var(--navy-900));
  color: var(--cream-50);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: 0 10px 22px -10px rgba(15,33,72,0.55);
}
.flow-dot.hardware {
  background: radial-gradient(circle at 35% 30%, var(--gold-300), var(--gold-500) 75%);
  color: var(--navy-900);
}
.flow-dot svg { width: 19px; height: 19px; }
.flow-line {
  width: 2px;
  flex: 1;
  min-height: 34px;
  background: linear-gradient(var(--line-200), var(--gold-400));
  margin-top: 6px;
}
.flow-card {
  flex: 1;
  background: var(--cream-50);
  border: 1px solid var(--line-200);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-bottom: 30px;
  box-shadow: 0 14px 30px -22px rgba(15,33,72,0.35);
}
.flow-tag {
  font-size: 11px;
  letter-spacing: 0.6px;
  font-weight: 500;
  color: var(--navy-700);
  text-transform: uppercase;
  margin-bottom: 5px;
}
.flow-title {
  font-size: 15.5px;
  font-weight: 600;
  color: var(--ink-900);
  margin-bottom: 5px;
}
.flow-desc {
  font-size: 13px;
  font-weight: 300;
  color: var(--ink-600);
  line-height: 1.65;
}
.flow-desc code {
  font-family: "Prompt", monospace;
  font-size: 12.5px;
  background: rgba(15,33,72,0.06);
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--navy-800);
}

.flow-branch-row {
  display: flex;
  gap: 14px;
  align-items: stretch;
  margin-bottom: 30px;
}
.flow-branch-connector {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 2px;
  flex: 0 0 auto;
}
.flow-branch-connector .arrow-line {
  width: 26px; height: 0;
  border-top: 2px solid var(--navy-700);
  position: relative;
}
.flow-branch-connector .arrow-line::after {
  content: "";
  position: absolute; right: -1px; top: -3px;
  border: 4px solid transparent;
  border-left-color: var(--navy-700);
}
.flow-branch-connector .arrow-line.dashed {
  border-top: 2px dashed var(--gold-500);
}
.flow-branch-connector .arrow-line.dashed::after {
  border-left-color: var(--gold-500);
  transform: rotate(180deg);
  right: auto; left: -1px;
}
.flow-branch-card {
  flex: 1;
  background: var(--cream-50);
  border: 1px dashed var(--gold-400);
  border-radius: var(--radius-md);
  padding: 14px 18px;
}

/* ==========================================================================
   mobile.php — อ่านบัตรผ่านเครื่องอ่าน USB ที่เสียบกับมือถือ/แท็บเล็ตโดยตรง
   (WebUSB, ทดลอง, รองรับเฉพาะ Chrome บน Android)
   ========================================================================== */

.mobile-requirements {
  text-align: left;
  max-width: 480px;
  margin: 0 auto 32px;
  background: var(--cream-50);
  border: 1px solid var(--line-200);
  border-radius: var(--radius-md);
  padding: 18px 22px;
}
.mobile-requirements .req-title {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--navy-700);
  margin-bottom: 10px;
}
.mobile-requirements ul { margin: 0; padding-left: 18px; }
.mobile-requirements li {
  font-size: 13px;
  color: var(--ink-600);
  margin-bottom: 6px;
  font-weight: 300;
  line-height: 1.6;
}

.mobile-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 28px;
}

.btn-outline-navy {
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 500;
  padding: 13px 26px;
  border-radius: 999px;
  background: transparent;
  color: var(--navy-800);
  border: 1.5px solid var(--navy-700);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background 0.2s ease, transform 0.2s var(--ease-out);
}
.btn-outline-navy:hover:not(:disabled) { background: rgba(15,33,72,0.06); transform: translateY(-2px); }
.btn-outline-navy:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-outline-navy svg { width: 16px; height: 16px; }

.mobile-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 400;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(15,33,72,0.06);
  color: var(--ink-600);
  margin-bottom: 28px;
}
.mobile-status-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-400); }
.mobile-status-pill.connected .dot { background: var(--success-600); }
.mobile-status-pill.connected { background: var(--success-100); color: var(--success-600); }

.mobile-log {
  max-width: 560px;
  margin: 0 auto 32px;
  background: #0F172A;
  color: #D1D9E6;
  font-family: "Prompt", monospace;
  font-size: 12px;
  border-radius: var(--radius-md);
  padding: 16px 18px;
  text-align: left;
  max-height: 240px;
  overflow-y: auto;
  line-height: 1.7;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06);
}
.mobile-log .log-line { white-space: pre-wrap; word-break: break-word; }
.mobile-log .ok   { color: #6EE7B7; }
.mobile-log .err  { color: #FCA5A5; }
.mobile-log .info { color: #93C5FD; }
.mobile-log .muted{ color: #64748B; }

.mobile-unsupported {
  max-width: 480px;
  margin: 0 auto 32px;
  background: var(--danger-100);
  border: 1px solid rgba(192,57,43,0.25);
  border-radius: var(--radius-md);
  padding: 18px 22px;
  color: var(--danger-600);
  font-size: 13.5px;
  font-weight: 400;
  line-height: 1.7;
  text-align: left;
}

/* ==========================================================================
   photo.php — อ่านบัตรจากรูปถ่าย/กล้อง ด้วย OCR (Tesseract.js) ฝั่งเบราว์เซอร์
   ========================================================================== */

.ocr-disclaimer {
  max-width: 520px;
  margin: 0 auto 28px;
  background: rgba(201,162,39,0.08);
  border: 1px solid rgba(201,162,39,0.3);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  color: var(--navy-800);
  font-size: 13px;
  font-weight: 300;
  line-height: 1.7;
  text-align: left;
}
.ocr-disclaimer strong { font-weight: 500; }

.capture-tabs {
  display: inline-flex;
  background: var(--cream-50);
  border: 1px solid var(--line-200);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 20px;
}
.capture-tab {
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 11px 20px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--ink-600);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.2s ease, color 0.2s ease;
}
.capture-tab svg { width: 12px; height: 12px; flex-shrink: 0; }
.capture-tab.active { background: var(--navy-800); color: var(--cream-50); }

.capture-panel { max-width: 360px; margin: 0 auto 24px; }
.capture-panel[hidden] { display: none; }

.camera-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 8/5;
  background: #0F172A;
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 16px;
  box-shadow: 0 16px 36px -20px rgba(15,33,72,0.5);
}
.camera-frame video, .camera-frame canvas.preview-canvas {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.camera-frame.is-live video {
  cursor: pointer;
}
.camera-frame.is-live::after {
  content: "แตะที่ภาพเพื่อถ่ายรูป";
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15,33,72,0.65);
  color: var(--cream-50);
  font-size: 11px;
  font-weight: 300;
  padding: 5px 12px;
  border-radius: 999px;
  pointer-events: none;
}
.camera-guide {
  position: absolute;
  inset: 10% 8%;
  border: 2px dashed rgba(255,255,255,0.55);
  border-radius: 14px;
  pointer-events: none;
}
.camera-placeholder {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; color: rgba(255,255,255,0.6); font-size: 13px; font-weight: 300;
}
.camera-placeholder svg { width: 18px; height: 18px; }

.dropzone {
  border: 1.5px dashed var(--line-200);
  border-radius: var(--radius-md);
  padding: 22px 18px;
  text-align: center;
  cursor: pointer;
  background: var(--cream-50);
  margin-bottom: 16px;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.dropzone:hover, .dropzone.drag-over { border-color: var(--gold-500); background: rgba(201,162,39,0.05); }
.dropzone svg { width: 16px; height: 16px; color: var(--ink-400); margin-bottom: 6px; }
.dropzone .dz-text { font-size: 13.5px; color: var(--ink-600); font-weight: 300; }
.dropzone .dz-text strong { color: var(--navy-700); font-weight: 500; }

.preview-image-wrap {
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 16px;
  box-shadow: 0 12px 30px -18px rgba(15,33,72,0.4);
}
.preview-image-wrap img { width: 100%; display: block; }

.ocr-progress {
  max-width: 480px;
  margin: 0 auto 24px;
}
.ocr-progress-bar {
  height: 8px;
  border-radius: 999px;
  background: var(--line-200);
  overflow: hidden;
  margin-bottom: 8px;
}
.ocr-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold-500), var(--gold-400));
  border-radius: 999px;
  width: 0%;
  transition: width 0.3s ease;
}
.ocr-progress-label { font-size: 12.5px; color: var(--ink-600); font-weight: 300; text-align: center; }

.ocr-fields {
  max-width: 520px;
  margin: 0 auto 24px;
  text-align: left;
}
.ocr-field { margin-bottom: 16px; }
.ocr-field label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--navy-700);
  margin-bottom: 6px;
}
.ocr-field input, .ocr-field textarea {
  width: 100%;
  font-family: "Prompt", sans-serif;
  font-size: 16px; /* ต้อง >= 16px กัน Safari บน iOS ซูมจอทุกครั้งที่แตะช่องกรอก */
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-200);
  background: var(--cream-50);
  color: var(--ink-900);
  box-sizing: border-box;
}
.ocr-field input:focus, .ocr-field textarea:focus {
  outline: none;
  border-color: var(--gold-500);
  box-shadow: 0 0 0 3px rgba(201,162,39,0.15);
}
.ocr-field textarea { resize: vertical; min-height: 64px; }

.ocr-raw-toggle {
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 400;
  color: var(--ink-400);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}
.ocr-raw-text {
  max-width: 520px;
  margin: 12px auto 24px;
  background: #0F172A;
  color: #94A3B8;
  font-family: monospace;
  font-size: 11.5px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  white-space: pre-wrap;
  max-height: 200px;
  overflow-y: auto;
  text-align: left;
}

/* corner-bracket scan guide (แทนกรอบเส้นประธรรมดา ให้ความรู้สึกเหมือนแอปสแกนเอกสาร) */
.scan-corner {
  position: absolute;
  width: 26px; height: 26px;
  border: 2.5px solid var(--gold-400);
  opacity: 0.9;
}
.scan-corner.tl { top: 9%; left: 8%; border-right: none; border-bottom: none; border-radius: 6px 0 0 0; }
.scan-corner.tr { top: 9%; right: 8%; border-left: none; border-bottom: none; border-radius: 0 6px 0 0; }
.scan-corner.bl { bottom: 9%; left: 8%; border-right: none; border-top: none; border-radius: 0 0 0 6px; }
.scan-corner.br { bottom: 9%; right: 8%; border-left: none; border-top: none; border-radius: 0 0 6px 0; }


.ocr-workspace {
  max-width: 900px;
  margin: 0 auto 60px;
  padding: 0 24px;
  display: grid;
  grid-template-columns: minmax(280px, 380px) 1fr;
  gap: 28px;
  align-items: start;
}
@media (max-width: 860px) {
  .ocr-workspace { grid-template-columns: 1fr; }
}

.ocr-image-panel { position: sticky; top: 20px; }
@media (max-width: 860px) { .ocr-image-panel { position: static; } }

.ocr-image-frame {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: 0 16px 36px -20px rgba(15,33,72,0.45);
  margin-bottom: 14px;
}
.ocr-image-frame img { width: 100%; display: block; }

.ocr-progress-overlay {
  position: absolute; inset: 0;
  background: rgba(15,33,72,0.72);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.ocr-progress-overlay.is-active { opacity: 1; pointer-events: auto; }

.progress-ring {
  width: 84px; height: 84px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--gold-500) 0%, rgba(255,255,255,0.2) 0%);
  transition: background 0.2s linear;
}
.progress-ring-inner {
  width: 68px; height: 68px;
  border-radius: 50%;
  background: var(--navy-900);
  display: grid;
  place-items: center;
  color: var(--cream-50);
  font-size: 15px;
  font-weight: 600;
}
.ocr-progress-overlay .stage-label {
  font-size: 12px;
  color: rgba(255,255,255,0.85);
  font-weight: 300;
  text-align: center;
  max-width: 240px;
}

/* การ์ดผลลัพธ์ (ฝั่งขวา) */
.ocr-result-card {
  background: var(--cream-50);
  border: 1px solid var(--line-200);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 16px 40px -26px rgba(15,33,72,0.35);
}
.ocr-result-head {
  background: linear-gradient(120deg, var(--navy-900), var(--navy-700));
  color: var(--cream-50);
  padding: 18px 22px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.ocr-result-head .icon-badge {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: rgba(255,255,255,0.12);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.ocr-result-head .icon-badge svg { width: 14px; height: 14px; }
.ocr-result-head .h-title { font-size: 15px; font-weight: 600; }
.ocr-result-head .h-sub { font-size: 12px; font-weight: 300; opacity: 0.75; }

.ocr-result-body { padding: 22px; }

.ocr-field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 16px;
}
.ocr-field-grid .ocr-field.full { grid-column: 1 / -1; }
@media (max-width: 520px) {
  .ocr-field-grid { grid-template-columns: 1fr; }
}
@media (max-width: 380px) {
  .capture-tab { padding: 10px 14px; font-size: 12px; }
}
.ocr-field-grid .ocr-field { margin-bottom: 0; }
.ocr-field-grid .ocr-field label {
  display: flex;
  align-items: center;
  gap: 6px;
}
.ocr-field-grid .ocr-field label svg { width: 12px; height: 12px; color: var(--navy-600); flex-shrink: 0; }

.ocr-result-footer {
  border-top: 1px solid var(--line-200);
  padding: 16px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
