* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, sans-serif;
  color: #1e293b;
  background: #f8fafc;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr 260px auto;
  gap: 16px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid #cbd5e1;
  background: #ffffff;
}

.topbar h1 {
  margin: 0;
  font-size: 1.2rem;
}

.progress-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.progress-bar {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

#progressFill {
  width: 0;
  height: 100%;
  background: #22c55e;
  transition: width 0.2s ease;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

button {
  border: 1px solid #94a3b8;
  border-radius: 8px;
  padding: 8px 10px;
  background: #ffffff;
  cursor: pointer;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  height: calc(100vh - 71px);
}

#map {
  width: 100%;
  height: 100%;
}

#map.cursor-add,
#map.cursor-add .leaflet-interactive {
  cursor: copy !important;
}

#map.cursor-move,
#map.cursor-move .leaflet-interactive {
  cursor: move !important;
}

#map.cursor-rotate,
#map.cursor-rotate .leaflet-interactive {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 28 28'%3E%3Cpath d='M7 10a8 8 0 1 1 3.2 11.2' fill='none' stroke='%230f172a' stroke-width='2'/%3E%3Cpath d='M8 5v6h6' fill='none' stroke='%230f172a' stroke-width='2'/%3E%3C/svg%3E") 14 14, crosshair !important;
}

.leaflet-control-layers.basemap-control {
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.12);
  background: rgba(255, 255, 255, 0.95);
  font-size: 12px;
}

.leaflet-control-layers.basemap-control .leaflet-control-layers-list {
  margin: 8px 10px;
}

.leaflet-control-layers.basemap-control .leaflet-control-layers-list label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 6px 0;
  font-weight: 500;
  font-size: 13px;
  line-height: 1.2;
}

.leaflet-control-layers.basemap-control .leaflet-control-layers-list input {
  margin: 0;
  width: auto;
  flex: 0 0 auto;
}

.map-utility-control {
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.12);
  background: rgba(255, 255, 255, 0.95);
  padding: 4px;
}

.map-utility-control button {
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
  padding: 6px 10px;
  font-size: 12px;
  white-space: nowrap;
}

.map-utility-control button:disabled {
  opacity: 0.5;
}

.panel {
  border-left: 1px solid #cbd5e1;
  padding: 14px;
  overflow-y: auto;
  background: #ffffff;
}

.panel h2 {
  margin-top: 0;
}

.guidance-toggle {
  width: 100%;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  font-weight: 600;
}

.guidance-panel {
  margin-top: 10px;
}

.info {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
}

.panel label,
dialog label {
  display: block;
  margin-top: 10px;
  margin-bottom: 5px;
  font-weight: 600;
}

select,
input,
textarea {
  width: 100%;
  border: 1px solid #94a3b8;
  border-radius: 6px;
  padding: 8px;
  font-family: inherit;
  resize: vertical;
}

#downloadDataBtn {
  margin-top: 10px;
  width: 100%;
}

.hidden {
  display: none;
}

#loadListItems {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#substationListItems {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#substationListItems li {
  padding: 6px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
  font-size: 0.9rem;
}

.substation-list-item {
  width: 100%;
  text-align: left;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
  padding: 6px 8px;
}

.substation-list-item.selected {
  border-color: #2563eb;
  background: #dbeafe;
}

.circle-number-label {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid #334155;
  background: #ffffff;
  color: #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

#loadListItems button {
  width: 100%;
  text-align: left;
}

dialog {
  border: 1px solid #94a3b8;
  border-radius: 12px;
  max-width: 640px;
  width: calc(100% - 24px);
}

.dialog-actions {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

@media (max-width: 1024px) {
  .topbar {
    grid-template-columns: 1fr;
  }

  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: 60vh auto;
    height: auto;
  }

  .panel {
    border-left: none;
    border-top: 1px solid #cbd5e1;
  }
}
