:root {
  /* โทนสีฟ้า/กรมท่า ตามภาพโบรชัวร์อ้างอิง (เดิมเป็นโทนส้ม) — ยังใช้ชื่อตัวแปร --orange เดิมไว้ (ไม่เปลี่ยนชื่อ)
     เพื่อไม่ต้องแก้จุดที่อ้างถึงตัวแปรนี้ทั่วทั้งเว็บ */
  --orange: #0EA5E9;
  --orange-dark: #0284C7;
  --orange-light: #E0F2FE;
  --navy: #16293F;
  --navy-dark: #0F1D2E;
  --blue: #2563EB;
  --blue-dark: #1D4ED8;
  --gray-900: #1F2937;
  --gray-700: #374151;
  --gray-500: #6B7280;
  --gray-200: #E5E7EB;
  --gray-100: #F3F4F6;
  --bg: #EEF1F5;
  --white: #FFFFFF;
  --green: #16A34A;
  --green-light: #ECFDF3;
  --red: #DC2626;
  --red-dark: #B91C1C;
  --red-light: #FEF2F2;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
}

/* ป้ายบอกว่ารายการนี้ใช้ "รหัสเฉพาะ" (เช่น JS0007) แทนทะเบียนรถจริง — ใช้ร่วมกันหลายหน้า (staff/history/reports) */
.id-badge {
  display: inline-block; font-size: 10px; font-weight: 700; color: var(--blue);
  background: #EFF6FF; border: 1px solid var(--blue); border-radius: 6px; padding: 1px 8px; margin-left: 4px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  font-family: "Sarabun", "Segoe UI", -apple-system, sans-serif;
  background: var(--bg);
  color: var(--gray-900);
}
a { color: inherit; }

/* ---------- Login ---------- */
.login-body {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--orange) 0%, var(--orange-dark) 100%);
}
.login-card {
  background: var(--white);
  padding: 40px 36px;
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  width: 100%; max-width: 360px;
  display: flex; flex-direction: column; gap: 4px;
}
.login-logo { font-size: 40px; text-align: center; margin-bottom: 8px; }
.login-card h1 { font-size: 19px; text-align: center; margin: 0 0 20px; color: var(--gray-900); }
.login-card label { font-size: 13px; color: var(--gray-500); margin-top: 12px; }
.login-card input {
  padding: 12px 14px; border: 1px solid var(--gray-200); border-radius: 8px;
  font-size: 15px; margin-top: 4px;
}
.alert-error {
  background: var(--red-light); color: var(--red);
  padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 8px;
}

/* ---------- Layout ---------- */
.topbar {
  background: var(--white); border-bottom: 1px solid var(--gray-200);
  display: flex; flex-direction: column; gap: 8px;
  padding: 12px 24px; position: sticky; top: 0; z-index: 10;
}
/* แถวบน (โลโก้/ชื่อ site/ผู้ใช้) แยกจากแถวเมนู (nav) เป็นคนละแถวกัน กันชื่อ site ที่จัดกึ่งกลางแบบ
   position: absolute ไปทับเมนูที่มีหลายลิงก์ (เมื่อก่อนอยู่แถวเดียวกับ nav แล้วข้อความยาวๆ ไปบังลิงก์ "สมาชิก"/"ประเภทรถ" ได้) */
.topbar-row1 { display: flex; align-items: center; justify-content: space-between; position: relative; }
.topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--orange); font-size: 18px; }
/* ชื่อ site (เช่น "ตลาดเจริญศรี") จัดไว้กึ่งกลางแถวบนเสมอ ไม่ว่า brand/user ฝั่งซ้าย-ขวาจะกว้างเท่าไหร่ */
.topbar-site-center {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  font-weight: 700; color: var(--gray-700); font-size: 22px; white-space: nowrap;
}
@media (max-width: 640px) { .topbar-site-center { display: none; } }
.topbar nav { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; }
.topbar nav a {
  text-decoration: none; padding: 12px 16px; border-radius: 8px; font-size: 14px;
  color: var(--gray-700); font-weight: 500; display: inline-flex; align-items: center;
  min-height: 44px; box-sizing: border-box; touch-action: manipulation;
}
.topbar nav a.active, .topbar nav a:hover { background: var(--orange-light); color: var(--orange-dark); }
.topbar .user { font-size: 13px; color: var(--gray-500); display: flex; align-items: center; gap: 10px; }
.topbar .user a { color: var(--orange); text-decoration: none; font-weight: 600; }

.container { max-width: 1180px; margin: 0 auto; padding: 24px; }
.page-title { font-size: 22px; font-weight: 700; margin: 0 0 4px; }
.page-sub { color: var(--gray-500); font-size: 14px; margin: 0 0 20px; }

