/* ==========================================
   Q-TRACK MAIN STYLES
   ========================================== */
        body {
            font-family: 'Fredoka', sans-serif;
            background-color: #fdfbf7;
            background-image: url('bg-masjid.png');
            background-position: center bottom;
            background-repeat: repeat-x;
            background-size: contain;
            background-attachment: fixed;
            -webkit-tap-highlight-color: transparent;
        }

        /* OPTIMASI MESRA PERANTI (RESPONSIVE MOBILE FIRST) */
        html,
        body {
            overflow-x: hidden;
            width: 100%;
        }

        /* Elak iOS Safari auto-zoom pada input & butang */
        input,
        select,
        textarea,
        button {
            touch-action: manipulation;
            font-size: 16px !important;
        }

        @media (min-width: 768px) {

            input,
            select,
            textarea,
            button {
                font-size: 14px !important;
            }
        }

        .overflow-x-auto {
            -webkit-overflow-scrolling: touch;
        }

        .islamic-font {
            font-family: 'Amiri', serif;
        }

        /* --- TEMA KARTUN (NEO-BRUTALISM) OVERRIDES --- */

        /* Kad Utama & Container */
        .bg-white,
        .glass-card,
        .bg-emerald-50,
        .bg-blue-50,
        .bg-gray-50,
        .bg-orange-50 {
            background-color: rgba(255, 255, 255, 0.95) !important;
            border: 3px solid #000000 !important;
            border-radius: 16px !important;
            box-shadow: 5px 5px 0px #000000 !important;
            backdrop-filter: blur(8px) !important;
            margin-bottom: 12px;
        }

        /* Header Utama */
        header {
            border-bottom: 4px solid #000000 !important;
            box-shadow: 0px 6px 0px #000000 !important;
            background-color: #34d399 !important;
            border-radius: 0 0 20px 20px !important;
        }

        /* Butang */
        button,
        .btn {
            border: 3px solid #000000 !important;
            border-radius: 12px !important;
            box-shadow: 4px 4px 0px #000000 !important;
            transition: all 0.15s ease-in-out !important;
            font-weight: 700 !important;
        }

        button:hover,
        .btn:hover {
            transform: translate(-2px, -2px) !important;
            box-shadow: 6px 6px 0px #000000 !important;
        }

        button:active,
        .btn:active {
            transform: translate(4px, 4px) !important;
            box-shadow: 0px 0px 0px #000000 !important;
        }

        /* Butang Tindakan Dalam Jadual (Compact Table Action Buttons) */
        .tbl-act-btn {
            border: 2px solid #000000 !important;
            border-radius: 8px !important;
            box-shadow: 2px 2px 0px #000000 !important;
            padding: 4px 7px !important;
            font-size: 11px !important;
            line-height: 1 !important;
            display: inline-flex !important;
            align-items: center !important;
            justify-content: center !important;
        }

        .tbl-act-btn:hover {
            transform: translate(-1px, -1px) !important;
            box-shadow: 3px 3px 0px #000000 !important;
        }

        .tbl-act-btn:active {
            transform: translate(2px, 2px) !important;
            box-shadow: 0px 0px 0px #000000 !important;
        }

        /* Input & Select */
        input,
        select,
        textarea {
            border: 3px solid #000000 !important;
            border-radius: 12px !important;
            box-shadow: 3px 3px 0px #000000 !important;
            font-family: 'Fredoka', sans-serif !important;
            font-weight: 600 !important;
            background-color: #ffffff !important;
            transition: all 0.2s;
        }

        input:focus,
        select:focus,
        textarea:focus {
            outline: none !important;
            box-shadow: 5px 5px 0px #000000 !important;
            transform: translate(-1px, -1px);
        }

        /* Jadual (Tables) */
        table {
            border-collapse: separate !important;
            border-spacing: 0 !important;
            border: 3px solid #000000 !important;
            border-radius: 16px !important;
            overflow: hidden !important;
            box-shadow: 5px 5px 0px #000000 !important;
            background: white !important;
            width: 100% !important;
            margin-bottom: 10px;
        }

        thead {
            background-color: #fcd34d !important;
        }

        th,
        td {
            border-bottom: 2px solid #000000 !important;
            border-right: 2px solid #000000 !important;
        }

        th:last-child,
        td:last-child {
            border-right: none !important;
        }

        tr:last-child td {
            border-bottom: none !important;
        }

        /* Lencana (Badges) */
        span[class*="bg-"] {
            border: 2px solid #000000 !important;
            box-shadow: 2px 2px 0px #000000 !important;
            font-weight: 700 !important;
            border-radius: 8px !important;
        }

        /* ==========================================
           PENGECUALIAN MOD JADUAL MATRIKS (EXECUTIVE SPREADSHEET LOOK)
           ========================================== */
        #view-matrix-grid * {
            box-shadow: none !important;
        }

        #view-matrix-grid table {
            border-collapse: separate !important;
            border-spacing: 0 !important;
            border: 1.5px solid #cbd5e1 !important;
            border-radius: 12px !important;
            overflow: visible !important;
            background: #ffffff !important;
            width: 100% !important;
        }

        #view-matrix-grid thead tr {
            background-color: #f1f5f9 !important;
            box-shadow: none !important;
            border-radius: 0 !important;
        }

        #view-matrix-grid tbody tr,
        #view-matrix-grid tbody tr.bg-white,
        #view-matrix-grid tbody tr.glass-card,
        #view-matrix-grid tbody tr[class*="bg-"] {
            border-top: none !important;
            border-left: none !important;
            border-right: none !important;
            border-bottom: 1px solid #e2e8f0 !important;
            border-radius: 0 !important;
            box-shadow: none !important;
            margin-bottom: 0 !important;
            backdrop-filter: none !important;
        }

        .matrix-table-container {
            max-height: 75vh !important;
            overflow: auto !important;
            position: relative !important;
            -webkit-overflow-scrolling: touch !important;
        }

        #view-matrix-grid table thead {
            position: sticky !important;
            top: 0 !important;
            z-index: 35 !important;
        }

        #view-matrix-grid table thead th {
            position: sticky !important;
            top: 0 !important;
            z-index: 35 !important;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1) !important;
        }

        body:not(.dark-mode) #view-matrix-grid table thead th {
            background-color: #f1f5f9 !important;
            color: #0f172a !important;
        }

        body.dark-mode #view-matrix-grid table thead th {
            background-color: #0f172a !important;
            color: #ffffff !important;
        }

        /* --------------------------------------------------
           PEMAKSAAN LAJUR BERGANDA (BIL & NAMA MURID & REKOD TERKINI) STICKY LEFT
           -------------------------------------------------- */
        #view-matrix-grid table th:first-child,
        #view-matrix-grid table td:first-child {
            position: sticky !important;
            left: 0 !important;
            width: 220px !important;
            min-width: 220px !important;
            max-width: 220px !important;
            z-index: 30 !important;
            border-right: 1px solid #cbd5e1 !important;
            padding-left: 10px !important;
            padding-right: 8px !important;
        }

        #view-matrix-grid table th:nth-child(2),
        #view-matrix-grid table td:nth-child(2) {
            position: sticky !important;
            left: 220px !important;
            width: 115px !important;
            min-width: 115px !important;
            max-width: 115px !important;
            z-index: 30 !important;
            box-shadow: 4px 0 8px -2px rgba(0,0,0,0.15) !important; /* Bayangan pemisah lajur */
            border-right: 3px solid #0f766e !important; /* Garisan pemisah hijau padu tebal */
            padding-left: 4px !important;
            padding-right: 4px !important;
        }

        /* Background legap supaya teks skrol tidak nampak di belakang */
        body:not(.dark-mode) #view-matrix-grid table td:first-child {
            background-color: #ffffff !important;
        }

        body:not(.dark-mode) #view-matrix-grid table td:nth-child(2) {
            background-color: #ecfdf5 !important; /* Soft Emerald Background */
        }

        body.dark-mode #view-matrix-grid table td:first-child {
            background-color: #1e293b !important;
        }

        body.dark-mode #view-matrix-grid table td:nth-child(2) {
            background-color: #064e3b !important;
        }

        /* Bucu Atas Kiri (Intersection Sticky Top & Left) */
        #view-matrix-grid table thead th:first-child {
            position: sticky !important;
            top: 0 !important;
            left: 0 !important;
            z-index: 50 !important;
            width: 220px !important;
            min-width: 220px !important;
            max-width: 220px !important;
            border-right: 1px solid #cbd5e1 !important;
        }

        #view-matrix-grid table thead th:nth-child(2) {
            position: sticky !important;
            top: 0 !important;
            left: 220px !important;
            z-index: 50 !important;
            width: 115px !important;
            min-width: 115px !important;
            max-width: 115px !important;
            border-right: 3px solid #0f766e !important;
        }

        body:not(.dark-mode) #view-matrix-grid table thead th:first-child,
        body:not(.dark-mode) #view-matrix-grid table thead th:nth-child(2) {
            background-color: #d1fae5 !important;
            color: #064e3b !important;
        }

        body.dark-mode #view-matrix-grid table thead th:first-child,
        body.dark-mode #view-matrix-grid table thead th:nth-child(2) {
            background-color: #064e3b !important;
            color: #ffffff !important;
        }

        /* --------------------------------------------------
           MOD SPREADSHEET PENUH & ZOOM
           -------------------------------------------------- */
        .matrix-table-container {
            touch-action: pan-x pan-y pinch-zoom !important;
            overflow-x: auto !important;
            -webkit-overflow-scrolling: touch !important;
        }

        .matrix-table-container table {
            min-width: 1550px !important;
        }

        /* --------------------------------------------------
           PENYESUAIAN KHAS MOD POTRET TELEFON BIMBIT (< 768px)
           -------------------------------------------------- */
        @media (max-width: 768px) and (orientation: portrait) {
            #view-matrix-grid:not(.matrix-fullscreen-active) table th:first-child,
            #view-matrix-grid:not(.matrix-fullscreen-active) table td:first-child,
            #view-matrix-grid:not(.matrix-fullscreen-active) table thead th:first-child {
                width: 135px !important;
                min-width: 135px !important;
                max-width: 135px !important;
                padding-left: 6px !important;
                padding-right: 4px !important;
                font-size: 11px !important;
            }

            #view-matrix-grid:not(.matrix-fullscreen-active) table th:nth-child(2),
            #view-matrix-grid:not(.matrix-fullscreen-active) table td:nth-child(2),
            #view-matrix-grid:not(.matrix-fullscreen-active) table thead th:nth-child(2) {
                left: 135px !important;
                width: 90px !important;
                min-width: 90px !important;
                max-width: 90px !important;
                padding-left: 2px !important;
                padding-right: 2px !important;
                font-size: 9.5px !important;
            }
        }

        /* --------------------------------------------------
           MOD SKRIN PENUH & LANSKAP MATRIKS (FULLSCREEN OVERLAY)
           -------------------------------------------------- */
        #view-matrix-grid.matrix-fullscreen-active {
            position: fixed !important;
            inset: 0 !important;
            width: 100vw !important;
            height: 100vh !important;
            z-index: 99999 !important;
            background-color: #f8fafc !important;
            padding: 8px !important;
            overflow-y: auto !important;
            box-sizing: border-box !important;
            margin: 0 !important;
        }

        body.dark-mode #view-matrix-grid.matrix-fullscreen-active {
            background-color: #090d16 !important;
        }

        #view-matrix-grid.matrix-fullscreen-active .matrix-table-container {
            max-height: calc(100vh - 120px) !important;
            height: calc(100vh - 120px) !important;
        }

        /* Butang Apung Keluar Skrin Penuh (Floating Exit Button) */
        .btn-matrix-floating-exit {
            display: none;
            position: fixed;
            bottom: 16px;
            right: 16px;
            z-index: 100000;
            box-shadow: 0 4px 15px rgba(0,0,0,0.3);
            animation: pulseFloatingBtn 2s infinite;
        }

        #view-matrix-grid.matrix-fullscreen-active .btn-matrix-floating-exit {
            display: flex !important;
        }

        @keyframes pulseFloatingBtn {
            0%, 100% { transform: scale(1); }
            50% { transform: scale(1.05); }
        }

        /* Sticky Row Baris Guru Tasmik */
        #view-matrix-grid table tr.matrix-guru-header td {
            position: sticky !important;
            top: 36px !important;
            z-index: 30 !important;
        }

        #view-matrix-grid td {
            border-right: 1px solid #e2e8f0 !important;
            border-bottom: 1px solid #e2e8f0 !important;
            vertical-align: middle !important;
            padding: 5px 6px !important;
        }

        #view-matrix-grid th:last-child,
        #view-matrix-grid td:last-child {
            border-right: none !important;
        }

        #view-matrix-grid input,
        #view-matrix-grid select {
            border: 1px solid #cbd5e1 !important;
            border-radius: 6px !important;
            background-color: #ffffff !important;
            font-size: 12px !important;
        }

        #view-matrix-grid input:focus,
        #view-matrix-grid select:focus {
            border-color: #10b981 !important;
            outline: 2px solid #10b981 !important;
            outline-offset: -1px !important;
        }

        #view-matrix-grid button {
            border: none !important;
            border-radius: 6px !important;
        }

        #view-matrix-grid span[class*="bg-"] {
            border: none !important;
            border-radius: 20px !important;
        }

        /* ==========================================
           PENGESANAN KURSOR & BARIS AKTIF (ROW HIGHLIGHT & ACTIVE FOCUS)
           ========================================== */
        #view-matrix-grid table tbody tr {
            transition: background-color 0.15s ease, box-shadow 0.15s ease !important;
            cursor: pointer;
        }

        #view-matrix-grid table tbody tr td:first-child {
            transition: background-color 0.15s ease, border-left 0.15s ease, color 0.15s ease !important;
        }

        /* 1. HOVER HIGHLIGHT (KURSOR DIHALAKAN KE BARIS MURID) - LIGHT MODE */
        body:not(.dark-mode) #view-matrix-grid table tbody tr:not(.matrix-guru-header):hover {
            background-color: #fef9c3 !important; /* Soft Canary Yellow Glow */
        }
        body:not(.dark-mode) #view-matrix-grid table tbody tr:not(.matrix-guru-header):hover td {
            background-color: #fef9c3 !important;
        }
        body:not(.dark-mode) #view-matrix-grid table tbody tr:not(.matrix-guru-header):hover td:first-child {
            background-color: #fef08a !important; /* Vivid Light Amber */
            border-left: 5px solid #059669 !important; /* Emerald Indicator Pin */
            color: #064e3b !important;
        }
        body:not(.dark-mode) #view-matrix-grid table tbody tr:not(.matrix-guru-header):hover td:nth-child(2) {
            background-color: #dcfce7 !important;
        }

        /* 2. ACTIVE / FOCUS HIGHLIGHT (SEDANG MENGISI INPUT / KLIK PADA BARIS) - LIGHT MODE */
        body:not(.dark-mode) #view-matrix-grid table tbody tr:not(.matrix-guru-header):focus-within,
        body:not(.dark-mode) #view-matrix-grid table tbody tr.matrix-row-active {
            background-color: #fef3c7 !important; /* Warm Amber Active */
            box-shadow: inset 0 0 0 1.5px #f59e0b !important;
        }
        body:not(.dark-mode) #view-matrix-grid table tbody tr:not(.matrix-guru-header):focus-within td,
        body:not(.dark-mode) #view-matrix-grid table tbody tr.matrix-row-active td {
            background-color: #fef3c7 !important;
        }
        body:not(.dark-mode) #view-matrix-grid table tbody tr:not(.matrix-guru-header):focus-within td:first-child,
        body:not(.dark-mode) #view-matrix-grid table tbody tr.matrix-row-active td:first-child {
            background-color: #fde047 !important; /* Bright Gold Accent */
            border-left: 6px solid #d97706 !important; /* Prominent Amber Bar */
            color: #78350f !important;
            font-weight: 900 !important;
        }
        body:not(.dark-mode) #view-matrix-grid table tbody tr:not(.matrix-guru-header):focus-within td:nth-child(2),
        body:not(.dark-mode) #view-matrix-grid table tbody tr.matrix-row-active td:nth-child(2) {
            background-color: #fef08a !important;
        }

        /* 3. HOVER HIGHLIGHT - DARK MODE */
        body.dark-mode #view-matrix-grid table tbody tr:not(.matrix-guru-header):hover {
            background-color: #334155 !important;
        }
        body.dark-mode #view-matrix-grid table tbody tr:not(.matrix-guru-header):hover td {
            background-color: #334155 !important;
        }
        body.dark-mode #view-matrix-grid table tbody tr:not(.matrix-guru-header):hover td:first-child {
            background-color: #1e293b !important;
            border-left: 5px solid #10b981 !important;
            color: #f8fafc !important;
        }
        body.dark-mode #view-matrix-grid table tbody tr:not(.matrix-guru-header):hover td:nth-child(2) {
            background-color: #064e3b !important;
        }

        /* 4. ACTIVE / FOCUS HIGHLIGHT - DARK MODE */
        body.dark-mode #view-matrix-grid table tbody tr:not(.matrix-guru-header):focus-within,
        body.dark-mode #view-matrix-grid table tbody tr.matrix-row-active {
            background-color: #0f172a !important;
            box-shadow: inset 0 0 0 1.5px #38bdf8 !important;
        }
        body.dark-mode #view-matrix-grid table tbody tr:not(.matrix-guru-header):focus-within td,
        body.dark-mode #view-matrix-grid table tbody tr.matrix-row-active td {
            background-color: #0f172a !important;
        }
        body.dark-mode #view-matrix-grid table tbody tr:not(.matrix-guru-header):focus-within td:first-child,
        body.dark-mode #view-matrix-grid table tbody tr.matrix-row-active td:first-child {
            background-color: #1e3a8a !important;
            border-left: 6px solid #38bdf8 !important;
            color: #ffffff !important;
            font-weight: 900 !important;
        }
        body.dark-mode #view-matrix-grid table tbody tr:not(.matrix-guru-header):focus-within td:nth-child(2),
        body.dark-mode #view-matrix-grid table tbody tr.matrix-row-active td:nth-child(2) {
            background-color: #0c4a6e !important;
        }

        /* ==========================================
           1. MOD CERAH (LIGHT MODE) - KONTRAST MAKSIMUM (100% JELAS & TAJAM)
           ========================================== */
        body:not(.dark-mode) #view-matrix-grid table {
            background-color: #ffffff !important;
            border-color: #cbd5e1 !important;
            color: #0f172a !important;
        }

        body:not(.dark-mode) #view-matrix-grid thead tr {
            background-color: #f1f5f9 !important;
            border-bottom-color: #94a3b8 !important;
        }

        body:not(.dark-mode) #view-matrix-grid th {
            color: #0f172a !important;
            border-color: #cbd5e1 !important;
            background-color: #f1f5f9 !important;
            font-weight: 800 !important;
        }

        body:not(.dark-mode) #view-matrix-grid td {
            border-color: #e2e8f0 !important;
            color: #0f172a !important;
        }

        /* Murid & Teks dalam Light Mode */
        body:not(.dark-mode) #view-matrix-grid td,
        body:not(.dark-mode) #view-matrix-grid td span,
        body:not(.dark-mode) #view-matrix-grid td div {
            color: #0f172a !important;
        }

        /* Tarikh Sejarah Dalam Light Mode (Warna Gelap Tajam, BUKAN Kuning/Oren!) */
        body:not(.dark-mode) #view-matrix-grid .matrix-date-past {
            color: #047857 !important; /* Deep Emerald Green */
            font-weight: 800 !important;
        }

        body:not(.dark-mode) #view-matrix-grid .matrix-ms-past {
            color: #0f172a !important; /* Solid Slate Black */
            font-weight: 900 !important;
        }

        body:not(.dark-mode) #view-matrix-grid .matrix-iqra-past {
            color: #1d4ed8 !important; /* Deep Royal Blue */
            font-weight: 800 !important;
        }

        body:not(.dark-mode) #view-matrix-grid .matrix-khatam-past {
            color: #be185d !important; /* Deep Pink */
            font-weight: 900 !important;
        }

        /* Input & Select Dalam Light Mode */
        body:not(.dark-mode) #view-matrix-grid input,
        body:not(.dark-mode) #view-matrix-grid select,
        body:not(.dark-mode) #matrix-grid-select-guru,
        body:not(.dark-mode) #matrix-tarikh-input,
        body:not(.dark-mode) #matrix-kelas-select {
            background-color: #ffffff !important;
            color: #0f172a !important;
            border-color: #94a3b8 !important;
            font-weight: 700 !important;
        }

        /* ==========================================
           2. MOD GELAP (DARK MODE) - KONTRAST MAKSIMUM (100% JELAS & TAJAM)
           ========================================== */
        body.dark-mode #view-matrix-grid table {
            background-color: #1e293b !important;
            border-color: #475569 !important;
            color: #ffffff !important;
        }

        body.dark-mode #view-matrix-grid thead tr {
            background-color: #0f172a !important;
            border-bottom-color: #64748b !important;
        }

        body.dark-mode #view-matrix-grid th {
            color: #f8fafc !important;
            border-color: #475569 !important;
            background-color: #0f172a !important;
            font-size: 11.5px !important;
        }

        body.dark-mode #view-matrix-grid td {
            border-color: #334155 !important;
            color: #ffffff !important;
        }

        /* MEMATIKAN OVERLAY KELABU MEMUTIH DALAM MOD GELAP */
        body.dark-mode #view-matrix-grid td[class*="bg-slate-50"],
        body.dark-mode #view-matrix-grid td[class*="bg-emerald-50"],
        body.dark-mode #view-matrix-grid td[class*="bg-emerald-100"] {
            background-color: rgba(15, 23, 42, 0.4) !important;
        }

        body.dark-mode #view-matrix-grid td:nth-child(9) { /* REKOD TERKINI (-1) */
            background-color: rgba(6, 78, 59, 0.5) !important; /* Deep Dark Emerald for Latest Record */
        }

        body.dark-mode #view-matrix-grid tbody tr {
            background-color: #1e293b !important;
            border-bottom: 1px solid #334155 !important;
        }

        body.dark-mode #view-matrix-grid tbody tr:nth-child(even) {
            background-color: #182232 !important;
        }

        body.dark-mode #view-matrix-grid tbody tr:hover {
            background-color: #334155 !important;
        }

        /* Tarikh Sejarah Dalam Dark Mode (Kuning Amber Emas Menyala) */
        body.dark-mode #view-matrix-grid .matrix-date-past {
            color: #fbbf24 !important; /* Bright Amber Gold */
            font-weight: 800 !important;
        }

        body.dark-mode #view-matrix-grid .matrix-ms-past {
            color: #ffffff !important; /* Pure White */
            font-weight: 900 !important;
        }

        body.dark-mode #view-matrix-grid .matrix-iqra-past {
            color: #93c5fd !important; /* Light Sky Blue */
            font-weight: 800 !important;
        }

        body.dark-mode #view-matrix-grid .matrix-khatam-past {
            color: #f472b6 !important; /* Bright Pink */
            font-weight: 900 !important;
        }

        /* INPUT & SELECT IN HIGH CONTRAST DARK MODE */
        body.dark-mode #view-matrix-grid input,
        body.dark-mode #view-matrix-grid select,
        body.dark-mode #matrix-grid-select-guru,
        body.dark-mode #matrix-tarikh-input,
        body.dark-mode #matrix-kelas-select {
            background-color: #0f172a !important;
            color: #ffffff !important;
            border-color: #64748b !important;
            font-weight: 800 !important;
        }

        body.dark-mode #view-matrix-grid select option,
        body.dark-mode #matrix-grid-select-guru option,
        body.dark-mode #matrix-kelas-select option {
            background-color: #0f172a !important;
            color: #ffffff !important;
        }

        body.dark-mode #view-matrix-grid input:focus,
        body.dark-mode #view-matrix-grid select:focus,
        body.dark-mode #matrix-grid-select-guru:focus,
        body.dark-mode #matrix-tarikh-input:focus {
            border-color: #34d399 !important;
            outline: 2px solid #34d399 !important;
        }

        /* ==========================================
           TAB NAVIGATION BUTTONS - RESPONSIVE MOBILE FIT
           ========================================== */
        .tab-btn {
            border: none !important;
            box-shadow: none !important;
            border-radius: 12px !important;
            white-space: nowrap !important;
            flex-shrink: 0 !important;
            padding: 8px 12px !important;
            font-size: 11.5px !important;
            font-weight: 800 !important;
            min-height: 38px !important;
            margin-bottom: 0 !important;
        }

        body:not(.dark-mode) .tab-btn:not(.active-tab) {
            background-color: transparent !important;
            color: #065f46 !important;
        }

        body:not(.dark-mode) .tab-btn.active-tab {
            background-color: #059669 !important;
            color: #ffffff !important;
            box-shadow: 0 4px 10px rgba(5, 150, 105, 0.35) !important;
        }

        body.dark-mode .tab-btn:not(.active-tab) {
            background-color: transparent !important;
            color: #a7f3d0 !important;
        }

        body.dark-mode .tab-btn.active-tab {
            background-color: #10b981 !important;
            color: #022c22 !important;
            box-shadow: 0 4px 10px rgba(16, 185, 129, 0.4) !important;
        }

        @media (min-width: 640px) {
            .tab-btn {
                flex: 1 1 0% !important;
                font-size: 12px !important;
            }
        }

        /* Navigasi Bawah (Bottom Nav) */
        .fixed.bottom-0 {
            border-top: 4px solid #000000 !important;
            box-shadow: 0px -4px 0px #000000 !important;
            border-radius: 24px 24px 0 0 !important;
            background-color: #ffffff !important;
        }

        /* Modal Overlay */
        .bg-black\/50 {
            background-color: rgba(0, 0, 0, 0.75) !important;
            backdrop-filter: blur(3px);
        }

        .modal {
            display: none;
            position: fixed;
            inset: 0;
            background-color: rgba(0, 0, 0, 0.7);
            backdrop-filter: blur(6px);
            -webkit-backdrop-filter: blur(6px);
            z-index: 9999;
            align-items: center;
            justify-content: center;
            padding: 1rem;
        }

        .loading-overlay {
            display: none;
            position: fixed;
            inset: 0;
            background: rgba(255, 255, 255, 0.8);
            z-index: 200;
            align-items: center;
            justify-content: center;
        }

        @keyframes spin {
            0% {
                transform: rotate(0deg);
            }

            100% {
                transform: rotate(360deg);
            }
        }

        .spinner {
            border: 4px solid #f3f3f3;
            border-top: 4px solid #10b981;
            border-radius: 50%;
            width: 40px;
            height: 40px;
            animation: spin 1s linear infinite;
        }

        /* Custom Scrollbar Global & Matriks */
        ::-webkit-scrollbar {
            width: 8px;
            height: 8px;
        }

        ::-webkit-scrollbar-track {
            background: #f1f5f9;
            border-radius: 6px;
        }

        ::-webkit-scrollbar-thumb {
            background: #10b981;
            border-radius: 6px;
            border: 1.5px solid #f1f5f9;
        }

        ::-webkit-scrollbar-thumb:hover {
            background: #059669;
        }

        /* Khusus Jadual Matriks - Scrollbar Tebal & Mesra Laptop */
        .matrix-table-container {
            scrollbar-width: auto;
            scrollbar-color: #10b981 #e2e8f0;
        }

        .matrix-table-container::-webkit-scrollbar {
            width: 14px;
            height: 14px;
        }

        .matrix-table-container::-webkit-scrollbar-track {
            background: #e2e8f0;
            border-radius: 8px;
            box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.05);
        }

        .matrix-table-container::-webkit-scrollbar-thumb {
            background: #10b981;
            border-radius: 8px;
            border: 3px solid #e2e8f0;
            transition: background-color 0.2s ease;
        }

        .matrix-table-container::-webkit-scrollbar-thumb:hover {
            background: #059669;
        }

        .matrix-table-container::-webkit-scrollbar-thumb:active {
            background: #047857;
        }

        /* Dark Mode Scrollbar Matriks */
        body.dark-mode .matrix-table-container::-webkit-scrollbar-track {
            background: #1e293b;
        }

        body.dark-mode .matrix-table-container::-webkit-scrollbar-thumb {
            background: #059669;
            border: 3px solid #1e293b;
        }

        body.dark-mode .matrix-table-container::-webkit-scrollbar-thumb:hover {
            background: #10b981;
        }

        .no-scrollbar::-webkit-scrollbar {
            display: none;
        }

        .no-scrollbar {
            -ms-overflow-style: none;
            scrollbar-width: none;
        }

        /* Progress Bar Animation */
        .bar-grow {
            transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
        }

        /* Pulse Dot for Live Status */
        .live-dot {
            height: 8px;
            width: 8px;
            background-color: #10b981;
            border-radius: 50%;
            display: inline-block;
            box-shadow: 0 0 0 0 rgba(16, 185, 129, 1);
            animation: pulse-green 2s infinite;
        }

        @keyframes pulse-green {
            0% {
                transform: scale(0.95);
                box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
            }

            70% {
                transform: scale(1);
                box-shadow: 0 0 0 4px rgba(16, 185, 129, 0);
            }

            100% {
                transform: scale(0.95);
                box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
            }
        }

        /* ========================================================
           CSS CETAKAN RASMI (PRINT OPTIMIZATION)
           ======================================================== */
        @page {
            size: A4 portrait;
            margin: 10mm;
        }

        @media print {
            body {
                background: white !important;
                background-image: none !important;
                -webkit-print-color-adjust: exact !important;
                print-color-adjust: exact !important;
            }

            .no-print {
                display: none !important;
            }

            #section-profil .glass-card {
                box-shadow: none !important;
                border: none !important;
                padding: 0 !important;
                background: transparent !important;
            }

            #profil-print-area {
                border: none !important;
                box-shadow: none !important;
                padding: 0 !important;
            }

            table {
                page-break-inside: auto;
            }

            tr {
                page-break-inside: avoid;
                page-break-after: auto;
            }

            .break-inside-avoid {
                page-break-inside: avoid;
                break-inside: avoid;
            }
        }

        /* ==========================================
           REKA BENTUK MOD GELAP (DARK MODE) PERFECT CONTRAST
           ========================================== */
        body.dark-mode {
            background-color: #0f172a !important;
            /* slate-900 */
            background-image: linear-gradient(rgba(15, 23, 42, 0.88), rgba(15, 23, 42, 0.93)), url('bg-masjid.png') !important;
            background-position: center bottom !important;
            background-repeat: repeat-x !important;
            background-size: contain !important;
            background-attachment: fixed !important;
            color: #f8fafc !important;
        }

        body.dark-mode .bg-white,
        body.dark-mode .glass-card {
            background-color: #1e293b !important;
            /* slate-800 */
            color: #f8fafc !important;
            border-color: #334155 !important;
        }

        /* PERKATAAN KELABU KINI TERANG & JELAS DALAM DARK MODE */
        body.dark-mode .text-gray-400,
        body.dark-mode .text-gray-500,
        body.dark-mode .text-gray-600,
        body.dark-mode .text-gray-700,
        body.dark-mode .text-gray-800,
        body.dark-mode .text-gray-900,
        body.dark-mode .text-slate-400,
        body.dark-mode .text-slate-500,
        body.dark-mode .text-slate-600,
        body.dark-mode .text-slate-700 {
            color: #cbd5e1 !important;
            /* slate-300 */
        }

        /* KOTAK CATATAN & CONTAINER SAMPINGAN */
        body.dark-mode .bg-gray-50,
        body.dark-mode .bg-emerald-50\/50,
        body.dark-mode .bg-indigo-50\/50 {
            background-color: #334155 !important;
            /* slate-700 */
            color: #f8fafc !important;
            border-color: #475569 !important;
        }

        body.dark-mode .bg-emerald-50 {
            background-color: #064e3b !important;
            color: #6ee7b7 !important;
        }

        body.dark-mode .bg-blue-50 {
            background-color: #1e3a8a !important;
            color: #93c5fd !important;
        }

        body.dark-mode .bg-orange-50 {
            background-color: #7c2d12 !important;
            color: #fdba74 !important;
        }

        body.dark-mode .bg-purple-50 {
            background-color: #581c87 !important;
            color: #e9d5ff !important;
        }

        body.dark-mode .bg-indigo-50 {
            background-color: #312e81 !important;
            color: #c7d2fe !important;
        }

        body.dark-mode input,
        body.dark-mode select,
        body.dark-mode textarea {
            background-color: #0f172a !important;
            color: #ffffff !important;
            border-color: #475569 !important;
        }

        body.dark-mode input::placeholder,
        body.dark-mode textarea::placeholder {
            color: #94a3b8 !important;
        }

        body.dark-mode table {
            background: #1e293b !important;
            color: #f8fafc !important;
            border-color: #334155 !important;
        }

        body.dark-mode th {
            background-color: #334155 !important;
            color: #ffffff !important;
            border-color: #475569 !important;
        }

        body.dark-mode td {
            border-color: #334155 !important;
            color: #e2e8f0 !important;
        }

        body.dark-mode tr:hover {
            background-color: #334155 !important;
        }

        body.dark-mode header,
        body.dark-mode nav {
            background-color: #064e3b !important;
            /* emerald-950 */
            border-color: #000000 !important;
        }

        body.dark-mode .text-emerald-800,
        body.dark-mode .text-emerald-700,
        body.dark-mode .text-teal-600 {
            color: #34d399 !important;
            /* emerald-400 */
        }

        body.dark-mode .text-indigo-700,
        body.dark-mode .text-blue-600 {
            color: #818cf8 !important;
            /* indigo-400 */
        }

        body.dark-mode .text-black,
        body.dark-mode .text-slate-900 {
            color: #f8fafc !important;
        }

        body.dark-mode .border-gray-100,
        body.dark-mode .border-gray-200,
        body.dark-mode .border-gray-300 {
            border-color: #334155 !important;
        }

        /* ==========================================
           TEMA WARNA SISTEM (THEMES) - SAFE OVERRIDES
           ========================================== */
        body.theme-navy nav {
            background-color: #1e3a8a !important;
            /* Navy Blue */
        }

        body.theme-navy .bg-emerald-600 {
            background-color: #1e40af !important;
        }

        body.theme-navy .hover\:bg-emerald-700:hover {
            background-color: #1e3a8a !important;
        }

        body.theme-navy .border-emerald-600 {
            border-color: #1e40af !important;
        }

        body.theme-turquoise nav {
            background-color: #0f766e !important;
            /* Deep Teal */
        }

        body.theme-turquoise .bg-emerald-600 {
            background-color: #0d9488 !important;
        }

        body.theme-turquoise .hover\:bg-emerald-700:hover {
            background-color: #0f766e !important;
        }

        /* ==========================================
           EXCEL PARSER (SHEETJS)
           ========================================== */

