:root {
  /* ===== BRAND / PRIMARY ===== */
  --primary-500: #00a2ff;
  --primary-400: #25afff;
  --primary-300: #44baff;

  /* ===== ACCENT ===== */
  --accent-orange: #f97316;

  /* ===== DANGER ===== */
  --danger-300: #fecaca;
  --danger-400: #f87171;
  --danger-500: #ef4444;
  --danger-600: #dc2626;
  --danger-700: #b91c1c;

  /* ===== SUCCESS ===== */
  --success-300: #bbf7d0;
  --success-400: #6ee7b7;
  --success-500: #22c55e;
  --success-600: #16a34a;

  /* ===== WARNING ===== */
  --warning-300: #fef9c3;
  --warning-400: #fef08a;
  --warning-500: #eab308;

  /* ===== INFO / BLUE ===== */
  --info-300: #e0f2fe;
  --info-500: #0ea5e9;
  --info-600: #0284c7;
  --info-700: #1e40af;

  /* ===== NEUTRAL ===== */
  --white: #ffffff;
  --black: #000000;

  --gray-50:  #f9fafb;
  --gray-100: #f8fafc;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #475569;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #020617;

  /* ===== BACKGROUND ===== */
  --bg-body: radial-gradient(
    circle at top,
    var(--primary-500) 0%,
    var(--primary-400) 45%,
    var(--white) 100%
  );

  --bg-app: radial-gradient(
    circle at top,
    var(--white) 0%,
    var(--white) 60%,
    var(--white) 100%
  );

  /* ===== SHADOW ===== */
  --shadow-header: 0 2px 18px rgba(0,0,0,0.6);
  --shadow-container: 0 25px 60px #929292;
}
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
}

body {
  touch-action: manipulation;
  font-family: "K2D", sans-serif;
  background: var(--bg-body);         
  color: var(--gray-900);             
  overflow-x: hidden;
}

body, input, button, textarea {
  font-family: "K2D", sans-serif;
}
.fa-solid,
.fa-regular,
.fa-brands,
.fas,
.far,
.fab {
  font-family: "Font Awesome 6 Free" !important;
  font-weight: 800 !important;
}
.app-container {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg-app);           /* ORIGINAL: white gradient */
  color: var(--gray-50);               /* ORIGINAL: #f9fafb */
  position: relative;
  padding-bottom: 80px;
}
@media (min-width: 600px) {
  .app-container {
    margin-top: 16px;
    margin-bottom: 16px;
    border-radius: 32px;
    box-shadow: var(--shadow-container); /* ORIGINAL: #929292 */
    overflow: hidden;
  }
}
.header {
  background: linear-gradient(
    135deg,
    var(--primary-500) 0%,
    var(--primary-500) 20%,
    var(--primary-500) 100%
  );
  color: var(--gray-50);                /* ORIGINAL: #f9fafb */
  padding: 16px 20px;
  box-shadow: var(--shadow-header);     /* ORIGINAL rgba */
}

.header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.header p {
  margin-top: 2px;
  font-size: 12px;
  opacity: 0.85;
}
.content {
  padding: 18px 18px 24px;
}
.scan-hero {
  text-align: center;
  padding: 8px 4px 6px;
}

.scan-hero h2 {
  font-size: 22px;
  font-weight: 600;
  color: var(--black);           /* ORIGINAL: #000000 */
}

.scan-hero p {
  font-size: 13px;
  color: var(--gray-900);        /* ORIGINAL: #9ca3af */
}

/* วงกลมไอคอนตรงกลาง */
.scan-hero .hero-circle {
  width: 150px;
  height: 150px;
}

/* Glow ไอคอน */
.scan-hero i.fa-fire-extinguisher {
  text-shadow: 0 0 18px rgba(248,113,113,0.8); /* คงค่า glow เดิม */
}
.scan-button {
  background: linear-gradient(
    135deg,
    var(--accent-orange) 0%,      /* ORIGINAL: #f97316 */
    var(--danger-500) 40%,        /* ORIGINAL: #ef4444 */
    var(--danger-600) 100%        /* ORIGINAL: #dc2626 */
  );
  color: var(--white);            /* ORIGINAL: #ffffff */
  border: none;
  padding: 16px 32px;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  max-width: 280px;
  margin: 0 auto;
  box-shadow: 0 12px 30px rgba(248,113,113,0.45);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
}

.scan-button:active {
  transform: scale(0.97) translateY(1px);
  box-shadow: 0 6px 16px rgba(248,113,113,0.4);
  opacity: 0.9;
}
.quick-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 26px;
}