/* ---------- Cards / stats ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); gap: 14px; margin-bottom: 24px; }
.stat-card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.stat-card .label { font-size: 13px; color: var(--gray-500); }
.stat-card .value { font-size: 26px; font-weight: 700; margin-top: 4px; }
.stat-card.orange .value { color: var(--orange); }
.stat-card.green .value { color: var(--green); }

.section-title { font-size: 16px; font-weight: 700; margin: 28px 0 12px; display: flex; align-items: center; gap: 8px; }
.badge-count { background: var(--orange); color: #fff; font-size: 12px; padding: 2px 9px; border-radius: 6px; }

/* ---------- Vehicle queue cards ---------- */
.queue-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px,1fr)); gap: 16px; }
.vcard {
  background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden; border: 1px solid var(--gray-200);
}
.vcard .thumb { width: 100%; height: 150px; background: var(--gray-100) center/cover no-repeat; display:flex; align-items:center; justify-content:center; color: var(--gray-500); font-size: 13px; }
.vcard .body { padding: 14px; }
.vcard .plate { font-size: 20px; font-weight: 700; }
.vcard .meta { font-size: 12px; color: var(--gray-500); margin-top: 2px; }
.vcard .row { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.vcard select { padding: 11px 10px; border-radius: 8px; border: 1px solid var(--gray-200); font-size: 15px; min-height: 44px; touch-action: manipulation; }
.vcard .price { font-size: 18px; font-weight: 700; color: var(--orange); }
.vcard .actions { display: flex; gap: 8px; margin-top: 12px; }
.tag { font-size: 11px; padding: 3px 9px; border-radius: 6px; font-weight: 600; }
.tag-unregistered { background: var(--red-light); color: var(--red); }
.tag-pending { background: var(--orange-light); color: var(--orange-dark); }
.tag-paid { background: var(--green-light); color: var(--green); }
.tag-manual { background: var(--gray-100); color: var(--gray-500); }

/* ---------- Buttons ---------- */
/* ขนาดปุ่มปรับให้กดง่ายบนจอทัชสกรีน (touch target ขั้นต่ำ ~44px) ทุกหน้า
   touch-action: manipulation กันดีเลย์ 300ms ที่เบราว์เซอร์มือถือรอดูว่าจะ double-tap ซูมไหม */
.btn {
  border: none; border-radius: 99px; padding: 12px 18px; font-size: 15px; font-weight: 600;
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  min-height: 44px; touch-action: manipulation;
}
.btn-primary { background: var(--orange); color: #fff; }
.btn-primary:hover { background: var(--orange-dark); }
.btn-outline { background: var(--white); color: var(--gray-700); border: 1px solid var(--gray-200); }
.btn-outline:hover { background: var(--gray-100); }
.btn-block { width: 100%; margin-top: 22px; padding: 14px; font-size: 16px; min-height: 48px; }
.btn-sm { padding: 9px 14px; font-size: 13px; min-height: 38px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Tables ---------- */
.table-wrap { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 14px 16px; border-bottom: 1px solid var(--gray-100); }
th { background: var(--gray-100); color: var(--gray-500); font-weight: 600; font-size: 12px; text-transform: uppercase; }
tr:last-child td { border-bottom: none; }
/* checkbox ในตาราง (เช่นเลือกรายการออกรายงาน PDF) — ขยายให้แตะง่ายขึ้นบนจอทัชสกรีน */
td input[type="checkbox"], th input[type="checkbox"] { width: 20px; height: 20px; cursor: pointer; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
/* min-width: 0 กัน CSS Grid บังคับให้คอลัมน์กว้างเกิน 1fr ตาม min-content ของ label/input ยาวๆ (เช่น "รหัสประเภท * (เช่น A, 6W, PICKUP)")
   ซึ่งทำให้ฟอร์มล้นกรอบ modal ออกไป — ไม่มีบรรทัดนี้ label ยาวจะดันกล่องล้นแทนที่จะตัดคำ/ห่อบรรทัดตามปกติ */
.form-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.form-field label { font-size: 13px; color: var(--gray-500); font-weight: 600; }
.form-field input, .form-field select { padding: 12px; border: 1px solid var(--gray-200); border-radius: 8px; font-size: 15px; min-height: 44px; box-sizing: border-box; touch-action: manipulation; }
.card-block { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar input, .toolbar select { padding: 11px 12px; border: 1px solid var(--gray-200); border-radius: 8px; font-size: 15px; min-height: 44px; box-sizing: border-box; touch-action: manipulation; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--gray-500); font-size: 14px; }

/* ---------- Print slip ---------- */
.slip { width: 58mm; margin: 0 auto; padding: 8px; font-family: monospace; font-size: 12px; }
/* ประกาศขนาดกระดาษเป็นม้วนใบเสร็จ 58mm ให้เครื่องพิมพ์ความร้อนจริงตัดขอบกระดาษเปล่าออก
   (ช่วยลดพื้นที่หัว-ท้ายกระดาษที่บางเบราว์เซอร์ใส่ URL/วันที่ให้อัตโนมัติเวลาพิมพ์ไปด้วย
   แต่ปิดข้อความหัว-ท้ายกระดาษของเบราว์เซอร์เองแบบเต็มที่ต้องไปปิดที่ตัวเลือก "Headers and footers"
   ในหน้าต่างสั่งพิมพ์ของเบราว์เซอร์เอง หน้าเว็บสั่งปิดให้แทนไม่ได้) */
@media print { @page { size: 58mm auto; margin: 3mm; } }
.slip h2 { text-align: center; font-size: 14px; margin: 4px 0; }
.slip .line { border-top: 1px dashed #000; margin: 6px 0; }
.slip .row { display: flex; justify-content: space-between; margin: 3px 0; }
.slip .total { font-size: 15px; font-weight: 700; }
.slip-datetime { text-align: center; font-size: 10px; font-weight: 700; margin-bottom: 4px; white-space: nowrap; }
.slip-contact { text-align: center; font-size: 11px; margin-top: 6px; }
@media print { .no-print { display: none; } body { background: #fff; } }

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .topbar nav { display: none; }
}
