/* ================================================================
   🎨  PP5 Design System — Classic Dark Nav Layout
   ================================================================ */

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; }
body {
    font-family: 'K2D', sans-serif;
    background: #f0f4f8;
    margin: 0; padding: 0;
    color: #1e293b;
    -webkit-font-smoothing: antialiased;
}

/* ================================================================
   🔐  LOGIN PAGE
   ================================================================ */
#loginOverlay {
    position: fixed; inset: 0;
    background: linear-gradient(135deg, #0f1f3d 0%, #1e3a6e 50%, #1e40af 100%);
    z-index: 9999;
    display: flex; justify-content: center; align-items: center;
    padding: 20px;
}
.login-box {
    background: #fff;
    padding: 32px 36px 36px;
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.45);
    width: 100%; max-width: 380px;
    text-align: center;
    animation: loginFadeIn 0.3s ease;
}
@keyframes loginFadeIn {
    from { opacity:0; transform:translateY(10px); }
    to   { opacity:1; transform:translateY(0); }
}
.login-box h2 { margin: 0 0 6px; color: #0f1f3d; font-size: 20px; font-weight: 700; }
.login-box p  { color: #64748b; font-size: 13px; margin: 0 0 18px; }
.login-box input {
    width: 100%; margin-bottom: 10px;
    padding: 10px 13px;
    border: 1.5px solid #e2e8f0; border-radius: 8px;
    box-sizing: border-box; font-size: 14px;
    font-family: 'K2D', sans-serif; color: #1e293b;
    outline: none; transition: border-color 0.2s;
    background: #f8fafc;
}
.login-box input:focus {
    border-color: #1d4ed8;
    box-shadow: 0 0 0 3px rgba(29,78,216,0.1);
    background: #fff;
}
.login-box .btn-green {
    background: #1d4ed8 !important;
    width: 100%;
}
.login-box .btn-green:hover { background: #1e40af !important; }
.login-divider {
    display: flex; align-items: center; gap: 10px;
    margin: 12px 0 10px; color: #94a3b8; font-size: 12px;
}
.login-divider::before, .login-divider::after {
    content:''; flex:1; height:1px; background:#e2e8f0;
}
.btn-google {
    display: flex; align-items: center; justify-content: center; gap: 9px;
    width: 100%; padding: 10px 16px;
    background: #fff; border: 1.5px solid #e2e8f0; border-radius: 8px;
    font-size: 13px; font-weight: 600; color: #374151;
    cursor: pointer; font-family: 'K2D', sans-serif;
    transition: background 0.2s;
}
.btn-google:hover { background: #f8fafc; }
.btn-google svg { width:18px; height:18px; flex-shrink:0; }

/* ================================================================
   🧭  TOP BAR — full-width, dark navy, above sidebar+content
   ================================================================ */
#topBar {
    display: none;   /* JS shows after login */
    background: #1d2a35;   /* Cloudflare-style dark slate */
    color: #fff;
    border-bottom: 3px solid #f6821f;   /* แถบ accent ส้ม */
    height: 48px;
    min-height: 48px;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px 0 14px;
    position: sticky;
    top: 0;
    z-index: 200;
    flex-shrink: 0;
    gap: 8px;
}
#topBarLeft {
    display: flex; align-items: center; gap: 10px;
    min-width: 0; overflow: hidden;
}
#topBarRight {
    display: flex; align-items: center; gap: 6px;
    flex-shrink: 0;
}
#sysLogoTitle {
    font-size: 14px; font-weight: 700; color: #fff;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    letter-spacing: 0.01em;
}
/* User label in topbar */
#lblCurrentUser {
    font-size: 12px; color: rgba(255,255,255,0.88); font-weight: 500;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 240px;
}
/* hide new-design elements not in classic layout */
.topbar-school-info, .user-avatar-wrap, #topBarSub,
.topbar-user-desktop, .sidebar-header, .sidebar-nav,
.nav-group-label, #sidebarSchoolName, #sidebarSchoolYear,
#topBarSchoolName, #topBarSchoolYear { display: none !important; }
#userAvatarIcon { display: none !important; }
.btn-label-icon { display: none; }

/* Online indicator (inline in topbar) */
.online-indicator {
    display: flex; align-items: center; gap: 4px;
    font-size: 12px; color: #4ade80; font-weight: 600;
    white-space: nowrap;
}
.online-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: #4ade80;
    animation: pulse-online 2s infinite;
}
@keyframes pulse-online {
    0%,100% { opacity: 1; }
    50%      { opacity: 0.5; }
}

/* Tier badge */
#tierBadge {
    font-size: 11px; background: #1d4ed8; color: #fff;
    padding: 2px 8px; border-radius: 12px; font-weight: 700;
    cursor: pointer; white-space: nowrap; border: 1px solid #3b82f6;
}
#btnSubStatus {
    font-size: 11px; background: #166534; color: #fff;
    border: none; padding: 3px 8px; border-radius: 6px;
    cursor: pointer; font-weight: 600; font-family: inherit; white-space: nowrap;
}
#btnUpgrade {
    font-size: 11px; background: #f59e0b; color: #fff;
    border: none; padding: 3px 8px; border-radius: 6px;
    cursor: pointer; font-weight: 700; font-family: inherit; white-space: nowrap;
}
.btn-logout {
    background: #dc2626; color: #fff; border: none;
    border-radius: 6px; padding: 5px 10px; cursor: pointer;
    font-family: inherit; font-size: 13px; font-weight: 600;
    white-space: nowrap; transition: background 0.2s;
}
.btn-logout:hover { background: #b91c1c; }

/* ================================================================
   📐  MAIN LAYOUT — flex column: topBar → mainWrapper
   ================================================================ */
#mainContainer {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
#mainWrapper {
    display: flex;
    flex: 1;
    align-items: stretch;
}
#contentArea {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: #f6f7f9;   /* เทาอ่อนเป็นกลางแบบ Cloudflare */
}

/* ================================================================
   🗂️  SIDEBAR — dark navy, fixed left column
   ================================================================ */
.tabs {
    width: 178px;
    min-width: 178px;
    flex-shrink: 0;
    background: #1f2c37;   /* Cloudflare-style slate sidebar */
    display: flex !important;
    flex-direction: column !important;
    position: sticky;
    top: 48px;
    height: calc(100vh - 48px);
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 50;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.15) transparent;
}
.tabs::-webkit-scrollbar { width: 4px; }
.tabs::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }

/* Nav item */
.tab {
    display: flex !important;
    align-items: center;
    gap: 7px;
    width: 100% !important;
    padding: 10px 12px !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    color: rgba(255,255,255,0.72) !important;
    background: transparent !important;
    border: none !important;
    border-left: 3px solid transparent !important;
    border-radius: 0 !important;
    cursor: pointer !important;
    text-align: left !important;
    line-height: 1.35 !important;
    transition: background 0.15s, color 0.15s !important;
    box-shadow: none !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    text-decoration: none;
    font-family: 'K2D', sans-serif;
}
.tab.tab-hidden { display: none !important; }
.tab:hover:not(.active) {
    background: rgba(255,255,255,0.08) !important;
    color: rgba(255,255,255,0.95) !important;
}
.tab.active {
    background: rgba(246,130,31,0.16) !important;   /* ส้มจางแบบ Cloudflare */
    color: #fff !important;
    font-weight: 700 !important;
    border-left-color: #f6821f !important;            /* แถบ accent ส้ม */
}

/* icon in nav item */
.nav-icon { font-size: 14px; flex-shrink: 0; }

/* ================================================================
   📐  CONTAINER & PAGE CARD
   ================================================================ */
.container {
    padding: 20px 24px !important;
    max-width: none !important;
    margin: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
    min-width: 0;
}

.page-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.07), 0 4px 12px rgba(0,0,0,0.04);
    padding: 22px 24px;
    margin-bottom: 16px;
}

h1 { color: #0f1f3d; text-align: left; margin: 0 0 18px; font-size: 20px; font-weight: 700; }

/* ================================================================
   📱  HAMBURGER & MOBILE RESPONSIVE
   ================================================================ */
#hamburgerBtn {
    display: none;
    align-items: center; justify-content: center;
    width: 32px; height: 32px;
    background: rgba(255,255,255,0.18); border: 1px solid rgba(255,255,255,0.35);
    border-radius: 6px; cursor: pointer;
    color: #fff; font-size: 15px; flex-shrink: 0;
}
#hamburgerBtn svg { stroke: #fff !important; width: 20px; height: 20px; display: block; }
#hamburgerBtn i { color: #fff; }

#sidebarOverlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 250;
}
#sidebarOverlay.active { display: block; }

@media (max-width: 900px) {
    #mainContainer { flex-direction: column; }

    /* TopBar: fixed full-width */
    #topBar {
        position: fixed !important;
        top: 0; left: 0; right: 0;
        z-index: 300 !important;
    }
    #sysLogoTitle { font-size: 12px !important; }
    #lblCurrentUser { display: none !important; }
    .online-indicator { display: none !important; }
    #btnSubStatus { font-size: 10px !important; padding: 2px 6px !important; }
    #btnUpgrade   { font-size: 10px !important; padding: 2px 6px !important; }
    #tierBadge    { font-size: 10px !important; padding: 2px 6px !important; }

    /* MainWrapper: padding-top for fixed topbar */
    #mainWrapper { padding-top: var(--topbar-h, 48px); }

    /* Sidebar: fixed, slides in */
    .tabs {
        position: fixed !important;
        top: 0 !important; left: -190px !important;
        width: 190px !important; min-width: unset !important;
        height: 100vh !important;
        z-index: 300 !important;
        transition: left 0.25s ease !important;
        padding-top: var(--topbar-h, 48px) !important;
    }
    .tabs.sidebar-open { left: 0 !important; box-shadow: 4px 0 20px rgba(0,0,0,0.4) !important; }

    .container { padding: 12px !important; }
    #hamburgerBtn { display: flex !important; }

    .fast-att-wrapper    { padding: 4px 12px 12px !important; margin-top: 0 !important; }
    .fast-att-title-block { margin-top: 0 !important; margin-bottom: 10px !important; padding-left: 2px !important; }
}

/* ================================================================
   🔄  LEGACY: tab-content visibility
   ================================================================ */