.stat-card {
  background: var(--bg-card-dark);      /* ORIGINAL: dark radial */
  border-radius: 18px;
  padding: 12px 10px;
  text-align: center;
  border: 1px solid rgba(248,113,113,0.25);
  box-shadow: 0 10px 26px rgba(0,0,0,0.6);
}

.stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--white);                  /* ORIGINAL: #ffffff */
  margin: 0;
}

.stat-label {
  font-size: 11px;
  color: var(--white);                  /* ORIGINAL: #ffffff */
  margin-top: 2px;
}
.card {
  background: var(--bg-card-blue);          /* ORIGINAL: radial #00aff5 */
  border-radius: 22px;
  padding: 18px 16px;
  margin-bottom: 16px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 18px 38px rgba(207, 207, 207, 0.7);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--black);                 /* ORIGINAL: #000000 */
}
.badge {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid transparent;
}

.badge-good {
  background: rgba(22, 163, 74, 0.15);
  color: var(--success-300);           /* ORIGINAL: #bbf7d0 */
  border-color: rgba(34, 197, 94, 0.5);
}

.badge-bad {
  background: rgba(248, 113, 113, 0.18);
  color: var(--danger-300);            /* ORIGINAL: #fecaca */
  border-color: rgba(248, 113, 113, 0.7);
}

.badge-warning {
  background: rgba(234, 179, 8, 0.15);
  color: var(--warning-300);           /* ORIGINAL: #fef9c3 */
  border-color: rgba(250, 204, 21, 0.7);
}
.info-grid {
  display: grid;
  gap: 10px;
  margin-top: 6px;
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 6px 0;
  border-bottom: 1px solid rgba(216, 216, 216, 0.9);
}

.info-row:last-child {
  border-bottom: none;
}

.info-label {
  font-size: 12px;
  color: var(--gray-800);             /* ORIGINAL: #9ca3af */
}

.info-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-800);             /* ORIGINAL: #e5e7eb */
  text-align: right;
}
.checklist-item {
  background: var(--bg-card-dark);            /* ORIGINAL: radial dark */
  padding: 14px 12px;
  border-radius: 18px;
  margin-bottom: 10px;
  border: 1px solid rgba(255, 255, 255, 0.9);
}

.checklist-question {
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-900);                     /* ORIGINAL: #e5e7eb */
  margin-bottom: 10px;
}
.toggle-group {
  display: flex;
  gap: 8px;
}
.toggle-btn {
  flex: 1;
  padding: 8px 4px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.9);
  background: var(--gray-200);                /* ORIGINAL: #020617 */
  color: var(--gray-900);                     /* ORIGINAL: #e5e7eb */
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease,
    transform 0.08s ease;
}

.toggle-btn:active {
  transform: scale(0.97);
}

.toggle-btn.active-yes {
  background: rgba(21, 128, 61, 0.85);
  border-color: var(--success-500);           /* ORIGINAL: #22c55e */
  color: #eafff4;
}

.toggle-btn.active-no {
  background: rgba(185, 28, 28, 0.85);
  border-color: var(--danger-500);            /* ORIGINAL: #ef4444 */
  color: #fee2e2;
}

.toggle-btn.active-na {
  background: rgba(30, 64, 175, 0.7);
  border-color: #6366f1;
  color: var(--info-300);                     /* ORIGINAL: #e0f2fe */
}

/* generic active */
.toggle-btn.active {
  background: var(--info-500);                /* ORIGINAL: #0ea5e9 */
  color: var(--white);
  border-color: var(--info-600);              /* ORIGINAL: #0284c7 */
}
.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-900);                     /* ORIGINAL: #9ca3af */
  margin-bottom: 6px;
}
.form-input {
  width: 100%;
  padding: 10px 11px;
  border-radius: 12px;
  border: 1px solid rgba(180, 180, 180, 0.9);
  background: var(--gray-200);                /* ORIGINAL: #020617 */
  color: var(--gray-900);                      /* ORIGINAL: #f9fafb */
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-input::placeholder {
  color: var(--gray-900);                     /* ORIGINAL: #6b7280 */
}

.form-input:focus {
  border-color: var(--accent-orange);         /* ORIGINAL: #f97316 */
  box-shadow: 0 0 0 1px rgba(249, 115, 22, 0.6);
}

textarea.form-input {
  min-height: 80px;
  resize: vertical;
}
.btn {
  width: 100%;
  padding: 14px 16px;
  border-radius: 999px;
  border: none;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
}

/* PRIMARY */
.btn-primary {
  background: linear-gradient(
    135deg,
    var(--primary-300) 0%,         /* ORIGINAL: #37b6ff */
    var(--primary-500) 40%,        /* ORIGINAL: #00a2ff */
    var(--primary-500) 100%
  );
  color: var(--white);             /* ORIGINAL: #ffffff */
  box-shadow: 0 14px 30px rgba(0, 87, 138, 0.55);
}

.btn-primary:active {
  transform: scale(0.97) translateY(1px);
  box-shadow: 0 8px 18px rgba(248, 113, 113, 0.45);
  opacity: 0.95;
}

/* SECONDARY */
.btn-secondary {
  background: rgba(15, 23, 42, 0.9);
  color: var(--gray-200);          /* ORIGINAL: #e5e7eb */
  border: 1px solid rgba(55, 65, 81, 0.9);
  margin-top: 10px;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.65);
}

