: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 & TOPBAR MENU */
        .app-layout {
            display: flex;
            flex-direction: column;
            width: 100vw;
            height: 100vh;
            overflow: hidden;
            box-sizing: border-box;
        }

        /* THANH TOPBAR CAO CẤP NẰM NGANG TRÊN CÙNG */
        .app-topbar {
            width: 100%;
            height: 56px;
            min-height: 56px;
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(16px);
            -webkit-backdrop-filter: blur(16px);
            border-bottom: 1.5px solid var(--border-card);
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0 16px;
            gap: 16px;
            z-index: 1000;
            box-sizing: border-box;
            flex-shrink: 0;
        }

        .topbar-left {
            display: flex;
            align-items: center;
            gap: 10px;
            flex-shrink: 0;
        }

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

        .topbar-left .brand-info h1 {
            font-family: var(--font-title);
            font-size: 14.5px;
            font-weight: 800;
            color: #1f4e79;
            line-height: 1.2;
            margin: 0;
            white-space: nowrap;
        }

        .topbar-left .brand-info p {
            font-size: 11px;
            color: var(--text-sub);
            margin: 1px 0 0;
            font-weight: 600;
            white-space: nowrap;
        }

        /* 2 TAB CHUYỂN ĐỔI Ở CHÍNH GIỮA TOPBAR */
        .topbar-nav {
            display: flex;
            align-items: center;
            gap: 8px;
            background: rgba(241, 245, 249, 0.85);
            padding: 4px;
            border-radius: 10px;
            border: 1px solid #e2e8f0;
        }

        .topbar-nav .tab-btn {
            width: auto;
            padding: 6px 16px;
            border-radius: 7px;
            border: 1px solid transparent;
            background: transparent;
            font-family: var(--font-title);
            font-weight: 700;
            font-size: 13px;
            color: #475569;
            cursor: pointer;
            display: inline-flex;
            align-items: center;
            gap: 6px;
            transition: all 0.18s ease;
            white-space: nowrap;
            line-height: 1.2;
        }

        .topbar-nav .tab-btn:hover {
            color: var(--primary);
            background: rgba(255, 255, 255, 0.6);
        }

        .topbar-nav .tab-btn.active {
            background: #ffffff;
            color: #2e75b6;
            border-color: #c9dced;
            font-weight: 800;
            box-shadow: 0 1px 3px rgba(31, 78, 121, 0.15);
        }

        /* CỤM NÚT BÊN PHẢI TOPBAR */
        .topbar-right {
            display: flex;
            align-items: center;
            gap: 8px;
            flex-shrink: 0;
        }

        .btn-topbar-action {
            background: #f8fafc;
            border: 1px solid #cbd5e1;
            border-radius: 7px;
            padding: 5px 10px;
            font-size: 12px;
            font-weight: 700;
            color: #334155;
            cursor: pointer;
            display: inline-flex;
            align-items: center;
            gap: 5px;
            transition: all 0.15s ease;
            height: 34px;
            box-sizing: border-box;
        }

        .btn-topbar-action:hover {
            background: #e2e8f0;
            color: var(--primary);
        }

        .btn-topbar-action.btn-gear {
            padding: 5px 8px;
            font-size: 14px;
        }

        .btn-print-topbar {
            height: 34px;
            padding: 5px 12px;
            font-size: 12px;
            font-weight: 700;
            border-radius: 7px;
            display: inline-flex;
            align-items: center;
            gap: 5px;
        }

        .cloud-badge {
            display: inline-flex;
            align-items: center;
            gap: 4px;
            font-size: 10.5px;
            font-weight: 700;
            background: #e0f2fe;
            color: #0369a1;
            padding: 2px 8px;
            border-radius: 12px;
            cursor: pointer;
            transition: all 0.15s ease;
        }
        .cloud-badge:hover {
            opacity: 0.85;
            transform: scale(1.02);
        }

        .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;
        }

        .btn-primary {
            background: var(--primary);
            color: #fff;
        }
        .btn-primary:hover {
            background: 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 LAPTOP DELL 15") */
        .main-container {
            flex: 1;
            height: calc(100vh - 56px);
            overflow-y: auto;
            padding: 10px 16px 20px;
            box-sizing: border-box;
            width: 100%;
            max-width: 100%;
            margin: 0;
        }

        .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;
        }

        /* ======================== TAB 1: THỜI KHÓA BIỂU ======================== */
        .tkb-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-bottom: 6px;
            padding-bottom: 10px;
            border-bottom: 1.5px solid rgba(225, 205, 175, 0.6);
            flex-wrap: wrap;
            gap: 10px;
        }

        .tkb-title-area {
            display: flex;
            align-items: baseline;
            gap: 12px;
            flex-wrap: wrap;
        }

        .tkb-title-area h2 {
            font-family: var(--font-title);
            font-size: 18px;
            font-weight: 800;
            color: #1e293b;
            margin: 0;
        }

        .tkb-title-area p {
            font-size: 12px;
            color: var(--text-sub);
            font-weight: 600;
            margin: 0;
        }

        .tkb-table-wrap {
            width: 100%;
            overflow-x: auto;
            border-radius: 12px;
            border: 1px solid var(--border-color);
            background: #ffffff;
            box-shadow: 0 2px 4px rgba(0,0,0,0.03);
        }

        .tkb-table-wrap {
            width: 100%;
            overflow-x: auto;
            border-radius: 12px;
            border: 2px solid var(--border-card);
            background: #ffffff;
            box-shadow: 0 4px 15px rgba(0,0,0,0.05);
        }

        .tkb-table {
            width: 100%;
            border-collapse: collapse;
            text-align: center;
            font-size: 12.5px;
        }

        .tkb-table th {
            background: #1f4e79;
            color: #ffffff !important;
            font-family: var(--font-title);
            font-weight: 700;
            padding: 7px 6px;
            border: 1px solid rgba(255, 255, 255, 0.25);
            font-size: 12.5px;
            letter-spacing: 0.3px;
            user-select: none;
        }

        .tkb-table th.today-col {
            background: #0284c7 !important;
            color: #ffffff !important;
            border: 2px solid #38bdf8 !important;
            box-shadow: inset 0 0 8px rgba(0,0,0,0.2);
        }

        .tkb-table td {
            padding: 3px 4px;
            border: 1px solid #e2e8f0;
            vertical-align: middle;
            height: 38px;
        }

        .col-buoi {
            font-weight: 700;
            background: #f8fafc;
            color: #475569;
            width: 46px;
            font-size: 11px;
            user-select: none;
            padding: 2px !important;
        }

        .col-tiet {
            font-weight: 700;
            background: #f8fafc;
            width: 40px;
            color: #1e293b;
            font-size: 11.5px;
            user-select: none;
            padding: 2px !important;
        }

        .col-time {
            font-size: 10.5px;
            color: #64748b;
            font-weight: 600;
            width: 76px;
            background: #fafafa;
            user-select: none;
            padding: 2px !important;
            white-space: nowrap;
        }

        .banner-cell {
            font-weight: 700;
            font-size: 12px;
            padding: 4px;
            user-select: none;
            cursor: default;
        }

        .banner-shdg {
            background: #fff1f2 !important;
            color: #be185d;
        }

        .banner-break {
            background: #f1f5f9 !important;
            color: #475569;
        }

        .banner-lunch {
            background: #fef3c7 !important;
            color: transparent !important;
            height: 12px !important;
            min-height: 12px !important;
            max-height: 12px !important;
            padding: 0 !important;
            font-size: 0 !important;
            line-height: 0 !important;
            border-top: 1px solid #fde68a !important;
            border-bottom: 1px solid #fde68a !important;
        }

        .select-wrapper {
            display: inline-flex;
            justify-content: center;
            align-items: center;
            width: 100%;
        }

        .subject-select {
            appearance: none;
            -webkit-appearance: none;
            -moz-appearance: none;
            width: 100%;
            max-width: 135px;
            height: 28px;
            border-radius: 7px;
            font-family: var(--font-main);
            font-weight: 700;
            font-size: 12.5px;
            text-align: center;
            text-align-last: center;
            cursor: pointer;
            outline: none;
            border: 1px solid rgba(148, 163, 184, 0.4);
            box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
            transition: all 0.15s ease;
            padding: 0 4px;
        }

        .subject-select:hover {
            box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.3);
        }

        .subject-select:focus {
            box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.5);
            border-color: var(--primary);
        }

        .current-period-pulse {
            box-shadow: 0 0 0 3px #10b981 !important;
            animation: pulsePeriod 2s infinite;
        }

        @keyframes pulsePeriod {
            0% { box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.7); }
            50% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0.3); }
            100% { box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.7); }
        }
            50% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0.3); }
            100% { box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.7); }
        }

        /* ======================== TAB 2: SƠ ĐỒ CHỖ NGỒI (TỐI ƯU DELL 15" KHÔNG KHUẤT CHỮ) ======================== */
        
        .btn-icon-only {
            width: 36px;
            height: 36px;
            min-width: 36px;
            padding: 0;
            font-size: 16px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            border-radius: 8px;
            flex-shrink: 0;
            cursor: pointer;
            transition: all 0.15s ease;
            box-sizing: border-box;
        }
        .btn-icon-only:hover {
            transform: translateY(-2px);
            box-shadow: 0 3px 8px rgba(0,0,0,0.12);
        }

        .seating-controls {
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-bottom: 6px;
            flex-wrap: wrap;
            gap: 8px;
            background: rgba(241, 245, 249, 0.88);
            padding: 4px 8px;
            border-radius: 12px;
            border: 1px solid var(--border-color);
        }

        .swap-guide {
            display: flex;
            align-items: center;
            gap: 6px;
            font-size: 12px;
            font-weight: 700;
            color: #334155;
            flex-wrap: wrap;
        }

        .swap-guide .highlight-tag {
            background: #fef08a;
            color: #854d0e;
            padding: 2px 7px;
            border-radius: 5px;
            font-size: 11.5px;
        }

        .classroom-wrapper {
            background: rgba(255, 255, 255, 0.94);
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            border: 1.5px solid var(--border-card);
            border-radius: 12px;
            padding: 8px 10px;
            box-shadow: var(--shadow-card);
            position: relative;
            overflow-x: auto;
            -webkit-overflow-scrolling: touch;
        }

        .rows-container, .podium-area {
            min-width: 680px;
        }

        .double-desk {
            min-width: 140px;
        }

        .seat-card {
            min-width: 68px;
        }

        /* BỤC GIẢNG */
        .podium-area {
            display: grid;
            grid-template-columns: 1fr 2fr 1fr;
            align-items: center;
            gap: 12px;
            margin-bottom: 4px;
            padding-bottom: 4px;
            border-bottom: 1.5px dashed rgba(203, 213, 225, 0.8);
            width: 100%;
            box-sizing: border-box;
        }

        .podium-box {
            padding: 4px 12px;
            height: 32px;
            min-height: 32px;
            border-radius: 6px;
            text-align: center;
            font-family: var(--font-title);
            font-weight: 800;
            font-size: 12.5px;
            letter-spacing: 0.5px;
            transition: all 0.15s ease;
            cursor: pointer;
            user-select: none;
            position: relative;
            display: flex;
            align-items: center;
            justify-content: center;
            box-sizing: border-box;
        }

        .podium-box:nth-child(1) {
            justify-self: start;
        }

        .podium-box:nth-child(2) {
            justify-self: center;
        }

        .podium-box:nth-child(3) {
            justify-self: end;
        }

        .box-teacher {
            min-width: 160px;
            max-width: 210px;
            height: 32px;
            background: #fef3c7;
            border: 1.5px solid #f59e0b;
            color: #78350f;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 6px;
            border-radius: 6px;
            font-size: 12px;
            padding: 0 10px;
            box-sizing: border-box;
        }

        .box-board {
            width: 100%;
            max-width: 100%;
            height: 32px;
            background: #1e293b;
            border: 1.5px solid #0f172a;
            color: #ffffff;
            box-shadow: 0 2px 5px rgba(0,0,0,0.15);
            font-size: 12.5px;
            letter-spacing: 3px;
            text-align: center;
            border-radius: 6px;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 0;
            box-sizing: border-box;
        }

        .box-door {
            width: 100%;
            max-width: 130px;
            height: 32px;
            background: #f8fafc;
            border: 1.5px dashed #64748b;
            border-radius: 6px;
            color: #1e293b;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 6px;
            font-size: 11.5px;
            font-weight: 800;
            cursor: pointer;
            transition: all 0.15s ease;
            user-select: none;
            justify-self: start;
            box-shadow: 0 1px 3px rgba(0,0,0,0.06);
            box-sizing: border-box;
            padding: 0 8px;
        }
        .box-door:hover {
            background: #f1f5f9;
            border-color: #334155;
            transform: translateY(-2px);
            box-shadow: 0 4px 10px rgba(0,0,0,0.1);
        }

        .podium-box:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(0,0,0,0.12);
        }

        .podium-box.selected {
            border: 2.5px solid #1f4e79 !important;
            box-shadow: 0 0 0 4px rgba(31, 78, 121, 0.3) !important;
            animation: pulseSelect 1.5s infinite;
        }

        .podium-box.drag-over {
            background: #f0fdf4 !important;
            border: 2px dashed #10b981 !important;
            transform: scale(1.03);
        }

        .box-teacher {
            background: #fef3c7;
            border: 1.5px solid #f59e0b;
            color: #78350f;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 6px;
        }

        .box-board {
            background: #1e293b;
            border: 2px solid #0f172a;
            color: #ffffff;
            box-shadow: 0 4px 8px rgba(0,0,0,0.15);
            font-size: 14px;
            letter-spacing: 3px;
        }

        .box-door {
            background: #f1f5f9;
            border: 1.5px solid #94a3b8;
            color: #334155;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 6px;
        }

        /* TIÊU ĐỀ 4 DÃY BÀN & 3 LỐI ĐI */
        .aisle-header-row {
            display: grid;
            /* Cột Hàng (40px) | Dãy 1 (1fr) | Lối đi 1 (18px) | Dãy 2 (1fr) | Lối đi 2 (18px) | Dãy 3 (1fr) | Lối đi 3 (18px) | Dãy 4 (1fr) */
            grid-template-columns: 1fr 20px 1fr 20px 1fr 20px 1fr;
            gap: 6px;
            align-items: center;
            margin-bottom: 8px;
            text-align: center;
        }

        .aisle-col-title {
            background: #e8f1fa;
            color: #3730a3;
            font-family: var(--font-title);
            font-weight: 800;
            font-size: 12px;
            padding: 5px 8px;
            border-radius: 6px;
            border: 1px solid #c9dced;
            letter-spacing: 0.3px;
        }

        /* KHUNG CÁC HÀNG GHẾ */
        .rows-container {
            display: flex;
            flex-direction: column;
            gap: 5px;
        }

        .seating-row {
            display: grid;
            grid-template-columns: 1fr 22px 1fr 22px 1fr 22px 1fr;
            align-items: center;
            gap: 4px;
            background: rgba(248, 250, 252, 0.85);
            padding: 1px 4px;
            border-radius: 6px;
            border: 1px solid #e2e8f0;
        }

        .row-label {
            font-family: var(--font-title);
            font-weight: 800;
            font-size: 11.5px;
            color: #475569;
            text-align: center;
            background: #e2e8f0;
            padding: 10px 2px;
            border-radius: 6px;
            line-height: 1.15;
        }

        /* BÀN ĐÔI (MỖI BÀN 2 BẠN) */
        .double-desk {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 3px;
            background: #ffffff;
            padding: 3px;
            border-radius: 8px;
            border: 1.5px solid #cbd5e1;
            box-shadow: 0 1px 2px rgba(0,0,0,0.03);
            position: relative;
        }

        .double-desk::before {
            content: '';
            position: absolute;
            top: 4px;
            bottom: 4px;
            left: 50%;
            width: 1px;
            background: #e2e8f0;
        }

        /* KHOẢNG HỞ LỐI ĐI GIỮA CÁC DÃY */
        .aisle-spacer {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            font-size: 10px;
            font-weight: 800;
            color: #94a3b8;
            user-select: none;
            background: rgba(226, 232, 240, 0.4);
            border-radius: 4px;
            height: 100%;
        }

        .aisle-dots {
            display: flex;
            flex-direction: column;
            gap: 3px;
            align-items: center;
        }

        .aisle-dot {
            width: 3.5px;
            height: 3.5px;
            background: #94a3b8;
            border-radius: 50%;
        }

        /* THẺ GHẾ HỌC SINH (KHÔNG BỊ KHUẤT CHỮ TRÊN LAPTOP DELL 15") */
        .seat-card {
            border-radius: 8px;
            padding: 6px 8px;
            height: 56px;
            min-height: 56px;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            text-align: center;
            cursor: pointer;
            user-select: none;
            transition: all 0.15s ease;
            position: relative;
            border: 1.5px solid transparent;
            box-sizing: border-box;
        }

        .seat-top-row {
            display: flex;
            align-items: center;
            justify-content: center;
            width: 100%;
            position: relative;
            margin-top: 1px;
        }

        .seat-name {
            font-size: 14.5px;
            font-weight: 800;
            color: #0f172a;
            line-height: 1.25;
            text-align: center;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            padding: 0 2px;
            letter-spacing: -0.2px;
            width: 100%;
        }

        .seat-star-btn {
            position: absolute;
            left: 0;
            top: 50%;
            transform: translateY(-50%);
            background: none;
            border: none;
            cursor: pointer;
            font-size: 10px;
            opacity: 0.7;
            padding: 0;
            line-height: 1;
            z-index: 5;
        }
        .seat-star-btn:hover {
            opacity: 1;
            transform: translateY(-50%) scale(1.2);
        }

        .seat-bottom-row {
            display: flex;
            align-items: center;
            justify-content: space-between;
            width: 100%;
            height: 18px;
        }

        .seat-speak-count {
            font-size: 9.5px;
            font-weight: 800;
            background: #fef08a;
            color: #854d0e;
            padding: 1px 4px;
            border-radius: 4px;
            border: 1px solid #fde047;
            line-height: 1.1;
            display: inline-flex;
            align-items: center;
            gap: 2px;
            pointer-events: none;
        }

        .seat-speak-controls {
            display: flex;
            align-items: center;
            gap: 3px;
            margin-left: auto;
            flex-shrink: 0;
        }

        .btn-speak-minus, .btn-speak-plus {
            width: 22px;
            height: 20px;
            border-radius: 4px;
            font-size: 13px;
            font-weight: 800;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            background: #ffffff;
            transition: all 0.12s ease;
            line-height: 1;
            padding: 0;
            box-shadow: none;
        }

        .btn-speak-minus {
            border: 1px solid #f87171;
            color: #ef4444;
            background: #ffffff;
        }
        .btn-speak-minus:hover {
            background: #ef4444;
            border-color: #dc2626;
            color: #ffffff;
            transform: scale(1.1);
        }

        .btn-speak-plus {
            border: 1px solid #38bdf8;
            color: #0284c7;
            background: #ffffff;
        }
        .btn-speak-plus:hover {
            background: #0284c7;
            border-color: #0369a1;
            color: #ffffff;
            transform: scale(1.1);
        }

        /* Tô nền nhẹ & viền theo giới tính */
        .seat-card.card-nam {
            background: #e0f2fe;
            border-color: #7dd3fc;
        }

        .seat-card.card-nu {
            background: #fce7f3;
            border-color: #f472b6;
        }

        .seat-card:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 10px rgba(0,0,0,0.08);
            border-color: #6366f1;
        }

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

        @keyframes pulseSelect {
            0% { transform: scale(1); }
            50% { transform: scale(1.02); }
            100% { transform: scale(1); }
        }

        .seat-card.drag-over {
            background: #f0fdf4 !important;
            border: 2px dashed #10b981 !important;
            transform: scale(1.02);
        }

        .seat-card.empty {
            background: #f8fafc;
            border: 1.5px dashed #cbd5e1;
            color: #94a3b8;
            align-items: center;
            justify-content: center;
            min-height: 60px;
        }

        /* Đã bỏ mô tả D4-T */

        .seat-avatar-badge {
            display: flex;
            align-items: center;
            gap: 3px;
        }

        .avatar-icon {
            font-size: 11px;
            line-height: 1;
        }

        .stt-badge {
            font-size: 9px;
            font-weight: 800;
            width: 14px;
            height: 14px;
            border-radius: 4px;
            display: flex;
            align-items: center;
            justify-content: center;
            line-height: 1;
        }

        .stt-nam {
            background: #e0f2fe;
            color: #0369a1;
        }

        .stt-nu {
            background: #fce7f3;
            color: #be185d;
        }

        /* Tên học sinh hiển thị to rõ, không bị khuất chữ */
        .seat-name {
            font-size: 14.5px;
            font-weight: 800;
            color: #0f172a;
            line-height: 1.25;
            text-align: center;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            margin: 2px 0;
            padding: 0 16px;
            letter-spacing: -0.2px;
            width: 100%;
        }

        /* ======================== TAB 3: DANH MỤC & LỚP ======================== */
        .management-grid {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 16px;
        }

        @media (max-width: 1024px) {
            .management-grid {
                grid-template-columns: 1fr;
            }
        }

        .table-custom {
            width: 100%;
            border-collapse: collapse;
            font-size: 13px;
        }

        .table-custom th {
            background: #f8fafc;
            padding: 9px 10px;
            text-align: left;
            font-weight: 700;
            color: #475569;
            border-bottom: 1px solid var(--border-color);
            font-size: 12px;
        }

        .table-custom td {
            padding: 7px 10px;
            border-bottom: 1px solid var(--border-color);
            vertical-align: middle;
        }

        .search-box {
            width: 100%;
            padding: 8px 12px;
            border-radius: 8px;
            border: 1px solid var(--border-color);
            font-size: 13px;
            outline: none;
            margin-bottom: 6px;
        }

        .search-box:focus {
            border-color: var(--primary);
            box-shadow: 0 0 0 3px rgba(31, 78, 121, 0.15);
        }

        .add-subject-bar {
            display: flex;
            gap: 6px;
            align-items: center;
            margin-bottom: 6px;
            background: #f8fafc;
            padding: 8px 10px;
            border-radius: 8px;
            border: 1px solid var(--border-color);
            flex-wrap: wrap;
        }

        .color-picker-group {
            display: flex;
            align-items: center;
            gap: 4px;
            font-size: 12px;
            font-weight: 700;
            color: #475569;
        }

        .color-input-mini {
            width: 30px;
            height: 28px;
            padding: 1px;
            border: 1px solid #cbd5e1;
            border-radius: 5px;
            cursor: pointer;
            background: transparent;
        }

        .subject-pill-preview {
            display: inline-block;
            padding: 3px 10px;
            border-radius: 6px;
            font-family: var(--font-title);
            font-weight: 700;
            font-size: 12px;
            text-align: center;
        }

        .backup-card {
            background: linear-gradient(135deg, rgba(248, 250, 252, 0.95), rgba(237, 242, 247, 0.95));
            border: 1.5px solid #cbd5e1;
            border-radius: 12px;
            padding: 16px;
            margin-top: 14px;
        }

        /* MODAL DIALOGS */
        .modal-overlay {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(15, 23, 42, 0.6);
            backdrop-filter: blur(4px);
            display: none;
            align-items: center;
            justify-content: center;
            z-index: 1000;
            padding: 16px;
        }

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

        .modal-content {
            background: #ffffff;
            border-radius: 16px;
            max-width: 480px;
            width: 100%;
            box-shadow: 0 20px 40px rgba(0,0,0,0.25);
            overflow: hidden;
            animation: modalSlide 0.2s ease-out;
        }

        @keyframes modalSlide {
            from { transform: scale(0.95); opacity: 0; }
            to { transform: scale(1); opacity: 1; }
        }

        .modal-header {
            padding: 14px 18px;
            background: #f8fafc;
            border-bottom: 1px solid var(--border-color);
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        .modal-header h3 {
            font-family: var(--font-title);
            font-size: 15px;
            font-weight: 800;
            color: #1e293b;
        }

        .modal-body {
            padding: 16px 18px;
        }

        .modal-footer {
            padding: 12px 18px;
            background: #f8fafc;
            border-top: 1px solid var(--border-color);
            display: flex;
            justify-content: flex-end;
            gap: 8px;
        }

        .form-group {
            margin-bottom: 6px;
        }

        .form-group label {
            display: block;
            font-size: 12.5px;
            font-weight: 700;
            color: #334155;
            margin-bottom: 5px;
        }

        .form-control {
            width: 100%;
            padding: 7px 10px;
            border-radius: 7px;
            border: 1px solid var(--border-color);
            font-size: 13px;
            outline: none;
        }
        .form-control:focus {
            border-color: var(--primary);
            box-shadow: 0 0 0 3px rgba(31, 78, 121, 0.15);
        }

        /* TOAST NOTIFICATION */
        #toast {
            position: fixed;
            bottom: 20px;
            right: 20px;
            background: #1e293b;
            color: #ffffff;
            padding: 10px 18px;
            border-radius: 9px;
            font-size: 13px;
            font-weight: 700;
            box-shadow: 0 10px 25px rgba(0,0,0,0.2);
            display: none;
            z-index: 9999;
            align-items: center;
            gap: 8px;
            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; }
        }

        /* PRINT FORMAT */
        @media print {
            @page {
                size: A4 landscape;
                margin: 6mm 8mm;
            }

            body {
                background: #ffffff !important;
                color: #000000 !important;
                font-family: Arial, Helvetica, sans-serif !important;
                height: auto !important;
                overflow: visible !important;
            }

            /* Ẩn các thanh công cụ, nút bấm */
            .app-header, .app-sidebar, .app-topbar, .seating-controls, .btn, .nav-tabs, #toast, .modal-overlay, 
            .search-box, .add-subject-bar, .backup-card, .unassigned-tray,
            .card > div > div > button, input[type="color"] {
                display: none !important;
            }

            .app-layout {
                display: block !important;
                width: 100% !important;
                height: auto !important;
                overflow: visible !important;
            }

            .main-container {
                display: block !important;
                padding: 0 !important;
                margin: 0 !important;
                width: 100% !important;
                max-width: 100% !important;
                height: auto !important;
                overflow: visible !important;
            }

            .card {
                border: none !important;
                box-shadow: none !important;
                padding: 0 !important;
                background: transparent !important;
                backdrop-filter: none !important;
            }

            /* CHẾ ĐỘ IN TKB (CHUẨN 2 BẢNG A4: BẢNG LỚN Ở TRÊN & BẢNG RÚT GỌN Ở DƯỚI) */
            body.mode-print-tkb .app-layout,
            body.mode-print-tkb .main-container,
            body.mode-print-tkb .app-sidebar,
            body.mode-print-tkb .app-topbar,
            body.mode-print-tkb #tab-tkb,
            body.mode-print-tkb #tab-seating,
            body.mode-print-tkb #tab-grade,
            body.mode-print-tkb #tab-mgmt {
                display: none !important;
            }

            body.mode-print-tkb #print-section {
                display: flex !important;
                flex-direction: column !important;
                align-items: center !important;
                width: 100% !important;
            }

            .excel-paper-frame {
                width: 100% !important;
                max-width: 960px !important;
                display: flex !important;
                flex-direction: column !important;
                gap: 16px !important;
            }

            /* HỘP BẢNG 1 (TRÊN): BẢNG CHI TIẾT CÓ KHUNG VIỀN ĐEN BẢO VỆ */
            .box-table-top {
                border: 2px solid #000000;
                padding: 10px;
                background: #fff;
            }

            /* HỘP BẢNG 2 (DƯỚI): BẢNG RÚT GỌN CÓ KHUNG VIỀN ĐEN BẢO VỆ */
            .box-table-bottom {
                border: 2px solid #000000;
                padding: 10px;
                background: #fff;
                display: flex;
                flex-direction: column;
                align-items: flex-end; /* Căn phải để các cột Thứ 2-6 thẳng hàng với bảng trên */
            }

            .tbl-main {
                width: 100%;
                border-collapse: collapse;
                text-align: center;
                font-size: 11pt;
                color: #000000 !important;
            }

            .tbl-main th, .tbl-main td {
                border: 1px solid #000000 !important;
                padding: 4.5px 3px;
                height: 24px;
                color: #000000 !important;
            }

            .tbl-main th {
                background-color: #d9d9d9 !important;
                -webkit-print-color-adjust: exact;
                print-color-adjust: exact;
                font-weight: bold;
                font-size: 11pt;
                color: #000000 !important;
            }

            .cell-gray {
                background-color: #d9d9d9 !important;
                -webkit-print-color-adjust: exact;
                print-color-adjust: exact;
            }

            .italic-note {
                font-style: italic;
                color: #000000 !important;
            }

            .bold-note {
                font-weight: bold;
                font-style: italic;
                color: #000000 !important;
            }

            /* BẢNG 2 RÚT GỌN DƯỚI */
            .tbl-compact {
                width: 88%; /* Khớp đúng vị trí từ cột Tiết đến Thứ 6 */
                border-collapse: collapse;
                text-align: center;
                font-size: 11pt;
                color: #000000 !important;
            }

            .tbl-compact th, .tbl-compact td {
                border: 1px solid #000000 !important;
                padding: 4px 3px;
                height: 23px;
                color: #000000 !important;
            }

            .tbl-compact th {
                background-color: #d9d9d9 !important;
                -webkit-print-color-adjust: exact;
                print-color-adjust: exact;
                font-weight: bold;
                font-size: 11pt;
                color: #000000 !important;
            }

            /* CHẾ ĐỘ IN SƠ ĐỒ CHỖ NGỒI (BUNG RỘNG CÂN ĐỐI KHỔ GIẤY A4 NẰM NGANG) */
            body.mode-print-seating #tab-tkb,
            body.mode-print-seating #tab-mgmt,
            body.mode-print-seating #tab-grade {
                display: none !important;
            }
            body.mode-print-seating {
                display: flex !important;
                flex-direction: column !important;
                align-items: center !important;
                justify-content: center !important;
                min-height: 100vh !important;
                margin: 0 !important;
                padding: 0 !important;
            }
            body.mode-print-seating .app-layout {
                display: flex !important;
                flex-direction: column !important;
                align-items: center !important;
                justify-content: center !important;
                width: 100% !important;
                margin: 0 auto !important;
            }
            body.mode-print-seating .main-container {
                display: flex !important;
                flex-direction: column !important;
                align-items: center !important;
                justify-content: center !important;
                width: 100% !important;
                margin: 0 auto !important;
            }
            body.mode-print-seating #tab-seating {
                display: flex !important;
                flex-direction: column !important;
                align-items: center !important;
                justify-content: center !important;
                width: 100% !important;
                max-width: 275mm !important; /* Vừa khít A4 ngang căn giữa tuyệt đối */
                margin: 0 auto !important;
                padding: 0 !important;
            }
            body.mode-print-seating #tab-seating .card {
                padding: 0 !important;
                margin: 0 auto !important;
                width: 100% !important;
                border: none !important;
                background: transparent !important;
                display: flex !important;
                flex-direction: column !important;
                align-items: center !important;
            }
            body.mode-print-seating .classroom-wrapper {
                border: none !important;
                box-shadow: none !important;
                padding: 0 !important;
                margin: 0 auto !important;
                background: transparent !important;
                width: 100% !important;
                max-width: 100% !important;
                box-sizing: border-box !important;
                display: flex !important;
                flex-direction: column !important;
                align-items: center !important;
            }
            body.mode-print-seating .print-title-page {
                display: block !important;
                text-align: center;
                margin-top: 0 !important;
                margin-bottom: 8px !important;
            }
            body.mode-print-seating .print-title-page h2 {
                font-size: 16pt !important;
                font-weight: 800;
                text-transform: uppercase;
                color: #000 !important;
                margin-bottom: 2px !important;
            }
            body.mode-print-seating .print-title-page p {
                font-size: 10.5pt !important;
                color: #000 !important;
            }
            /* Bục giảng bung vừa vặn thẳng hàng 4 dãy */
            body.mode-print-seating .podium-area {
                display: grid !important;
                grid-template-columns: 1fr 2fr 1fr !important;
                gap: 14px !important;
                margin-top: 10px !important;
                margin-bottom: 0 !important;
                padding-bottom: 0 !important;
                border-bottom: none !important;
                width: 100% !important;
                box-sizing: border-box !important;
            }
            body.mode-print-seating .podium-box {
                height: 34px !important;
                min-height: 34px !important;
                font-size: 11pt !important;
                border-radius: 4px !important;
                display: flex !important;
                align-items: center !important;
                justify-content: center !important;
                max-width: none !important;
                min-width: 0 !important;
                width: 100% !important;
                padding: 0 !important;
                box-sizing: border-box !important;
            }
            body.mode-print-seating .box-board {
                background: #f1f5f9 !important;
                color: #000 !important;
                border: 1.5px solid #000 !important;
                font-weight: 800 !important;
                letter-spacing: 4px !important;
            }
            body.mode-print-seating .box-teacher,
            body.mode-print-seating .box-door {
                border: 1.5px solid #000 !important;
                color: #000 !important;
                background: #ffffff !important;
                font-weight: 700 !important;
            }
            /* Khung hàng ghế: giãn đều, 4 dãy bàn đôi gọn gàng trong chiều ngang trang in */
            body.mode-print-seating .rows-container {
                display: flex !important;
                flex-direction: column !important;
                gap: 8px !important;
                width: 100% !important;
            }
            body.mode-print-seating .seating-row {
                background: transparent !important;
                border: none !important;
                box-shadow: none !important;
                padding: 0 !important;
                display: grid !important;
                grid-template-columns: repeat(4, 1fr) !important;
                align-items: center !important;
                gap: 14px !important;
                width: 100% !important;
                box-sizing: border-box !important;
            }
            body.mode-print-seating .double-desk {
                border: none !important;
                background: transparent !important;
                box-shadow: none !important;
                padding: 0 !important;
                gap: 4px !important;
                display: grid !important;
                grid-template-columns: 1fr 1fr !important;
                width: 100% !important;
                box-sizing: border-box !important;
            }
            body.mode-print-seating .double-desk::before {
                display: none !important;
            }
            body.mode-print-seating .aisle-spacer {
                display: none !important;
            }
            body.mode-print-seating .aisle-dot {
                background: #94a3b8 !important;
                width: 4px !important;
                height: 4px !important;
            }
            /* Ô học sinh: cao 50px, rộng rãi thoải mái, chữ 12.5pt vừa khít không bị tràn mép */
            body.mode-print-seating .seat-card,
            body.mode-print-seating .seat-card.card-nam,
            body.mode-print-seating .seat-card.card-nu,
            body.mode-print-seating .seat-card.empty {
                border: 1px solid #000000 !important;
                background: #ffffff !important;
                box-shadow: none !important;
                border-radius: 4px !important;
                height: 50px !important;
                min-height: 50px !important;
                width: 100% !important;
                padding: 2px 3px !important;
                display: flex !important;
                flex-direction: column !important;
                justify-content: center !important;
                align-items: center !important;
                box-sizing: border-box !important;
            }
            body.mode-print-seating .seat-top-row {
                margin: 0 !important;
                width: 100% !important;
                display: flex !important;
                justify-content: center !important;
                align-items: center !important;
            }
            body.mode-print-seating .seat-name {
                font-size: 10pt !important;
                font-weight: 800 !important;
                color: #000000 !important;
                text-align: center !important;
                white-space: nowrap !important;
                overflow: hidden !important;
                text-overflow: clip !important;
                letter-spacing: -0.3px !important;
            }
            /* Ẩn toàn bộ nút bấm, điểm cộng, controls khi in */
            body.mode-print-seating .seat-bottom-row,
            body.mode-print-seating .seat-speak-controls,
            body.mode-print-seating .btn-speak-minus,
            body.mode-print-seating .btn-speak-plus,
            body.mode-print-seating .seat-speak-count,
            body.mode-print-seating .seat-speak-badge-wrap,
            body.mode-print-seating .seat-star-btn,
            body.mode-print-seating .stt-badge {
                display: none !important;
            }

            /* CHẾ ĐỘ IN BẢNG ĐIỂM VĂN */
            body.mode-print-grade #tab-tkb,
            body.mode-print-grade #tab-seating,
            body.mode-print-grade #tab-mgmt {
                display: none !important;
            }
            body.mode-print-grade #tab-grade {
                display: block !important;
            }
            body.mode-print-grade #table-grade-list th {
                background: #f1f5f9 !important;
                border: 1.5px solid #000 !important;
                color: #000 !important;
            }
            body.mode-print-grade #table-grade-list td {
                border: 1px solid #000 !important;
                color: #000 !important;
            }
            /* In bảng điểm: giữ nguyên cột điểm cộng, ẩn các nút bấm +/- khi in */
            @media print {
                #table-grade-list td button {
                    display: none !important;
                }
                #table-grade-list input {
                    border: none !important;
                    background: transparent !important;
                }
            }
            body.mode-print-grade div[style*="max-height:520px"] {
                max-height: none !important;
                overflow: visible !important;
            }

            /* CHẾ ĐỘ IN DANH SÁCH LỚP */
            body.mode-print-students #tab-tkb,
            body.mode-print-students #tab-seating,
            body.mode-print-students .management-grid > div:last-child {
                display: none !important;
            }
            body.mode-print-students #tab-mgmt {
                display: block !important;
            }
            body.mode-print-students .management-grid {
                grid-template-columns: 1fr !important;
            }
            body.mode-print-students .table-custom th {
                border: 1.5px solid #000 !important;
                background: #f1f5f9 !important;
                color: #000 !important;
            }
            body.mode-print-students .table-custom td {
                border: 1px solid #000 !important;
                color: #000 !important;
                padding: 5px 8px !important;
            }
            body.mode-print-students .table-custom td:last-child,
            body.mode-print-students .table-custom th:last-child {
                display: none !important; /* ẩn cột thao tác sửa/xóa */
            }
            body.mode-print-students div[style*="max-height:500px"] {
                max-height: none !important;
                overflow: visible !important;
                border: none !important;
            }
        }
