:root{--primary:#c1121f;--primary-dark:#8f0e18;--primary-light:#f6d3d6;--primary-soft:#fdf3f3;--success:#16a34a;--warning:#f59e0b;--danger:#c1121f;--info:#2563eb;--bg:#fafafa;--surface:#fff;--text:#141414;--text-secondary:#5c5c5c;--muted:#8f8f8f;--border:#e6e6e6;--radius-sm:10px;--radius-md:14px;--radius-lg:20px;--radius-xl:28px;--shadow-sm:0 2px 10px rgba(0,0,0,.06);--shadow-md:0 10px 26px rgba(0,0,0,.1);--shadow-lg:0 20px 48px rgba(0,0,0,.14);--sidebar-width:250px;--accent-green:#16a34a;--accent-green-pale:#dcf7e3;--accent-blue:#2563eb;--accent-blue-pale:#e0eaff;--accent-purple:#9333ea;--accent-purple-pale:#f2e3ff;--gradient-warm:linear-gradient(135deg,#e5383b 0%,#c1121f 55%,#8f0e18 100%)}*{box-sizing:border-box;margin:0;padding:0}html{scroll-behavior:smooth}body{font-family:"Prompt","Segoe UI",Tahoma,Arial,sans-serif;background:var(--bg);color:var(--text);font-size:14px;line-height:1.6;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility}button,input,textarea,select{font:inherit}button{border:0;cursor:pointer}img{max-width:100%;display:block}a{color:inherit;text-decoration:none}.hidden{display:none!important}.text-red{color:var(--primary)}.text-green{color:var(--success)}.text-warning{color:var(--warning)}.text-muted{color:var(--text-secondary)}.w-full{width:100%}
.login-page{min-height:100vh;display:flex;align-items:center;justify-content:center;padding:24px;background:radial-gradient(circle at 15% 15%,rgba(193,18,31,.08),transparent 30%),radial-gradient(circle at 85% 85%,rgba(193,18,31,.06),transparent 32%),#fafafa}.login-card{width:100%;max-width:420px;padding:38px;background:rgba(255,255,255,.98);border-radius:28px;box-shadow:0 20px 50px rgba(0,0,0,.1);animation:loginIn .4s ease}@keyframes loginIn{from{opacity:0;transform:translateY(16px)}to{opacity:1;transform:translateY(0)}}.brand-mark{width:62px;height:62px;display:grid;place-items:center;margin-bottom:16px;border-radius:18px;color:#fff;background:linear-gradient(145deg,#c1121f,#7a0d16);font-size:23px;font-weight:800;box-shadow:0 10px 20px rgba(193,18,31,.32)}.brand-title{color:#141414;font-size:26px;font-weight:700;letter-spacing:-.5px}.brand-sub{margin-top:4px;margin-bottom:28px;color:var(--text-secondary);font-size:13px}
label{display:block;margin:13px 0 7px;color:#5c5c5c;font-size:13px;font-weight:500}input,textarea,select{width:100%;padding:12px 14px;border:1px solid var(--border);border-radius:var(--radius-md);outline:none;background:#fff;color:var(--text);transition:border-color .2s ease,box-shadow .2s ease,background .2s ease}input:hover,textarea:hover,select:hover{border-color:#e3b3b7}input:focus,textarea:focus,select:focus{border-color:#c1121f;box-shadow:0 0 0 4px rgba(193,18,31,.12)}textarea{min-height:120px;resize:vertical}
.input-search{padding-left:42px;border-radius:100px;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238f8f8f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M21 21l-4.3-4.3'/%3E%3C/svg%3E");background-repeat:no-repeat;background-position:14px center;background-size:17px}
.btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;min-height:42px;padding:10px 18px;border-radius:100px;font-size:13px;font-weight:600;transition:transform .2s ease,box-shadow .2s ease,background .2s ease}.btn:hover{transform:translateY(-1px)}.btn:active{transform:translateY(0)}.btn-primary{color:#fff;background:linear-gradient(135deg,#c1121f,#8f0e18);box-shadow:0 6px 16px rgba(193,18,31,.3)}.btn-primary:hover{background:linear-gradient(135deg,#8f0e18,#5c090f)}.btn-light{color:#141414;background:#f0f0f0}.btn-light:hover{background:#e5e5e5}.btn-danger{color:#991b1b;background:#fee2e2}.btn-success{color:#166534;background:#dcfce7}.btn-full{width:100%}.demo-hint{margin-top:18px;color:#8f8f8f;text-align:center;font-size:11px}
.app{min-height:100vh;display:flex;background:var(--bg)}.sidebar{width:var(--sidebar-width);position:fixed;inset:0 auto 0 0;z-index:50;display:flex;flex-direction:column;padding:16px 14px;color:var(--text);background:#fff;border-right:1px solid var(--border);box-shadow:4px 0 20px rgba(0,0,0,.04);overflow-y:auto}.sidebar-brand{display:flex;align-items:center;gap:11px;padding:10px 8px 22px}.sidebar-brand>span{width:42px;height:42px;display:grid;place-items:center;border-radius:13px;background:var(--primary-light);color:var(--primary);font-size:14px;font-weight:800}.sidebar-brand b{display:block;font-size:13px;font-weight:700;color:var(--text)}.sidebar-brand small{display:block;margin-top:2px;color:var(--text-secondary);font-size:9px;letter-spacing:.7px}.sidebar nav{display:grid;gap:5px}.sidebar nav button{width:100%;padding:12px 13px;border-radius:10px;color:#3d3d3d;background:transparent;text-align:left;font-size:13px;transition:background .2s ease,color .2s ease}.sidebar nav button:hover{color:var(--primary-dark);background:var(--primary-soft)}.sidebar nav button.active{color:var(--primary-dark);background:var(--primary-light);box-shadow:inset 3px 0 0 #c1121f}.sidebar-bottom{margin-top:auto}.profile-mini{width:100%;padding:12px;border-radius:12px;color:var(--text);background:var(--surface-card,#f2f2f2);text-align:left}.profile-mini small{color:var(--text-secondary)}.logout{width:100%;margin-top:7px;padding:10px 12px;color:var(--primary-dark);background:transparent;text-align:left;border-radius:10px}.logout:hover{background:var(--primary-soft)}
.main{width:calc(100% - var(--sidebar-width));margin-left:var(--sidebar-width)}.topbar{height:78px;position:sticky;top:0;z-index:20;display:flex;align-items:center;justify-content:space-between;padding:0 30px;background:rgba(255,255,255,.96);border-bottom:1px solid var(--border);backdrop-filter:blur(12px)}.topbar h2{margin:0;font-size:19px;font-weight:700}.topbar>div:first-of-type span{display:block;color:var(--text-secondary);font-size:11px}.top-right{display:flex;align-items:center;gap:14px}.user-chip{padding:7px 12px;color:var(--primary)!important;background:var(--primary-light);border-radius:100px}.menu-btn{display:none;width:40px;height:40px;margin-right:10px;color:#141414;background:#f0f0f0;border-radius:10px}
#content{width:100%;max-width:1500px;padding:28px;margin:0 auto}.section-title{display:flex;align-items:center;justify-content:space-between;gap:16px;margin-bottom:18px}.section-title h3{margin:0;font-size:20px;font-weight:700}.section-title p{margin-top:3px;color:var(--text-secondary);font-size:12px}.grid4{display:grid;grid-template-columns:repeat(4,1fr);gap:16px}.stat{position:relative;overflow:hidden;padding:19px;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-lg);box-shadow:var(--shadow-sm)}.stat::after{content:"";width:75px;height:75px;position:absolute;top:-30px;right:-30px;border-radius:50%;background:var(--primary-light)}.stat .icon{width:40px;height:40px;display:grid;place-items:center;position:relative;z-index:2;color:var(--primary);background:var(--primary-light);border-radius:12px;font-weight:700}.stat b{display:block;margin-top:10px;font-size:28px;line-height:1.1}.stat small{color:var(--text-secondary);font-size:12px}.card{padding:18px;background:#fff;border:1px solid var(--border);border-radius:var(--radius-lg);box-shadow:var(--shadow-sm)}.card h4{margin-bottom:14px;font-size:15px}.two{display:grid;grid-template-columns:1.4fr 1fr;gap:16px;margin-top:16px}.table-wrap{width:100%;overflow-x:auto}.table{width:100%;border-collapse:collapse}.table th,.table td{padding:13px 10px;border-bottom:1px solid #ececec;text-align:left;font-size:12px;white-space:nowrap}.table th{color:var(--text-secondary);font-size:11px;font-weight:600;background:#fafafa}.table tr:hover td{background:#f7f7f7}
.toolbar{display:flex;gap:10px;margin-bottom:16px}.toolbar input{max-width:400px}.project-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:16px}.project-card{position:relative;padding:19px;background:#fff;border:1px solid var(--border);border-radius:18px;box-shadow:var(--shadow-sm);transition:transform .2s ease,box-shadow .2s ease,border-color .2s ease}.project-card:hover{transform:translateY(-2px);border-color:#e3b3b7;box-shadow:var(--shadow-md)}.project-head{display:flex;justify-content:space-between;gap:14px}.project-head h4{margin-bottom:4px;font-size:16px}.meta{margin:4px 0;color:var(--text-secondary);font-size:11px}.project-card p{margin:15px 0;color:#5c5c5c;font-size:12px}.project-actions{display:flex;gap:8px;margin-top:16px}.project-actions .btn{font-size:12px}.tag{display:inline-flex;padding:5px 9px;margin-right:4px;border-radius:100px;color:#3d3d3d;background:#f0f0f0;font-size:10px}.form-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:14px}.form-grid .full{grid-column:1/-1}.staff-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:8px}.staff-item{display:flex;align-items:center;gap:9px;min-height:46px;padding:10px 12px;background:#fff;border:1px solid var(--border);border-radius:11px;color:#1a1a1a;font-size:12px;cursor:pointer;transition:border-color .2s ease,background .2s ease}.staff-item:hover{border-color:#e3b3b7;background:#fafafa}.staff-item input{width:auto;margin:0}.map-box{min-height:260px;display:grid;place-items:center;border-radius:14px;color:#8f0e18;background:radial-gradient(circle at center,rgba(255,255,255,.9),transparent 35%),linear-gradient(135deg,#f6d3d6,#f0f0f0);font-size:13px}.empty{padding:55px 20px;color:var(--text-secondary);text-align:center;grid-column:1/-1}.empty b{display:block;margin-bottom:5px;color:#2a2a2a;font-size:14px}.mini-list{display:grid;gap:0}.mini-row{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:11px 0;border-bottom:1px solid #f0f0f0}.mini-row:last-child{border-bottom:0}.person{display:flex;align-items:center;gap:9px}.avatar{width:36px;height:36px;display:grid;place-items:center;flex-shrink:0;border-radius:11px;color:var(--primary-dark);background:var(--primary-light);font-weight:700}
.modal{position:fixed;inset:0;z-index:100;display:grid;place-items:center;padding:18px;background:rgba(0,0,0,.62);backdrop-filter:blur(4px)}.modal-card{width:min(620px,96vw);max-height:94vh;overflow-y:auto;padding:18px;background:#fff;border-radius:20px;box-shadow:0 25px 80px rgba(0,0,0,.25);animation:modalIn .22s ease}@keyframes modalIn{from{opacity:0;transform:scale(.97) translateY(6px)}to{opacity:1;transform:scale(1) translateY(0)}}.modal-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:14px}.modal-head h3{font-size:17px}.modal-head button{width:35px;height:35px;display:grid;place-items:center;border-radius:10px;color:#1a1a1a;background:#f0f0f0}.modal-head button:hover{background:#e5e5e5}.camera-card{width:min(680px,96vw)}.camera-wrap{position:relative;overflow:hidden;width:100%;aspect-ratio:3/4;max-height:46vh;border-radius:17px;background:#050505}.camera-wrap video{width:100%;height:100%;object-fit:cover}.camera-guide{position:absolute;inset:13% 10%;border:2px solid rgba(255,255,255,.82);border-radius:22px;box-shadow:0 0 0 999px rgba(0,0,0,.17);pointer-events:none}.camera-guide::before{content:"";position:absolute;top:50%;left:50%;width:10px;height:10px;margin:-5px;border-radius:50%;background:rgba(255,255,255,.8)}.camera-status{margin:10px 0;color:var(--text-secondary);text-align:center;font-size:12px}.location-box{padding:12px 14px;border:1px solid var(--border);border-radius:12px;color:#2a2a2a;background:#fafafa;font-size:12px;line-height:1.75}.camera-actions{display:flex;gap:10px;margin-top:12px}.camera-actions .btn{flex:1}.qr-card{width:min(420px,95vw);text-align:center}#qrBox{min-height:270px;display:grid;place-items:center;padding:25px;background:#fafafa;border-radius:15px}#qrBox img{padding:10px;background:#fff;border-radius:12px}.qr-inline{display:grid;place-items:center;min-height:220px;padding:15px;background:#fafafa;border-radius:14px}.toast{position:fixed;right:20px;bottom:20px;z-index:200;max-width:360px;padding:12px 16px;color:#fff;background:#141414;border-radius:12px;box-shadow:0 12px 30px rgba(0,0,0,.2);opacity:0;pointer-events:none;transform:translateY(12px);transition:opacity .25s ease,transform .25s ease}.toast.show{opacity:1;transform:translateY(0)}
@media(max-width:1100px){.grid4{grid-template-columns:repeat(2,1fr)}.project-grid{grid-template-columns:1fr}.two{grid-template-columns:1fr}}@media(max-width:1400px){.sidebar{transform:translateX(-100%);transition:transform .25s ease}.sidebar.open{transform:translateX(0)}.main{width:100%;margin-left:0}.topbar{height:68px;padding:0 15px}.menu-btn{display:inline-grid;place-items:center}.top-right #currentDate{display:none}#content{padding:16px}.section-title{align-items:flex-start;flex-direction:column}.section-title>.btn{width:100%}.grid4{grid-template-columns:repeat(2,1fr)}.form-grid{grid-template-columns:1fr}.form-grid .full{grid-column:auto}.staff-grid{grid-template-columns:1fr}.toolbar{flex-direction:column}.toolbar input{max-width:none}.project-actions{flex-direction:column}.project-actions .btn{width:100%}.table-wrap{overflow-x:auto}input,textarea,select{font-size:16px}.topbar{height:auto;min-height:64px;flex-wrap:wrap;row-gap:8px;padding:12px 15px}.top-right{flex-wrap:wrap;row-gap:6px}.user-chip{max-width:170px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}}@media(max-width:430px){.login-card{padding:28px 22px;border-radius:20px}.brand-title{font-size:22px}.grid4{grid-template-columns:1fr}.stat{display:grid;grid-template-columns:auto 1fr;column-gap:12px;align-items:center}.stat b{margin-top:0}.stat small{grid-column:2}.camera-wrap{max-height:38vh}}@media print{body{background:#fff}.sidebar,.topbar,.btn,.modal-head button{display:none!important}.main{width:100%;margin:0}#content{max-width:none;padding:0}}


/* =========================================================
   COMPATIBILITY BRIDGE
   ระบบเราเดิมใช้ชื่อ token/class ต่างไปบ้าง — alias ให้ชี้มาที่ token
   ชุดใหม่ด้านบน เพื่อให้หน้าที่ยังไม่ได้ปรับโครง (เช่น staff mobile)
   ยังใช้จานสีเดียวกันได้ถูกต้อง ไม่ต้องไล่แก้ inline style ทุกที่
   ========================================================= */
:root {
    --primary-pressed: var(--primary-dark);
    --ink: var(--text);
    --body-c: var(--text);
    --mute: var(--text-secondary);
    --ash: var(--muted);
    --hairline: var(--border);
    --hairline-soft: var(--border);
    --canvas: var(--surface);
    --surface-soft: var(--bg);
    --surface-card: #f2f2f2;
    --success-deep: #166534;
    --success-pale: #dcfce7;
    --error: var(--danger);
    --error-pale: #fbe4e6;
    --warn-deep: #92400e;
    --warn-pale: #fef3c7;
    --info-deep: #1d4ed8;
    --info-pale: #dbeafe;
    --rounded-md: var(--radius-lg);
    --rounded-sm: var(--radius-md);
    --rounded-lg: var(--radius-xl);
    --rounded-full: 9999px;
    --shadow: var(--shadow-md);
    --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
    --safe-b: env(safe-area-inset-bottom, 0px);
    --safe-t: env(safe-area-inset-top, 0px);
}

@media (prefers-reduced-motion: reduce) {
    * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}
html { -webkit-tap-highlight-color: transparent; }

@keyframes fadeInUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
@keyframes popupBounceIn { 0% { transform: scale(0.3); opacity: 0; } 50% { transform: scale(1.08); opacity: 1; } 70% { transform: scale(0.95); } 100% { transform: scale(1); opacity: 1; } }

/* --- Layout utilities ยังใช้ทุกหน้า --- */
.container { max-width: 1040px; margin: 0 auto; padding: 24px 20px 64px; }
.container-narrow { max-width: 460px; margin: 0 auto; padding: 24px 20px 64px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
h1 { font-size: 24px; font-weight: 700; color: var(--ink); margin: 0 0 4px; letter-spacing: -0.2px; }
h2 { font-size: 18px; font-weight: 700; color: var(--ink); margin: 0 0 4px; letter-spacing: -0.1px; }
.page-head { margin-bottom: 20px; }
.page-head p { color: var(--mute); font-size: 14px; margin: 0; }
.hint { font-size: 12px; color: var(--ash); margin-top: 4px; }
.field { margin-bottom: 16px; }

/* --- Sidebar: รองรับ nav แบบ <a> จริง (multi-page ไม่ใช่ SPA) ควบคู่กับ <button> เดิมของไฟล์ต้นฉบับ --- */
.sidebar nav a {
    display: block;
    width: 100%;
    padding: 12px 13px;
    border-radius: 10px;
    color: #3d3d3d;
    background: transparent;
    text-align: left;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.2s ease, color 0.2s ease;
}
.sidebar nav a:hover { color: var(--primary-dark); background: var(--primary-soft); }
.sidebar nav a.active { color: var(--primary-dark); background: var(--primary-light); box-shadow: inset 3px 0 0 #c1121f; }
.sidebar nav a svg { width: 16px; height: 16px; margin-right: 8px; vertical-align: -3px; }
.sidebar-section-label { padding: 14px 13px 4px; font-size: 11px; font-weight: 700; letter-spacing: 0.4px; color: var(--ash); text-transform: uppercase; }
.sidebar-brand > span svg { width: 20px; height: 20px; }
.brand-mark svg { width: 28px; height: 28px; }
.login-logo { display: block; width: 100%; max-width: 220px; height: auto; margin: 0 auto 18px; }
.login-title-img { display: block; width: 100%; max-width: 300px; height: auto; margin: 0 auto 28px; }
.checkin-title-img { display: block; width: 100%; max-width: 220px; height: auto; margin: 0 auto 18px; }
.checkin-hand-img { display: block; width: 100%; max-width: 200px; height: auto; margin: 18px auto 0; }
.logout svg { width: 15px; height: 15px; margin-right: 6px; vertical-align: -2px; }

/* --- Buttons: ตัวแปรเสริมที่ต้นฉบับไม่มีชื่อนี้ แต่ HTML เรายังใช้อยู่ --- */
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-secondary { color: #141414; background: #f0f0f0; }
.btn-secondary:hover { background: #e5e5e5; }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 0 14px; font-size: 12.5px; border-radius: 100px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* --- Card ที่กดเป็นลิงก์ได้ (การ์ดงานของ staff) --- */
.card-tap { display: block; cursor: pointer; transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease; }
.card-tap:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: #e3b3b7; }
.card-tap:active { transform: translateY(0); }

/* --- ไอคอนกลมทั่วไป (ใช้นอกบริบท .stat เช่น การ์ดงานของ staff) --- */
.stat-tile { display: flex; align-items: center; gap: 12px; }
.icon { width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; color: var(--primary); flex: none; }
.icon svg { width: 18px; height: 18px; }

/* --- .table: คอลัมน์ชื่อ (มักยาว) ให้ตัดขึ้นบรรทัดใหม่ได้ แทนที่จะบีบตารางทั้งแถวให้ล้นแนวนอนจนคอลัมน์ปุ่ม "แก้ไข" ทางขวาหลุดจอ --- */
.table td:first-child, .table th:first-child { white-space: normal; min-width: 160px; }
.table td:last-child, .table th:last-child { white-space: nowrap; text-align: right; }

/* --- คอลัมน์สถานที่ (ที่อยู่เต็มยาวๆ) ก็ต้องตัดขึ้นบรรทัดใหม่ได้เหมือนกัน ไม่งั้นดันตารางล้นแนวนอนทั้งที่จอกว้างพอ --- */
.table td.col-location { white-space: normal; max-width: 260px; }

/* --- Backdrop ตอนเปิด sidebar บนจอแคบ (เป็น overlay ทับเนื้อหา) แตะพื้นที่ว่างตรงไหนก็ปิดได้ ไม่ต้องกดปุ่ม menu ซ้ำ --- */
.sidebar-backdrop { display: none; position: fixed; inset: 0; z-index: 45; background: rgba(0, 0, 0, 0.4); }
@media (max-width: 1400px) { .sidebar-backdrop.open { display: block; } }

/* --- Badge สถานะเช็คอิน/เช็คเอาท์ (มี dot บอกสถานะ, ใช้ทั่วระบบ) --- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 100px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.badge .bdot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge-pending { background: var(--warn-pale); color: var(--warn-deep); }
.badge-in { background: var(--info-pale); color: var(--info-deep); }
.badge-out { background: var(--success-pale); color: var(--success-deep); }
.badge-role { background: var(--surface-card); color: var(--body-c); border: 1px solid var(--hairline); }
.badge-success { background: var(--success-pale); color: var(--success-deep); }
.badge-danger { background: var(--warn-pale); color: var(--danger); }

/* --- Alert แจ้งเตือน/error/success แบบเต็มบรรทัด (ใช้ทั่วระบบ) --- */
.alert { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: var(--radius-md); font-size: 13.5px; margin-bottom: 16px; animation: fadeInUp 0.2s var(--ease); }
.alert svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.alert-error { background: var(--error-pale); color: var(--error); }
.alert-success { background: var(--success-pale); color: var(--success-deep); }
.alert-warn { background: var(--warn-pale); color: var(--warn-deep); }

/* --- Loading / skeleton --- */
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid rgba(255, 255, 255, 0.4); border-top-color: #fff; animation: spin 0.7s linear infinite; flex: none; }
.spinner-dark { border-color: var(--hairline); border-top-color: var(--primary); }
.loading-line { display: flex; align-items: center; gap: 10px; color: var(--mute); font-size: 14px; padding: 4px 0; }
.skeleton { background: linear-gradient(90deg, var(--surface-card) 25%, var(--hairline-soft) 37%, var(--surface-card) 63%); background-size: 400% 100%; animation: pulse 1.3s ease-in-out infinite; border-radius: var(--radius-md); }

/* --- ค้นหาสถานที่ (autocomplete) --- */
.location-suggestions { position: absolute; z-index: 20; top: 100%; left: 0; right: 0; margin-top: 4px; background: var(--canvas); border: 1px solid var(--hairline); border-radius: var(--radius-md); box-shadow: var(--shadow-lg); max-height: 260px; overflow-y: auto; }
.location-suggestion-item { padding: 10px 14px; font-size: 13.5px; color: var(--body-c); cursor: pointer; border-bottom: 1px solid var(--hairline-soft); }
.location-suggestion-item:last-child { border-bottom: none; }
.location-suggestion-item:hover { background: var(--surface-card); }
.checklist { display: flex; flex-direction: column; gap: 2px; max-height: 260px; overflow-y: auto; padding: 8px; border: 1px solid var(--hairline); border-radius: var(--radius-md); background: var(--surface-card); }
.checklist label { display: flex; align-items: center; gap: 8px; font-weight: 400; margin: 0; padding: 6px 4px; border-radius: 6px; font-size: 14px; }
.checklist label:hover { background: rgba(0, 0, 0, 0.03); }
.checklist input[type="checkbox"] { width: 16px; height: 16px; }

/* --- กล่องแยกแสดงรายชื่อ CO ที่เลือกไว้แล้ว (chip ลบออกได้ทีละคน) แยกจาก checklist รายชื่อทั้งหมดด้านล่าง --- */
.co-selected-box { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px; margin-bottom: 8px; border: 1px solid var(--primary-light); border-radius: var(--radius-md); background: var(--primary-soft); }
.co-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 6px 5px 12px; border-radius: 100px; background: #fff; border: 1px solid var(--hairline); font-size: 12.5px; font-weight: 600; color: var(--ink); }
.co-chip button { display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: rgba(0, 0, 0, 0.06); color: var(--mute); font-size: 14px; line-height: 1; }
.co-chip button:hover { background: rgba(0, 0, 0, 0.12); color: var(--danger); }

.bottom-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex;
    background: rgba(255, 255, 255, 0.96); backdrop-filter: saturate(180%) blur(10px);
    border-top: 1px solid var(--hairline); padding: 6px 6px calc(6px + var(--safe-b));
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.05);
}
.bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 4px 6px; color: var(--ash); font-size: 11px; font-weight: 600; border-radius: var(--radius-md); transition: color 0.15s var(--ease); }
.bottom-nav a svg { width: 22px; height: 22px; transition: transform 0.15s var(--ease); }
.bottom-nav a.active { color: var(--primary); }
.bottom-nav a.active svg { transform: translateY(-1px); }
.bottom-nav a:active svg { transform: scale(0.88); }
body.has-bottom-nav { padding-bottom: calc(70px + var(--safe-b)); }

/* --- bottom nav ที่เสริมให้หน้า sidebar shell (admin/pm/staff) โชว์เฉพาะจอแคบที่ sidebar หลบไปหลังปุ่ม menu แล้ว — จอกว้าง sidebar โชว์อยู่แล้วไม่ต้องซ้ำ --- */
.bottom-nav-responsive { display: none; }
@media (max-width: 1400px) { .bottom-nav-responsive { display: flex; } }

/* --- Check-in flow ของ staff: stepper + ไอคอนขั้นตอน --- */
.checkin-card { width: 100%; max-width: 460px; }
.qr-scan-box { width: 100%; border-radius: var(--radius-lg); overflow: hidden; background: #000; box-shadow: var(--shadow); }
#cameraInput { display: none; }
.info-box { background: var(--surface-card); padding: 16px; border-radius: var(--radius-lg); font-size: 14px; }
.qr-display { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 16px; background: var(--surface-card); border-radius: var(--radius-lg); }
.qr-display img { width: 220px; height: 220px; border-radius: var(--radius-md); background: #fff; }
.step-icon-wrap { width: 64px; height: 64px; border-radius: 50%; background: var(--primary-light); color: var(--primary); display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; animation: fadeInUp 0.25s var(--ease); }
.step-icon-wrap svg { width: 30px; height: 30px; }
.stepper { display: flex; align-items: center; justify-content: center; gap: 6px; margin-bottom: 4px; }
.stepper .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--hairline); transition: background 0.2s var(--ease), transform 0.2s var(--ease); }
.stepper .dot.active { background: var(--primary); transform: scale(1.3); }
.stepper .dot.done { background: var(--success-deep); }

/* --- Login: จำลอง .container ที่หน้า login เก่าอ้างถึง (เผื่อ markup ใดยังอ้างอยู่) --- */
.login-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }

/* --- สีไอคอนหมุนวนใน .grid4 .stat ให้แต่ละ tile มีสีต่างกัน (สดใสแบบตัวอย่าง category icon) --- */
.grid4 .stat:nth-child(2) .icon { color: var(--accent-green); background: var(--accent-green-pale); }
.grid4 .stat:nth-child(2)::after { background: var(--accent-green-pale); }
.grid4 .stat:nth-child(3) .icon { color: var(--accent-blue); background: var(--accent-blue-pale); }
.grid4 .stat:nth-child(3)::after { background: var(--accent-blue-pale); }
.grid4 .stat:nth-child(4) .icon { color: var(--accent-purple); background: var(--accent-purple-pale); }
.grid4 .stat:nth-child(4)::after { background: var(--accent-purple-pale); }

/* --- Hero banner: การ์ดทักทาย/สรุปด้านบนของหน้ารายการหลัก (โทนอุ่นสดใสแบบตัวอย่าง promo banner) --- */
.hero-banner {
    position: relative; overflow: hidden; padding: 24px 26px; margin-bottom: 16px;
    border-radius: var(--radius-xl); color: #fff; background: var(--gradient-warm);
    box-shadow: 0 16px 34px rgba(193, 18, 31, 0.3);
}
.hero-banner::before {
    content: ""; position: absolute; width: 180px; height: 180px; right: -50px; top: -60px;
    border-radius: 50%; background: rgba(255, 255, 255, 0.1);
}
.hero-banner::after {
    content: ""; position: absolute; width: 120px; height: 120px; right: 40px; bottom: -70px;
    border-radius: 50%; background: rgba(255, 255, 255, 0.07);
}
.hero-banner .eyebrow { display: inline-flex; align-items: center; gap: 7px; padding: 4px 12px; margin-bottom: 10px; border-radius: 100px; font-size: 11px; font-weight: 700; color: #141414; background: #fff; letter-spacing: .03em; }
.hero-banner .eyebrow::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--primary); flex: none; }

/* --- Segmented pill-tab toggle: กลุ่มปุ่มสลับมุมมอง (สถานะ/ช่วงเวลา ฯลฯ) แบบแทร็คเดียวลอยได้ทั้งบนพื้นขาวและบนพื้นสีเข้ม (เช่น hero-banner) --- */
.segmented {
    display: inline-flex; gap: 3px; padding: 4px; border-radius: 100px;
    background: rgba(0, 0, 0, 0.05); flex-wrap: wrap;
}
.hero-banner .segmented, .segmented.on-dark { background: rgba(255, 255, 255, 0.16); }
.segmented button {
    padding: 8px 16px; border-radius: 100px; font-size: 12.5px; font-weight: 600;
    color: var(--text-secondary); background: transparent; white-space: nowrap; transition: background .15s ease, color .15s ease;
}
.hero-banner .segmented button, .segmented.on-dark button { color: rgba(255, 255, 255, 0.85); }
.segmented button.active { color: var(--primary-dark); background: #fff; box-shadow: var(--shadow-sm); }
.hero-banner .segmented button.active, .segmented.on-dark button.active { color: var(--primary-dark); background: #fff; }

/* --- Filter bar: กล่องพื้นเทาอ่อนครอบแถวตัวกรอง (วันที่/สถานะ/dropdown) แยกจากพื้นการ์ดขาวให้เห็นเป็นกลุ่มชัดเจน --- */
.filter-bar {
    display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
    padding: 12px 14px; border-radius: var(--radius-md); background: var(--bg);
    border: 1px solid var(--border);
}
.filter-bar > * { flex: none; }
.filter-bar input, .filter-bar select { min-width: 0; }
.hero-banner h3 { position: relative; z-index: 2; margin: 0 0 4px; font-size: 21px; font-weight: 700; color: #fff; }
.hero-banner p { position: relative; z-index: 2; margin: 0; color: rgba(255, 255, 255, 0.88); font-size: 13.5px; max-width: 420px; }
.hero-banner .btn { position: relative; z-index: 2; margin-top: 14px; color: var(--primary-dark); background: #fff; }
.hero-banner .btn:hover { background: #fff; opacity: .92; }

/* --- Grid 2 คอลัมน์แบบตายตัว (260px ซ้าย + เนื้อหาที่เหลือ) ใช้ในหน้ารายละเอียดโปรเจ็คของ PM — ต้องยุบเป็น 1 คอลัมน์บนจอแคบ ไม่งั้นล้นจอแนวนอน --- */
.detail-two-col { grid-template-columns: 260px 1fr; }
@media (max-width: 1400px) { .detail-two-col { grid-template-columns: 1fr; } }

/* --- แถวค้นหา+ฟิลเตอร์ (input + select): บนจอแคบ select หลายตัวในแถวเดียวจะถูกบีบจนตัวหนังสือโดนตัด (เช่น "ทุกแผนก" เหลือ "ทุกเ")
   ให้ตั้ง min-width พอประมาณ แล้วให้ .row (มี flex-wrap:wrap อยู่แล้ว) ตัดขึ้นบรรทัดใหม่เองแทนการบีบ --- */
@media (max-width: 1400px) {
    .row select { min-width: 130px; }
    .row .input-search { min-width: 160px; }
}

/* --- Mobile: แปลงตารางเป็นการ์ดวางซ้อนกันแทนการบีบตารางแคบๆ บนมือถือ (เข้าธีมการ์ดโค้งมนสดใส) --- */
@media (max-width: 1400px) {
    .table-wrap { overflow-x: visible; }
    .table thead { display: none; }
    .table, .table tbody { display: block; width: 100%; }
    .table tr {
        display: block; margin-bottom: 12px; padding: 14px 16px; background: var(--surface);
        border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
    }
    .table td { display: block; padding: 3px 0 !important; border-bottom: none; white-space: normal !important; text-align: left !important; font-size: 13px; }
    .table td:empty { display: none; }
    .table td:first-child { font-size: 15.5px; font-weight: 700; margin-bottom: 4px; }
    .table td:last-child:not(:first-child) { margin-top: 10px; }
    .table td:last-child .btn { width: 100%; }
    /* หัวตาราง (thead) ถูกซ่อนไปตอนพับเป็นการ์ด — เซลล์ไหนใส่ data-label ไว้ จะโชว์เป็นป้ายเล็กๆ กำกับค่าแทน ให้รู้ว่าตัวเลข/สถานะนั้นคืออะไร */
    .table td[data-label]::before {
        content: attr(data-label);
        display: block;
        font-size: 10.5px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: .03em;
        color: var(--mute);
        margin-bottom: 2px;
    }
}

/* --- ชื่อผู้ใช้มุมขวาบน: จอใหญ่โชว์ชื่อเต็ม (.chip-full) / มือถือโชว์ตัวอักษรแรกในวงกลม (.chip-initial) — ข้อความใส่โดย auth-guard.js --- */
.user-chip .chip-initial { display: none; }
/* มือถือเท่านั้น (≤767px — iPad/PC คงแบบเดิม): topbar บรรทัดเดียว เมนู+หัวข้อทางซ้าย กระดิ่ง+วงกลมชื่อชิดขวาบน */
@media (max-width: 767px) {
    .topbar { flex-wrap: nowrap; column-gap: 10px; }
    .topbar > .row { flex: 1 1 auto; min-width: 0; flex-wrap: nowrap; }   /* .row กลางยอมให้ขึ้นบรรทัดใหม่ — ปุ่มเมนูกับหัวข้อต้องอยู่บรรทัดเดียวกัน */
    .topbar > .row > div { flex: 1 1 auto; min-width: 0; }
    /* หัวข้อ/คำอธิบายใต้หัวข้อ บรรทัดเดียว ยาวเกินตัด "…" — topbar สูงเท่ากันทุกหน้า ไม่ดันเนื้อหาลง */
    .topbar > .row > div > h2,
    .topbar > .row > div > span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .top-right { flex: 0 0 auto; flex-wrap: nowrap; gap: 8px; margin-left: auto; }
    .user-chip { width: 38px; height: 38px; max-width: none; padding: 0; display: grid; place-items: center; border-radius: 50%; font-size: 16px; font-weight: 700; }
    .user-chip .chip-full { display: none; }
    .user-chip .chip-initial { display: inline; }
}
