/* =====================================================================
   SejaTi MADANI@USAHAWAN B40 — lapisan reka bentuk atas Bootstrap 5.3.8
   Rujukan warna: biru institusi JPM, emas Jata Negara, kertas borang.
   ===================================================================== */

:root {
  --ink:        #12202F;
  --ink-soft:   #5B6878;
  --navy:       #0B2E5A;
  --navy-700:   #0E3C74;
  --navy-050:   #EAF0F7;
  --gold:       #C8922A;
  --gold-050:   #FBF4E4;
  --paper:      #EEF1F5;
  --surface:    #FFFFFF;
  --rule:       #DCE3EC;

  --ok:    #1E7A4B;
  --warn:  #B8720F;
  --stop:  #A8162A;

  --radius:    12px;
  --radius-sm: 8px;
  --shadow:    0 1px 2px rgba(18,32,47,.06), 0 8px 24px -12px rgba(11,46,90,.22);

  --bs-primary:       #0B2E5A;
  --bs-primary-rgb:   11,46,90;
  --bs-body-color:    var(--ink);
  --bs-body-bg:       var(--paper);
  --bs-border-color:  var(--rule);
  --bs-link-color:    var(--navy-700);
  --bs-font-sans-serif: "Plus Jakarta Sans", -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { -webkit-tap-highlight-color: transparent; }

body {
  font-family: var(--bs-font-sans-serif);
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, .h1, .h2, .h3 { font-weight: 700; letter-spacing: -.015em; color: var(--ink); }
h1 { font-size: clamp(1.5rem, 1.2rem + 1.4vw, 2rem); }
h2 { font-size: clamp(1.25rem, 1.1rem + .8vw, 1.5rem); }

.lead-sm { color: var(--ink-soft); font-size: .95rem; max-width: 68ch; }
.num     { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

a { text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------------------------------------------------------------- rangka */
.app-shell { display: flex; min-height: 100vh; }

.app-side {
  width: 258px;
  flex: 0 0 258px;
  background: var(--navy);
  color: #C9D6E6;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.app-side .brand {
  padding: 20px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.10);
}
.app-side .brand b { color: #fff; display: block; font-size: 1rem; line-height: 1.25; }
.app-side .brand span { font-size: .74rem; color: var(--gold); }

.app-side .role-chip {
  margin: 14px 16px 6px;
  padding: 9px 12px;
  background: rgba(255,255,255,.07);
  border-left: 3px solid var(--gold);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: .78rem;
}
.app-side .role-chip strong { display: block; color: #fff; font-size: .86rem; }

.app-side nav { padding: 10px 12px 28px; }
.app-side nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  margin-bottom: 2px;
  border-radius: var(--radius-sm);
  color: #C9D6E6;
  font-size: .9rem;
  font-weight: 500;
}
.app-side nav a i { width: 18px; text-align: center; font-size: .9rem; opacity: .85; }
.app-side nav a:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.app-side nav a.active { background: #fff; color: var(--navy); font-weight: 700; }
.app-side nav a.active i { opacity: 1; }
.app-side nav .group {
  font-size: .7rem;
  color: #7E93AD;
  padding: 16px 12px 6px;
  font-weight: 600;
}

.app-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

.app-top {
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 1030;
}
.app-top .title { font-weight: 700; font-size: 1rem; margin: 0; }
.app-top .sub   { font-size: .78rem; color: var(--ink-soft); }

.app-body   { padding: 22px 20px 56px; flex: 1 1 auto; }
.app-foot {
  border-top: 1px solid var(--rule);
  background: var(--surface);
  padding: 16px 20px;
  font-size: .8rem;
  color: var(--ink-soft);
}

/* -------------------------------------------------- kad & panel borang */
.panel {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.panel > header {
  padding: 15px 18px;
  border-bottom: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.panel > header h2, .panel > header h3 { margin: 0; font-size: 1rem; }
.panel > header p { margin: 2px 0 0; font-size: .82rem; color: var(--ink-soft); }
.panel .body { padding: 18px; }
.panel .body.tight { padding: 0; }

/* Penanda bahagian borang kertas (Bahagian A / B / C) */
.part-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--navy-050);
  color: var(--navy);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: .76rem;
  font-weight: 700;
}

/* ------------------------------------------------------ tulang aliran kerja
   Elemen tanda aras sistem: meniru aliran Bahagian A → B → C borang asal. */
.spine {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 18px;
}
.spine .node {
  padding: 14px 16px 15px;
  border-right: 1px solid var(--rule);
  position: relative;
}
.spine .node:last-child { border-right: 0; }
.spine .node .k {
  font-size: .72rem;
  color: var(--ink-soft);
  font-weight: 600;
  display: block;
  margin-bottom: 3px;
}
.spine .node .v { font-weight: 700; font-size: .93rem; line-height: 1.3; }
.spine .node .m { font-size: .76rem; color: var(--ink-soft); margin-top: 3px; }
.spine .node::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: var(--rule);
}
.spine .node.done::before    { background: var(--ok); }
.spine .node.current::before { background: var(--gold); }
.spine .node.current { background: var(--gold-050); }
.spine .node.stop::before    { background: var(--stop); }

/* ------------------------------------------------------------- statistik */
.stat {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 16px 18px;
  height: 100%;
}
.stat .k { font-size: .78rem; color: var(--ink-soft); font-weight: 600; }
.stat .v { font-size: 1.75rem; font-weight: 800; line-height: 1.1; margin-top: 4px; letter-spacing: -.02em; }
.stat .v.money { font-size: 1.35rem; }
.stat .d { font-size: .76rem; color: var(--ink-soft); margin-top: 4px; }
.stat.accent { border-left: 4px solid var(--gold); }

/* ---------------------------------------------------------------- borang */
.form-label { font-weight: 600; font-size: .86rem; margin-bottom: 5px; }
.form-label .req { color: var(--stop); }
.form-control, .form-select {
  border-color: #C9D3DF;
  border-radius: var(--radius-sm);
  padding: .55rem .75rem;
  font-size: .92rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--navy-700);
  box-shadow: 0 0 0 3px rgba(11,46,90,.13);
}
.form-text { font-size: .78rem; }
.form-check-input:checked { background-color: var(--navy); border-color: var(--navy); }

/* Pilihan Ya/Tidak bergaya butang — mudah disentuh pada telefon */
.yn { display: inline-flex; border: 1px solid #C9D3DF; border-radius: var(--radius-sm); overflow: hidden; }
.yn input { position: absolute; opacity: 0; pointer-events: none; }
.yn label {
  padding: .48rem 1.15rem;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  margin: 0;
  background: #fff;
  color: var(--ink-soft);
  min-width: 78px;
  text-align: center;
}
.yn label + input + label { border-left: 1px solid #C9D3DF; }
.yn input:checked + label { background: var(--navy); color: #fff; }
.yn input:checked + label.no { background: var(--stop); }
.yn input:focus-visible + label { outline: 3px solid var(--gold); outline-offset: -3px; }

/* Baris kriteria verifikasi */
.criterion { padding: 16px 18px; border-bottom: 1px solid var(--rule); }
.criterion:last-child { border-bottom: 0; }
.criterion .no {
  font-weight: 800;
  color: var(--navy);
  font-size: .92rem;
  min-width: 24px;
}
.criterion .q { font-size: .92rem; margin: 0; }
.criterion .hint { font-size: .8rem; color: var(--ink-soft); margin: 4px 0 0; }
.group-head {
  background: var(--navy-050);
  padding: 10px 18px;
  font-weight: 700;
  font-size: .86rem;
  color: var(--navy);
  border-bottom: 1px solid var(--rule);
}
.group-head span { font-weight: 500; color: var(--ink-soft); display: block; font-size: .8rem; }

/* ---------------------------------------------------------------- jadual */
.table { --bs-table-hover-bg: #F5F8FC; margin: 0; }
.table > thead th {
  background: #F7F9FC;
  font-size: .78rem;
  font-weight: 700;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--rule);
  white-space: nowrap;
  padding: 11px 14px;
}
.table > tbody td { padding: 12px 14px; vertical-align: middle; font-size: .89rem; }
.table .ref { font-weight: 700; color: var(--navy); }

.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: .76rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
}
.st-secondary { background: #EEF1F5; color: #4C5A6B; border-color: #DDE3EB; }
.st-info      { background: #E7F1FB; color: #14548F; border-color: #C9E0F5; }
.st-primary   { background: var(--navy-050); color: var(--navy); border-color: #C9D9EC; }
.st-warning   { background: var(--gold-050); color: #8A6210; border-color: #EBD9AE; }
.st-success   { background: #E6F4EC; color: var(--ok); border-color: #BFE3CE; }
.st-danger    { background: #FBEAEC; color: var(--stop); border-color: #F1C6CC; }

/* --------------------------------------------------------------- butang */
.btn { border-radius: var(--radius-sm); font-weight: 600; font-size: .9rem; padding: .52rem 1.05rem; }
.btn-primary { background: var(--navy); border-color: var(--navy); }
.btn-primary:hover, .btn-primary:focus { background: var(--navy-700); border-color: var(--navy-700); }
.btn-gold { background: var(--gold); border-color: var(--gold); color: #2A1E05; }
.btn-gold:hover { background: #B5821F; border-color: #B5821F; color: #2A1E05; }
.btn-outline-secondary { border-color: #C4CEDA; color: var(--ink); }
.btn-lg { padding: .7rem 1.3rem; font-size: .98rem; }

/* --------------------------------------------------------- halaman masuk */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr; }
.auth-aside {
  background: var(--navy);
  color: #D7E2EF;
  padding: 48px 52px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.auth-aside h1 { color: #fff; font-size: 2.1rem; line-height: 1.15; max-width: 15ch; }
.auth-aside .kicker { color: var(--gold); font-weight: 600; font-size: .88rem; margin-bottom: 14px; }
.auth-aside ul { list-style: none; padding: 0; margin: 26px 0 0; }
.auth-aside li {
  padding: 11px 0 11px 30px;
  border-top: 1px solid rgba(255,255,255,.12);
  position: relative;
  font-size: .92rem;
}
.auth-aside li i { position: absolute; left: 0; top: 14px; color: var(--gold); }
.auth-aside .foot { font-size: .78rem; color: #8FA5BF; }

.auth-panel { display: flex; align-items: center; justify-content: center; padding: 40px 24px; background: var(--surface); }
.auth-panel .inner { width: 100%; max-width: 400px; }

.code-input {
  font-size: 1.7rem;
  letter-spacing: .6em;
  text-align: center;
  font-weight: 700;
  padding: .7rem .5rem .7rem 1.1rem;
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------- makluman */
.alert { border-radius: var(--radius-sm); font-size: .9rem; border-width: 1px; }
.empty { text-align: center; padding: 44px 20px; color: var(--ink-soft); }
.empty i { font-size: 1.9rem; color: #B7C2D0; margin-bottom: 12px; display: block; }
.empty p { margin: 0 0 14px; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 18px 26px; border-left: 2px solid var(--rule); }
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline li::before {
  content: ""; position: absolute; left: -7px; top: 3px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--rule);
}
.timeline li.done::before { background: var(--ok); border-color: var(--ok); }
.timeline li.current::before { background: var(--gold); border-color: var(--gold); }
.timeline .t { font-weight: 600; font-size: .9rem; }
.timeline .d { font-size: .8rem; color: var(--ink-soft); }

.dl-flush { margin: 0; }
.dl-flush > div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 0;
  border-bottom: 1px dashed var(--rule);
  font-size: .89rem;
}
.dl-flush > div:last-child { border-bottom: 0; }
.dl-flush dt { color: var(--ink-soft); font-weight: 500; flex: 0 0 44%; }
.dl-flush dd { margin: 0; font-weight: 600; text-align: right; }

/* -------------------------------------------------------------- responsif */
.side-toggle { display: none; }

@media (max-width: 991.98px) {
  .app-side {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1045;
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: 0 0 40px rgba(0,0,0,.3);
  }
  .app-side.open { transform: translateX(0); }
  .side-toggle { display: inline-flex; }
  .side-scrim {
    position: fixed; inset: 0; background: rgba(9,20,33,.5);
    z-index: 1040; display: none;
  }
  .side-scrim.show { display: block; }
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-aside { padding: 30px 24px; }
  .auth-aside h1 { font-size: 1.6rem; }
  .auth-aside ul, .auth-aside .foot { display: none; }
  .spine { grid-template-columns: 1fr 1fr; }
  .spine .node:nth-child(2) { border-right: 0; }
  .spine .node:nth-child(-n+2) { border-bottom: 1px solid var(--rule); }
}

@media (max-width: 575.98px) {
  body { font-size: 14.5px; }
  .app-body { padding: 16px 13px 46px; }
  .app-top  { padding: 10px 13px; }
  .panel .body, .criterion { padding: 14px; }
  .panel > header { padding: 13px 14px; }
  .stat { padding: 13px 14px; }
  .stat .v { font-size: 1.5rem; }
  .spine { grid-template-columns: 1fr; }
  .spine .node { border-right: 0; border-bottom: 1px solid var(--rule); }
  .spine .node:last-child { border-bottom: 0; }
  .yn { display: flex; width: 100%; }
  .yn label { flex: 1; padding: .62rem .5rem; }
  .btn { padding: .58rem 1rem; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table > tbody td, .table > thead th { padding: 10px 11px; }
  .dl-flush > div { flex-direction: column; gap: 2px; }
  .dl-flush dd { text-align: left; }
  .code-input { font-size: 1.45rem; letter-spacing: .45em; }
}

/* Kad senarai untuk telefon menggantikan jadual lebar */
.record-card {
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  margin-bottom: 10px;
  background: var(--surface);
}
.record-card .top { display: flex; justify-content: space-between; align-items: start; gap: 10px; }
.record-card .name { font-weight: 700; font-size: .95rem; }
.record-card .meta { font-size: .8rem; color: var(--ink-soft); margin-top: 2px; }

@media print {
  .app-side, .app-top, .app-foot, .no-print { display: none !important; }
  .app-body { padding: 0; }
  .panel { box-shadow: none; break-inside: avoid; }
  body { background: #fff; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