.btn-secondary:active {
  transform: scale(0.97) translateY(1px);
  opacity: 0.95;
}

/* SUCCESS */
.btn-success {
  background: linear-gradient(
    135deg,
    var(--success-500) 0%,          /* ORIGINAL: #22c55e */
    var(--success-600) 60%          /* ORIGINAL: #16a34a */
  );
  color: var(--gray-50);            /* ORIGINAL: #f9fafb */
  box-shadow: 0 14px 30px rgba(34, 197, 94, 0.5);
}

.btn-success:active {
  transform: scale(0.97) translateY(1px);
}

/* DISABLED */
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}
.result-icon {
  width: 90px;
  height: 90px;
  margin: 0 auto 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  box-shadow: 0 0 40px rgba(34, 197, 94, 0.4);
}

/* PASS */
.result-pass {
  background: radial-gradient(
    circle at top,
    var(--success-500),
    #14532d 70%
  );
  color: #ecfdf5;
}

/* FAIL */
.result-fail {
  background: radial-gradient(
    circle at top,
    var(--danger-500),
    #7f1d1d 70%
  );
  color: #fef2f2;
  box-shadow: var(--shadow-danger-glow); /* ORIGINAL: rgba(248,113,113,.55) */
}

.result-title {
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 4px;
}

.result-subtitle {
  text-align: center;
  font-size: 13px;
  color: var(--gray-400);           /* ORIGINAL: #9ca3af */
  margin-bottom: 22px;
}
.history-item {
  background: radial-gradient(circle at top left, #2eb2ff 0%, var(--primary-500) 80%);
  padding: 14px 13px;
  border-radius: 18px;
  margin-bottom: 10px;
  border: 1px solid rgba(255, 255, 255, 0.9);
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease,
    box-shadow 0.15s ease;
}

.history-item:active {
  transform: scale(0.98);
  background: radial-gradient(circle at top left, var(--gray-800) 0%, var(--gray-900) 80%);
  box-shadow: 0 10px 24px rgba(255, 255, 255, 0.75);
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 4px;
}

.history-id {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-50);          /* ORIGINAL: #e5e7eb */
}

.history-date {
  font-size: 11px;
  color: var(--gray-100);          /* ORIGINAL: #9ca3af */
}

.history-inspector {
  font-size: 12px;
  color: var(--gray-100);
  margin-top: 2px;
}

.history-date-small {
  font-size: 11px;
  color: var(--gray-200);          /* ORIGINAL: #6b7280 */
}

.history-item.loading {
  opacity: 0.6;
  pointer-events: none;
}
.status-badge {
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

/* PASS */
.status-good {
  background: rgba(22, 163, 74, 0.18);
  color: var(--success-300);
  border: 1px solid rgba(34, 197, 94, 0.7);
}

/* FAIL */
.status-bad {
  background: rgba(248, 113, 113, 0.2);
  color: var(--danger-300);
  border: 1px solid rgba(248, 113, 113, 0.8);
}

/* WARN */
.status-warn {
  background: rgba(234, 179, 8, 0.2);
  color: var(--warning-300);
  border: 1px solid rgba(250, 204, 21, 0.8);
}
.loading {
  text-align: center;
  padding: 32px 16px;
  font-size: 13px;
  color: var(--gray-400);          /* ORIGINAL: #9ca3af */
}
.skeleton-card {
  height: 64px;
  border-radius: 18px;
  margin-bottom: 10px;
  background: linear-gradient(
    90deg,
    var(--white) 0%,
    var(--white) 50%,
    var(--white) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.1s linear infinite;
}

@keyframes skeleton-shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}
.screen {
  display: none;
}

.screen.active {
  display: block;
}
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  max-width: 480px;
  margin: 0 auto;
  background: #00a2ff;
  border-top: 1px solid var(--gray-200);          /* ORIGINAL: rgba(31,41,55,.9) */
  display: flex;
  justify-content: space-around;
  padding: 8px 8px 10px;
  box-shadow: 0 -10px 25px rgba(146, 146, 146, 0.7);
  backdrop-filter: blur(20px);
}

