:root{
  --bg:#0b0c10;
  --panel:#14161c;
  --border:#2a2d38;
  --teal:#4fd8d8;
  --teal-dim:rgba(79,216,216,.25);
  --text:#d9dbe3;
  --muted:#8a8d9a;
}

html,body{
  margin:0;
  padding:0;
  height:100%;
  background:var(--bg);
  font-family:'Segoe UI',system-ui,sans-serif;
  color:var(--text);
  scrollbar-width:thin;
  scrollbar-color:var(--teal-dim) transparent;
}

*::-webkit-scrollbar{
  width:6px;
  height:6px;
}
*::-webkit-scrollbar-track{
  background:transparent;
}
*::-webkit-scrollbar-thumb{
  background:var(--teal-dim);
  border-radius:3px;
}
*::-webkit-scrollbar-thumb:hover{
  background:var(--teal);
}

#app{
  display:flex;
  height:100vh;
}
  
#map{
  flex:1;
  background:#05060a;
}

#sidebar{
  width:300px;
  background:var(--panel);
  border-right:1px solid var(--border);
  padding:16px;
  box-sizing:border-box;
  overflow-y:auto;
}

#sidebar-logo{
  display:block;
  max-width:100%;
  height:auto;
  margin:0 0 24px 0;
  filter:drop-shadow(0 0 8px var(--teal-dim));
}
#sidebar-close{
  display:none;
}
.block{
  margin-bottom:16px;
  padding-bottom:14px;
  border-bottom:1px solid var(--border);
}
.block:last-child{
  border-bottom:none;
}
.block h4{
  font-size:11px;
  text-transform:uppercase;
  letter-spacing:.5px;
  color:var(--muted);
  margin:0 0 8px 0;
}
label{
  display:flex;
  align-items:center;
  gap:8px;
  font-size:13px;
  cursor:pointer;
  padding:5px 6px;
  border-radius:6px;
}
label:hover{
  background:rgba(255,255,255,.04);
}
.swatch{
  width:10px;
  height:10px;
  border-radius:50%;
  flex-shrink:0;
}

input[type=text], input[type=password], select, textarea{
  width:100%;
  background:#0b0c10;
  border:1px solid var(--border);
  color:var(--text);
  border-radius:6px;
  padding:7px 8px;
  font-size:12.5px;
  box-sizing:border-box;
  margin-bottom:6px;
  font-family:inherit;
}
textarea{
  resize:vertical;
  min-height:50px;
}
input[type=color]{
  width:100%;
  height:30px;
  border:1px solid var(--border);
  border-radius:6px;
  background:#0b0c10;
  margin-bottom:6px;
}

button{
  width:100%;
  background:var(--teal);
  color:#0b0c10;
  border:none;
  border-radius:6px;
  padding:9px;
  font-size:12.5px;
  font-weight:600;
  cursor:pointer;
  margin-top:4px;
}
button:hover{
  filter:brightness(1.1);
}
button.secondary{
  background:transparent;
  color:var(--teal);
  border:1px solid var(--teal);
}
button.danger{
  background:#e04f4f;
  color:#fff;
}
button.active{
  background:#e04f4f;
  color:#fff;
}
button.small{
  width:auto;
  padding:4px 8px;
  font-size:12px;
  margin:0;
}
button.link{
  background:transparent;
  color:var(--teal);
  text-decoration:underline;
  font-weight:400;
  padding:4px 0;
}

#status{
  margin-top:8px;
  font-size:11px;
  line-height:1.5em;
  color:var(--teal);
  min-height:16px;
  font-family:monospace;
}

#btn-save{
  background:#3a7a4a;
  color:#fff;
  font-size:13.5px;
  padding:11px;
}
@keyframes pulse{
  0%{
    box-shadow:0 0 0 0 rgba(201,139,43,.5);
  }
  70%{
    box-shadow:0 0 0 8px rgba(201,139,43,0);
  }
  100%{
    box-shadow:0 0 0 0 rgba(201,139,43,0);
  }
}
#dirty-note{
  font-size:11px;
  color:#c98b2b;
  margin-top:6px;
  display:none;
}
body.is-dirty #dirty-note{
  display:block;
}

