/* KP WWB Field App — theme (matches the admin panel) */
:root{--brand:#0F5132;--deep:#0B2E1E;--accent:#1F7A4D;--ink:#16211B;--muted:#5B6660;--line:#E1E7E3;--bg:#F2F5F3;--card:#fff;
--g:#166534;--gbg:#DCFCE7;--y:#92400E;--ybg:#FEF3C7;--r:#991B1B;--rbg:#FEE2E2;--b:#1E40AF;--bbg:#E8F0FF;--p:#6D28D9;--pbg:#EDE9FE;
--sh:0 1px 2px rgba(16,24,20,.05),0 6px 18px rgba(16,24,20,.06);--rad:18px;--tab:64px}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{margin:0;background:var(--bg);color:var(--ink);font-family:Inter,system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;font-size:15px;line-height:1.45;-webkit-font-smoothing:antialiased}
#app{max-width:560px;margin:0 auto;min-height:100vh;min-height:100dvh;display:flex;flex-direction:column;position:relative}
#app.has-tabs{padding-bottom:calc(var(--tab) + env(safe-area-inset-bottom))}
.splash{margin:auto;text-align:center;font-weight:700;font-size:20px;color:var(--brand);padding:40px}
.splash small{font-weight:400;color:var(--muted);font-size:14px}
svg{flex-shrink:0}

/* header */
.hdr{background:linear-gradient(135deg,var(--deep) 0%,var(--brand) 55%,var(--accent) 100%);color:#fff;
  padding:calc(14px + env(safe-area-inset-top)) 16px 18px;display:flex;flex-direction:column;gap:12px;border-radius:0 0 26px 26px;position:relative;overflow:hidden}