.nav-item {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--gray-600);                         /* ORIGINAL: #6b7280 */
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  cursor: pointer;
}

.nav-item i {
  font-size: 18px;
}

.nav-item.active {
  color: var(--gray-200);                    /* ORIGINAL: #f97316 */
}

.nav-item.active i {
  text-shadow: 0 0 10px rgb(255, 255, 255);
}
#qr-video {
  border-radius: 18px !important;
  background: var(--black);                       /* ORIGINAL: #000 */
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.9);
}
.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin: 16px 0;
}

.summary-card {
  background: #00aff5;                            /* คงสีเดิม (brand sub) */
  border-radius: 16px;
  padding: 14px 16px;
  border: 1px solid var(--white);                 /* ORIGINAL: #ffffff */
  text-align: center;
}

.summary-title {
  font-size: 12px;
  color: var(--white);                            /* ORIGINAL: #ffffff */
}

.summary-detail {
  font-size: 10px;
  color: #dbdbdb;
}

.summary-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--white);                            /* ORIGINAL: #ffffff */
  margin-top: 4px;
}

.summary-card.clickable {
  cursor: pointer;
}

.summary-card.clickable:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0,0,0,0.12);
}
.pf-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 10px 0 22px;
}

.pass-card,
.fail-card {
  padding: 14px 16px;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 700;
}

.pass-card {
  background: rgba(52,211,153,0.2);
  color: var(--success-400);                      /* ORIGINAL: #6ee7b7 */
}

.fail-card {
  background: rgba(248,113,113,0.2);
  color: var(--danger-300);                       /* ORIGINAL: #fecaca */
}
.section-title {
  font-size: 16px;
  margin-bottom: 4px;
  text-align: center;
}
.alert-card {
  padding: 14px 16px;
  border-radius: 16px;
  margin-bottom: 14px;
}

.alert-warn {
  background: rgba(234,179,8,0.18);
  color: var(--warning-400);                      /* ORIGINAL: #fef08a */
}

.alert-danger {
  background: rgba(248,113,113,0.18);
  color: var(--danger-300);                       /* ORIGINAL: #fecaca */
}

.alert-box {
  padding: 16px;
  border-radius: 12px;
  margin-bottom: 20px;
  background: var(--gray-100);                    /* ORIGINAL: #f8fafc */
  border: 1px solid var(--gray-200);              /* ORIGINAL: #e2e8f0 */
}

.alert-warn {
  background: #fff8e1;
  border-color: #feffb3;
}

.alert-danger {
  background: #ffebee;
  border-color: #ffcdd2;
}
.alert-list {
  margin-top: 8px;
  font-size: 14px;
  line-height: 1.4;
  color: #1d1d1d;
}

