/* =====================================================================
   ระบบจัดการช่องจอดรถ — public/style.css
   ส่วนที่ Tailwind CDN ไม่มีให้: utility เฉพาะตัว, component ตาม class
   ที่ใช้ใน index.html (nav-tab, stat-card, zone-pill, tag-chip,
   status-radio-card, slot card, timeline, การ์ด A4 สำหรับพิมพ์รายงาน)
   ===================================================================== */

:root {
  --pk-green: #10b981;
  --pk-green-dark: #059669;
  --pk-red: #f43f5e;
  --pk-yellow: #f59e0b;
  --pk-purple: #a855f7;
  --pk-slate-850: #1e293b;
  --pk-slate-750: #293548;
  --pk-card-radius: 1rem;
}

/* ---------- 1. Fonts & base ---------- */
.font-prompt { font-family: "Prompt", "Segoe UI", Tahoma, sans-serif; }
.font-chakra { font-family: "Chakra Petch", "Prompt", ui-monospace, monospace; letter-spacing: .02em; }

html { scroll-behavior: smooth; -webkit-tap-highlight-color: transparent; }
body { text-rendering: optimizeLegibility; }

/* Tailwind v3 ไม่มี slate-850 / slate-750 — นิยามเพิ่มให้คลาสที่ใช้ใน index.html */
.bg-slate-850 { background-color: var(--pk-slate-850); }
.bg-slate-850\/50 { background-color: rgba(30, 41, 59, .5); }
.bg-slate-750 { background-color: var(--pk-slate-750); }
.hover\:bg-slate-750:hover { background-color: var(--pk-slate-750); }