/* ==========================================
   HELP CHATBOX STYLES
   ========================================== */
        @keyframes helpPulse {

            0%,
            100% {
                transform: scale(1);
                box-shadow: 0 4px 20px rgba(5, 150, 105, 0.5);
            }

            50% {
                transform: scale(1.06);
                box-shadow: 0 6px 28px rgba(5, 150, 105, 0.7);
            }
        }

        #help-chat-btn:hover {
            transform: scale(1.1) !important;
            animation: none !important;
        }

        .help-faq-btn {
            background: white;
            border: 1.5px solid #6ee7b7;
            color: #065f46;
            font-family: 'Fredoka', sans-serif;
            font-size: 11px;
            font-weight: 600;
            padding: 5px 10px;
            border-radius: 20px;
            cursor: pointer;
            transition: all 0.2s;
        }

        .help-faq-btn:hover {
            background: #059669;
            color: white;
            border-color: #059669;
            transform: translateY(-1px);
        }

        #help-chat-messages::-webkit-scrollbar {
            width: 4px;
        }

        #help-chat-messages::-webkit-scrollbar-track {
            background: transparent;
        }

        #help-chat-messages::-webkit-scrollbar-thumb {
            background: #6ee7b7;
            border-radius: 4px;
        }

        /* AI Auto-Navigator Glow Effect */
        @keyframes aiGlowPulse {
            0% { box-shadow: 0 0 0 0px rgba(16, 185, 129, 0.8), 0 0 20px rgba(16, 185, 129, 0.6); transform: scale(1.01); }
            50% { box-shadow: 0 0 0 14px rgba(16, 185, 129, 0), 0 0 35px rgba(16, 185, 129, 0.9); transform: scale(1.02); }
            100% { box-shadow: 0 0 0 0px rgba(16, 185, 129, 0), 0 0 0px rgba(16, 185, 129, 0); transform: scale(1); }
        }
        .ai-glow-highlight {
            animation: aiGlowPulse 1.2s ease-in-out 2 !important;
            border-color: #10b981 !important;
            border-width: 3px !important;
            position: relative;
            z-index: 30;
        }

        /* ==========================================
           MEDIA PRINT - QTRACK GURU
           ========================================== */
        @media print {
            .no-print,
            nav,
            header,
            footer,
            #help-chat-widget,
            #loading,
            .modal,
            button,
            .btn,
            #tab-nav,
            #section-tambah,
            #section-tetapan,
            #sidebar-filter,
            #banner-mobile-pc-recommendation {
                display: none !important;
            }

            body {
                background: white !important;
                background-image: none !important;
                font-size: 11px;
            }

            .glass-card,
            .bg-white {
                box-shadow: none !important;
                border: 1px solid #ccc !important;
            }

            table {
                box-shadow: none !important;
                font-size: 10px;
            }

            #section-dashboard,
            #section-analisis {
                display: block !important;
            }

            .overflow-x-auto {
                overflow: visible !important;
            }
        }

        /* Toast Notification */
        #qtrack-toast {
            transition: opacity 0.4s ease !important;
        }

        /* CETAKAN SIJIL KHAS (A4 LANDSCAPE) */
        @media print {
            body.printing-sijil > *:not(#modal-sijil-qtrack) {
                display: none !important;
            }
            body.printing-sijil #modal-sijil-qtrack {
                position: fixed !important;
                inset: 0 !important;
                background: white !important;
                padding: 0 !important;
                margin: 0 !important;
                display: flex !important;
                align-items: center !important;
                justify-content: center !important;
                z-index: 999999 !important;
                width: 100vw !important;
                height: 100vh !important;
            }
            body.printing-sijil .no-print-sijil {
                display: none !important;
            }
            body.printing-sijil #sijil-print-area {
                width: 100vw !important;
                height: 100vh !important;
                border-width: 12pt !important;
                box-shadow: none !important;
                border-radius: 0 !important;
                page-break-after: always;
                page-break-inside: avoid;
            }
            @page {
                size: A4 landscape;
                margin: 0;
            }
        }

        /* ==========================================
           FULLSCREEN STYLING FOR QURAN & IQRA MODALS
           ========================================== */
        #modal-quran:fullscreen,
        #modal-quran-portal:fullscreen,
        #modal-iqra:fullscreen,
        #modal-iqra-portal:fullscreen {
            width: 100vw !important;
            height: 100vh !important;
            max-width: 100vw !important;
            max-height: 100vh !important;
            padding: 0 !important;
            margin: 0 !important;
            border-radius: 0 !important;
            border: none !important;
            background-color: #f0f9ff !important;
            overflow: hidden !important;
        }

        #modal-quran:fullscreen .glass-card,
        #modal-quran-portal:fullscreen .glass-card,
        #modal-iqra:fullscreen .glass-card,
        #modal-iqra-portal:fullscreen .glass-card,
        #modal-quran .glass-card:fullscreen,
        #modal-quran-portal .glass-card:fullscreen,
        #modal-iqra .glass-card:fullscreen,
        #modal-iqra-portal .glass-card:fullscreen {
            max-width: 100vw !important;
            width: 100vw !important;
            max-height: 100vh !important;
            height: 100vh !important;
            border: none !important;
            border-radius: 0 !important;
            box-shadow: none !important;
            background-color: #ffffff !important;
            margin: 0 !important;
            padding: 12px !important;
        }

        /* Fullscreen Dark Mode */
        body.dark-mode #modal-quran:fullscreen,
        body.dark-mode #modal-quran-portal:fullscreen,
        body.dark-mode #modal-iqra:fullscreen,
        body.dark-mode #modal-iqra-portal:fullscreen,
        body.dark-mode #modal-quran .glass-card:fullscreen,
        body.dark-mode #modal-quran-portal .glass-card:fullscreen,
        body.dark-mode #modal-iqra .glass-card:fullscreen,
        body.dark-mode #modal-iqra-portal .glass-card:fullscreen {
            background-color: #1e293b !important;
        }

        /* ==========================================
           PENUNJUK MENGAJI / IQRA POINTING FINGER CURSOR
           ========================================== */
        .iqra-pointer-cursor,
        .iqra-pointer-cursor canvas,
        .iqra-pointer-cursor img {
            cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='36' height='36' viewBox='0 0 36 36'%3E%3Cfilter id='shadow' x='-10%25' y='-10%25' width='130%25' height='130%25'%3E%3CfeDropShadow dx='1' dy='2' stdDeviation='1.2' flood-color='%23000000' flood-opacity='0.4'/%3E%3C/filter%3E%3Cg filter='url(%23shadow)' transform='rotate(-15 14 14)'%3E%3Cpath d='M12,2 C13.3,2 14.3,3 14.3,4.5 L14.3,13.5 C15.1,12.8 16,12.5 17,12.8 C18,13.1 18.6,14 18.6,15 L18.6,15.5 C19.3,14.8 20.3,14.6 21.3,15 C22.2,15.4 22.8,16.3 22.8,17.3 L22.8,18 C23.4,17.5 24.4,17.4 25.2,17.9 C26.1,18.4 26.6,19.4 26.6,20.5 L26.6,23 C26.6,27.5 22.8,31 18,31 L14.5,31 C10.5,31 7,27.5 7,23.5 L7,16.5 C7,15.1 8.1,14 9.5,14 C10.9,14 12,15.1 12,16.5 L12,4.5 C12,3 13,2 14,2 Z' fill='%23fcd34d' stroke='%2378350f' stroke-width='1.8' stroke-linejoin='round' stroke-linecap='round'/%3E%3Cpath d='M7,24 L26.6,24 L26.6,31 L7,31 Z' fill='%23059669' stroke='%23064e3b' stroke-width='1.5' stroke-linejoin='round'/%3E%3C/g%3E%3C/svg%3E") 6 2, pointer !important;
        }

        /* ==========================================
           AUTO-CROP & FOCUS VERSE MODAL (CADANGAN 2)
           ========================================== */
        .focus-crop-overlay {
            position: absolute;
            inset: 0;
            background: rgba(0, 0, 0, 0.85);
            backdrop-filter: blur(6px);
            z-index: 60;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            padding: 12px;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.3s ease;
        }

        .focus-crop-overlay.active {
            opacity: 1;
            pointer-events: auto;
        }

        .focus-crop-card {
            background: #ffffff;
            border: 3px solid #059669;
            border-radius: 20px;
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5), 0 0 25px rgba(16, 185, 129, 0.35);
            max-width: 96%;
            max-height: 85%;
            width: auto;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            padding: 14px;
            position: relative;
            transform: scale(0.92);
            transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        }

        .focus-crop-overlay.active .focus-crop-card {
            transform: scale(1);
        }

        .focus-crop-img {
            max-width: 100%;
            max-height: 65vh;
            object-fit: contain;
            border-radius: 12px;
            box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
            border: 1px solid #e5e7eb;
        }
