:root {
  --navy: #064e3b;
  --navy-2: #065f46;
  --blue: #047857;
  --gold: #facc15;
  --gold-2: #fef08a;
  --gold-ink: #856000;
  --green: #047857;
  --red: #d9363e;
  --purple: #8b4fd9;
  --pink: #e0488b;
  --teal: #0e97b0;
  --ink: #142e26;
  --muted: #4e655c;
  --line: #deece5;
  --bg: #f2f8f4;
  --tint: #e9f5ee;
  --card: #fff;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(6, 78, 59, .08);
  --sb: 232px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: "Nunito Sans", "Segoe UI", sans-serif; background: var(--bg); color: var(--ink); font-size: 14px; }
a { color: var(--blue); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- Log masuk ---------- */
.login-page {
  display: grid; place-items: center; min-height: 100vh; min-height: 100dvh; padding: 24px;
  background: radial-gradient(ellipse at 10% 10%, #d1fae5, transparent 55%),
    radial-gradient(ellipse at 90% 90%, #fef9c3, transparent 45%), var(--bg);
}
.login-panel {
  display: grid; grid-template-columns: .95fr 1fr; width: min(100%, 860px); overflow: hidden;
  background: var(--card); border: 1px solid var(--line); border-radius: 25px;
  box-shadow: 0 24px 70px rgba(6,78,59,.17);
}
.login-brand {
  display: flex; flex-direction: column; justify-content: center; align-items: flex-start; padding: clamp(26px, 5vw, 54px);
  color: #dcfce7; background: radial-gradient(circle at 95% 8%, #047857, transparent 60%), var(--navy);
  border-bottom: 5px solid var(--gold);
}
.login-mark {
  display: grid; place-items: center; width: 60px; height: 60px; margin-bottom: 24px;
  border-radius: 18px; background: var(--gold); color: var(--navy); font-size: 27px;
}
.login-kicker { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .13em; color: var(--gold-ink); }
.login-brand .login-kicker { color: var(--gold-2); }
.login-brand-title {
  margin: 10px 0 0; color: #fff; font-size: clamp(24px, 4vw, 37px); line-height: 1.12; font-weight: 800;
}
.login-brand p:last-child { max-width: 30ch; line-height: 1.55; }
.login-form { padding: clamp(24px, 5vw, 50px); }
.login-form h1 { margin: 8px 0 0; color: var(--navy); font-size: clamp(24px, 4vw, 32px); line-height: 1.15; }
#login-hint, #login-loading { color: var(--muted); margin: 10px 0 22px; }
#login-fields { display: grid; gap: 14px; }
.login-form input { min-height: 44px; }
.password-field { position: relative; }
.password-field input { width: 100%; padding-right: 44px; }
.password-field button { position: absolute; inset: 0 0 0 auto; width: 42px; color: var(--navy); }
.login-submit { justify-content: center; min-height: 44px; margin-top: 4px; }
#login-error { padding: 9px 12px; border-radius: 9px; background: #fde1e3; color: #9c1c23; }
.account-form { max-width: 500px; }
.account-form .field { margin: 12px 0; }
.account-message { color: var(--navy); font-weight: 700; }

@media (max-width: 650px) {
  .login-page { padding: 14px; }
  .login-panel { grid-template-columns: 1fr; max-width: 440px; }
  .login-mark { width: 44px; height: 44px; margin-bottom: 12px; font-size: 20px; }
  .login-brand p:last-child { display: none; }
}

/* ---------- Sidebar ---------- */
#sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sb); display: flex; flex-direction: column; color: #fff;
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-2) 60%, var(--blue) 100%); z-index: 30; overflow-x: hidden; overflow-y: auto; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.3) transparent; }
.brand { text-align: center; padding: 16px 12px 12px; }
.brand-icon { font-size: 34px; color: var(--gold-2); }
.brand-title { font-weight: 800; font-size: 15px; line-height: 1.25; margin-top: 6px; }
.brand-sub { color: var(--gold-2); font-size: 12px; font-weight: 700; margin-top: 4px; }
.brand::after { content: ""; display: block; width: 34px; height: 3px; background: var(--gold); margin: 10px auto 0; border-radius: 3px; }
#menu { padding: 4px 8px; }
#menu a { display: flex; align-items: center; gap: 12px; color: #fff; padding: 10px 12px; border-radius: 9px; font-weight: 600; margin-bottom: 2px; }
#menu a i:first-child { width: 20px; text-align: center; font-size: 15px; }
#menu a:hover { background: rgba(255,255,255,.12); }
#menu a.active { background: linear-gradient(90deg, var(--gold-2), var(--gold)); color: #231800; font-weight: 800; box-shadow: 0 3px 10px rgba(250,204,21,.35); }
#menu .caret { margin-left: auto; font-size: 11px; transition: transform .2s; }
#menu .open > a .caret { transform: rotate(180deg); }
#menu .sub { display: none; }
#menu .open > .sub { display: block; }
#menu .sub a { padding: 7px 12px 7px 30px; font-size: 13px; }
#menu .sub a i:first-child { font-size: 9px; width: 10px; }
.sb-art { margin-top: auto; min-height: 150px; position: relative; flex-shrink: 0; }
.sb-art img, .sb-art svg { display: block; width: 100%; height: 170px; object-fit: cover; }
.sb-art::before { content: ""; position: absolute; left: -10%; right: -10%; top: -12px; height: 24px; border-top: 5px solid var(--gold); border-radius: 50%; transform: rotate(-6deg); }

