/* ─── Leaflet 1.9.4  ─────────────── */
.leaflet-pane,.leaflet-tile,.leaflet-marker-icon,.leaflet-marker-shadow,.leaflet-tile-container,.leaflet-pane>svg,.leaflet-pane>canvas,.leaflet-zoom-box,.leaflet-image-layer,.leaflet-layer{position:absolute;left:0;top:0}
.leaflet-container{overflow:hidden;-webkit-tap-highlight-color:transparent}
.leaflet-tile,.leaflet-marker-icon,.leaflet-marker-shadow{-webkit-user-select:none;user-select:none;-webkit-user-drag:none}
.leaflet-tile::selection{background:transparent}
.leaflet-marker-icon,.leaflet-marker-shadow{display:block}
.leaflet-container .leaflet-overlay-pane svg,.leaflet-container .leaflet-marker-pane img,.leaflet-container .leaflet-shadow-pane img,.leaflet-container .leaflet-tile-pane img,.leaflet-container img.leaflet-image-layer,.leaflet-container .leaflet-layer img:not(.leaflet-tile){max-width:none!important;max-height:none!important}
.leaflet-container.leaflet-touch-zoom{touch-action:pan-x pan-y}
.leaflet-container.leaflet-touch-drag{touch-action:none;-webkit-touch-callout:none}
.leaflet-container.leaflet-touch-drag.leaflet-touch-zoom{touch-action:none}
.leaflet-tile{filter:inherit;visibility:hidden}
.leaflet-tile-loaded{visibility:inherit}
.leaflet-zoom-box{width:0;height:0;box-sizing:border-box;z-index:800}
.leaflet-pane{z-index:400}.leaflet-tile-pane{z-index:200}.leaflet-overlay-pane{z-index:400}
.leaflet-shadow-pane{z-index:500}.leaflet-marker-pane{z-index:600}.leaflet-tooltip-pane{z-index:650}
.leaflet-popup-pane{z-index:700}.leaflet-map-pane canvas{z-index:100}.leaflet-map-pane svg{z-index:200}
.leaflet-control{position:relative;z-index:800;pointer-events:auto}
.leaflet-top,.leaflet-bottom{position:absolute;z-index:1000;pointer-events:none}
.leaflet-top{top:0}.leaflet-right{right:0}.leaflet-bottom{bottom:0}.leaflet-left{left:0}
.leaflet-control{float:left;clear:both}.leaflet-right .leaflet-control{float:right}
.leaflet-top .leaflet-control{margin-top:10px}.leaflet-bottom .leaflet-control{margin-bottom:10px}
.leaflet-left .leaflet-control{margin-left:10px}.leaflet-right .leaflet-control{margin-right:10px}
.leaflet-fade-anim .leaflet-popup{opacity:0;transition:opacity .2s linear}
.leaflet-fade-anim .leaflet-map-pane .leaflet-popup{opacity:1}
.leaflet-zoom-animated{transform-origin:0 0}
.leaflet-zoom-anim .leaflet-zoom-animated{transition:transform .25s cubic-bezier(0,0,.25,1)}
.leaflet-zoom-anim .leaflet-tile,.leaflet-pan-anim .leaflet-tile{transition:none}
.leaflet-interactive{cursor:pointer}.leaflet-grab{cursor:grab}
.leaflet-crosshair,.leaflet-crosshair .leaflet-interactive{cursor:crosshair}
.leaflet-popup-pane,.leaflet-control{cursor:auto}
.leaflet-dragging .leaflet-grab,.leaflet-dragging .leaflet-grab .leaflet-interactive,.leaflet-dragging .leaflet-marker-draggable{cursor:grabbing}
.leaflet-marker-icon,.leaflet-marker-shadow,.leaflet-image-layer,.leaflet-pane>svg path,.leaflet-tile-container{pointer-events:none}
.leaflet-marker-icon.leaflet-interactive,.leaflet-image-layer.leaflet-interactive,.leaflet-pane>svg path.leaflet-interactive,path.leaflet-interactive{pointer-events:auto}
.leaflet-container{background:#ddd;font-family:system-ui,sans-serif;font-size:12px;line-height:1.5}
.leaflet-container a{color:#0078A8}
.leaflet-zoom-box{border:2px dotted #38f;background:rgba(255,255,255,.5)}
.leaflet-bar{box-shadow:0 1px 5px rgba(0,0,0,.65);border-radius:4px}
.leaflet-bar a,.leaflet-bar a:hover,.leaflet-bar a:focus{background-color:#fff;border-bottom:1px solid #ccc;width:26px;height:26px;line-height:26px;display:block;text-align:center;text-decoration:none;color:#000}
.leaflet-bar a:hover,.leaflet-bar a:focus{background-color:#f4f4f4}
.leaflet-bar a:first-child{border-top-left-radius:4px;border-top-right-radius:4px}
.leaflet-bar a:last-child{border-bottom-left-radius:4px;border-bottom-right-radius:4px;border-bottom:none}
.leaflet-bar a.leaflet-disabled{cursor:default;background-color:#f4f4f4;color:#bbb}
.leaflet-control-zoom-in,.leaflet-control-zoom-out{font:bold 18px/26px Lucida Console,Monaco,monospace;text-indent:1px}
.leaflet-control-attribution{background:rgba(255,255,255,.8);margin:0;padding:0 5px}
.leaflet-control-attribution a{text-decoration:none}
.leaflet-control-scale-line{border:2px solid #777;border-top:none;line-height:1.1;padding:2px 5px 1px;font-size:11px;white-space:nowrap;overflow:hidden;box-sizing:border-box;background:rgba(255,255,255,.8)}
.leaflet-popup{position:absolute;text-align:center;margin-bottom:20px}
.leaflet-popup-content-wrapper{padding:1px;text-align:left;border-radius:12px}
.leaflet-popup-content{margin:13px 20px 13px 16px;line-height:1.3;font-size:13px;min-height:1px}
.leaflet-popup-content p{margin:1.3em 0}
.leaflet-popup-tip-container{width:40px;height:20px;position:absolute;left:50%;margin-left:-20px;overflow:hidden;pointer-events:none}
.leaflet-popup-tip{width:17px;height:17px;padding:1px;margin:-10px auto 0;pointer-events:auto;transform:rotate(45deg)}
.leaflet-popup-content-wrapper,.leaflet-popup-tip{background:#fff;color:#333;box-shadow:0 3px 14px rgba(0,0,0,.4)}
.leaflet-container a.leaflet-popup-close-button{position:absolute;top:0;right:0;border:none;text-align:center;width:24px;height:24px;font:16px/24px Tahoma,Verdana,sans-serif;color:#757575;text-decoration:none;background:transparent}
.leaflet-container a.leaflet-popup-close-button:hover{color:#333}
.leaflet-tooltip{position:absolute;padding:6px;background-color:#fff;border:1px solid #fff;border-radius:3px;color:#222;white-space:nowrap;user-select:none;pointer-events:none;box-shadow:0 1px 3px rgba(0,0,0,.4)}

/* ─── Tokens ──────────────────────────────────────────────── */
:root{
  --green:#1A9B6C;--green-dk:#107A50;--green-lt:#E4F5EE;
  --amber:#C87F00;--amber-lt:#FEF3C7;
  --red:#DC2626;--red-lt:#FEE2E2;
  --gray:#6B7280;--gray-lt:#F3F4F6;
  --blue:#2563EB;--teal:#0E7490;--purple:#7C3AED;
  --bg:#FFFFFF;--surface:#F7F9F8;--border:#E2E8E4;
  --text:#111827;--text-2:#374151;--text-muted:#6B7280;
  --sidebar-w:320px;--header-h:50px;
}
@media(prefers-color-scheme:dark){:root:not([data-theme="light"]){
  --bg:#121416;--surface:#1A1D20;--border:#2D3237;--text:#ECEFF1;
  --text-2:#C2C8CD;--text-muted:#8B949C;--gray-lt:#1F2C25;
  --green-lt:#0D2A1E;--amber-lt:#2A1E00;--red-lt:#2A0A0A;
}}
:root[data-theme="dark"]{
  --bg:#121416;--surface:#1A1D20;--border:#2D3237;--text:#ECEFF1;
  --text-2:#C2C8CD;--text-muted:#8B949C;--gray-lt:#1F2C25;
  --green-lt:#0D2A1E;--amber-lt:#2A1E00;--red-lt:#2A0A0A;
}
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
html,body{height:100%;overflow:hidden}
body{font-family:'Inter',system-ui,sans-serif;background:var(--bg);color:var(--text);
  display:grid;grid-template-rows:var(--header-h) 1fr}

/* ─── Header ─────────────────────────────────────────────── */
header{background:var(--green);color:#fff;display:flex;align-items:center;
  padding:0 14px;gap:10px;z-index:20;box-shadow:0 2px 8px rgba(0,0,0,.2)}
.logo{width:28px;height:28px;background:rgba(255,255,255,.2);border-radius:6px;
  display:flex;align-items:center;justify-content:center;font-weight:700;font-size:13px;flex-shrink:0}
header h1{font-size:14px;font-weight:600;flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.hbtn{background:rgba(255,255,255,.15);border:none;color:#fff;border-radius:6px;
  padding:5px 11px;font-size:12px;font-weight:500;cursor:pointer;white-space:nowrap;display:flex;align-items:center;gap:4px}
.hbtn:hover{background:rgba(255,255,255,.25)}
.hsep{width:1px;height:20px;background:rgba(255,255,255,.25)}

/* ─── Layout ─────────────────────────────────────────────── */
.main{display:grid;grid-template-columns:var(--sidebar-w) 1fr;overflow:hidden}

/* ─── Sidebar ─────────────────────────────────────────────── */
.sidebar{background:var(--surface);border-right:1px solid var(--border);
  display:flex;flex-direction:column;overflow:hidden}
.sb-scroll{flex:1;overflow-y:auto;padding:12px 14px 20px;scroll-behavior:smooth}
.sb-scroll::-webkit-scrollbar{width:4px}
.sb-scroll::-webkit-scrollbar-thumb{background:var(--border);border-radius:2px}
.stitle{font-size:10px;font-weight:700;text-transform:uppercase;letter-spacing:.07em;
  color:var(--text-muted);margin:14px 0 8px}
.stitle:first-child{margin-top:0}

/* Stats */
.stats{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.scard{background:var(--bg);border:1px solid var(--border);border-radius:8px;padding:10px 12px}
.scard .v{font-size:22px;font-weight:700;line-height:1}
.scard .l{font-size:11px;color:var(--text-muted);margin-top:2px}

/* Phase bars */
.prow{display:grid;grid-template-columns:1fr auto;align-items:baseline;column-gap:8px;row-gap:4px;margin-bottom:10px;cursor:default}
.pname{font-size:12px;color:var(--text-2);line-height:1.3}
.pbar{grid-column:1 / -1;height:5px;background:var(--border);border-radius:3px;overflow:hidden}
.pfill{height:100%;background:var(--green);border-radius:3px;transition:width .4s}
.ppct{font-size:11px;color:var(--text-muted);text-align:right}

/* Layer toggles */
.layer-row{display:flex;align-items:center;gap:8px;padding:5px 0;cursor:pointer}
.layer-row:hover .llabel{color:var(--green)}
.layer-row input[type=checkbox]{width:14px;height:14px;accent-color:var(--green);cursor:pointer;flex-shrink:0}
.llabel{font-size:12px;color:var(--text-2);flex:1;user-select:none}
.lcount{font-size:11px;color:var(--text-muted);background:var(--border);
  border-radius:10px;padding:1px 7px}

/* Records */
.reccard{background:var(--bg);border:1px solid var(--border);border-radius:8px;
  padding:9px 12px;cursor:pointer;margin-bottom:6px;transition:border-color .15s}
.reccard:hover{border-color:var(--green)}
.rectop{display:flex;align-items:center;gap:6px;margin-bottom:2px}
.recdot{width:8px;height:8px;border-radius:50%;flex-shrink:0}
.recaddr{font-size:13px;font-weight:500;flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.recmeta{font-size:11px;color:var(--text-muted)}
.recphase{font-size:11px;background:var(--green-lt);color:var(--green-dk);
  border-radius:4px;padding:1px 6px}

/* Search */
.sbox{position:relative;margin-bottom:0}
.sinput{width:100%;border:1px solid var(--border);border-radius:8px;
  background:var(--bg);color:var(--text);font-size:13px;padding:8px 34px 8px 10px;
  outline:none;font-family:inherit}
.sinput:focus{border-color:var(--green);box-shadow:0 0 0 3px rgba(26,155,108,.12)}
.sspin{position:absolute;right:9px;top:50%;transform:translateY(-50%);
  width:14px;height:14px;border:2px solid var(--border);border-top-color:var(--green);
  border-radius:50%;animation:spin .6s linear infinite;display:none}
@keyframes spin{to{transform:translateY(-50%) rotate(360deg)}}
.sres{position:absolute;z-index:1100;width:100%;background:var(--bg);
  border:1px solid var(--border);border-radius:8px;
  box-shadow:0 4px 18px rgba(0,0,0,.12);margin-top:4px;
  max-height:220px;overflow-y:auto;display:none}
.sresitem{padding:9px 12px;cursor:pointer;font-size:13px;
  border-bottom:1px solid var(--border);color:var(--text-2)}
.sresitem:last-child{border-bottom:none}
.sresitem:hover{background:var(--green-lt);color:var(--green-dk)}

/* Note */
.note{background:var(--amber-lt);border:1px solid var(--amber);border-radius:8px;
  padding:9px 12px;font-size:12px;color:#854D0E;margin-bottom:12px;line-height:1.5}
.note strong{display:block;margin-bottom:2px;font-size:12px}

/* ─── Map ─────────────────────────────────────────────────── */
.mapwrap{position:relative;display:flex;flex-direction:column}
#map{flex:1}

/* Floating legend */
.flegend{position:absolute;top:12px;right:12px;z-index:900;
  background:var(--bg);border:1px solid var(--border);border-radius:10px;
  padding:10px 14px;box-shadow:0 2px 14px rgba(0,0,0,.12);font-size:11px;min-width:200px}
.fleg-title{font-weight:700;font-size:12px;color:var(--text);display:flex;align-items:center;gap:6px}
.fleg-toggle{background:none;border:none;color:var(--text-muted);cursor:pointer;
  font-size:11px;margin-left:auto;padding:2px 4px;border-radius:4px}
.fleg-toggle:hover{background:var(--gray-lt)}
.fleg-section{font-size:10px;font-weight:700;text-transform:uppercase;
  letter-spacing:.05em;color:var(--text-muted);margin:8px 0 4px}
.fleg-row{display:flex;align-items:center;gap:7px;margin-bottom:4px;color:var(--text-2)}
.lsym{width:16px;height:16px;display:flex;align-items:center;justify-content:center;flex-shrink:0}

/* Mode bar */
.modebar{position:absolute;bottom:22px;left:50%;transform:translateX(-50%);
  z-index:900;display:flex;gap:3px;background:var(--bg);border:1px solid var(--border);
  border-radius:24px;padding:4px 6px;box-shadow:0 2px 14px rgba(0,0,0,.12)}
.mbtn{border:none;background:none;padding:6px 14px;border-radius:18px;font-size:12px;
  font-weight:500;cursor:pointer;color:var(--text-muted);transition:all .15s}
.mbtn.on{background:var(--green);color:#fff}
.mbtn:hover:not(.on){background:var(--gray-lt);color:var(--text)}

/* ─── Modal ───────────────────────────────────────────────── */
.overlay{position:fixed;inset:0;background:rgba(0,0,0,.45);z-index:2000;
  display:none;align-items:center;justify-content:center;padding:16px}
.overlay.open{display:flex}
.modal{background:var(--bg);border-radius:14px;width:100%;max-width:500px;
  max-height:90dvh;display:flex;flex-direction:column;box-shadow:0 16px 50px rgba(0,0,0,.25)}
.mhead{padding:16px 18px 12px;border-bottom:1px solid var(--border);
  display:flex;align-items:center;gap:8px}
.mhead h2{font-size:15px;font-weight:700;flex:1}
.mclose{background:none;border:none;cursor:pointer;color:var(--text-muted);
  font-size:20px;line-height:1;padding:2px 6px;border-radius:6px}
.mclose:hover{background:var(--gray-lt)}
.mbody{padding:16px 18px;overflow-y:auto;flex:1}
.mfoot{padding:12px 18px;border-top:1px solid var(--border);
  display:flex;justify-content:flex-end;gap:8px}
.fg{margin-bottom:13px}
.fg label{display:block;font-size:11px;font-weight:600;color:var(--text-2);margin-bottom:4px}
.fg input,.fg select,.fg textarea{width:100%;border:1px solid var(--border);border-radius:7px;
  padding:7px 9px;font-size:13px;background:var(--bg);color:var(--text);font-family:inherit;outline:none}
.fg input:focus,.fg select:focus,.fg textarea:focus{
  border-color:var(--green);box-shadow:0 0 0 3px rgba(26,155,108,.12)}
.fg textarea{resize:vertical;min-height:65px}
.fg2{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.pstrip{display:flex;gap:5px;flex-wrap:wrap;margin-top:5px}
.pthumb{width:56px;height:56px;object-fit:cover;border-radius:6px;border:2px solid var(--border);cursor:pointer}
.padd{width:56px;height:56px;border:2px dashed var(--border);border-radius:6px;
  display:flex;align-items:center;justify-content:center;cursor:pointer;
  color:var(--text-muted);font-size:22px;background:var(--gray-lt)}
.padd:hover{border-color:var(--green);color:var(--green)}
.izone{border:2px dashed var(--border);border-radius:10px;padding:26px 18px;
  text-align:center;cursor:pointer;transition:all .15s;color:var(--text-muted)}
.izone:hover,.izone.drag{border-color:var(--green);color:var(--green);background:var(--green-lt)}
.izone .big{font-size:30px}
.izone p{font-size:13px;margin-top:6px}
.btn{padding:8px 18px;border-radius:8px;font-size:13px;font-weight:500;cursor:pointer;border:none;transition:all .15s}
.btn-p{background:var(--green);color:#fff}.btn-p:hover{background:var(--green-dk)}
.btn-o{background:transparent;border:1px solid var(--border);color:var(--text-2)}.btn-o:hover{background:var(--gray-lt)}
.btn-d{background:var(--red-lt);color:var(--red);border:1px solid transparent}.btn-d:hover{background:var(--red);color:#fff}
.toast{position:fixed;bottom:22px;left:50%;transform:translateX(-50%) translateY(20px);
  background:#1F2937;color:#fff;padding:9px 18px;border-radius:20px;font-size:12px;
  z-index:9999;opacity:0;transition:all .3s;pointer-events:none;white-space:nowrap}
.toast.show{opacity:1;transform:translateX(-50%) translateY(0)}
