/* ---------- Header ---------- */
header {
  background: linear-gradient(180deg, #0f6b4f 0%, #094a36 100%);
  color: #fff;
  padding: calc(8px + env(safe-area-inset-top)) max(var(--gutter), calc((100% - var(--lebar)) / 2 + var(--gutter))) 8px;
  min-height: var(--header-h);
  display: flex;
  align-items: center;
  gap: var(--r2);
  position: sticky;
  top: 0;
  z-index: 10;
}
header img { height: 32px; width: auto; flex: none; }
.header-teks { flex: 1; min-width: 0; }
header h1 { font-size: .9375rem; letter-spacing: -.01em; margin: 0; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-sub { font-size: var(--fs-xs); line-height: 1.3; color: rgba(255,255,255,.9); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.sync-pill {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  position: relative; min-height: 28px; min-width: 32px; padding: 2px 8px; border-radius: var(--jejari-s); border: 0;
  background: rgba(255,255,255,.16); color: #fff;
  font: inherit; font-size: .72rem; font-weight: 600; cursor: pointer; flex: none; white-space: nowrap;
  transition: background .15s, border-color .15s, box-shadow .15s, color .15s, transform .1s;
}
.sync-pill::after { content: ""; position: absolute; inset: -8px -4px; } /* kawasan sentuh kekal 44px */
.sync-pill:focus-visible { outline-color: #fff; }
@media (hover: hover) { .sync-pill:hover { background: rgba(255,255,255,.26); } }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: #6ee7b7; flex: none; }
.sync-pill.sibuk .sync-dot { background: #fcd34d; animation: denyut 1.1s infinite; }
.sync-pill.offline .sync-dot { background: #fca5a5; }
.sync-pill svg { width: 16px; height: 16px; flex: none; }
@keyframes denyut { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: .4; transform: scale(1.25); } }
.sync-pill[hidden] { display: none; }
@media (max-width: 419px) { #btnJadual span, #btnKeluar span { display: none; } #btnJadual, #btnKeluar { padding: 0; } }
@media (min-width: 768px) {
  header { gap: var(--r3); }
  header img { height: 40px; }
  header h1 { font-size: var(--fs-l); }
  .header-sub { font-size: var(--fs-s); }
  .sync-pill { font-size: var(--fs-s); padding: 0 12px; }
}

/* ---------- Navigasi: bawah (mobile), tab atas (tablet/desktop) ---------- */
nav {
  display: flex;
  background: #fff;
  border-bottom: 1px solid var(--garis);
  position: sticky;
  top: var(--header-h);
  z-index: 9;
  padding: 0 max(var(--gutter), calc((100% - var(--lebar)) / 2 + var(--gutter)));
  gap: var(--r1);
}
nav button {
  flex: none;
  min-height: var(--nav-h);
  padding: 0 var(--r4);
  border: 0;
  background: none;
  font: inherit;
  font-size: var(--fs-s);
  font-weight: 500;
  color: var(--kelabu);
  border-bottom: 3px solid transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--r2);
  transition: background .15s, border-color .15s, box-shadow .15s, color .15s, transform .1s;
}
@media (hover: hover) { nav button:not(.aktif):hover { color: var(--hijau-teks); background: var(--hijau-muda); } }
nav button svg { width: 20px; height: 20px; flex: none; }
nav button.aktif { color: var(--hijau); border-bottom-color: var(--hijau); font-weight: 600; }
nav button[hidden], nav[hidden] { display: none; }

@media (min-width: 768px) {
  nav { justify-content: center; gap: 4px; padding: 0 16px; }
  nav button { flex: 0 1 160px; }
}
@media (max-width: 767px) {
  nav {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    border-bottom: 0;
    border-top: 1px solid var(--garis);
    padding: 6px var(--r2) calc(8px + env(safe-area-inset-bottom));
    z-index: 20;
    gap: var(--r1);
  }
  nav button {
    flex: 1;
    flex-direction: column;
    gap: var(--r1);
    padding: var(--r2) var(--r1);
    min-height: 56px;
    border-bottom: 0;
    border-radius: var(--jejari-m);
    font-size: var(--fs-xs);
  }
  nav button svg { width: 24px; height: 24px; }
  nav button.aktif { background: var(--hijau-muda); }
  main { padding-bottom: calc(96px + env(safe-area-inset-bottom)) !important; }
}

/* ---------- Bekas halaman ---------- */
main { max-width: var(--lebar); margin: 0 auto; padding: var(--r4) var(--gutter); }
section { display: none; }
section.aktif { display: block; }
@media (min-width: 768px) {
  main { padding-top: var(--r5); padding-bottom: var(--r6); }
}
@media (min-width: 1280px) {
  #tab-catat.aktif { max-width: 880px; }
  #tab-tetapan.aktif { max-width: 560px; }

  #tab-senarai.aktif { display: grid; grid-template-columns: 340px minmax(0, 1fr); column-gap: var(--r5); align-items: start; }
  #tab-senarai > .bulan { grid-column: 1; }
  #tab-senarai > #kpiSenarai { grid-column: 1; position: sticky; top: calc(var(--header-h) + var(--nav-h) + var(--r5)); }
  #tab-senarai > #senarai { grid-column: 2; grid-row: 2; }

  #tab-borang.aktif, #tab-admin.aktif { display: grid; grid-template-columns: 360px minmax(0, 1fr); column-gap: var(--r5); align-items: start; }
  #tab-borang > *:not(.pratonton), #tab-admin > *:not(.pratonton) { grid-column: 1; }
  #tab-borang > .pratonton, #tab-admin > .pratonton { grid-column: 2; grid-row: 1 / span 6; }
}
@media (max-width: 380px) {
  main { padding-left: 12px; padding-right: 12px; }
}
