/* ==========================================================
   ระบบชนหวยชุด (Lottery Matching System) - Modern Premium Dark UI
   ========================================================== */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Prompt:ital,wght@0,300;0,400;0,500;0,600;0,700;1,300&family=JetBrains+Mono:wght@500;700;800&display=swap');

:root {
  --bg-main: #0a0e17;
  --bg-card: rgba(18, 24, 38, 0.75);
  --bg-card-hover: rgba(28, 38, 58, 0.85);
  --bg-glass: rgba(15, 23, 42, 0.65);
  --border-glass: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(99, 102, 241, 0.35);

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent-gold: #f59e0b;
  --accent-gold-glow: rgba(245, 158, 11, 0.35);
  --accent-gold-gradient: linear-gradient(135deg, #f59e0b 0%, #d97706 50%, #b45309 100%);

  --accent-emerald: #10b981;
  --accent-emerald-glow: rgba(16, 185, 129, 0.3);
  --accent-indigo: #6366f1;
  --accent-indigo-gradient: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  --accent-rose: #f43f5e;
  --accent-cyan: #06b6d4;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.25);
  --shadow-gold: 0 0 25px rgba(245, 158, 11, 0.25);

  --font-thai: 'Prompt', -apple-system, sans-serif;
  --font-en: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background-color: var(--bg-main);
  background-image: 
    radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.12) 0px, transparent 50%),
    radial-gradient(at 100% 0%, rgba(245, 158, 11, 0.1) 0px, transparent 50%),
    radial-gradient(at 50% 100%, rgba(16, 185, 129, 0.08) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-primary);
  font-family: var(--font-thai);
  font-weight: 400;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
  background: #252f44;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #3b4865;
}

/* -------------------------------------------------------------
   HEADER & NAVBAR
   ------------------------------------------------------------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 14, 23, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-glass);
  padding: 0.85rem 1.75rem;
}

.header-container {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  text-decoration: none;
  cursor: pointer;
}

.brand-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--accent-gold-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  box-shadow: var(--shadow-gold);
}

.brand-title {
  font-family: var(--font-thai);
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-family: var(--font-en);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* System Status Pill */
.system-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.35rem 0.9rem;
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 600;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #34d399;
  transition: all 0.3s ease;
}

.system-status-pill.status-closed {
  background: rgba(244, 63, 94, 0.12);
  border-color: rgba(244, 63, 94, 0.3);
  color: #fb7185;
}

.status-indicator-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: currentColor;
  box-shadow: 0 0 10px currentColor;
  animation: pulse-dot 2s infinite ease-in-out;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

/* Period Display in Header */
.period-badge {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass);
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: #cbd5e1;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* User Profile & Actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem;
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: 9999px;
  font-size: 0.85rem;
  color: #c7d2fe;
}

.role-tag {
  font-size: 0.7rem;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  background: var(--accent-indigo);
  color: white;
  font-weight: 600;
  text-transform: uppercase;
}

.role-tag.admin {
  background: var(--accent-gold);
  color: #000;
}

/* -------------------------------------------------------------
   NAVIGATION TABS
   ------------------------------------------------------------- */
.nav-tabs-wrapper {
  max-width: 1440px;
  margin: 1.25rem auto 0;
  padding: 0 1.75rem;
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border-glass);
}

.nav-tab-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-thai);
  font-size: 0.95rem;
  font-weight: 500;
  padding: 0.75rem 1.4rem;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.25s ease;
  position: relative;
}

.nav-tab-btn:hover {
  color: #fff;
}

.nav-tab-btn.active {
  color: #fff;
  font-weight: 600;
  border-bottom-color: var(--accent-gold);
}

.nav-tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 10px;
  background: radial-gradient(ellipse at bottom, rgba(245, 158, 11, 0.4) 0%, transparent 70%);
}

.badge-counter {
  font-size: 0.72rem;
  padding: 0.1rem 0.45rem;
  border-radius: 9999px;
  background: rgba(245, 158, 11, 0.2);
  color: var(--accent-gold);
  font-family: var(--font-mono);
  font-weight: 700;
}