#logoutBtn, button.btn-red[onclick*="logout"] {
    background: #dc2626; padding: 7px 14px; font-size: 13px; border-radius: 8px;
}

        .tab-content { display: none; }
        .tab-content.active { display: block; width: 100%; min-width: 0; }
        #page8, #page9, #page10 { width: 100%; }

        /* 🎯 ตัวเลือกปี/ภาคเรียน — สไตล์มาตรฐานเดียวกับ tab2 (unity ทั้งระบบ) */
        .controls { display: flex; flex-wrap: wrap; justify-content: flex-start; gap: 10px; margin-bottom: 16px; align-items: flex-end; background: #f8fafc; padding: 14px; border-radius: 10px; border: 1px solid #e2e8f0; }
        .controls label { font-size: 13px; font-weight: 600; color: #475569; display: block; margin-bottom: 4px; }
        .controls select, .controls input { padding: 7px 10px; border: 1px solid #cbd5e1; border-radius: 7px; font-family: 'K2D', sans-serif; font-size: 14px; background: #fff; color: #1e293b; }
        select, input { padding: 8px 12px; font-size: 15px; border-radius: 6px; border: 1px solid #85b7eb; outline: none; font-family: 'K2D', sans-serif; color: #0c447c; font-weight: 500;}
        
        /* =====================================================
           🎨 Button Design System — Unified & Modern
           ===================================================== */
        button {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 5px;
            background: #0c447c;
            color: white;
            border: none;
            padding: 8px 16px;
            font-size: 13px;
            font-weight: 600;
            border-radius: 8px;
            cursor: pointer;
            font-family: 'K2D', sans-serif;
            transition: background 0.18s, transform 0.1s, box-shadow 0.18s;
            line-height: 1.4;
            white-space: nowrap;
            letter-spacing: 0.01em;
        }
        button:hover  { background: #082d54; box-shadow: 0 2px 8px rgba(0,0,0,0.15); }
        button:active { transform: translateY(1px); box-shadow: none; }

        /* Variants — ขนาดเดียวกัน ต่างแค่สี */
        button.btn-green  { background: #16a34a; }
        button.btn-green:hover  { background: #15803d; }

        button.btn-amber  { background: #d97706; }
        button.btn-amber:hover  { background: #b45309; }

        button.btn-red    { background: #dc2626; }
        button.btn-red:hover    { background: #b91c1c; }

        button.btn-gray   { background: #64748b; }
        button.btn-gray:hover   { background: #475569; }

        /* หัวข้อหน้ามาตรฐาน (ชื่อแท็บ + เส้นใต้) — ใช้ทุกแท็บเพื่อความเป็นอันหนึ่งอันเดียว */
        .pp5-page-title {
            font-size: 22px;
            font-weight: 700;
            color: #1d2a35;
            margin: 0 0 18px 0;
            padding-bottom: 10px;
            border-bottom: 3px solid #f6821f;   /* เส้นใต้ accent ส้มแบบ Cloudflare */
            font-family: 'K2D', sans-serif;
            line-height: 1.4;
        }
        @media (max-width: 600px) { .pp5-page-title { font-size: 18px; } }

        /* ปุ่มแก้ไข/ลบในตาราง — ดีไซน์มาตรฐานเดียวกันทั้งระบบ (อ้างอิงแท็บ 2) */
        .btn-cell-edit { background:#eff6ff; border:1px solid #bfdbfe; color:#2563eb; border-radius:5px; padding:4px 10px; font-size:12px; cursor:pointer; font-family:'K2D',sans-serif; line-height:1.6; }
        .btn-cell-edit:hover { background:#dbeafe; }
        .btn-cell-del  { background:#fef2f2; border:1px solid #fecaca; color:#dc2626; border-radius:5px; padding:4px 10px; font-size:12px; cursor:pointer; font-family:'K2D',sans-serif; line-height:1.6; }
        .btn-cell-del:hover  { background:#fee2e2; }

        button.btn-blue   { background: #2563eb; }
        button.btn-blue:hover   { background: #1d4ed8; }

        button.btn-teal   { background: #0891b2; }
        button.btn-teal:hover   { background: #0e7490; }

        /* Size modifiers */
        button.btn-sm { padding: 5px 11px; font-size: 12px; border-radius: 6px; }
        button.btn-lg { padding: 11px 26px; font-size: 15px; border-radius: 10px; }
        button.btn-xl { padding: 13px 36px; font-size: 16px; border-radius: 12px; font-weight: 700; }

        /* Outline variant */
        button.btn-outline {
            background: transparent;
            border: 1.5px solid currentColor;
            color: #0c447c;
        }
        button.btn-outline:hover { background: #eef5fa; box-shadow: none; }

        /* ── ป้องกัน inline style จากโค้ด JS override ระบบปุ่ม ──
           ทุก variant ต้องมี padding / font-size เดียวกับ base */
        button.btn-green,
        button.btn-amber,
        button.btn-red,
        button.btn-gray,
        button.btn-blue,
        button.btn-teal {
            padding: 8px 16px !important;
            font-size: 13px !important;
            font-family: 'K2D', sans-serif !important;
            font-weight: 600 !important;
            border-radius: 8px !important;
            border: none !important;
            line-height: 1.4 !important;
        }
        /* sm/lg/xl override padding แต่ยัง inherit สี */
        button.btn-sm { padding: 5px 11px !important; font-size: 12px !important; border-radius: 6px !important; }
        button.btn-lg { padding: 11px 26px !important; font-size: 15px !important; border-radius: 10px !important; }
        button.btn-xl { padding: 13px 36px !important; font-size: 16px !important; border-radius: 12px !important; font-weight: 700 !important; }

        /* ปุ่มปิด banner (X) */
        .btn-close-banner {
            background: transparent !important;
            color: #713f12 !important;
            font-size: 16px !important;
            padding: 0 6px !important;
            border: none !important;
            box-shadow: none !important;
            font-weight: 700;
        }
        .btn-close-banner:hover { background: rgba(0,0,0,0.08) !important; box-shadow: none !important; }

        /* ชื่อชุมนุม — คลิกได้ ดูรายชื่อสมาชิก */
        .club-name-chip {
            display: inline-flex;
            align-items: center;
            gap: 5px;
            font-weight: 600;
            color: #92400e;
            background: #fffbeb;
            border: 1px solid #fde68a;
            border-radius: 20px;
            padding: 3px 10px;
            font-size: 13px;
            cursor: pointer;
            transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
            text-decoration: none;
        }
        .club-name-chip:hover {
            background: #fef3c7;
            border-color: #f59e0b;
            box-shadow: 0 1px 4px rgba(245,158,11,0.25);
        }


        table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 14.5px; }
        th, td { border: 1px solid #ddd; padding: 10px 12px; text-align: left; }
        th { background-color: #f0f6fc; color: #0c447c; text-align: center; font-weight: 600;}
        td.center { text-align: center; }
        tr:nth-child(even) { background-color: #fcfcfc; }
        tr:hover { background-color: #f1f8eb; }
        .summary-row { background-color: #eef5fa !important; font-weight: bold; color: #0c447c; }

        /* Modal Styles */
        .modal-backdrop { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 1000; justify-content: center; align-items: center; }
        .modal-backdrop.active { display: flex; }
        /* กล่องแจ้งเตือน/ยืนยัน (showAlert/showConfirm) ต้องอยู่บนสุดเสมอ เหนือ modal อื่น ๆ */
        #notiModal { z-index: 100000 !important; }
        /* ครูที่ปรึกษา/ครูประจำชั้น (Tab 4) ให้ฟอนต์เท่ากับ dropdown หัวหน้ากลุ่มสาระ */
        .hr-teacher-select { width: 100%; box-sizing: border-box; padding: 7px 10px; border: 1px solid #cbd5e1; border-radius: 7px; font-family: 'K2D', sans-serif; font-size: 13px; }
        .modal-box { background: #fff; padding: 25px; border-radius: 10px; width: 90%; max-width: 500px; box-shadow: 0 5px 20px rgba(0,0,0,0.2); }
        .modal-title { font-size: 18px; color: #0c447c; font-weight: 600; margin-bottom: 15px; border-bottom: 1px solid #eee; padding-bottom: 10px; }
        .form-group { margin-bottom: 12px; }
        .form-group label { display: block; font-size: 14px; font-weight: 500; color: #555; margin-bottom: 5px; }
        .form-group input, .form-group select { width: 100%; box-sizing: border-box; }
        .modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
        /* Layout สำหรับส่วนจัดการ ปพ.5 */
.management-container { display: flex; gap: 20px; margin-top: 12px; min-height: 400px; }
.side-menu { width: 240px; min-width: 200px; background: #f0f6fc; border-radius: 10px; border: 1px solid #bae6fd; padding: 14px; align-self: flex-start; box-shadow: 0 1px 4px rgba(12,68,124,0.07); }
@media (min-width: 901px) {
    .side-menu { position: sticky; top: calc(var(--topbar-h, 52px) + 16px); }
}
.side-menu h4 { margin: 0 0 12px 0; color: #0c447c; font-size: 13px; font-weight: 700; border-bottom: 2px solid #bae6fd; padding-bottom: 10px; letter-spacing: 0.02em; }
.menu-item { padding: 10px 14px; margin-bottom: 6px; background: #fff; border-radius: 8px; cursor: pointer; transition: background 0.15s, color 0.15s, box-shadow 0.15s; border: 1px solid #e2e8f0; font-weight: 500; font-size: 13px; color: #374151; }
.menu-item:hover { background: #eff6ff; color: #0c447c; border-color: #bae6fd; box-shadow: 0 1px 4px rgba(12,68,124,0.08); }
.menu-item.active { background: linear-gradient(135deg,#0c447c,#1e40af); color: white; border-color: #0c447c; box-shadow: 0 2px 6px rgba(12,68,124,0.25); font-weight: 600; }
.main-content-area { flex: 1; min-width: 0; background: #fff; padding: 20px; border-radius: 10px; border: 1px solid #e2e8f0; box-shadow: 0 1px 4px rgba(0,0,0,0.04); }

/* ── ส่วนหัวของแต่ละเมนูย่อยใน Tab 6 ── */
.pp5-sect-hd {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    background: #f0f9ff;
    border-bottom: 2px solid #bae6fd;
    border-radius: 8px 8px 0 0;
    padding: 12px 16px;
    margin: -20px -20px 20px -20px;
}
.pp5-sect-hd h3 {
    margin: 0;
    font-size: 15px;
    color: #0c447c;
    font-weight: 700;
}

/* ── Toolbar สำหรับกรอกด่วน ── */
.quick-fill-bar {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 14px;
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}
.status-badge { padding: 4px 8px; border-radius: 4px; font-size: 12px; font-weight: bold; }
.status-process { background: #dbeafe; color: #1e40af; } /* กำลังดำเนินการ */
.status-waiting { background: #ffedd5; color: #c2410c; } /* รอตรวจสอบ */
.status-approved { background: #dcfce7; color: #166534; } /* อนุมัติแล้ว */
/* ========================================= */
/* 📅 Tab 6 — บันทึกเวลาเรียน               */
/* ========================================= */

/* กล่องตั้งค่าวันสอน */
.att-setup-box {
    background: #fff8eb;
    padding: 12px 15px;
    border-radius: 8px;
    border: 1px solid #fcd34d;
    margin-bottom: 15px;
    font-size: 14px;
}
/* แถว checkbox วันสอน */
.att-days-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-top: 8px;
}
/* แถวปุ่มบันทึกการตั้งค่า */
.att-save-row {
    margin-top: 10px;
}
/* desktop: ปุ่มชิดขวา */
@media (min-width: 901px) {
    .att-save-row { text-align: right; }
}
/* mobile: ปุ่มเต็มความกว้าง */
@media (max-width: 900px) {
    .att-save-row button { width: 100%; }
}

/* กล่องเลือกวันที่ + คาบคู่ + กำหนดทั้งหมด */
.att-date-box {
    display: flex;
    gap: 15px;
    align-items: flex-start;
    background: #eef5fa;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #d0e3f0;
    margin-bottom: 15px;
    flex-wrap: wrap;
}
.att-date-item {
    display: flex;
    flex-direction: column;
}
/* คาบคู่ checkbox label */
.att-double-label {
    font-weight: bold;
    color: #a32d2d;
    cursor: pointer;
    background: #fff0f0;
    padding: 7px 12px;
    border-radius: 6px;
    border: 1px solid #fca5a5;
    margin-top: 22px;   /* align กับ input date ด้านซ้าย */
    white-space: nowrap;
}

/* mobile: เรียงลงมาแนวตั้ง ทุก item เต็มความกว้าง */
@media (max-width: 900px) {
    .att-date-box {
        flex-direction: column;
        gap: 10px;
    }
    .att-date-item { width: 100%; }
    .att-double-label { margin-top: 0; white-space: normal; }
    .att-date-box select,
    .att-date-box input[type="text"] { width: 100% !important; box-sizing: border-box; }
}

/* ========================================= */
/* 🎛️ Tab 4 — ปุ่มจัดการนักเรียน            */
/* desktop: แถวเดียว 2 กลุ่ม               */
/* mobile: grid 2×2 เท่ากันทุกปุ่ม          */
/* ========================================= */
.stu-action-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    padding: 14px 16px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    flex-wrap: wrap;
}
.stu-btn-group {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}
/* desktop: ซ่อน label สั้น แสดง label ยาว */
.lbl-short { display: none; }
.lbl-long  { display: inline; }

@media (max-width: 640px) {
    /* mobile: grid 2×2 เต็มความกว้าง */
    .stu-action-bar {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        padding: 10px 12px;
    }
    .stu-btn-group {
        display: contents; /* ให้ปุ่มไปอยู่ใน grid โดยตรง */
    }
    .stu-action-bar button {
        width: 100% !important;
        justify-content: center;
        font-size: 13px !important;
        padding: 10px 6px !important;
    }
    /* mobile: แสดง label สั้น ซ่อน label ยาว */
    .lbl-short { display: inline !important; }
    .lbl-long  { display: none !important; }
}

/* ── Scroll wrapper สำหรับ preview ปพ.5 บน mobile ──
   ให้ scroll แนวนอนได้เมื่อหน้าจอแคบกว่า paper-document (800px)
   ไม่กระทบ print mode เพราะ print mode override position/overflow ของ #printArea */
.pp5-preview-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 8px;
    padding-bottom: 4px;

    /* scroll shadow indicator (เหมือน tbl-scroll-wrap) */
    background:
        linear-gradient(to right, #f0f4f8 20%, rgba(240,244,248,0)) left center,
        linear-gradient(to left,  #f0f4f8 20%, rgba(240,244,248,0)) right center,
        radial-gradient(farthest-side at 0 50%, rgba(12,68,124,.12), transparent) left center,
        radial-gradient(farthest-side at 100% 50%, rgba(12,68,124,.12), transparent) right center;
    background-repeat: no-repeat;
    background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
    background-attachment: local, local, scroll, scroll;
}
/* custom scrollbar เหมือน tbl-scroll-wrap */
.pp5-preview-wrap::-webkit-scrollbar          { height: 5px; }
.pp5-preview-wrap::-webkit-scrollbar-track    { background: #e2e8f0; border-radius: 3px; }
.pp5-preview-wrap::-webkit-scrollbar-thumb    { background: #94a3b8; border-radius: 3px; }
.pp5-preview-wrap::-webkit-scrollbar-thumb:hover { background: #0c447c; }

/* Styles สำหรับหน้าปก ปพ.5 (A4 Paper View) */
.paper-document {
    background: white;
    padding: 40px;
    border: 1px solid #ccc;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    width: 800px;
    min-width: 800px;
    max-width: 800px;
    margin: 0 auto;
    color: #000;
    font-family: 'Sarabun', 'K2D', sans-serif; /* ใช้ฟอนต์ทางการ */
}
.paper-document h2, .paper-document h3, .paper-document h4 { margin: 5px 0; text-align: center; font-weight: normal; }
.paper-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
    margin-top: 20px;
    margin-bottom: 20px;
}
.paper-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
    text-align: center;
}
.paper-table th, .paper-table td {
    border: 1px solid #000;
    padding: 5px;
    font-size: 14px;
    text-align: center;      /* จัดกึ่งกลางแนวนอน */
    vertical-align: middle;  /* จัดกึ่งกลางแนวตั้งให้เป๊ะ! */
}
.paper-sign-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 40px;
    text-align: center;
}
.paper-sign-box { margin-bottom: 30px; }
.dotted-line {
    border-bottom: 1px dotted #000;
    display: inline-block;
    min-width: 150px;
    margin: 0 5px;
}
/* Styles สำหรับคำอธิบายรายวิชาและตัวชี้วัด */
.desc-container { display: flex; gap: 20px; align-items: flex-start; }
.desc-col { flex: 1; background: #fff; padding: 20px; border-radius: 8px; border: 1px solid #ddd; }
.standard-block { background: #f9f9f9; padding: 15px; border-radius: 6px; border: 1px dashed #ccc; margin-bottom: 15px; position: relative; }
.standard-block-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.indicator-row { display: flex; align-items: center; gap: 10px; margin-bottom: 5px; margin-left: 20px; }
.remove-btn { color: #ef4444; cursor: pointer; font-weight: bold; border: none; background: none; }
.remove-btn:hover { color: #b91c1c; }

/* 💯 Styles สำหรับตารางคะแนนเก็บ (ล็อกขนาดช่องให้กะทัดรัด) */
.score-table input.score-input { 
    width: 45px !important; 
    text-align: center; 
    padding: 4px; 
    border: 1px solid #85b7eb; 
    border-radius: 4px; 
    font-size: 13px; 
    display: inline-block; 
}
.score-table th, .score-table td { padding: 4px; vertical-align: middle; }

/* ========================================= */

/* ========================================= */
/* 📊 Styles สำหรับตารางเวลาเรียน (แบ่งหน้า/ตรึงคอลัมน์) */
/* ========================================= */
.att-history-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    background: white;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 8px rgba(12,68,124,0.07);
    /* Custom scrollbar */
    scrollbar-width: thin;
    scrollbar-color: #94a3b8 #f1f5f9;
}
.att-history-wrapper::-webkit-scrollbar { height: 8px; }
.att-history-wrapper::-webkit-scrollbar-track { background: #f1f5f9; border-radius: 0 0 10px 10px; }
.att-history-wrapper::-webkit-scrollbar-thumb { background: #94a3b8; border-radius: 4px; }
.att-history-wrapper::-webkit-scrollbar-thumb:hover { background: #64748b; }

/* sticky เลขที่ */
.sticky-col-1 {
    background: #f8fafc;
    min-width: 40px;
}
/* คอลัมน์ชื่อ (เลื่อนซ้าย-ขวาได้ปกติ ไม่ตรึง) */
.sticky-col-2 {
    background: #f8fafc;
    min-width: 200px;
    text-align: left !important;
    border-right: 1px solid #e2e8f0 !important;
}
/* tbody sticky — โดยไม่กระทบ thead */
tbody .sticky-col-1, tbody .sticky-col-2 { background: #fff; }
tbody tr:nth-child(even) .sticky-col-1,
tbody tr:nth-child(even) .sticky-col-2 { background: #f8fafc; }
tbody tr:hover .sticky-col-1,
tbody tr:hover .sticky-col-2 { background: #eff6ff !important; }

/* date column header ปุ่ม+วัน */
.att-date-th {
    width: 50px; min-width: 42px;
    border: 1px solid #e2e8f0 !important;
    padding: 3px 2px !important;
    vertical-align: bottom;
    text-align: center;
    background: #f8fafc;
}
.att-date-th .att-day-num {
    font-size: 13px; font-weight: 700; color: #475569;
    display: block; padding: 3px 0 2px;
}
.att-date-th .att-btn-wrap {
    display: flex; flex-direction: column; gap: 2px; align-items: center;
}
.att-date-th .att-btn-wrap button {
    font-size: 12px; padding: 2px 6px; margin: 0; min-width: 32px;
}

/* month group header — lighter blue */
.att-month-th {
    text-align: center;
    background: #f1f5f9 !important;
    color: #475569 !important;
    font-weight: 700;
    font-size: 12px;
    padding: 6px 4px !important;
    border: 1px solid #e2e8f0 !important;
    white-space: nowrap;
}

/* legacy vertical-date (still used in print att CSS) */
.vertical-date { writing-mode: vertical-rl; transform: rotate(180deg); padding: 6px 3px; height: 80px; margin: 0 auto; font-size: 12px; color: #0c447c; font-weight: 600; }
.col-action-btns { display: flex; flex-direction: column; gap: 4px; padding: 5px; border-bottom: 1px dashed #ccc; background: #eef5fa; }
.col-action-btns button { padding: 2px; font-size: 11px; width: 100%; }

/* ========================================= */
/* 🖨️ ระบบการพิมพ์ (แยกระหว่าง หน้าปก vs เวลาเรียน) */
/* ========================================= */
@media print {
    /* 🛠️ แก้ปัญหาหน้ากระดาษเปล่าตอนท้าย (ลบพื้นที่เมนูล่องหนทิ้งให้หมด) */
    body[class*="print-mode-"] h1,
    body[class*="print-mode-"] .tabs,
    body[class*="print-mode-"] .controls,
    body[class*="print-mode-"] .side-menu,
    body[class*="print-mode-"] .print-hide,
    body[class*="print-mode-"] #manageListArea {
        display: none !important;
    }
    body[class*="print-mode-"] .container {
        padding: 0 !important; margin: 0 !important; box-shadow: none !important; border: none !important; height: 0; overflow: visible;
    }
    body[class*="print-mode-"] .management-container {
        min-height: 0 !important; margin: 0 !important; padding: 0 !important;
    }
    body[class*="print-mode-"] .main-content-area {
        padding: 0 !important; border: none !important;
    }
    body * { visibility: hidden; }
    html, body { background: #fff; margin: 0 !important; padding: 0 !important; }

    /* 📘 โหมดที่ 1: พิมพ์หน้าปก (print-mode-cover) — mobile-compatible approach */
    /* @page margin inject ผ่าน JS ใน printCover() เพื่อ override @page { margin:0 } ของโหมดอื่น */
    /* ซ่อนทุก element ระดับ body ยกเว้น mobilePrintContainer */
    body.print-mode-cover > *:not(#mobilePrintContainer) { display: none !important; }
    body.print-mode-cover #mobilePrintContainer,
    body.print-mode-cover #mobilePrintContainer * {
        visibility: visible !important;
    }
    body.print-mode-cover #mobilePrintContainer {
        display: block !important;
        width: 100% !important; margin: 0 !important; padding: 0 !important;
        background: #fff !important;
    }
    body.print-mode-cover #mobilePrintContainer .paper-document {
        max-width: none !important; width: 100% !important;
        padding: 0 !important; margin: 0 !important;
        border: none !important; box-shadow: none !important;
        background: #fff !important;
    }
    body.print-mode-cover #mobilePrintContainer h3 { margin: 1px 0 !important; }
    body.print-mode-cover #mobilePrintContainer .paper-table { margin-bottom: 4px !important; }
    body.print-mode-cover #mobilePrintContainer .paper-table th,
    body.print-mode-cover #mobilePrintContainer .paper-table td { padding: 3px 4px !important; }
    body.print-mode-cover #mobilePrintContainer .print-hide { display: none !important; }
    /* 🔠 ขยายตัวอักษรหน้าปกตอนพิมพ์ให้เต็มหน้ากระดาษมากขึ้น (+1-2px) */
    body.print-mode-cover #mobilePrintContainer div { font-size: 15px !important; }
    body.print-mode-cover #mobilePrintContainer h3 { font-size: 16px !important; }
    body.print-mode-cover #mobilePrintContainer .paper-table th,
    body.print-mode-cover #mobilePrintContainer .paper-table td { font-size: 14px !important; }
    
    /* 📊 โหมดที่ 2: พิมพ์เวลาเรียน (print-mode-att) */
    body.print-mode-att #printAttHistoryArea, body.print-mode-att #printAttHistoryArea * { visibility: visible; }
body.print-mode-att #printAttHistoryArea { display: block !important; position: absolute; left: 0; top: 0; width: 100%; padding: 10mm; box-sizing: border-box; }    body.print-mode-att .sticky-col-1, body.print-mode-att .sticky-col-2 { position: static !important; background: transparent !important; border-right: 1px solid #000 !important; }
    body.print-mode-att .col-action-btns, body.print-mode-att .print-hide { display: none !important; }
body.print-mode-att .paper-table { 
        width: 100% !important; 
        min-width: 100% !important; /* 🌟 ยกเลิกความกว้างขั้นต่ำ 800px บังคับให้พอดีหน้ากระดาษ */
        table-layout: fixed !important; /* 🌟 บังคับให้ทุกคอลัมน์หารแบ่งพื้นที่กันอย่างพอดี */
        border-collapse: collapse !important; 
        page-break-inside: auto; 
    }    body.print-mode-att .paper-table tr { page-break-inside: avoid; page-break-after: auto; }
    body.print-mode-att .paper-table th, body.print-mode-att .paper-table td { border: 1px solid #000 !important; padding: 4px !important; font-size: 12px !important; color: #000 !important; }
    body.print-mode-att .vertical-date { height: 70px !important; padding: 2px !important; }
    body.print-mode-att .sticky-col-1 { width: 35px !important; }
    body.print-mode-att .sticky-col-2 { width: 180px !important; }

    @page { size: A4 portrait; margin: 0; }
    /* 📝 โหมดที่ 3: พิมพ์คำอธิบายรายวิชา (print-mode-desc) */
    body.print-mode-desc #printDescArea, body.print-mode-desc #printDescArea * { visibility: visible; }
    body.print-mode-desc #printDescArea { display: block !important; position: absolute; left: 0; top: 0; width: 100%; padding: 15mm; box-sizing: border-box; }
    body.print-mode-desc .print-hide { display: none !important; }
    .page-break { page-break-before: always; }
    /* 💯 โหมดที่ 4: พิมพ์คะแนนเก็บ (print-mode-score) แนวตั้ง ตัดหน้าอัตโนมัติ */
    body.print-mode-score #printScoreArea, body.print-mode-score #printScoreArea * { visibility: visible; }
    body.print-mode-score #printScoreArea { display: block !important; position: absolute; left: 0; top: 0; width: 100%; padding: 10mm; box-sizing: border-box; }
    body.print-mode-score .print-hide { display: none !important; }
    body.print-mode-score .score-table input { border: none !important; background: transparent !important; padding: 0 !important; text-align: center; font-family: 'Sarabun', sans-serif; font-size: 13px !important; color: #000 !important; -moz-appearance: none; -webkit-appearance: none; appearance: none; }
    body.print-mode-score .paper-table { width: 100% !important; border-collapse: collapse !important; margin-bottom: 20px; page-break-inside: auto; }
    body.print-mode-score .paper-table tr { page-break-inside: avoid; page-break-after: auto; }
    body.print-mode-score .paper-table th, body.print-mode-score .paper-table td { border: 1px solid #000 !important; padding: 4px !important; font-size: 12px !important; color: #000 !important; }
    @page { size: A4 portrait; margin: 0; }
    /* 📈 โหมดที่ 5: พิมพ์ผลการเรียนรู้ (print-mode-outcome) */
    body.print-mode-outcome #printOutcomeArea, body.print-mode-outcome #printOutcomeArea * { visibility: visible; }
    body.print-mode-outcome #printOutcomeArea { display: block !important; position: absolute; left: 0; top: 0; width: 100%; padding: 10mm; box-sizing: border-box; }
    body.print-mode-outcome .print-hide { display: none !important; }
    body.print-mode-outcome .score-table input { border: none !important; background: transparent !important; padding: 0 !important; text-align: center; font-family: 'Sarabun', sans-serif; font-size: 14px !important; color: #000 !important; -moz-appearance: none; -webkit-appearance: none; appearance: none; }
    body.print-mode-outcome .paper-table { width: 100% !important; border-collapse: collapse !important; margin-bottom: 20px; page-break-inside: auto; }
    body.print-mode-outcome .paper-table tr { page-break-inside: avoid; page-break-after: auto; }
    body.print-mode-outcome .paper-table th, body.print-mode-outcome .paper-table td { border: 1px solid #000 !important; padding: 6px !important; font-size: 14px !important; color: #000 !important; }
    @page { size: A4 portrait; margin: 0; }
}
/* ========================================= */
/* 📱 รองรับหน้าจอขนาดเล็ก (Responsive / Mobile-Friendly) */
/* ========================================= */
@media (max-width: 900px) {
    /* ปรับขอบจอให้พอดีมือถือ/แท็บเล็ต */
    body { padding: 0; }
    .container { padding: 12px 20px !important; margin: 0 !important; border-radius: 0 !important; box-sizing: border-box !important; }
    h1 { font-size: 20px; }

    /* หมายเหตุ: ลบ .tabs/.tab rules เดิมออก เพราะ sidebar ถูก redesign เป็น slide-in แล้ว
       Rules ใหม่อยู่ใน @media (max-width: 900px) block บนสุดของไฟล์ */

    /* กล่องค้นหา / ตัวกรอง เรียงเป็นแนวตั้ง */
    .controls { flex-direction: column; align-items: stretch !important; gap: 10px; }
    .controls > div { display: flex; flex-direction: column; width: 100%; }
    .controls input, .controls select, .controls button { width: 100% !important; box-sizing: border-box; }

    /* เลย์เอาต์ที่เคยแบ่งซ้าย-ขวา ให้ซ้อนทับกัน (Stack) บนล่าง */
    div[style*="display:flex; gap:20px"],
    div[style*="display: flex; gap: 30px;"],
    div[style*="display: flex; gap: 20px;"],
    .desc-container {
        flex-direction: column !important;
    }

    /* เมนูจัดการวิชา (Dashboard ด้านใน) */
    .management-container { flex-direction: column; }
    .side-menu { width: 100%; box-sizing: border-box; margin-bottom: 15px; }
    /* ฟอร์ม 3 คอลัมน์ (เช่น หัวหน้ากลุ่มสาระ) เปลี่ยนเป็น 1 คอลัมน์เรียงลงมา */
    div[style*="grid-template-columns: repeat(3, 1fr)"] {
        grid-template-columns: 1fr !important;
    }
    /* จัดการตารางไม่ให้ล้นจอ */
    /* page overflow handled by .tbl-scroll-wrap per-table */
    /* ตารางใช้ .tbl-scroll-wrap (JS auto-wrap) ดู CSS ด้านล่าง */
    /* Modal ให้เต็มจอขึ้น */
    .modal-box {
        width: 96% !important;
        max-width: 96% !important;
        padding: 14px !important;
        max-height: 88vh !important;
        overflow-y: auto !important;
        border-radius: 10px !important;
    }
    .modal-title { font-size: 15px !important; margin-bottom: 10px !important; }
    .modal-footer { flex-wrap: wrap; gap: 8px !important; }
    .modal-footer button { flex: 1 1 auto; }
    div[style*="display: flex; gap: 10px;"] { flex-direction: column !important; gap: 5px !important; }
    div[style*="background:#eef5fa; padding:15px"] { flex-direction: column; align-items: flex-start !important; }
}

/* ===== Tab 9 / Tab 10: Modern Attendance Cards ===== */

/* Grid container */
.att-card-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
    margin-top: 12px;
}

/* Individual card */
.att-card {
    background: #ffffff;
    border: 1px solid #e8edf5;
    border-radius: 16px;
    padding: 14px 14px 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    position: relative;
    overflow: hidden;
}
.att-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, #6366f1, #3b82f6);
    border-radius: 16px 16px 0 0;
}
.att-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.09);
}

/* Card header: number + name */
.att-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

/* Circle number badge */
.att-card-no {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(99, 102, 241, 0.35);
}

/* Student name */
.att-card-name {
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.3;
    flex: 1;
    min-width: 0;
}

/* Radio button group */
.att-radio-group {
    display: flex;
    gap: 5px;
    flex-wrap: nowrap;
}
.att-radio-group input[type="radio"] { display: none; }
.att-radio-label {
    flex: 1;
    text-align: center;
    padding: 6px 4px;
    background: #f8fafc;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
    user-select: none;
    transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
    white-space: nowrap;
}
.att-radio-label:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #334155;
}

/* Checked state — มา (default green) */
.att-radio-group input[type="radio"]:checked + .att-radio-label {
    background: #22c55e;
    color: white;
    border-color: #16a34a;
    box-shadow: 0 2px 6px rgba(34,197,94,0.35);
}
/* ขาด */
.att-radio-group input[value="ข"]:checked + .att-radio-label {
    background: #ef4444;
    color: white;
    border-color: #dc2626;
    box-shadow: 0 2px 6px rgba(239,68,68,0.35);
}
/* ลา */
.att-radio-group input[value="ล"]:checked + .att-radio-label {
    background: #f59e0b;
    color: white;
    border-color: #d97706;
    box-shadow: 0 2px 6px rgba(245,158,11,0.35);
}
/* สาย */
.att-radio-group input[value="ส"]:checked + .att-radio-label {
    background: #6366f1;
    color: white;
    border-color: #4f46e5;
    box-shadow: 0 2px 6px rgba(99,102,241,0.35);
}
/* หนี */
.att-radio-group input[value="น"]:checked + .att-radio-label {
    background: #64748b;
    color: white;
    border-color: #475569;
    box-shadow: 0 2px 6px rgba(100,116,139,0.30);
}
/* ทำ (Tab 10 area duty) */
.att-radio-group input[value="ทำ"]:checked + .att-radio-label {
    background: #10b981;
    color: white;
    border-color: #059669;
    box-shadow: 0 2px 6px rgba(16,185,129,0.35);
}
/* ไม่ทำ */
.att-radio-group input[value="ไม่ทำ"]:checked + .att-radio-label {
    background: #f97316;
    color: white;
    border-color: #ea580c;
    box-shadow: 0 2px 6px rgba(249,115,22,0.35);
}

/* Card ที่บันทึกแล้ว — แสดง border เขียวอ่อน */
.att-card--saved {
    border-color: #86efac;
    background: #f0fdf4;
}
.att-card--saved::before {
    background: linear-gradient(90deg, #22c55e, #16a34a);
}

/* Chip สถานะที่โชว์บน header ของ card */
.att-card-status-chip {
    margin-left: auto;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
    letter-spacing: 0.3px;
}
.att-chip-present { background:#dcfce7; color:#166534; }
.att-chip-absent  { background:#fee2e2; color:#991b1b; }
.att-chip-leave   { background:#fef3c7; color:#92400e; }
.att-chip-late    { background:#ede9fe; color:#4c1d95; }
.att-chip-skip    { background:#f1f5f9; color:#334155; }

/* Controls bar (ปี/ภาค/วิชา/วัน) */
.fast-att-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
    background: #f8fafc;
    padding: 14px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    margin-bottom: 16px;
}
.fast-att-controls > div { flex: 0 1 auto; }
.fast-att-controls label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #475569;
    margin-bottom: 4px;
    text-transform: none;
    letter-spacing: normal;
}
.fast-att-controls select,
.fast-att-controls input[type="text"] {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    padding: 7px 10px;
    font-size: 14px;
    background: #fff;
    color: #1e293b;
    font-weight: 500;
    transition: border-color 0.15s, box-shadow 0.15s;
    box-sizing: border-box;
    font-family: 'K2D', sans-serif;
}
.fast-att-controls select:focus,
.fast-att-controls input[type="text"]:focus {
    border-color: #94a3b8;
    outline: none;
    box-shadow: 0 0 0 3px rgba(148,163,184,0.18);
}

/* 📊 Tab 11: ข้อมูลนักเรียนประจำชั้น — pills ย่อย + ตาราง */
.ci-pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 14px; border: 1px solid #cbd5e1; border-radius: 999px;
    background: #fff; color: #475569; font-family: 'K2D', sans-serif;
    font-size: 13.5px; font-weight: 600; cursor: pointer; transition: all .15s;
}
.ci-pill:hover { border-color: #2563eb; color: #2563eb; }
.ci-pill.active { background: #2563eb; border-color: #2563eb; color: #fff; }
.ci-table { width: 100%; border-collapse: collapse; font-family: 'K2D', sans-serif; font-size: 13px; }
.ci-table th, .ci-table td { border: 1px solid #e2e8f0; padding: 7px 9px; text-align: center; }
.ci-table thead th { background: #f1f5f9; color: #334155; font-weight: 700; position: sticky; top: 0; }
.ci-table td.ci-left { text-align: left; white-space: nowrap; }
.ci-table tbody tr:nth-child(even) { background: #f8fafc; }
.ci-rot { writing-mode: vertical-lr; transform: rotate(180deg); white-space: nowrap; display: inline-block; line-height: 1.1; max-height: 130px; }
.ci-wrap { overflow-x: auto; border: 1px solid #e2e8f0; border-radius: 10px; }

/* แถบ pills + ปุ่มสไลด์ (จอเล็ก) */
.ci-pills-bar { display: flex; align-items: center; gap: 6px; margin-bottom: 14px; }
.ci-pills-scroll { display: flex; gap: 8px; flex-wrap: wrap; flex: 1 1 auto; min-width: 0; }
.ci-arrow {
    display: none; flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%;
    border: 1px solid #cbd5e1; background: #fff; color: #2563eb; cursor: pointer;
    align-items: center; justify-content: center; box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.ci-arrow:active { background: #eff6ff; }
@media (max-width: 640px) {
    .ci-pills-scroll {
        flex-wrap: nowrap; overflow-x: auto; scroll-behavior: smooth;
        -ms-overflow-style: none; scrollbar-width: none;
    }
    .ci-pills-scroll::-webkit-scrollbar { display: none; }
    .ci-pills-scroll .ci-pill { flex: 0 0 auto; }
    .ci-arrow { display: inline-flex; }
}

/* Title block */
.fast-att-title-block { margin-bottom: 16px; }
.fast-att-title-block h2 {
    font-size: 20px;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 4px;
}
.fast-att-title-block p { color: #64748b; font-size: 14px; margin: 0; }

/* Toolbar (quick-select all) */
.hr-action-toolbar {
    background: #ffffff;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid #e2e8f0;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.hr-quick-btn {
    padding: 7px 16px;
    border-radius: 10px;
    border: none;
    color: white;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    transition: opacity 0.15s, transform 0.1s;
    font-family: inherit;
}
.hr-quick-btn:hover { opacity: 0.88; transform: scale(0.97); }

/* Save button sticky footer */
.hr-save-sticky-wrap {
    text-align: center;
    padding: 20px 0;
    position: sticky;
    bottom: 0;
    z-index: 100;
    background: linear-gradient(0deg, #fff 65%, transparent 100%);
    margin-top: 24px;
}
.hr-save-main-btn {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: white;
    border: none;
    padding: 14px 52px;
    font-size: 16px;
    font-weight: 700;
    border-radius: 14px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(37,99,235,0.35);
    transition: transform 0.15s, box-shadow 0.15s;
    letter-spacing: 0.02em;
    font-family: inherit;
}
.hr-save-main-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(37,99,235,0.45);
}
.hr-save-main-btn:active { transform: scale(0.97); }

/* Loading / empty state */
.hr-loading-placeholder {
    grid-column: 1 / -1;
    text-align: center;
    padding: 32px;
    color: #94a3b8;
    border: 1.5px dashed #cbd5e1;
    border-radius: 16px;
    background: #f8fafc;
    font-size: 15px;
}

/* Sub-tab buttons (Tab 10) */
.sub-tab-btn {
    padding: 10px 18px;
    background: #f1f5f9;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    color: #475569;
    transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
    font-family: inherit;
}
.sub-tab-btn:hover { background: #e2e8f0; color: #1e293b; }
.sub-tab-btn.active {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    border-color: #2563eb;
    box-shadow: 0 2px 8px rgba(37,99,235,0.30);
}

/* Mobile */
@media (max-width: 900px) {
    .att-card-container {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 10px;
    }
    .att-card { padding: 12px 12px 10px; }
    .att-card-no { width: 28px; height: 28px; font-size: 11px; }
    .att-card-name { font-size: 13px; }
    .att-radio-label { padding: 5px 3px; font-size: 12px; }
    .sub-tab-btn { padding: 8px 10px; font-size: 13px; flex: 1 1 auto; text-align: center; }
    .hr-save-main-btn { width: 100% !important; padding: 14px 20px !important; }
    .fast-att-controls { padding: 12px; gap: 8px; }
}

/* ============================================================
   📱 tbl-scroll-wrap — ห่อตารางทุกตัวเพื่อ scroll แนวนอน
   JS (autoWrapTables) สร้าง div.tbl-scroll-wrap ครอบทุก <table>
   ยกเว้น print area / att-history-wrapper
   ============================================================ */
.tbl-scroll-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    max-width: 100%;
    border-radius: 8px;
    /* scroll shadow — แสดงเงาซ้าย/ขวาเมื่อมี content ซ่อน */
    background:
        linear-gradient(to right, #fff 20%, rgba(255,255,255,0)) left center,
        linear-gradient(to left,  #fff 20%, rgba(255,255,255,0)) right center,
        radial-gradient(farthest-side at 0 50%, rgba(12,68,124,.10), transparent) left center,
        radial-gradient(farthest-side at 100% 50%, rgba(12,68,124,.10), transparent) right center;
    background-repeat: no-repeat;
    background-size: 36px 100%, 36px 100%, 12px 100%, 12px 100%;
    background-attachment: local, local, scroll, scroll;
}
/* scrollbar สวยงาม */
.tbl-scroll-wrap::-webkit-scrollbar        { height: 5px; }
.tbl-scroll-wrap::-webkit-scrollbar-track  { background: #e2e8f0; border-radius: 3px; }
.tbl-scroll-wrap::-webkit-scrollbar-thumb  { background: #94a3b8; border-radius: 3px; }
.tbl-scroll-wrap::-webkit-scrollbar-thumb:hover { background: #0c447c; }

/* hint text "ปัดซ้าย/ขวา" — แสดงเฉพาะมือถือ */
.tbl-scroll-hint {
    display: none;
    font-size: 11px;
    color: #94a3b8;
    text-align: center;
    padding: 4px 0 2px;
    letter-spacing: 0.02em;
}
@media (max-width: 900px) {
    .tbl-scroll-hint { display: block; }
    /* ตารางใน wrapper: คงรูปแบบตาราง ไม่เปลี่ยนเป็น block */
    .tbl-scroll-wrap table {
        display: table !important;
        width: auto !important;
        min-width: 500px;   /* บังคับให้ตารางกว้างพอ scroll ได้ */
        overflow-x: unset !important;
    }
}

/* att-history-wrapper: ตาราง min-width บน mobile */
@media (max-width: 900px) {
    .att-history-wrapper { -webkit-overflow-scrolling: touch; }
}
