@import url('https://fonts.googleapis.com/css2?family=Prompt:wght@400;500;600;700;800&display=swap');

:root {
    --bg: #ffffff;
    --panel: #f5f5f6;
    --panel-alt: #fafafa;
    --border: #e8e8ea;
    --text: #1c1c1e;
    --muted: #8a8a8e;
    --accent: #e3241b;
    --accent-dark: #c31d15;
    --ok: #1aa05b;
    --late: #d68a00;
    --flag: #e3241b;
    --pending: #ececee;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'Prompt', 'Segoe UI', 'Sarabun', system-ui, -apple-system, sans-serif;
}

.wrap { max-width: 480px; margin: 0 auto; padding: 16px; }
.wrap-wide { max-width: 1100px; margin: 0 auto; padding: 16px; }

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 22px;
    margin-bottom: 16px;
}

h1, h2, h3 { margin-top: 0; font-weight: 700; }

label { display: block; margin: 12px 0 4px; color: var(--muted); font-size: 14px; }

input, select {
    width: 100%;
    padding: 10px 12px;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 16px;
    font-family: inherit;
}

button, .btn {
    display: inline-block;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 18px;
    font-size: 16px;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: background .15s ease;
}

button:hover:not(:disabled) { background: var(--accent-dark); }
button:disabled { background: #d5d5d7; color: #9a9a9e; cursor: not-allowed; }
.btn-secondary { background: #3a3a3c; }
.btn-secondary:hover { background: #222224; }

.error { color: var(--flag); margin: 8px 0; font-weight: 500; }
.muted { color: var(--muted); font-size: 14px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; }

.badge { display: inline-block; padding: 3px 12px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge-ok { background: rgba(26,160,91,.12); color: var(--ok); }
.badge-late { background: rgba(214,138,0,.14); color: var(--late); }
.badge-flag { background: rgba(227,36,27,.10); color: var(--flag); }
.badge-pending { background: var(--pending); color: var(--muted); }
.badge-missed { background: rgba(227,36,27,.10); color: var(--flag); }

/* !important จำเป็นจริงๆ ตรงนี้: .hidden ต้องชนะทุกกรณีเสมอไม่ว่าจะไปเจอ class อื่นที่ตั้ง display
   ไว้เอง (เช่น .result-overlay, .shutter-row ที่ display:flex) เพราะเป็น utility class ที่ตั้งใจให้
   "ซ่อนแน่นอน" กับ element ไหนก็ได้ — ถ้าไม่มี !important จะแพ้ตาม CSS cascade เมื่อ specificity เท่ากัน
   (class อื่นประกาศทีหลังในไฟล์นี้จะชนะ) ทำให้ element ที่ควรถูกซ่อนไม่หายไปจริงๆ (บั๊กที่เจอจริง: หน้า
   เครื่องหมายถูกสีเขียวหลังสแกน QR สำเร็จค้างอยู่ไม่ยอมหายแม้ JS จะสั่ง classList.add('hidden') แล้ว) */
.hidden { display: none !important; }
.center { text-align: center; }

/* ----- หน้ากล้อง (scan_camera.php) — ธีมมืดเต็มจอ อ้างอิงดีไซน์ pilot เดิมที่ผู้ใช้ส่งภาพมาให้ดู -----
   ต่างจากหน้าอื่นๆ ในแอป (ธีมสว่าง การ์ดกลางจอ) หน้านี้ตั้งใจให้เต็มจอสีดำแบบแอปกล้องจริง — ไม่ใช้ .wrap
   หรือ .card ครอบ ใช้ .camera-page เป็นคอนเทนเนอร์ 100vh ของตัวเองแทน */
body.camera-dark { background: #000; color: #fff; }
.camera-page {
    min-height: 100vh;
    min-height: 100dvh; /* dvh กันแถบ address bar มือถือบัง/ดันเลย์เอาต์ ใช้ vh สำรองไว้ให้เบราว์เซอร์เก่า */
    display: flex;
    flex-direction: column;
}

.camera-topbar-2 { display: flex; align-items: center; gap: 10px; padding: 14px 16px; flex-shrink: 0; }
.camera-back-btn {
    width: 34px; height: 34px; border-radius: 50%;
    background: rgba(255,255,255,.08); color: #fff; text-decoration: none;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; line-height: 1; flex-shrink: 0;
}
.camera-back-btn:hover { background: rgba(255,255,255,.18); }
.camera-title-block { flex: 1; min-width: 0; text-align: center; }
.camera-title-label { font-size: 12px; color: rgba(255,255,255,.55); letter-spacing: .3px; }
.camera-title-main {
    font-size: 16px; font-weight: 700; margin-top: 2px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.camera-logo-badge { background: #fff; border-radius: 8px; padding: 5px 8px; flex-shrink: 0; }

/* ----- สเตจกล้องเต็มพื้นที่ที่เหลือ — วิดีโอเต็มจอ ไม่ใช่กรอบ 3x4 นิ้วคงที่แบบเดิมแล้ว ----- */
.camera-stage-2 {
    position: relative;
    flex: 1;
    min-height: 0;
    background: #000;
    overflow: hidden;
}
.camera-stage-2 video,
.camera-stage-2 #captured-img {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    display: block;
}
.camera-stage-2 video { object-fit: cover; } /* ภาพสดตอนสแกน — เต็มจอ ตัดขอบได้ไม่เป็นไร */
/* ภาพนิ่งหลังกดชัตเตอร์ (พรีวิวก่อนบันทึก) ต้องใช้ contain ไม่ใช่ cover — กันแถบ watermark ที่วาดเต็ม
   ความกว้างภาพต้นฉบับ (ทั้งข้อความ 2 บรรทัด) โดนตัดขอบซ้าย-ขวาหายไปตอนอัตราส่วนภาพจากกล้อง (แนวนอน
   4:3/16:9) ไม่ตรงกับอัตราส่วนจอมือถือ (แนวตั้งสูง) — บั๊กที่เจอจริงตอนทดสอบ (ข้อความ watermark ครึ่งซ้าย
   หายไปนอกจอ) ยอมให้มีแถบดำ letterbox บน-ล่างหรือซ้าย-ขวาแทน เพื่อให้เห็นภาพ+watermark เต็มใบแน่นอน */
.camera-stage-2 #captured-img { object-fit: contain; background: #000; }

/* ----- กรอบมุมแดง (corner brackets) — แค่เส้นไกด์บอกตำแหน่งเล็ง QR ไม่ได้ครอบตัดภาพจริง
   (วิดีโอเต็มจอเสมอ ต่างจากกรอบทึบ 3x4 นิ้วรุ่นก่อน) ซ่อนไว้ตอนที่ไม่ได้อยู่ในโหมดสแกน QR ----- */
.scan-frame-brackets { position: absolute; left: 12%; right: 12%; top: 24%; bottom: 34%; pointer-events: none; }
.scan-frame-brackets .bracket { position: absolute; width: 28px; height: 28px; border: 3px solid var(--accent); }
.scan-frame-brackets .tl { top: 0; left: 0; border-right: none; border-bottom: none; border-top-left-radius: 6px; }
.scan-frame-brackets .tr { top: 0; right: 0; border-left: none; border-bottom: none; border-top-right-radius: 6px; }
.scan-frame-brackets .bl { bottom: 0; left: 0; border-right: none; border-top: none; border-bottom-left-radius: 6px; }
.scan-frame-brackets .br { bottom: 0; right: 0; border-left: none; border-top: none; border-bottom-right-radius: 6px; }

/* ----- เส้น effect กวาดหา QR — กวาดเฉพาะภายในโซนกรอบมุมแดงด้านบน (ไม่ใช่เต็มจอ) ----- */
.scan-sweep {
    position: absolute;
    left: 12%;
    right: 12%;
    top: 24%;
    height: 3px;
    background: linear-gradient(to right, rgba(227,36,27,0), rgba(227,36,27,.95), rgba(227,36,27,0));
    box-shadow: 0 0 10px 2px rgba(227,36,27,.75);
    animation: scan-sweep-move 1.8s ease-in-out infinite;
    pointer-events: none;
}
@keyframes scan-sweep-move {
    0%   { top: 25%; }
    50%  { top: 65%; }
    100% { top: 25%; }
}

/* ----- ผลสแกน QR คลุมเต็มสเตจชั่วคราว: ถูกจุด (เขียว) / ผิดจุด (แดง) ----- */
.result-overlay {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 16px;
    color: #fff;
}
.result-overlay.ok { background: rgba(26,160,91,.94); cursor: pointer; }
.result-overlay.bad { background: rgba(227,36,27,.94); }
.result-icon { font-size: 64px; font-weight: 800; line-height: 1; margin-bottom: 10px; }
.result-text { font-size: 16px; font-weight: 700; }

/* ----- กลุ่มเนื้อหาลอยกลางสเตจ (เหนือวิดีโอ) — ข้อความ error กล้อง/ปุ่มลองใหม่/ปุ่มชัตเตอร์/
   ปุ่มถ่ายใหม่-บันทึกภาพ อยู่ตรงนี้ทั้งหมด จัดกึ่งกลางสเตจอัตโนมัติด้วย flex ไม่ต้องกะตำแหน่งเอง ----- */
.camera-stage-content {
    position: absolute; inset: 0; z-index: 2;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
    padding: 24px; pointer-events: none; /* ปล่อยให้แตะทะลุไปโดนวิดีโอ/สแกนได้ตอนไม่มีปุ่มโชว์ */
}
.camera-stage-content > * { pointer-events: auto; }
.camera-status-text { color: #8fc0ff; font-size: 14px; max-width: 280px; }
.camera-error-icon {
    width: 40px; height: 40px; border-radius: 10px; border: 2.5px solid #8fc0ff; position: relative;
}
.camera-error-icon::after {
    content: ''; position: absolute; top: 50%; left: 50%; width: 12px; height: 12px;
    border-radius: 50%; border: 2.5px solid #8fc0ff; transform: translate(-50%, -50%);
}
.camera-stage-content .btn-row { width: 100%; max-width: 320px; }

/* ----- แถบคำแนะนำล่างสุด — โชว์เฉพาะตอนกำลังสแกน QR เท่านั้น ----- */
.camera-hint {
    flex-shrink: 0; margin: 0; text-align: center; font-size: 14px; color: rgba(255,255,255,.85);
    padding: 14px 20px calc(14px + env(safe-area-inset-bottom));
}

/* ----- โหมดถ่ายภาพ: มีแค่ปุ่มชัตเตอร์กลมสีขาวปุ่มเดียวตรงกลาง ----- */
.shutter-row { display: flex; justify-content: center; margin-top: 6px; }
.shutter-btn-2 {
    width: 76px;
    height: 76px;
    border-radius: 50%;
    background: #ffffff;
    border: 5px solid #d5d5d7;
    padding: 0;
    cursor: pointer;
}
.shutter-btn-2:active { background: #ececee; }
.shutter-btn-2:disabled { opacity: .6; }

/* .btn-secondary ปกติเป็นเทาเข้ม (#3a3a3c) ออกแบบไว้บนพื้นหลังสว่าง — บนหน้ากล้องธีมมืดพื้นดำ
   สีนี้จะกลืนไปกับพื้นหลังจนแทบมองไม่เห็นปุ่ม เลยทำให้สว่างขึ้นเฉพาะตอนอยู่ในหน้ากล้องเท่านั้น */
.camera-stage-content .btn-secondary { background: rgba(255,255,255,.16); }
.camera-stage-content .btn-secondary:hover { background: rgba(255,255,255,.26); }

/* ----- ปุ่มถ่ายใหม่ / บันทึกภาพ วางคู่กัน ----- */
.btn-row { display: flex; gap: 10px; margin-top: 6px; }
.btn-row button { flex: 1; margin-top: 0 !important; }

.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.topbar a { color: var(--muted); text-decoration: none; font-size: 14px; }
.topbar a:hover { color: var(--accent); }

/* ----- โลโก้ Index Creative Village (ข้อความ ไม่มีไฟล์ภาพจริง) ----- */
/* โลโก้จริงของ Index Creative Village (ไฟล์ภาพ /assets/img/logo*.png) แทนโลโก้ข้อความ "Ind e x" เดิม —
   logo-compact.png ตัดแถบข้อความ "CREATIVE VILLAGE" ด้านล่างออกแล้ว ใช้กับหัวข้อหน้าขนาดเล็กทุกจุด
   ส่วน logo.png (เต็ม มี tagline) ใช้เฉพาะหน้า login ที่มีที่ว่างพอให้โลโก้ใหญ่ขึ้น */
.brand-logo { height: 22px; width: auto; display: inline-block; vertical-align: middle; }
.brand-logo-sm { height: 18px; }
.brand-logo-lg { height: 68px; }
.eyebrow { color: var(--accent); font-weight: 700; font-size: 13px; letter-spacing: .5px; margin: 0 0 6px; }

/* ----- stat tiles (จำนวนจุดตรวจ/รอบ/ครั้งต่อวัน) ----- */
.stat-row { display: flex; gap: 12px; flex-wrap: wrap; margin: 16px 0; }
.stat-tile {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 20px;
    min-width: 100px;
    flex: 1;
}
.stat-tile .num { font-size: 34px; font-weight: 800; color: var(--accent); line-height: 1.1; }
.stat-tile .label { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* ----- pill เวลาออกตรวจ ----- */
.pill-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 10px 0; }
.pill {
    border: 1.5px solid var(--accent);
    color: var(--accent);
    border-radius: 999px;
    padding: 10px 20px;
    font-weight: 700;
    font-size: 15px;
    background: #fff;
}

/* ----- รายการพื้นที่ (area breakdown) ----- */
.area-list .area-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 4px;
    border-bottom: 1px solid var(--border);
    font-size: 15px;
}
.area-list .area-row:last-child { border-bottom: none; }
.area-list .area-count { color: var(--accent); font-weight: 700; }

/* ----- หน้าสแกน (scan.php): ดีไซน์อ้างอิงจากภาพหน้าจอ pilot เดิมที่ผู้ใช้ส่งมา ----- */
.scan-top-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }

.online-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ok); font-weight: 600; }
.online-badge .online-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); display: inline-block; }
.online-badge.offline { color: var(--flag); }
.online-badge.offline .online-dot { background: var(--flag); }

.staff-row { display: flex; align-items: center; gap: 12px; margin: 14px 0 10px; }
.avatar-circle {
    width: 44px; height: 44px; border-radius: 50%;
    background: rgba(227,36,27,.10); color: var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 15px; flex-shrink: 0;
}
.staff-info { display: flex; flex-direction: column; gap: 2px; }
.staff-info strong { font-size: 15px; }

.progress-summary-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.progress-bar-outer { height: 6px; background: var(--pending); border-radius: 999px; overflow: hidden; }
.progress-bar-inner { height: 100%; background: var(--ok); border-radius: 999px; transition: width .2s ease; }

.round-pill-row { display: flex; gap: 6px; overflow-x: auto; padding: 14px 0 2px; -webkit-overflow-scrolling: touch; }
.round-pill {
    flex-shrink: 0; padding: 7px 11px; border-radius: 999px; font-size: 12.5px; font-weight: 700;
    background: var(--pending); color: var(--muted); border: 1.5px solid transparent;
}
.round-pill.current { background: #fff; color: var(--accent); border-color: var(--accent); }

.checklist { display: flex; flex-direction: column; gap: 10px; }
.checklist-item {
    display: flex; align-items: center; gap: 14px;
    background: var(--panel); border: 1.5px solid var(--border); border-radius: 12px; padding: 14px 16px;
    color: inherit; text-decoration: none; /* การ์ด "รอตรวจ" เป็น <a> ตอนนี้ — เอา underline/สีลิงก์เริ่มต้นออก */
}
/* จุด "รอตรวจ" (จุดถัดไปที่ต้องสแกนเท่านั้น) เป็นลิงก์กดได้ตรงไปหน้ากล้อง — ไฮไลต์ให้เห็นชัดว่าแตะได้ */
.checklist-item.next { border-color: var(--accent); background: #fff; cursor: pointer; }
.checklist-item.done { opacity: .75; }
.checklist-num { font-weight: 800; color: var(--muted); font-size: 15px; width: 22px; flex-shrink: 0; }
.checklist-info { flex: 1; min-width: 0; }
.checklist-name { font-weight: 700; font-size: 15px; color: var(--text); }
.checklist-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }

.progress-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; margin-top: 12px; }
.progress-cell {
    aspect-ratio: 1;
    display: flex; align-items: center; justify-content: center;
    border-radius: 10px; font-size: 12px; font-weight: 700;
    background: var(--pending); color: var(--muted);
    border: 1px solid var(--border);
}
.progress-cell.done { background: var(--ok); color: #fff; border-color: var(--ok); }
.progress-cell.late { background: var(--late); color: #fff; border-color: var(--late); }
.progress-cell.flag { background: var(--flag); color: #fff; border-color: var(--flag); }

/* ----- หน้าภาพรวมแอดมิน (admin/dashboard.php) ดีไซน์ใหม่ — อ้างอิงภาพหน้าจอ dashboard เดิมของ pilot ----- */
.dash-filter-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 20px; }
.dash-pill {
    display: inline-flex; align-items: center; gap: 8px;
    border: 1.5px solid var(--border); border-radius: 999px;
    padding: 8px 16px; background: #fff; font-size: 14px;
}
.dash-pill .dash-pill-label { color: var(--muted); }
.dash-pill select, .dash-pill input[type="date"] {
    border: none; padding: 0; width: auto; font-size: 14px; font-weight: 600;
    color: var(--text); background: transparent; font-family: inherit;
}
.dash-pill select:focus, .dash-pill input[type="date"]:focus { outline: none; }
.dash-pill-thai-date { font-weight: 600; }

/* ปุ่มวันที่: ซ่อน <input type="date"> จริงให้โปร่งใสแต่คลุมเต็มพื้นที่ปุ่ม (คลิกได้ทั้งปุ่ม เปิดตัวเลือก
   ปฏิทินจริงของเบราว์เซอร์) โชว์แค่ป้ายข้อความ พ.ศ. ที่ครอบไว้ด้านบนแทน กันตัวเลขปฏิทิน ค.ศ. ของเบราว์เซอร์
   ไม่ให้ซ้อนโผล่มาคู่กับป้ายที่ตั้งใจแสดง (ดูคอมเมนต์ใน admin/dashboard.php ประกอบ) */
.dash-date-pill { position: relative; cursor: pointer; }
.dash-date-pill input[type="date"] {
    position: absolute; inset: 0; opacity: 0; cursor: pointer; padding: 0; border: 0;
}

.live-badge {
    display: inline-flex; align-items: center; gap: 7px;
    border-radius: 999px; padding: 8px 16px; background: rgba(26,160,91,.10);
    color: var(--ok); font-size: 13px; font-weight: 600;
}
.live-badge .live-dot {
    width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex-shrink: 0;
    animation: live-dot-pulse 1.6s ease-in-out infinite;
}
@keyframes live-dot-pulse {
    0%, 100% { opacity: 1; } 50% { opacity: .35; }
}

.dash-section-label { color: var(--muted); font-weight: 700; font-size: 13px; letter-spacing: .3px; margin: 22px 0 10px; }
.dash-section-label:first-child { margin-top: 0; }

.stat-grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.stat-card {
    background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px;
}
.stat-card .stat-card-label { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.stat-card .stat-card-num { font-size: 30px; font-weight: 800; line-height: 1.1; }
.stat-card .stat-card-sub { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.stat-card .stat-card-num.c-green { color: var(--ok); }
.stat-card .stat-card-num.c-red { color: var(--flag); }
.stat-card .stat-card-num.c-orange { color: var(--late); }
.stat-card .stat-card-num.c-neutral { color: var(--text); }

.dash-columns { display: grid; grid-template-columns: minmax(0, 2fr) minmax(240px, 1fr); gap: 16px; align-items: start; }
@media (max-width: 800px) { .dash-columns { grid-template-columns: 1fr; } }

.card-header-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 10px; }
.card-header-row h3 { margin: 0; }
.btn-export { background: #fff; border: 1.5px solid var(--border); color: var(--text); font-weight: 600; padding: 9px 16px; font-size: 13.5px; }
.btn-export:hover { background: var(--panel); }

.live-table-wrap { max-height: 420px; overflow-y: auto; }
.live-table-note { font-size: 12.5px; color: var(--muted); margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }

.alerts-empty { color: var(--muted); font-size: 14px; padding: 6px 0; }
.alert-item { display: flex; gap: 8px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; line-height: 1.5; }
.alert-item:last-child { border-bottom: none; }
.alert-item .alert-icon { flex-shrink: 0; }
.alert-item.type-missed { color: var(--flag); }
.alert-item.type-rapid { color: var(--late); }
.alert-body { flex: 1; min-width: 0; }

/* ข้อความแจ้งเตือนยาวๆ (เช่น รายชื่อจุดตรวจที่ขาดเป็นสิบๆ จุด) ตัดไว้แค่ 2 บรรทัดก่อน แล้วมีปุ่ม
   "อ่านต่อ"/"ย่อ" ให้กดขยาย-ย่อเอาเอง (ดู setupAlertToggles() ใน admin_dashboard.js — ปุ่มนี้ซ่อนไว้
   โดย default ผ่าน attribute [hidden] แล้ว JS จะโชว์เฉพาะข้อความที่ยาวเกิน 2 บรรทัดจริงๆ เท่านั้น) */
.alert-text {
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.alert-text.expanded { display: block; -webkit-line-clamp: unset; overflow: visible; }
.alert-toggle {
    background: none; border: none; padding: 4px 0 0; margin: 0;
    color: var(--accent); font-weight: 700; font-size: 12.5px; cursor: pointer; font-family: inherit;
    display: block;
}
.alert-toggle:hover { text-decoration: underline; }

.toggle-btn-group { display: inline-flex; border: 1.5px solid var(--border); border-radius: 999px; overflow: hidden; }
.toggle-btn {
    background: #fff; color: var(--muted); border: none; padding: 8px 18px; font-size: 13.5px;
    font-weight: 600; cursor: pointer; font-family: inherit;
}
.toggle-btn.active { background: var(--accent); color: #fff; }
.toggle-btn:hover:not(.active) { background: var(--panel); }
.report-filter-row { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.report-filter-row select { width: auto; min-width: 160px; }
.report-footnote { font-size: 12.5px; color: var(--muted); margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }

/* ----- Dialog ดูภาพเช็คอิน (หน้า admin/checkins.php) — กระเด้งขึ้นมาทับหน้าเดิม ไม่เปิดแท็บ/หน้าต่างใหม่ ----- */
.photo-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.75);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 28px;
    z-index: 1000;
}
.photo-modal.hidden { display: none; }
.photo-modal-inner { position: relative; max-width: 92vw; max-height: 92vh; }
.photo-modal-inner img {
    display: block;
    max-width: 92vw;
    max-height: 92vh;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0,0,0,.5);
}
.photo-modal-close {
    position: absolute;
    top: -14px;
    right: -14px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #ffffff;
    color: var(--text);
    border: none;
    font-size: 18px;
    font-weight: 800;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0,0,0,.35);
    padding: 0;
}
.photo-modal-close:hover { background: var(--pending); }

/* ลูกศรเลื่อนดูภาพก่อนหน้า/ถัดไป — วางกึ่งกลางแนวตั้งของขอบภาพซ้าย/ขวา (โผล่คร่อมขอบเหมือนปุ่มปิด)
   จางลง (opacity ต่ำ + ห้ามคลิก) เมื่อถึงภาพแรก/ภาพสุดท้ายในหน้านั้นแล้ว (ดู photo_modal.js) */
.photo-modal-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #ffffff;
    color: var(--text);
    border: none;
    font-size: 26px;
    font-weight: 800;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0,0,0,.35);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.photo-modal-prev { left: -14px; }
.photo-modal-next { right: -14px; }
.photo-modal-nav:hover:not(:disabled) { background: var(--pending); }
.photo-modal-nav:disabled { opacity: .3; cursor: default; box-shadow: none; }

/* กระดิ่งแจ้งเตือน "กรอก PIN ผิด" ในหน้า admin/dashboard.php — ป้ายตัวเลขแดงสไตล์แอปแชท (LINE ฯลฯ) */
.notif-bell-wrap { position: relative; flex-shrink: 0; }
.notif-bell-btn {
    position: relative;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1.5px solid var(--border);
    background: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    padding: 0;
    line-height: 1;
}
.notif-bell-btn:hover { background: var(--panel); }
.notif-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 15px;
    height: 15px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--accent);
    color: #ffffff;
    font-size: 9px;
    font-weight: 800;
    line-height: 15px;
    text-align: center;
    box-shadow: 0 0 0 2px #ffffff;
}
.notif-panel {
    position: absolute;
    top: 40px;
    left: 0;
    width: 300px;
    max-height: 380px;
    overflow-y: auto;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 10px 32px rgba(0,0,0,.14);
    z-index: 50;
}
.notif-panel-header {
    padding: 12px 16px;
    font-weight: 700;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
}
.notif-item {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 13.5px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.notif-item:last-child { border-bottom: none; }
.notif-item-icon { color: var(--accent); font-size: 14px; flex-shrink: 0; }
.notif-empty { padding: 20px 16px; text-align: center; margin: 0; }

/* ===== admin/export.php — รายงานตรวจจุด A4 (จุดตรวจ x รอบเวลา) ===== */
.report-header { display: none; } /* โชว์เฉพาะตอนพิมพ์ — ดู @media print ด้านล่าง */
.report-grid { width: 100%; border-collapse: collapse; font-size: 13px; }
.report-grid th, .report-grid td { border: 1px solid var(--border); padding: 6px 8px; text-align: center; }
.report-grid th { background: var(--panel); white-space: nowrap; }
.report-grid td.cp-name, .report-grid th.cp-name { text-align: left; white-space: nowrap; }
.report-cell-ok { background: rgba(26,160,91,.10); }
.report-cell-late { background: rgba(214,138,0,.12); }
.report-cell-flag { background: rgba(227,36,27,.10); }
.report-cell-empty { color: var(--muted); }
.report-cell-time { display: block; font-weight: 700; }
.report-cell-staff { display: block; font-size: 11px; color: var(--muted); font-weight: 400; }
.report-legend { display: flex; gap: 16px; margin-top: 12px; font-size: 13px; flex-wrap: wrap; align-items: center; }
.report-legend-dot { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }
.report-signature { display: flex; justify-content: space-between; margin-top: 56px; }
.report-signature div { width: 44%; border-top: 1px solid var(--text); padding-top: 6px; text-align: center; font-size: 13px; }

@media print {
    body * { visibility: hidden; }
    #print-area, #print-area * { visibility: visible; }
    #print-area { position: absolute; left: 0; top: 0; width: 100%; }
    .no-print { display: none !important; }
    .report-header { display: block; margin-bottom: 16px; font-size: 13px; }
    .card { border: none; box-shadow: none; padding: 0; }
    @page { size: A4; margin: 12mm; }
}

/* นาฬิกาดิจิตอลเวลาปัจจุบันในหน้า admin/checkins.php (ดู admin_checkins.js) — ตัวหนังสือสีดำ ขนาดใหญ่
   พอประมาณ ตัวเลขความกว้างเท่ากันทุกหลัก (tabular-nums) กันตัวเลขขยับตอนอัปเดตทุกวินาที */
.live-clock {
    font-size: 24px;
    font-weight: 800;
    color: #000000;
    font-variant-numeric: tabular-nums;
    letter-spacing: 1px;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 6px 16px;
    line-height: 1.3;
}

