/* Dirancang untuk dipakai di bawah matahari: kontras tinggi, target sentuh besar. */
:root {
  --asphalt: #101A33; --asphalt-2: #1A2747; --paper: #F7F8FB; --ink: #0E1530; --muted: #5B6585;
  --line: #D9DEEA; --route: #1F6FEB; --signal: #F5C400; --alert: #E0007A; --ok: #1B9E5A; --bad: #D62828;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; font-family: var(--font); background: var(--asphalt); color: var(--ink); overscroll-behavior: none; }
body { overflow: hidden; }
button, input { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--signal); outline-offset: 2px; }

#app { position: fixed; inset: 0; display: flex; flex-direction: column; }

/* Header */
#top { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(env(safe-area-inset-top, 0px) + 8px) 12px 8px; background: var(--asphalt); color: #fff; z-index: 500; }
#top h1 { margin: 0; font-size: 18px; font-weight: 800; letter-spacing: .01em; line-height: 1.15; }
#status { margin: 2px 0 0; font-size: 12.5px; color: #B9C2E0; display: flex; align-items: center; gap: 6px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); display: inline-block; }
.dot.off { background: #8892B0; } .dot.warn { background: var(--signal); } .dot.bad { background: var(--bad); }
.top-actions { display: flex; gap: 6px; }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; border: 0; background: var(--asphalt-2); color: #fff; font-size: 20px; line-height: 1; }
.icon-btn:active { background: #26376a; }

/* Peta */
#map { flex: 1; min-height: 0; background: #dfe3ea; z-index: 1; }
.leaflet-container { font-family: var(--font); }

/* Banner SOS */
.banner { position: absolute; left: 10px; right: 10px; top: calc(env(safe-area-inset-top, 0px) + 66px); z-index: 600;
  border: 0; border-radius: 12px; padding: 12px 14px; background: var(--alert); color: #fff; font-weight: 800; font-size: 16px; text-align: left;
  box-shadow: 0 6px 20px rgba(0,0,0,.35); }

/* Bawah */
#bottom { display: flex; gap: 10px; align-items: stretch; padding: 10px 12px calc(env(safe-area-inset-bottom, 0px) + 10px); background: var(--asphalt); z-index: 500; }
.gps { flex: 1; display: flex; align-items: center; gap: 10px; border: 2px solid #33426f; border-radius: 14px; padding: 8px 12px; background: var(--asphalt-2); color: #fff; text-align: left; min-height: 64px; }
.gps b { display: block; font-size: 15px; } .gps small { display: block; font-size: 12px; color: #B9C2E0; margin-top: 1px; }
.gps .gps-ic { font-size: 24px; }
.gps.on { border-color: var(--ok); }
.gps.off { border-color: var(--signal); }

.sos { position: relative; overflow: hidden; width: 112px; min-height: 64px; border: 0; border-radius: 14px; background: var(--bad); color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; touch-action: none; user-select: none; -webkit-user-select: none; }
.sos .sos-label { position: relative; font-size: 24px; font-weight: 900; letter-spacing: .04em; line-height: 1; }
.sos small { position: relative; font-size: 11px; opacity: .9; margin-top: 3px; }
.sos .sos-fill { position: absolute; inset: 0; background: #fff; opacity: .0; transform-origin: left; transform: scaleX(0); }
.sos.holding .sos-fill { opacity: .35; transform: scaleX(1); transition: transform 2s linear; }
.sos.active { background: var(--alert); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px rgba(224,0,122,.35); } }

.ops-fab { position: absolute; right: 12px; bottom: calc(env(safe-area-inset-bottom, 0px) + 88px); z-index: 550; border: 0; border-radius: 999px;
  padding: 14px 20px; background: var(--signal); color: var(--ink); font-weight: 800; font-size: 15px; box-shadow: 0 6px 18px rgba(0,0,0,.3); }

/* Penanda peta */
.pin { width: 34px; height: 34px; border-radius: 50%; background: var(--c, #1F6FEB); border: 3px solid #fff; display: grid; place-items: center;
  font-size: 17px; box-shadow: 0 2px 6px rgba(0,0,0,.45); }
.pin.stale { background: #9AA0AD; filter: grayscale(.4); }
.pin.me { box-shadow: 0 0 0 4px rgba(245,196,0,.9), 0 2px 6px rgba(0,0,0,.45); }
.pin.sos { background: var(--alert); animation: ping 1s infinite; }
@keyframes ping { 0% { box-shadow: 0 0 0 0 rgba(224,0,122,.8); } 100% { box-shadow: 0 0 0 22px rgba(224,0,122,0); } }
.plabel { position: absolute; left: 50%; top: 38px; transform: translateX(-50%); white-space: nowrap; max-width: 140px;
  background: rgba(16,26,51,.88); color: #fff; font-weight: 700; font-size: 12px; line-height: 1; padding: 4px 7px; border-radius: 6px; pointer-events: none; }
.plabel.sos { background: var(--alert); }
.hide-labels .plabel { display: none; }
.flag { font-size: 24px; filter: drop-shadow(0 1px 2px rgba(0,0,0,.5)); }
.pop b { font-size: 15px; } .pop div { margin-top: 3px; font-size: 13px; color: var(--muted); }
.pop a { display: inline-block; margin: 6px 8px 0 0; font-weight: 700; color: var(--route); }

/* Overlay & kartu */
.overlay { position: fixed; inset: 0; z-index: 900; background: rgba(10,16,40,.78); display: grid; place-items: center; padding: 16px; overflow-y: auto; }
.card { width: 100%; max-width: 420px; background: var(--paper); border-radius: 18px; padding: 20px; display: grid; gap: 12px; }
.card h2 { margin: 0; font-size: 22px; }
.muted { color: var(--muted); margin: 0; line-height: 1.45; font-size: 14px; }
label { display: grid; gap: 5px; font-weight: 700; font-size: 14px; }
input[type=text], input[type=tel], input[type=email], input[type=password], input[type=search] {
  width: 100%; min-height: 50px; border: 2px solid var(--line); border-radius: 12px; padding: 0 14px; font-size: 17px; background: #fff; color: var(--ink); }
input:focus { border-color: var(--route); outline: none; }
.err { margin: 0; color: var(--bad); font-weight: 700; font-size: 14px; min-height: 0; }
.primary { min-height: 52px; border: 0; border-radius: 12px; background: var(--route); color: #fff; font-weight: 800; font-size: 17px; }
.link { border: 0; background: none; color: var(--route); font-weight: 700; padding: 8px; }
.ghost { min-height: 44px; border: 2px solid var(--line); background: #fff; border-radius: 10px; font-weight: 700; }
.danger { min-height: 44px; border: 2px solid var(--bad); background: #fff; color: var(--bad); border-radius: 10px; font-weight: 700; }
.help { margin: 0; padding-left: 20px; display: grid; gap: 8px; line-height: 1.45; font-size: 15px; }

/* Menu */
.menu { position: absolute; right: 10px; top: calc(env(safe-area-inset-top, 0px) + 60px); z-index: 800; background: #fff; border-radius: 12px; overflow: hidden; box-shadow: 0 8px 24px rgba(0,0,0,.35); min-width: 190px; }
.menu button { display: block; width: 100%; text-align: left; border: 0; background: #fff; padding: 14px 16px; font-size: 16px; border-bottom: 1px solid var(--line); }
.menu button:last-child { border-bottom: 0; }

/* Panel operator */
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 850; height: 78%; background: var(--paper); border-radius: 18px 18px 0 0;
  box-shadow: 0 -8px 30px rgba(0,0,0,.4); display: flex; flex-direction: column; padding: 12px 12px calc(env(safe-area-inset-bottom, 0px) + 12px); gap: 10px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h2 { margin: 0; font-size: 20px; }
.sheet .icon-btn { background: var(--line); color: var(--ink); }
.stats { display: flex; gap: 8px; flex-wrap: wrap; }
.stats span { background: #fff; border: 2px solid var(--line); border-radius: 999px; padding: 5px 12px; font-weight: 700; font-size: 13px; }
.stats span.s { border-color: var(--alert); color: var(--alert); }
.plist { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; display: grid; gap: 8px; align-content: start; }
.plist li { background: #fff; border: 2px solid var(--line); border-radius: 12px; padding: 10px 12px; display: grid; gap: 6px; }
.plist li.sos { border-color: var(--alert); background: #FFF0F8; }
.plist .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.plist .nm { font-weight: 800; font-size: 16px; }
.plist .meta { font-size: 13px; color: var(--muted); }
.plist .acts { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.plist .acts button, .plist .acts a, .plist select { min-height: 38px; padding: 0 12px; border-radius: 9px; border: 2px solid var(--line); background: #fff; font-weight: 700; font-size: 14px; color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; }
.plist .acts .sosclr { background: var(--alert); border-color: var(--alert); color: #fff; }
.ops-tools { display: flex; flex-wrap: wrap; gap: 8px; }
.file-btn { min-height: 44px; display: inline-flex; align-items: center; padding: 0 14px; border-radius: 10px; background: var(--route); color: #fff; font-weight: 800; cursor: pointer; }
.file-btn input { display: none; }

/* Toast */
.toast { position: fixed; left: 16px; right: 16px; bottom: calc(env(safe-area-inset-bottom, 0px) + 96px); z-index: 1000; background: var(--ink); color: #fff;
  padding: 12px 14px; border-radius: 12px; font-weight: 700; text-align: center; box-shadow: 0 6px 20px rgba(0,0,0,.4); }

@media (min-width: 720px) {
  #app { max-width: 520px; margin: 0 auto; }
  .sheet { max-width: 520px; left: 50%; right: auto; width: 100%; transform: translateX(-50%); }
}
@media (prefers-reduced-motion: reduce) { .pin.sos, .sos.active { animation: none; } .sos.holding .sos-fill { transition: none; } }

/* Daftar nama peserta */
.roster { list-style: none; margin: -4px 0 0; padding: 0; max-height: 220px; overflow-y: auto; border: 2px solid var(--line); border-radius: 12px; background: #fff; }
.roster li { border-bottom: 1px solid var(--line); }
.roster li:last-child { border-bottom: 0; }
.roster button { width: 100%; min-height: 46px; text-align: left; border: 0; background: #fff; padding: 0 14px; font-size: 16px; color: var(--ink); }
.roster button:active { background: #E8F0FE; }
.roster .none { padding: 12px 14px; color: var(--muted); font-size: 14px; }

/* Daftar nama berbentuk pilihan (radio) */
.radios { max-height: 260px; overflow-y: auto; border: 2px solid var(--line); border-radius: 12px; background: #fff; }
.rad { display: flex; align-items: center; gap: 12px; min-height: 50px; padding: 0 14px; border-bottom: 1px solid var(--line); font-weight: 600; font-size: 16px; cursor: pointer; }
.rad:last-child { border-bottom: 0; }
.rad input { width: 22px; height: 22px; margin: 0; accent-color: var(--route); flex: none; }
.rad:has(input:checked) { background: #E8F0FE; font-weight: 800; }
.radios .none { padding: 12px 14px; color: var(--muted); font-size: 14px; font-weight: 400; }