/* -------------------------------------------------------------
   MAIN CONTAINER & SECTIONS
   ------------------------------------------------------------- */
.app-main {
  max-width: 1440px;
  margin: 1.5rem auto 3rem;
  padding: 0 1.75rem;
}

.tab-pane {
  display: none;
  animation: fadeIn 0.3s ease forwards;
}

.tab-pane.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* -------------------------------------------------------------
   LOCKED / CLOSED SYSTEM BANNER
   ------------------------------------------------------------- */
.lock-banner {
  background: linear-gradient(135deg, rgba(244, 63, 94, 0.15) 0%, rgba(15, 23, 42, 0.8) 100%);
  border: 1px solid rgba(244, 63, 94, 0.3);
  border-radius: var(--radius-lg);
  padding: 2.25rem 2rem;
  text-align: center;
  margin-bottom: 2rem;
  backdrop-filter: blur(12px);
  position: relative;
  overflow: hidden;
}

.lock-banner::before {
  content: '🔒';
  font-size: 8rem;
  position: absolute;
  top: -20px;
  right: -20px;
  opacity: 0.05;
  pointer-events: none;
}

.lock-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #fda4af;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.lock-subtitle {
  color: #cbd5e1;
  font-size: 0.95rem;
  max-width: 650px;
  margin: 0 auto 1.5rem;
}

.countdown-box {
  display: inline-flex;
  gap: 1.25rem;
  background: rgba(0, 0, 0, 0.4);
  padding: 1rem 2rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.time-segment {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.time-num {
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 800;
  color: #fff;
  line-height: 1;
}

.time-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.25rem;
}

/* -------------------------------------------------------------
   SCANNER SECTION (หน้าร้านค้าสแกนสลาก)
   ------------------------------------------------------------- */
.scanner-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.75rem;
}

@media (max-width: 960px) {
  .scanner-grid {
    grid-template-columns: 1fr;
  }
}

.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-xl);
  padding: 1.75rem;
  box-shadow: var(--shadow-card);
  transition: border-color 0.3s ease;
}

.glass-card:hover {
  border-color: rgba(255, 255, 255, 0.12);
}

.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.card-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* Scan Input Box */
.scan-viewport {
  position: relative;
  background: rgba(0, 0, 0, 0.5);
  border: 2px dashed rgba(245, 158, 11, 0.4);
  border-radius: var(--radius-lg);
  padding: 2.25rem 1.5rem;
  text-align: center;
  overflow: hidden;
  transition: all 0.3s ease;
}

.scan-viewport.focused {
  border-color: var(--accent-gold);
  box-shadow: 0 0 25px rgba(245, 158, 11, 0.25);
  background: rgba(0, 0, 0, 0.65);
}

.scan-viewport.success-pulse {
  border-color: var(--accent-emerald);
  box-shadow: 0 0 35px rgba(16, 185, 129, 0.4);
}

.scan-viewport.dup-pulse {
  border-color: var(--accent-rose);
  box-shadow: 0 0 35px rgba(244, 63, 94, 0.4);
}

/* Laser animation */
.scan-laser {
  position: absolute;
  top: 0;
  left: 5%;
  width: 90%;
  height: 2px;
  background: linear-gradient(90deg, transparent, #fbbf24, #f59e0b, transparent);
  box-shadow: 0 0 12px #f59e0b;
  animation: laserSweep 2.2s infinite ease-in-out;
  pointer-events: none;
}

@keyframes laserSweep {
  0% { top: 5%; opacity: 0.3; }
  50% { top: 92%; opacity: 1; }
  100% { top: 5%; opacity: 0.3; }
}

.scan-input-primary {
  width: 100%;
  background: transparent;
  border: none;
  color: #fff;
  font-family: var(--font-mono);
  font-size: 2.5rem;
  font-weight: 800;
  text-align: center;
  letter-spacing: 0.2em;
  outline: none;
  caret-color: var(--accent-gold);
}

.scan-input-primary::placeholder {
  color: var(--text-muted);
  font-size: 1.35rem;
  letter-spacing: 0.05em;
  font-family: var(--font-thai);
  font-weight: 400;
}

.scan-hint {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

/* Simulation / Demo Action Toolbar */
.demo-toolbar {
  margin-top: 1.25rem;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-glass);
}

.demo-toolbar-title {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.demo-buttons-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.btn-demo-chip {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--border-glass);
  color: #e2e8f0;
  font-size: 0.8rem;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--font-thai);
  transition: all 0.2s;
}

