/* ============================================================
   奥维内网地图系统 · 样式
   ============================================================ */
:root{
  --primary:#1a7f52;
  --primary-2:#22a066;
  --primary-light:#e6f4ec;
  --bg:#eef2f0;
  --panel:#ffffff;
  --text:#1f2a24;
  --text-sub:#6b7a72;
  --border:#dde5e0;
  --danger:#d0453b;
  --warn:#e08b1a;
  --shadow:0 6px 24px rgba(22,48,36,.10);
  --radius:10px;
}
*{box-sizing:border-box;}
html,body{height:100%;margin:0;}
body{
  font:14px/1.55 "Microsoft YaHei","PingFang SC","Segoe UI",system-ui,sans-serif;
  color:var(--text); background:var(--bg); overflow:hidden;
  -webkit-font-smoothing:antialiased;
}
.hidden{display:none !important;}
button,input,select{font-family:inherit;font-size:14px;}
code{background:#eef3f0;padding:1px 5px;border-radius:4px;font-size:12.5px;color:#2b6b4d;}
.muted{color:var(--text-sub);}
.sm{font-size:12.5px;}

/* ---------------- 按钮 ---------------- */
.btn{
  border:1px solid var(--border); background:#fff; color:var(--text);
  padding:7px 14px; border-radius:8px; cursor:pointer; transition:.15s;
  white-space:nowrap; line-height:1.2;
}
.btn:hover{border-color:#b9cdc3; background:#f7fbf9;}
.btn:active{transform:translateY(1px);}
.btn.primary{background:var(--primary); border-color:var(--primary); color:#fff;}
.btn.primary:hover{background:var(--primary-2); border-color:var(--primary-2);}
.btn.ghost{background:transparent;}
.btn.ghost:hover{background:#f2f6f4;}
.btn.sm{padding:5px 10px; font-size:12.5px; border-radius:7px;}
.btn.block{width:100%; padding:11px; font-size:15px;}
.btn:disabled{opacity:.55; cursor:not-allowed;}

/* ---------------- 登录 ---------------- */
.mask{
  position:fixed; inset:0; z-index:9000; display:flex; align-items:center; justify-content:center;
  background:linear-gradient(160deg,#12321f 0%,#1d4a33 45%,#256b45 100%);
}
.login-card{
  width:376px; background:#fff; border-radius:16px; padding:30px 30px 24px;
  box-shadow:0 24px 60px rgba(0,0,0,.28);
}
.login-logo{font-size:23px; font-weight:700; letter-spacing:1px; color:#163d29; text-align:center;}
.login-sub{text-align:center; color:var(--text-sub); font-size:12.5px; margin:6px 0 22px;}
.login-err{color:var(--danger); font-size:12.5px; min-height:18px; margin:2px 0 8px;}
.login-tip{margin-top:16px; font-size:11.5px; color:#8a9a92; line-height:1.7; text-align:center;}

.fld{display:flex; flex-direction:column; gap:5px; margin-bottom:12px; flex:1; min-width:0;}
.fld>span{font-size:12.5px; color:var(--text-sub);}
.fld input[type=text],.fld input[type=password],.fld input[type=number],
.fld input:not([type]),.fld select,.side-search input{
  border:1px solid var(--border); border-radius:8px; padding:8px 10px;
  background:#fbfdfc; outline:none; transition:.15s; width:100%; color:var(--text);
}
.fld input:focus,.fld select:focus,.side-search input:focus{
  border-color:var(--primary); background:#fff; box-shadow:0 0 0 3px rgba(26,127,82,.10);
}
.fld input[type=color]{width:100%; height:34px; padding:2px; border:1px solid var(--border); border-radius:8px; background:#fff;}
.fld input[type=range]{width:100%; accent-color:var(--primary);}
.fld.chk{flex-direction:row; align-items:center; gap:8px; margin-top:8px;}
.fld.chk span{font-size:13px; color:var(--text);}
.fld.chk input{width:auto; accent-color:var(--primary);}
.fld-row{display:flex; gap:12px; align-items:flex-end;}

/* ---------------- 布局 ---------------- */
.app{height:100vh; display:flex; flex-direction:column;}
.topbar{
  height:54px; flex:0 0 54px; display:flex; align-items:center; gap:16px;
  padding:0 16px; background:#163d29; color:#eaf4ee;
}
.brand{display:flex; align-items:center; gap:9px; font-size:15.5px; font-weight:600; letter-spacing:.4px;}
.brand-mark{
  width:20px;height:20px;border-radius:6px;
  background:linear-gradient(135deg,#5fd39a,#22a066); box-shadow:inset 0 0 0 2px rgba(255,255,255,.35);
}
.brand-sub{font-size:11.5px; font-weight:400; color:#9dc4b0; margin-left:2px;}
.svc-pill{
  display:flex; align-items:center; gap:7px; padding:5px 12px; border-radius:20px;
  background:rgba(255,255,255,.10); font-size:12.5px; cursor:pointer; color:#d8ece1;
}
.svc-pill .dot{width:8px;height:8px;border-radius:50%; background:#f0b429;}
.svc-pill.ok .dot{background:#4ade80; box-shadow:0 0 0 3px rgba(74,222,128,.2);}
.svc-pill.bad .dot{background:#f87171; box-shadow:0 0 0 3px rgba(248,113,113,.2);}
.top-right{margin-left:auto; display:flex; align-items:center; gap:8px;}
.who{font-size:13px; margin-right:4px; color:#dbece3;}
.who b{font-weight:600;}
.who em{
  font-style:normal; font-size:11px; margin-left:6px; padding:1px 7px; border-radius:10px;
  background:rgba(255,255,255,.14); color:#c7e3d5;
}
.topbar .btn.ghost{color:#dbece3; border-color:rgba(255,255,255,.22);}
.topbar .btn.ghost:hover{background:rgba(255,255,255,.12); border-color:rgba(255,255,255,.35);}

.alert-bar{
  flex:0 0 auto; display:flex; align-items:center; gap:10px; padding:9px 16px;
  background:#fdf0ef; border-bottom:1px solid #f5c9c5; color:#9c2c23; font-size:13px;
}
.alert-ico{
  width:18px;height:18px;border-radius:50%;background:var(--danger);color:#fff;
  display:flex;align-items:center;justify-content:center;font-size:12px;font-weight:700;flex:0 0 18px;
}
.alert-text{font-weight:600;}
.alert-detail{color:#b0554c; font-size:12px; flex:1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
.alert-bar .btn{margin-left:auto;}

.layout{flex:1; display:flex; min-height:0;}
.sidebar{
  width:286px; flex:0 0 286px; background:var(--panel); border-right:1px solid var(--border);
  display:flex; flex-direction:column; min-height:0;
}
.side-head{
  display:flex; align-items:center; justify-content:space-between;
  padding:12px 14px 8px; font-weight:600; font-size:13.5px; color:#20493a;
}
.side-count{
  background:var(--primary-light); color:var(--primary); font-size:11.5px;
  padding:1px 8px; border-radius:10px; font-weight:600;
}
.side-actions{display:flex; gap:8px; padding:0 12px 8px;}
.side-actions .btn{flex:1; padding:6px 4px; font-size:12.5px;}
.side-search{padding:0 12px 8px;}
.side-search input{padding:7px 10px; font-size:12.5px;}

.layer-list{flex:1; overflow-y:auto; padding:2px 8px 10px;}
.layer-item{
  display:flex; align-items:center; gap:8px; padding:8px 8px; border-radius:8px;
  cursor:pointer; position:relative; margin-bottom:2px; border:1px solid transparent;
}
.layer-item:hover{background:#f4f9f6;}
.layer-item.selected{background:#eaf5ef; border-color:#bfe3d0;}
.layer-item .swatch{
  width:13px;height:13px;border-radius:4px;flex:0 0 13px;
  border:1px solid rgba(0,0,0,.15); box-shadow:inset 0 0 0 1px rgba(255,255,255,.5);
}
.layer-item .swatch.line{height:4px;border-radius:2px;}
.layer-item .swatch.dot{width:11px;height:11px;border-radius:50%;}
.layer-item input[type=checkbox]{accent-color:var(--primary); width:14px;height:14px; flex:0 0 14px;}
.layer-name{
  flex:1; min-width:0; font-size:13px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
.layer-item.off .layer-name{color:#9aa9a1; text-decoration:line-through;}
.layer-meta{font-size:11px; color:#96a79e; flex:0 0 auto;}
.layer-btns{display:none; gap:2px; flex:0 0 auto;}
.layer-item:hover .layer-btns{display:flex;}
.layer-btns button{
  border:0; background:transparent; cursor:pointer; font-size:13px; color:#6b7a72;
  padding:2px 4px; border-radius:5px; line-height:1;
}
.layer-btns button:hover{background:#e3efe8; color:var(--primary);}
.layer-btns button.del:hover{background:#fbe9e7; color:var(--danger);}
.layer-empty{padding:26px 14px; text-align:center; color:#9aa9a1; font-size:12.5px; line-height:1.9;}

.side-foot{
  border-top:1px solid var(--border); padding:9px 14px 11px; font-size:11.5px; color:var(--text-sub);
  background:#fafcfb;
}
.foot-row{display:flex; justify-content:space-between; padding:2px 0;}
.foot-row b{color:#2f4a3d; font-weight:600;}

.map-wrap{flex:1; position:relative; min-width:0;}
#map{position:absolute; inset:0; background:#dfe7e2;}

/* ---------------- 工具栏 ---------------- */
.toolbar{
  position:absolute; left:14px; top:14px; z-index:600; display:flex; gap:6px; align-items:center;
  background:rgba(255,255,255,.96); padding:6px; border-radius:10px; box-shadow:var(--shadow);
  flex-wrap:wrap; max-width:calc(100% - 28px);
}
.tool{
  border:1px solid transparent; background:transparent; padding:6px 10px; border-radius:7px;
  cursor:pointer; font-size:12.5px; color:#2c4a3c; white-space:nowrap;
}
.tool:hover{background:#eef6f1;}
.tool.active{background:var(--primary); color:#fff;}
.tool-sep{width:1px; height:20px; background:var(--border); margin:0 2px;}

.measure-panel{
  position:absolute; right:14px; top:14px; z-index:600; width:212px;
  background:#fff; border-radius:10px; box-shadow:var(--shadow); padding:11px 13px;
}
.mp-title{font-size:12.5px; color:var(--text-sub);}
.mp-val{font-size:19px; font-weight:700; color:var(--primary); margin:2px 0 3px; letter-spacing:.3px;}
.mp-tip{font-size:11.5px; color:#92a39a; line-height:1.5;}
.mp-btns{display:flex; gap:6px; margin-top:9px;}
.mp-btns .btn{flex:1; padding:4px 2px; font-size:11.5px;}

.draw-hint{
  position:absolute; left:50%; transform:translateX(-50%); bottom:44px; z-index:600;
  background:rgba(22,61,41,.92); color:#e8f5ee; padding:6px 16px; border-radius:20px;
  font-size:12.5px; box-shadow:var(--shadow);
}

.statusbar{
  position:absolute; left:0; right:0; bottom:0; height:26px; z-index:600;
  display:flex; align-items:center; gap:8px; padding:0 12px;
  background:rgba(255,255,255,.94); border-top:1px solid var(--border);
  font-size:11.5px; color:#5d7369; backdrop-filter:blur(4px);
}
.sb-sep{color:#cbd8d1;}
.sb-right{margin-left:auto;}

/* ---------------- 地图要素 ---------------- */
.leaflet-container{font-family:inherit; background:#dfe7e2;}
.leaflet-popup-content-wrapper{border-radius:10px; box-shadow:0 8px 26px rgba(20,45,33,.18); padding:0;}
.leaflet-popup-content{margin:0; width:auto !important; min-width:250px; max-width:340px;}
.pop-head{
  padding:10px 13px 8px; border-bottom:1px solid #eef2ef; font-weight:600; font-size:13.5px;
  color:#1d4a35; display:flex; align-items:center; gap:7px;
}
.pop-head .swatch{width:10px;height:10px;border-radius:3px;}
.pop-body{padding:8px 13px 11px; font-size:12.5px;}
.pop-table{width:100%; border-collapse:collapse;}
.pop-table td{padding:3px 0; vertical-align:top; line-height:1.6;}
.pop-table td.k{color:#7b8b83; white-space:nowrap; padding-right:12px; max-width:130px;}
.pop-table td.v{color:#22332b; word-break:break-all;}
.pop-geo{margin-top:7px; padding-top:6px; border-top:1px dashed #e6ece8; color:#7b8b83; font-size:11.5px;}
.pop-acts{display:flex; gap:6px; padding:0 13px 11px;}
.pop-acts .btn{flex:1; padding:4px 2px; font-size:11.5px;}
.pop-acts .btn.danger{color:var(--danger); border-color:#f0cdc9;}
.pop-acts .btn.danger:hover{background:#fdf1ef;}
.pop-empty{color:#93a49b; padding:3px 0;}

.mk-measure-label{
  background:rgba(22,61,41,.88); color:#fff; border:0; border-radius:6px;
  padding:2px 7px; font-size:11.5px; box-shadow:none;
}
.mk-measure-label::before{display:none;}
.mk-vertex{
  width:10px;height:10px;border-radius:50%;background:#fff;border:2px solid var(--primary);
  box-shadow:0 0 0 1px rgba(255,255,255,.6);
}

/* ---------------- 弹窗 ---------------- */
.modal-mask{background:rgba(12,30,20,.45); z-index:9500;}
.modal{
  width:520px; max-width:calc(100vw - 40px); max-height:calc(100vh - 60px);
  background:#fff; border-radius:14px; box-shadow:0 24px 60px rgba(0,0,0,.25);
  display:flex; flex-direction:column; overflow:hidden;
}
.modal.wide{width:660px;}
.modal.narrow{width:400px;}
.modal-head{
  display:flex; align-items:center; justify-content:space-between; padding:14px 18px;
  border-bottom:1px solid var(--border); font-weight:600; color:#1d4a35; font-size:14.5px;
}
.modal-head .x{
  border:0; background:transparent; font-size:22px; line-height:1; cursor:pointer; color:#8fa198;
  padding:0 2px;
}
.modal-head .x:hover{color:var(--danger);}
.modal-body{padding:16px 18px; overflow-y:auto;}
.modal-foot{
  display:flex; justify-content:flex-end; gap:10px; padding:12px 18px;
  border-top:1px solid var(--border); background:#fafcfb;
}
.set-group{
  font-size:12px; font-weight:700; color:#3d6b55; letter-spacing:.5px;
  margin:14px 0 10px; padding-bottom:5px; border-bottom:1px solid #edf2ef;
}
.set-group:first-child{margin-top:0;}
.set-tip{font-size:11.5px; color:#8fa198; line-height:1.7; margin:-4px 0 6px;}
.test-row{display:flex; align-items:center; gap:12px; margin-bottom:6px;}
.test-result{font-size:12.5px; color:var(--text-sub); flex:1; line-height:1.5;}
.test-result.ok{color:var(--primary);}
.test-result.bad{color:var(--danger);}

.drop{
  border:1.5px dashed #c3d6cb; border-radius:10px; padding:22px 14px; text-align:center;
  background:#fafdfb; cursor:pointer; transition:.15s; line-height:1.9;
}
.drop:hover,.drop.over{border-color:var(--primary); background:#f1f9f4;}
.drop-ico{font-size:22px; color:var(--primary);}
.file-chosen{margin:9px 0; font-size:12.5px; color:#3d6b55;}
.file-chosen div{background:#f2f8f4; border-radius:6px; padding:4px 9px; margin-bottom:4px;}
.import-note{
  margin-top:12px; font-size:11.5px; color:#8fa198; background:#f7faf8;
  border-left:3px solid #cfe4d8; padding:8px 10px; border-radius:0 6px 6px 0; line-height:1.7;
}
.fm-fields .fld-row{margin-bottom:0;}
.fm-fields .fld{margin-bottom:8px;}

/* ---------------- Toast ---------------- */
.toast-wrap{position:fixed; top:66px; left:50%; transform:translateX(-50%); z-index:9900; display:flex; flex-direction:column; gap:8px; align-items:center;}
.toast{
  padding:9px 18px; border-radius:8px; background:#163d29; color:#eaf4ee; font-size:13px;
  box-shadow:0 8px 24px rgba(0,0,0,.2); animation:toastIn .18s ease-out;
  max-width:80vw; text-align:center;
}
.toast.ok{background:#1a7f52;}
.toast.err{background:#b8382f;}
@keyframes toastIn{from{opacity:0; transform:translateY(-6px);} to{opacity:1; transform:none;}}

/* ---------------- 只读角色 ---------------- */
body.role-staff .admin-only{display:none !important;}
body.role-staff .layer-btns{display:none !important;}

::-webkit-scrollbar{width:9px; height:9px;}
::-webkit-scrollbar-thumb{background:#cfdbd5; border-radius:5px;}
::-webkit-scrollbar-thumb:hover{background:#b6c7bf;}
::-webkit-scrollbar-track{background:transparent;}

@media (max-width:960px){
  .sidebar{width:240px; flex:0 0 240px;}
  .brand-sub{display:none;}
}

/* ---------------- 手机 / 竖屏：侧栏抽屉化，工具栏可横向滑动 ---------------- */
.side-toggle{display:none;}
.side-mask{display:none;}

@media (max-width:760px){
  .topbar{height:48px; flex:0 0 48px; gap:8px; padding:0 10px; overflow:hidden; position:relative;}
  .top-right{position:absolute; right:8px; top:50%; transform:translateY(-50%); display:flex; align-items:center; gap:6px;}
  .top-right .who{display:none;}
  .brand{font-size:12.5px; min-width:0; flex:1 1 auto; max-width:calc(100% - 168px); overflow:hidden; white-space:nowrap; gap:5px;}
  .brand > span:not(.brand-mark){overflow:hidden; text-overflow:ellipsis;}
  .brand-sub{display:none;}
  .svc-pill{padding:0; width:12px; height:12px; overflow:hidden; border:0; background:transparent; flex:0 0 12px;}
  #svc-text{display:none;}
  #btn-logout{display:none !important;}
  .topbar .btn.sm{padding:5px 8px; font-size:11.5px;}
  #btn-pwd{display:none !important;}
  #btn-settings{font-size:0; padding:5px 9px;}
  #btn-settings::before{content:'⚙'; font-size:15px;}
  .side-toggle{display:inline-flex; align-items:center; gap:4px;}

  .sidebar{
    position:fixed; top:48px; bottom:0; left:0; width:min(86vw,320px);
    flex:none; z-index:900; transform:translateX(-102%);
    transition:transform .22s ease; box-shadow:6px 0 24px rgba(0,0,0,.18);
  }
  body.side-open .sidebar{transform:none;}
  .side-mask{
    display:block; position:fixed; left:0; right:0; top:48px; bottom:0;
    background:rgba(10,26,18,.35); z-index:880; opacity:0; pointer-events:none;
    transition:opacity .2s;
  }
  body.side-open .side-mask{opacity:1; pointer-events:auto;}

  .toolbar{
    left:8px; right:8px; top:8px; max-width:none; padding:4px; gap:2px;
    flex-wrap:nowrap; overflow-x:auto; border-radius:9px;
    -webkit-overflow-scrolling:touch; scrollbar-width:none;
  }
  .toolbar::-webkit-scrollbar{display:none;}
  .tool{font-size:12px; padding:5px 8px;}
  .tool-sep{display:none;}
  .measure-panel{left:8px; right:8px; width:auto; top:62px;}

  .statusbar{height:24px; font-size:10.5px; padding:0 8px; gap:6px;}
  .sb-right{display:none;}
  .leaflet-bottom.leaflet-right{margin-bottom:20px;}
  .modal.wide{width:calc(100vw - 24px);}

  /* 嵌在主系统 iframe 里时，顶栏只留「图层 / 状态 / 设置」，避免与外层页头重复 */
  body.embedded .topbar{height:42px; flex-basis:42px;}
  body.embedded .brand{max-width:none; flex:0 0 auto;}
  body.embedded #app-title{display:none;}
  body.embedded .brand-mark{display:none;}
  body.embedded .side-mask{top:42px;}
  body.embedded .sidebar{top:42px;}
}


/* 扫描提示状态色 */
.set-tip.ok { color:#2f8f57; }
.set-tip.bad { color:#c0392b; }
.test-result.warn{color:#d68910;}