/* ---------- Header ---------- */
#main { margin-left: var(--sb); min-height: 100vh; }
#header { display: flex; align-items: center; gap: 14px; background: #fff; padding: 0 20px 0 22px; height: 64px;
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; overflow: hidden; }
.hd-logo { width: 46px; height: 46px; display: grid; place-items: center; font-size: 30px; color: var(--gold-ink); flex-shrink: 0; }
.hd-logo img { max-width: 100%; max-height: 100%; object-fit: contain; }
.hd-text { min-width: 0; }
.hd-nama { font-weight: 800; font-size: 17px; color: var(--navy); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hd-sub { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hd-right { margin-left: auto; align-self: stretch; display: flex; align-items: center; gap: 18px; padding: 0 4px 0 90px; position: relative; }
.hd-right::before { content: ""; position: absolute; inset: -2px -30px -2px 20px; background: linear-gradient(100deg, var(--navy), var(--blue));
  clip-path: polygon(0 0, 100% 0, 100% 100%, 60px 100%); border-top: 4px solid var(--gold); }
.hd-right > * { position: relative; }
.icon-btn { background: none; border: 0; font-size: 19px; padding: 6px; }
#btn-menu { display: none; color: var(--navy); }
.bell { color: #fff; position: relative; }
#bell-count { position: absolute; top: -2px; right: -8px; background: var(--red); border-radius: 20px; font-size: 10px; font-weight: 800; padding: 1px 5px; }
.user { display: flex; align-items: center; gap: 10px; color: #fff; }
.user b { display: block; font-size: 13px; }
.user small { display: block; font-size: 11.5px; opacity: .85; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: #fff; color: var(--blue); display: grid; place-items: center; }

/* ---------- Content ---------- */
#content { padding: 18px 20px 32px; }
.loading { padding: 60px; text-align: center; color: var(--muted); }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-bottom: 14px; }
.page-title { display: flex; gap: 12px; align-items: center; margin-right: auto; }
.page-title > i { font-size: 30px; color: var(--gold-ink); }
.page-title h1 { margin: 0; font-size: 24px; color: var(--navy); }
.page-title p { margin: 0; color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 4px; font-weight: 700; font-size: 12px; }
input, select, textarea { border: 1px solid #a7c7b7; background: #fff; border-radius: 9px; padding: 8px 11px; font-weight: 400; font-size: 14px; max-width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(4,120,87,.35); border-color: var(--blue); }
input:disabled, select:disabled { background: var(--bg); }

.btn { display: inline-flex; align-items: center; gap: 8px; border: 0; border-radius: 9px; padding: 9px 16px; font-weight: 700;
  background: linear-gradient(180deg, var(--blue), var(--navy-2)); color: #fff; white-space: nowrap; }
.btn:hover { filter: brightness(1.07); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.gold { background: linear-gradient(180deg, var(--gold-2), var(--gold)); color: #231800; }
.btn.green { background: var(--green); }
.btn.red { background: linear-gradient(180deg, #e84a52, #c0272f); }
.btn.light { background: #fff; color: var(--blue); border: 1px solid #a7c7b7; }
.btn.sm { padding: 5px 10px; font-size: 12px; gap: 5px; }
.actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; min-width: 0; }
.card + .card { margin-top: 14px; }
.grid > .card + .card { margin-top: 0; }
.card h3 { margin: 0 0 10px; font-size: 15px; color: var(--navy); display: flex; align-items: center; gap: 8px; }
.card h3 > i { color: var(--blue); }
.card h3 .btn, .card h3 .right { margin-left: auto; }
.grid { display: grid; gap: 14px; margin-bottom: 14px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); }
.g4 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.charts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 1560px) { .charts { grid-template-columns: 1.35fr 1fr 1fr 1fr; } }
@media (max-width: 760px) { .charts { grid-template-columns: minmax(0, 1fr); } }
.g6 { grid-template-columns: repeat(auto-fit, minmax(155px, 1fr)); gap: 10px; }

/* ---------- Kad statistik ---------- */
.stat { display: flex; align-items: center; gap: 12px; padding: 11px 12px; }
.stat .ic { width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; font-size: 20px; flex-shrink: 0;
  color: var(--c, var(--blue)); background: color-mix(in srgb, var(--c, var(--blue)) 14%, white); }
.stat small { display: block; color: var(--muted); font-weight: 700; font-size: 12px; }
.stat b { display: block; font-size: 22px; font-weight: 800; color: var(--v, var(--ink)); }
.money { background: linear-gradient(120deg, #fff, color-mix(in srgb, var(--c) 17%, white)); border-color: color-mix(in srgb, var(--c) 30%, white); }
.money .ic { background: #fff; }
.money b { font-size: 25px; color: var(--v, var(--c)); }
.ring { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0;
  background: conic-gradient(var(--green) calc(var(--p) * 1%), var(--line) 0); }
.ring span { width: 40px; height: 40px; background: #fff; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 800; }

/* ---------- Carta ---------- */
.chart-box { position: relative; height: 215px; }
.donut-wrap { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.donut { position: relative; width: 160px; height: 160px; margin: 0 auto; }
.donut .center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; font-weight: 700; pointer-events: none; line-height: 1.15; z-index: 0; }
.donut canvas { position: relative; z-index: 1; }
.donut .center b { font-size: 22px; }
.donut .center i { font-size: 24px; color: var(--gold-ink); }
.legend { list-style: none; margin: 0; padding: 0; flex: 1; min-width: 130px; font-size: 12px; }
.legend li { display: flex; gap: 8px; margin-bottom: 8px; }
.legend li::before { content: ""; width: 11px; height: 11px; border-radius: 50%; background: var(--c); flex-shrink: 0; margin-top: 3px; }
.bar-row { display: grid; grid-template-columns: 62px 1fr 52px; gap: 10px; align-items: center; margin: 11px 0; font-weight: 700; font-size: 12.5px; }
.progress { height: 10px; background: var(--line); border-radius: 10px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--c, var(--blue)); border-radius: 10px; }

.fund { background: linear-gradient(135deg, #fff 35%, color-mix(in srgb, var(--c) 15%, white)); position: relative; overflow: hidden; }
.fund h3 > i { color: var(--c); font-size: 20px; }
.fund .big { font-size: 21px; font-weight: 800; color: color-mix(in srgb, var(--c) 75%, black); margin: 8px 0; }
.fund .progress { height: 14px; margin-top: 10px; }
.fund .deco { position: absolute; right: 12px; bottom: 6px; font-size: 56px; color: var(--c); opacity: .18; }

/* ---------- Jadual ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 9px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { background: var(--tint); color: var(--navy); font-size: 12px; white-space: nowrap; }
tbody tr:hover { background: var(--bg); }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.center-cell { text-align: center; }
.nowrap { white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.empty { text-align: center; color: var(--muted); padding: 26px 10px; }
.empty i { display: block; font-size: 28px; margin-bottom: 8px; opacity: .4; }
.badge { display: inline-block; border-radius: 20px; padding: 2px 11px; font-size: 11.5px; font-weight: 800; white-space: nowrap; }
.b-green { background: #d1fae5; color: var(--navy-2); }
.b-red { background: #fde1e3; color: #b3242b; }
.b-gold { background: #fef9c3; color: var(--gold-ink); }
.b-blue { background: var(--tint); color: var(--navy-2); }
.b-gray { background: #e8eeea; color: var(--muted); }
.plus { color: var(--green); font-weight: 700; }
.minus { color: var(--red); font-weight: 700; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; align-items: center; }
.toolbar .grow { flex: 1; min-width: 180px; }
.toolbar .spacer { margin-left: auto; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs a { padding: 8px 16px; border-radius: 22px; background: #fff; border: 1px solid var(--line); font-weight: 700; color: var(--navy); }
.tabs a.active { background: var(--navy-2); color: #fff; border-color: var(--navy-2); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid h4 { margin: 8px 0 0; color: var(--blue); border-bottom: 2px solid var(--gold-2); padding-bottom: 4px; }
.hint { font-weight: 400; color: var(--muted); font-size: 12px; margin: 2px 0; }
.alert { border-radius: 11px; padding: 11px 14px; margin-bottom: 14px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; background: #fff6dc; border: 1px solid #f1d58a; }
.alert.info { background: var(--tint); border-color: #a7c7b7; }
.alert .btn { margin-left: auto; }
.preview-img { max-width: 220px; max-height: 110px; border: 1px dashed #a7c7b7; border-radius: 10px; padding: 6px; object-fit: contain; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--tint); border-radius: 20px; padding: 5px 8px 5px 14px; font-weight: 700; }
.chip button { border: 0; background: #fff; border-radius: 50%; width: 23px; height: 23px; font-size: 11px; color: var(--blue); }
.chip button.del { color: var(--red); }

/* ---------- Modal & toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(5,46,35,.55); display: flex; align-items: flex-start; justify-content: center; padding: 40px 14px; overflow-y: auto; z-index: 50; }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 580px; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal.wide { max-width: 940px; }
.modal-head { background: linear-gradient(90deg, var(--navy), var(--blue)); color: #fff; padding: 13px 18px; display: flex; border-bottom: 4px solid var(--gold); }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-head button { margin-left: auto; background: none; border: 0; color: #fff; font-size: 18px; }
.modal-body { padding: 18px; }
.modal-foot { padding: 0 18px 18px; display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.form-error { margin: 0 18px 12px; background: #fde1e3; color: #9c1c23; border-radius: 9px; padding: 9px 12px; font-weight: 700; }
#toast-root { position: fixed; right: 18px; bottom: 18px; z-index: 60; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--green); color: #fff; border-radius: 10px; padding: 12px 18px; font-weight: 700; box-shadow: var(--shadow); max-width: 360px; }
.toast.error { background: var(--red); }

/* ---------- Kertas laporan ---------- */
.paper { background: #fff; max-width: 860px; margin: 0 auto; padding: 30px 34px; border: 1px solid var(--line); box-shadow: var(--shadow); color: #000; overflow-x: auto; }
.rpt-head { display: flex; gap: 14px; align-items: center; border-bottom: 3px double var(--navy); padding-bottom: 10px; margin-bottom: 14px; }
.rpt-head img { width: 62px; height: 62px; object-fit: contain; }
.rpt-head h2 { margin: 0; font-size: 18px; text-transform: uppercase; }
.rpt-head div div { font-size: 12px; }
.rpt-title { text-align: center; margin: 0 0 14px; font-size: 15px; text-transform: uppercase; }
.paper table { font-size: 12px; margin-bottom: 14px; }
.paper th, .paper td { border: 1px solid #a7bdb1; padding: 5px 7px; }
.paper th { background: var(--tint); }
.paper tr.total td { font-weight: 800; background: #fef9c3; }
.paper h4 { margin: 14px 0 6px; }
.sign { display: flex; justify-content: space-between; gap: 20px; margin-top: 55px; font-size: 12px; page-break-inside: avoid; }
.sign div { flex: 1; border-top: 1px solid #000; padding-top: 5px; }
.rcpt-meta td { border: 0 !important; padding: 3px 4px !important; }
.rcpt-total { border: 2px solid var(--navy); border-radius: 8px; padding: 10px 14px; font-size: 17px; font-weight: 800; display: flex; justify-content: space-between; }
#print-root { display: none; }

@media (max-width: 960px) {
  #sidebar { transform: translateX(-100%); transition: transform .2s; }
  body.menu-open #sidebar { transform: none; }
  body.menu-open #overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 25; }
  #main { margin-left: 0; }
  #btn-menu { display: block; }
  .hd-right { padding-left: 60px; gap: 12px; }
  .user span:last-child { display: none; }
}
@media (max-width: 620px) {
  .form-grid, .g2, .g3 { grid-template-columns: minmax(0, 1fr); }
  #content { padding: 12px; }
  .hd-logo { display: none; }
}

@media print {
  @page { size: A4; margin: 12mm; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body { background: #fff; }
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block; }
  #print-root .paper { border: 0; box-shadow: none; padding: 0; max-width: none; overflow: visible; }
  tr { page-break-inside: avoid; }
  thead { display: table-header-group; }
}