.btn-demo-chip:hover {
  background: rgba(245, 158, 11, 0.2);
  border-color: var(--accent-gold);
  color: var(--accent-gold);
}

/* Recent Scans Table */
.recent-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  max-height: 480px;
  overflow-y: auto;
  padding-right: 0.4rem;
}

.recent-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
}

.recent-item:hover {
  background: rgba(255, 255, 255, 0.06);
  transform: translateX(3px);
}

.ticket-digits-badge {
  font-family: var(--font-mono);
  font-size: 1.35rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.08em;
}

.match-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  font-size: 0.78rem;
  font-weight: 600;
}

.match-status-badge.matched {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.4);
  color: var(--accent-gold);
}

.match-status-badge.waiting {
  background: rgba(148, 163, 184, 0.12);
  border: 1px solid rgba(148, 163, 184, 0.25);
  color: #cbd5e1;
}

/* -------------------------------------------------------------
   ADMIN DASHBOARD SECTION (สรุปผลเลขชน)
   ------------------------------------------------------------- */
.stats-cards-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
  margin-bottom: 2rem;
}

@media (max-width: 1024px) {
  .stats-cards-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .stats-cards-grid {
    grid-template-columns: 1fr;
  }
}

.stat-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 1.35rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.stat-card.gold-highlight {
  border-color: rgba(245, 158, 11, 0.35);
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.1) 0%, rgba(18, 24, 38, 0.8) 100%);
}

.stat-card.emerald-highlight {
  border-color: rgba(16, 185, 129, 0.35);
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(18, 24, 38, 0.8) 100%);
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 2.25rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.1;
}

.stat-card.gold-highlight .stat-value {
  color: #fbbf24;
}

.stat-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Filter & Search Bar */
.filter-toolbar {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.filter-group-left {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
}

.btn-filter-pill {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  font-family: var(--font-thai);
  padding: 0.45rem 1rem;
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-filter-pill:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.btn-filter-pill.active {
  background: var(--accent-gold);
  border-color: var(--accent-gold);
  color: #000;
  font-weight: 700;
}

.search-input-box {
  position: relative;
  min-width: 260px;
}

.search-input-field {
  width: 100%;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  padding: 0.5rem 1rem 0.5rem 2.25rem;
  color: #fff;
  font-family: var(--font-thai);
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.2s;
}

.search-input-field:focus {
  border-color: var(--accent-gold);
}

.search-icon-adornment {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  font-size: 0.85rem;
}

/* Matching Cards Grid */
.matches-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 1.25rem;
}

.match-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 1.35rem 1.5rem;
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.match-card:hover {
  transform: translateY(-3px);
  border-color: rgba(245, 158, 11, 0.4);
  box-shadow: 0 12px 30px -8px rgba(0, 0, 0, 0.8), 0 0 20px rgba(245, 158, 11, 0.15);
}

.match-card.tier-10plus {
  border-color: rgba(245, 158, 11, 0.5);
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.12) 0%, rgba(18, 24, 38, 0.85) 100%);
}

.match-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.ticket-number-display {
  font-family: var(--font-mono);
  font-size: 2.1rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.06em;
  line-height: 1;
}

.set-size-badge {
  background: var(--accent-gold-gradient);
  color: #000;
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 800;
  padding: 0.35rem 0.9rem;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.shops-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.85rem;
}

.shop-chip {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 0.3rem 0.65rem;
  font-size: 0.78rem;
  color: #cbd5e1;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.shop-chip-qty {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent-gold);
  background: rgba(245, 158, 11, 0.15);
  padding: 0.05rem 0.35rem;
  border-radius: 4px;
}