/* ---------- 2. Scrollbar ---------- */
.scrollbar-none { scrollbar-width: none; -ms-overflow-style: none; }
.scrollbar-none::-webkit-scrollbar { display: none; height: 0; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: #0f172a; }
::-webkit-scrollbar-thumb { background: #334155; border-radius: 8px; border: 2px solid #0f172a; }
::-webkit-scrollbar-thumb:hover { background: #059669; }

/* ---------- 3. Navigation tabs ---------- */
.nav-tab {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  padding: .5rem .875rem;
  font-size: .75rem;
  font-weight: 600;
  color: #94a3b8;
  background: transparent;
  border: 1px solid transparent;
  border-radius: .75rem;
  cursor: pointer;
  transition: all .18s ease;
}
.nav-tab:hover { color: #e2e8f0; background: rgba(148, 163, 184, .1); }
.nav-tab.active-tab {
  color: #fff;
  background: linear-gradient(135deg, #059669, #14b8a6);
  border-color: rgba(20, 184, 166, .4);
  box-shadow: 0 6px 18px -8px rgba(5, 150, 105, .8);
}

/* ---------- 4. Stat cards (ตัวนับ 4 สถานะ) ---------- */
.stat-card {
  padding: .875rem 1rem;
  border-radius: var(--pk-card-radius);
  border-width: 1px;
  border-style: solid;
  transition: transform .15s ease, box-shadow .15s ease;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 12px 24px -18px rgba(0, 0, 0, .9); }

/* ---------- 5. Zone filter pills ---------- */
.zone-pill {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  padding: .35rem .75rem;
  font-size: .7rem;
  font-weight: 600;
  color: #cbd5e1;
  background: rgba(51, 65, 85, .5);
  border: 1px solid rgba(71, 85, 105, .6);
  border-radius: 9999px;
  cursor: pointer;
  transition: all .16s ease;
}
.zone-pill:hover { background: rgba(71, 85, 105, .9); color: #fff; }
.zone-pill.active {
  color: #052e16;
  background: linear-gradient(135deg, #34d399, #2dd4bf);
  border-color: rgba(45, 212, 191, .7);
  box-shadow: 0 4px 14px -6px rgba(16, 185, 129, .9);
}

/* ---------- 6. Tag chips (ติ๊กเลือกสาเหตุ / ห้อง / ประเภทรถ) ---------- */
.tag-chip, .type-chip {
  padding: .3rem .6rem;
  font-size: .68rem;
  font-weight: 600;
  color: #e2e8f0;
  background: rgba(30, 41, 59, .85);
  border: 1px solid rgba(100, 116, 139, .45);
  border-radius: .6rem;
  cursor: pointer;
  transition: all .14s ease;
  user-select: none;
}
.tag-chip:hover, .type-chip:hover { border-color: rgba(16, 185, 129, .7); color: #fff; transform: translateY(-1px); }
.tag-chip.selected {
  color: #052e16;
  background: linear-gradient(135deg, #34d399, #10b981);
  border-color: #10b981;
  box-shadow: 0 4px 12px -6px rgba(16, 185, 129, .9);
}
.tag-chip.selected::before { content: "✓ "; font-weight: 900; }
.type-chip.selected {
  color: #0c4a6e;
  background: linear-gradient(135deg, #7dd3fc, #38bdf8);
  border-color: #38bdf8;
  box-shadow: 0 4px 12px -6px rgba(56, 189, 248, .9);
}
.type-chip.selected::before { content: "✓ "; font-weight: 900; }

/* ---------- 7. Status radio cards ใน modal ---------- */
.status-radio-card { position: relative; display: block; }
.status-radio-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .15rem;
  padding: .7rem .4rem;
  min-height: 84px;
  color: #e2e8f0;
  background: rgba(15, 23, 42, .7);
  border: 2px solid rgba(71, 85, 105, .5);
  border-radius: .85rem;
  transition: all .16s ease;
}
.status-radio-card:hover .status-radio-inner { transform: translateY(-2px); }
.status-radio-card.green:hover .status-radio-inner { border-color: rgba(16, 185, 129, .7); }
.status-radio-card.red:hover .status-radio-inner { border-color: rgba(244, 63, 94, .7); }
.status-radio-card.yellow:hover .status-radio-inner { border-color: rgba(245, 158, 11, .7); }
.status-radio-card.purple:hover .status-radio-inner { border-color: rgba(168, 85, 247, .7); }

.status-radio-card input:checked + .status-radio-inner,
.status-radio-card.selected .status-radio-inner { border-style: solid; }
.status-radio-card.green input:checked + .status-radio-inner,
.status-radio-card.green.selected .status-radio-inner {
  background: rgba(16, 185, 129, .16); border-color: #10b981; color: #6ee7b7;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, .18), 0 10px 22px -14px rgba(16, 185, 129, .9);
}
.status-radio-card.red input:checked + .status-radio-inner,
.status-radio-card.red.selected .status-radio-inner {
  background: rgba(244, 63, 94, .16); border-color: #f43f5e; color: #fda4af;
  box-shadow: 0 0 0 3px rgba(244, 63, 94, .18), 0 10px 22px -14px rgba(244, 63, 94, .9);
}
.status-radio-card.yellow input:checked + .status-radio-inner,
.status-radio-card.yellow.selected .status-radio-inner {
  background: rgba(245, 158, 11, .16); border-color: #f59e0b; color: #fcd34d;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, .18), 0 10px 22px -14px rgba(245, 158, 11, .9);
}
.status-radio-card.purple input:checked + .status-radio-inner,
.status-radio-card.purple.selected .status-radio-inner {
  background: rgba(168, 85, 247, .16); border-color: #a855f7; color: #d8b4fe;
  box-shadow: 0 0 0 3px rgba(168, 85, 247, .18), 0 10px 22px -14px rgba(168, 85, 247, .9);
}

/* ---------- 8. Generic action button ---------- */
.btn-action {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  font-size: .75rem;
  border: none;
  cursor: pointer;
}
.btn-action:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- 9. Zone card & parking slot grid (render โดย app.js) ---------- */
.zone-card {
  background: rgba(30, 41, 59, .66);
  border: 1px solid rgba(71, 85, 105, .55);
  border-radius: 1.25rem;
  padding: .875rem;
  box-shadow: 0 18px 40px -32px rgba(0, 0, 0, .95);
  backdrop-filter: blur(6px);
}
.zone-card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .75rem; flex-wrap: wrap; }
.zone-card-title { display: flex; align-items: center; gap: .6rem; font-weight: 700; color: #fff; font-size: .9rem; }
.zone-icon {
  width: 2.25rem; height: 2.25rem; display: flex; align-items: center; justify-content: center;
  border-radius: .8rem; font-size: 1.05rem; color: #fff;
  background: linear-gradient(135deg, #0f766e, #059669);
  box-shadow: 0 8px 20px -12px rgba(5, 150, 105, .95);
}

.slot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .625rem; }
@media (max-width: 420px) { .slot-grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); } }

.slot-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: .3rem;
  padding: .6rem .65rem .55rem;
  border-radius: .9rem;
  background: rgba(15, 23, 42, .82);
  border: 2px solid rgba(71, 85, 105, .55);
  cursor: pointer;
  overflow: hidden;
  transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease;
}
.slot-card:hover { transform: translateY(-3px); box-shadow: 0 16px 30px -20px rgba(0, 0, 0, 1); }
.slot-card:active { transform: translateY(-1px) scale(.99); }
.slot-card .slot-stripe { position: absolute; inset: 0 auto 0 0; width: 5px; }

.slot-code { font-family: "Chakra Petch", monospace; font-weight: 700; font-size: .95rem; letter-spacing: .04em; color: #fff; }
.slot-status-label { font-size: .66rem; font-weight: 700; display: inline-flex; align-items: center; gap: .25rem; }
.slot-plate {
  font-family: "Chakra Petch", monospace;
  font-size: .78rem; font-weight: 700; letter-spacing: .04em;
  color: #fcd34d; background: rgba(2, 6, 23, .7);
  border: 1px solid rgba(148, 163, 184, .35);
  border-radius: .4rem; padding: .1rem .35rem;
  display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.slot-meta { font-size: .62rem; color: #94a3b8; display: flex; flex-direction: column; gap: .1rem; }
.slot-thumb {
  position: absolute; right: .5rem; top: .5rem; width: 2.4rem; height: 2.4rem;
  border-radius: .55rem; object-fit: cover; border: 1px solid rgba(148, 163, 184, .4);
  box-shadow: 0 6px 14px -8px rgba(0, 0, 0, 1);
}
.slot-duration { font-size: .6rem; color: #fbbf24; font-weight: 600; }

/* สถานะ 4 สี */
.slot-card.s-available { border-color: rgba(16, 185, 129, .75); background: linear-gradient(160deg, rgba(6, 78, 59, .5), rgba(15, 23, 42, .9)); }
.slot-card.s-available .slot-stripe { background: #10b981; }
.slot-card.s-available .slot-status-label { color: #6ee7b7; }

.slot-card.s-occupied { border-color: rgba(244, 63, 94, .8); background: linear-gradient(160deg, rgba(76, 5, 25, .55), rgba(15, 23, 42, .9)); }
.slot-card.s-occupied .slot-stripe { background: #f43f5e; }
.slot-card.s-occupied .slot-status-label { color: #fda4af; }

.slot-card.s-temporary_out { border-color: rgba(245, 158, 11, .8); background: linear-gradient(160deg, rgba(120, 53, 15, .5), rgba(15, 23, 42, .9)); }
.slot-card.s-temporary_out .slot-stripe { background: #f59e0b; }
.slot-card.s-temporary_out .slot-status-label { color: #fcd34d; }

.slot-card.s-reserved { border-color: rgba(168, 85, 247, .8); background: linear-gradient(160deg, rgba(76, 29, 149, .5), rgba(15, 23, 42, .9)); }
.slot-card.s-reserved .slot-stripe { background: #a855f7; }
.slot-card.s-reserved .slot-status-label { color: #d8b4fe; }

.slot-card.pulse-sync { animation: slotPulse .9s ease; }
@keyframes slotPulse {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, .55); }
  100% { box-shadow: 0 0 0 14px rgba(16, 185, 129, 0); }
}

/* ---------- 10. History table ---------- */
#history-table-body tr { transition: background .12s ease; }
#history-table-body tr:hover { background: rgba(51, 65, 85, .32); }
#history-table-body tr.is-stale td { color: #94a3b8; }
.status-badge {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .12rem .5rem; border-radius: 9999px;
  font-size: .62rem; font-weight: 700; border: 1px solid transparent; white-space: nowrap;
}
.status-badge.b-available { color: #6ee7b7; background: rgba(16, 185, 129, .12); border-color: rgba(16, 185, 129, .4); }
.status-badge.b-occupied { color: #fda4af; background: rgba(244, 63, 94, .12); border-color: rgba(244, 63, 94, .4); }
.status-badge.b-temporary_out { color: #fcd34d; background: rgba(245, 158, 11, .12); border-color: rgba(245, 158, 11, .4); }
.status-badge.b-reserved { color: #d8b4fe; background: rgba(168, 85, 247, .12); border-color: rgba(168, 85, 247, .4); }
.reason-tag {
  display: inline-block; font-size: .58rem; font-weight: 600; color: #5eead4;
  background: rgba(20, 184, 166, .12); border: 1px solid rgba(20, 184, 166, .3);
  border-radius: .35rem; padding: .05rem .3rem; margin: .05rem .1rem .05rem 0;
}
.mini-photo { width: 2.2rem; height: 2.2rem; object-fit: cover; border-radius: .45rem; border: 1px solid rgba(148, 163, 184, .4); cursor: zoom-in; }

/* ---------- 11. Timeline (ประวัติรายช่อง) ---------- */
.timeline-item {
  position: relative; padding-left: 1.6rem; padding-bottom: .85rem;
  border-left: 2px dashed rgba(100, 116, 139, .35);
}
.timeline-item:last-child { border-left-color: transparent; }
.timeline-dot {
  position: absolute; left: -.48rem; top: .1rem; width: .95rem; height: .95rem;
  border-radius: 9999px; border: 2px solid #0f172a;
}
.timeline-card { background: rgba(15, 23, 42, .7); border: 1px solid rgba(71, 85, 105, .5); border-radius: .8rem; padding: .6rem .7rem; }

/* ---------- 12. Modal helpers ---------- */
#modal-update-slot:not(.hidden), #modal-slot-timeline:not(.hidden),
#modal-report:not(.hidden), #modal-share-report:not(.hidden),
#modal-screenshot-share:not(.hidden), #modal-share-slot:not(.hidden) { display: flex; }
.modal-body-scroll { scrollbar-width: thin; }
.modal-enter { animation: modalIn .18s ease-out; }
@keyframes modalIn { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------- 13. OCR / camera ---------- */
.ocr-progress-wrap { background: rgba(2, 6, 23, .8); border: 1px solid rgba(20, 184, 166, .35); border-radius: .8rem; padding: .6rem .75rem; }
.ocr-bar { height: .4rem; border-radius: 9999px; background: rgba(51, 65, 85, .8); overflow: hidden; }
.ocr-bar > span { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, #10b981, #38bdf8); transition: width .2s ease; }
#live-camera-video { background: #000; }
.viewfinder-off #live-camera-video { display: none; }

/* ---------- 14. Offline / sync toast ---------- */
.pk-toast {
  position: fixed; right: 1rem; bottom: 1rem; z-index: 9999;
  display: flex; align-items: center; gap: .5rem;
  padding: .6rem .9rem; border-radius: .8rem; font-size: .72rem; font-weight: 600;
  background: rgba(15, 23, 42, .96); border: 1px solid rgba(100, 116, 139, .5); color: #e2e8f0;
  box-shadow: 0 20px 40px -24px rgba(0, 0, 0, 1);
  animation: toastIn .2s ease-out;
}
.pk-toast.ok { border-color: rgba(16, 185, 129, .6); color: #6ee7b7; }
.pk-toast.warn { border-color: rgba(245, 158, 11, .6); color: #fcd34d; }
.pk-toast.err { border-color: rgba(244, 63, 94, .6); color: #fda4af; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ---------- 15. Report document (A4) ---------- */
#report-document-wrapper { color: #0f172a; }
.report-page {
  width: 210mm; min-height: 296mm; margin: 0 auto 1rem; padding: 12mm 12mm 14mm;
  background: #fff; color: #0f172a;
  box-shadow: 0 10px 30px -18px rgba(0, 0, 0, .8);
  border-radius: .35rem;
  font-family: "Prompt", "Segoe UI", sans-serif;
}
.report-page:last-child { margin-bottom: 0; }
.report-head { border-bottom: 3px double #0f172a; padding-bottom: .45rem; margin-bottom: .7rem; }
.report-head h1 { font-size: 17pt; font-weight: 800; margin: 0; color: #065f46; }
.report-head .report-sub { font-size: 9.5pt; color: #334155; margin-top: .15rem; }
.report-head .report-meta { display: flex; flex-wrap: wrap; gap: .35rem 1.1rem; font-size: 8.5pt; color: #475569; margin-top: .35rem; }
.report-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .35rem; margin: .6rem 0 .8rem; }
.report-kpi { border: 1.5px solid #cbd5e1; border-radius: 6px; padding: .35rem .45rem; }
.report-kpi .k-label { font-size: 8pt; color: #475569; }
.report-kpi .k-value { font-family: "Chakra Petch", monospace; font-size: 13pt; font-weight: 700; color: #0f172a; line-height: 1.1; }
table.report-table { width: 100%; border-collapse: collapse; font-size: 8.6pt; }
table.report-table th, table.report-table td { border: 1px solid #94a3b8; padding: .28rem .35rem; text-align: left; vertical-align: top; }
table.report-table thead th { background: #0f172a; color: #fff; font-size: 8.2pt; font-weight: 700; }
table.report-table tbody tr:nth-child(even) td { background: #f8fafc; }
table.report-table td.num { text-align: center; font-family: "Chakra Petch", monospace; }
table.report-table img { width: 44px; height: 34px; object-fit: cover; border: 1px solid #cbd5e1; border-radius: 3px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 9999px; margin-right: 4px; vertical-align: middle; }
.dot-available { background: #10b981; } .dot-occupied { background: #f43f5e; }
.dot-temporary_out { background: #f59e0b; } .dot-reserved { background: #a855f7; }
.report-note { margin-top: .8rem; font-size: 8pt; color: #475569; border-top: 1px dashed #cbd5e1; padding-top: .4rem; display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.report-sign { margin-top: 1.4rem; display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; font-size: 8.5pt; color: #334155; text-align: center; }
.report-sign .line { border-top: 1px solid #94a3b8; margin-top: 2.2rem; padding-top: .2rem; }

/* ---------- 15a2. เลือก "แบบรายงาน" ในหน้าต่างรายงาน (คำสั่งข้อ 13) ---------- */
.report-mode-btn {
  display: flex; flex-direction: column; gap: .2rem; text-align: left;
  padding: .55rem .7rem; border-radius: .75rem; font-size: .78rem; font-weight: 600;
  border: 2px solid #334155; background: #0f172a; color: #cbd5e1; cursor: pointer; transition: .15s;
}
.report-mode-btn:hover { border-color: #475569; background: #1e293b; }
.report-mode-btn .rm-title { font-weight: 800; color: #e2e8f0; }
.report-mode-btn .rm-sub { font-size: .68rem; font-weight: 500; color: #94a3b8; line-height: 1.3; }
.report-mode-btn.active { border-color: #10b981; background: rgba(16, 185, 129, .14); color: #d1fae5; box-shadow: 0 0 0 3px rgba(16, 185, 129, .16); }
.report-mode-btn.active .rm-title { color: #6ee7b7; }

/* ---------- 15a3. แบบที่ 1: รายงานสรุปงานประจำวัน (Daily Real-Time Summary) ---------- */
.daily-head { text-align: center; }
.daily-title { font-size: 16pt; font-weight: 800; color: #0f172a; margin: 0; }
.daily-range { font-size: 10pt; font-weight: 700; color: #1e293b; margin-top: .25rem; }
.daily-meta { font-size: 8.5pt; color: #475569; margin-top: .2rem; }
.daily-warn {
  text-align: center; font-size: 9pt; font-weight: 700; color: #ea580c;
  margin: .45rem 0 .5rem; border-bottom: 1.5px solid #cbd5e1; padding-bottom: .45rem;
}
.daily-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .45rem; margin-bottom: .6rem; }
.daily-kpi { border-radius: 8px; padding: .4rem .5rem; text-align: center; border: 1.5px solid #cbd5e1; background: #f8fafc; }
.daily-kpi .k-label { font-size: 8.2pt; font-weight: 700; color: #334155; line-height: 1.15; }
.daily-kpi .k-value { font-family: "Chakra Petch", monospace; font-size: 15pt; font-weight: 800; line-height: 1.2; color: #0f172a; }
.daily-kpi .k-unit { font-size: 8pt; font-weight: 600; }
.daily-kpi.k-total { background: #f1f5f9; border-color: #cbd5e1; }
.daily-kpi.k-ok { background: #ecfdf5; border-color: #6ee7b7; }
.daily-kpi.k-ok .k-label, .daily-kpi.k-ok .k-value { color: #047857; }
.daily-kpi.k-out { background: #fffbeb; border-color: #fcd34d; }
.daily-kpi.k-out .k-label, .daily-kpi.k-out .k-value { color: #b45309; }
.daily-kpi.k-turn { background: #eff6ff; border-color: #93c5fd; }
.daily-kpi.k-turn .k-label, .daily-kpi.k-turn .k-value { color: #1d4ed8; }
table.report-table.daily-table { font-size: 8.2pt; table-layout: fixed; }
table.report-table.daily-table th, table.report-table.daily-table td { text-align: center; vertical-align: middle; word-break: break-word; }
table.report-table.daily-table thead th { background: #f1f5f9; color: #0f172a; font-size: 8pt; font-weight: 800; border-bottom: 2px solid #64748b; }
table.report-table.daily-table td.c-slot { font-family: "Chakra Petch", monospace; font-weight: 800; font-size: 9pt; }
table.report-table.daily-table td.c-plate { font-family: "Chakra Petch", monospace; font-weight: 700; }
table.report-table.daily-table td img { width: 100%; max-width: 52px; height: 40px; display: block; margin: 0 auto; }
.daily-foot {
  margin-top: .8rem; padding-top: .5rem; border-top: 1px solid #cbd5e1;
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; font-size: 8pt; color: #64748b;
}
@media (max-width: 720px) {
  .daily-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  table.report-table.daily-table { font-size: .76rem; }
  table.report-table.daily-table td img { max-width: 100%; height: auto; aspect-ratio: 4 / 3; }
}

@media (max-width: 720px) {
  .report-page { width: 100%; min-height: auto; padding: 10mm 6mm; box-shadow: none; border-radius: 0; }
  .report-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- 15b. รายงานบนหน้าจอโทรศัพท์: พอดีจอ + เห็นข้อมูลและรูปครบ ----------
   บนมือถือเปลี่ยน "ตาราง" ให้เป็น "การ์ดรายช่อง" (แต่ละคอลัมน์มีป้ายกำกับ)
   เพื่อให้ข้อมูลฝั่งซ้ายไม่ถูกตัด และเห็นรูปถ่ายรถเต็ม ๆ — ตอนสั่งพิมพ์ A4
   ยังใช้ตารางแนวนอนเหมือนเดิม (rules อยู่ใน @media screen เท่านั้น) */
@media screen and (max-width: 760px) {
  #report-document-wrapper { padding: .4rem !important; border-radius: .5rem; }
  .report-page { width: 100% !important; min-height: auto; padding: .75rem .6rem; box-shadow: none; border-radius: .5rem; border: 1px solid #cbd5e1; }
  .report-page:last-child { margin-bottom: 0 !important; }
  .report-page .report-head h1 { font-size: 14pt; }
  .report-page .report-head .report-sub, .report-page .report-head .report-meta { font-size: 8pt; }
  .report-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .report-page table.report-table { font-size: .76rem; }
  /* ตารางรายงานประจำวันใช้ table-layout:fixed + colgroup เพื่อกำหนดความกว้างคอลัมน์ตอนพิมพ์ A4
     บนมือถือซึ่งแปลงตารางเป็นการ์ดรายช่อง ต้องปลดออก ไม่งั้นคอลัมน์จะบีบเหลือไม่กี่พิกเซล */
  .report-page table.report-table.daily-table { table-layout: auto; }
  .report-page table.report-table.daily-table col { width: auto !important; }
  .report-page table.report-table.daily-table td img { max-width: 100%; height: 160px; }
  .report-page table.report-table thead { display: none; }
  .report-page table.report-table tbody { display: block; }
  .report-page table.report-table tr {
    display: block; border: 1px solid #94a3b8; border-radius: .5rem;
    padding: .35rem .45rem; margin-bottom: .5rem; background: #fff; break-inside: avoid;
  }
  .report-page table.report-table td {
    display: flex; align-items: flex-start; gap: .45rem; border: 0; padding: .08rem 0;
    width: auto !important; text-align: left; font-size: .76rem; background: transparent !important;
  }
  .report-page table.report-table td::before {
    content: attr(data-label); flex: 0 0 5.4rem; color: #475569; font-weight: 700; font-size: .68rem; padding-top: .1rem;
  }
  .report-page table.report-table td.cell-photo { display: block; margin-top: .3rem; }
  .report-page table.report-table td.cell-photo::before { display: block; flex: none; margin-bottom: .2rem; }
  .report-page table.report-table td.cell-photo img {
    display: block; width: 100%; max-width: 100%; height: 160px; object-fit: cover; border-radius: .4rem;
  }
  .report-page .report-sign { grid-template-columns: 1fr; gap: 1.2rem; }
  .report-mobile-bar { display: flex !important; }
}

/* ---------- 15c. เมนู "สถานะลูกค้า" แทนปุ่ม Checked Out (คำสั่งข้อ 10) ---------- */
.customer-state-btn {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .5rem .8rem; border-radius: .75rem;
  font-size: .72rem; font-weight: 700; line-height: 1;
  color: #cbd5e1; background: rgba(30, 41, 59, .85);
  border: 1px solid rgba(100, 116, 139, .35);
  transition: transform .12s ease, background .15s ease, box-shadow .15s ease, color .15s ease;
}
.customer-state-btn:hover { background: rgba(51, 65, 85, .95); }
.customer-state-btn:active { transform: scale(.97); }
.customer-state-btn.state-none { min-width: 3.4rem; justify-content: center; color: #64748b; }
.customer-state-btn.active {
  color: #0f172a; border-color: rgba(255, 255, 255, .3);
  background: linear-gradient(90deg, #f59e0b, #f97316);
  box-shadow: 0 4px 14px rgba(249, 115, 22, .35);
}
.customer-state-btn[data-state="checkout"].active {
  color: #fff; background: linear-gradient(90deg, #059669, #0d9488 55%, #22c55e);
  animation: checkoutPulse 1.9s ease-in-out infinite;
}
.customer-state-btn[data-state="checkout"].active:hover { background: linear-gradient(90deg, #047857, #0f766e 55%, #16a34a); }
/* ค่าว่าง = สีเทา ตามคำสั่งข้อ 10 */
.customer-state-btn.state-none.active {
  color: #334155; background: #e2e8f0; border-color: #f8fafc;
  box-shadow: 0 0 0 2px rgba(226, 232, 240, .35); animation: none;
}
@keyframes checkoutPulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(16, 185, 129, .28); }
  50% { box-shadow: 0 0 0 8px rgba(16, 185, 129, .06); }
}
@media (prefers-reduced-motion: reduce) { .customer-state-btn[data-state="checkout"].active { animation: none; } }

/* ---------- 15d. ปุ่มย้อนกลับหลักของโปรแกรม (คำสั่งข้อ 1) ---------- */
.app-back-btn {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top));
  left: calc(12px + env(safe-area-inset-left));
  z-index: 9998;
  display: inline-flex; align-items: center; gap: .5rem;
  min-height: 48px; padding: .65rem 1.1rem;
  border-radius: 999px;
  font-size: .95rem; font-weight: 800; letter-spacing: .01em;
  color: #052e16; background: linear-gradient(90deg, #34d399, #22d3ee);
  border: 2px solid rgba(255, 255, 255, .72);
  box-shadow: 0 10px 26px rgba(16, 185, 129, .42);
}
.app-back-btn:hover { filter: brightness(1.06); }
.app-back-btn:active { transform: scale(.97); }
.app-back-btn i { font-size: 1.05rem; }
.app-back-btn.hidden { display: none !important; }

/* ---------- 16. Print ---------- */
.print-only { display: none; }
@media print {
  @page { size: A4 portrait; margin: 8mm; }
  body { background: #fff !important; color: #0f172a !important; }
  body * { visibility: hidden !important; }
  #report-print-container, #report-print-container * { visibility: visible !important; }
  #report-print-container { position: absolute !important; left: 0; top: 0; width: 100%; }
  .print-hide { display: none !important; }
  .print-only { display: block !important; }
  .report-page {
    width: auto !important; min-height: auto !important; margin: 0 !important; padding: 0 !important;
    box-shadow: none !important; border-radius: 0 !important;
    page-break-after: always; break-after: page;
  }
  .report-page:last-child { page-break-after: auto; break-after: auto; }
  table.report-table thead { display: table-header-group; }
  table.report-table tr { page-break-inside: avoid; }
}

/* ---------- 17. Misc ---------- */
kbd { font-family: "Chakra Petch", monospace; }
.truncate-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.user-mgr-nav.hidden { display: none !important; }
.admin-only.hidden { display: none !important; }
.no-select { user-select: none; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