.list-row{
  display:flex;
  align-items:center;
  gap:6px;
  padding:4px 6px;
  font-size:13px;
  border-radius:6px;
}
.view-tabs{
  display:flex;
  gap:6px;
}
.region-tab{
  flex:1;
  background:transparent;
  border:1px solid var(--border);
  color:var(--muted);
  margin:0;
}
.region-tab.active{
  background:#4fd8d850;
  color:#4fd8d8;
  border-color:transparent;
  font-weight:600;
}
.list-row:hover{
  background:rgba(255,255,255,.04);
}
.list-row label{
  flex:1;
  padding:0;
}
.list-row .row-actions{
  display:flex;
  gap:4px;
  flex-shrink:0;
}
.list-row .row-actions.edit-only{
  display:none;
}
body.edit-mode .list-row .row-actions.edit-only{
  display:flex;
}
#empty-districts, #empty-cats{
  font-size:11.5px;
  color:var(--muted);
  font-style:italic;
  padding:4px 6px;
}

.leaflet-popup-content-wrapper{
  background:var(--panel);
  color:var(--text);
  border:1px solid var(--border);
}
.leaflet-popup-tip{
  background:var(--panel);
}
.leaflet-popup-content h3{
  margin:0 0 4px 0;
  color:var(--teal);
  font-size:14px;
}
.leaflet-popup-content p{
  margin:0 0 8px 0;
  font-size:12.5px;
  color:var(--muted);
}
.popup-actions{
  display:flex;
  gap:6px;
}
.icon-btn{
  width:auto;
  padding:5px 10px;
  font-size:13px;
  margin:0;
}
.icon-btn.del{
  background:#e04f4f;
  color:#fff;
}
.icon-btn.edit{
  background:transparent;
  border:1px solid var(--teal);
  color:var(--teal);
}

.leaflet-tooltip.map-tooltip{
  background:var(--panel);
  color:var(--text);
  border:1px solid var(--border);
  font-size:12px;
  padding:6px 9px;
  box-shadow:none;
}
.leaflet-tooltip.map-tooltip b{
  color:var(--teal);
}
.leaflet-tooltip-top.map-tooltip::before{
  border-top-color:var(--border);
}

.pin{
  width:26px;
  height:26px;
  border-radius:50% 50% 50% 0;
  transform:rotate(-45deg);
  border:2px solid #0b0c10;
  box-shadow:0 0 6px rgba(0,0,0,.6);
  cursor:pointer;
  display:flex;
  align-items:center;
  justify-content:center;
}
.pin:hover{
  animation: pinPulse 0.6s ease-in-out 1;
}
@keyframes pinPulse{
  0%, 100%{
    transform: rotate(-45deg) scale(1);
  }
  50%{
    transform: rotate(-45deg) scale(1.2);
  }
}
.pin-symbol{
  transform:rotate(45deg);
  font-size:12px;
  line-height:1;
  width:18px;
  height:18px;
  border-radius:50%;
  background:#101828;
  display:flex;
  align-items:center;
  justify-content:center;
}
.pin-label{
  color:#fff;
  font-size:11px;
  font-weight:600;
  text-shadow:0 0 3px #000,0 0 3px #000,0 0 3px #000;
  white-space:normal;
  text-wrap: balance;
  pointer-events:none;
  text-align:center;
}
.pin-label.label-zoom{
  display:none;
}
body.zoom-labels-on .pin-label.label-zoom{
  display:block;
}
.pin-label.label-hidden, .district-label.label-hidden{
  display:none !important;
}
.district-label{
  color:#fff;
  font-size:11px;
  font-weight:700;
  text-shadow:0 0 4px #000,0 0 6px #000;
  white-space:normal;
  text-wrap: balance;
  pointer-events:none;
  letter-spacing:.5px;
  text-transform:uppercase;
  text-align: center;
}

.edit-only{
  display:none;
}
body.edit-mode .edit-only{
  display:block;
}
body.edit-mode .view-lock-btn{
  display:none;
}
body.edit-mode .leaflet-draw-toolbar{
  display:block;
}

#selected-panel{
  font-size:12.5px;
}
#selected-panel h5{
  margin:0 0 4px 0;
  color:var(--teal);
  font-size:13px;
}
#selected-panel p{
  margin:0 0 8px 0;
  color:var(--muted);
}
#selected-panel .popup-actions{
  margin-top:4px;
}
#selected-empty{
  font-size:11.5px;
  color:var(--muted);
  font-style:italic;
}

#inline-newcat{
  display:none;
  border:1px dashed var(--border);
  border-radius:8px;
  padding:8px;
  margin-top:4px;
  margin-bottom:6px;
}
#inline-newcat.open{
  display:block;
}

