.tool-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 1.25rem;
  align-items: start;
}

.tool-main {
  display: grid;
  gap: 1.25rem;
  min-width: 0;
}

.network-workflow {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .55rem;
  padding: .65rem .8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.network-workflow .workflow-step {
  position: relative;
  min-height: 58px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  min-width: 0;
  padding: .45rem .6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  background: var(--surface);
  font-size: .78rem;
  font-weight: 800;
}

.network-workflow .workflow-step:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -.2rem;
  width: .4rem;
  height: 1px;
  background: var(--border);
}

.network-workflow .workflow-step > span {
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  font-size: .76rem;
}

.network-workflow .workflow-step > div {
  min-width: 0;
  display: contents;
}

.network-workflow h3 {
  margin: 0;
  color: var(--navy-950);
  font-size: .92rem;
  line-height: 1.25;
}

.network-workflow p {
  flex-basis: 100%;
  margin: 0;
  padding-left: 2.15rem;
  color: var(--text-secondary);
  font-size: .76rem;
  font-weight: 550;
  line-height: 1.4;
}

.network-workflow .is-active {
  color: var(--blue-600);
}

.network-workflow .is-active > span {
  color: #fff;
  border-color: var(--blue-600);
  background: var(--blue-600);
}

.section-actions {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.section-actions h2,
.section-actions h3 {
  margin-top: 0;
}

.section-actions p {
  margin: .25rem 0 0;
  color: var(--text-secondary);
}

.section-actions.compact {
  align-items: center;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: .65rem;
  justify-content: flex-end;
}

.import-guidance {
  margin: 1rem 0;
  padding: 1.1rem 1.25rem;
  border-left: 4px solid var(--blue-600);
  border-radius: 8px;
  background: var(--surface);
}

.import-guidance h3 {
  margin: 0 0 .25rem;
  color: var(--navy-950);
}

.import-guidance p {
  margin: .55rem 0 0;
  color: var(--text-secondary);
}

.import-columns {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.import-columns div {
  display: grid;
  gap: .25rem;
  min-width: 0;
  padding-right: 1rem;
  border-right: 1px solid var(--border);
}

.import-columns div:last-child {
  border-right: 0;
}

.import-columns strong,
.example-row strong {
  color: var(--navy-950);
}

.import-columns span {
  color: var(--text-secondary);
}

.example-row {
  padding: .7rem .85rem;
  border-radius: 8px;
  background: var(--blue-100);
  overflow-wrap: anywhere;
}

.privacy-note {
  margin: 1rem 0;
  padding: .75rem .9rem;
  border: 1px solid #a7f3d0;
  border-radius: 8px;
  background: #ecfdf3;
  color: #047857;
  font-weight: 650;
}

.map-privacy-note {
  margin: .75rem 0 1rem;
  padding: .75rem .9rem;
  border: 1px solid rgba(31, 111, 235, .22);
  border-radius: 8px;
  background: #eff6ff;
  color: var(--text-secondary);
  font-weight: 650;
}

.form-grid {
  display: grid;
  grid-template-columns: minmax(180px, 260px) minmax(260px, 1fr) auto;
  gap: 1rem;
  align-items: end;
}

.form-grid label {
  display: grid;
  gap: .4rem;
  color: var(--navy-950);
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .72rem .85rem;
  color: var(--text-primary);
  background: #fff;
  font: inherit;
}

.form-action {
  display: flex;
}

.status-text {
  min-height: 1.5rem;
  margin: .75rem 0 0;
  color: var(--text-secondary);
  font-weight: 700;
}

.editable-section {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.table-scroll {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.data-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: .8rem;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.data-table th {
  color: var(--text-secondary);
  background: var(--surface);
  font-size: var(--tool-label-size);
  font-weight: 850;
  text-transform: uppercase;
}

.data-table td:last-child,
.data-table th:last-child {
  border-right: 0;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.data-table input {
  min-width: 120px;
}

.remove-row {
  background: #fff !important;
  color: #b42318 !important;
  border-color: #fecdca !important;
  box-shadow: none !important;
}

.error-message {
  padding: .9rem 1rem;
  border: 1px solid #fecdca;
  border-radius: 8px;
  background: #fff1f2;
  color: #b42318;
  font-weight: 800;
}

.kpi-grid,
.comparison-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .9rem;
  margin: 1rem 0;
}

.kpi-card,
.comparison-card {
  min-width: 0;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.kpi-card span,
.comparison-card span {
  display: block;
  color: var(--text-secondary);
  font-size: var(--tool-label-size);
  font-weight: 850;
  text-transform: uppercase;
}

.kpi-card strong,
.comparison-card strong {
  display: block;
  margin-top: .3rem;
  color: var(--navy-950);
  font-size: 1.35rem;
  font-weight: 850;
}

.interpretation-panel,
.map-detail {
  margin: 1rem 0;
  padding: 1rem;
  border: 1px solid rgba(31, 111, 235, .22);
  border-left: 4px solid var(--blue-600);
  border-radius: 8px;
  background: #eff6ff;
  color: var(--text-secondary);
}

.interpretation-panel strong,
.map-detail strong {
  color: var(--navy-950);
}

.network-map-shell {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.network-map {
  width: 100%;
  min-height: 420px;
}

.map-controls-card {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 520;
  width: min(255px, calc(100% - 5.75rem));
  padding: .9rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 16px 36px rgba(6, 23, 43, .18);
}

.map-controls-card h3 {
  margin: 0 0 .7rem;
  color: var(--navy-950);
  font-size: .95rem;
  font-weight: 850;
}

.map-check {
  display: flex;
  align-items: center;
  min-height: 34px;
  gap: .55rem;
  color: var(--text-primary);
  font-size: .88rem;
  font-weight: 750;
}

.map-check input {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  accent-color: var(--blue-600);
}

.map-select-label {
  display: block;
  margin: .75rem 0 .35rem;
  color: var(--text-primary);
  font-size: .82rem;
  font-weight: 850;
}

.map-controls-card select {
  width: 100%;
  min-height: 40px;
  padding: .55rem .7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text-primary);
  font: inherit;
  font-size: .9rem;
}

.network-map-marker {
  background: transparent;
}

.network-map-marker span {
  display: block;
  width: 22px;
  height: 22px;
  border: 3px solid #fff;
  box-shadow: 0 10px 24px rgba(6, 23, 43, .24);
}

.facility-map-marker span {
  background: var(--navy-950);
  border-radius: 7px;
  outline: 2px solid rgba(6, 23, 43, .36);
}

.customer-map-marker span {
  background: var(--blue-600);
  border-radius: 999px;
  outline: 2px solid rgba(31, 111, 235, .36);
}

.network-map-marker:focus-visible span,
.leaflet-marker-icon:focus-visible span {
  outline: 3px solid var(--blue-500);
  outline-offset: 3px;
}

.network-point-label {
  padding: .18rem .45rem;
  border: 1px solid rgba(16, 42, 71, .16);
  border-radius: 999px;
  background: rgba(255, 255, 255, .95);
  box-shadow: 0 6px 16px rgba(6, 23, 43, .14);
  color: var(--navy-950);
  font-size: .76rem;
  font-weight: 850;
}

.route-map-label {
  border: 0;
  background: transparent;
}

.route-map-label span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  max-width: 128px;
  padding: .2rem .45rem;
  border-radius: 999px;
  background: rgba(31, 111, 235, .92);
  box-shadow: 0 8px 20px rgba(31, 111, 235, .24);
  color: #fff;
  font-size: .72rem;
  font-weight: 850;
  line-height: 1.15;
  text-align: center;
  white-space: normal;
}

.map-fallback {
  width: 100%;
  min-height: 420px;
  padding: 1rem;
}

.map-fallback svg {
  display: block;
  width: 100%;
  height: auto;
  min-height: 340px;
}

.route-line {
  stroke: var(--blue-600);
  stroke-linecap: round;
  opacity: .72;
}

.facility-node {
  fill: var(--navy-950);
}

.customer-node {
  fill: var(--blue-600);
}

.map-label {
  fill: var(--text-primary);
  font-size: 12px;
  font-weight: 750;
}

.guidance-card {
  min-width: 0;
}

@media (max-width: 980px) {
  .tool-layout {
    grid-template-columns: 1fr;
  }

  .network-side-nav {
    order: -1;
  }

  .network-workflow,
  .import-columns,
  .kpi-grid,
  .comparison-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 720px) {
  .section-actions,
  .form-grid {
    grid-template-columns: 1fr;
    display: grid;
  }

  .button-row,
  .form-action {
    justify-content: stretch;
  }

  .button-row button,
  .form-action button,
  .section-actions > button {
    width: 100%;
  }

  .network-workflow,
  .import-columns,
  .kpi-grid,
  .comparison-grid {
    grid-template-columns: 1fr;
  }

  .network-workflow .workflow-step::after {
    display: none;
  }

  .map-controls-card {
    position: static;
    width: auto;
    margin: .75rem;
  }

  .network-map {
    min-height: 360px;
  }

  .import-columns div {
    padding-right: 0;
    padding-bottom: .75rem;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .import-columns div:last-child {
    border-bottom: 0;
  }

  .network-map,
  .map-fallback {
    min-height: 320px;
  }
}
