/* =========================================================
   style.css — Tema Biru & Emas
   ========================================================= */
:root {
  --navy-950: #061538;
  --navy-900: #0a2259;
  --navy-800: #0f3079;
  --blue: #1f5fe0;
  --blue-soft: #e4ecfd;
  --gold: #f6b800;
  --gold-d: #c98f00;
  --gold-soft: #fff4cc;
  --bg: #eaf0fb;
  --card: #ffffff;
  --ink: #14213d;
  --muted: #6b7690;
  --line: #dbe3f3;
  --green: #1f9d4a;
  --red: #d8433a;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(10, 34, 89, .09);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: 'Poppins', system-ui, sans-serif; background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.45; }
a { color: var(--blue); }
h2, h3, h4 { margin: 0; }
.muted { color: var(--muted); }
small { font-size: 12px; }

/* ---------- Susun atur ---------- */
.app { display: grid; grid-template-columns: 224px 1fr; grid-template-rows: auto 1fr; min-height: 100vh; }
.banner { grid-column: 1 / -1; grid-row: 1; }
.sidebar { grid-column: 1; grid-row: 2; }
.view { grid-column: 2; grid-row: 2; padding: 18px 22px 40px; min-width: 0; }

/* ---------- Banner ---------- */
.banner {
  position: relative; overflow: hidden; display: flex; align-items: center; gap: 12px;
  padding: 10px 24px; color: #fff;
  background: linear-gradient(100deg, var(--navy-950) 0%, var(--navy-900) 45%, #1747b8 100%);
  border-bottom: 4px solid var(--gold);
}
.banner-logo .logo-img { display: block; width: 50px; height: 59px; object-fit: contain; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .4)); }
.banner-text { position: relative; z-index: 2; }
.banner .t1 { font-weight: 700; font-size: 13px; letter-spacing: .5px; }
.banner .t2 { font-weight: 800; font-size: 23px; line-height: 1.1; color: var(--gold); text-shadow: 0 2px 6px rgba(0, 0, 0, .3); }
.banner .t3 { font-size: 13px; opacity: .95; }
.banner-deco { position: absolute; right: -40px; top: 0; bottom: 0; width: 46%; transform: skewX(-24deg); pointer-events: none; }
.banner-deco span { position: absolute; top: 0; bottom: 0; }
.banner-deco span:nth-child(1) { right: 0; width: 55%; background: linear-gradient(90deg, rgba(246, 184, 0, 0), rgba(246, 184, 0, .12)); }
.banner-deco span:nth-child(2) { right: 34%; width: 14px; background: var(--gold); opacity: .85; }
.banner-deco span:nth-child(3) { right: 28%; width: 6px; background: #4f8bff; opacity: .9; }
.menu-toggle { display: none; background: rgba(255, 255, 255, .12); border: 0; color: #fff; width: 40px; height: 40px; border-radius: 8px; font-size: 18px; cursor: pointer; position: relative; z-index: 3; }

/* ---------- Sidebar ---------- */
.sidebar {
  background: linear-gradient(180deg, var(--navy-900), var(--navy-950));
  padding: 14px 10px; display: flex; flex-direction: column; justify-content: space-between;
  position: sticky; top: 0; align-self: start; height: calc(100vh - 0px); max-height: 100vh; overflow-y: auto;
}
.sidebar nav { display: flex; flex-direction: column; gap: 3px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 10px;
  color: #d4def5; text-decoration: none; font-weight: 500; transition: .15s; border-left: 4px solid transparent;
}
.nav-item i { width: 20px; text-align: center; font-size: 16px; }
.nav-item:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.nav-item.active { background: linear-gradient(90deg, var(--blue), #2f74f5); color: #fff; border-left-color: var(--gold); box-shadow: 0 3px 10px rgba(31, 95, 224, .45); }
.nav-item.active i { color: var(--gold); }
.nav-bottom { padding-top: 10px; border-top: 1px solid rgba(255, 255, 255, .12); margin-top: 10px; }

/* ---------- Penapis ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; margin-bottom: 16px; }
.fbox { display: flex; flex-direction: column; gap: 4px; min-width: 170px; flex: 1 1 170px; max-width: 280px; }
.fbox.wide { max-width: 420px; flex: 2 1 240px; }
.fbox span, .fld span { font-size: 12px; font-weight: 600; color: var(--navy-800); }
select, input[type=text], input[type=number], input[type=date], input[type=time], input:not([type]), textarea {
  font: inherit; color: var(--ink); background: #fff; border: 1.5px solid var(--line); border-radius: 9px; padding: 9px 12px; width: 100%; outline: none; transition: .15s;
}
input[type=color] { width: 100%; height: 40px; border: 1.5px solid var(--line); border-radius: 9px; padding: 3px; background: #fff; cursor: pointer; }
select:focus, input:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(31, 95, 224, .15); }
.infocard {
  margin-left: auto; display: flex; gap: 26px; padding: 10px 20px; border-radius: var(--radius);
  background: var(--blue-soft); border: 1px solid #cbd8f6;
}
.infocard > div { display: grid; grid-template-columns: auto 1fr; column-gap: 10px; align-items: center; }
.infocard i { grid-row: span 2; font-size: 22px; color: var(--navy-800); }
.infocard small { color: var(--muted); }
.infocard b { font-size: 14px; }
.infocard.small { margin-left: 0; }
.infocard.small i { font-size: 20px; }

/* ---------- Kad statistik ---------- */
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 16px; }
.stat { color: #fff; border-radius: var(--radius); padding: 16px 16px; display: flex; gap: 14px; align-items: center; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.stat::after { content: ''; position: absolute; right: -30px; top: -30px; width: 100px; height: 100px; border-radius: 50%; background: rgba(255, 255, 255, .1); }
.stat > i { font-size: 38px; opacity: .92; }
.stat span { display: block; font-weight: 600; font-size: 14px; }
.stat b { display: block; font-size: 36px; line-height: 1.1; font-weight: 800; }
.stat small { display: block; opacity: .95; font-size: 11.5px; }
.stat .up { color: #9dffb4; } .stat .down { color: #ffb4ae; }
.c-blue { background: linear-gradient(135deg, #1b4fd0, #2f7bf5); }
.c-green { background: linear-gradient(135deg, #17883a, #35b955); }
.c-orange { background: linear-gradient(135deg, #f07a00, #ffb02e); }
.c-purple { background: linear-gradient(135deg, #6a2fc8, #a14de6); }
.c-pink { background: linear-gradient(135deg, #d1215c, #f2527f); }

/* ---------- Panel / kad ---------- */
.grid { display: grid; gap: 14px; margin-bottom: 16px; align-items: start; }
.g3a { grid-template-columns: 1.15fr 1.3fr 1fr; }
.g3b { grid-template-columns: 1fr 1fr 1fr; }
.g2 { grid-template-columns: 1fr 1fr; }
.panel { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; min-width: 0; }
.panel-head {
  background: linear-gradient(90deg, var(--navy-900), var(--navy-800)); color: #fff; font-weight: 600; padding: 11px 16px;
  display: flex; align-items: center; gap: 10px; border-bottom: 3px solid var(--gold);
}
.panel-head i { color: var(--gold); font-size: 17px; }
.panel-body { padding: 12px 14px 14px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 16px; min-width: 0; }
.grid > .card { margin-bottom: 0; }
.card-title { font-size: 15px; color: var(--navy-900); margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.card-title i { color: var(--gold-d); }
.card-note { color: var(--muted); font-size: 12.5px; margin-bottom: 8px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.page-head h2 { font-size: 22px; color: var(--navy-900); display: flex; align-items: center; gap: 10px; }
.page-head h2 i { color: var(--gold-d); }
.loading { text-align: center; padding: 60px; color: var(--muted); }
.notice { background: var(--gold-soft); border: 1px solid #f0d77a; border-radius: var(--radius); padding: 12px 16px; margin-bottom: 14px; }
.notice i { color: var(--gold-d); }

/* ---------- Jadual ---------- */
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { background: var(--navy-900); color: #fff; text-align: left; padding: 9px 10px; font-weight: 600; white-space: nowrap; }
.tbl td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr:nth-child(even) { background: #f5f8fe; }
.tbl tbody tr:hover { background: var(--gold-soft); }
.tbl tr.first { background: #fff9e0 !important; }
.tbl .num { text-align: right; white-space: nowrap; }
.tbl .act { text-align: right; white-space: nowrap; width: 1%; }
.dot { display: inline-block; width: 13px; height: 13px; border-radius: 4px; margin-right: 8px; vertical-align: -2px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); }
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.badge.green { background: #1f9d4a; color: #fff; } .badge.blue { background: var(--blue-soft); color: var(--navy-800); }
.badge.gray { background: #e8ebf3; color: #55607a; } .badge.red { background: #fde1df; color: var(--red); }
.m1 { color: #e0a800; } .m2 { color: #9aa3b2; } .m3 { color: #c07a3a; }

/* ---------- Butang ---------- */
.btn { display: inline-flex; align-items: center; gap: 8px; border: 0; border-radius: 9px; padding: 9px 16px; font: inherit; font-weight: 600; cursor: pointer; transition: .15s; text-decoration: none; }
.btn.gold { background: linear-gradient(135deg, var(--gold), #ffd24a); color: #3b2a00; box-shadow: 0 2px 6px rgba(201, 143, 0, .35); }
.btn.gold:hover { filter: brightness(1.05); transform: translateY(-1px); }
.btn.ghost { background: #fff; color: var(--navy-800); border: 1.5px solid var(--line); }
.btn.ghost:hover { border-color: var(--blue); background: var(--blue-soft); }
.btn.danger { background: var(--red); color: #fff; }
.btn.danger:hover { filter: brightness(1.08); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 10px 0; }
.icon-btn { background: transparent; border: 0; color: var(--navy-800); cursor: pointer; width: 32px; height: 32px; border-radius: 8px; font-size: 14px; }
.icon-btn:hover { background: var(--blue-soft); }
.icon-btn.danger { color: var(--red); } .icon-btn.danger:hover { background: #fde1df; }

/* ---------- Borang ---------- */
.fld { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.fld small { color: var(--muted); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.chk { display: flex; gap: 8px; align-items: center; margin: 4px 0 8px; }
.chk input { width: auto; }
.event-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.event-head h3 { font-size: 18px; color: var(--navy-900); }
.event-head .btn-row { margin: 0; }

/* ---------- Modal & toast ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(6, 21, 56, .6); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 100; backdrop-filter: blur(2px); }
.modal { background: #fff; border-radius: 14px; width: min(480px, 100%); max-height: 92vh; overflow: auto; box-shadow: 0 20px 50px rgba(0, 0, 0, .35); border-top: 5px solid var(--gold); }
.modal.wide { width: min(700px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px 6px; }
.modal-head h3 { color: var(--navy-900); font-size: 17px; }
.modal-body { padding: 8px 20px 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.confirm-msg { margin: 6px 0 10px; font-size: 14.5px; }
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: var(--navy-900); color: #fff; padding: 11px 16px; border-radius: 10px; border-left: 5px solid var(--gold); box-shadow: 0 6px 20px rgba(0, 0, 0, .3); max-width: 360px; animation: in .25s; }
.toast.err { border-left-color: var(--red); } .toast.ok i { color: #6be28d; } .toast.err i { color: #ff8c84; }
.toast.out { opacity: 0; transform: translateX(20px); transition: .45s; }
@keyframes in { from { opacity: 0; transform: translateY(10px); } }

/* ---------- Dashboard ---------- */
.subhead { background: var(--navy-900); color: #fff; font-weight: 600; text-align: center; padding: 6px; border-radius: 8px 8px 0 0; margin-top: 12px; font-size: 13px; }
.champ-panel .panel-body { padding: 0; }
.champ { background: linear-gradient(160deg, var(--navy-950), #17409e); text-align: center; padding: 12px 10px 16px; position: relative; }
.champ-title { color: var(--gold); font-weight: 700; font-size: 17px; }
.champ-flag { width: 120px; height: 80px; display: block; margin: 4px auto 0; }
.champ-ribbon { display: inline-block; background: var(--hc); color: #fff; font-weight: 800; letter-spacing: 1px; padding: 5px 30px; border: 2px solid var(--gold); border-radius: 4px; margin-top: -4px; font-size: 18px; text-shadow: 0 1px 2px rgba(0, 0, 0, .4); }
.champ-panel .subhead { margin: 0; border-radius: 0; }
.bars { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 9px; }
.bar-row { display: grid; grid-template-columns: 105px 1fr 40px; gap: 8px; align-items: center; }
.bar-row b { text-align: right; }
.bar-rank { font-weight: 600; white-space: nowrap; }
.bar-rank i { color: var(--gold); }
.bar-track { display: block; height: 16px; background: #e8edf8; border-radius: 10px; overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 10px; }
.donut-wrap { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; justify-content: center; }
.donut { position: relative; width: 170px; height: 170px; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
.donut-center b { font-size: 28px; line-height: 1; color: var(--navy-900); }
.donut-center span { font-size: 12px; color: var(--muted); }
.legend { display: flex; flex-direction: column; gap: 6px; font-size: 13px; flex: 1; min-width: 150px; }
.lg-row { display: flex; align-items: center; gap: 8px; }
.lg-row span { flex: 1; } .lg-row small { color: var(--muted); }
.chart-box { position: relative; height: 200px; }

/* ---------- Rumah sukan ---------- */
.houses { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; margin-bottom: 14px; }
.house-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; border-top: 6px solid var(--hc); }
.house-top { display: flex; justify-content: space-between; align-items: center; }
.house-name { font-weight: 700; font-size: 18px; display: flex; align-items: center; gap: 10px; color: var(--navy-900); }
.house-badge { width: 28px; height: 28px; border-radius: 50%; background: var(--hc); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 14px; border: 2px solid var(--gold); }
.house-score { font-size: 34px; font-weight: 800; color: var(--navy-900); margin: 6px 0; }
.house-score small { font-size: 13px; color: var(--muted); font-weight: 500; }
.house-meta { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; font-size: 13px; color: var(--muted); }

/* ---------- Lain-lain ---------- */
.empty { text-align: center; color: var(--muted); padding: 28px 10px; }
.empty i { font-size: 32px; color: #b9c5e0; display: block; margin-bottom: 8px; }
.logo-prev { text-align: center; padding: 10px; background: linear-gradient(135deg, var(--navy-900), var(--navy-800)); border-radius: 10px; }
.logo-prev .logo-img { height: 100px; max-width: 100%; object-fit: contain; }
code { background: var(--gold-soft); padding: 1px 6px; border-radius: 5px; }

/* ---------- Laporan ---------- */
.rpt-head { display: flex; gap: 14px; align-items: center; border-bottom: 3px double var(--navy-900); padding-bottom: 10px; margin-bottom: 12px; }
.rpt-logo { width: 60px; height: 72px; object-fit: contain; }
.rpt-t1 { font-weight: 800; font-size: 18px; color: var(--navy-900); }
.rpt-title { text-align: center; margin: 10px 0 14px; color: var(--navy-900); text-transform: uppercase; letter-spacing: .5px; }
.report h4 { margin: 16px 0 6px; color: var(--navy-800); }
.rpt-foot { margin-top: 18px; font-size: 12px; color: var(--muted); text-align: right; }

/* ---------- Responsif ---------- */
@media (max-width: 1250px) {
  .stats { grid-template-columns: repeat(3, 1fr); }
  .g3a, .g3b { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .view { grid-column: 1; padding: 14px 12px 40px; }
  .menu-toggle { display: block; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 250px; z-index: 60; transform: translateX(-100%); transition: .25s; height: 100vh; padding-top: 70px; }
  .sidebar.open { transform: none; box-shadow: 8px 0 30px rgba(0, 0, 0, .4); }
  .banner { padding: 7px 14px; gap: 10px; }
  .banner .t1 { font-size: 10px; } .banner .t2 { font-size: 16px; } .banner .t3 { font-size: 11px; }
  .banner-logo .logo-img { width: 37px; height: 44px; }
  .infocard { margin-left: 0; width: 100%; flex-wrap: wrap; }
  .g2 { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .g3a, .g3b { grid-template-columns: 1fr; }
  .row3 { grid-template-columns: 1fr; }
  .fbox, .fbox.wide { max-width: none; }
}
@media (max-width: 460px) {
  .stats { grid-template-columns: 1fr; }
  .row2 { grid-template-columns: 1fr; }
}

/* ---------- Cetak ---------- */
@media print {
  body { background: #fff; font-size: 12px; }
  .banner, .sidebar, .no-print, .toasts, .menu-toggle { display: none !important; }
  .app { display: block; }
  .view { padding: 0; }
  .card, .report { box-shadow: none; padding: 0; }
  .tbl th { background: #e6ebf7 !important; color: #000 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; border-bottom: 1px solid #000; }
  .tbl tbody tr:nth-child(even), .tbl tr.first { background: #fff !important; }
  .tbl td { padding: 4px 8px; border-bottom: 1px solid #bbb; }
  .report h4 { page-break-after: avoid; }
  .tbl tr { page-break-inside: avoid; }
}
