:root {
  --blue: #2f6fbf; --blue-d: #1f4f8f; --blue-l: #e8f0fb; --hd: #4a90d9;
  --ink: #1d2433; --mut: #6b7385; --line: #dfe3ea; --bg: #f4f6f9; --card: #fff;
  --green: #1d8a4e; --red: #c7362f; --amber: #b7791f;
  --r: 10px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--blue); }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 18px; margin: 24px 0 12px; }
h3 { font-size: 15px; margin: 0 0 12px; }
h4 { font-size: 13px; margin: 14px 0 6px; }
code { background: #eef1f5; padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--mut); } .small { font-size: 12.5px; } .tiny { font-size: 11px; }
.r { text-align: right; } .c { text-align: center; } .strong { font-weight: 700; } .nowrap { white-space: nowrap; }
.red { color: #d0021b; }

/* Topbar */
.topbar { display: flex; align-items: center; gap: 18px; background: #fff; border-bottom: 1px solid var(--line); padding: 0 20px; height: 58px; position: sticky; top: 0; z-index: 20; }
.brand { font-weight: 700; font-size: 16px; color: var(--ink); text-decoration: none; display: flex; align-items: center; gap: 8px; }
.logo { background: linear-gradient(135deg, #5b6573, #2e3540); color: #fff; padding: 4px 9px; border-radius: 6px; font-style: italic; letter-spacing: 1px; }
.topbar nav { display: flex; gap: 2px; flex: 1; }
.topbar nav a { padding: 8px 12px; border-radius: 8px; text-decoration: none; color: var(--ink); white-space: nowrap; }
.topbar nav a:hover { background: var(--bg); }
.topbar nav a.on { background: var(--blue-l); color: var(--blue-d); font-weight: 600; }
.who { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.who a { text-decoration: none; color: var(--ink); font-weight: 600; }
.who small { color: var(--mut); }
.who .logout { color: var(--mut); font-weight: 400; }
.nav-toggle { display: none; background: none; border: 0; font-size: 22px; cursor: pointer; margin-left: auto; }
.pill { background: var(--red); color: #fff; border-radius: 10px; padding: 0 7px; font-size: 11px; font-weight: 700; }

.wrap { max-width: 1280px; margin: 0 auto; padding: 24px 20px 80px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; margin-bottom: 16px; }
.narrow { max-width: 560px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.section-head h1, .section-head h2, .section-head h3 { margin: 0; }

/* Forms */
label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 12px; }
input, select, textarea { font: inherit; display: block; width: 100%; margin-top: 4px; padding: 8px 10px; border: 1px solid #c9cfd9; border-radius: 7px; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue-l); border-color: var(--blue); }
input[type=checkbox], input[type=radio] { width: auto; display: inline; margin: 0 6px 0 0; }
label.chk { font-weight: 400; display: flex; align-items: center; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.span2 { grid-column: span 2; }
.form-grid h3 { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.form-grid h3:first-of-type { border: 0; margin-top: 0; padding-top: 0; }
.inline { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 0; }
.inline input, .inline select { width: auto; margin: 0; }
input.sm { max-width: 160px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px; }
.filters input, .filters select { width: auto; margin: 0; }
.filters label.chk { margin: 0; }
.choice { display: grid; gap: 10px; margin-bottom: 16px; }
.opt { display: flex; gap: 8px; align-items: flex-start; border: 1px solid var(--line); border-radius: 8px; padding: 12px; font-weight: 400; cursor: pointer; margin: 0; }
.opt:has(input:checked) { border-color: var(--blue); background: var(--blue-l); }
.opt input { margin-top: 4px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 7px; border: 1px solid #c9cfd9; background: #fff; color: var(--ink); text-decoration: none; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-d); }
.btn-danger { background: #fff; border-color: #e6b3b0; color: var(--red); }
.btn-danger:hover { background: #fdf0ef; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--mut); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-block { width: 100%; justify-content: center; padding: 11px; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 12px 0; }
.actions .spacer { flex: 1; }
.actions.sticky { position: sticky; bottom: 0; background: rgba(244, 246, 249, .95); padding: 12px 0; border-top: 1px solid var(--line); z-index: 5; }
.x { border: 0; background: none; color: var(--mut); cursor: pointer; font-size: 14px; padding: 4px 6px; border-radius: 5px; }
.x:hover { background: #fdecea; color: var(--red); }

/* Alerts & badges */
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 10px; border: 1px solid; }
.alert-ok { background: #ecf8f1; border-color: #b7e3c8; color: #145c35; }
.alert-err { background: #fdf0ef; border-color: #f1c2be; color: #8a231d; }
.alert-warn { background: #fff8e6; border-color: #f2dc9b; color: #7a5208; }
.alert-info { background: var(--blue-l); border-color: #c3d6f2; color: #1a3d6e; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.b-grey { background: #eceff3; color: #555e6e; } .b-blue { background: #e3eefc; color: #1f5fae; } .b-teal { background: #dff5f2; color: #11756a; }
.b-purple { background: #efe8fb; color: #6338a8; } .b-green { background: #e2f6ea; color: #17733f; } .b-dark { background: #2e3540; color: #fff; } .b-red { background: #fde8e6; color: #b42a22; }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.kpis.small { grid-template-columns: 1fr 1fr; margin: 0; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; }
.kpi span { display: block; color: var(--mut); font-size: 12.5px; }
.kpi strong { display: block; font-size: 22px; margin-top: 2px; }
.kpis.small .kpi strong { font-size: 18px; }
.kpi small { color: var(--mut); }

/* Tables */
.table-scroll { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; color: var(--mut); font-weight: 600; padding: 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 9px 8px; border-bottom: 1px solid #eef0f4; vertical-align: middle; }
.tbl tfoot td { border-top: 2px solid var(--line); border-bottom: 0; }
.tbl.compact td { padding: 6px 6px; }
.tbl th.r { text-align: right; }
.tbl.grid th { background: var(--hd); color: #fff; text-align: center; border: 1px solid #3b7cc2; font-size: 11.5px; padding: 5px; }
.tbl.grid td { padding: 3px; border: 1px solid #e3e7ee; }
.tbl.grid input, .tbl.grid select { margin: 0; padding: 6px 6px; font-size: 13px; border-radius: 5px; min-width: 70px; }
.tbl.grid input[type=date] { min-width: 132px; }
.tbl.grid select { min-width: 130px; }
.tbl.grid input[type=time] { min-width: 96px; }
.tbl.grid input.num { text-align: right; min-width: 70px; width: 80px; }
.tbl.grid input.num.sm { width: 60px; min-width: 55px; }
.tbl.grid .w-desc { min-width: 200px; }
.tbl.grid .w-proj { min-width: 200px; }
.tbl.grid td.n { text-align: center; color: var(--mut); width: 28px; }
.tbl.grid td.calc { background: #f6f8fb; min-width: 70px; padding: 6px; }
.matrix td, .matrix th { white-space: nowrap; }
.w-bar { width: 40%; } .w-bar i { display: block; height: 8px; background: var(--hd); border-radius: 4px; }

.form-meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 20px; }
.form-meta span { display: block; font-size: 12px; color: var(--mut); }
.claimable { font-size: 16px; }
.claim-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid #eef0f4; }
.claim-row:last-child { border: 0; }
.files { list-style: none; padding: 0; margin: 0 0 10px; }
.files li { display: flex; gap: 8px; align-items: center; padding: 4px 0; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.thumb { border: 1px solid var(--line); border-radius: 8px; padding: 6px; text-decoration: none; color: var(--ink); display: flex; flex-direction: column; gap: 4px; }
.thumb img { width: 100%; height: 110px; object-fit: cover; border-radius: 5px; background: var(--bg); }
.thumb .pdf { height: 110px; display: grid; place-items: center; background: #fdecea; color: var(--red); font-weight: 700; border-radius: 5px; }
.thumb small { word-break: break-all; font-size: 11px; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 6px 0 6px 14px; border-left: 2px solid var(--line); margin-left: 4px; position: relative; }
.timeline li::before { content: ''; position: absolute; left: -5px; top: 12px; width: 8px; height: 8px; border-radius: 50%; background: var(--blue); }
.dl { display: grid; grid-template-columns: 140px 1fr; gap: 6px; margin: 0 0 12px; }
.dl dt { color: var(--mut); } .dl dd { margin: 0; font-weight: 600; }
.tabs { display: flex; gap: 4px; margin-bottom: 8px; }
.tabs a { padding: 6px 12px; border-radius: 7px; text-decoration: none; color: var(--mut); }
.tabs a.on { background: #fff; border: 1px solid var(--line); color: var(--ink); font-weight: 600; }

/* Chart */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 170px; padding-top: 10px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }
.bar .stack { flex: 1; width: 100%; max-width: 34px; display: flex; flex-direction: column-reverse; }
.bar .stack i { display: block; width: 100%; }
.bar span { font-size: 10.5px; color: var(--mut); margin-top: 4px; }
i.e { background: var(--hd); } i.o { background: #f2b33d; }
.legend { font-size: 12px; color: var(--mut); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin: 0 4px 0 10px; }

/* ===== Paparan borang (sheet) ===== */
.sheet { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 26px 30px; margin: 16px 0; font-family: Arial, Helvetica, sans-serif; font-size: 12px; overflow-x: auto; }
.sheet-top { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 3px solid #000; padding-bottom: 6px; }
.sheet-co { font-weight: 700; font-size: 13px; letter-spacing: .3px; }
.sheet-co.big { font-size: 16px; }
.sheet-title { text-align: center; font-style: italic; font-size: 14px; margin: 6px 0 10px; }
.sheet-meta { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 10px 30px; margin: 10px 0 12px; }
.sheet-meta.ot { grid-template-columns: 1fr 1fr 1fr; font-weight: 700; }
.sheet-meta div { display: flex; gap: 8px; }
.sheet-meta span { white-space: nowrap; }
.sheet-meta u { flex: 1; text-decoration: none; border-bottom: 1px solid #000; min-height: 16px; }
.form-tbl { width: 100%; border-collapse: collapse; }
.form-tbl th, .form-tbl td { border: 1px solid #000; padding: 3px 5px; height: 22px; }
.form-tbl th { font-weight: 400; text-align: center; background: #fff; font-size: 11px; }
.sheet-ot .form-tbl th { font-weight: 700; }
.form-tbl tfoot td { font-weight: 400; }
.form-tbl .big { font-size: 15px; }
.sheet-bottom { display: grid; grid-template-columns: 1fr 1fr 220px; gap: 20px; align-items: start; margin: 8px 0; }
.tot-box { border-collapse: collapse; width: 100%; }
.tot-box td { padding: 3px 6px; }
.tot-box td.r { border: 1px solid #000; width: 90px; }
.signs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px; margin-top: 22px; }
.signs.three { grid-template-columns: repeat(3, 1fr); }
.signs div { display: flex; flex-direction: column; gap: 4px; }
.signs .sig { border-bottom: 1px solid #000; min-height: 30px; font-family: "Brush Script MT", "Segoe Script", cursive; font-size: 17px; font-weight: 400; padding-top: 8px; }
.sheet-report .rep-title { margin: 18px 0 10px; font-size: 13px; }
.report-tbl th { background: #4a90e2; color: #000; font-weight: 700; height: 40px; }
.report-tbl td { height: 30px; }
.report-tbl tr.hl td { background: #ffff00; }
.report-tbl tfoot td { border: 0; font-weight: 400; }
.report-tbl tfoot td.dbl { border-bottom: 4px double #000; }
a.plain { color: inherit; text-decoration: none; }
.print-only { display: none; }

/* Login */
.login-page { display: grid; place-items: center; min-height: 100vh; background: linear-gradient(160deg, #eaf1fb, #f4f6f9); }
.login-box { background: #fff; padding: 32px; border-radius: 14px; width: 100%; max-width: 380px; box-shadow: 0 10px 40px rgba(30, 60, 110, .12); margin: 16px; }
.login-box h1 { font-size: 20px; margin: 10px 0 2px; }
.login-logo { display: inline-block; background: linear-gradient(135deg, #5b6573, #2e3540); color: #fff; padding: 6px 14px; border-radius: 8px; font-weight: 800; font-style: italic; letter-spacing: 2px; font-size: 20px; }

/* Responsive */
@media (max-width: 1000px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 16px; }
  .nav-toggle { display: block; }
  .topbar nav, .who { display: none; width: 100%; }
  body.nav-open .topbar nav { display: flex; flex-direction: column; }
  body.nav-open .who { display: flex; padding: 8px 12px; border-top: 1px solid var(--line); }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .form-meta { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .wrap { padding: 16px 12px 80px; }
  .form-grid { grid-template-columns: 1fr; } .span2 { grid-column: auto; }
  .kpi strong { font-size: 18px; }
  .sheet { padding: 14px; }
}

/* Print */
@media print {
  @page { size: A4 landscape; margin: 10mm; }
  body { background: #fff; font-size: 11px; }
  .no-print, .topbar, .alert { display: none !important; }
  .print-only { display: grid; }
  .wrap { max-width: none; padding: 0; }
  .sheet { border: 0; padding: 0; margin: 0; border-radius: 0; overflow: visible; }
  .report-tbl th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .report-tbl tr.hl td { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .card { border: 0; padding: 0; }
  .form-tbl th, .form-tbl td { height: 17px; padding: 1px 4px; }
  .signs { margin-top: 10px; }
  .sheet-meta { margin: 6px 0 8px; }
  .sheet p { margin: 6px 0; }
  .form-tbl tr.blank ~ tr.blank ~ tr.blank ~ tr.blank { display: none; }   /* cetak: maksimum 3 baris kosong */
  .co-split { font-size: 10px; margin: 6px 0; }
  .signs .sig { min-height: 22px; padding-top: 4px; font-size: 14px; }
  a { color: inherit; text-decoration: none; }
}

/* Syarikat */
.b-co { background: #fff3dc; color: #8a5a00; border: 1px solid #f1d9a6; }
.claim-sub { margin-top: 6px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.co-choice { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 600px) { .co-choice { grid-template-columns: 1fr; } }
.filters-inline select, .filters-inline input { width: auto; margin: 0; }
.add-proj { display: grid; grid-template-columns: 2fr 2fr auto; gap: 12px; align-items: end; background: var(--blue-l); padding: 14px; border-radius: 8px; margin-bottom: 14px; }
.add-proj label { margin: 0; }
@media (max-width: 700px) { .add-proj { grid-template-columns: 1fr; } }
.co-split { width: auto; min-width: 320px; margin: 10px 0; } .co-split td { border-bottom: 1px solid #ddd; }

.sheet-notes { display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap; }
.sheet-notes > p { margin-top: 10px; }
@media print { .sheet-notes { gap: 16px; } .form-tbl th, .form-tbl td { height: 15px; font-size: 10px; } .sheet { font-size: 10px; } .signs { margin-top: 6px; } }