/* -------------------------------------------------------------
   BUTTONS & COMMON COMPONENTS
   ------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.35rem;
  border-radius: var(--radius-md);
  font-family: var(--font-thai);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent-gold-gradient);
  color: #000;
  box-shadow: 0 4px 16px rgba(245, 158, 11, 0.35);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.5);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--border-glass);
  color: #fff;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-danger {
  background: rgba(244, 63, 94, 0.2);
  border: 1px solid rgba(244, 63, 94, 0.4);
  color: #fda4af;
}

.btn-danger:hover {
  background: rgba(244, 63, 94, 0.35);
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

/* Forms */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.88rem;
  font-weight: 500;
  color: #cbd5e1;
  margin-bottom: 0.45rem;
}

.form-control {
  width: 100%;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  color: #fff;
  font-family: var(--font-thai);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-control:focus {
  border-color: var(--accent-gold);
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-container {
  background: #121826;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-xl);
  max-width: 600px;
  width: 100%;
  padding: 2rem;
  box-shadow: var(--shadow-card);
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-close-btn {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  transition: color 0.2s;
}

.modal-close-btn:hover {
  color: #fff;
}

/* Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table th {
  padding: 0.85rem 1rem;
  background: rgba(255, 255, 255, 0.03);
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 600;
  border-bottom: 1px solid var(--border-glass);
}

.data-table td {
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border-glass);
  font-size: 0.9rem;
  color: #e2e8f0;
}

.data-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.toast {
  background: #1e293b;
  border-left: 4px solid var(--accent-gold);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1.25rem;
  color: #fff;
  font-size: 0.9rem;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  gap: 0.65rem;
  animation: slideInRight 0.3s ease;
}

.toast.success { border-left-color: var(--accent-emerald); }
.toast.error { border-left-color: var(--accent-rose); }

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.badge-status {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
}
.badge-status.active {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}
.badge-status.suspended {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}
.table-actions-cell {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-wrap: wrap;
}

.badge-role {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-family: var(--font-mono);
  white-space: nowrap;
}
.badge-role.admin {
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.35);
}
.badge-role.user {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

/* -------------------------------------------------------------
   LOGIN SCREEN (FORCED AUTHENTICATION - FULL SCREEN BLOCKER)
   ------------------------------------------------------------- */
.login-screen-wrapper {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 50% 30%, #1e1b4b 0%, #09090b 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999999;
  padding: 1.5rem;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: rgba(24, 24, 27, 0.9);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-lg, 16px);
  padding: 2.5rem 2rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8), 0 0 50px rgba(99, 102, 241, 0.18);
  animation: loginFadeIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes loginFadeIn {
  from { opacity: 0; transform: scale(0.94) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* -------------------------------------------------------------
   PRINT STYLES: PICK LIST (ใบจัดสลาก)
   ------------------------------------------------------------- */
@media print {
  body {
    background: #fff !important;
    color: #000 !important;
  }
  .app-header, .nav-tabs-wrapper, .app-main, .login-screen-wrapper, .modal-close-btn, .toast-container, button {
    display: none !important;
  }
  .modal-overlay {
    position: static !important;
    background: none !important;
    padding: 0 !important;
    display: block !important;
    opacity: 1 !important;
  }
  .modal-container {
    background: #fff !important;
    color: #000 !important;
    border: none !important;
    box-shadow: none !important;
    max-width: 100% !important;
    padding: 0 !important;
  }
  .data-table {
    width: 100% !important;
    border-collapse: collapse !important;
  }
  .data-table th, .data-table td {
    border: 1px solid #ddd !important;
    color: #000 !important;
    padding: 8px !important;
  }
  .data-table th {
    background: #f3f4f6 !important;
  }
}

/* -------------------------------------------------------------
   THEME CONSISTENT SELECT & DROPDOWN STYLING
   ------------------------------------------------------------- */
select,
select.form-control,
.user-switcher-select {
  background-color: #18181b !important;
  color: #f1f5f9 !important;
  border: 1px solid rgba(255, 255, 255, 0.18) !important;
  border-radius: var(--radius-sm, 8px);
  padding: 0.45rem 0.75rem;
  font-family: var(--font-primary, inherit);
  cursor: pointer;
  outline: none;
  transition: all 0.2s ease;
}

select:focus,
select.form-control:focus,
.user-switcher-select:focus {
  border-color: var(--accent-gold, #f59e0b) !important;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.25) !important;
}

select option,
select.form-control option,
.user-switcher-select option {
  background-color: #18181b !important;
  color: #f8fafc !important;
  padding: 10px 14px !important;
}

.user-switcher-select {
  background: rgba(24, 24, 27, 0.95) !important;
  border: 1px solid rgba(245, 158, 11, 0.45) !important;
  color: #fbbf24 !important;
  font-weight: 600;
  font-size: 0.82rem;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-md, 8px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.user-switcher-select:hover {
  border-color: #fbbf24 !important;
  background: rgba(30, 27, 75, 0.9) !important;
}

/* Shop Dashboard Specific Styling */
.btn-shop-filter-pill {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-secondary);
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-shop-filter-pill:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.btn-shop-filter-pill.active {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.2) 0%, rgba(217, 119, 6, 0.3) 100%);
  border-color: #f59e0b;
  color: #fbbf24;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.25);
}

.impersonate-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
}

/* =============================================================
   MOBILE & TABLET RESPONSIVE DESIGN (SMARTPHONES, IPAD, TABLET)
   ============================================================= */

/* Universal Touch & Performance Optimizations */
button, 
.btn, 
.nav-tab-btn, 
.btn-filter-pill, 
.btn-shop-filter-pill,
select,
input {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button:active, 
.btn:active, 
.nav-tab-btn:active, 
.btn-filter-pill:active, 
.btn-shop-filter-pill:active {
  transform: scale(0.97);
  transition: transform 0.1s ease;
}

/* Ensure inputs on mobile don't trigger iOS Safari auto-zoom */
input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea {
  font-size: 16px !important;
}

/* Table Responsive Container */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-glass);
}

.action-bar-responsive {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.action-buttons-group {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
}

@media (max-width: 768px) {
  .action-bar-responsive {
    flex-direction: column;
    align-items: stretch;
    gap: 0.85rem;
  }
  .action-buttons-group {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    width: 100%;
  }
  .action-buttons-group .btn {
    width: 100%;
    justify-content: center;
    padding: 0.6rem 0.5rem;
    font-size: 0.82rem;
    text-align: center;
  }
}

@media (max-width: 480px) {
  .action-buttons-group {
    grid-template-columns: 1fr;
  }
}

/* -------------------------------------------------------------
   1. TABLET & IPAD (Landscape & Portrait <= 1024px)
   ------------------------------------------------------------- */
@media (max-width: 1024px) {
  .app-header {
    padding: 0.85rem 1.25rem;
  }

  .app-main {
    padding: 1.25rem 1.25rem;
  }

  .nav-tabs-wrapper {
    padding: 0 1.25rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .nav-tabs-wrapper::-webkit-scrollbar {
    display: none;
  }

  .nav-tab-btn {
    flex-shrink: 0;
    padding: 0.75rem 1.1rem;
    font-size: 0.9rem;
    min-height: 44px;
  }

  .stats-cards-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 1rem;
  }

  .matches-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 1rem;
  }

  .scanner-grid {
    grid-template-columns: 1fr !important;
    gap: 1.5rem;
  }
}

/* -------------------------------------------------------------
   2. SMALL TABLET & PHABLET (<= 768px)
   ------------------------------------------------------------- */
@media (max-width: 768px) {
  .app-header {
    padding: 0.75rem 1rem;
  }

  .header-container {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .brand-wrapper {
    justify-content: space-between;
    width: 100%;
  }

  .brand-title {
    font-size: 1.15rem;
  }

  .brand-icon {
    width: 38px;
    height: 38px;
    font-size: 1.2rem;
  }

  .header-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    width: 100%;
  }

  .user-switcher-wrapper {
    flex: 1 1 100%;
    display: flex;
    gap: 0.5rem;
  }

  .user-switcher-select {
    flex: 1;
    min-width: 0;
    width: 100%;
    font-size: 0.85rem;
    padding: 0.5rem 0.75rem;
  }

  #returnAdminBtn {
    flex-shrink: 0;
    padding: 0.5rem 0.85rem !important;
    font-size: 0.82rem !important;
    min-height: 38px;
  }

  .user-badge {
    padding: 0.3rem 0.65rem;
    font-size: 0.8rem;
  }

  /* Filter toolbar on small tablet */
  .filter-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.85rem;
    padding: 0.85rem 1rem;
  }

  .filter-group-left {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 0.35rem;
  }

  .filter-group-left::-webkit-scrollbar {
    display: none;
  }

  .btn-filter-pill,
  .btn-shop-filter-pill {
    flex-shrink: 0;
    font-size: 0.8rem;
    padding: 0.4rem 0.8rem;
  }

  .search-input-box {
    width: 100%;
    min-width: 100%;
  }

  .modal-container {
    width: 95vw !important;
    max-width: 95vw !important;
    padding: 1.25rem !important;
    border-radius: var(--radius-lg) !important;
  }

  .countdown-box {
    padding: 0.75rem 1.25rem;
    gap: 0.85rem;
  }

  .time-num {
    font-size: 1.5rem;
  }

  .toast-container {
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
  }

  .toast {
    width: 100%;
    font-size: 0.85rem;
    padding: 0.75rem 1rem;
  }
}

