/* tvls-base.css — Base Styles, Variables, Common Components */
:root {
            --primary: #1f4e79;
            --primary-hover: #2e75b6;
            --primary-light: #e8f1fa;
            --primary-gradient: linear-gradient(135deg, #1f4e79 0%, #2e75b6 100%);
            --secondary: #2e75b6;
            --accent: #f59e0b;
            --success: #2eb85c;
            --warning: #f59e0b;
            --danger: #e55353;
            --bg-card: rgba(255, 255, 255, 0.94);
            --border-card: #dbe2ea;
            --text-main: #1e293b;
            --text-sub: #64748b;
            --border-color: #e2e8f0;
            --shadow-card: 0 4px 15px rgba(0, 0, 0, 0.05);
            --radius-card: 12px;
            --radius-button: 8px;
            --radius-badge: 6px;
            --font-main: 'Nunito', sans-serif;
            --font-title: 'Montserrat', sans-serif;
        }

        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
        }

        body {
            font-family: var(--font-main);
            color: var(--text-main);
            margin: 0;
            padding: 0;
            height: 100vh;
            width: 100vw;
            overflow: hidden;
            background: url('../assets/bg.jpg') no-repeat center center fixed;
            background-size: cover;
            overflow-x: hidden;
        }

        /* APP LAYOUT & SIDEBAR CHUẨN DESIGN TOKENS */
        .app-layout {
            display: flex;
            flex-direction: row;
            width: 100vw;
            height: 100vh;
            overflow: hidden;
            box-sizing: border-box;
        }

        /* SIDEBAR BÊN TRÁI CỐ ĐỊNH TRÊN DESKTOP */
        .app-sidebar {
            width: 260px;
            min-width: 260px;
            height: 100vh;
            background: rgba(255, 255, 255, 0.96);
            backdrop-filter: blur(16px);
            -webkit-backdrop-filter: blur(16px);
            border-right: 1.5px solid var(--border-card);
            box-shadow: 2px 0 12px rgba(0, 0, 0, 0.04);
            display: flex;
            flex-direction: column;
            justify-content: space-between;
            z-index: 100;
            box-sizing: border-box;
            flex-shrink: 0;
            transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        }

        /* BRAND TRÊN SIDEBAR */
        .sidebar-brand {
            padding: 14px 16px 12px;
            border-bottom: 1.5px solid var(--border-card);
            display: flex;
            flex-wrap: wrap;
            align-items: center;
            gap: 0 12px;
        }

        .sidebar-brand .brand-logo-img {
            width: 44px;
            height: 44px;
            object-fit: contain;
            filter: drop-shadow(0 2px 6px rgba(31, 78, 121, 0.25));
            animation: tvlsHeartbeat 3.6s ease-in-out infinite;
            cursor: pointer;
            flex-shrink: 0;
        }

        .sidebar-brand .brand-badge {
            background: linear-gradient(135deg, #1f4e79 0%, #2e75b6 100%);
            color: #fff;
            width: 38px;
            height: 38px;
            border-radius: 10px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-family: var(--font-title);
            font-weight: 800;
            font-size: 16px;
            box-shadow: 0 2px 6px rgba(31, 78, 121, 0.3);
            flex-shrink: 0;
        }

        .sidebar-brand .brand-info h1 {
            font-family: var(--font-title);
            font-size: 15px;
            font-weight: 800;
            color: var(--primary);
            line-height: 1.2;
            margin: 0;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .sidebar-brand .brand-info p {
            font-size: 11.5px;
            color: var(--text-sub);
            margin: 2px 0 0;
            font-weight: 600;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .welcome-logo-img {
            width: 320px;
            max-width: 90%;
            height: auto;
            max-height: 200px;
            object-fit: contain;
            filter: drop-shadow(0 16px 32px rgba(31, 78, 121, 0.28));
            animation: pulseLogo 3s infinite ease-in-out;
            margin-bottom: 16px;
        }

        @keyframes pulseLogo {
            0% { transform: scale(1); opacity: 0.95; }
            50% { transform: scale(1.05); opacity: 1; filter: drop-shadow(0 12px 28px rgba(31, 78, 121, 0.35)); }
            100% { transform: scale(1); opacity: 0.95; }
        }

        /* NAVIGATION MENU DỌC TRONG SIDEBAR */
        .sidebar-nav {
            padding: 16px 12px;
            display: flex;
            flex-direction: column;
            gap: 6px;
            flex: 1;
            overflow-y: auto;
        }

        .sidebar-section-title {
            font-size: 11px;
            font-weight: 800;
            color: #94a3b8;
            text-transform: uppercase;
            letter-spacing: 0.6px;
            padding: 8px 10px 4px;
        }

        .sidebar-nav .nav-item-btn {
            width: 100%;
            text-align: left;
            background: transparent;
            border: 1px solid transparent;
            color: #475569;
            padding: 10px 14px;
            border-radius: var(--radius-button);
            cursor: pointer;
            font-weight: 700;
            font-size: 13.5px;
            display: flex;
            align-items: center;
            gap: 10px;
            transition: all 0.18s ease;
            text-decoration: none;
            box-sizing: border-box;
        }

        .sidebar-nav .nav-item-btn:hover {
            color: var(--primary);
            background: var(--primary-light);
        }

        .sidebar-nav .nav-item-btn.active {
            background: var(--primary-light);
            color: var(--secondary);
            border-color: #c9dced;
            font-weight: 800;
            box-shadow: 0 1px 3px rgba(31, 78, 121, 0.12);
        }

        /* SIDEBAR FOOTER (ACTIONS, SYNC, PROFILE) */
        .sidebar-footer {
            padding: 14px 12px;
            border-top: 1.5px solid var(--border-card);
            display: flex;
            flex-direction: column;
            gap: 8px;
            background: rgba(248, 250, 252, 0.7);
        }

        .sidebar-footer-row {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 6px;
        }

        /* KHUNG CHỨA NỘI DUNG CHÍNH (CONTENT AREA BÊN PHẢI SIDEBAR) */
        .content-area-wrap {
            flex: 1;
            display: flex;
            flex-direction: column;
            height: 100vh;
            overflow: hidden;
            background: transparent;
        }

        /* TOP HEADER BAR — CHỈ HIỂN THỊ TRÊN MOBILE KHI CẦN BURGER MENU */
        .mobile-only-header,
        .app-top-header.mobile-only-header {
            display: none !important;
        }

        .app-top-header {
            height: 52px;
            min-height: 52px;
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(14px);
            -webkit-backdrop-filter: blur(14px);
            border-bottom: 1.5px solid var(--border-card);
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0 16px;
            box-sizing: border-box;
            z-index: 90;
        }

        .top-header-left {
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .top-header-right {
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .top-icon-btn {
            background: #ffffff;
            border: 1px solid #cbd5e1;
            border-radius: 8px;
            width: 32px;
            height: 32px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 15px;
            cursor: pointer;
            transition: all 0.2s ease;
            color: #334155;
            text-decoration: none;
            box-sizing: border-box;
            flex-shrink: 0;
        }

        .top-icon-btn:hover {
            transform: translateY(-1px);
            box-shadow: 0 3px 6px rgba(0,0,0,0.08);
        }

        /* CỤM NÚT THAO TÁC Ở GÓC TRÊN SIDEBAR BRAND — xuống hàng riêng, không đè lên tên/phụ đề */
        .sidebar-top-actions {
            display: flex;
            align-items: center;
            justify-content: flex-start;
            gap: 6px;
            flex-basis: 100%;
            margin: 8px 0 0 56px; /* thẳng hàng với brand-info, chừa chỗ logo */
        }

        .sidebar-top-actions .cloud-badge {
            width: 32px;
            height: 32px;
            font-size: 15px;
            border-radius: 8px;
            padding: 0;
        }

        .top-icon-btn:hover {
            background: var(--primary-light);
            border-color: var(--secondary);
            color: var(--primary);
            transform: translateY(-1px);
        }

        .mobile-brand-title {
            display: none;
            align-items: center;
            gap: 8px;
            font-family: var(--font-title);
            font-size: 14.5px;
            font-weight: 800;
            color: var(--primary);
        }

        .mobile-brand-title img {
            width: 28px;
            height: 28px;
            object-fit: contain;
        }

        /* NÚT BURGER MENU (☰) */
        .btn-burger-menu {
            display: none;
            background: #f8fafc;
            border: 1px solid #cbd5e1;
            border-radius: 8px;
            padding: 6px 10px;
            cursor: pointer;
            font-size: 18px;
            color: var(--primary);
            line-height: 1;
            transition: all 0.15s ease;
        }

        .btn-burger-menu:hover {
            background: var(--primary-light);
        }

        /* DRAWER BACKDROP TRÊN MOBILE */
        .drawer-backdrop {
            display: none;
            position: fixed;
            inset: 0;
            background: rgba(15, 23, 42, 0.5);
            backdrop-filter: blur(4px);
            -webkit-backdrop-filter: blur(4px);
            z-index: 998;
            opacity: 0;
            transition: opacity 0.25s ease;
        }

        .drawer-backdrop.active {
            display: block;
            opacity: 1;
        }

        /* NÚT CLOSE DRAWER */
        .btn-close-drawer {
            display: none;
            background: none;
            border: none;
            font-size: 20px;
            color: #64748b;
            cursor: pointer;
            padding: 4px;
        }

        /* CÁC NÚT ACTION CHUNG TRONG SIDEBAR FOOTER */
        .btn-sidebar-action {
            background: #ffffff;
            border: 1px solid #cbd5e1;
            border-radius: var(--radius-button);
            padding: 8px 12px;
            font-size: 12.5px;
            font-weight: 700;
            color: #334155;
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 8px;
            width: 100%;
            text-align: left;
            transition: all 0.15s ease;
            box-sizing: border-box;
            text-decoration: none;
        }

        .btn-sidebar-action:hover {
            background: #f1f5f9;
            color: var(--primary);
            border-color: #94a3b8;
        }

        .cloud-badge {
            position: relative;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 36px;
            height: 36px;
            font-size: 17px;
            background: #ffffff;
            border: 1px solid #cbd5e1;
            border-radius: 8px;
            cursor: pointer;
            transition: all 0.2s ease;
            box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
            user-select: none;
            filter: grayscale(0.6) opacity(0.75); /* mặc định: chưa rõ trạng thái = mờ đi (disabled) */
        }

        /* CHẤM TRẠNG THÁI ĐỒNG BỘ — 1 icon mây duy nhất, chỉ đổi màu chấm góc (enabled/disabled) */
        .cloud-badge::after {
            content: '';
            position: absolute;
            top: 3px;
            right: 3px;
            width: 8px;
            height: 8px;
            border-radius: 50%;
            background: #94a3b8;
            border: 1.5px solid #ffffff;
        }
        .cloud-badge[data-state="synced"] {
            filter: none; /* enabled: mây rõ màu */
        }
        .cloud-badge[data-state="synced"]::after {
            background: #059669;
        }
        .cloud-badge[data-state="syncing"] {
            filter: none;
        }
        .cloud-badge[data-state="syncing"]::after {
            background: #f59e0b;
        }
        .cloud-badge[data-state="error"] {
            filter: none;
        }
        .cloud-badge[data-state="error"]::after {
            background: #dc2626;
        }
        .cloud-badge[data-state="guest"]::after {
            background: #94a3b8;
        }
        .cloud-badge:hover {
            opacity: 0.9;
            transform: translateY(-1px);
            box-shadow: 0 3px 6px rgba(0, 0, 0, 0.08);
        }

        .sidebar-clock {
            display: flex;
            align-items: center;
            gap: 6px;
            background: rgba(248, 250, 252, 0.95);
            padding: 5px 8px;
            border-radius: 8px;
            font-size: 11.5px;
            font-weight: 700;
            color: #334155;
            border: 1px solid #e2e8f0;
        }

        .live-dot {
            width: 8px;
            height: 8px;
            background-color: var(--success);
            border-radius: 50%;
            animation: pulse 1.8s infinite;
            flex-shrink: 0;
        }

        @keyframes pulse {
            0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
            70% { transform: scale(1.1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
            100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
        }

        
        .btn-config-gear {
            background: rgba(241, 245, 249, 0.8);
            border: 1px solid #cbd5e1;
            border-radius: 6px;
            cursor: pointer;
            font-size: 13px;
            padding: 4px 6px;
            color: #475569;
            transition: all 0.15s ease;
            margin-left: auto;
            flex-shrink: 0;
        }
        .btn-config-gear:hover {
            background: #e2e8f0;
            color: var(--primary);
        }

        

        .tab-btn {
            width: 100%;
            padding: 9px 10px;
            border-radius: 8px;
            border: 1px solid transparent;
            background: transparent;
            font-family: var(--font-title);
            font-weight: 700;
            font-size: 12px;
            color: #475569;
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 7px;
            transition: all 0.18s ease;
            text-align: left;
            line-height: 1.3;
            box-sizing: border-box;
        }

        .tab-btn:hover {
            color: var(--primary);
            background: #f1f5f9;
        }

        .tab-btn.active {
            background: #e8f1fa;
            color: #2e75b6;
            border-color: #c9dced;
            font-weight: 800;
            box-shadow: 0 1px 3px rgba(79, 70, 229, 0.12);
        }

        

        .btn {
            padding: 6px 12px;
            border-radius: 8px;
            border: 1px solid transparent;
            font-family: var(--font-main);
            font-weight: 700;
            font-size: 12px;
            cursor: pointer;
            display: inline-flex;
            align-items: center;
            gap: 5px;
            transition: all 0.18s ease;
            text-decoration: none;
            white-space: nowrap;
        }

        /* --primary-strong: màu nền đủ sẫm cho chữ trắng (tvls-theme.js tự chọn theo theme; ở chế độ Tối
           --primary là màu sáng để làm chữ nhấn, nếu làm nền nút thì chữ trắng bị nhạt) */
        .btn-primary {
            background: var(--primary-strong, var(--primary));
            color: #fff;
        }
        .btn-primary:hover {
            background: var(--primary-strong-hover, var(--primary-hover));
        }

        .btn-outline {
            background: rgba(255, 255, 255, 0.9);
            border-color: #cbd5e1;
            color: #334155;
        }
        .btn-outline:hover {
            background: #ffffff;
            border-color: #94a3b8;
            color: var(--primary);
        }

        .btn-danger {
            background: #fee2e2;
            color: var(--danger);
            border-color: #fecaca;
        }
        .btn-danger:hover {
            background: var(--danger);
            color: #fff;
        }

        /* MAIN CONTAINER (TỐI ƯU KHÔNG BỊ KHUẤT CHỮ TRÊN DESKTOP & MOBILE) */
        .main-container {
            flex: 1;
            height: 100vh;
            overflow-y: auto;
            padding: 14px 16px 20px;
            box-sizing: border-box;
            width: 100%;
            max-width: 100%;
            margin: 0;
            -webkit-overflow-scrolling: touch;
        }

        .tab-content {
            display: none;
            animation: fadeIn 0.2s ease-in-out;
        }
        .tab-content.active {
            display: block;
        }

        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(4px); }
            to { opacity: 1; transform: translateY(0); }
        }

        /* GLASS CARD (CHUẨN Thoi_Khoa_Bieu_7D.html) */
        .card {
            background: var(--bg-card);
            backdrop-filter: blur(16px);
            -webkit-backdrop-filter: blur(16px);
            border-radius: 14px;
            border: 1.5px solid var(--border-card);
            box-shadow: var(--shadow-card);
            padding: 8px 10px;
            margin-bottom: 8px;
        }

        
        /* TKB BADGE VỚI TÍNH NĂNG ĐỔI CHỖ & NÚT MŨI TÊN CHỌN MÔN */
        .tkb-badge-card {
            width: 100%;
            max-width: 135px;
            height: 30px;
            border-radius: 7px;
            font-family: var(--font-main);
            font-weight: 700;
            font-size: 12px;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0 4px 0 8px;
            margin: 0 auto;
            border: 1.5px solid rgba(148, 163, 184, 0.4);
            box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
            transition: all 0.15s ease;
            position: relative;
            user-select: none;
            box-sizing: border-box;
        }

        .tkb-badge-card:hover {
            transform: translateY(-1px);
            box-shadow: 0 3px 6px rgba(0,0,0,0.08);
        }

        .tkb-badge-card.selected {
            border: 2px solid #1f4e79 !important;
            box-shadow: 0 0 0 3px rgba(31, 78, 121, 0.3) !important;
            animation: pulseSelect 1.5s infinite;
        }

        .tkb-badge-card.drag-over {
            transform: scale(1.04);
            border: 2px dashed #10b981 !important;
        }

        .tkb-badge-name {
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            flex: 1;
            text-align: center;
            font-size: 12px;
        }

        .tkb-arrow-wrap {
            position: relative;
            width: 18px;
            height: 22px;
            display: flex;
            align-items: center;
            justify-content: center;
            margin-left: 2px;
            flex-shrink: 0;
            border-radius: 4px;
            transition: background 0.12s ease;
        }

        .tkb-arrow-wrap:hover {
            background: rgba(0, 0, 0, 0.08);
        }

        .tkb-arrow-icon {
            font-size: 9px;
            opacity: 0.7;
            pointer-events: none;
            line-height: 1;
        }

        .tkb-native-select {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            opacity: 0;
            cursor: pointer;
            z-index: 10;
        }

        td[data-day="7"] .tkb-native-select,
        td[data-day="6"] .tkb-native-select {
            left: auto !important;
            right: 0 !important;
            direction: rtl;
        }
        td[data-day="7"] .tkb-native-select option,
        td[data-day="6"] .tkb-native-select option {
            direction: ltr;
        }

        /* ===============================================================
           RESPONSIVE DESIGN: DESKTOP VS MOBILE AUTO-HIDE BURGER DRAWER
           =============================================================== */
        @media (max-width: 991px) {
            .app-layout {
                flex-direction: column !important;
            }

            /* Header mỏng hiển thị trên Mobile */
            .mobile-only-header,
            .app-top-header.mobile-only-header {
                display: flex !important;
            }

            .mobile-brand-title {
                display: flex !important;
            }

            .btn-burger-menu {
                display: inline-flex !important;
                align-items: center;
                justify-content: center;
            }

            /* Sidebar biến thành Drawer ẩn sang trái */
            .app-sidebar {
                position: fixed !important;
                top: 0 !important;
                left: 0 !important;
                width: 280px !important;
                max-width: 82vw !important;
                height: 100vh !important;
                height: 100dvh !important;
                transform: translateX(-100%) !important;
                z-index: 9999 !important;
                box-shadow: 4px 0 24px rgba(0, 0, 0, 0.2) !important;
            }

            .admin-sidebar {
                min-width: unset !important;
            }

            /* Khi mở Drawer */
            .app-sidebar.drawer-open {
                transform: translateX(0) !important;
            }

            .btn-close-drawer {
                display: block !important;
            }

            /* Main container điều chỉnh chiều cao trừ đi mobile header */
            .main-container {
                height: calc(100vh - 52px) !important;
                height: calc(100dvh - 52px) !important;
                padding: 10px 10px 24px !important;
            }
        }

        /* =========================================================================
           GLOBAL MODAL OVERLAY & CONTENT (TVLS STANDARD)
           ========================================================================= */
        .modal-overlay {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(15, 23, 42, 0.65);
            backdrop-filter: blur(6px);
            -webkit-backdrop-filter: blur(6px);
            display: none;
            align-items: center;
            justify-content: center;
            z-index: 9999999 !important;
            padding: 16px;
            box-sizing: border-box;
        }

        .modal-overlay.active {
            display: flex !important;
        }

        .modal-content {
            background: #ffffff;
            border-radius: 16px;
            max-width: 480px;
            width: 100%;
            box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
            overflow: hidden;
            animation: modalFadeIn 0.2s ease-out;
            border: 1px solid rgba(226, 232, 240, 0.8);
        }

        @keyframes modalFadeIn {
            from { transform: scale(0.96); opacity: 0; }
            to { transform: scale(1); opacity: 1; }
        }

        /* TOAST NOTIFICATION (GLOBAL) */
        #toast {
            position: fixed;
            bottom: 24px;
            right: 24px;
            background: #0f172a;
            color: #ffffff;
            padding: 12px 20px;
            border-radius: 10px;
            font-size: 13.5px;
            font-weight: 700;
            box-shadow: 0 10px 30px rgba(0,0,0,0.25);
            display: none;
            z-index: 9999999;
            align-items: center;
            gap: 10px;
            border: 1px solid rgba(255, 255, 255, 0.15);
            animation: slideToast 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        }

        @keyframes slideToast {
            from { transform: translateY(20px); opacity: 0; }
            to { transform: translateY(0); opacity: 1; }
        }



        /* Tạm ẩn với mọi tài khoản trừ sysadmin (04/10/2026: Bảng điểm, Xét tuyển lớp 10 đang chờ BXSon test).
           Lớp la-sysadmin gắn lên <html> sau khi đăng nhập (tvls-auth.js, tvls-nb-core.js). */
        html:not(.la-sysadmin) .chi-sysadmin { display: none !important; }
        html.la-sysadmin .tru-sysadmin { display: none !important; }

        /* Ô nhập dùng chung (trước chỉ có trong tvls-catalog.css nên sodiem/quantri bị ô trần). Đặt ở base để mọi trang có. */
        .form-control {
            width: 100%;
            padding: 7px 10px;
            border-radius: 7px;
            border: 1px solid var(--border-color);
            font-size: 13px;
            font-family: inherit;
            background: #ffffff;
            color: var(--text-main);
            outline: none;
            box-sizing: border-box;
        }
        .form-control:focus {
            border-color: var(--primary);
            box-shadow: 0 0 0 3px rgba(31, 78, 121, 0.15);
        }
        .form-group { margin-bottom: 12px; }
        .form-group > label { display: block; margin-bottom: 5px; }
        /* Phần thân / chân / đầu hộp thoại (trước chỉ có trong tvls-catalog.css nên Sổ điểm, Quản trị bị dính sát mép) */
        .modal-header { padding: 14px 18px; border-bottom: 1px solid var(--border-color); }
        .modal-body { padding: 16px 18px; }
        .modal-footer { padding: 12px 18px; background: #f8fafc; border-top: 1px solid var(--border-color); }
        html.dark-mode .modal-footer { background: transparent; }