.alert-item {
  display: flex;
  justify-content: space-between;
  background: var(--white);
  color: #1d1d1d;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
  border: 1px solid var(--gray-200);
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

.alert-item .id {
  font-weight: 600;
}

.alert-item .days {
  color: #d32f2f;
  font-weight: 600;
}
.blink {
  animation: glowBlink 1.2s infinite ease-in-out;
}

@keyframes glowBlink {
  0%   { opacity: 1; text-shadow: 0 0 4px #ff9800; }
  50%  { opacity: 0.3; text-shadow: 0 0 12px #ff9800; }
  100% { opacity: 1; text-shadow: 0 0 4px #ff9800; }
}

.blink-warn {
  animation: glowBlinkwarn 1.2s infinite ease-in-out;
}

@keyframes glowBlinkwarn {
  0%   { opacity: 1; text-shadow: 0 0 4px #ff3333; }
  50%  { opacity: 0.3; text-shadow: 0 0 12px #ff3333; }
  100% { opacity: 1; text-shadow: 0 0 4px #ff3333; }
}
#loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.35);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 99999;
}

.loading-box {
  background: var(--white);                    /* ORIGINAL: #ffffff */
  padding: 30px 40px;
  border-radius: 16px;
  text-align: center;
  box-shadow: 0 8px 20px rgba(0,0,0,0.15);
}

.loader {
  width: 48px;
  height: 48px;
  border: 5px solid #ddd;
  border-top-color: var(--danger-500);         /* ORIGINAL: #ef4444 */
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}

#loading-text {
  font-size: 16px;
  font-weight: 600;
  color: #334155;
}
.filter-bar {
  display: flex;
  gap: 8px;
  padding: 10px;
  margin-bottom: 16px;
  overflow-x: auto;
  scrollbar-width: none;
}

.filter-bar::-webkit-scrollbar {
  display: none;
}
.filter-btn {
  display: flex;
  align-items: center;
  gap: 6px;

  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;

  border-radius: 999px;
  border: 1px solid var(--gray-200);           /* ORIGINAL: #e5e7eb */
  background: var(--white);                    /* ORIGINAL: #ffffff */
  color: var(--gray-700);                      /* ORIGINAL: #374151 */

  cursor: pointer;
  white-space: nowrap;

  transition: all 0.25s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.filter-btn i {
  font-size: 12px;
  opacity: 0.85;
}

.filter-btn:hover {
  background: var(--gray-100);                 /* ORIGINAL: #f8fafc */
  border-color: #cbd5e1;
}

.filter-btn.active {
  background: linear-gradient(
    135deg,
    var(--primary-300),
    var(--primary-500)
  );
  color: var(--white);
  border-color: transparent;
  box-shadow: 0 4px 10px var(--primary-700);   /* ORIGINAL: #005d92 */
}

.filter-btn.active i {
  opacity: 1;
}

.filter-btn:active {
  transform: scale(0.95);
}
.file-upload {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.file-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;

  width: 100%;
  padding: 14px;
  border-radius: 14px;
  border: 2px dashed #c7d2fe;

  background: #eef2ff;
  color: var(--info-900);                      /* ORIGINAL: #1e40af */
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s ease;
}

.file-btn i {
  font-size: 18px;
}

.file-btn:hover {
  background: #e0e7ff;
  border-color: #6366f1;
}

.file-btn:active {
  transform: scale(.98);
}

.file-info {
  font-size: 13px;
  color: var(--gray-900);                     
}

.file-hint {
  font-size: 12px;
  color: #64748b;
}

/* MOBILE */
@media (max-width: 480px) {
  .file-btn {
    padding: 16px;
    font-size: 16px;
  }
}
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.modal-overlay.show {
  display: flex;
}

.modal-box {
  background: var(--white);
  width: min(92vw, 380px);
  border-radius: 18px;
  padding: 22px 20px;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0,0,0,.2);
}

.modal-box.success {
  border-top: 6px solid var(--success-500);    /* ORIGINAL: #22c55e */
}

.modal-box.error {
  border-top: 6px solid var(--danger-500);     /* ORIGINAL: #ef4444 */
}

.modal-icon {
  font-size: 42px;
  margin-bottom: 8px;
}

.modal-btn {
  margin-top: 16px;
  width: 100%;
  padding: 10px;
  border-radius: 12px;
  border: none;
  font-size: 15px;
  cursor: pointer;
  background: #2563eb;
  color: var(--white);
}
.loading-spin {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.form-input.locked {
  background-color: #f1f5f9;
  color: #475569;
  cursor: not-allowed;
}

.app-locked {
  pointer-events: none;
  user-select: none;
}

.app-locked #loading-overlay {
  pointer-events: all; /* ให้กดไม่ได้แต่เห็น */
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.search-bar i {
  color: #94a3b8;
}

.search-bar input {
  border: none;
  outline: none;
  width: 100%;
  font-size: 14px;
}

/* =========================
   JOB MODE (ออกงาน / ปิดงาน)
========================= */
.job-mode {
  display: flex;
  gap: 12px;
  margin: 20px 0 24px;
}

.mode-btn {
  flex: 1;
  padding: 14px 0;
  border-radius: 14px;
  border: 2px solid #e5e7eb;
  background: #f8fafc;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s ease;
  color: #475569;
}

/* hover */
.mode-btn:hover {
  background: #f1f5f9;
}

/* 🚚 ออกงาน (active) */
.mode-btn.active[data-mode="open"] {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  border-color: #16a34a;
  color: #ffffff;
  box-shadow: 0 6px 18px rgba(34,197,94,0.35);
}

/* 🏁 ปิดงาน (active) */
.mode-btn.active[data-mode="close"] {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  border-color: #dc2626;
  color: #ffffff;
  box-shadow: 0 6px 18px rgba(239,68,68,0.35);
}

/* required highlight ตอนปิดงาน */
.required {
  border-color: #ef4444 !important;
  background: #fff1f2 !important;
}

#submit-inspection-btn i {
  margin-right: 6px;
  font-size: 16px;
  vertical-align: middle;
}

.job-mode {
  display: none !important;
}

#new-inspection-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
