       :root {
            --bg-body: #f4f7f9;
            --card-bg: #ffffff;
            --text-main: #2d3748;
            --pastel-purple: #9b9eed;
            --pastel-purple-dark: #6366f1;
            --event-academic-bg: #f0f4ff;
            --event-academic-border: #4e89ff;
            --event-holiday-bg: #fff0f4;
            --event-holiday-border: #ff6b8b;
        }

        body { background-color: var(--bg-body); background-image: radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.15) 0px, transparent 50%), radial-gradient(at 100% 0%, rgba(236, 72, 153, 0.15) 0px, transparent 50%), radial-gradient(at 100% 100%, rgba(56, 189, 248, 0.15) 0px, transparent 50%); background-attachment: fixed; min-height: 100vh; font-family: 'Sarabun', sans-serif; color: var(--text-main); -webkit-font-smoothing: antialiased; padding-bottom: 3rem; margin: 0; }
        .head-banner { position: relative; background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%); padding: 4rem 2rem 6rem 2rem; text-align: center; color: white; overflow: hidden; box-shadow: 0 10px 30px rgba(99, 102, 241, 0.3); }
        .banner-bg-icon { position: absolute; color: rgba(255, 255, 255, 0.15); z-index: 1; }
        .bg-icon-1 { top: -10%; left: 10%; font-size: 8rem; transform: rotate(-20deg); } .bg-icon-2 { bottom: 10%; right: 5%; font-size: 10rem; transform: rotate(15deg); } .bg-icon-3 { top: 20%; right: 25%; font-size: 4rem; transform: rotate(30deg); } .bg-icon-4 { bottom: 20%; left: 20%; font-size: 5rem; transform: rotate(-15deg); }
        .banner-content { position: relative; z-index: 2; }
        
        .logo-container {
            display: inline-flex; justify-content: center; align-items: center;
            width: 90px; height: 90px; margin-bottom: 1rem;
            background: linear-gradient(135deg, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0.05) 100%);
            backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
            border: 2px solid rgba(255,255,255,0.5); border-radius: 28px;
            box-shadow: 0 15px 35px rgba(0,0,0,0.2), inset 0 0 20px rgba(255,255,255,0.3);
            animation: float3D 4s ease-in-out infinite;
        }
        .icon-3d { font-size: 3.2rem; color: #ffffff; text-shadow: 0 4px 10px rgba(0,0,0,0.2); }

        .banner-title { font-family: 'Sarabun', sans-serif; font-weight: 800; font-size: 2.5rem; letter-spacing: 1px; text-shadow: 2px 4px 8px rgba(0,0,0,0.3); margin-bottom: 0.5rem; }
        .banner-subtitle { font-size: 1.2rem; font-weight: 500; opacity: 0.9; background: rgba(255, 255, 255, 0.2); padding: 5px 20px; border-radius: 30px; display: inline-block; backdrop-filter: blur(5px); border: 1px solid rgba(255,255,255,0.3); }

        .calendar-wrapper { background: var(--card-bg); box-shadow: 0 15px 40px rgba(0,0,0,0.08); border-radius: 24px; padding: 2rem; border: 1px solid #fff; margin-top: -4rem; position: relative; z-index: 10; }

        /* ✨ สไตล์สำหรับ Toolbar สลับมุมมอง (ปรับขนาดให้เล็กลง มินิมอลขึ้น) ✨ */
        .controls-wrapper-modern { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1.2rem; }
        @media (min-width: 768px) { .controls-wrapper-modern { flex-direction: row; justify-content: space-between; align-items: center; } }
        
        /* กล่องพื้นหลังของแท็บสลับมุมมอง (เล็กลง) */
        .view-switcher-modern { background: #f1f5f9; border: 1px solid #e2e8f0; padding: 4px; display: flex; box-shadow: inset 0 2px 5px rgba(0,0,0,0.03); max-width: 300px; /* จำกัดความกว้างไม่ให้ยืดเต็มจอในมือถือ */ margin: 0 auto; }
        @media (min-width: 768px) { .view-switcher-modern { margin: 0; } }
        
        /* ปุ่มตัวเลือกแต่ละอัน (ลด padding และขนาดตัวอักษร) */
        .btn-switcher-modern { color: #64748b; border: none; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); font-size: 0.8rem; display: flex; align-items: center; justify-content: center; padding: 6px 14px; font-weight: 700; cursor: pointer; border-radius: 50rem; flex: 1; margin: 0; }
        .btn-switcher-modern:hover { color: #334155; }
        
        /* สถานะเมื่อปุ่มถูกเลือก (Active) */
        .btn-check:checked + .btn-switcher-modern { background-color: #ffffff; color: var(--pastel-purple-dark); box-shadow: 0 2px 8px rgba(99, 102, 241, 0.12); transform: scale(1.02); }
        
        /* ป้ายเตือนเลื่อนซ้ายขวา (ปรับให้กะทัดรัดขึ้น) */
        .swipe-hint-modern { background: #f0fdf4; color: #16a34a; padding: 6px 14px; border-radius: 30px; font-size: 0.75rem; border: 1px dashed #bbf7d0; display: inline-flex; align-items: center; box-shadow: 0 2px 10px rgba(22, 163, 74, 0.05); }

        .table-responsive-custom { border-radius: 16px; overflow-x: auto; border: 1px solid #e2e8f0; background: white; max-height: 70vh; overflow-y: auto; }
        .table-responsive-custom::-webkit-scrollbar { width: 8px; height: 8px; }
        .table-responsive-custom::-webkit-scrollbar-track { background: #f1f5f9; border-radius: 10px; }
        .table-responsive-custom::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
        .table-responsive-custom::-webkit-scrollbar-thumb:hover { background: var(--pastel-purple); }

        .table-custom { margin-bottom: 0; width: 100%; min-width: 900px; table-layout: fixed; font-size: 0.85rem; }
        .table-custom thead th { background: #f8fafc; color: #475569; text-align: center; vertical-align: middle; font-weight: 700; padding: 12px 8px; position: sticky; top: 0; z-index: 5; border: 1px solid #e2e8f0; }
        .table-custom thead tr:nth-child(2) th { top: 45px; } 
        .table-custom td { vertical-align: top; border: 1px solid #e2e8f0; padding: 10px 8px; height: 65px; overflow: hidden; }

        .month-divider { position: sticky; left: 0; top: 82px; z-index: 4; font-size: 1.05rem; font-weight: 700; padding: 12px 20px !important; border-bottom: 2px solid rgba(0,0,0,0.05) !important; color: #334155; background-color: #f1f5f9 !important; }
        
        .event-item-table { padding: 4px 8px; border-radius: 6px; font-size: 0.8rem; font-weight: 500; cursor: pointer; border-left: 3px solid; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 4px; transition: 0.2s; }
        .event-item-table:hover { transform: translateY(-1px); filter: brightness(0.95); }
        .event-item-table.academic { background: var(--event-academic-bg); border-color: var(--event-academic-border); color: #2c5db5; }
        .event-item-table.holiday { background: var(--event-holiday-bg); border-color: var(--event-holiday-border); color: #b52a4a; }
        
        .more-btn { display: inline-block; font-size: 0.72rem; font-weight: 600; color: var(--pastel-purple-dark); background: #f0f1ff; padding: 3px 10px; border-radius: 8px; cursor: pointer; transition: 0.2s; margin-top: 2px; }
        .more-btn:hover { background: #e0e2ff; transform: translateY(-1px); }

        .today-circle { display: inline-flex; justify-content: center; align-items: center; width: 26px; height: 26px; background-color: #ec4899; color: white; border-radius: 50%; font-weight: 700; box-shadow: 0 0 10px rgba(236, 72, 153, 0.4); }
        .highlight-today { background-color: #fef2f2 !important; }

        .app-calendar-card { border: 1px solid #e2e8f0; border-radius: 20px; padding: 1.5rem; background: #fff; box-shadow: 0 4px 20px rgba(0,0,0,0.03); max-width: 550px; margin: 0 auto; }
        .app-cal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
        .app-cal-title { font-weight: 800; font-size: 1.3rem; color: #1e293b; margin: 0; }
        .app-cal-btn { background: #f1f5f9; border: none; width: 40px; height: 40px; border-radius: 50%; color: #64748b; cursor: pointer; transition: 0.2s; display: flex; justify-content: center; align-items: center; }
        .app-cal-btn:hover { background: #e2e8f0; color: #0f172a; }

        .app-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; text-align: center; }
        .app-cal-weekday { font-weight: 700; font-size: 0.85rem; color: #94a3b8; padding-bottom: 10px; }
        .app-cal-day { aspect-ratio: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; font-size: 1rem; font-weight: 600; color: #334155; border-radius: 50%; cursor: pointer; position: relative; transition: 0.2s; }
        .app-cal-day:hover { background: #f8fafc; }
        .app-cal-day.empty { visibility: hidden; }
        .app-cal-day.today { color: #ec4899; font-weight: 800; }
        .app-cal-day.selected { background: var(--pastel-purple-dark) !important; color: white !important; font-weight: 700; box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4); }
        .app-cal-dots { display: flex; gap: 4px; position: absolute; bottom: 6px; }
        .dot { width: 5px; height: 5px; border-radius: 50%; }
        .dot-academic { background-color: var(--event-academic-border); }
        .dot-holiday { background-color: var(--event-holiday-border); }
        .app-cal-day.selected .dot { background-color: rgba(255,255,255,0.9); }

        .selected-date-title { font-weight: 700; font-size: 1.1rem; color: #1e293b; margin-top: 2rem; margin-bottom: 1rem; padding-left: 10px; border-left: 4px solid var(--pastel-purple-dark); }
        
        /* ✨ เพิ่ม Scroll ให้กล่องกิจกรรม (กันหน้ายาวเกินไป) ✨ */
        .selected-events-wrapper {
            max-height: 260px; /* โชว์แค่ประมาณ 3 รายการ ถ้าเกินก็เลื่อนเอา */
            overflow-y: auto;
            padding-right: 5px;
        }
        .selected-events-wrapper::-webkit-scrollbar { width: 5px; }
        .selected-events-wrapper::-webkit-scrollbar-track { background: #f1f5f9; border-radius: 10px; }
        .selected-events-wrapper::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
        .selected-events-wrapper::-webkit-scrollbar-thumb:hover { background: var(--pastel-purple-dark); }

        .event-card { display: flex; flex-direction: column; padding: 14px 18px; border-radius: 16px; margin-bottom: 12px; border-left: 4px solid; background: #fff; box-shadow: 0 4px 15px rgba(0,0,0,0.03); cursor: pointer; transition: 0.2s; border: 1px solid #f1f5f9; border-left-width: 4px; }
        .event-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,0.06); }
        .event-card.academic { border-left-color: var(--event-academic-border); }
        .event-card.holiday { border-left-color: var(--event-holiday-border); }
        .event-card-time { font-size: 0.85rem; font-weight: 700; margin-bottom: 6px; }
        .event-card-title { font-weight: 700; font-size: 1rem; color: #1e293b; }

        .mobile-filter-bar { background: #f8fafc; padding: 12px; border-radius: 16px; margin-bottom: 1.5rem; display: flex; gap: 10px; border: 1px solid #e2e8f0; }
        .mobile-select { border: 2px solid #cbd5e1; border-radius: 12px; padding: 10px 14px; font-weight: 600; color: #334155; }
        .mobile-week-card { background: white; border-radius: 16px; padding: 16px; margin-bottom: 1.2rem; border: 1px solid #e2e8f0; box-shadow: 0 4px 15px rgba(0,0,0,0.02); }

        .d-none-custom { display: none !important; }
        .swal2-popup-cute { border-radius: 20px !important; font-family: 'Sarabun', sans-serif !important; padding: 2rem !important; }

        /* ✨ เพิ่ม Scrollbar ให้เฉพาะช่องในตารางที่มีกิจกรรมเยอะ ✨ */
        .table-events-wrapper {
            max-height: 120px; /* กำหนดความสูงสูงสุด (แสดงได้ประมาณ 4 บรรทัด) ถ้าเกินจะเกิดสกอร์บาร์ */
            overflow-y: auto;
            padding-right: 3px;
        }
        .table-events-wrapper::-webkit-scrollbar { width: 4px; }
        .table-events-wrapper::-webkit-scrollbar-track { background: transparent; }
        .table-events-wrapper::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
        .table-events-wrapper::-webkit-scrollbar-thumb:hover { background: var(--pastel-purple-dark); }

        @media (max-width: 767.98px) { 
            .calendar-wrapper { padding: 1.5rem; border-radius: 20px; margin-top: -3rem; }
            .head-banner { padding: 3rem 1.5rem 5rem 1.5rem; }
            .banner-title { font-size: 2rem; }
        }

        /* ✨ สไตล์สำหรับ List View แบบ Google Calendar ✨ */
        .gcal-list-container { background: #fff; border-radius: 16px; border: 1px solid #e2e8f0; padding: 10px 0; overflow: hidden; box-shadow: 0 4px 15px rgba(0,0,0,0.02); }
        .gcal-day-row { display: flex; border-bottom: 1px solid #f1f5f9; padding: 15px 20px; transition: 0.2s; align-items: flex-start; }
        .gcal-day-row:last-child { border-bottom: none; }
        .gcal-day-row:hover { background-color: #f8fafc; }
        
        .gcal-date-col { width: 70px; flex-shrink: 0; display: flex; flex-direction: column; align-items: center; margin-top: -4px; }
        .gcal-date-num { font-size: 1.4rem; font-weight: 500; color: #1e293b; width: 38px; height: 38px; display: flex; justify-content: center; align-items: center; border-radius: 50%; margin-bottom: 2px; }
        .gcal-date-num.today { background-color: #1a73e8; color: white; font-weight: 600; box-shadow: 0 4px 10px rgba(26, 115, 232, 0.3); }
        .gcal-date-text { font-size: 0.75rem; color: #64748b; font-weight: 600; }
        
        /* 🌟 ใส่ min-width: 0; ป้องกัน Flexbox ดันคอนเทนต์จนล้นจอ */
        .gcal-events-col { flex-grow: 1; padding-left: 15px; border-left: 2px solid transparent; min-width: 0; }
        
        .gcal-event-item { display: flex; align-items: flex-start; margin-bottom: 8px; cursor: pointer; padding: 6px 10px; border-radius: 8px; transition: 0.2s; }
        .gcal-event-item:last-child { margin-bottom: 0; }
        .gcal-event-item:hover { background-color: #f1f5f9; transform: translateX(4px); }
        
        .gcal-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; margin-right: 12px; flex-shrink: 0; }
        .gcal-dot.aca { background-color: var(--event-academic-border); }
        .gcal-dot.hol { background-color: var(--event-holiday-border); }
        
        /* 🌟 บังคับตัดคำขึ้นบรรทัดใหม่ */
        .gcal-event-title { font-size: 0.95rem; color: #3c4043; font-weight: 500; line-height: 1.9; /* line-height: 1.4;*/ word-wrap: break-word; overflow-wrap: break-word; }
        .gcal-event-detail { font-size: 0.8rem; color: #70757a; margin-top: 2px; word-wrap: break-word; overflow-wrap: break-word; }

        /* 📱 รองรับมือถือ (Max-width 768px) */
        @media (max-width: 768px) {
            .gcal-day-row { padding: 12px 10px; } /* ลดขอบซ้ายขวาลงให้มีพื้นที่ข้อความมากขึ้น */
            .gcal-date-col { width: 55px; } /* ลดขนาดช่องวันที่ */
            .gcal-date-num { width: 32px; height: 32px; font-size: 1.2rem; }
            .gcal-events-col { padding-left: 10px; }
            
            /* 🌟 บังคับให้ข้อความขึ้นบรรทัดใหม่ (ทับคลาส text-truncate เดิม) */
            .gcal-event-title, .gcal-event-detail, .text-truncate {
                white-space: normal !important; 
                max-width: 100% !important;
            }
            
            .gcal-event-item { padding: 4px 6px; }
            .gcal-dot { margin-right: 8px; }
        }

        /* ✨ สไตล์ปุ่ม Excel ให้เข้าคู่กับปุ่มสลับมุมมอง ✨ */
        .btn-action-excel {
            background-color: #ffffff;
            color: #16a34a; /* โทนสีเขียว Excel */
            border: none;
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            font-size: 0.8rem;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 6px 14px;
            font-weight: 700;
            cursor: pointer;
            border-radius: 50rem;
            box-shadow: 0 2px 8px rgba(22, 163, 74, 0.12);
            white-space: nowrap; /* 🌟 ล็อคให้ไอคอนอยู่ซ้าย ตัวหนังสืออยู่ขวาเสมอ ห้ามตกบรรทัด */
        }
        .btn-action-excel:hover {
            background-color: #f0fdf4;
            color: #15803d;
            box-shadow: 0 4px 12px rgba(22, 163, 74, 0.2);
            transform: scale(1.02);
        }

        /* พิมพ์แบบ A4 */
        /* ✨ สไตล์ปุ่ม พิมพ์ A4 ✨ */
        .btn-action-print {
            background-color: #ffffff; color: #4f46e5; border: none; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            font-size: 0.8rem; display: flex; align-items: center; justify-content: center; padding: 6px 14px;
            font-weight: 700; cursor: pointer; border-radius: 50rem; box-shadow: 0 2px 8px rgba(79, 70, 229, 0.12);
            white-space: nowrap;
        }
        .btn-action-print:hover { background-color: #eef2ff; color: #3730a3; transform: scale(1.02); box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2); }

        /* ✨ UI กระดาษ A4 Fullscreen ✨ */
        #printOverlay {
            position: absolute; top: 0; left: 0; width: 100%; min-height: 100vh;
            background: rgba(15, 23, 42, 0.95); backdrop-filter: blur(10px);
            z-index: 99999; padding-top: 80px; overflow-x: hidden;
        }
        #printPagesContainer {
            display: flex; flex-direction: column; align-items: center; gap: 30px; padding-bottom: 50px;
        }
        .a4-paper {
            background: white; width: 297mm; height: 210mm; max-height: 210mm;
            padding: 10mm 12mm; box-shadow: 0 20px 50px rgba(0,0,0,0.5);
            display: flex; flex-direction: column; overflow: hidden;
        }
        
        /* 🌟 แต่งสวยตารางและสีสันแบบพรีเมียม */
        .print-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
        .print-table th, .print-table td { border: 1px solid #e2e8f0; vertical-align: top; }
        .print-table th { padding: 4px; text-align: center; font-weight: bold; }
        .print-month-title { font-weight: bold; text-align: left; padding: 6px 12px !important; }

        /* 🌟 บังคับ Padding ของหัวตารางให้กว้างขึ้นตามต้องการ */
        .print-table th { 
            padding: 6px 4px !important;  /* ✨ ปรับ padding ตรงนี้ได้เลย */
            text-align: center; 
            font-weight: bold; 
            vertical-align: middle;
        }
        
        /* 🌟 แต่งสวยการ์ดกิจกรรม (Mini Card) */
        .print-event-card { 
            background: #ffffff; 
            border: 1px solid #f1f5f9;
            border-left: 4px solid #cbd5e1; 
            padding: 2px 6px;  /* ลด padding บน-ล่าง ให้บางลง */
            border-radius: 4px; 
            margin-bottom: 2px; /* ลดระยะห่างระหว่างการ์ด */
            box-shadow: 0 1px 2px rgba(0,0,0,0.02);
            line-height: 1.2;
            break-inside: avoid; 
        }

        /* ✨ ควบคุมตอนสั่งพิมพ์จริง ✨ */
        @media print {
            /* 🌟 บังคับเบราว์เซอร์ให้พิมพ์สีพื้นหลังและการ์ดออกมาด้วย! 🌟 */
            * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
            
            body { background: white; margin: 0; padding: 0; }
            .head-banner, .container-fluid, .swal2-container, .no-print { display: none !important; }
            
            #printOverlay { position: static !important; background: transparent !important; padding: 0 !important; height: auto !important; min-height: auto !important; }
            #printPagesContainer { gap: 0 !important; padding: 0 !important; transform: none !important; }
            
            .a4-paper { 
                width: 297mm !important; height: 205mm !important; max-height: 210mm !important; 
                margin: 0 !important; padding: 6mm 8mm !important; box-shadow: none !important; 
                page-break-after: always !important; page-break-inside: avoid !important;
            }
            .a4-paper:last-child { page-break-after: auto !important; }
            @page { size: A4 landscape; margin: 0; } 
        }