.route-workspace-clean-ui .app-shell {
  width: 100%;
  min-width: 0;
  grid-template-columns: minmax(0, 1fr);
}

.route-workspace-clean-ui .app-view {
  min-width: 0;
}

.route-workspace-clean-ui #mapView .workspace {
  min-height: 0;
  overflow: hidden;
}

.route-workspace-clean-ui #mapView .map-stage {
  min-height: 0;
  grid-template-rows: auto auto minmax(0, 1fr);
}

.route-workspace-clean-ui #mapView .map-toolbar {
  grid-row: 1;
}

.route-workspace-clean-ui #mapView #map,
.route-workspace-clean-ui #mapView #mapFallback {
  grid-row: 3;
  grid-column: 1;
  min-height: 0;
}

.route-command-bar {
  position: relative;
  z-index: 490;
  grid-row: 2;
  display: grid;
  grid-template-columns: minmax(210px, auto) minmax(0, 1fr) auto;
  grid-template-areas:
    "context actions toggle"
    "context explanation explanation";
  align-items: center;
  gap: 5px 14px;
  min-width: 0;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}

.route-command-context {
  grid-area: context;
  display: grid;
  min-width: 0;
  gap: 1px;
}

.route-command-context > span,
.route-command-context > small {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.route-command-context > span {
  font-weight: 800;
  text-transform: uppercase;
}

.route-command-context > strong {
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#routeCommandSaveStatus:empty {
  display: none;
}

#routeCommandSaveStatus .route-save-status {
  display: block;
  margin-top: 2px;
}

.route-command-actions {
  grid-area: actions;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-width: 0;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.route-command-actions button {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 6px 10px;
  white-space: nowrap;
}

.route-command-actions #navigateNextButton:not(:disabled),
.route-command-actions #saveSharedRouteButton:not(:disabled) {
  border-color: #111827;
  background: #111827;
  color: #fff;
}

.route-command-actions button:disabled {
  border-color: var(--line);
  background: #eef1f5;
  color: #8a94a3;
}

.route-order-toggle {
  grid-area: toggle;
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  color: #344054;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.route-order-toggle input {
  width: auto;
}

.route-order-explanation {
  grid-area: explanation;
  justify-self: end;
  color: var(--muted);
  font-size: 11px;
}

.route-order-icon-host {
  border: 0;
  background: transparent;
}

.route-order-number {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #111827;
  color: #fff;
  box-shadow: 0 2px 7px rgba(17, 24, 39, 0.35);
  font-size: 12px;
  font-weight: 850;
}

.route-order-number.is-current {
  background: #d9a441;
  color: #111827;
  box-shadow: 0 0 0 3px rgba(217, 164, 65, 0.3), 0 2px 7px rgba(17, 24, 39, 0.35);
}

.route-order-number.is-complete {
  background: #7d8794;
}

.route-workspace-clean-ui #mapView .right-panel {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
}

.map-inspector-tabs {
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: 1fr 1fr;
  padding: 8px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}

.map-inspector-tabs button {
  min-height: 36px;
  border-radius: 0;
  background: transparent;
}

.map-inspector-tabs button:first-child {
  border-radius: 6px 0 0 6px;
}

.map-inspector-tabs button:last-child {
  margin-left: -1px;
  border-radius: 0 6px 6px 0;
}

.map-inspector-tabs button.is-active {
  position: relative;
  z-index: 1;
  border-color: #111827;
  background: #111827;
  color: #fff;
}

.route-workspace-clean-ui #mapView .inspector-panel {
  min-width: 0;
  min-height: 0;
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.route-workspace-clean-ui #mapView .inspector-panel[hidden] {
  display: none;
}

.route-workspace-clean-ui #mapView .route-inspector-panel {
  padding-bottom: 20px;
}

.route-workspace-clean-ui #mapView .route-scope-bar {
  display: none;
}

.route-workspace-clean-ui #mapView .route-inspector-panel > .section-heading {
  align-items: flex-start;
  flex-direction: column;
}

.route-workspace-clean-ui #mapView .route-inspector-panel > .section-heading .heading-actions,
.route-workspace-clean-ui #mapView .route-inspector-panel > .route-actions {
  display: grid;
  width: 100%;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.route-workspace-clean-ui #mapView .route-inspector-panel > .section-heading .heading-actions button,
.route-workspace-clean-ui #mapView .route-inspector-panel > .route-actions button {
  min-width: 0;
  white-space: normal;
}

.selected-summary-heading {
  display: grid;
  gap: 7px;
}

.selected-summary-heading .selected-name {
  overflow-wrap: anywhere;
  font-size: 18px;
  line-height: 1.2;
}

.selected-summary-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.selected-performance-reason {
  margin: 0;
  color: #475467;
  font-size: 13px;
}

