/* ===== Tema: biru laut + emas ===== */
:root {
  --biru: #0b3a8f;
  --biru-tua: #0a2a6b;
  --biru-2: #0b4aa8;
  --biru-muda: #4a8bf0;
  --emas: #f5b82e;
  --emas-tua: #c8961a;
  --latar: #f1f5fb;
  --kad: #fff;
  --teks: #1e293b;
  --redup: #64748b;
  --garis: #e2e8f0;
  --ok: #16a34a;
  --bahaya: #dc2626;
  --sisi: 240px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: 'Poppins', system-ui, sans-serif; background: var(--latar); color: var(--teks); font-size: 14px; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--redup); font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.c { text-align: center !important; }
.full { grid-column: 1 / -1; }
.ikon-emas { color: var(--emas); }

/* ===== Susun atur ===== */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sisi); flex: none; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: linear-gradient(180deg, var(--biru) 0%, var(--biru-tua) 100%); color: #fff; padding: 14px 12px;
  display: flex; flex-direction: column; gap: 10px; z-index: 40;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 4px 14px; }
.brand-logo { width: 52px; height: 52px; flex: none; border-radius: 50%; background: rgba(255, 255, 255, .12); display: grid; place-items: center; font-size: 26px; color: var(--emas); overflow: hidden; }
.brand-logo img, .head-logo img { width: 100%; height: 100%; object-fit: contain; }
.brand-text { font-weight: 600; line-height: 1.2; font-size: 16px; }
.brand-text span { display: block; font-size: 11px; font-weight: 400; opacity: .8; margin-top: 3px; }
#nav { display: flex; flex-direction: column; gap: 3px; }
#nav a { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 10px; color: #e6edf9; font-weight: 500; transition: background .15s; }
#nav a i { width: 20px; text-align: center; }
#nav a:hover { background: rgba(255, 255, 255, .1); }
#nav a.aktif { background: linear-gradient(90deg, var(--emas), #f8c94f); color: var(--biru-tua); font-weight: 600; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 12px 22px; background: #fff; border-bottom: 1px solid var(--garis);
  position: relative; overflow: hidden; flex-wrap: wrap;
}
.topbar::after { /* hiasan kelok biru-emas */
  content: ''; position: absolute; right: -60px; top: -40px; width: 260px; height: 160px; pointer-events: none;
  background: linear-gradient(135deg, transparent 40%, rgba(245, 184, 46, .35) 41%, rgba(245, 184, 46, .35) 52%, rgba(11, 58, 143, .9) 53%);
  border-radius: 0 0 0 100%; opacity: .15;
}
.head-logo { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; font-size: 30px; color: var(--biru); overflow: hidden; flex: none; }
.head-title h1 { font-size: 22px; font-weight: 700; color: var(--biru-tua); line-height: 1.2; }
.head-title p { color: var(--biru-2); font-size: 12.5px; }
.head-title p i { margin: 0 6px; color: var(--redup); font-style: normal; }
.head-tools { margin-left: auto; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; position: relative; z-index: 1; }
.head-tools select, .chip-tarikh, .select-sm {
  border: 1px solid var(--garis); background: #fff; border-radius: 10px; padding: 8px 12px; font-size: 13px; box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
}
.chip-tarikh { display: flex; align-items: center; gap: 8px; color: var(--biru-tua); white-space: nowrap; }
.avatar { display: flex; align-items: center; gap: 8px; background: var(--biru); color: #fff; padding: 6px 14px 6px 6px; border-radius: 30px; font-size: 13px; }
.avatar i { width: 30px; height: 30px; border-radius: 50%; background: rgba(255, 255, 255, .2); display: grid; place-items: center; }
.menu-btn { display: none; }
#view { padding: 18px 22px 30px; }

/* ===== Komponen asas ===== */
.panel { background: var(--kad); border-radius: 14px; box-shadow: 0 1px 3px rgba(15, 23, 42, .08); padding: 16px 18px; min-width: 0; }
.ph { font-size: 15px; font-weight: 700; color: var(--biru-tua); margin-bottom: 12px; }
.btn { border: 0; border-radius: 10px; padding: 9px 16px; cursor: pointer; font-weight: 500; display: inline-flex; align-items: center; gap: 8px; transition: filter .15s, transform .05s; }
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--biru-2); color: #fff; }
.btn-danger { background: var(--bahaya); color: #fff; }
.btn-ghost { background: #fff; border: 1px solid var(--garis); color: var(--biru-tua); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.icon-btn { border: 0; background: transparent; cursor: pointer; width: 32px; height: 32px; border-radius: 8px; color: var(--biru-2); }
.icon-btn:hover { background: #e8effc; }
.icon-btn.bahaya { color: var(--bahaya); }
.icon-btn.bahaya:hover { background: #fee2e2; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.badge.ok { background: #dcfce7; color: #15803d; }
.badge.info { background: #dbeafe; color: #1d4ed8; }
.badge.warn { background: #fef3c7; color: #b45309; }
.badge.bad { background: #fee2e2; color: #b91c1c; }
.tag { display: inline-block; background: #eef3fc; color: var(--biru-2); border-radius: 6px; padding: 1px 8px; font-size: 11.5px; margin: 1px 0; }
.tahap { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; color: #fff; font-weight: 700; font-size: 12px; }
.t-A { background: #0b4aa8; } .t-B { background: #4a8bf0; } .t-C { background: #f5b82e; color: #5a3d00; } .t-D { background: #9aa4b2; } .t-E { background: #6b7280; }
.chips { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { border-left: 4px solid var(--c); background: #f8fafc; padding: 6px 12px; border-radius: 8px; font-size: 12.5px; }

/* ===== Dashboard ===== */
.dash { display: flex; flex-direction: column; gap: 14px; }
.kpi-row { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; }
.kpi { background: #fff; border-radius: 14px; padding: 14px 16px; display: flex; gap: 12px; align-items: center; box-shadow: 0 1px 3px rgba(15, 23, 42, .08); }
.kpi-ikon { font-size: 30px; color: var(--emas); width: 46px; text-align: center; flex: none; }
.kpi:first-child .kpi-ikon { color: var(--biru-muda); }
.kpi-label { font-size: 12.5px; font-weight: 500; }
.kpi-nilai { font-size: 26px; font-weight: 700; color: var(--biru-tua); line-height: 1.15; }
.delta { font-size: 12px; font-weight: 500; }
.delta.naik { color: var(--ok); } .delta.turun { color: var(--bahaya); } .delta.muted { color: var(--redup); }
.row { display: grid; gap: 14px; }
.row-a { grid-template-columns: 1fr 1.15fr 1.15fr 1fr; }
.row-b { grid-template-columns: 1fr 1.25fr .95fr 1fr; }
.donat-wrap { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.donat { width: 216px; max-width: 100%; height: 156px; flex: none; position: relative; }
.legenda { list-style: none; margin: 0; padding: 0; flex: 1; min-width: 150px; display: flex; flex-direction: column; gap: 7px; font-size: 12px; }
.legenda li { display: flex; align-items: center; gap: 6px; }
.legenda .lnama { flex: 1; }
.legenda small { color: var(--redup); }
.kotak { width: 10px; height: 10px; border-radius: 2px; flex: none; }
.trend { height: 200px; }
.kat-wrap { display: flex; gap: 12px; align-items: stretch; }
.kat-bars { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 12px; }
.kat-row { display: grid; grid-template-columns: 1fr 70px 24px; gap: 8px; align-items: center; font-size: 12px; }
.kat-bar { height: 12px; background: #e8effc; border-radius: 6px; overflow: hidden; }
.kat-bar i { display: block; height: 100%; background: var(--biru-2); border-radius: 6px; }
.kat-total { width: 86px; flex: none; background: #fff6df; border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 8px; }
.kat-total i { color: var(--emas); font-size: 24px; } .kat-total b { font-size: 26px; color: var(--biru-tua); } .kat-total small { font-size: 11px; }
.penting { display: flex; gap: 12px; align-items: center; padding: 9px 10px; background: #f8fafc; border-radius: 10px; margin-bottom: 8px; border: 1px solid var(--garis); }
.penting i { font-size: 24px; width: 28px; text-align: center; }
.penting small { display: block; color: var(--redup); font-size: 11.5px; margin-top: 2px; }
.penting b { font-size: 13px; }
.tr0 { color: #e4a400; } .tr1 { color: #9aa4b2; } .tr2 { color: #b87333; }

/* Kalendar */
.cal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; text-align: center; font-size: 12px; }
.cal-grid em { font-style: normal; font-weight: 600; color: var(--biru-tua); padding: 3px 0; }
.hari { height: 26px; display: grid; place-items: center; border-radius: 50%; position: relative; }
.hari.ada::after { content: ''; position: absolute; bottom: 1px; width: 4px; height: 4px; border-radius: 50%; background: var(--emas-tua); }
.hari.ini { background: var(--biru-2); color: #fff; font-weight: 600; }
.hari.ini.ada::after { background: #fff; }
.minggu { margin-top: 10px; background: #fff6df; border-radius: 10px; padding: 10px 12px; font-size: 12px; }
.mg-item { display: flex; gap: 8px; margin-top: 6px; align-items: baseline; }
.mg-t { font-weight: 600; white-space: nowrap; }

/* ===== Jadual ===== */
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { background: #eef3fc; color: var(--biru-tua); text-align: left; padding: 9px 10px; font-weight: 600; white-space: nowrap; }
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--garis); vertical-align: middle; }
.tbl tbody tr:hover { background: #f8fbff; }
.tbl.mini { font-size: 12px; }
.tbl.mini th, .tbl.mini td { padding: 7px 8px; }
.tbl tfoot td { background: var(--biru-2); color: #fff; font-weight: 700; padding: 9px 10px; }

/* ===== Halaman senarai ===== */
.page-head { display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; align-items: flex-start; margin-bottom: 14px; }
.page-head h2 { font-size: 18px; color: var(--biru-tua); }
.page-head h2 i { color: var(--emas); margin-right: 6px; }
.page-head p { color: var(--redup); font-size: 12.5px; margin-top: 3px; max-width: 640px; }
.page-tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.search { position: relative; }
.search i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--redup); font-size: 12px; }
.search input { border: 1px solid var(--garis); border-radius: 10px; padding: 8px 12px 8px 32px; width: 220px; background: #fff; }
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; color: var(--redup); font-size: 12.5px; flex-wrap: wrap; gap: 8px; }
.pager .pg { margin: 0 8px; }
.empty { text-align: center; padding: 36px 10px; color: var(--redup); }
.empty i { font-size: 34px; margin-bottom: 8px; color: #b9c4d6; }
.empty.small { padding: 18px 10px; }
.empty-big { text-align: center; padding: 50px 20px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.empty-big > i { font-size: 46px; color: var(--emas); }
.empty-big h2 { color: var(--biru-tua); } .empty-big p { color: var(--redup); max-width: 480px; }

/* ===== Borang & modal ===== */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 500; margin-bottom: 4px; color: var(--biru-tua); }
.field label b { color: var(--bahaya); }
.field input, .field select, .field textarea, .tambah-ahli select, .ahli-scroll select {
  width: 100%; border: 1px solid #cbd5e1; border-radius: 9px; padding: 8px 11px; background: #fff;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid rgba(74, 139, 240, .45); border-color: var(--biru-muda); }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(10, 30, 70, .5); display: grid; place-items: center; z-index: 100; padding: 16px; animation: fade .15s; }
.modal { background: #fff; border-radius: 14px; width: min(560px, 100%); max-height: 92vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.modal.sm { width: min(420px, 100%); } .modal.lg { width: min(780px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--garis); }
.modal-head h3 { color: var(--biru-tua); font-size: 16px; }
.modal-body { padding: 16px 18px 18px; overflow-y: auto; }
.confirm-msg { margin-bottom: 16px; line-height: 1.5; }
.tambah-ahli { display: grid; grid-template-columns: 1fr 190px auto; gap: 10px; margin-bottom: 10px; }
.ahli-scroll { max-height: 48vh; overflow-y: auto; }
.profil-head { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.profil-head p { color: var(--redup); font-size: 13px; }
.avatar-lg { width: 60px; height: 60px; border-radius: 50%; background: var(--biru); color: #fff; display: grid; place-items: center; font-size: 26px; }
.dua-kol { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 14px; }
.modal h4 { color: var(--biru-tua); margin: 4px 0 8px; font-size: 14px; }
.lst { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.lst li { background: #f8fafc; border: 1px solid var(--garis); border-radius: 8px; padding: 7px 10px; font-size: 13px; }
.lst small { display: block; color: var(--redup); font-size: 11.5px; }
.pajsk-big { font-size: 30px; font-weight: 700; color: var(--biru-tua); }
.pajsk-big small { font-size: 14px; color: var(--redup); }

/* ===== Tetapan & laporan ===== */
.tetapan { display: grid; gap: 14px; max-width: 860px; }
.logo-uploader { display: flex; gap: 14px; align-items: center; }
.logo-pratonton { width: 84px; height: 84px; border: 2px dashed #cbd5e1; border-radius: 12px; display: grid; place-items: center; color: #b9c4d6; font-size: 28px; overflow: hidden; background: #f8fafc; }
.logo-pratonton img { width: 100%; height: 100%; object-fit: contain; }
.stat-rekod { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-bottom: 16px; }
.stat-rekod div { background: #f1f5fb; border-radius: 10px; padding: 10px; text-align: center; }
.stat-rekod b { display: block; font-size: 20px; color: var(--biru-tua); } .stat-rekod small { color: var(--redup); }
.btn-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.lap-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; margin-bottom: 4px; }
.lap-kad { border: 1px solid var(--garis); border-radius: 12px; padding: 14px; display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; align-items: center; }
.lap-kad > i { font-size: 24px; color: var(--emas); }
.lap-kad small { display: block; color: var(--redup); font-size: 12px; }
.lap-btn { grid-column: 1 / -1; display: flex; gap: 8px; margin-top: 6px; }
#sijilBox { margin-top: 14px; }

/* ===== Toast ===== */
#toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: #fff; border-left: 4px solid var(--ok); padding: 11px 16px; border-radius: 10px; box-shadow: 0 6px 20px rgba(0, 0, 0, .18); display: flex; gap: 10px; align-items: center; animation: naik .25s; max-width: 360px; }
.toast.bad { border-color: var(--bahaya); } .toast.bad i { color: var(--bahaya); } .toast i { color: var(--ok); }
.toast.hide { opacity: 0; transition: opacity .3s; }
@keyframes fade { from { opacity: 0; } }
@keyframes naik { from { transform: translateY(10px); opacity: 0; } }

/* ===== Responsif ===== */
@media (max-width: 1500px) {
  .kpi-row { grid-template-columns: repeat(3, 1fr); }
  .row-a, .row-b { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
  .menu-btn { display: block; }
  .sidebar { position: fixed; left: 0; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.buka { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .4); }
  .head-tools { margin-left: 0; width: 100%; }
  .head-title h1 { font-size: 18px; }
  #view { padding: 14px; }
}
@media (max-width: 700px) {
  .kpi-row { grid-template-columns: 1fr 1fr; }
  .row-a, .row-b, .form-grid, .dua-kol { grid-template-columns: 1fr; }
  .stat-rekod { grid-template-columns: repeat(2, 1fr); }
  .tambah-ahli { grid-template-columns: 1fr; }
  .search input { width: 100%; }
}
.koku-pilihan, .koku-kepala { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.koku-pilihan { flex-wrap: wrap; }
.koku-kepala { justify-content: space-between; color: var(--biru-tua); }
.koku-kosong { color: var(--redup); margin-bottom: 12px; }
.koku-skrol { overflow-x: auto; }
.koku-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); min-width: 560px; border: 1px solid var(--garis); border-radius: 10px; overflow: hidden; }
.koku-hari { text-align: center; padding: 8px; background: var(--latar); color: var(--biru-tua); font-weight: 600; }
.koku-petak { min-height: 86px; padding: 6px; border-top: 1px solid var(--garis); border-right: 1px solid var(--garis); }
.koku-petak:nth-child(7n) { border-right: 0; }
.koku-luar { background: var(--latar); }
.koku-petak time { display: block; font-weight: 600; }
.koku-acara { display: block; width: 100%; margin-top: 4px; padding: 4px 6px; border: 0; border-radius: 5px; background: var(--latar); color: var(--biru-tua); font: inherit; font-size: 12px; text-align: left; overflow-wrap: anywhere; cursor: pointer; }
.koku-acara:hover { background: var(--garis); }
.koku-tahunan { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 155px), 1fr)); gap: 10px; }
.koku-tahunan .koku-bulan { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 14px; }
.koku-bulan span { color: var(--redup); }
.koku-butiran { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0; }
.koku-butiran dt { font-weight: 600; }
.koku-butiran dd { margin: 0; overflow-wrap: anywhere; }

@media print { .sidebar, .topbar { display: none; } }
