:root{
  --blue:#0a3d8f; --blue-d:#061f55; --blue-m:#1e63d6; --blue-l:#e8f0fd;
  --gold:#d4a017; --gold-l:#f6dc84; --gold-d:#a67c00;
  --green:#22a35a; --red:#e5484d; --purple:#8e44ad; --orange:#f08a24; --teal:#14b8c4;
  --bg:#f3f6fc; --line:#dde5f3; --text:#1b2540; --muted:#6b7694;
  --side:252px;
}
*{box-sizing:border-box}
html,body{margin:0;background:var(--bg);color:var(--text);font-family:'Poppins',system-ui,sans-serif;font-size:14px}
a{color:var(--blue-m);text-decoration:none}
.loading{position:fixed;inset:0;background:#fff;z-index:9999;display:flex;flex-direction:column;gap:12px;align-items:center;justify-content:center;color:var(--blue);font-weight:600}

/* ---------- Sidebar ---------- */
.sidebar{position:fixed;inset:0 auto 0 0;width:var(--side);background:linear-gradient(180deg,#0d4aad 0%,#0a3d8f 45%,#061f55 100%);color:#fff;display:flex;flex-direction:column;z-index:1040;overflow-y:auto}
.brand{padding:18px 16px 16px;display:flex;gap:12px;align-items:center;border-bottom:3px solid var(--gold);background:linear-gradient(135deg,rgba(255,255,255,.1),transparent)}
.brand .logo{width:58px;height:58px;flex:none;border-radius:50%;background:#fff;display:flex;align-items:center;justify-content:center;overflow:hidden;box-shadow:0 0 0 3px var(--gold)}
.brand .logo img{width:100%;height:100%;object-fit:contain}
.brand .b-name{font-weight:800;line-height:1.15;font-size:15px;text-transform:uppercase;letter-spacing:.3px}
.brand .b-loc{font-size:10px;letter-spacing:2px;color:var(--gold-l);text-transform:uppercase;margin-top:3px}
.nav-menu{padding:14px 10px;display:flex;flex-direction:column;gap:3px}
.nav-menu a{display:flex;align-items:center;gap:12px;padding:10px 14px;border-radius:10px;color:#e4ecff;font-weight:500;transition:.15s}
.nav-menu a i{font-size:18px;width:22px;text-align:center}
.nav-menu a:hover{background:rgba(255,255,255,.12);color:#fff}
.nav-menu a.active{background:linear-gradient(90deg,var(--gold-l),var(--gold));color:var(--blue-d);font-weight:700;box-shadow:0 3px 10px rgba(0,0,0,.25)}
.sidebar-art{margin-top:auto;text-align:center;font-size:90px;color:rgba(246,220,132,.25);line-height:1;padding:20px 0 10px}
.sidebar-backdrop{display:none}

/* ---------- Topbar / main ---------- */
.main{margin-left:var(--side);min-height:100vh}
.topbar{display:flex;align-items:center;gap:14px;padding:12px 24px;background:#fff;position:sticky;top:0;z-index:1030;border-bottom:1px solid var(--line);
  background-image:linear-gradient(115deg,#fff 70%,#fff4cc 100%)}
.topbar-title{flex:1;min-width:0}
.topbar h1{margin:0;font-size:24px;font-weight:800;color:var(--blue);line-height:1.2}
.topbar .sub{color:var(--muted);font-size:13px}
.menu-btn{display:none}
.user-chip{display:flex;align-items:center;gap:10px;padding:6px 14px;border:1px solid var(--line);border-radius:12px;background:#fff}
.user-chip>i{font-size:26px;color:var(--blue)}
.u-name{font-weight:600;font-size:13px;line-height:1.2}
.u-role{font-size:11px;color:var(--gold-d);font-weight:600}
.view{padding:20px 24px 40px}

/* ---------- Cards / panels ---------- */
.panel{background:#fff;border:1px solid var(--line);border-radius:14px;box-shadow:0 2px 8px rgba(10,61,143,.06);overflow:hidden;height:100%}
.panel-h{padding:9px 14px;font-weight:700;color:#fff;background:linear-gradient(100deg,var(--blue) 0%,var(--blue-m) 65%,var(--gold) 100%);display:flex;align-items:center;gap:8px;font-size:14px}
.panel-h .more{margin-left:auto;font-size:12px;color:#fff;font-weight:600;opacity:.95}
.panel-b{padding:14px}
.filters{display:flex;flex-wrap:wrap;gap:10px;align-items:center;background:#fff;border:1px solid var(--line);border-radius:14px;padding:10px 14px;margin-bottom:16px}
.filters .lbl{font-weight:700;color:var(--blue);display:flex;gap:6px;align-items:center}
.filters .form-select{width:auto;min-width:170px;border-radius:10px}

.kpis{display:grid;grid-template-columns:repeat(7,1fr);gap:12px;margin-bottom:16px}
.kpi{background:#fff;border:1px solid var(--line);border-radius:14px;padding:12px;display:flex;gap:10px;align-items:center;box-shadow:0 2px 8px rgba(10,61,143,.06);border-bottom:3px solid var(--c,var(--blue-m))}
.kpi .ic{width:46px;height:46px;border-radius:12px;display:flex;align-items:center;justify-content:center;color:#fff;font-size:22px;background:var(--c,var(--blue-m));flex:none}
.kpi .n{font-size:26px;font-weight:800;line-height:1;color:var(--blue-d)}
.kpi .t{font-size:12px;color:var(--muted);font-weight:500;line-height:1.2;margin-top:3px}
.grid4{display:grid;grid-template-columns:repeat(4,1fr);gap:14px;margin-bottom:14px}
.grid2{display:grid;grid-template-columns:1fr 1fr;gap:14px}
.chart-box{position:relative;height:210px}
.legend{font-size:12.5px;display:flex;flex-direction:column;gap:5px}
.legend div{display:flex;align-items:center;gap:7px}
.legend i{width:11px;height:11px;border-radius:3px;display:inline-block;flex:none}
.legend b{margin-left:auto;padding-left:8px}
.donut-wrap{display:flex;gap:10px;align-items:center}
.donut-wrap .chart-box{width:42%;height:170px;flex:none}
.donut-wrap>.legend,.donut-wrap>div:last-child{min-width:0;flex:1}
.legend small{display:block;text-align:right}
.legend div{align-items:flex-start;line-height:1.25}
.legend b{white-space:nowrap}
.sum-list{display:flex;flex-direction:column}
.sum-list div{display:flex;justify-content:space-between;align-items:center;padding:8px 2px;border-bottom:1px dashed var(--line);font-size:13px}
.sum-list div:last-child{border:0}
.sum-list b{color:var(--blue);font-size:15px}
.sum-list i{color:var(--gold);margin-right:8px}

/* ---------- Tables ---------- */
.dt-bar{display:flex;flex-wrap:wrap;gap:10px;align-items:center;margin-bottom:12px}
.dt-bar .search{position:relative;flex:1 1 220px;max-width:340px}
.dt-bar .search i{position:absolute;left:12px;top:50%;transform:translateY(-50%);color:var(--muted)}
.dt-bar .search input{padding-left:36px;border-radius:10px}
.dt-bar .form-select{width:auto;max-width:200px;border-radius:10px}
table.dt{margin:0;font-size:13px}
table.dt thead th{background:linear-gradient(180deg,var(--blue),var(--blue-d));color:#fff;font-weight:600;white-space:nowrap;border:0;padding:9px 10px;position:sticky;top:0}
table.dt thead th.sortable{cursor:pointer;user-select:none}
table.dt tbody td{padding:7px 10px;vertical-align:middle;border-color:var(--line)}
table.dt tbody tr:nth-child(even){background:#f7f9fe}
table.dt tbody tr:hover{background:#eef4ff}
.dt-foot{display:flex;justify-content:space-between;align-items:center;gap:10px;margin-top:10px;font-size:13px;color:var(--muted);flex-wrap:wrap}
.pager{display:flex;gap:4px}
.pager button{border:1px solid var(--line);background:#fff;border-radius:8px;min-width:34px;height:32px;color:var(--blue);font-weight:600}
.pager button.on{background:var(--blue);color:#fff;border-color:var(--blue)}
.pager button:disabled{opacity:.4}
.act{border:0;background:var(--blue-l);color:var(--blue);width:30px;height:30px;border-radius:8px;margin-left:3px}
.act:hover{background:var(--blue);color:#fff}
.act.del{background:#fde8e8;color:var(--red)} .act.del:hover{background:var(--red);color:#fff}
.act.gold{background:#fdf1c8;color:var(--gold-d)} .act.gold:hover{background:var(--gold);color:#fff}

.badge-p{display:inline-block;padding:3px 10px;border-radius:7px;font-weight:700;font-size:11.5px;color:#fff;white-space:nowrap}
.bp-JOHAN{background:linear-gradient(90deg,#f5cf55,#d4a017);color:#4a3600}
.bp-NAIB{background:#1e63d6} .bp-KETIGA{background:#22a35a} .bp-PENYERTAAN{background:#8e44ad} .bp-LAIN{background:#6b7694}
.chip{display:inline-block;padding:2px 9px;border-radius:20px;font-size:11.5px;font-weight:600;background:var(--blue-l);color:var(--blue)}
.chip.g{background:#fdf1c8;color:var(--gold-d)}
.btn-gold{background:linear-gradient(90deg,var(--gold-l),var(--gold));color:var(--blue-d);font-weight:700;border:0}
.btn-gold:hover{filter:brightness(.95);color:var(--blue-d)}
.btn-blue{background:linear-gradient(90deg,var(--blue-m),var(--blue));color:#fff;font-weight:600;border:0}
.btn-blue:hover{filter:brightness(1.1);color:#fff}

/* ---------- Kumpulan cards ---------- */
.gcards{display:grid;grid-template-columns:repeat(auto-fill,minmax(210px,1fr));gap:14px;margin-bottom:16px}
.gcard{background:#fff;border:2px solid var(--line);border-radius:14px;padding:14px;cursor:pointer;border-top:5px solid var(--c);transition:.15s}
.gcard:hover{transform:translateY(-2px);box-shadow:0 6px 16px rgba(10,61,143,.12)}
.gcard.on{border-color:var(--c);background:linear-gradient(180deg,#fff,var(--blue-l))}
.gcard .gn{font-weight:700;color:var(--blue-d);font-size:14px}
.gcard .gc{font-size:30px;font-weight:800;color:var(--c);line-height:1.1}
.gcard .gs{font-size:12px;color:var(--muted)}

/* ---------- Laporan ---------- */
.rtabs{display:flex;flex-wrap:wrap;gap:8px;margin-bottom:14px}
.rtabs button{border:1px solid var(--line);background:#fff;border-radius:10px;padding:8px 14px;font-weight:600;color:var(--blue)}
.rtabs button.on{background:linear-gradient(90deg,var(--gold-l),var(--gold));color:var(--blue-d);border-color:var(--gold)}
.paper{background:#fff;border:1px solid var(--line);border-radius:6px;padding:22px 26px;max-width:1000px;margin:14px auto 0;box-shadow:0 2px 12px rgba(0,0,0,.08)}
.r-head{display:flex;gap:16px;align-items:center;border-bottom:3px double var(--blue);padding-bottom:10px;margin-bottom:12px}
.r-head .lg{width:70px;height:70px;flex:none}
.r-head .lg img,.r-head .lg svg{width:100%;height:100%;object-fit:contain}
.r-head .sn{font-weight:800;font-size:18px;color:var(--blue-d);text-transform:uppercase}
.r-head .ad{font-size:12px;color:#444}
.r-title{text-align:center;font-weight:800;font-size:16px;margin:8px 0 4px;text-transform:uppercase;color:var(--blue-d)}
.r-sub{text-align:center;font-size:12.5px;margin-bottom:10px;color:#333}
table.rt{width:100%;border-collapse:collapse;font-size:11.5px;margin-bottom:12px}
table.rt th,table.rt td{border:1px solid #333;padding:3px 6px}
table.rt th{background:#dfe8fb;text-align:center;font-weight:700}
table.rt td.c{text-align:center}
.rt-sec{margin-bottom:14px}
.rt-sec h3{font-size:13.5px;font-weight:700;margin:10px 0 6px;color:var(--blue-d);border-left:5px solid var(--gold);padding-left:8px}
.sign{display:flex;justify-content:space-between;margin-top:34px;font-size:12px}
.sign div{width:42%} .sign .ln{border-bottom:1px solid #000;height:46px;margin-bottom:4px}
.r-foot{font-size:10.5px;color:#666;text-align:right;margin-top:8px}

/* ---------- Misc ---------- */
.toasts{position:fixed;right:18px;top:18px;z-index:3000;display:flex;flex-direction:column;gap:8px}
.toast-i{background:#fff;border-left:5px solid var(--green);padding:10px 16px;border-radius:10px;box-shadow:0 6px 20px rgba(0,0,0,.18);font-weight:500;min-width:220px;animation:in .2s}
.toast-i.err{border-color:var(--red)} .toast-i.warn{border-color:var(--gold)}
@keyframes in{from{transform:translateX(30px);opacity:0}to{opacity:1}}
.modal-header{background:linear-gradient(100deg,var(--blue),var(--blue-m));color:#fff;border-bottom:3px solid var(--gold)}
.modal-header .btn-close{filter:invert(1)}
.modal-title{font-weight:700}
.form-label{font-weight:600;font-size:12.5px;color:var(--blue-d);margin-bottom:3px}
.form-control,.form-select{border-radius:9px}
.empty{text-align:center;color:var(--muted);padding:28px}
.logo-prev{width:90px;height:90px;border:2px dashed var(--line);border-radius:12px;display:flex;align-items:center;justify-content:center;overflow:hidden;background:#fff}
.logo-prev img,.logo-prev svg{width:100%;height:100%;object-fit:contain}
.setting-card{background:#fff;border:1px solid var(--line);border-radius:14px;padding:18px;margin-bottom:16px;border-top:4px solid var(--gold)}
.setting-card h5{color:var(--blue);font-weight:700;margin-bottom:12px}
.err-list{max-height:260px;overflow:auto;font-size:12.5px;background:#fff6f6;border:1px solid #f3c2c2;border-radius:8px;padding:8px 12px}

/* ---------- Responsive ---------- */
@media (max-width:1400px){.kpis{grid-template-columns:repeat(4,1fr)}.grid4{grid-template-columns:repeat(2,1fr)}}
@media (max-width:992px){
  .sidebar{transform:translateX(-100%);transition:.2s}
  body.side-open .sidebar{transform:none}
  body.side-open .sidebar-backdrop{display:block;position:fixed;inset:0;background:rgba(0,0,0,.4);z-index:1035}
  .main{margin-left:0}.menu-btn{display:block}
  .kpis{grid-template-columns:repeat(2,1fr)} .grid2{grid-template-columns:1fr}
  .topbar h1{font-size:18px} .user-chip div{display:none}
}
@media (max-width:640px){.grid4{grid-template-columns:1fr}.view{padding:14px}}

/* ---------- Cetak ---------- */
@page{size:A4;margin:12mm}
@media print{
  body{background:#fff}
  .no-print,.sidebar,.topbar,.toasts{display:none!important}
  .main{margin:0}.view{padding:0}
  .paper{border:0;box-shadow:none;margin:0;padding:0;max-width:none}
  .rt-sec.pb{page-break-after:always}
  .rt-sec.pb:last-of-type{page-break-after:auto}
  table.rt thead{display:table-header-group} table.rt tr{page-break-inside:avoid}
  *{-webkit-print-color-adjust:exact;print-color-adjust:exact}
}

/* ---------- Tahun / arkib ---------- */
.year-sel{width:auto;font-weight:700;color:var(--blue);border:2px solid var(--gold);border-radius:10px}
.topbar-right{display:flex;gap:10px;align-items:center}
.ro-banner{background:linear-gradient(90deg,#fff3cd,#ffe69c);border-bottom:2px solid var(--gold);padding:9px 24px;font-weight:600;color:#664d03;display:flex;gap:10px;align-items:center;flex-wrap:wrap}
.readonly .act[title="Edit"],.readonly .act[title="Padam"],.readonly .act[title="Edit murid"],.readonly .act[title^="Keluarkan"],
.readonly .btn-gold,.readonly #gAdd,.readonly #gRen,.readonly #gDel,.readonly #newG,.readonly .modal .act{display:none!important}
.readonly .ro-banner .btn-gold{display:inline-block!important}
[hidden] { display: none !important; }
.admin-login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(ellipse at 15% 15%, #254678, transparent 55%),
              radial-gradient(ellipse at 90% 90%, #284c62, transparent 48%), #101b33;
}
.login-card {
  width: min(100%, 440px);
  padding: clamp(24px, 6vw, 44px);
  border-radius: 24px;
  background: #fff;
  color: #142341;
  box-shadow: 0 24px 80px #0006;
}
.login-mark {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin-bottom: 20px;
  border-radius: 16px;
  background: #ffedbb;
  color: #735000;
  font-size: 24px;
}
.login-kicker { font-size: .75rem; letter-spacing: .14em; font-weight: 800; color: #52637e; }
.login-card h1 { margin: 8px 0; font-size: clamp(1.6rem, 5vw, 2rem); font-weight: 800; }
.login-card p { color: #52637e; }
.login-card label { display: block; margin: 14px 0 5px; font-size: .88rem; font-weight: 600; }
.login-card input { width: 100%; padding: 10px 12px; border: 1px solid #b5c2d4; border-radius: 10px; }
.login-field { display: flex; gap: 6px; }
.login-field button { border: 1px solid #b5c2d4; border-radius: 10px; background: #eef3fa; color: #142341; }
.login-submit { width: 100%; padding: 11px; border: 0; border-radius: 10px; background: #173863; color: white; font-weight: 700; }
.login-submit:disabled { opacity: .65; }
.login-card #loginError { color: #a42335; margin: 12px 0; font-size: .88rem; }