.selected-sales-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.selected-sales-grid > div {
  display: grid;
  gap: 2px;
  padding: 8px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.selected-sales-grid > div:nth-child(2n) {
  border-right: 0;
}

.selected-sales-grid > div:nth-last-child(-n + 2) {
  border-bottom: 0;
}

.selected-sales-grid span,
.selected-contact-line span,
.selected-last-visit span {
  color: var(--muted);
  font-size: 12px;
}

.selected-contact-line,
.selected-last-visit {
  display: grid;
  gap: 2px;
}

.selected-contact-line span,
.selected-last-visit span {
  overflow-wrap: anywhere;
}

.selected-placement {
  padding: 7px 8px;
  border-left: 3px solid #80b7a7;
  background: #edf8f4;
  color: #176b55;
  font-size: 12px;
  font-weight: 700;
}

.selected-placement.needs-review {
  border-left-color: #d9a441;
  background: #fff8df;
  color: #765700;
}

.selected-alert {
  display: grid;
  gap: 2px;
  padding: 8px;
  border-left: 3px solid var(--action);
  background: #fff3fb;
}

.selected-alert span {
  color: #7a2e6c;
  font-size: 12px;
}

.selected-card-actions .primary-action {
  border-color: #111827;
  background: #111827;
  color: #fff;
}

.visit-entry-modal {
  z-index: 2200;
}

.visit-entry-dialog {
  width: min(720px, 100%);
  max-height: min(90vh, 850px);
}

.visit-entry-header > div {
  display: grid;
  gap: 2px;
}

.visit-entry-header span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.visit-entry-body {
  min-height: 0;
  overflow-y: auto;
}

.visit-entry-modal .visit-panel {
  display: grid;
  gap: 2px;
  padding: 16px;
  border: 0;
  background: #fff;
}

.visit-entry-modal .visit-panel > .section-heading {
  margin-bottom: 4px;
}

.visit-entry-modal .visit-panel > .section-heading h2 {
  display: none;
}

.visit-entry-modal .outcome-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.visit-entry-advanced {
  margin: 2px 0 10px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.visit-entry-advanced summary {
  cursor: pointer;
  color: #475467;
  font-size: 12px;
  font-weight: 700;
}

.visit-entry-advanced .field {
  margin-top: 10px;
}

.visit-entry-secondary {
  padding: 0 16px 16px;
}

.visit-entry-secondary button {
  width: 100%;
  color: #475467;
}

@media (min-width: 1181px) {
  .route-workspace-clean-ui #mapView .workspace {
    height: calc(100vh - 194px);
    min-height: 620px;
    grid-template-columns: 280px minmax(560px, 1fr) 380px;
  }

  .route-workspace-clean-ui #mapView .left-panel,
  .route-workspace-clean-ui #mapView .right-panel {
    height: 100%;
  }
}

@media (max-width: 1650px) {
  .route-command-bar {
    grid-template-columns: minmax(190px, 0.7fr) minmax(0, 1.3fr);
    grid-template-areas:
      "context toggle"
      "actions actions"
      "explanation explanation";
  }

  .route-command-actions {
    justify-content: flex-start;
  }

  .route-order-toggle {
    justify-self: end;
  }
}

@media (max-width: 1180px) {
  .route-workspace-clean-ui #mapView .workspace {
    height: auto;
    overflow: visible;
  }

  .route-workspace-clean-ui #mapView .right-panel {
    min-height: 380px;
    max-height: 520px;
    grid-column: 1 / -1;
  }
}

@media (max-width: 820px) {
  .route-workspace-clean-ui .tab-strip {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: thin;
  }

  .route-workspace-clean-ui .tab-strip .tab-button {
    flex: 0 0 auto;
  }

  .route-workspace-clean-ui #mapView .metrics-row {
    display: flex;
    overflow-x: auto;
    scrollbar-width: thin;
  }

  .route-workspace-clean-ui #mapView .metric {
    flex: 0 0 120px;
  }

  .route-workspace-clean-ui #mapView .map-stage {
    order: 1;
  }

  .route-workspace-clean-ui #mapView .right-panel {
    order: 2;
  }

  .route-workspace-clean-ui #mapView .left-panel {
    order: 3;
  }

  .route-workspace-clean-ui #mapView .map-stage {
    min-height: 620px;
    grid-template-rows: auto auto minmax(420px, 58vh);
  }

  .route-command-bar {
    grid-template-columns: 1fr;
    grid-template-areas:
      "context"
      "actions"
      "toggle"
      "explanation";
  }

  .route-command-actions {
    justify-content: flex-start;
  }

  .route-order-toggle,
  .route-order-explanation {
    justify-self: start;
  }

  .route-workspace-clean-ui #mapView .right-panel {
    min-height: 440px;
    max-height: 640px;
  }

  .visit-entry-modal {
    align-items: end;
    padding: 0;
  }

  .visit-entry-dialog {
    width: 100%;
    max-height: 94dvh;
    border-radius: 8px 8px 0 0;
  }

  .visit-entry-modal .outcome-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .route-command-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: visible;
  }

  .route-command-actions button {
    width: 100%;
    white-space: normal;
  }

  .selected-sales-grid {
    grid-template-columns: 1fr;
  }

  .selected-sales-grid > div,
  .selected-sales-grid > div:nth-child(2n),
  .selected-sales-grid > div:nth-last-child(-n + 2) {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .selected-sales-grid > div:last-child {
    border-bottom: 0;
  }
}
