/* Tema Biru & Emas */
:root {
  --navy: #0a2457;
  --navy-2: #123b86;
  --blue: #1f66d6;
  --blue-l: #e3eefc;
  --gold: #d9a520;
  --gold-d: #b8860b;
  --gold-l: #fdf1cf;
  --green: #168a3a;
  --green-l: #dcf4e3;
  --red: #c62839;
  --red-l: #fde0e5;
  --bg: #eef2f9;
  --card: #fff;
  --text: #17233c;
  --muted: #6b7a96;
  --line: #e2e8f3;
  --side-w: 230px;
  --top-h: 78px;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(10, 36, 87, .08);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: 'Poppins', system-ui, -apple-system, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
a { color: var(--blue); }
h1, h2, h3, p { margin: 0; }

/* ---------- Susun atur ---------- */
.app { min-height: 100vh; }
.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--top-h); z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 24px 0 18px; color: #fff;
  background: linear-gradient(100deg, var(--navy) 0%, var(--navy-2) 100%);
  border-bottom: 3px solid var(--gold);
}
.menu-toggle { display: none; background: none; border: 0; color: #fff; font-size: 22px; cursor: pointer; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 0 0 calc(var(--side-w) - 18px); padding-right: 12px; }
.logo { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; font-size: 22px; color: var(--gold); border: 2px solid var(--gold); background: rgba(255, 255, 255, .06); flex: none; }
.brand-text { min-width: 0; }
.brand-text h1 { font-size: 14px; font-weight: 700; line-height: 1.35; overflow-wrap: anywhere; }
.topbar-page-title { flex: 1; min-width: 0; font-size: clamp(15px, 1.5vw, 22px); font-weight: 600; line-height: 1.3; }
.topbar-right { display: flex; align-items: center; gap: 18px; flex-shrink: 0; }
.sesi-pill { display: flex; align-items: center; gap: 8px; background: rgba(255, 255, 255, .1); padding: 9px 14px; border-radius: 12px; font-weight: 600; }
.sesi-pill select { background: transparent; color: #fff; border: 0; font: inherit; font-weight: 700; cursor: pointer; outline: 0; }
.sesi-pill select option { color: #000; }
.baki-box { display: flex; align-items: center; gap: 12px; padding-left: 18px; border-left: 1px solid rgba(255, 255, 255, .25); }
.baki-icon { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: rgba(255, 255, 255, .1); font-size: 20px; color: var(--gold); }
.baki-box small { display: block; font-size: 12px; color: #cfe0ff; }
.baki-box strong { font-size: 22px; color: #ffd45c; font-weight: 700; white-space: nowrap; }

.sidebar {
  position: fixed; top: var(--top-h); bottom: 0; left: 0; width: var(--side-w); z-index: 20;
  display: flex; flex-direction: column; padding: 14px 0 0; overflow: hidden;
  background: linear-gradient(180deg, var(--navy-2) 0%, var(--navy) 100%);
}
.sidebar a { display: flex; align-items: center; gap: 14px; padding: 12px 20px; color: #dbe7ff; text-decoration: none; font-weight: 500; border-radius: 0 28px 28px 0; margin-right: 12px; transition: .15s; }
.sidebar a i { width: 20px; text-align: center; font-size: 16px; }
.sidebar a:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.sidebar a.active { background: linear-gradient(90deg, var(--gold), #f0c24a); color: var(--navy); font-weight: 700; }
.side-art { margin-top: auto; padding: 20px; text-align: center; font-size: 80px; color: rgba(255, 255, 255, .08); }
.backdrop { display: none; }

.content { margin-left: var(--side-w); padding: calc(var(--top-h) + 18px) 18px 30px; max-width: 1500px; }

/* ---------- Kad & KPI ---------- */
.page-head { display: flex; justify-content: flex-end; align-items: center; margin-bottom: 14px; gap: 12px; flex-wrap: wrap; }
.page-head h2 { font-size: 20px; color: var(--navy); display: flex; align-items: center; gap: 10px; }
.page-head h2 i { color: var(--gold-d); }
.card { background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px; border: 1px solid var(--line); }
.card-title { font-size: 16px; color: var(--navy); margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.card-title i { color: var(--gold-d); }
.notice { background: var(--gold-l); border: 1px solid var(--gold); color: #6b4e00; padding: 12px 16px; border-radius: 12px; margin-bottom: 14px; }
.hint { color: var(--muted); font-size: 12.5px; margin-top: 10px; line-height: 1.5; }
.muted { color: var(--muted); }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 14px; }
.kpis.three { grid-template-columns: repeat(3, 1fr); }
.kpi { display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: var(--radius); border: 1px solid rgba(0, 0, 0, .04); box-shadow: var(--shadow); }
.kpi-ic { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; font-size: 24px; flex: none; background: rgba(255, 255, 255, .7); }
.kpi small { display: block; color: #3b4a66; font-size: 12.5px; line-height: 1.35; }
.kpi strong { display: block; font-size: 24px; font-weight: 700; margin-top: 2px; white-space: nowrap; }
.kpi strong.sm { font-size: 15px; white-space: normal; }
.kpi.green { background: var(--green-l); } .kpi.green .kpi-ic { color: var(--green); } .kpi.green strong { color: #0b5c25; }
.kpi.red { background: var(--red-l); } .kpi.red .kpi-ic { color: var(--red); } .kpi.red strong { color: #9b1424; }
.kpi.blue { background: var(--blue-l); } .kpi.blue .kpi-ic { color: var(--blue); } .kpi.blue strong { color: var(--navy); }
.kpi.gold { background: var(--gold-l); } .kpi.gold .kpi-ic { color: var(--gold-d); } .kpi.gold strong { color: #7a5a00; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-2.wide-left { grid-template-columns: 1.55fr 1fr; }
.grid-2 > .card { margin-bottom: 14px; min-width: 0; }

.chart-box { position: relative; height: 270px; }
.donut-wrap { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.donut-box { position: relative; width: 190px; height: 190px; flex: none; margin: 0 auto; }
.donut-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; }
.donut-center small { font-weight: 600; } .donut-center b { font-size: 15px; }
.legend { list-style: none; padding: 0; margin: 0; flex: 1; min-width: 230px; font-size: 12.5px; }
.legend li { display: grid; grid-template-columns: 14px 1fr auto auto; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.legend li i { width: 14px; height: 14px; border-radius: 4px; display: block; }
.legend em { font-style: normal; color: var(--muted); }

/* ---------- Jadual ---------- */
.table-scroll { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; padding: 9px 10px; background: #eaf0fb; color: var(--navy); font-weight: 600; white-space: nowrap; }
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr:hover { background: #f7faff; }
.tbl.compact td { padding: 7px 10px; }
.tbl .num, .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl .center, .center { text-align: center; }
.tbl .no { width: 28px; color: var(--muted); }
.nowrap { white-space: nowrap; }
.pos { color: var(--green); font-weight: 600; } .neg { color: var(--red); font-weight: 600; }
.tbl tfoot td { padding: 10px; font-weight: 700; }
.foot-green td { background: #c9f2b9; color: #0b4d1f; }
.foot-red td { background: #fbc7d4; color: #7d1022; }
.foot-gold td { background: var(--gold-l); color: #5f4400; }
.tbl-card { padding: 0; overflow: hidden; }
.tbl-card .tbl td, .tbl-card .tbl tfoot td { padding-left: 16px; padding-right: 16px; }
.tbl-head { display: flex; justify-content: space-between; padding: 11px 16px; color: #fff; font-weight: 600; }
.tbl-head.green { background: #0b6b2d; } .tbl-head.red { background: #b3243a; }
.tbl-head i { margin-right: 6px; }

.pill { display: inline-block; padding: 3px 12px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.p-green { background: #cdf2d8; color: #0b5c25; } .p-red { background: #fdd0d8; color: #a11b2d; }
.p-blue { background: #d6e6ff; color: #1b4fa8; } .p-gray { background: #e5e9f1; color: #4b5873; }

.bar { height: 8px; background: #e6ecf7; border-radius: 6px; overflow: hidden; }
.bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--blue), #4f95f5); border-radius: 6px; }
.bar span.over { background: var(--red); }

/* ---------- Butang & borang ---------- */
.btn { border: 0; border-radius: 10px; padding: 10px 18px; font: inherit; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; transition: .15s; }
.btn.gold { background: linear-gradient(135deg, var(--gold), #f0c24a); color: var(--navy); }
.btn.gold:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn.ghost { background: #fff; color: var(--navy); border: 1.5px solid var(--navy-2); }
.btn.ghost:hover { background: var(--blue-l); }
.btn.danger { background: var(--red); color: #fff; }
.btn:disabled { opacity: .6; cursor: wait; }
.btn-row { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 10px; }
.icon-btn { background: none; border: 0; cursor: pointer; width: 30px; height: 30px; border-radius: 8px; color: var(--navy-2); font-size: 14px; }
.icon-btn:hover { background: var(--blue-l); } .icon-btn.del { color: var(--red); } .icon-btn.del:hover { background: var(--red-l); }

.form { display: flex; flex-direction: column; gap: 12px; }
.form label, .fl { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--navy); }
.form label.inline { flex-direction: row; align-items: center; font-weight: 400; gap: 6px; }
input, select, textarea { font: inherit; font-weight: 400; color: var(--text); padding: 9px 11px; border: 1.5px solid #cfd8ea; border-radius: 9px; background: #fff; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(31, 102, 214, .15); }
input[type=checkbox] { width: auto; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 12px; }
.toolbar select, .toolbar input[type=date] { width: auto; min-width: 150px; }
.search { position: relative; flex: 1; min-width: 200px; }
.search i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input { padding-left: 34px; }
.resit-now { font-size: 12.5px; background: var(--blue-l); padding: 8px 10px; border-radius: 8px; display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.resit-img { max-width: 100%; display: block; margin: 0 auto; border-radius: 8px; }
.resit-frame { width: 100%; height: 70vh; border: 0; }

/* ---------- Modal & toast ---------- */
.modal-wrap { position: fixed; inset: 0; background: rgba(10, 36, 87, .55); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 480px; max-height: 92vh; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
.modal.wide { max-width: 760px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; background: linear-gradient(100deg, var(--navy), var(--navy-2)); color: #fff; border-bottom: 3px solid var(--gold); }
.modal-head h3 { font-size: 16px; } .modal-head .icon-btn { color: #fff; } .modal-head .icon-btn:hover { background: rgba(255, 255, 255, .15); }
.modal-body { padding: 18px; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 18px; border-top: 1px solid var(--line); background: #f7f9fd; }
.confirm-msg { line-height: 1.6; }
#toast-root { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--navy); color: #fff; padding: 11px 16px; border-radius: 10px; border-left: 4px solid var(--gold); box-shadow: var(--shadow); transition: .4s; }
.toast.err { border-left-color: #ff6b7d; background: #7d1022; }
.toast.hide { opacity: 0; transform: translateY(8px); }

/* ---------- Penyata ---------- */
.statement { max-width: 780px; margin: 0 auto 14px; }
.stmt-title { text-align: center; margin-bottom: 14px; }
.stmt-title h3 { color: var(--navy); letter-spacing: .5px; }
.stmt-title p { color: var(--muted); font-size: 13px; }
.stmt td { border-bottom: 1px dotted var(--line); }
.stmt tr.sec td { font-weight: 700; background: #f2f6fd; color: var(--navy); }
.stmt td.ind { padding-left: 32px; }
.stmt tr.tot td { font-weight: 700; border-top: 1.5px solid var(--navy); }
.stmt tr.grand td { font-weight: 700; font-size: 15px; background: var(--gold-l); border-top: 2px solid var(--gold); border-bottom: 3px double var(--gold-d); }
.sign { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 50px; text-align: center; }
.sign .line { border-top: 1.5px solid #333; margin-bottom: 6px; }
.sign b, .sign small { display: block; } .sign small { color: var(--muted); }
.stmt-date { margin-top: 24px; font-size: 12px; color: var(--muted); text-align: right; }

.print-only { display: none; }
.print-head { text-align: center; margin-bottom: 12px; }
.print-head h2 { font-size: 20px; } .print-head h3 { font-size: 15px; font-weight: 500; } .print-head p { font-size: 12px; }

/* ---------- Responsif ---------- */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-2.wide-left { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
  :root { --top-h: 112px; }
  .menu-toggle { display: block; }
  .topbar { padding: 8px 12px; gap: 8px; flex-wrap: wrap; }
  .brand { flex: 1; padding-right: 0; }
  .topbar-page-title { order: 4; flex: 0 0 100%; font-size: 14px; }
  .topbar-right { gap: 8px; }
  .sesi-pill { font-size: 11px; }
  .brand-text h1 { font-size: 14px; white-space: normal; line-height: 1.2; }
  .logo { width: 38px; height: 38px; font-size: 17px; }
  .baki-icon { display: none; } .baki-box { padding-left: 10px; } .baki-box strong { font-size: 15px; } .baki-box small { font-size: 10px; }
  .sesi-pill { padding: 6px 8px; } .sesi-pill i { display: none; }
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 4px 0 20px rgba(0, 0, 0, .3); }
  .backdrop.show { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 15; }
  .content { margin-left: 0; padding: calc(var(--top-h) + 14px) 12px 24px; }
  .kpis, .kpis.three { grid-template-columns: 1fr; }
  .row2 { grid-template-columns: 1fr; }
  .toolbar select, .toolbar input[type=date] { width: 100%; }
}

/* ---------- Cetak ---------- */
@media print {
  @page { margin: 14mm; }
  body { background: #fff; font-size: 12px; }
  .no-print, .sidebar, .topbar, .backdrop, #toast-root, #modal-root { display: none !important; }
  .print-only { display: block; }
  .content { margin: 0; padding: 0; max-width: none; }
  .card, .kpi { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  .kpi { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .tbl th, .foot-green td, .foot-red td, .foot-gold td, .stmt tr.sec td, .stmt tr.grand td { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .page-head { display: none; }
}