/* -------------------------------------------------------------
   3. SMARTPHONES (<= 540px)
   ------------------------------------------------------------- */
@media (max-width: 540px) {
  .app-main {
    padding: 1rem 0.75rem;
    margin: 1rem auto 2.5rem;
  }

  .nav-tabs-wrapper {
    padding: 0 0.75rem;
    margin-top: 0.5rem;
  }

  .nav-tab-btn {
    padding: 0.65rem 0.85rem;
    font-size: 0.82rem;
  }

  /* 2x2 Grid for Metric Cards on Phone so they look like sleek app widgets */
  .stats-cards-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.65rem !important;
    margin-bottom: 1.25rem;
  }

  .stat-card {
    padding: 0.9rem 0.85rem;
    border-radius: var(--radius-md);
    gap: 0.35rem;
  }

  .stat-label {
    font-size: 0.74rem;
  }

  .stat-value {
    font-size: 1.5rem;
  }

  .stat-desc {
    font-size: 0.68rem;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  /* Single Column Matches Grid on Phone */
  .matches-grid {
    grid-template-columns: 1fr !important;
    gap: 0.85rem !important;
  }

  .match-card {
    padding: 1rem;
    border-radius: var(--radius-lg);
  }

  .ticket-number-display {
    font-size: 1.45rem;
  }

  /* Scanner Box on Phone */
  .glass-card {
    padding: 1.15rem 0.9rem;
    border-radius: var(--radius-lg);
  }

  .card-title {
    font-size: 1.05rem;
  }

  .scan-viewport {
    padding: 1.5rem 1rem;
  }

  .scan-input-field {
    font-size: 1.1rem !important;
    padding: 0.75rem 0.85rem;
  }

  .lock-banner {
    padding: 1.5rem 1rem;
  }

  .lock-title {
    font-size: 1.2rem;
  }

  .lock-subtitle {
    font-size: 0.85rem;
  }

  .time-num {
    font-size: 1.3rem;
  }

  .time-label {
    font-size: 0.68rem;
  }

  /* Login Card on Phone */
  .login-card {
    padding: 1.75rem 1.25rem;
    border-radius: var(--radius-lg);
  }

  .login-card h1 {
    font-size: 1.35rem !important;
  }

  /* Button Tap targets */
  .btn {
    padding: 0.6rem 1rem;
    font-size: 0.88rem;
    min-height: 42px;
  }

  .btn-sm {
    min-height: 36px;
    padding: 0.35rem 0.65rem;
  }
}

/* -------------------------------------------------------------
   4. ULTRA-SMALL PHONES (<= 375px e.g. iPhone SE)
   ------------------------------------------------------------- */
@media (max-width: 375px) {
  .brand-title {
    font-size: 1rem;
  }

  .stat-value {
    font-size: 1.35rem;
  }

  .stats-cards-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 0.5rem !important;
  }
}