#modal-overlay{
  display:none;
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.6);
  z-index:2000;
  align-items:center;
  justify-content:center;
}
#modal{
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:10px;
  padding:18px;
  width:300px;
  max-width:90vw;
}
#modal h3{
  margin:0 0 10px 0;
  color:var(--teal);
  font-size:14px;
}
#modal .row{
  margin-bottom:8px;
}
#modal .actions{
  display:flex;
  gap:8px;
  margin-top:8px;
}
#modal .actions button{
  margin-top:0;
}
#icon-picker{
  display:flex;
  flex-wrap:wrap;
  gap:5px;
  max-height:180px;
  overflow-y:auto;
  padding:4px;
  border:1px solid var(--border);
  border-radius:8px;
}
.icon-choice{
  width:32px;
  height:32px;
  padding:0;
  margin:0;
  font-size:15px;
  background:#0b0c10;
  border:1px solid var(--border);
  color:var(--text);
  border-radius:6px;
  flex:none;
}
.icon-choice.chosen{
  border-color:var(--teal);
  background:var(--teal-dim);
}

#sidebar-toggle{
  display:none;
  position:fixed;
  top:12px;
  left:12px;
  z-index:1500;
  width:42px;
  height:42px;
  border-radius:8px;
  background:var(--panel);
  border:1px solid var(--border);
  color:var(--teal);
  font-size:18px;
  align-items:center;
  justify-content:center;
  cursor:pointer;
}
#sidebar-backdrop{
  display:none;
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.5);
  z-index:999;
}

#shape-edit-bar{
  display:none;
  position:fixed;
  bottom:20px;
  left:50%;
  transform:translateX(-50%);
  z-index:1600;
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:10px;
  padding:10px 14px;
  align-items:center;
  gap:10px;
  box-shadow:0 4px 20px rgba(0,0,0,.5);
}
#shape-edit-bar.active{
  display:flex;
}
#shape-edit-bar span{
  font-size:12px;
  color:var(--muted);
}
#shape-edit-bar button{
  width:auto;
  margin:0;
  padding:8px 14px;
  white-space:nowrap;
}

@media (max-width: 768px){
  #sidebar-toggle{
    display:flex;
  }
  #app{
    position:relative;
  }
  #sidebar{
    position:fixed;
    top:0;
    left:0;
    bottom:0;
    z-index:1000;
    width:82vw;
    max-width:320px;
    transform:translateX(-100%);
    transition: transform .25s ease;
    padding:0;
    display:flex;
    flex-direction:column;
    height:100%;
    overflow:hidden;
  }
  body.sidebar-open #sidebar{
    transform:translateX(0);
  }
  body.sidebar-open #sidebar-backdrop{
    display:block;
  }
  body.sidebar-open #sidebar-toggle{
    display:none;
  }
  #sidebar-header{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:10px;
    flex-shrink:0;
    padding:16px;
    border-bottom:1px solid var(--border);
  }
  #sidebar-header #sidebar-logo{
    margin:0;
    min-width:0;
    flex:1;
  }
  #sidebar-close{
    display:flex;
    align-items:center;
    justify-content:center;
    flex-shrink:0;
    width:32px;
    height:32px;
    border-radius:8px;
    background:transparent;
    border:1px solid var(--border);
    color:var(--teal);
    font-size:16px;
    cursor:pointer;
  }
  #sidebar-content{
    flex:1;
    overflow-y:auto;
    padding:16px;
  }
  #map{
    width:100%;
  }
  .leaflet-top.leaflet-left{
    top:60px;
  }
  .leaflet-bottom.leaflet-left{
    z-index:500;
  }
  .leaflet-control-zoom{
    display:flex;
    flex-direction:row;
  }
  .leaflet-control-zoom a{
    border-bottom:none !important;
  }
  .leaflet-control-zoom-in{
    border-right:1px solid #ccc;
    border-top-right-radius:0 !important;
    border-bottom-right-radius:0 !important;
    border-bottom-left-radius:4px !important;
  }
  .leaflet-control-zoom-out{
    border-top-left-radius:0 !important;
    border-bottom-left-radius:0 !important;
    border-top-right-radius:4px !important;
  }
  #shape-edit-bar{
    max-width:calc(100vw - 24px);
    flex-wrap:wrap;
    justify-content:center;
    text-align:center;
  }
  #modal{
    width:88vw;
  }
  button, .icon-btn{
    font-size:14px;
    padding:11px;
  }
  .icon-btn{
    padding:8px 12px;
  }
  label{
    padding:8px 6px;
    font-size:14px;
  }
}