.print-title-page {
            display: none;
        }
    
        /* KHAY HỌC SINH CHƯA XẾP CHỖ */
        .unassigned-tray {
            margin-top: 14px;
            background: rgba(255, 255, 255, 0.95);
            border: 2px dashed #94a3b8;
            border-radius: 12px;
            padding: 10px 14px;
            box-shadow: 0 2px 8px rgba(0,0,0,0.06);
        }

        .unassigned-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-bottom: 8px;
            font-size: 12.5px;
            font-weight: 800;
            color: #1e293b;
        }

        .unassigned-cards-wrap {
            display: flex;
            flex-wrap: wrap;
            gap: 6px;
            max-height: 140px;
            overflow-y: auto;
            padding: 4px;
            background: #f8fafc;
            border-radius: 8px;
            border: 1px solid #e2e8f0;
        }

        .unassigned-card {
            display: inline-flex;
            align-items: center;
            gap: 5px;
            padding: 4px 8px;
            border-radius: 6px;
            border: 1.5px solid transparent;
            font-size: 11.5px;
            font-weight: 700;
            cursor: pointer;
            user-select: none;
            transition: all 0.15s ease;
        }

        .unassigned-card:hover {
            transform: translateY(-2px);
            box-shadow: 0 3px 6px rgba(0,0,0,0.1);
            border-color: #6366f1;
        }

        .unassigned-card.selected {
            border-color: #1f4e79 !important;
            background: #e0e7ff !important;
            box-shadow: 0 0 0 3px rgba(31, 78, 121, 0.3) !important;
        }

        .plan-select-group {
            display: flex;
            align-items: center;
            gap: 6px;
            flex-wrap: wrap;
        }

        .seating-plan-select {
            height: 32px;
            padding: 2px 8px;
            border-radius: 6px;
            border: 1.5px solid var(--border-card);
            font-family: var(--font-title);
            font-weight: 700;
            font-size: 12.5px;
            color: #1e293b;
            background: #fff;
            outline: none;
            cursor: pointer;
            max-width: 240px;
        }

    
        /* THẺ ĐIỂM CỘNG & PHÁT BIỂU TRÊN GHẾ */
        .seat-grade-badge {
            position: absolute;
            bottom: 2px;
            left: 4px;
            display: flex;
            align-items: center;
            gap: 3px;
            font-size: 10px;
            font-weight: 800;
            background: #fef08a;
            color: #854d0e;
            padding: 1px 4px;
            border-radius: 4px;
            border: 1px solid #fde047;
            pointer-events: none;
            line-height: 1.1;
        }

        .seat-plus-btn {
            position: absolute;
            bottom: 2px;
            right: 3px;
            width: 18px;
            height: 18px;
            border-radius: 4px;
            background: #1f4e79;
            color: #ffffff;
            border: none;
            font-weight: 900;
            font-size: 12px;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: all 0.12s ease;
            box-shadow: 0 1px 3px rgba(31, 78, 121, 0.3);
            z-index: 5;
        }

        .seat-plus-btn:hover {
            background: #2e75b6;
            transform: scale(1.15);
        }

        .seat-edit-grade-btn {
            position: absolute;
            top: 2px;
            left: 3px;
            background: none;
            border: none;
            cursor: pointer;
            font-size: 10px;
            opacity: 0.7;
            z-index: 5;
            padding: 1px 3px;
            border-radius: 3px;
        }
        .seat-edit-grade-btn:hover {
            opacity: 1;
            background: rgba(0,0,0,0.06);
        }

            #print-section {
            display: none;
        }

        
        
        /* ======================== RESPONSIVE CHO MÀN HÌNH DI ĐỘNG & TABLET ======================== */
        @media (max-width: 768px) {
            body {
                overflow: hidden !important;
                background-attachment: fixed !important;
            }

            .app-layout {
                flex-direction: column !important;
                height: 100vh !important;
                height: 100dvh !important;
                position: relative !important;
            }

            /* TOP BAR: Header gồm Logo trường và các nút sao lưu/HTML */
            .app-sidebar {
                width: 100% !important;
                min-width: 100% !important;
                max-width: 100% !important;
                height: auto !important;
                min-height: auto !important;
                max-height: none !important;
                flex-direction: column !important;
                align-items: stretch !important;
                justify-content: flex-start !important;
                padding: 6px 8px 6px !important;
                border-right: none !important;
                border-bottom: 1.5px solid var(--border-card) !important;
                box-shadow: 0 2px 8px rgba(0,0,0,0.06) !important;
                z-index: 100 !important;
                gap: 6px !important;
                background: rgba(255, 255, 255, 0.96) !important;
                backdrop-filter: none !important;
                -webkit-backdrop-filter: none !important;
                flex-shrink: 0 !important;
            }

            /* Hàng 1: Brand & Nút Thao tác */
            .sidebar-brand {
                padding: 0 !important;
                border-bottom: none !important;
                gap: 6px !important;
                display: flex !important;
                align-items: center !important;
                justify-content: space-between !important;
                width: 100% !important;
            }

            .sidebar-brand .brand-badge {
                width: 28px !important;
                height: 28px !important;
                font-size: 12px !important;
            }

            .sidebar-brand .brand-info h1 {
                font-size: 13px !important;
                font-weight: 800 !important;
                white-space: nowrap !important;
            }

            .sidebar-brand .brand-info p {
                display: none !important;
            }

            /* Hàng 2: THANH 2 TAB CHÍNH (TKB & SƠ ĐỒ) HIỂN THỊ CÂN XỨNG TO RÕ */
            .sidebar-nav {
                display: grid !important;
                grid-template-columns: repeat(2, 1fr) !important;
                gap: 6px !important;
                width: 100% !important;
                padding: 2px 0 !important;
                margin: 0 !important;
                overflow: hidden !important;
                flex-shrink: 0 !important;
            }

            .tab-btn {
                width: 100% !important;
                max-width: 100% !important;
                padding: 6px 2px !important;
                font-size: 10px !important;
                font-weight: 700 !important;
                border-radius: 6px !important;
                white-space: nowrap !important;
                text-align: center !important;
                border: 1px solid #cbd5e1 !important;
                background: #f8fafc !important;
                color: #475569 !important;
                display: flex !important;
                align-items: center !important;
                justify-content: center !important;
                overflow: hidden !important;
                text-overflow: ellipsis !important;
            }

            .tab-btn.active {
                color: #ffffff !important;
                background: var(--primary) !important;
                border-color: var(--primary) !important;
                font-weight: 800 !important;
                box-shadow: 0 1px 3px rgba(31, 78, 121, 0.3) !important;
            }

            /* NÚT THAO TÁC Ở SIDEBAR GỌN GÀNG */
            .sidebar-actions {
                display: flex !important;
                flex-direction: row !important;
                gap: 4px !important;
                margin: 0 !important;
                padding: 0 !important;
                border: none !important;
            }
            .sidebar-actions .btn {
                padding: 3px 6px !important;
                font-size: 10.5px !important;
                height: 26px !important;
                border-radius: 5px !important;
            }

            /* MAIN CONTAINER */
            .main-container {
                flex: 1 !important;
                height: calc(100vh - 84px) !important;
                height: calc(100dvh - 84px) !important;
                overflow-y: auto !important;
                overflow-x: hidden !important;
                padding: 6px 4px 20px !important;
                box-sizing: border-box !important;
                -webkit-overflow-scrolling: touch !important;
            }

            .card {
                padding: 6px 8px !important;
                border-radius: 12px !important;
                overflow-x: auto !important;
                -webkit-overflow-scrolling: touch !important;
            }

            /* BẢO ĐẢM SƠ ĐỒ CHỖ NGỒI VÀ BỤC GIẢNG NẰM TRÊN MẶT PHẲNG 680px, VUỐT NGANG MƯỢT MÀ, KHÔNG CO MÉO */
            .classroom-wrapper {
                overflow-x: visible !important;
                padding: 6px 4px !important;
                width: max-content !important;
                min-width: 680px !important;
                box-sizing: border-box !important;
            }

            .podium-area {
                width: 100% !important;
                min-width: 680px !important;
            }

            .rows-container {
                width: 100% !important;
                min-width: 680px !important;
            }

            .seating-row {
                display: grid !important;
                grid-template-columns: 1fr 22px 1fr 22px 1fr 22px 1fr !important;
                gap: 4px !important;
                width: 100% !important;
                min-width: 680px !important;
                box-sizing: border-box !important;
            }

            .double-desk {
                display: grid !important;
                grid-template-columns: 1fr 1fr !important;
                gap: 3px !important;
                box-sizing: border-box !important;
            }

            .seat-card {
                height: 68px !important;
                min-height: 68px !important;
                box-sizing: border-box !important;
            }

            .tkb-table-wrap {
                overflow-x: auto !important;
                -webkit-overflow-scrolling: touch !important;
                border-radius: 10px !important;
            }

            .tkb-table {
                min-width: 620px !important;
            }

            .tkb-header {
                flex-direction: column !important;
                align-items: flex-start !important;
                gap: 6px !important;
            }

            .seating-controls {
                flex-wrap: wrap !important;
                gap: 6px !important;
                min-width: 680px !important;
            }
        }
