/* Tema bendera Sarawak: kuning, hitam, merah. */
@font-face { font-family: 'Archivo'; src: url('vendor/archivo-latin.woff2') format('woff2'); font-weight: 400 800; font-stretch: 62% 125%; font-display: swap; }
:root {
  --kuning: #FCD116;
  --kuning-cerah: #FFF3B0;
  --merah: #CE1126;
  --merah-gelap: #A50E1F;
  --hitam: #000;
  --dakwat: #22201C;
  --kelabu: #6B665C;
  --garis: #E4E0D4;
  --kertas: #FAF8F2;
  --putih: #fff;
  --font: 'Archivo', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); color: var(--dakwat); background: var(--kertas); font-size: 15px; line-height: 1.45; }
button, input, select, textarea { font: inherit; }
:focus-visible { outline: 3px solid var(--merah); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
a { color: var(--merah); font-weight: 600; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Butang ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .45rem; border: 1.5px solid var(--hitam);
  background: var(--putih); color: var(--hitam); padding: .5rem .9rem; border-radius: 6px;
  font-weight: 600; cursor: pointer; text-decoration: none; font-size: .9rem; white-space: nowrap;
}
.btn:hover { background: var(--hitam); color: var(--kuning); }
.btn-utama { background: var(--merah); border-color: var(--merah); color: var(--putih); }
.btn-utama:hover { background: var(--merah-gelap); border-color: var(--merah-gelap); color: var(--putih); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Header (medan kuning + jalur bendera di hujung) ---------- */
.header {
  position: relative; display: flex; align-items: center; gap: 1rem;
  background: var(--kuning); color: var(--hitam); padding: .7rem 1.25rem; padding-right: 210px; overflow: hidden;
  border-bottom: 3px solid var(--hitam);
}
.header::after { /* jalur hitam atas merah, sudut sama seperti bendera */
  content: ''; position: absolute; right: 0; top: 0; bottom: 0; width: 190px;
  background: linear-gradient(26.57deg, transparent 38%, var(--merah) 38%, var(--merah) 52%, var(--hitam) 52%, var(--hitam) 70%, transparent 70%);
  pointer-events: none;
}
.header .jata { width: 46px; height: 46px; object-fit: contain; flex: none; }
.header .tajuk { display: flex; flex-direction: column; min-width: 0; }
.header h1 { margin: 0; font-size: 1.35rem; font-weight: 800; font-stretch: 112%; letter-spacing: -.01em; line-height: 1.1; }
.header .sub { font-size: .85rem; color: #3A3426; }
.header .alat { margin-left: auto; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.header .btn { background: transparent; }
.header .btn:hover { background: var(--hitam); color: var(--kuning); }

/* ---------- Login ---------- */
.login { min-height: 100%; display: grid; grid-template-columns: 1.15fr 1fr; }
.login-bendera { background: var(--kuning) url('img/bendera-sarawak.svg') center / cover no-repeat; min-height: 220px; }
.login-borang { display: flex; align-items: center; justify-content: center; padding: 2.5rem 1.5rem; background: var(--putih); }
.login-kad { width: 100%; max-width: 360px; text-align: center; }
.login-kad .jata { width: 132px; height: 132px; object-fit: contain; }
.login-kad .negeri { margin: .75rem 0 0; font-weight: 700; font-stretch: 112%; font-size: 1rem; }
.login-kad h1 { margin: .15rem 0 1.75rem; font-size: 1.6rem; font-weight: 800; font-stretch: 112%; line-height: 1.15; }
.login-kad form { text-align: left; display: grid; gap: 1rem; }
.login-kad .btn { justify-content: center; padding: .7rem; font-size: 1rem; }
@media (max-width: 760px) { .login { grid-template-columns: 1fr; grid-template-rows: 180px 1fr; } }

/* ---------- Medan borang ---------- */
.medan { display: grid; gap: .3rem; }
.medan label { font-weight: 600; font-size: .88rem; }
.medan input, .medan select, .medan textarea {
  border: 1.5px solid #C9C3B3; border-radius: 6px; padding: .6rem .7rem; background: var(--putih); width: 100%;
}
.medan input:focus, .medan select:focus, .medan textarea:focus { border-color: var(--hitam); outline: none; box-shadow: 0 0 0 3px var(--kuning); }
.ralat { color: var(--merah); font-weight: 600; font-size: .9rem; min-height: 1.3em; margin: 0; }
.berjaya { color: #1D6B32; font-weight: 600; font-size: .9rem; margin: 0; }

/* ---------- Dashboard ---------- */
.app { height: 100%; display: grid; grid-template-rows: auto auto 1fr; }
.kpi { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--putih); border-bottom: 1px solid var(--garis); }
.kpi > div { padding: .8rem 1.25rem .9rem; border-top: 4px solid var(--kuning); }
.kpi > div:nth-child(2) { border-top-color: var(--hitam); }
.kpi > div:nth-child(3) { border-top-color: var(--merah); }
.kpi > div + div { border-left: 1px solid var(--garis); }
.kpi dt { font-size: .85rem; color: var(--kelabu); font-weight: 500; }
.kpi dd { margin: .1rem 0 0; font-size: 1.9rem; font-weight: 800; font-stretch: 105%; letter-spacing: -.02em; line-height: 1.1; }
.kpi .skop { font-size: .78rem; color: var(--kelabu); }

.utama { display: grid; grid-template-columns: 1fr minmax(420px, 40%); min-height: 0; }
#peta { position: relative; min-height: 360px; background: #E3E1DB; } /* close to the greyed land tiles, so not-yet-loaded areas blend in instead of looking blank */
#peta .leaflet-tile-pane { filter: grayscale(.85) contrast(.9) brightness(1.05); } /* quiet basemap so DUN colours lead */
/* Floating map toolbar: one pill, two view buttons and one on/off toggle */
.peta-alat { position: absolute; z-index: 5; top: 12px; left: 50%; transform: translateX(-50%); display: flex; align-items: stretch;
  background: var(--putih); border: 2px solid var(--hitam); border-radius: 999px; box-shadow: 0 4px 14px rgba(0,0,0,.25); overflow: hidden; }
.peta-alat button { font: inherit; font-weight: 700; font-size: .88rem; color: var(--hitam); background: none; border: 0; padding: .55rem 1rem; cursor: pointer; white-space: nowrap; }
.peta-alat button + button { border-left: 1px solid rgba(0,0,0,.25); }
.peta-alat button:hover { background: var(--hitam); color: var(--kuning); }
.peta-alat button:focus-visible { outline: 3px solid var(--merah); outline-offset: -3px; }
.peta-alat .togol { display: flex; align-items: center; gap: .55rem; border-left: 2px solid var(--hitam); }
.peta-alat .togol::after { content: ''; width: 2rem; height: 1.1rem; border-radius: 999px; background: #B9B3A3 radial-gradient(circle at .55rem 50%, #fff .38rem, transparent .4rem); border: 1px solid var(--hitam); }
.peta-alat .togol[aria-pressed="true"]::after { background: var(--merah) radial-gradient(circle at calc(100% - .55rem) 50%, #fff .38rem, transparent .4rem); }
@media (max-width: 640px) { .peta-alat button { padding: .5rem .65rem; font-size: .8rem; } }

.leaflet-interactive:focus { outline: none; }
.label-dun { background: none; border: 0; }
.label-dun span {
  display: inline-block; transform: translate(-50%, -50%); white-space: nowrap; text-align: center;
  font-weight: 800; font-stretch: 112%; font-size: 13px; color: var(--hitam); line-height: 1.15;
  text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 6px #fff;
}
.label-dun small { display: block; font-weight: 600; font-stretch: 100%; font-size: 11px; }
.label-dun.aktif span { display: none; } /* the panel heading names the selected DUN; keeps the DM labels readable */
.label-dm { background: none; border: 0; }
.label-dm span { display: inline-block; transform: translate(-50%, -50%); white-space: nowrap; pointer-events: none;
  font-size: 11px; font-weight: 700; color: #fff; text-shadow: 0 0 3px #000, 0 0 3px #000, 0 0 5px #000; }
/* MapLibre (dashboard): the marker element is already centred, so drop the Leaflet-style offset, and let clicks reach the map. */
.maplibregl-marker.label-dun span, .maplibregl-marker.label-dm span { transform: none; }
.maplibregl-marker.label-dun, .maplibregl-marker.label-dm { pointer-events: none; }
#peta.zum-dekat .label-dun, #peta:not(.zum-dekat) .label-dm:not(.dun-aktif), #peta.tanpa-dm .label-dm { display: none; }
#peta.tanpa-dm.zum-dekat .label-dun { display: block; } /* no DM names to show: keep the DUN names */
.peta-ralat { position: absolute; inset: auto 1rem 1rem; background: var(--putih); padding: .75rem 1rem; border-radius: 6px; }
.nota { font-size: .78rem; color: var(--kelabu); margin: .6rem 0 0; }
.leaflet-tooltip.tip { font-family: var(--font); border: 1.5px solid var(--hitam); border-radius: 6px; padding: .45rem .6rem; box-shadow: none; }
.leaflet-tooltip.tip b { font-stretch: 112%; }
/* Hover tag (follows the mouse) and the DM card */
.maplibregl-popup.tip { pointer-events: none; }
.maplibregl-popup.tip .maplibregl-popup-tip { display: none; }
.maplibregl-popup.tip .maplibregl-popup-content { font-family: var(--font); border: 1.5px solid var(--hitam); border-radius: 6px; padding: .4rem .6rem; box-shadow: 0 4px 12px rgba(0,0,0,.18); line-height: 1.3; }
.maplibregl-popup.tip b { display: block; font-stretch: 112%; }
.maplibregl-popup.tip span { font-size: .8rem; color: var(--kelabu); }
/* Kad permohonan pada peta: seperti slip rujukan bercetak. Sudut tajam, bayang keras, jalur rujukan hitam. */
.maplibregl-popup.kad .maplibregl-popup-content { font-family: var(--font); border: 2px solid var(--hitam); border-radius: 0; padding: 0; background: var(--putih);
  box-shadow: 5px 5px 0 var(--hitam); animation: kadMasuk .2s ease-out; }
.maplibregl-popup.kad.tutup .maplibregl-popup-content { animation: kadKeluar .14s ease-in forwards; }
@keyframes kadMasuk { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes kadKeluar { to { opacity: 0; transform: translateY(4px); } }
.maplibregl-popup.kad .maplibregl-popup-tip { border-width: 9px; }
.maplibregl-popup-anchor-bottom.kad .maplibregl-popup-tip, .maplibregl-popup-anchor-bottom-left.kad .maplibregl-popup-tip, .maplibregl-popup-anchor-bottom-right.kad .maplibregl-popup-tip { border-top-color: var(--hitam); }
.maplibregl-popup-anchor-top.kad .maplibregl-popup-tip, .maplibregl-popup-anchor-top-left.kad .maplibregl-popup-tip, .maplibregl-popup-anchor-top-right.kad .maplibregl-popup-tip { border-bottom-color: var(--hitam); }
.maplibregl-popup-anchor-left.kad .maplibregl-popup-tip { border-right-color: var(--hitam); }
.maplibregl-popup-anchor-right.kad .maplibregl-popup-tip { border-left-color: var(--hitam); }
.maplibregl-popup.kad .maplibregl-popup-close-button { color: var(--kuning); font-size: 1.25rem; padding: 0 .55rem; line-height: 1.7; }
.maplibregl-popup.kad .maplibregl-popup-close-button:hover { background: var(--merah); }
.km-ruj { margin: 0; background: var(--hitam); color: var(--kuning); font-size: .78rem; font-weight: 700; letter-spacing: .02em; padding: .35rem 2.2rem .35rem .75rem; font-variant-numeric: tabular-nums; }
.km-isi { padding: .65rem .75rem .75rem; }
.km h3 { margin: 0; font-size: 1.05rem; font-stretch: 108%; line-height: 1.2; }
.km-sub { margin: .2rem 0 .6rem; font-size: .8rem; color: var(--kelabu); }
.km-amaun { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--hitam); padding-top: .5rem; }
.km-amaun div + div { border-left: 1px solid var(--hitam); padding-left: .75rem; }
.km-amaun span { display: block; font-size: .72rem; color: var(--kelabu); }
.km-amaun b { font-size: 1.05rem; font-variant-numeric: tabular-nums; }

/* ---------- Pin lokasi ---------- */
button.pin { all: unset; display: block; cursor: pointer; }
button.pin:focus-visible svg { outline: 3px solid var(--merah); outline-offset: 2px; }
.pin svg { display: block; filter: drop-shadow(0 2px 2px rgba(0,0,0,.35)); transform-origin: 50% 100%; transition: transform .15s; }
.pin svg path { fill: var(--hitam); stroke: #fff; stroke-width: 1.5; }
.pin svg circle { fill: var(--kuning); }
.pin:hover svg { transform: scale(1.12); }
.pin.aktif svg { transform: scale(1.25); }
.pin.aktif svg path { fill: var(--kuning); stroke: var(--hitam); }
.pin.aktif svg circle { fill: var(--hitam); }

/* ---------- Panel sisi ---------- */
.panel { background: var(--putih); border-left: 1px solid var(--garis); display: flex; flex-direction: column; min-height: 0; }
.pilih-dun { display: grid; grid-template-columns: repeat(3, 1fr); border-bottom: 1px solid var(--garis); }
.pilih-dun button {
  border: 0; background: var(--putih); padding: .65rem .5rem; cursor: pointer; text-align: left;
  border-bottom: 4px solid transparent; line-height: 1.2;
}
.pilih-dun button + button { border-left: 1px solid var(--garis); }
.pilih-dun button b { display: block; font-stretch: 112%; }
.pilih-dun button span { font-size: .8rem; color: var(--kelabu); }
.pilih-dun button:hover { background: var(--kuning-cerah); }
.pilih-dun button[aria-pressed="true"] { border-bottom-color: var(--merah); background: #FDECEE; }

.panel-isi { position: relative; /* contains .sr-only (absolute), which otherwise escapes the scroll area and makes the whole page scroll */ overflow: auto; padding: 1.1rem 1.25rem 1.5rem; flex: 1; }
.panel-isi.masuk { animation: masuk .35s ease-out; }
@keyframes masuk { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
.panel h2 { margin: 0; font-size: 1.6rem; font-weight: 800; font-stretch: 112%; line-height: 1.1; }
.panel h2 .kod { color: var(--merah); }
.btn-kecil { padding: .3rem .7rem; font-size: .82rem; margin-bottom: .7rem; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { border: 1.5px solid var(--hitam); background: var(--putih); border-radius: 999px; padding: .25rem .75rem; font-weight: 600; font-size: .82rem; cursor: pointer; }
.chip span { background: var(--kuning); border-radius: 999px; padding: 0 .45rem; margin-left: .2rem; }
.chip:hover { background: var(--kuning-cerah); }
.chip[aria-pressed="true"] { background: var(--merah); border-color: var(--merah); color: #fff; }
.chip[aria-pressed="true"] span { background: #fff; color: var(--merah); }
.lencana.jenis { background: var(--hitam); color: var(--kuning); margin: 0 .3rem 0 0; }
.panel h3 { font-size: .95rem; margin: 1.4rem 0 .6rem; }
.panel .ket { color: var(--kelabu); margin: .3rem 0 0; }

.bar { display: grid; grid-template-columns: minmax(0, 8.5rem) 1fr auto; gap: .6rem; align-items: center; font-size: .86rem; margin: .35rem 0; }
.bar .nama { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar .trek { display: block; height: 10px; background: #F1EEE4; border-radius: 5px; overflow: hidden; }
.bar .isi { display: block; height: 100%; background: var(--hitam); border-radius: 5px; }
.bar .isi.lulus { background: var(--merah); }

.cari { margin: .3rem 0 .6rem; }
table.senarai { width: 100%; border-collapse: collapse; font-size: .84rem; }
.senarai th { text-align: left; font-weight: 700; padding: .45rem .4rem; border-bottom: 2px solid var(--hitam); position: sticky; top: -1.1rem; background: var(--putih); }
.senarai th button { all: unset; cursor: pointer; }
.senarai th button:focus-visible { outline: 2px solid var(--merah); }
.senarai th[aria-sort="ascending"] button::after { content: ' ▲'; font-size: .7em; }
.senarai th[aria-sort="descending"] button::after { content: ' ▼'; font-size: .7em; }
.senarai td { padding: .5rem .4rem; border-bottom: 1px solid var(--garis); vertical-align: top; }
.senarai td.rm, .senarai th.rm { text-align: right; white-space: nowrap; }
.senarai .ulasan { color: var(--kelabu); font-size: .8rem; display: block; margin-top: .15rem; }
.senarai .ruj { font-size: .78rem; color: var(--kelabu); display: block; }
.lencana { display: inline-block; font-size: .72rem; font-weight: 700; padding: .1rem .45rem; border-radius: 999px; margin-top: .2rem; }
.lencana.lulus { background: var(--merah); color: #fff; }
.lencana.tolak { background: var(--hitam); color: #fff; }
.lencana.proses { background: var(--kuning); color: var(--hitam); }
.kosong { padding: 1.5rem 0; color: var(--kelabu); }

@media (max-width: 960px) {
  .app { height: auto; }
  .utama { grid-template-columns: 1fr; }
  #peta { height: 60vh; }
  .kpi { grid-template-columns: repeat(2, 1fr); }
  .kpi > div:nth-child(3) { border-left: 0; }
  .header { padding-right: 1.25rem; }
  .header::after { width: 70px; opacity: .9; }
  .header .tajuk { flex: 1 1 0; }
  .header .alat { padding-right: 50px; flex-wrap: nowrap; flex: none; }
}

@media (max-width: 640px) {
  .header { flex-wrap: wrap; gap: .5rem .75rem; padding-right: 64px; }
  .header .jata { width: 36px; height: 36px; }
  .header .tajuk { flex: 1 1 0; } /* stays beside the logo instead of dropping under it */
  .header h1 { font-size: 1.05rem; }
  .header .sub { font-size: .78rem; }
  .header .alat { width: 100%; justify-content: flex-start; padding-right: 0; }
  .header .btn { padding: .35rem .65rem; font-size: .82rem; }
  .header::after { width: 56px; }
  .kpi dd { font-size: 1.4rem; }
  .utama { grid-template-columns: 1fr; }
}

/* ---------- Admin ---------- */
.admin { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; display: grid; gap: 1.5rem; grid-template-columns: 1.2fr 1fr; align-items: start; }
.admin section { background: var(--putih); border: 1px solid var(--garis); border-top: 4px solid var(--hitam); border-radius: 8px; padding: 1.25rem; }
.admin section:nth-child(2) { border-top-color: var(--merah); }
.admin h2 { margin: 0 0 .3rem; font-size: 1.2rem; font-stretch: 112%; }
.admin .ket { color: var(--kelabu); margin: 0 0 1rem; font-size: .9rem; }
.admin form { display: grid; gap: .85rem; }
.admin form .btn { justify-content: center; }
.admin .dua { display: grid; grid-template-columns: 1fr 1fr; gap: .85rem; }
.admin section.lebar { grid-column: 1 / -1; }
.lokasi-grid { display: grid; grid-template-columns: minmax(280px, 1fr) 2fr; gap: 1.25rem; align-items: start; margin-bottom: 1.25rem; }
#petaLokasi { height: 400px; border: 1.5px solid var(--hitam); border-radius: 6px; background: #E3E1DB; }
#petaLokasi .leaflet-tile-pane { filter: grayscale(.85) contrast(.9) brightness(1.05); }
@media (max-width: 860px) { .lokasi-grid { grid-template-columns: minmax(0, 1fr); } }
.zon-fail { border: 2px dashed #C9C3B3; border-radius: 8px; padding: 1.25rem; text-align: center; background: var(--kertas); }
.zon-fail.atas { border-color: var(--merah); background: #FDECEE; }
.pratonton { overflow: auto; max-height: 300px; margin-top: .75rem; }
.senarai-ralat { margin: .5rem 0 0; padding-left: 1.1rem; color: var(--merah); font-size: .88rem; max-height: 220px; overflow: auto; }
@media (max-width: 860px) { .admin { grid-template-columns: minmax(0, 1fr); } }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

#peta.zum-jauh .label-dun { display: none; }

/* ---------- Butiran permohonan (panel): borang rasmi dengan garis titik dan lejar ---------- */
.nama-btn { all: unset; cursor: pointer; font-weight: 700; }
.nama-btn:hover { text-decoration: underline; text-decoration-color: var(--merah); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.nama-btn:focus-visible { outline: 2px solid var(--merah); outline-offset: 2px; }
.bt-balik { all: unset; cursor: pointer; font-weight: 600; font-size: .85rem; color: var(--merah); margin-bottom: .7rem; display: inline-block; }
.bt-balik:hover { text-decoration: underline; }
.bt-balik:focus-visible { outline: 2px solid var(--merah); outline-offset: 3px; }
.bt-kepala { position: relative; padding-right: 8rem; }
.bt-ruj { display: inline-block; margin: 0; background: var(--hitam); color: var(--kuning); font-weight: 700; font-size: .82rem; letter-spacing: .02em; padding: .25rem .65rem; font-variant-numeric: tabular-nums; }
.bt h2 { margin: .5rem 0 .7rem; font-size: 1.4rem; line-height: 1.12; }
.cop { position: absolute; right: 0; top: .1rem; transform: rotate(-4deg); border: 3px double currentColor; padding: .2rem .6rem; font-weight: 800; font-size: .95rem;
  letter-spacing: .08em; text-transform: uppercase; mix-blend-mode: multiply; white-space: nowrap; }
.cop.lulus { color: var(--merah); }
.cop.tolak, .cop.proses { color: var(--dakwat); }
.bt-tujuan { margin: .8rem 0 .2rem; border-top: 2px solid var(--hitam); padding-top: .5rem; }
.panel .bt-tujuan h3 { margin: 0 0 .25rem; font-size: .8rem; font-weight: 600; color: var(--kelabu); }
.bt-tujuan p { margin: 0; line-height: 1.5; max-width: 62ch; }
.bt-borang { margin: .6rem 0 .9rem; }
.bt-borang div { display: flex; align-items: baseline; gap: .5rem; padding: .18rem 0; font-size: .92rem; }
.bt-borang dt { color: var(--kelabu); flex: none; }
.bt-borang dd { margin: 0; font-weight: 600; text-align: right; }
.titik { flex: 1; border-bottom: 1.5px dotted #A9A394; transform: translateY(-.2em); }
.bt-lejar { width: 100%; border-collapse: collapse; }
.bt-lejar th { text-align: left; font-weight: 400; padding: .3rem 0; }
.bt-lejar td { text-align: right; font-size: 1.1rem; font-weight: 700; padding: .3rem 0; }
.bt-lejar tr + tr { border-top: 1px solid var(--garis); }
.bt-lejar .beza { border-top: 2px solid var(--hitam); border-bottom: 4px double var(--hitam); }
.bt-lejar .beza th { font-weight: 700; }
.bt-peratus { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: .2rem .8rem; margin-top: .9rem; }
.bt-trek { height: 14px; border: 1.5px solid var(--hitam); background: repeating-linear-gradient(135deg, transparent 0 4px, #D9D4C5 4px 6px); }
.bt-isi { display: block; height: 100%; background: var(--merah); }
.bt-peratus b { font-size: 1.6rem; font-stretch: 112%; line-height: 1; }
/* Detail view is tighter so it fits the side panel on a laptop screen without scrolling (still scrolls on very short windows or long purposes) */
.panel-isi:has(.bt) { padding: .8rem 1.25rem .9rem; }
.panel-isi:has(.bt) .bt-balik { margin-bottom: .35rem; }
.bt h2 { margin: .4rem 0 .5rem; }
.bt-tujuan { margin: .5rem 0 .1rem; padding-top: .4rem; }
.bt-borang { margin: .4rem 0 .6rem; }
.bt-borang div { padding: .1rem 0; }
.bt-lejar th, .bt-lejar td { padding: .2rem 0; }
.bt-peratus { margin-top: .6rem; }
.bt-ket { grid-column: 1 / -1; font-size: .8rem; color: var(--kelabu); }

/* Pin daerah mengundi: merah dengan titik putih, supaya berbeza daripada pin lokasi (hitam dan kuning) */
.pin-dm svg path { fill: var(--merah); }
.pin-dm svg circle { fill: #fff; }
.km-senarai { max-height: 240px; overflow: auto; }
.km-senarai .km-item + .km-item { border-top: 2px solid var(--hitam); }
.km-butiran { display: block; width: 100%; border: 0; border-top: 1px solid var(--hitam); background: var(--kuning-cerah); color: var(--hitam);
  font-weight: 700; font-size: .85rem; text-align: left; padding: .5rem .75rem; cursor: pointer; }
.km-butiran:hover { background: var(--hitam); color: var(--kuning); }
.km-butiran:focus-visible { outline: 3px solid var(--merah); outline-offset: -3px; }

.alat-jadual { display: flex; gap: .75rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.alat-jadual .cari { flex: 1 1 18rem; margin: .3rem 0; }
#tbodyMohon .btn-kecil + .btn-kecil { margin-left: .25rem; }

/* ---------- Responsif: telefon, tablet, desktop ---------- */
@media (max-width: 640px) {
  .maplibregl-ctrl-top-left { top: 52px; } /* clear of the floating toolbar */
  .maplibregl-ctrl-attrib { font-size: 10px; line-height: 1.3; }
  .btn, .chip, .peta-alat button { min-height: 40px; } /* finger-sized */
  .peta-alat { max-width: calc(100% - 16px); top: 8px; }
  .pilih-dun button { padding: .55rem .4rem; }
  .pilih-dun button b { font-size: .9rem; }
  .pilih-dun button span { font-size: .72rem; }
  .panel-isi { padding: 1rem; }
  .panel h2 { font-size: 1.35rem; }
  .bar { grid-template-columns: minmax(0, 6.5rem) 1fr auto; font-size: .8rem; }
  .bt-kepala { padding-right: 0; }
  .cop { position: static; display: inline-block; margin: .5rem 0 0 0; transform: rotate(-3deg); }
  .bt-lejar td { font-size: 1rem; }
  /* Kad permohonan: lembaran di bawah peta, bukan di sebelah titik (MapLibre tak menyemak ruang di tepi skrin sempit) */
  .maplibregl-popup.kad { position: absolute !important; left: 8px !important; right: 8px !important; top: auto !important; bottom: 26px !important;
    transform: none !important; max-width: none !important; }
  .maplibregl-popup.kad .maplibregl-popup-tip { display: none; }
  .maplibregl-popup.kad .maplibregl-popup-content { max-width: none; }
  .km-senarai { max-height: 34vh; }
}

.panel { overflow-x: clip; } /* the slide-in animation shifts the panel 24px; without this it briefly widens the page on phones */
@media (min-width: 961px) and (max-width: 1280px) { /* tablet landscape and small laptops: a one-row header leaves more room for the map */
  .header { padding-right: 170px; }
  .header::after { width: 150px; }
  .header h1 { font-size: 1.15rem; }
  .header .alat { flex-wrap: nowrap; }
  .header .btn { padding: .4rem .7rem; font-size: .85rem; }
  .kpi dd { font-size: 1.6rem; }
}

.admin section { min-width: 0; } /* a wide table must scroll inside its box, not stretch the page */
@media (max-width: 640px) {
  .admin { padding: 1rem .75rem 2rem; gap: 1rem; }
  .admin section { padding: 1rem; }
  .admin .dua { grid-template-columns: 1fr; } /* two narrow columns are hard to tap on a phone */
  .pratonton .senarai { min-width: 520px; }
  #petaLokasi { height: 320px; }
}
