*{box-sizing:border-box}body{margin:0;background:#101820;color:#fff;font:14px Arial}header{height:62px;background:#182934;padding:15px;display:flex;justify-content:space-between}#gps{background:#a66b00;padding:7px 12px;border-radius:16px}.mapwrap{position:relative}#map{height:56vh;min-height:370px}.layers{position:absolute;z-index:800;top:12px;left:12px;background:#172833;padding:5px;border-radius:7px}button{border:0;border-radius:6px;padding:10px;background:#385466;color:#fff;font-weight:bold;cursor:pointer}#tools{display:grid;grid-template-columns:repeat(6,1fr);gap:5px;padding:7px;background:#14232d}#tools button{font-size:19px}#tools small{display:block;margin-top:5px}#tools .active{background:#f4a600;color:#111}section{background:#213540;padding:12px}section>div:first-child{display:flex;justify-content:space-between}.stats{display:flex;gap:8px;flex-wrap:wrap;margin:12px 0}.stats b{background:#12242f;padding:8px;border-radius:6px}.actions{display:flex;gap:8px}#gen{margin-left:auto;background:#07985d}.leaflet-tooltip{font-weight:bold}@media(max-width:700px){#tools{grid-template-columns:repeat(3,1fr)}#map{height:50vh}}.editbar{display:flex;align-items:center;gap:8px;background:#162934;padding:8px;border-radius:7px;margin:8px 0}.editbar b{margin-right:auto}.editbar #delete{background:#a33b3b}.editbar #move{background:#b47500}.hidden{display:none!important}.selectedMarker{filter:drop-shadow(0 0 5px #fff)}.modal{position:fixed;z-index:2200;inset:0;background:#000a;display:grid;place-items:center;padding:16px}.card{width:min(470px,100%);background:#203642;border-radius:12px;padding:18px}.card h3{margin:0 0 12px}.card label{display:block;margin:12px 0;color:#c7d7df}.card input,.card textarea{display:block;width:100%;margin-top:5px;padding:10px;border:1px solid #536c79;border-radius:6px;background:#10242e;color:#fff}.card textarea{min-height:90px}.coords{background:#112833;padding:10px;border-radius:6px;font-weight:bold}.modalActions{display:flex;justify-content:flex-end;gap:8px;margin-top:14px}#pesave{background:#07985d}#peform{background:#1479c9}
.quickcard{background:#132a35;border:1px solid #47616d;border-radius:9px;padding:10px;margin:8px 0;max-width:520px}
.quickhead{display:flex;justify-content:space-between;align-items:center}.quickhead b{font-size:16px}.quickhead #qclose{padding:4px 10px;background:#344b58;font-size:18px}
.qcoords{font-weight:bold;color:#d9eaf2;margin:7px 0 9px}.qrow{display:grid;grid-template-columns:95px 1fr;gap:8px;padding:5px 0;border-top:1px solid #29424e}.qrow span:first-child{color:#9fb5c0}.qactions{display:flex;gap:7px;margin-top:10px}.qactions #qedit{background:#1479c9}.qactions #qmove{background:#b47500}.qactions #qdelete{background:#a33b3b}

.hovercard{font:12px Arial;min-width:220px}.hovercard b{font-size:13px}.hovercard .hc{margin-top:4px}.hovercard .muted{color:#52636d}

.photoBox{margin-top:10px;background:#10242e;padding:8px;border-radius:8px}
.photoBox img{display:block;width:100%;max-height:230px;object-fit:contain;border-radius:6px;background:#0b171d}
.photoActions{display:flex;align-items:center;gap:8px;margin-top:7px}.photoActions span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:1}
#removePhoto{background:#9c3b3b;padding:7px 9px}
.hovercard img{display:block;width:150px;max-height:105px;object-fit:cover;border-radius:5px;margin-top:6px}
.qphoto{width:100%;max-width:300px;max-height:160px;object-fit:cover;border-radius:6px;margin-top:7px}

#specificFields label{display:block;margin:11px 0;color:#c7d7df}
#specificFields input,#specificFields select{display:block;width:100%;margin-top:5px;padding:10px;border:1px solid #536c79;border-radius:6px;background:#10242e;color:#fff}
.specificActions{display:flex;gap:7px;flex-wrap:wrap;margin-top:14px}.specificActions #specificSave{background:#07985d;margin-left:auto}.specificActions #specificDelete{background:#a33b3b}.specificActions #specificMove{background:#b47500}

#clearPreview{background:#7c4d12}.proj-pp{filter:drop-shadow(0 0 3px #fff)}
.projLabel{background:#182832;color:#fff;border:1px solid #fff;border-radius:4px;padding:2px 4px;font-weight:bold}
.previewLegend{position:absolute;z-index:790;right:10px;bottom:10px;background:#12242ee8;color:#fff;padding:8px 10px;border-radius:7px;font-size:11px}

#tools{grid-template-columns:repeat(8,1fr)}
@media(max-width:900px){#tools{grid-template-columns:repeat(4,1fr)}}
.startIcon{filter:drop-shadow(0 0 4px #fff)}

/* V0.4.6: início automático; 7 ferramentas na barra */
#tools{grid-template-columns:repeat(7,1fr)}
@media(max-width:900px){#tools{grid-template-columns:repeat(4,1fr)}}
.autoStartRing{filter:drop-shadow(0 0 4px #27d34d)}

.techLabel{background:#10242e;color:#fff;border:1px solid #d7e4ea;border-radius:4px;padding:3px 5px;font-size:10px;line-height:1.2}

.ppTechTag{background:#10242e;color:#fff;border:1px solid #d7e4ea;border-radius:4px;padding:2px 5px;font-size:10px;font-weight:700;white-space:nowrap;box-shadow:0 1px 3px #0008}

.cabo335Preview{background:#10242e;color:#fff;border:1px solid #e8f2f7;border-radius:3px;padding:2px 4px;font-size:9px;font-weight:700;white-space:nowrap}

/* V0.5.5: anotações do vão paralelas à rede, como no DXF */
.spanRotatedIcon{background:transparent!important;border:0!important}
.spanRotatedText{
  position:absolute;left:0;top:0;transform-origin:center center;
  color:#fff;font-weight:700;white-space:nowrap;
  text-shadow:-1px -1px 1px #10242e,1px -1px 1px #10242e,-1px 1px 1px #10242e,1px 1px 1px #10242e;
  pointer-events:none;
}
.spanCable{font-size:10px}
.spanCota{font-size:10px}

/* V0.5.6: cabo/cota colados à rede, mantendo rotação do vão */
.spanRotatedText{
  display:inline-block;
  padding:1px 3px;
  border-radius:3px;
  line-height:1.05;
  background:rgba(25,45,55,.92);
  border:1px solid rgba(255,255,255,.70);
  box-shadow:0 1px 2px rgba(0,0,0,.35);
  color:#fff;
  text-shadow:none;
}
.spanCable{
  font-size:10px;
  border:1.5px solid #fff;
  outline:1px solid rgba(25,45,55,.95);
  outline-offset:1px;
}
.spanCota{
  font-size:10px;
}

/* V0.5.7: etiqueta de poste compacta em duas linhas */
.techTag,
.leaflet-tooltip.techTag{
  text-align:center;
  line-height:1.15;
  white-space:nowrap;
  padding:3px 5px;
  min-width:58px;
}

/* V0.5.9 — geometria real dos blocos PP e PE da Prancha Modelo 2017.5 */
.poleBlockMarker{background:transparent!important;border:0!important}
.poleReal{width:30px;height:34px;transform-origin:50% 50%;position:relative}
.poleReal svg{width:100%;height:100%;overflow:visible}
.poleReal svg line{fill:none;stroke-linecap:square;stroke-linejoin:miter}
.ppReal svg line{stroke:#000;stroke-width:1.55}
.ppReal .poleFill{fill:#000;stroke:none}
.peReal svg line{stroke:#000;stroke-width:1.65}
.peReal .poleFill{fill:none}
.poleStart:after{
 content:"";position:absolute;left:50%;top:50%;width:31px;height:31px;
 transform:translate(-50%,-50%);border:2px solid #29d34d;border-radius:50%;
 box-sizing:border-box;pointer-events:none;
}


/* V0.6.0 — bloco real T da Prancha Modelo 2017.5 */
.groundingBlockMarker{background:transparent!important;border:0!important}
.groundingReal{width:36px;height:36px;position:relative}
.groundingReal svg{width:100%;height:100%;overflow:visible}
.groundingReal svg line,.groundingReal svg circle,.groundingReal svg polyline,.groundingReal svg polygon{
  stroke:#000;stroke-width:1.9;fill:none;stroke-linecap:square;stroke-linejoin:miter;
}

#projectManager{background:#142a36;padding:8px 10px;border-bottom:1px solid #274756}.pmRow{display:flex;gap:6px;align-items:center;flex-wrap:wrap}.pmRow input{height:34px;border:1px solid #547080;border-radius:5px;padding:0 9px;background:#f5f7f8;color:#111;min-width:155px}.pmRow button{height:36px;border:0;border-radius:5px;background:#355d72;color:#fff;font-weight:800;padding:0 13px}#saveProject{background:#16784a}.pmRow #newProject{background:#875813}#projectsPanel{margin-top:8px;background:#eef3f5;color:#111;border-radius:6px;padding:8px;max-height:220px;overflow:auto}.pmPanelTitle{font-weight:900;font-size:12px;margin-bottom:6px}.pmProject{display:grid;grid-template-columns:1fr auto auto;gap:6px;align-items:center;padding:7px;border-bottom:1px solid #ccd6db}.pmProject small{display:block;color:#52636c}.pmProject button{border:0;border-radius:4px;padding:6px 9px;font-weight:800}.pmOpen{background:#246b8b;color:#fff}.pmDelete{background:#8c3333;color:#fff}

/* V1.0.1 — separação visual entre gestão do projeto e mapa */
#projectManager{
  position:relative;
  z-index:1200;
  background:#142a36;
  padding:8px 10px 10px;
  border-bottom:2px solid #0d202a;
}
.pmRow{
  display:grid;
  grid-template-columns:auto minmax(180px,1fr) minmax(150px,1fr) minmax(150px,1fr) auto auto;
  gap:6px;
  align-items:center;
}
.pmRow input{width:100%;min-width:0;box-sizing:border-box}
#map{position:relative;z-index:1}
.leaflet-control-container{position:relative;z-index:800}
@media(max-width:850px){
 .pmRow{grid-template-columns:1fr 1fr}
 .pmRow input{grid-column:span 2}
 #projectsBtn,#saveProject,#newProject{width:100%}
}

/* V1.0.2 — restaura os controles superiores do Leaflet */
.leaflet-control-container{position:static!important;z-index:auto!important}
.leaflet-top,.leaflet-bottom{z-index:1000!important}
.leaflet-control{z-index:1000}
#map{position:relative;z-index:1}
.pmStorageInfo{font-size:12px;background:#dfe9ee;padding:7px;border-radius:4px;margin-bottom:6px;line-height:1.35}

#chooseFolder{background:#4c6270!important}
.pmFolderStatus{font-size:11px;color:#d9e8ef;margin-top:5px}

/* V1.1.2 — botão compacto Minha localização */
.myLocationBtn,.locateBtn,#myLocation,#locate,#gpsLocate{
  width:36px!important;height:36px!important;min-width:36px!important;
  padding:0!important;border-radius:50%!important;
  display:flex!important;align-items:center!important;justify-content:center!important;
  font-size:22px!important;line-height:1!important;font-weight:900!important;
  position:relative;
}
.locationPinIcon{width:18px;height:18px;display:block}

/* V1.1.3 — Minha localização fixa no canto inferior direito do mapa */
.myLocationBtn{
  position:absolute!important;
  right:16px!important;
  bottom:16px!important;
  left:auto!important;
  top:auto!important;
  z-index:1500!important;
  width:44px!important;
  height:44px!important;
  min-width:44px!important;
  border-radius:50%!important;
  background:#fff!important;
  color:#1976d2!important;
  border:1px solid #9aa7ad!important;
  box-shadow:0 2px 7px rgba(0,0,0,.35)!important;
  display:flex!important;
  align-items:center!important;
  justify-content:center!important;
  padding:0!important;
}
.myLocationBtn:hover{background:#f2f7fb!important}
.myLocationBtn .locationPinIcon{width:22px!important;height:22px!important}

/* V1.1.4 — controle independente e sempre visível */
#mapLocateBtn{
 position:absolute;right:16px;bottom:16px;z-index:2000;
 width:46px;height:46px;border-radius:50%;border:1px solid #8d9ba3;
 background:#fff;color:#1976d2;box-shadow:0 2px 8px rgba(0,0,0,.38);
 display:flex;align-items:center;justify-content:center;padding:0;cursor:pointer;
}
#mapLocateBtn:hover{background:#eef6ff}
#mapLocateBtn svg{width:24px;height:24px}

/* V1.2.1 MOBILE/PWA */
html,body{overscroll-behavior:none}
body{min-height:100dvh}
@media(max-width:700px){
 #projectManager{padding:6px}
 .pmRow{display:grid!important;grid-template-columns:1fr 1fr!important;gap:5px!important}
 .pmRow input{grid-column:1/-1!important;height:40px!important;font-size:15px!important}
 .pmRow button{height:40px!important}
 #map{min-height:360px!important}
 #mapLocateBtn{right:12px!important;bottom:12px!important;width:48px!important;height:48px!important}
}

/* V1.4.0 - Arruamento semiautomático */
#roadBtn{background:#245d70!important;color:#fff!important}
.roadCard{max-width:520px}
.roadHelp{font-size:12px;line-height:1.35;background:#eaf5f8;border:1px solid #b9dbe4;padding:9px;border-radius:8px;margin-bottom:10px}
.roadGrid{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.roadCard select,.roadCard input{width:100%;box-sizing:border-box}
.roadLegend{font-size:11px;font-weight:800;padding:8px 0}
@media(max-width:640px){.roadGrid{grid-template-columns:1fr}.roadCard .modalActions{display:grid;grid-template-columns:1fr 1fr;gap:6px}}