.hdr::after{content:"";position:absolute;right:-60px;top:-70px;width:220px;height:220px;border-radius:50%;background:rgba(255,255,255,.06);pointer-events:none}
.hdr.tall{padding-bottom:56px}
.hdr-row{display:flex;align-items:center;gap:12px;position:relative;z-index:1}
.hdr h1{margin:0;font-size:20px;line-height:1.25;letter-spacing:-.01em}.hdr p{margin:0;font-size:13px;color:#CFE6D8}
.hdr .back,.icon-btn{width:44px;height:44px;border-radius:14px;border:0;background:rgba(255,255,255,.14);color:#fff;font-size:22px;display:flex;align-items:center;justify-content:center;cursor:pointer;flex-shrink:0}
.hdr .back:active,.icon-btn:active{background:rgba(255,255,255,.25)}
.avatar{width:48px;height:48px;border-radius:16px;background:rgba(255,255,255,.16);border:1px solid rgba(255,255,255,.25);display:flex;align-items:center;justify-content:center;font-weight:700;font-size:17px;color:#fff;flex-shrink:0}
.avatar.lg{width:64px;height:64px;border-radius:20px;font-size:22px;background:var(--brand);color:#fff;border:0}
.chips{display:flex;flex-wrap:wrap;gap:6px;position:relative;z-index:1}
.chip{display:inline-flex;align-items:center;gap:6px;font-size:12px;font-weight:600;padding:5px 10px;border-radius:999px;background:rgba(255,255,255,.14);color:#fff}
.chip i{width:7px;height:7px;border-radius:4px;background:#4ADE80}
.chip.warn i{background:#FBBF24}.chip.bad{background:rgba(220,38,38,.35)}.chip.bad i{background:#FCA5A5}

/* body */
.body{padding:16px;display:flex;flex-direction:column;gap:12px;flex:1}
.body.lift{margin-top:-40px;position:relative;z-index:2}
h2{font-size:16px;margin:8px 0 0;display:flex;align-items:center;justify-content:space-between;gap:8px;letter-spacing:-.01em}
h2 small{font-weight:500;font-size:13px;color:var(--muted)}
.card{background:var(--card);border:1px solid var(--line);border-radius:var(--rad);padding:14px;display:flex;flex-direction:column;gap:8px;box-shadow:var(--sh)}
button.card{text-align:left;font:inherit;color:inherit;cursor:pointer;width:100%}
button.card:active{transform:scale(.99)}
.card.active{border:2px solid var(--brand)}
.card .top{display:flex;justify-content:space-between;gap:8px;align-items:center}
.small{font-size:12px;color:var(--muted);font-weight:600;letter-spacing:.01em}
.title{font-size:16px;font-weight:650;line-height:1.3}
.meta{font-size:13px;color:#3F4A44;display:flex;gap:6px;align-items:flex-start}
.meta svg{margin-top:2px;color:var(--muted)}
.badge{font-size:12px;font-weight:600;padding:4px 10px;border-radius:999px;white-space:nowrap}
.b-gray{background:#EEF0EE;color:#3F4A44}.b-yellow{background:var(--ybg);color:var(--y)}.b-green{background:var(--gbg);color:var(--g)}
.b-red{background:var(--rbg);color:var(--r)}.b-blue{background:#DBEAFE;color:var(--b)}.b-purple{background:var(--pbg);color:var(--p)}

/* stats */
.stats{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:0;padding:6px}
.stat{display:flex;flex-direction:column;gap:2px;padding:10px;border-radius:12px}
.stat+.stat{border-left:1px solid var(--line);border-radius:0}
.stat b{font-size:24px;line-height:1.1;letter-spacing:-.02em}.stat span{font-size:12px;color:var(--muted);font-weight:600}
.stat.warn b{color:#B45309}.stat.good b{color:var(--g)}

/* task card */
.tcard{position:relative;padding-left:18px}
.tcard::before{content:"";position:absolute;left:0;top:14px;bottom:14px;width:4px;border-radius:0 4px 4px 0;background:#CBD5CE}
.tcard.s-in_progress::before{background:#F59E0B}.tcard.s-completed::before{background:#2563EB}.tcard.s-approved::before{background:#16A34A}.tcard.s-rejected::before{background:#DC2626}
.steps{display:flex;gap:4px}.steps span{flex:1;height:6px;border-radius:3px;background:#E1E7E3}
.steps .done{background:#16A34A}.steps .now{background:#F59E0B}
.now-card{background:linear-gradient(135deg,#FFFBEB,#FEF3C7);border-color:#FCD34D}
.now-card .small{color:#92400E}

/* survey tiles */
.tiles{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
.tile{background:#fff;border:1px solid var(--line);border-radius:var(--rad);padding:14px;display:flex;flex-direction:column;align-items:flex-start;gap:8px;text-align:left;font:inherit;color:inherit;cursor:pointer;min-height:118px;box-shadow:var(--sh)}
.tile:active{transform:scale(.98)}
.tile b{font-size:14.5px;line-height:1.25}.tile small{font-size:12px;color:var(--muted);line-height:1.3}
.ti{width:40px;height:40px;border-radius:12px;display:flex;align-items:center;justify-content:center;color:#fff}
.ti-red{background:#FEE2E2;color:#B91C1C}.ti-amber{background:#FEF3C7;color:#B45309}.ti-green{background:#DCFCE7;color:#15803D}.ti-blue{background:#DBEAFE;color:#1D4ED8}.ti-purple{background:var(--pbg);color:var(--p)}

/* list rows */
.lrow{display:flex;gap:12px;align-items:center}
.lrow .ti{width:42px;height:42px}
.lrow .grow{flex:1;min-width:0}
.lrow .title{font-size:15px;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.chips-light{display:flex;gap:6px;overflow-x:auto;padding-bottom:2px;scrollbar-width:none}
.chips-light::-webkit-scrollbar{display:none}
.fchip{border:1px solid var(--line);background:#fff;border-radius:999px;padding:8px 14px;font:inherit;font-size:13px;font-weight:600;color:#3F4A44;white-space:nowrap;cursor:pointer;min-height:38px}
.fchip.on{background:var(--brand);border-color:var(--brand);color:#fff}
.search{position:relative}.search svg{position:absolute;left:14px;top:50%;transform:translateY(-50%);color:var(--muted)}
.search input{padding-left:42px}

/* misc blocks */
.dest{background:var(--bbg);border-radius:14px;padding:12px;display:flex;flex-direction:column;gap:2px;color:#172554}
.dest .small{color:#1E3A8A}
.kv{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}
.kv div{display:flex;flex-direction:column;gap:2px;min-width:0}.kv b{overflow-wrap:anywhere}
.tl{display:flex;flex-direction:column}
.tl-row{display:flex;gap:12px;min-height:56px}
.tl-dot{width:26px;height:26px;border-radius:13px;flex-shrink:0;display:flex;align-items:center;justify-content:center;color:#fff;font-size:14px;font-weight:700}
.tl-col{display:flex;flex-direction:column;align-items:center}
.tl-line{width:2px;flex:1;background:#E1E7E3;margin:2px 0}
.d-green{background:#16A34A}.d-yellow{background:#F59E0B}.d-red{background:#DC2626}.d-next{background:#fff;border:3px solid #F59E0B}.d-wait{background:#fff;border:2px solid #C9D2CC}
.foot{position:sticky;bottom:0;background:rgba(255,255,255,.96);backdrop-filter:blur(8px);border-top:1px solid var(--line);padding:12px 16px calc(14px + env(safe-area-inset-bottom));z-index:500}
.btn{width:100%;min-height:52px;border-radius:14px;border:0;background:var(--brand);color:#fff;font:inherit;font-size:16px;font-weight:650;display:flex;align-items:center;justify-content:center;gap:8px;cursor:pointer;box-shadow:0 4px 12px rgba(15,81,50,.22);text-decoration:none}
.btn:active{background:var(--deep)}
.btn:disabled{opacity:.55;box-shadow:none}
.btn-light{background:#fff;color:var(--brand);border:1px solid #B7CDBF;box-shadow:none}
.btn-light:active{background:#F2F7F4}
.btn-sm{min-height:44px;font-size:14px;width:auto;padding:0 14px}
.btn-danger{background:#fff;color:#B91C1C;border:1px solid #FCA5A5;box-shadow:none}
label{display:flex;flex-direction:column;gap:6px;font-weight:600;font-size:14px;color:#2B3630}
input,textarea,select{font:inherit;font-size:16px;padding:12px 14px;border:1px solid #CBD5CE;border-radius:12px;background:#fff;color:var(--ink);width:100%;min-height:48px}
input:focus,textarea:focus,select:focus{outline:2px solid #86EFAC;outline-offset:1px;border-color:var(--accent)}
.check{flex-direction:row;align-items:center;gap:10px;font-weight:500;min-height:44px}
.check input{width:22px;height:22px;min-height:0;flex-shrink:0;accent-color:var(--brand)}
.radio-cards{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
.radio-cards label{flex-direction:row;align-items:center;gap:8px;border:1px solid var(--line);border-radius:12px;padding:10px 12px;font-weight:600;min-height:48px;background:#fff}
.radio-cards input{width:20px;height:20px;min-height:0;accent-color:var(--brand)}
.radio-cards label:has(input:checked){border-color:var(--brand);background:#F0FDF4}
.map{height:220px;border-radius:16px;border:1px solid var(--line);overflow:hidden;box-shadow:var(--sh);z-index:1}
.map-tall{height:min(56vh,440px)}
.map-mid{height:260px}
.gps-box{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
.gps-box div{background:#fff;border:1px solid var(--line);border-radius:12px;padding:10px 12px;display:flex;flex-direction:column;gap:2px}
.gps-box b{font-size:15px}
.banner{border-radius:14px;padding:12px 14px;font-weight:600;font-size:14px;display:flex;flex-direction:column;gap:8px}
.ban-green{background:var(--gbg);color:#14532D}.ban-yellow{background:var(--ybg);color:#78350F}.ban-red{background:var(--rbg);color:#7F1D1D}.ban-blue{background:#DBEAFE;color:#1E3A8A}
.photos{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}
.ph{position:relative;aspect-ratio:1;border-radius:14px;overflow:hidden;background:#CBD5CE}
.ph img{width:100%;height:100%;object-fit:cover;display:block}
.ph button{position:absolute;top:4px;right:4px;width:32px;height:32px;border-radius:16px;border:0;background:rgba(23,32,27,.75);color:#fff;font-size:16px}
.ph-add{aspect-ratio:1;border-radius:14px;border:2px dashed #A7B5AD;background:#fff;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;font-size:13px;font-weight:600;color:#3F4A44;cursor:pointer}
.ph-add input{display:none}
.selfie{display:flex;flex-direction:row;gap:12px;align-items:center}
.selfie .ph{width:84px;height:84px;border-radius:42px;aspect-ratio:auto;flex-shrink:0}
.sig{width:100%;height:170px;background:#fff;border:1px solid #CBD5CE;border-radius:12px;touch-action:none;display:block}
.result{align-items:center;text-align:center;padding:28px 16px}
.result .big{width:76px;height:76px;border-radius:38px;display:flex;align-items:center;justify-content:center;color:#fff;font-size:38px;font-weight:700}
.muted{color:var(--muted)}.center{text-align:center}
.err{color:var(--r);font-weight:600}
.empty{text-align:center;color:var(--muted);padding:28px 10px;display:flex;flex-direction:column;align-items:center;gap:8px}
.empty svg{color:#A7B5AD}
.row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
.spacer{flex:1;min-width:0}
.sep{height:1px;background:var(--line);margin:4px 0}
#toast{position:fixed;left:50%;bottom:calc(var(--tab) + 24px + env(safe-area-inset-bottom));transform:translateX(-50%);background:#16211B;color:#fff;padding:10px 16px;border-radius:12px;font-size:14px;max-width:90vw;opacity:0;pointer-events:none;transition:opacity .2s;z-index:3000}
#toast.show{opacity:1}
.spin{width:20px;height:20px;border:3px solid rgba(255,255,255,.4);border-top-color:#fff;border-radius:50%;animation:sp .8s linear infinite}
@keyframes sp{to{transform:rotate(360deg)}}
#gpsBox{display:flex;flex-direction:column;gap:10px}

/* login */
.login{min-height:100vh;min-height:100dvh;display:flex;flex-direction:column}
.login-hdr{padding:calc(48px + env(safe-area-inset-top)) 24px 72px;border-radius:0 0 32px 32px;gap:14px}
.login-hdr .logo{width:64px;height:64px;border-radius:20px;background:rgba(255,255,255,.14);border:1px solid rgba(255,255,255,.25);display:flex;align-items:center;justify-content:center;color:#fff}
.login-hdr h1{font-size:26px}
.login-card{margin:-48px 16px 0;position:relative;z-index:2;gap:14px;padding:20px}
.login-foot{padding:20px 24px calc(20px + env(safe-area-inset-bottom));text-align:center;font-size:12px;color:var(--muted)}
.pw{position:relative}.pw input{padding-right:64px}
.pw button{position:absolute;right:6px;bottom:6px;height:36px;border:0;background:#EEF3F0;border-radius:9px;padding:0 10px;font:inherit;font-size:13px;font-weight:600;color:var(--brand)}

/* bottom tab bar */
.tabbar{position:fixed;left:50%;transform:translateX(-50%);bottom:0;width:100%;max-width:560px;background:rgba(255,255,255,.97);backdrop-filter:blur(10px);
  border-top:1px solid var(--line);display:flex;padding:6px 6px calc(6px + env(safe-area-inset-bottom));z-index:1000}
.tabbar button{flex:1;border:0;background:transparent;font:inherit;font-size:11.5px;font-weight:600;color:#6B7770;display:flex;flex-direction:column;align-items:center;gap:3px;padding:6px 0;min-height:52px;border-radius:12px;cursor:pointer;position:relative}
.tabbar button.on{color:var(--brand)}
.tabbar button.on .tb-ic{background:#DCFCE7}
.tb-ic{width:44px;height:28px;border-radius:14px;display:flex;align-items:center;justify-content:center}
.tabbar .dot{position:absolute;top:4px;right:calc(50% - 22px);min-width:18px;height:18px;border-radius:9px;background:#DC2626;color:#fff;font-size:11px;display:flex;align-items:center;justify-content:center;padding:0 5px}

/* drawing tools */
.seg{display:flex;background:#E9EEEB;border-radius:14px;padding:4px;gap:4px}
.seg button{flex:1;min-height:44px;border:0;border-radius:11px;background:transparent;font:inherit;font-weight:600;font-size:14px;color:#3F4A44;cursor:pointer;display:flex;align-items:center;justify-content:center;gap:6px}
.seg button.on{background:#fff;color:var(--brand);box-shadow:0 1px 3px rgba(0,0,0,.12)}
.toolrow{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:6px}
.toolrow button{min-height:52px;border:1px solid var(--line);background:#fff;border-radius:12px;font:inherit;font-size:12px;font-weight:600;color:#2B3630;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;cursor:pointer}
.toolrow button.primary{background:var(--brand);color:#fff;border-color:var(--brand)}
.toolrow button.stop{background:#DC2626;color:#fff;border-color:#DC2626}
.area-line{background:#fff;border:1px solid var(--line);border-radius:14px;padding:12px 14px;font-size:15px;display:flex;align-items:center;gap:10px;box-shadow:var(--sh)}
.area-line b{font-size:17px}
.stepno{display:inline-flex;width:24px;height:24px;border-radius:12px;background:var(--brand);color:#fff;font-size:13px;align-items:center;justify-content:center;margin-right:6px}
.profile{flex-direction:row;align-items:center;gap:14px}
.perm{display:flex;align-items:center;gap:10px;padding:8px 0}
.perm .ok{color:#16A34A}.perm .no{color:#9AA8A0}
@media (max-width:360px){.tiles{grid-template-columns:1fr}.tile{flex-direction:row;align-items:center;min-height:64px}.stats .stat b{font-size:20px}}
.leaflet-control-layers label{display:block;font-weight:500;font-size:13px;gap:0;margin:2px 0}.leaflet-control-layers label span{display:inline-flex;align-items:center;gap:6px}.leaflet-control-layers input{width:auto!important;min-height:0!important;height:auto;margin:0;padding:0}
.leaflet-container{font:inherit}
