*, *::before, *::after { box-sizing: border-box; }

/* ===== THEME COLOR SYSTEM (2026-07-11) =====
   เพิ่มตัวแปรสีธีมให้ปุ่มตั้งค่า (gear icon, partials/topbar.php) สลับได้ผ่าน [data-theme] บน <html>
   ครอบคลุมเฉพาะสีที่ hardcode ไว้ใน style.css นี้เท่านั้น (sidebar/header/ปุ่มหลัก/modal ฯลฯ) — ไฟล์อื่นๆ ที่เขียนสีส้ม
   inline แยกไว้ในแต่ละหน้า (report.php, dashboard.php ฯลฯ) ยังไม่ถูกแปลงเป็นตัวแปร จะยังเห็นสีส้มเดิมแม้เปลี่ยนธีม */
:root {
    --accent-50: #FFF8E7; --accent-100: #FFE8B2; --accent-200: #FFCC66;
    --accent-500: #e07800; --accent-600: #FF8C00; --accent-700: #cc6e00;
    --accent-rgb: 255,140,0;
}
:root[data-theme="blue"] {
    --accent-50: #EFF6FF; --accent-100: #BFDBFE; --accent-200: #93C5FD;
    --accent-500: #3B82F6; --accent-600: #2563EB; --accent-700: #1D4ED8;
    --accent-rgb: 37,99,235;
}
:root[data-theme="green"] {
    --accent-50: #F0FDF4; --accent-100: #BBF7D0; --accent-200: #86EFAC;
    --accent-500: #22C55E; --accent-600: #16A34A; --accent-700: #15803D;
    --accent-rgb: 22,163,74;
}
:root[data-theme="pink"] {
    --accent-50: #FDF2F8; --accent-100: #FBCFE8; --accent-200: #F9A8D4;
    --accent-500: #EC4899; --accent-600: #DB2777; --accent-700: #BE185D;
    --accent-rgb: 219,39,119;
}
:root[data-theme="purple"] {
    --accent-50: #FAF5FF; --accent-100: #E9D5FF; --accent-200: #D8B4FE;
    --accent-500: #A855F7; --accent-600: #9333EA; --accent-700: #7E22CE;
    --accent-rgb: 147,51,234;
}

/* ปรับขนาดทั้งหน้าทั้งระบบ (ตัวอักษร + ตาราง + การ์ด + ทุกอย่าง) — ใช้ zoom แทน font-size:%
   เพราะโค้ดส่วนใหญ่ในระบบกำหนด font-size เป็น px ตรงๆ (ไม่ใช่ rem) ตาม element/class ต่างๆ ทำให้การปรับ font-size ที่ <html>
   ไปไม่ถึงส่วนใหญ่ของหน้า (ตาราง/การ์ด/sidebar ส่วนใหญ่) — zoom สเกลทุกอย่างที่ render จริง ไม่ว่าจะกำหนดหน่วยเป็น px หรือ rem ก็ตาม */
html.font-sm { zoom: 87.5%; }
html.font-lg { zoom: 112.5%; }

/* ===== PAGE ENTRY ANIMATION ===== */
body { animation: pageFadeIn 0.4s ease both; }
@keyframes pageFadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ===== BASE ===== */
body {
    font-family: 'Tahoma', 'Segoe UI', sans-serif;
    background: var(--accent-50);
    margin: 0; padding: 0;
    display: flex;
    color: #2d3748;
    transition: all 0.3s;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: 260px;
    background: linear-gradient(180deg, var(--accent-600) 0%, var(--accent-500) 50%, var(--accent-700) 100%);
    color: white;
    min-height: 100vh;
    padding: 0;
    box-sizing: border-box;
    transition: width 0.3s cubic-bezier(0.4,0,0.2,1);
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: 4px 0 32px rgba(0,0,0,0.22);
    display: flex;
    flex-direction: column;
    position: relative;
}
/* glass shimmer overlay on sidebar */
.sidebar::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg,
        rgba(255,255,255,0.08) 0%,
        rgba(255,255,255,0.03) 40%,
        rgba(0,0,0,0.04) 100%);
    pointer-events: none;
    z-index: 0;
}
.sidebar > * { position: relative; z-index: 1; }

.sidebar-header {
    padding: 22px 18px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.15);
    background: rgba(0,0,0,0.12);
    backdrop-filter: blur(4px);
}
.sidebar-logo { display: flex; align-items: center; gap: 11px; margin-bottom: 14px; }
.sidebar-logo-icon {
    width: 42px; height: 42px;
    background: rgba(255,255,255,0.22);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.3);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.sidebar-logo-icon:hover { transform: rotate(-5deg) scale(1.08); box-shadow: 0 4px 16px rgba(0,0,0,0.28); }
