/* Tema: putih + biru + emas + warna-warni */
:root {
  --biru-tua: #0b2f7a; --biru: #1d4ed8; --biru-muda: #dbeafe;
  --emas: #f5b301; --emas-tua: #b7791f;
  --teks: #0f172a; --pudar: #64748b; --garis: #e2e8f0; --latar: #f3f6fd;
  --sisi: 236px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: Nunito, "Segoe UI", sans-serif; background: var(--latar); color: var(--teks); font-size: 14px; }
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }

/* sisi */
#sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sisi); background: linear-gradient(175deg, #0a2566, #12409f 60%, #0b2f7a); color: #fff; overflow-y: auto; z-index: 30; border-right: 4px solid var(--emas); }
.jenama { text-align: center; padding: 20px 14px 14px; border-bottom: 3px solid var(--emas); }
.logo { width: 76px; height: 76px; margin: 0 auto 10px; border-radius: 50%; background: #fff; color: var(--biru); display: grid; place-items: center; font-size: 34px; border: 3px solid var(--emas); overflow: hidden; }
.logo img { width: 100%; height: 100%; object-fit: contain; }
.nama-sekolah { font-weight: 900; font-size: 17px; text-transform: uppercase; line-height: 1.25; overflow-wrap: anywhere; }
#menu { padding: 12px 10px; display: grid; gap: 3px; }
#menu a { display: flex; align-items: center; gap: 12px; padding: 11px 13px; border-radius: 10px; font-weight: 700; }
#menu a i { width: 20px; text-align: center; }
#menu a:hover { background: rgba(255,255,255,.12); }
#menu a.aktif { background: linear-gradient(90deg, #ffd24d, var(--emas)); color: #1e1b4b; box-shadow: 0 4px 12px rgba(245,179,1,.35); }
#tirai { display: none; }

/* utama */
#utama { margin-left: var(--sisi); min-height: 100vh; }
#kepala { background: #fff; display: flex; align-items: center; gap: 16px; padding: 14px 22px; border-bottom: 3px solid var(--emas); flex-wrap: wrap; }
.tajuk { flex: 1; min-width: 220px; }
.tajuk h1 { font-size: 26px; color: var(--biru-tua); font-weight: 900; line-height: 1.2; }
.emas { color: var(--emas-tua); }
.tajuk p { color: var(--pudar); margin-top: 2px; }
.tajuk p b { color: var(--teks); }
.pilih-tahun { display: flex; align-items: center; gap: 8px; font-weight: 800; background: #fff8e1; border: 2px solid var(--emas); padding: 6px 12px; border-radius: 30px; }
.pilih-tahun select { border: 0; background: transparent; font-weight: 900; cursor: pointer; }
.butang-menu { display: none; border: 0; background: var(--biru); color: #fff; width: 40px; height: 40px; border-radius: 10px; cursor: pointer; }
main { padding: 18px 22px 40px; display: flex; flex-direction: column; gap: 16px; }

/* kad */
.kad { background: #fff; border: 1px solid var(--garis); border-radius: 16px; padding: 16px; box-shadow: 0 4px 16px rgba(15,40,100,.06); min-width: 0; }
.kad > h2 { display: flex; align-items: center; gap: 10px; font-size: 15px; color: var(--biru-tua); margin-bottom: 12px; font-weight: 900; }
.ikon { flex: none; width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, var(--biru), #0b2f7a); color: #fff; display: grid; place-items: center; font-size: 13px; box-shadow: 0 0 0 2px var(--emas); }
.grid { display: grid; gap: 16px; }
.g-atas { grid-template-columns: 1.1fr 1fr 1.5fr; }
.g-bawah { grid-template-columns: 1.25fr 1fr 1fr; align-items: start; }
.g-tiga { grid-template-columns: repeat(3, 1fr); }
.g-dua { grid-template-columns: 1.1fr 1fr; align-items: start; }
.susun { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

/* statistik */
.baris-stat { display: grid; grid-template-columns: repeat(8, 1fr); gap: 10px; }
.statistik { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 14px 8px; border-radius: 14px; border: 1px solid rgba(0,0,0,.05); box-shadow: 0 4px 12px rgba(15,40,100,.08); text-align: center; }
.statistik i { font-size: 28px; }
.statistik strong { display: block; font-size: 28px; font-weight: 900; line-height: 1.1; }
.statistik span { font-weight: 700; font-size: 12px; }
.s-murid { background: linear-gradient(135deg, #1d4ed8, #0b2f7a); color: #fff; }
.s-lelaki { background: #e0f0ff; color: #0b57a4; }
.s-perempuan { background: #ffe4ef; color: #be185d; }
.s-kelas { background: #fff2c6; color: #92590a; }
.s-unit { background: #d9fbe8; color: #11663b; }
.statistik.k-BB { background: #dbeafe; color: #1e40af; }
.statistik.k-KP { background: #f3e8ff; color: #7e22ce; }
.statistik.k-SP { background: #ffedd5; color: #c2410c; }

.carta { position: relative; width: 100%; }
.donut { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; }
.donut .bekas { position: relative; width: 210px; }
.donut .tengah { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; font-weight: 800; }
.donut .tengah b { font-size: 28px; line-height: 1; }
.petunjuk, .ringkas { list-style: none; display: grid; gap: 8px; }
.petunjuk i { display: inline-block; width: 13px; height: 13px; border-radius: 4px; margin-right: 7px; }
.ringkas li { display: flex; gap: 9px; align-items: baseline; font-weight: 600; }
.ringkas i { color: #16a34a; }
.legenda { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

/* jadual */
.gulung { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 7px 8px; border: 1px solid var(--garis); text-align: center; }
thead th { background: #eaf1ff; color: var(--biru-tua); font-weight: 900; }
tbody tr:hover { background: #fffbeb; }
td.kiri { text-align: left; font-weight: 700; }
.tiada { text-align: center; color: var(--pudar); padding: 24px; }
.pudar { color: var(--pudar); }
.merah-teks { color: #dc2626; font-weight: 800; }

.lencana { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 800; white-space: nowrap; }
.lencana.k-BB { background: #dbeafe; color: #1e40af; }
.lencana.k-KP { background: #f3e8ff; color: #7e22ce; }
.lencana.k-SP { background: #dcfce7; color: #166534; }
.lencana.j-L { background: #e0f0ff; color: #0b57a4; }
.lencana.j-P { background: #ffe4ef; color: #be185d; }
.cip { display: inline-block; min-width: 68px; padding: 2px 8px; border-radius: 8px; font-weight: 900; }
.cip.baik { background: #d1fae5; color: #065f46; }
.cip.sederhana { background: #fef3c7; color: #92400e; }
.cip.lemah { background: #fee2e2; color: #b91c1c; }
.cip.kosong { background: #f1f5f9; color: var(--pudar); }

/* kawalan */
.alatan { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
main > .alatan { margin-bottom: 0; }
.jarak { flex: 1; }
.kira { font-weight: 800; color: var(--biru); }
input:not([type=checkbox]), select { padding: 8px 11px; border: 1.5px solid #cbd5e1; border-radius: 9px; background: #fff; max-width: 100%; }
input:focus, select:focus, button:focus-visible { outline: 3px solid rgba(245,179,1,.55); outline-offset: 1px; }
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 9px 15px; border: 1.5px solid transparent; border-radius: 10px; font-weight: 800; cursor: pointer; }
.btn.utama { background: var(--biru); color: #fff; }
.btn.emas-btn { background: linear-gradient(90deg, #ffd24d, var(--emas)); color: #3b2600; }
.btn.hantu { background: #fff; border-color: #bfdbfe; color: var(--biru); }
.btn.bahaya { background: #dc2626; color: #fff; }
.btn.kecil { padding: 3px 12px; }
.btn:hover { filter: brightness(1.06); }
.ikon-btn { border: 0; background: #eaf1ff; color: var(--biru); width: 29px; height: 29px; border-radius: 8px; cursor: pointer; }
.ikon-btn.merah { background: #fee2e2; color: #dc2626; }
.aksi { white-space: nowrap; }
.aksi .ikon-btn { margin: 0 2px; }
.tajuk-halaman { color: var(--biru-tua); font-size: 20px; font-weight: 900; }
.nota { color: var(--pudar); margin-bottom: 10px; }

/* unit */
.g-unit { grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 12px; }
.kad-unit { text-align: left; padding: 13px 15px; border-radius: 14px; border: 2px solid transparent; cursor: pointer; display: flex; flex-direction: column; }
.kad-unit strong { font-size: 30px; font-weight: 900; }
.kad-unit span { font-size: 12px; font-weight: 700; }
.kad-unit.k-BB { background: #dbeafe; color: #1e40af; }
.kad-unit.k-KP { background: #f3e8ff; color: #7e22ce; }
.kad-unit.k-SP { background: #dcfce7; color: #166534; }
.kad-unit.aktif { border-color: var(--emas); box-shadow: 0 0 0 3px rgba(245,179,1,.3); }

/* kehadiran */
.tanda { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; border: 1px solid transparent; font-weight: 900; cursor: pointer; }
.tanda.h { background: #d1fae5; color: #047857; }
.tanda.t { background: #fee2e2; color: #dc2626; }
.tanda.x { background: #fef3c7; color: #92400e; }
.tanda.n { background: #f8fafc; color: #94a3b8; border-color: #cbd5e1; }
.kunci { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; }
.kunci .tanda { width: 22px; height: 22px; cursor: default; margin-left: 6px; }
table.hadir th small { display: block; font-size: 10px; color: var(--pudar); }
table.hadir th .ikon-btn { width: 24px; height: 20px; font-size: 10px; }
table.hadir td { padding: 3px; }
table.hadir td.kiri { padding: 3px 8px; min-width: 200px; }
table.hadir tfoot th { text-align: right; background: #fff8e1; }
table.hadir tfoot td { font-weight: 800; background: #fffdf5; }
.jadual-tarikh input { width: 132px; padding: 5px; font-size: 12px; }
.jadual-tarikh td.kiri { min-width: 180px; }
.set-semua { background: #fff8e1; }
details summary { cursor: pointer; font-weight: 900; color: var(--biru-tua); margin-bottom: 6px; }
.panas td { font-weight: 800; }
.panas tbody tr:hover { background: none; }

/* borang & modal */
.borang { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.borang label { display: flex; flex-direction: column; gap: 4px; font-weight: 800; min-width: 0; }
.penuh { grid-column: 1 / -1; }
.logo-urus { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.logo.kecil { width: 60px; height: 60px; font-size: 26px; margin: 0; }
#modal { position: fixed; inset: 0; background: rgba(8,20,55,.55); display: grid; place-items: center; padding: 16px; z-index: 50; }
.kotak { background: #fff; width: min(580px, 100%); max-height: 92vh; display: flex; flex-direction: column; border-radius: 16px; border-top: 6px solid var(--emas); overflow: hidden; }
.kotak.lebar { width: min(720px, 100%); }
.kotak h3 { padding: 16px 20px 8px; color: var(--biru-tua); }
.kotak .isi { padding: 8px 20px; overflow: auto; }
.kotak .isi ul { padding-left: 20px; margin: 8px 0; }
.tindakan { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; }
.senarai-pilih { max-height: 45vh; overflow: auto; border: 1px solid var(--garis); border-radius: 10px; margin-top: 6px; }
.senarai-pilih label { display: flex; gap: 10px; padding: 7px 12px; border-bottom: 1px solid var(--garis); cursor: pointer; }
.senarai-pilih small { color: var(--pudar); }
.kotak input[type=search] { width: 100%; margin-bottom: 6px; }
.amaran { padding-left: 20px; color: #92400e; display: grid; gap: 4px; font-size: 13px; }
h4 { margin: 14px 0 8px; color: var(--biru-tua); }
#toast { position: fixed; right: 20px; bottom: 20px; background: var(--biru-tua); color: #fff; padding: 12px 18px; border-radius: 12px; border-left: 5px solid var(--emas); font-weight: 800; opacity: 0; pointer-events: none; transform: translateY(10px); transition: .25s; z-index: 60; max-width: 360px; }
#toast.tunjuk { opacity: 1; transform: none; }
#toast.ralat { background: #991b1b; }

/* laporan */
.kertas { background: #fff; width: 100%; max-width: 210mm; margin: 0 auto; padding: 12mm; box-shadow: 0 6px 24px rgba(15,40,100,.14); overflow-x: auto; }
.kertas.lintang { max-width: 297mm; }
.kertas table { font-size: 10.5px; margin-bottom: 10px; }
.kertas th, .kertas td { padding: 3px 4px; border-color: #64748b; }
.kertas th small { display: block; font-weight: 600; font-size: 8.5px; }
.kertas h4 { margin: 10px 0 6px; }
.kepala-laporan { display: flex; justify-content: center; align-items: center; gap: 14px; text-align: center; text-transform: uppercase; border-bottom: 3px double var(--biru-tua); padding-bottom: 10px; margin-bottom: 12px; }
.kepala-laporan img { width: 60px; height: 60px; object-fit: contain; }
.kepala-laporan p { font-weight: 800; font-size: 12px; }
table.profil { width: auto; min-width: 50%; }
table.profil th { text-align: left; }
.kaki td { font-weight: 800; background: #f1f5f9; }
.graf { display: grid; gap: 4px; break-inside: avoid; }
.graf > div { display: grid; grid-template-columns: 170px 1fr 60px; gap: 8px; align-items: center; font-size: 11px; }
.trek { background: #f1f5f9; height: 11px; }
.trek i { display: block; height: 100%; border-radius: 0 4px 4px 0; }
.tandatangan { display: flex; justify-content: space-between; gap: 30px; margin-top: 26px; break-inside: avoid; font-size: 12px; }
.garis { width: 210px; border-bottom: 1px dotted var(--teks); height: 44px; margin-bottom: 4px; }

@media (max-width: 1450px) {
  .baris-stat { grid-template-columns: repeat(4, 1fr); }
  .g-atas, .g-bawah { grid-template-columns: 1fr 1fr; }
  .g-atas > :last-child, .g-bawah > :last-child { grid-column: 1 / -1; }
}
@media (max-width: 1000px) {
  .g-atas, .g-bawah, .g-tiga, .g-dua { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
  #sidebar { transform: translateX(-100%); transition: transform .25s; }
  .menu-buka #sidebar { transform: none; }
  .menu-buka #tirai { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 20; }
  #utama { margin-left: 0; }
  .butang-menu { display: block; }
  .tajuk h1 { font-size: 19px; }
  .baris-stat { grid-template-columns: repeat(2, 1fr); }
  .borang { grid-template-columns: 1fr; }
  main { padding: 14px 12px 30px; }
}

@media print {
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body { background: #fff; }
  #sidebar, #kepala, #toast, #modal, .tak-cetak { display: none !important; }
  #utama { margin: 0; min-height: 0; }
  main { padding: 0; display: block; }
  .kertas, .kertas.lintang { box-shadow: none; max-width: none; padding: 0; overflow: visible; }
  .kertas tr { break-inside: avoid; }
  .muka-baharu { break-before: page; }
  .kepala-laporan { padding-bottom: 5px; margin-bottom: 8px; }
  .kertas th, .kertas td { padding: 2px 4px; }
  .kertas h4 { margin: 4px 0; }
  .graf { gap: 1px; }
  .graf > div { font-size: 9px; line-height: 1.25; }
  .trek { height: 8px; }
  .tandatangan { margin-top: 10px; font-size: 11px; }
  .garis { height: 30px; }
}
