:root {
            --primary: #d32f2f; 
            --primary-dark: #b71c1c; 
            --dark: #1a1a1a; 
            --light: #f4f4f4; 
            --white: #ffffff; 
            --gray: #cccccc;
            --text-dark: #333333;
        }
        * { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; }
        body { background-color: var(--light); color: var(--text-dark); }
        
        #login_screen { height: 100vh; display: flex; flex-direction: column; justify-content: center; align-items: center; background: var(--white); padding: 20px; text-align: center; }
        .logo-sekolah { width: 120px; height: auto; margin-bottom: 15px; }
        .app-title { font-size: 1.5rem; color: var(--primary); font-weight: bold; margin-bottom: 5px; }
        .app-desc { font-size: 0.85rem; color: var(--dark); margin-bottom: 30px; font-style: italic; font-weight: 600; }
        
        header { background-color: var(--primary); color: var(--white); padding: 15px; text-align: center; box-shadow: 0 2px 5px rgba(0,0,0,0.2); border-bottom: 4px solid var(--dark); }
        header h2 { font-size: 1.2rem; text-transform: uppercase; letter-spacing: 1px; font-weight: bold; }
        header p { font-size: 0.75rem; color: #ffeb3b; margin-top: 3px; font-weight: 600; }

        .page { display: none; padding-bottom: 100px; } /* Jarak ekstra agar tak tertutup tombol */
        .page.active-page { display: block; }
        .container { padding: 15px; max-width: 600px; margin: auto; }
        .container-wide { padding: 15px; max-width: 900px; margin: auto; }

        /* ======================================= */
        /* DESAIN MENU BAWAH DENGAN TOMBOL TENGAH  */
        /* ======================================= */
        .bottom-nav { position: fixed; bottom: 0; left: 0; width: 100%; background: #ffffff; display: flex; box-shadow: 0 -4px 15px rgba(0,0,0,0.08); z-index: 100; height: 65px; border-radius: 20px 20px 0 0; justify-content: space-around;}
        .nav-item { flex: 1; padding: 0; text-align: center; font-size: 0.65rem; font-weight: bold; color: #777; cursor: pointer; display: flex; flex-direction: column; justify-content: center; align-items: center; border-radius: 20px; margin: 4px; transition: 0.3s; }
        .nav-item.active { color: var(--primary); background-color: #fce4e4;}
        .nav-icon { font-size: 1.3rem; display: block; margin-bottom: 2px; }
        .nav-space { width: 75px; flex-shrink: 0; } /* Ruang kosong untuk tombol Input di tengah */
        
        .fab-center {
            position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
            width: 70px; height: 70px; background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: white;
            border-radius: 50%; display: flex; justify-content: center; align-items: center;
            font-size: 1.8rem; font-weight: bold; box-shadow: 0 5px 15px rgba(211, 47, 47, 0.4);
            cursor: pointer; z-index: 105; transition: transform 0.2s, background-color 0.2s; border: 5px solid var(--light);
        }
        .fab-center:active { transform: translateX(-50%) scale(0.9); }
        .fab-center.active { border-color: #ffcdd2; background: var(--dark); box-shadow: 0 0 20px var(--primary); transform: translateX(-50%) scale(1.05); }
        /* ======================================= */

        .card { background: var(--white); border-radius: 10px; padding: 15px; margin-bottom: 15px; box-shadow: 0 2px 8px rgba(0,0,0,0.1); border-top: 3px solid var(--dark); }
        .card-title { font-weight: bold; margin-bottom: 15px; padding-bottom: 10px; border-bottom: 2px solid var(--primary); color: var(--dark); }

        label { display: block; margin-bottom: 5px; font-size: 0.9rem; font-weight: 600; color: var(--dark); }
        select, input[type="text"], input[type="number"], input[type="password"] { width: 100%; padding: 10px; border-radius: 6px; border: 1px solid var(--gray); font-size: 1rem; margin-bottom: 15px; background: #fff; }
        select:focus, input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 5px rgba(211, 47, 47, 0.3); }
        button { background-color: var(--primary); color: var(--white); border: none; padding: 12px 20px; font-size: 1rem; font-weight: bold; border-radius: 6px; cursor: pointer; width: 100%; transition: 0.3s; }
        button.btn-secondary { background-color: var(--dark); color: var(--white); }

        .tabs { display: flex; gap: 5px; margin-bottom: 15px; overflow-x: auto; padding-bottom: 5px;}
        .tab-btn { flex: 1; padding: 10px 5px; background: #e0e0e0; color: #555; text-align: center; border-radius: 6px; font-weight: bold; font-size: 0.75rem; cursor: pointer; min-width: 70px;}
        .tab-btn.active { background: var(--primary); color: var(--white); border-color: var(--primary-dark); }
        .tab-content { display: none; }
        .tab-content.active { display: block; }

        .tab-btn-lap { flex: 1; padding: 10px 5px; background: #e0e0e0; color: #555; text-align: center; border-radius: 6px; font-weight: bold; font-size: 0.75rem; cursor: pointer; }
        .tab-btn-lap.active { background: var(--primary); color: var(--white); border-color: var(--primary-dark); }
        .tab-content-lap { display: none; }
        .tab-content-lap.active { display: block; }

        .filter-row { display: flex; gap: 10px; }
        .filter-row > div { flex: 1; }
        .student-list { max-height: 300px; overflow-y: auto; border: 1px solid var(--gray); border-radius: 6px; padding: 10px; margin-bottom: 15px; background: #fafafa; }
        .student-item { display: flex; align-items: center; padding: 10px 0; border-bottom: 1px solid #eee; }
        .student-item input[type="checkbox"] { width: 20px; height: 20px; margin-right: 15px; accent-color: var(--primary); }
        .student-info { display: flex; flex-direction: column; }
        .student-name { font-weight: bold; font-size: 0.95rem; color: var(--dark); }
        .student-meta { font-size: 0.75rem; color: #666; }

        .autocomplete { position: relative; display: block; }
        .autocomplete-items { position: absolute; border: 1px solid var(--gray); border-top: none; z-index: 99; top: 100%; left: 0; right: 0; background-color: #fff; max-height: 200px; overflow-y: auto; border-radius: 0 0 6px 6px; box-shadow: 0 4px 6px rgba(0,0,0,0.1); margin-top: -15px; margin-bottom: 15px;}
        .autocomplete-items div { padding: 10px; cursor: pointer; border-bottom: 1px solid #eee; }
        .autocomplete-active { background-color: var(--primary) !important; color: #ffffff; }

        #reader { width: 100%; border-radius: 8px; overflow: hidden; margin-bottom: 10px; border: 2px solid var(--dark); }
        
        .report-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }
        .table-responsive { width: 100%; max-height: 500px; overflow-y: auto; overflow-x: auto; background: #fff; border-radius: 6px; border: 1px solid #ddd; }
        .table-laporan { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
        .table-laporan th, .table-laporan td { border-bottom: 1px solid #ddd; padding: 10px; text-align: left; }
        .table-laporan th { background-color: var(--primary); color: white; white-space: nowrap; position: sticky; top: 0; z-index: 10; }
        .table-laporan tr:nth-child(even) { background-color: #f9f9f9; }
        .empty-state { text-align: center; padding: 30px; color: #777; font-style: italic; }

        .data-siswa-list { display: flex; flex-direction: column; gap: 10px; max-height: 65vh; overflow-y: auto; padding: 2px;}
        .siswa-card { 
            background: #ffffff; 
            border-radius: 8px; 
            padding: 12px; 
            border: 1px solid #e0e0e0; 
            box-shadow: 0 1px 3px rgba(0,0,0,0.05);
            /* --- TRIK OPTIMALISASI RAM --- */
            content-visibility: auto;
            contain-intrinsic-size: 150px;
        }
        .jejak-item {
            content-visibility: auto;
            contain-intrinsic-size: 120px;
        }
        .siswa-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; border-bottom: 1px dashed #eee; padding-bottom: 8px;}
        .siswa-nama { font-weight: bold; font-size: 0.95rem; color: var(--primary); }
        .siswa-id { font-size: 0.7rem; color: #666; background: #f0f0f0; padding: 2px 6px; border-radius: 4px; font-family: monospace;}
        .siswa-detail { font-size: 0.8rem; color: #555; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
        .siswa-detail span { display: flex; align-items: center; gap: 4px; }

        #overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(255,255,255,0.9); display: none; justify-content: center; align-items: center; z-index: 1000; flex-direction: column; }
        .spinner { border: 4px solid #f3f3f3; border-top: 4px solid var(--primary); border-radius: 50%; width: 40px; height: 40px; animation: spin 1s linear infinite; margin-bottom: 10px;}
        @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
        
        #toast { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%); background: var(--dark); color: white; padding: 12px 20px; border-radius: 30px; font-size: 0.9rem; font-weight: bold; display: none; z-index: 999; box-shadow: 0 4px 10px rgba(0,0,0,0.3); white-space: nowrap;}
        .toast-success { border-bottom: 3px solid var(--primary); }
        .toast-error { border-bottom: 3px solid #ff9800; }
        
        .modal { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.5); justify-content: center; align-items: center; }
        .modal-content { background: white; padding: 20px; border-radius: 10px; width: 90%; max-width: 450px; max-height: 85vh; overflow-y: auto; }
        .btn-jejak-group { display: flex; gap: 5px; margin-top: 10px; }
        .btn-action { flex: 1; padding: 6px 10px; font-size: 0.75rem; border-radius: 5px; border: none; font-weight: bold; cursor: pointer; color: white; }
        .btn-add-jejak { background-color: #0288d1; }
        .btn-view-jejak { background-color: #7b1fa2; }
        
        /* Tombol Tambah Siswa (Tetap di Kanan Atas saat di Tab Data Siswa) */
        .fab-add {
            position: fixed; bottom: 95px; right: 20px; width: 50px; height: 50px; background-color: #1976d2; color: white; border-radius: 50%;
            display: flex; justify-content: center; align-items: center; font-size: 2rem; font-weight: bold; box-shadow: 0 4px 10px rgba(0,0,0,0.3);
            cursor: pointer; z-index: 90; transition: transform 0.2s;
        }
        .fab-add:active { transform: scale(0.9); }

        #print-area { position: absolute; left: -9999px; top: -9999px; visibility: hidden; }

        @media print {
            body > *:not(#print-area) { display: none !important; }
            #print-area { position: relative; left: 0; top: 0; visibility: visible; display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 15px; width: 100%; padding: 10px; }
            .print-card { border: 2px dashed #333; padding: 15px 10px; text-align: center; border-radius: 8px; page-break-inside: avoid; display: flex; flex-direction: column; align-items: center; }
            .print-qr img { margin: 0 auto; max-width: 110px; height: auto; }
            .print-name { font-size: 13px; font-weight: bold; margin-top: 10px; line-height: 1.2; color: #000; }
            .print-id { font-size: 11px; color: #333; margin-top: 5px; font-family: monospace; letter-spacing: 1px; }
        }