.sidebar-logo-text h2 { margin: 0; font-size: 16px; color: #fff; font-weight: 700; line-height: 1.3; }
.sidebar-logo-text small { font-size: 10.5px; color: rgba(255,255,255,0.65); }
.sidebar-user {
    background: rgba(255,255,255,0.12);
    border-radius: 10px; padding: 10px 12px;
    border: 1px solid rgba(255,255,255,0.18);
    backdrop-filter: blur(6px);
}
.sidebar-user .user-name { font-weight: 700; font-size: 13.5px; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .user-role {
    font-size: 11px; color: rgba(255,255,255,0.9);
    background: rgba(0,0,0,0.28);
    padding: 2px 9px; border-radius: 20px;
    display: inline-block; margin-top: 5px;
    border: 1px solid rgba(255,255,255,0.12);
    max-width: 100%; box-sizing: border-box;
    white-space: normal; word-break: break-word;
}

.sidebar-nav { padding: 14px 12px; flex: 1; overflow-y: auto; }
.sidebar-nav .nav-label {
    font-size: 10px; text-transform: uppercase; letter-spacing: 1.5px;
    color: rgba(255,255,255,0.45); margin: 14px 0 6px 8px;
}
.sidebar-nav a {
    display: flex !important; align-items: center; gap: 10px;
    color: #fff !important;
    text-decoration: none !important;
    padding: 10px 14px !important;
    margin: 3px 0 !important;
    border-radius: 10px !important;
    font-size: 13.5px !important;
    font-weight: 600 !important;
    border: 1px solid rgba(255,255,255,0.06) !important;
    transition: all 0.22s cubic-bezier(0.4,0,0.2,1) !important;
    background: rgba(0,0,0,0.15) !important;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.06) !important;
    position: relative !important;
    overflow: hidden !important;
}
.sidebar-nav a:hover {
    background: rgba(255,255,255,0.18) !important;
    color: #fff !important;
    transform: translateX(6px) !important;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.18), 0 4px 16px rgba(0,0,0,0.25) !important;
    border-color: rgba(255,255,255,0.18) !important;
}
.sidebar-nav a.nav-active {
    background: rgba(255,255,255,0.26) !important;
    color: #fff !important;
    border-left: 3px solid rgba(255,255,255,0.95) !important;
    font-weight: 700 !important;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.2), 0 4px 16px rgba(0,0,0,0.2), 0 0 16px rgba(255,255,255,0.12) !important;
    border-color: rgba(255,255,255,0.22) !important;
}
.nav-badge {
    margin-left: auto;
    background: #fff;
    color: var(--accent-500);
    font-size: 10.5px;
    font-weight: 800;
    padding: 2px 7px;
    border-radius: 20px;
    min-width: 20px;
    text-align: center;
    line-height: 1.5;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
.sidebar-avatar {
    width: 38px; height: 38px;
    background: rgba(255,255,255,0.22);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 17px; font-weight: 800; color: #fff;
    flex-shrink: 0;
    border: 2px solid rgba(255,255,255,0.45);
    box-shadow: 0 2px 8px rgba(0,0,0,0.18), 0 0 0 3px rgba(255,255,255,0.08);
    letter-spacing: 0;
}
.sidebar-nav a.nav-logout {
    background: rgba(178,34,34,0.75) !important;
    color: #fff !important;
    margin-top: 16px !important;
    font-weight: 700 !important;
    border: 1px solid rgba(255,100,100,0.3) !important;
    backdrop-filter: blur(4px) !important;
}
.sidebar-nav a.nav-logout:hover {
    background: #e74c3c !important;
    transform: translateX(6px) !important;
    box-shadow: 0 4px 16px rgba(231,76,60,0.45) !important;
}
.btn-switch {
    display: flex !important; align-items: center; justify-content: center; gap: 6px;
    background: rgba(255,255,255,0.14) !important;
    color: #fff !important; text-decoration: none !important;
    padding: 9px 12px !important; font-size: 13px !important;
    font-weight: 600 !important; border-radius: 10px !important;
    text-align: center !important; margin: 4px 0 !important;
    border: 1px solid rgba(255,255,255,0.2) !important;
    transition: all 0.2s ease !important;
    backdrop-filter: blur(4px) !important;
}
.btn-switch:hover { background: rgba(255,255,255,0.28) !important; transform: translateY(-1px) !important; box-shadow: 0 4px 12px rgba(0,0,0,0.2) !important; }

/* ===== SIDEBAR เฉพาะตอนเลือก "สีกำหนดเอง" (custom color picker): พื้นหลังอ่อนกว่า + ปุ่มที่เลือกอยู่เข้มกว่า ให้แยกออกจากกันชัดเจน — ไม่กระทบ 5 ธีมสำเร็จรูปเดิม ===== */
[data-theme="custom"] .sidebar { background: var(--accent-100); }
[data-theme="custom"] .sidebar-header { background: rgba(0,0,0,0.35); }
[data-theme="custom"] .sidebar-nav .nav-label { color: rgba(0,0,0,0.45); }
[data-theme="custom"] .sidebar-nav a {
    color: var(--accent-700) !important;
    background: rgba(255,255,255,0.5) !important;
    border: 1.5px solid rgba(0,0,0,0.1) !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04) !important;
}
[data-theme="custom"] .sidebar-nav a:hover {
    background: rgba(255,255,255,0.6) !important;
    color: var(--accent-700) !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.06) !important;
    border-color: rgba(255,255,255,0.4) !important;
    transform: translateX(6px) !important;
}
[data-theme="custom"] .sidebar-nav a.nav-active {
    background: var(--accent-600) !important;
    color: #fff !important;
    border-left: 3px solid var(--accent-700) !important;
    box-shadow: 0 4px 16px rgba(0,0,0,0.18) !important;
    border-color: var(--accent-700) !important;
}
[data-theme="custom"] .sidebar-nav a.nav-logout { background: rgba(178,34,34,0.85) !important; color: #fff !important; }
[data-theme="custom"] .nav-badge { color: var(--accent-700); }
[data-theme="custom"] .sidebar-avatar { background: var(--accent-600); color: #fff; border-color: rgba(255,255,255,0.5); }
[data-theme="custom"] .btn-switch { background: var(--accent-600) !important; color: #fff !important; border-color: var(--accent-700) !important; }
[data-theme="custom"] .btn-switch:hover { background: var(--accent-700) !important; }
[data-theme="custom"] .nav-group-btn { background: rgba(255,255,255,0.5); color: var(--accent-700); }
[data-theme="custom"] .nav-group-btn:hover { background: rgba(255,255,255,0.8); }
[data-theme="custom"] .nav-group-btn.open { background: rgba(255,255,255,0.8); }
[data-theme="custom"] .nav-group-items { background: rgba(0,0,0,0.04); }
[data-theme="custom"] .nav-sub { color: var(--accent-700) !important; }
[data-theme="custom"] .nav-sub:hover { background: rgba(255,255,255,0.6) !important; color: var(--accent-700) !important; }
[data-theme="custom"] .nav-sub.nav-active { background: var(--accent-600) !important; color: #fff !important; border-left-color: var(--accent-700) !important; }

body.sidebar-collapsed .sidebar { width: 0; }

/* ===== MAIN ===== */
.main-content { flex: 1; padding: 22px 26px; overflow-x: hidden; transition: all 0.3s; min-width: 0; }

/* ===== HEADER ===== */
.header {
    background: white; padding: 16px 22px;
    border-radius: 14px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05), 0 8px 24px rgba(0,0,0,0.06);
    margin-bottom: 18px;
    display: flex; flex-direction: column; align-items: stretch; gap: 10px;
    border-left: 5px solid var(--accent-600);
    animation: slideDown 0.4s cubic-bezier(0.34,1.56,0.64,1) both;
    /* animation กับ fill-mode "both" ทำให้ .header กลายเป็น stacking context ของตัวเอง (ค้างถาวรแม้ animation จบแล้ว)
       ต้องให้ position+z-index ชัดเจน ไม่งั้น dropdown แจ้งเตือนข้างในจะโดน content ที่มาทีหลังใน DOM (เช่นตาราง) ทับได้ ไม่ว่า z-index ข้างในจะสูงแค่ไหน */
    position: relative;
    z-index: 50;
}
@keyframes slideDown { from { opacity: 0; transform: translateY(-14px); } to { opacity: 1; transform: translateY(0); } }
.header-top-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; }
.header-title-block { display: flex; align-items: center; gap: 14px; flex-shrink: 0; }
.toggle-btn {
    background: var(--accent-50); color: var(--accent-600);
    border: 1.5px solid var(--accent-100);
    padding: 8px 11px; font-size: 16px;
    border-radius: 9px; cursor: pointer;
    transition: all 0.2s cubic-bezier(0.34,1.56,0.64,1); flex-shrink: 0;
}
.toggle-btn:hover { background: var(--accent-600); color: white; border-color: var(--accent-600); transform: scale(1.08); }
.header h1 { margin: 0; font-size: 19px; color: var(--accent-600); font-weight: 700; }
.header-date {
    font-size: 12.5px; color: #777;
    background: #f7f7f7; padding: 6px 14px; border-radius: 20px;
    white-space: nowrap;
}

/* ===== MARQUEE ===== */
.marquee-text {
    overflow: hidden; width: 100%; box-sizing: border-box;
    font-size: 15px; color: var(--accent-700); font-weight: 500;
    border-top: 1px solid var(--accent-100);
    padding: 8px 2px 0;
}
.marquee-text span { display: inline-block; white-space: nowrap; animation: marquee 40s linear infinite; }
@keyframes marquee { 0% { transform: translateX(100%); } 100% { transform: translateX(-100%); } }

/* ===== NOTIFICATIONS ===== */
.notif-bell-wrap { position: relative; flex-shrink: 0; }
.notif-bell-btn {
    position: relative; background: var(--accent-50); color: var(--accent-600); border: 1.5px solid var(--accent-100);
    width: 38px; height: 38px; border-radius: 10px; font-size: 17px; cursor: pointer;
    display: flex; align-items: center; justify-content: center; transition: all 0.2s cubic-bezier(0.34,1.56,0.64,1);
    font-family: inherit; padding: 0;
}
.notif-bell-btn:hover { background: var(--accent-600); color: white; border-color: var(--accent-600); transform: scale(1.08); }
.notif-badge {
    position: absolute; top: -5px; right: -5px; background: #dc2626; color: white;
    font-size: 10px; font-weight: 800; min-width: 17px; height: 17px; border-radius: 10px;
    align-items: center; justify-content: center; padding: 0 4px;
    border: 2px solid white; line-height: 1;
}
.notif-dropdown {
    position: absolute; top: calc(100% + 12px); right: 0; width: 360px; max-width: 92vw;
    background: white; border-radius: 16px; box-shadow: 0 16px 46px rgba(0,0,0,.16), 0 2px 8px rgba(0,0,0,.06);
    border: 1px solid #f0e0d6; z-index: 99999; display: none; overflow: hidden;
}
.notif-dropdown.show { display: block; animation: notifPop .16s cubic-bezier(0.34,1.56,0.64,1) both; }
@keyframes notifPop { from { opacity: 0; transform: translateY(-6px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.notif-dropdown-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px; border-bottom: 1px solid #f3f4f6;
}
.notif-dropdown-header .notif-title { font-weight: 800; color: #1f2937; font-size: .96rem; display: flex; align-items: center; gap: 7px; }
.notif-dropdown-header button {
    background: var(--accent-50); border: 1px solid var(--accent-100); color: var(--accent-700); font-size: .72rem; font-weight: 700;
    cursor: pointer; font-family: inherit; padding: 5px 11px; border-radius: 20px; transition: background .15s, border-color .15s;
}
.notif-dropdown-header button:hover { background: var(--accent-600); color: white; border-color: var(--accent-600); }
.notif-list { max-height: 380px; overflow-y: auto; }
.notif-item {
    display: flex; align-items: flex-start; gap: 11px;
    padding: 12px 16px; border-bottom: 1px solid #f8f8f8;
    cursor: pointer; transition: background .15s;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: #fafafa; }
.notif-item.unread { background: var(--accent-50); }
.notif-item-icon {
    width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; font-size: 1.05rem;
    background: var(--accent-50); color: var(--accent-700);
}
.notif-item-body { flex: 1; min-width: 0; }
.notif-item-msg {
    font-size: .83rem; color: #4b5563; line-height: 1.6;
    word-break: break-word;
}
.notif-item.unread .notif-item-msg { font-weight: 700; color: #1f2937; }
.notif-item-msg .notif-hl {
    color: var(--accent-700); font-weight: 800; background: var(--accent-50);
    padding: 1px 7px; border-radius: 6px; display: inline-block;
}
.notif-item-time { font-size: .71rem; color: #9ca3af; margin-top: 4px; }
.notif-item-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent-600); flex-shrink: 0; margin-top: 6px; }
.notif-empty { text-align: center; padding: 36px 16px; color: #9ca3af; font-size: .85rem; }
.notif-empty .notif-empty-ico { font-size: 2rem; margin-bottom: 8px; display: block; }

/* ===== SETTINGS (gear icon next to notif bell) ===== */
.settings-gear-wrap { position: relative; flex-shrink: 0; }
.settings-gear-btn {
    position: relative; background: var(--accent-50); color: var(--accent-600); border: 1.5px solid var(--accent-100);
    width: 38px; height: 38px; border-radius: 10px; font-size: 17px; cursor: pointer;
    display: flex; align-items: center; justify-content: center; transition: all 0.2s cubic-bezier(0.34,1.56,0.64,1);
    font-family: inherit; padding: 0;
}
.settings-gear-btn:hover { background: var(--accent-600); color: white; border-color: var(--accent-600); transform: scale(1.08) rotate(25deg); }
.settings-dropdown {
    position: absolute; top: calc(100% + 12px); right: 0; width: 280px; max-width: 92vw;
    background: white; border-radius: 16px; box-shadow: 0 16px 46px rgba(0,0,0,.16), 0 2px 8px rgba(0,0,0,.06);
    border: 1px solid #f0e0d6; z-index: 99999; display: none; overflow: hidden;
}
.settings-dropdown.show { display: block; animation: notifPop .16s cubic-bezier(0.34,1.56,0.64,1) both; }
.settings-dropdown-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px; border-bottom: 1px solid #f3f4f6;
    font-weight: 800; color: #1f2937; font-size: .96rem;
}
.settings-section { padding: 14px 16px; border-bottom: 1px solid #f8f8f8; }
.settings-section:last-child { border-bottom: none; }
.settings-section-title { font-size: .76rem; font-weight: 700; color: #9ca3af; text-transform: uppercase; letter-spacing: .4px; margin-bottom: 9px; }
.settings-opt-row { display: flex; gap: 8px; }
.settings-opt-btn {
    flex: 1; padding: 8px 6px; background: #f9fafb; border: 1.5px solid #e5e7eb; border-radius: 9px;
    font-family: inherit; font-size: .8rem; font-weight: 700; color: #4b5563; cursor: pointer;
    transition: all .15s; text-align: center;
}
.settings-opt-btn:hover { border-color: var(--accent-100); background: var(--accent-50); }
.settings-opt-btn.active { background: var(--accent-600); color: white; border-color: var(--accent-600); }
.settings-swatch-row { display: flex; gap: 10px; }
.settings-swatch {
    width: 32px; height: 32px; border-radius: 50%; border: 2px solid #fff;
    box-shadow: 0 0 0 1.5px #e5e7eb; cursor: pointer; padding: 0;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 14px; transition: all .15s;
}
.settings-swatch:hover { transform: scale(1.1); }
.settings-swatch.active { box-shadow: 0 0 0 2.5px var(--accent-600); }
.settings-swatch.active::after { content: '✓'; font-weight: 800; }
.settings-swatch-custom { background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red); }

/* ===== STAT CARDS ===== */
.stat-cards {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
    gap: 14px; margin-bottom: 20px;
}
.stat-card {
    background: white; border-radius: 14px; padding: 20px 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    border-top: 4px solid var(--accent-600);
    transition: all 0.28s cubic-bezier(0.34,1.56,0.64,1);
    animation: slideUp 0.5s cubic-bezier(0.34,1.56,0.64,1) both;
    cursor: default;
    position: relative;
    overflow: hidden;
}
/* glass shine sweep on card hover */
.stat-card::before {
    content: '';
    position: absolute;
    top: -50%; left: -60%;
    width: 70%; height: 200%;
    background: linear-gradient(105deg, rgba(255,255,255,0) 40%, rgba(255,255,255,0.38) 50%, rgba(255,255,255,0) 60%);
    transform: skewX(-20deg) translateX(-100%);
    transition: transform 0.55s ease;
    pointer-events: none;
}
.stat-card:hover::before { transform: skewX(-20deg) translateX(280%); }
.stat-card:hover { transform: translateY(-6px) scale(1.02); box-shadow: 0 14px 36px rgba(var(--accent-rgb),0.22), 0 2px 8px rgba(0,0,0,0.08); }
.stat-card .stat-num { font-size: 36px; font-weight: 800; color: var(--accent-600); line-height: 1; }
.stat-card .stat-label { font-size: 12px; color: #888; margin-top: 6px; }
/* เดิม nth-child(2/3/4) มีสีของตัวเองแยกจากธีม (ส้ม/เขียว/ฟ้า) — เอาออกแล้วให้ทุกการ์ดตามสีธีมที่เลือกเหมือนกันหมด ตามที่ผู้ใช้ขอ 2026-07-11 */

@keyframes slideUp { from { opacity: 0; transform: translateY(22px) scale(0.96); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }

/* ===== FILTER BAR ===== */
.filter-bar {
    background: white; padding: 14px 18px; border-radius: 14px;
    margin-bottom: 16px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    animation: slideUp 0.4s ease 0.1s both;
}
.filter-bar input[type="text"] {
    flex: 2; min-width: 210px; padding: 9px 14px;
    border: 1.5px solid #e2e8f0; border-radius: 9px; font-size: 13px;
    transition: all 0.2s; outline: none; font-family: inherit;
}
.filter-bar input[type="text"]:focus { border-color: var(--accent-600); box-shadow: 0 0 0 3px rgba(var(--accent-rgb),0.12); transform: translateY(-1px); }
.filter-bar select {
    flex: 1; min-width: 128px; padding: 9px 10px;
    border: 1.5px solid #e2e8f0; border-radius: 9px; background: white;
    cursor: pointer; font-size: 13px; outline: none; font-family: inherit;
    transition: all 0.2s;
}
.filter-bar select:focus { border-color: var(--accent-600); box-shadow: 0 0 0 3px rgba(var(--accent-rgb),0.12); }

/* ===== TABS ===== */
.tab-container {
    display: flex; gap: 5px; margin-bottom: 16px;
    background: white; padding: 6px 8px; border-radius: 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06); flex-wrap: wrap;
    animation: slideUp 0.4s ease 0.05s both;
}
.tab-btn {
    padding: 8px 16px; border: none; background: transparent;
    color: #666; cursor: pointer; border-radius: 9px;
    font-weight: 600; font-size: 13px;
    display: flex; align-items: center; gap: 5px;
    transition: all 0.22s cubic-bezier(0.34,1.56,0.64,1); font-family: inherit;
    position: relative; overflow: hidden;
}
.tab-btn:hover { background: var(--accent-50); color: var(--accent-600); transform: translateY(-1px); }
.tab-btn.active {
    background: linear-gradient(135deg, var(--accent-600), var(--accent-700));
    color: white;
    box-shadow: 0 4px 14px rgba(var(--accent-rgb),0.38);
    transform: translateY(-1px);
}
.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.3s ease; }

/* ===== PAGINATION (ตารางรายชื่อที่มีหลายหน้า) ===== */
.pagination { display:flex; gap:6px; justify-content:center; align-items:center; padding:16px 0; flex-wrap:wrap; }
.pg-btn { padding:6px 12px; border-radius:8px; border:1.5px solid #e5e7eb; background:#fff; color:#374151; font-weight:700; font-size:.82rem; text-decoration:none; cursor:pointer; }
.pg-btn.active { background:var(--accent-700); color:#fff; border-color:var(--accent-700); }
.pg-btn:hover:not(.active) { border-color:var(--accent-700); }
.pg-info { font-size:.8rem; color:#6b7280; padding:0 6px; }

/* ===== TABLE ===== */
.table-responsive { width: 100%; overflow-x: auto; border-radius: 14px; }
table {
    width: 100%; border-collapse: collapse; background: white;
    border-radius: 14px; overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06), 0 4px 20px rgba(0,0,0,0.05);
    margin-bottom: 0;
}
th {
    background: linear-gradient(135deg, var(--accent-600) 0%, var(--accent-700) 100%);
    color: white; font-weight: 700; padding: 13px 14px;
    text-align: left; white-space: nowrap; font-size: 13px;
}
td {
    padding: 11px 14px; text-align: left;
    border-bottom: 1px solid #f2f2f2; white-space: nowrap; font-size: 13px;
    transition: background 0.18s ease;
}
tbody tr { transition: all 0.18s ease; }
tbody tr:hover td { background: #FFFBF0; }
tbody tr:hover { box-shadow: inset 3px 0 0 var(--accent-600); }
tbody tr:last-child td { border-bottom: none; }

/* ===== BUTTONS ===== */
.btn {
    padding: 7px 14px; border-radius: 8px; text-decoration: none;
    font-size: 12.5px; font-weight: 600; cursor: pointer;
    display: inline-flex; align-items: center; gap: 4px;
    border: none; transition: all 0.22s cubic-bezier(0.34,1.56,0.64,1);
    white-space: nowrap; font-family: inherit;
    position: relative; overflow: hidden;
}
.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.28);
    border-radius: inherit;
    opacity: 0;
    transform: scale(0);
    transition: transform 0.35s ease, opacity 0.35s ease;
}
.btn:active::after { transform: scale(2.5); opacity: 1; transition: none; }
.btn-info    { background: #e8f7fa; color: #0e7490; }
.btn-info:hover    { background: #0e7490; color: #fff; transform: translateY(-2px); box-shadow: 0 5px 14px rgba(14,116,144,0.35); }
.btn-warning { background: #fef3cd; color: #92610a; }
.btn-warning:hover { background: #f39c12; color: #fff; transform: translateY(-2px); box-shadow: 0 5px 14px rgba(243,156,18,0.35); }
.btn-success { background: #e8f8f0; color: #166534; }
.btn-success:hover { background: #27ae60; color: #fff; transform: translateY(-2px); box-shadow: 0 5px 14px rgba(39,174,96,0.35); }
.btn-danger  { background: #fde8e8; color: #991b1b; }
.btn-danger:hover  { background: #e74c3c; color: #fff; transform: translateY(-2px); box-shadow: 0 5px 14px rgba(231,76,60,0.35); }
.btn-primary { background: #e8f0fd; color: #1e40af; }
.btn-primary:hover { background: #2980b9; color: #fff; transform: translateY(-2px); box-shadow: 0 5px 14px rgba(41,128,185,0.35); }

/* ===== ALERTS ===== */
.alert-success {
    background: #ecfdf5; color: #065f46; padding: 12px 16px;
    border-radius: 10px; margin-bottom: 14px; border-left: 4px solid #10b981;
    animation: slideUp 0.3s ease;
}
.alert-danger {
    background: #fef2f2; color: #991b1b; padding: 12px 16px;
    border-radius: 10px; margin-bottom: 14px; border-left: 4px solid #ef4444;
    animation: slideUp 0.3s ease;
}

/* ===== BADGES ===== */
.badge-status {
    padding: 4px 10px; border-radius: 20px;
    font-size: 11.5px; font-weight: 700;
    display: inline-flex; align-items: center; gap: 3px;
}
.badge-success { background: #dcfce7; color: #15803d; }
.badge-danger  { background: #fee2e2; color: #b91c1c; }
.badge-warning { background: #fef9c3; color: #854d0e; }

/* ===== MODAL ===== */
.modal {
    display: none; position: fixed; z-index: 9999;
    left: 0; top: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.45); backdrop-filter: blur(4px);
    align-items: center; justify-content: center;
}
.modal.active { display: flex; animation: fadeIn 0.25s ease; }
.modal-content {
    background: #fff; border-radius: 18px;
    width: 860px; max-width: 95%; max-height: 90vh;
    overflow: hidden; position: relative;
    display: flex; flex-direction: column;
    box-shadow: 0 24px 64px rgba(0,0,0,0.28), 0 2px 8px rgba(0,0,0,0.12);
    animation: modalSlideIn 0.32s cubic-bezier(0.34,1.56,0.64,1) both;
}
@keyframes modalSlideIn {
    from { opacity: 0; transform: translateY(-30px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-header {
    background: linear-gradient(135deg, var(--accent-600), var(--accent-700));
    color: white; padding: 16px 22px; border-radius: 18px 18px 0 0;
    display: flex; justify-content: space-between; align-items: center;
    flex-shrink: 0;
    box-shadow: 0 4px 16px rgba(var(--accent-rgb),0.3);
}
.modal-header h2 { margin: 0; font-size: 16px; color: white; }
.modal-body { padding: 22px 24px; overflow-y: auto; min-height: 0; }
.close-modal {
    background: rgba(255,255,255,0.2); border: none; color: white;
    width: 30px; height: 30px; border-radius: 50%;
    font-size: 17px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s cubic-bezier(0.34,1.56,0.64,1); line-height: 1; font-family: inherit;
}
.close-modal:hover { background: rgba(255,255,255,0.38); transform: scale(1.15) rotate(90deg); }
.modal-section-title {
    font-size: 12.5px; font-weight: 700; color: var(--accent-700);
    background: var(--accent-50); padding: 7px 14px;
    border-left: 4px solid var(--accent-600); margin: 18px 0 10px;
    border-radius: 0 6px 6px 0;
}
.modal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.modal-item { border-bottom: 1px solid #f5f5f5; padding: 8px 4px; font-size: 13.5px; }
.modal-item > span { font-weight: 600; color: #666; display: inline-block; width: 155px; }
.modal-item .val { color: #1a1a1a; display: block; margin-top: 2px; }
.form-group-edit { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.form-group-edit label { font-size: 12px; font-weight: 700; color: var(--accent-600); }
.form-control {
    width: 100%; padding: 8px 10px; box-sizing: border-box;
    border: 1.5px solid #e2e8f0; border-radius: 8px; font-size: 13px;
    transition: all 0.2s; outline: none; font-family: inherit;
}
.form-control:focus { border-color: var(--accent-600); box-shadow: 0 0 0 3px rgba(var(--accent-rgb),0.12); transform: translateY(-1px); }

/* ===== DOC LIST TABLE ===== */
.doc-list-table { width: 100%; margin-top: 10px; border: 1px solid #f0f0f0; border-radius: 10px; overflow: hidden; border-collapse: separate; border-spacing: 0; }
.doc-list-table th { background: var(--accent-50); color: var(--accent-700); font-size: 13px; padding: 10px 14px; font-weight: 700; }
.doc-list-table td { padding: 9px 14px; font-size: 13px; border-bottom: 1px solid #f8f8f8; transition: background 0.18s; }
.doc-list-table tbody tr:hover td { background: #FFFBF0; }

/* ===== CHECKPOINT ===== */
.checkpoint-container {
    background: white; padding: 22px; border-radius: 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06), 0 4px 20px rgba(0,0,0,0.05);
    margin-top: 18px; animation: slideUp 0.4s ease 0.15s both;
}
.checkpoint-title { color: var(--accent-600); font-size: 16px; margin: 0 0 16px; border-bottom: 2px solid var(--accent-100); padding-bottom: 10px; font-weight: 700; }
.timeline { display: flex; flex-direction: column; gap: 14px; position: relative; padding-left: 22px; }
.timeline::before { content: ''; position: absolute; left: 5px; top: 5px; bottom: 5px; width: 3px; background: linear-gradient(180deg, var(--accent-200), var(--accent-100)); border-radius: 4px; }
.step { display: flex; align-items: flex-start; gap: 15px; position: relative; }
.step-badge { width: 13px; height: 13px; border-radius: 50%; background: #ccc; position: absolute; left: -21px; top: 4px; border: 2px solid white; box-shadow: 0 0 0 2px #ccc; transition: all 0.3s ease; }
.step.active .step-badge { background: #27ae60; box-shadow: 0 0 0 2px #27ae60, 0 0 8px rgba(39,174,96,0.4); }
.step.disabled .step-badge { background: #e74c3c; box-shadow: 0 0 0 2px #e74c3c; }
.step-content { background: #fafafa; padding: 12px 16px; border-radius: 9px; flex: 1; border-left: 3px solid #ddd; transition: all 0.2s ease; }
.step.active .step-content { background: #f0fdf4; border-left-color: #27ae60; box-shadow: 0 2px 8px rgba(39,174,96,0.1); }
.step.disabled .step-content { background: #fef2f2; border-left-color: #e74c3c; }
.step-heading { font-weight: 700; font-size: 13.5px; margin-bottom: 3px; color: #333; }
.step.active .step-heading { color: #166534; }
.step.disabled .step-heading { color: #991b1b; }
.step-desc { font-size: 12px; color: #777; }

.back-link {
    display: inline-flex; align-items: center; gap: 6px;
    margin-bottom: 16px; padding: 9px 18px;
    background: linear-gradient(135deg, var(--accent-600), var(--accent-700));
    color: white; text-decoration: none;
    border-radius: 9px; font-weight: 600; font-size: 13px;
    transition: all 0.22s cubic-bezier(0.34,1.56,0.64,1);
    box-shadow: 0 4px 14px rgba(var(--accent-rgb),0.3);
    position: relative; overflow: hidden;
}
.back-link::after { content: ''; position: absolute; inset: 0; background: rgba(255,255,255,0.2); opacity: 0; transition: opacity 0.2s; }
.back-link:hover { transform: translateX(-4px) translateY(-2px); box-shadow: 0 6px 20px rgba(var(--accent-rgb),0.45); }
.back-link:hover::after { opacity: 1; }

/* ===== STANDALONE PAGES ===== */
.standalone-bg {
    background: linear-gradient(135deg, var(--accent-50) 0%, var(--accent-50) 100%);
    min-height: 100vh; display: flex;
    align-items: center; justify-content: center; padding: 20px;
    font-family: 'Tahoma', 'Segoe UI', sans-serif;
}
.standalone-card {
    background: white; border-radius: 18px;
    box-shadow: 0 12px 48px rgba(var(--accent-rgb),0.18), 0 2px 8px rgba(0,0,0,0.08);
    width: 100%; max-width: 430px; overflow: hidden;
    animation: modalSlideIn 0.4s cubic-bezier(0.34,1.56,0.64,1) both;
}
.standalone-card-header {
    background: linear-gradient(135deg, var(--accent-600), var(--accent-700));
    padding: 26px 30px 20px; text-align: center;
    position: relative; overflow: hidden;
}
.standalone-card-header::before {
    content: '';
    position: absolute;
    top: -40%; right: -20%;
    width: 200px; height: 200px;
    background: rgba(255,255,255,0.08);
    border-radius: 50%;
    pointer-events: none;
}
.standalone-card-header img { max-width: 72px; margin: 0 auto 12px; display: block; border-radius: 8px; }
.standalone-card-header h2 { margin: 0; font-size: 17px; color: white; font-weight: 700; line-height: 1.4; }
.standalone-card-header p { margin: 5px 0 0; font-size: 12px; color: rgba(255,255,255,0.8); }
.standalone-card-body { padding: 26px 30px; }
.s-form-group { margin-bottom: 16px; }
.s-form-group label { display: block; font-weight: 700; margin-bottom: 6px; color: #374151; font-size: 13px; }
.s-form-group input[type="text"],
.s-form-group input[type="password"],
.s-form-group input[type="email"] {
    width: 100%; padding: 10px 13px;
    border: 1.5px solid #e2e8f0; border-radius: 9px;
    box-sizing: border-box; font-size: 14px; font-family: inherit;
    transition: all 0.2s; outline: none;
}
.s-form-group input:focus { border-color: var(--accent-600); box-shadow: 0 0 0 3px rgba(var(--accent-rgb),0.12); transform: translateY(-1px); }
.s-btn-primary {
    width: 100%; padding: 12px;
    background: linear-gradient(135deg, var(--accent-600), var(--accent-700));
    color: white; border: none; border-radius: 10px;
    font-size: 15px; font-weight: 700; cursor: pointer;
    transition: all 0.22s cubic-bezier(0.34,1.56,0.64,1); font-family: inherit; margin-top: 6px;
    box-shadow: 0 4px 16px rgba(var(--accent-rgb),0.4);
    position: relative; overflow: hidden;
}
.s-btn-primary::after {
    content: '';
    position: absolute; inset: 0;
    background: rgba(255,255,255,0.25); opacity: 0;
    transform: scale(0);
    transition: transform 0.35s ease, opacity 0.35s ease;
    border-radius: inherit;
}
.s-btn-primary:active::after { transform: scale(2.5); opacity: 1; transition: none; }
.s-btn-primary:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(var(--accent-rgb),0.5); }
.s-footer { text-align: center; margin-top: 14px; font-size: 13px; color: #6b7280; }
.s-footer a { color: var(--accent-600); text-decoration: none; font-weight: 700; }
.s-footer a:hover { text-decoration: underline; }
.s-alert-error {
    background: #fef2f2; color: #991b1b; padding: 10px 13px;
    border-radius: 9px; margin-bottom: 14px; font-size: 13px;
    border-left: 4px solid #ef4444; font-weight: 600;
    animation: slideUp 0.3s ease;
}
.s-alert-success {
    background: #ecfdf5; color: #065f46; padding: 10px 13px;
    border-radius: 9px; margin-bottom: 14px; font-size: 13px;
    border-left: 4px solid #10b981; font-weight: 600;
    animation: slideUp 0.3s ease;
}
.s-divider { border: none; border-top: 1px solid #f0f0f0; margin: 16px 0; }

/* ===== PASSWORD TOGGLE ===== */
.pw-wrap {
    position: relative;
    display: block;
    width: 100%;
}
.pw-wrap input[type="password"],
.pw-wrap input[type="text"] {
    width: 100% !important;
    padding-right: 44px !important;
    box-sizing: border-box !important;
}
.pw-eye {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 40px;
    background: none;
    border: none;
    cursor: pointer;
    color: #bbb;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
    line-height: 0;
    z-index: 2;
}
.pw-eye:hover  { color: var(--accent-600); }
.pw-eye--on    { color: var(--accent-600); }

/* ========================================================================
   ===== RESPONSIVE / มือถือ (เพิ่ม 2026-10-02) =====
   ก่อนหน้านี้ไฟล์นี้ไม่มี @media เลยสักบรรทัด — sidebar กว้างคงที่ 260px (body เป็น flex row
   ระหว่าง .sidebar กับ .main-content) ผลักเนื้อหาจนเหลือพื้นที่ไม่พอบนจอมือถือ เบราว์เซอร์เลยบีบย่อ
   ทั้งหน้าแทน ต้องหมุนแนวนอนถึงจะอ่านออก

   แนวทาง: ไม่แตะ HTML/JS เดิมในหน้าไหนเลยสักไฟล์ (ปุ่ม ☰ ทุกหน้าเรียก
   document.body.classList.toggle("sidebar-collapsed") เหมือนเดิมทั้งหมด) แค่ตีความ class
   "sidebar-collapsed" ใหม่เฉพาะช่วงจอแคบ: จอใหญ่ class นี้แปลว่า "ซ่อน sidebar" (ของเดิม)
   แต่จอแคบ sidebar ซ่อนเป็นค่าเริ่มต้นอยู่แล้ว (ไม่ผลักเนื้อหา) การเพิ่ม class นี้เข้ามาเลยกลาย
   เป็น "เปิด sidebar ออกมาเป็นลิ้นชักลอย" แทน — ปุ่มเดิมใช้ได้ปกติไม่ต้องแก้สักหน้า
   ========================================================================= */
@media (max-width: 860px) {
    body { overflow-x: hidden; }

    /* sidebar กลายเป็นลิ้นชักลอยเต็มความสูงจอ ซ่อนนอกจอไว้เป็นค่าเริ่มต้น */
    .sidebar {
        position: fixed; top: 0; left: 0; height: 100vh; width: 260px;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
        z-index: 2000;
    }
    body.sidebar-collapsed .sidebar { transform: translateX(0); box-shadow: 4px 0 32px rgba(0,0,0,0.35); }
    /* ฉากหลังสีเข้มตอนลิ้นชักเปิดอยู่ (แตะเพื่อปิด — ดู partials/sidebar.php) */
    body.sidebar-collapsed::after {
        content: ''; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 1999;
    }

    /* เนื้อหาหลักเต็มความกว้างจอเสมอ ไม่ว่า sidebar จะเปิดหรือปิด (ลิ้นชักลอยทับ ไม่ได้ผลักเนื้อหา) */
    .main-content { width: 100%; padding: 14px 14px 22px; }

    /* แถบหัวข้อบนสุด: กันล้นจอ/ตัวอักษรใหญ่เกิน */
    .header { padding: 12px 14px; }
    .header h1 { font-size: 15px; }
    .header-top-row { flex-wrap: wrap; row-gap: 8px; }
    .header-date { font-size: 11px; padding: 5px 10px; }
    .marquee-text { font-size: 12.5px; }

    /* การ์ดสถิติ: บังคับ 2 คอลัมน์ให้พอดีจอแคบแทน auto-fit เดิมที่อาจเหลือ 1 คอลัมน์กว้างเกินไป */
    .stat-cards { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .stat-card { padding: 14px; }
    .stat-card .stat-num { font-size: 26px; }

    /* ช่องค้นหา/dropdown ในแถบ filter: เรียงเต็มความกว้างทีละช่อง อ่าน/กดง่ายกว่าบีบเรียงแถวเดียว */
    .filter-bar input[type="text"],
    .filter-bar select { flex: 1 1 100%; min-width: 0; }

    /* modal: ใช้พื้นที่เกือบเต็มจอ กันกรณีหลายหน้ากำหนด width/max-width แบบ px ตรงๆ (inline style) ล้นจอมือถือ */
    .modal-content { width: 100% !important; max-width: 96% !important; max-height: 94vh; }
    .modal-body { padding: 12px !important; }

    /* ไม่ให้ iPhone/iPad ซูมเข้าเองตอนแตะช่องกรอก (iOS ซูมเมื่อตัวอักษรในช่องเล็กกว่า 16px) */
    input:not([type="checkbox"]):not([type="radio"]), select, textarea { font-size: 16px; max-width: 100%; }

    /* ตัวหนังสือ/คำไทยยาวๆ ต้องขึ้นบรรทัดใหม่ ไม่ดันจนล้นกรอบ */
    html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
    body, .main-content, .header, .modal-content, td, th, label, p, span, div, a { overflow-wrap: anywhere; }
    img, video, iframe, canvas { max-width: 100%; height: auto; }

    /* ปุ่มขึ้นบรรทัดใหม่ได้ เลิกบังคับบรรทัดเดียวที่ทำให้ล้นกรอบ */
    .btn, button { white-space: normal; }
    .btn { padding: 7px 10px; font-size: 13px; }

    /* ตาราง: ตัวเล็กลงนิด เลื่อนซ้ายขวาได้ในกรอบตาราง (.table-responsive) ไม่ดันทั้งหน้า */
    table { font-size: 12.5px; }
    th, td { padding: 7px 6px; }

    /* ฟอร์มที่เขียน grid 2-3 คอลัมน์แบบ inline ใช้คอลัมน์เดียวบนจอแคบ */
    [style*="grid-template-columns:1fr 1fr"], [style*="grid-template-columns: 1fr 1fr"],
    [style*="repeat(2,1fr)"], [style*="repeat(2, 1fr)"],
    [style*="repeat(3,1fr)"], [style*="repeat(3, 1fr)"] { grid-template-columns: 1fr !important; }
    /* แถวที่เรียงเป็น flex แนวนอนแล้วอาจล้น ให้ขึ้นบรรทัดใหม่ */
    [style*="display:flex"], [style*="display: flex"] { flex-wrap: wrap; }

    /* หน้าลงทะเบียน (register.php) ใช้ grid class ของตัวเอง — บนจอแคบให้เป็นคอลัมน์เดียว */
    .rg-grid-2, .rg-grid-3-eq, .company-opts { grid-template-columns: 1fr !important; }
    .rg-btn { width: 100%; white-space: normal; }
}

@media (max-width: 420px) {
    .stat-cards { grid-template-columns: 1fr 1fr; gap: 8px; }
    .header h1 { font-size: 13.5px; }
}