/* ===============================================================
   TVLS ENHANCED MODULES: GRADES, ADMISSION, ADMIN, PRIVACY & CONNECT
   =============================================================== */

/* 1. IMPERSONATION BANNER */
.impersonation-banner {
    background: #fef3c7;
    border-bottom: 2px solid #f59e0b;
    color: #92400e;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    z-index: 9999;
}
.btn-exit-impersonate {
    background: #b45309;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

/* 2. SỔ ĐIỂM THÔNG TƯ 22 */
.grades-header-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}
.grades-select-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.grades-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}
.summary-stat-card {
    background: #ffffff;
    border: 1px solid #dbe2ea;
    border-radius: 12px;
    padding: 14px 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.summary-stat-card .stat-label {
    font-size: 12px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.summary-stat-card .stat-value {
    font-size: 22px;
    font-weight: 800;
    color: var(--primary);
    line-height: 1.2;
}
.summary-stat-card .stat-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 6px;
    display: inline-block;
    width: fit-content;
}

/* SMART TARGET SOLVER TOOLBAR */
.smart-solver-bar {
    background: #f8fafc;
    border: 1.5px solid #dbe2ea;
    border-radius: 12px;
    padding: 12px 16px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}
.solver-target-box {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* GRADES TABLE */
.grades-table-wrap {
    overflow-x: auto;
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid #dbe2ea;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.grades-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}
.grades-table th {
    background: #f1f5f9;
    color: #1f4e79;
    font-weight: 700;
    padding: 10px 8px;
    text-align: center;
    border-bottom: 1.5px solid #dbe2ea;
    white-space: nowrap;
}
.grades-table td {
    padding: 8px 6px;
    border-bottom: 1px solid #edf2f7;
    text-align: center;
}
.grades-table td.subject-name-col {
    text-align: left;
    font-weight: 700;
    color: #0f172a;
    padding-left: 14px;
}
.score-cell-input {
    width: 48px;
    height: 32px;
    text-align: center;
    font-size: 13.5px;
    font-weight: 700;
    border: 1.5px solid #cbd5e1;
    border-radius: 6px;
    background: #ffffff;
    color: #0f172a;
    transition: all 0.15s ease;
}
.score-cell-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(31, 78, 121, 0.15);
}
.score-cell-input.predicted {
    background: #fef9c3;
    border-color: #f59e0b;
    color: #b45309;
    font-style: italic;
}
.score-avg-badge {
    display: inline-block;
    min-width: 42px;
    padding: 4px 8px;
    border-radius: 6px;
    font-weight: 800;
    font-size: 13px;
    background: #e8f1fa;
    color: #1f4e79;
}

/* 3. MÔ PHỎNG XÉT TUYỂN LỚP 10 */
.admission-grid {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 20px;
}
@media (max-width: 900px) {
    .admission-grid {
        grid-template-columns: 1fr;
    }
}
.admission-input-card {
    background: #ffffff;
    border: 1px solid #dbe2ea;
    border-radius: 12px;
    padding: 18px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.benchmark-card {
    background: #ffffff;
    border: 1px solid #dbe2ea;
    border-radius: 12px;
    padding: 14px 18px;
    margin-bottom: 12px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
    transition: all 0.2s ease;
}
.benchmark-card:hover {
    border-color: #2e75b6;
    box-shadow: 0 4px 12px rgba(31, 78, 121, 0.08);
}
.benchmark-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.benchmark-school-name {
    font-size: 15px;
    font-weight: 700;
    color: #1f4e79;
}
.benchmark-score-tag {
    font-size: 13px;
    font-weight: 800;
    padding: 3px 8px;
    border-radius: 6px;
}
.progress-bar-bg {
    width: 100%;
    height: 8px;
    background: #edf2f7;
    border-radius: 4px;
    overflow: hidden;
    margin: 6px 0;
}
.progress-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.4s ease;
}

/* 4. CÀI ĐẶT & KẾT NỐI PHỤ HUYNH */
.settings-section-card {
    background: #ffffff;
    border: 1px solid #dbe2ea;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.settings-title {
    font-size: 16px;
    font-weight: 800;
    color: #1f4e79;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.avatar-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    gap: 10px;
    margin-top: 10px;
}
.avatar-choice-btn {
    width: 50px;
    height: 50px;
    font-size: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid transparent;
    border-radius: 50%;
    background: #f1f5f9;
    cursor: pointer;
    transition: all 0.15s ease;
}
.avatar-choice-btn.selected {
    border-color: var(--primary);
    background: #e8f1fa;
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(31, 78, 121, 0.2);
}
.connect-code-box {
    background: #f8fafc;
    border: 2px dashed #2e75b6;
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    margin: 12px 0;
}
.connect-code-digits {
    font-size: 28px;
    font-weight: 900;
    letter-spacing: 4px;
    color: #1f4e79;
    font-family: var(--font-title);
}

/* 5. ADMIN WORKSPACE (TVU ONEGATE) */
.admin-card-header {
    background: linear-gradient(135deg, #1f4e79 0%, #2e75b6 100%);
    color: #ffffff;
    padding: 16px 22px;
    border-radius: 12px 12px 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}
.admin-card-header h2 {
    font-size: 17px;
    font-weight: 700;
    margin: 0;
}
.admin-subnav {
    display: flex;
    gap: 6px;
    background: #f1f5f9;
    padding: 4px;
    border-radius: 8px;
    margin-bottom: 16px;
}
.admin-subnav-btn {
    padding: 7px 14px;
    border: none;
    background: transparent;
    font-size: 13px;
    font-weight: 700;
    color: #64748b;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}
.admin-subnav-btn.active {
    background: #ffffff;
    color: #1f4e79;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* 6. PRIVACY POLICY MODAL */
.policy-modal-body {
    max-height: 70vh;
    overflow-y: auto;
    font-size: 14px;
    line-height: 1.6;
    color: #334155;
    padding-right: 8px;
}
.policy-commitment-item {
    background: #f8fafc;
    border-left: 4px solid #1f4e79;
    border-radius: 0 8px 8px 0;
    padding: 12px 16px;
    margin-bottom: 12px;
}
.policy-commitment-item h4 {
    margin: 0 0 4px;
    color: #1f4e79;
    font-size: 14.5px;
    font-weight: 800;
}
