/**
 * Control Tower v2 — isolated layout for roster + Rotte panel.
 * Scoped exclusively to #planning-studio-root.ct-v2 and ct-* classes.
 * Does not depend on legacy .ps-vstop / .ps-workbench cascade.
 */

#planning-studio-root.ct-v2 {
  --ct-ink: #0f172a;
  --ct-muted: #64748b;
  --ct-line: #e2e8f0;
  --ct-line-2: #cbd5e1;
  --ct-panel: #ffffff;
  --ct-panel-2: #f8fafc;
  --ct-accent: #2563eb;
  --ct-ok: #16a34a;
  --ct-warn: #d97706;
  --ct-danger: #dc2626;
  --ct-info: #0284c7;
  --ct-radius: 12px;
  --ct-shadow: 0 8px 28px rgba(15, 23, 42, 0.12);
}

/* Neutralize legacy stop/workbench rules that fight v2 markup */
#planning-studio-root.ct-v2 .ct-route-workbench,
#planning-studio-root.ct-v2 .ps-workbench {
  display: block !important;
  position: relative;
  min-width: 0;
  width: 100%;
  height: 100%;
  grid-template-columns: none !important;
  gap: 0 !important;
}

#planning-studio-root.ct-v2 .ct-route-timeline,
#planning-studio-root.ct-v2 .ps-timeline-col {
  display: block;
  width: 100%;
  min-width: 0;
  height: 100%;
  overflow: hidden;
}

#planning-studio-root.ct-v2 .ct-inspector.ps-inspector-col {
  /* Drawer overlay — never compress the timeline column */
  position: absolute !important;
  inset: 0 0 0 auto !important;
  width: min(360px, 92%) !important;
  max-width: 360px !important;
  min-width: 0 !important;
  height: 100% !important;
  margin: 0 !important;
  border-left: 1px solid var(--ct-line);
  background: var(--ct-panel);
  box-shadow: var(--ct-shadow);
  transform: translateX(110%);
  transition: transform 0.2s ease;
  z-index: 40;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#planning-studio-root.ct-v2 .ct-inspector--open,
#planning-studio-root.ct-v2.ct-inspector-open .ct-inspector {
  transform: translateX(0);
}

/* ---------- Roster ---------- */

#planning-studio-root.ct-v2 .ct-roster,
#planning-studio-root.ct-v2 .ps-left.ct-roster {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--ct-panel-2);
}

#planning-studio-root.ct-v2 .ct-roster__head {
  flex: 0 0 auto;
  padding: 0.55rem 0.7rem 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ct-muted);
}

#planning-studio-root.ct-v2 .ct-roster__list {
  flex: 1 1 auto;
  overflow: auto;
  padding: 0.25rem 0.45rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

#planning-studio-root.ct-v2 .ct-roster-card {
  appearance: none;
  border: 1px solid transparent;
  background: var(--ct-panel);
  border-radius: 10px;
  min-height: 56px;
  padding: 0.45rem 0.55rem 0.4rem;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  color: var(--ct-ink);
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

#planning-studio-root.ct-v2 .ct-roster-card:hover {
  border-color: var(--ct-line-2);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

#planning-studio-root.ct-v2 .ct-roster-card:focus-visible {
  outline: 2px solid var(--ct-accent);
  outline-offset: 2px;
}

#planning-studio-root.ct-v2 .ct-roster-card--active {
  border-color: color-mix(in srgb, var(--ct-roster-accent, var(--ct-accent)) 55%, white);
  box-shadow: inset 3px 0 0 var(--ct-roster-accent, var(--ct-accent));
  background: #fff;
}

#planning-studio-root.ct-v2 .ct-roster-card--unused {
  opacity: 0.58;
}

#planning-studio-root.ct-v2 .ct-roster-card--deactivated {
  opacity: 0.45;
  filter: grayscale(0.85);
  border-style: dashed;
}

#planning-studio-root.ct-v2 .ct-roster-card--deactivated .ct-roster-card__name {
  text-decoration: line-through;
  color: #64748b;
}

#planning-studio-root.ct-v2 .ct-roster-card__reactivate {
  border: 1px solid #bbf7d0;
  background: #f0fdf4;
  color: #15803d;
  border-radius: 999px;
  padding: 0.15rem 0.5rem;
  font-size: 0.68rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.2;
}

#planning-studio-root.ct-v2 .ct-roster-card__reactivate:hover {
  background: #dcfce7;
}

#planning-studio-root.ct-v2 .ct-roster-card__top {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
}

#planning-studio-root.ct-v2 .ct-roster-card__avatar {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-weight: 700;
  color: #fff;
  background: var(--ct-roster-accent, var(--ct-accent));
  flex: 0 0 auto;
}

#planning-studio-root.ct-v2 .ct-roster-card__avatar--sm {
  width: 26px;
  height: 26px;
  font-size: 0.64rem;
}

#planning-studio-root.ct-v2 .ct-roster-card__name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.84rem;
  font-weight: 650;
  line-height: 1.2;
}

#planning-studio-root.ct-v2 .ct-roster-card__count {
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ct-muted);
  flex: 0 0 auto;
}

#planning-studio-root.ct-v2 .ct-roster-card__sem {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.12rem 0.35rem;
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
  white-space: nowrap;
}

#planning-studio-root.ct-v2 .ct-roster-card__sem--ok { background: #dcfce7; color: #166534; }
#planning-studio-root.ct-v2 .ct-roster-card__sem--warn { background: #ffedd5; color: #9a3412; }
#planning-studio-root.ct-v2 .ct-roster-card__sem--danger { background: #fee2e2; color: #991b1b; }

#planning-studio-root.ct-v2 .ct-roster-card__bar {
  display: block;
  height: 4px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

#planning-studio-root.ct-v2 .ct-roster-card__bar > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--ct-roster-accent, var(--ct-accent));
}

#planning-studio-root.ct-v2 .ct-roster-card__meta {
  font-size: 0.68rem;
  color: var(--ct-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#planning-studio-root.ct-v2 .ct-roster-card__warn {
  margin-left: 0.25rem;
  color: var(--ct-warn);
}

#planning-studio-root.ct-v2 .ct-roster-card__warn--danger {
  color: var(--ct-danger);
}

#planning-studio-root.ct-v2 .ct-roster-divider {
  margin: 0.45rem 0.15rem 0.15rem;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ct-muted);
  opacity: 0.85;
}

/* ---------- Routes chrome ---------- */

#planning-studio-root.ct-v2 .ct-route-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
}

#planning-studio-root.ct-v2 .ct-route-chrome {
  flex: 0 0 auto;
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--ct-panel);
  border-bottom: 1px solid var(--ct-line);
}

#planning-studio-root.ct-v2 .ct-route-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "driver tools"
    "search search";
  gap: 0.45rem 0.6rem;
  padding: 0.55rem 0.7rem;
  align-items: center;
  min-width: 0;
}

#planning-studio-root.ct-v2 .ct-route-header__driver { grid-area: driver; min-width: 0; }
#planning-studio-root.ct-v2 .ct-route-header__tools {
  grid-area: tools;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  justify-self: end;
}
#planning-studio-root.ct-v2 .ct-route-header__search {
  grid-area: search;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
}

#planning-studio-root.ct-v2 .ct-route-header__main {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}

#planning-studio-root.ct-v2 .ct-route-header__copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

#planning-studio-root.ct-v2 .ct-route-header__name {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--ct-ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#planning-studio-root.ct-v2 .ct-route-header__stats {
  font-size: 0.72rem;
  color: var(--ct-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#planning-studio-root.ct-v2 .ct-route-header__progress {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.2rem;
}

#planning-studio-root.ct-v2 .ct-route-header__progress-bar {
  flex: 1 1 auto;
  height: 4px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
  min-width: 48px;
  display: flex;
  flex-direction: row;
  align-items: stretch;
}

#planning-studio-root.ct-v2 .ct-route-header__progress-bar > span {
  display: block;
  height: 100%;
  flex: 0 0 auto;
}

#planning-studio-root.ct-v2 .ct-route-header__progress-done {
  background: #059669;
}

#planning-studio-root.ct-v2 .ct-route-header__progress-failed {
  background: #f59e0b;
}

#planning-studio-root.ct-v2 .ct-route-header__progress-label {
  font-size: 0.66rem;
  color: var(--ct-muted);
  white-space: nowrap;
}

#planning-studio-root.ct-v2 .ct-route-header__search .ps-vlane-search-wrap {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
}

#planning-studio-root.ct-v2 .ct-route-header__search .ps-vlane-filter-input {
  width: 100%;
  min-width: 0;
}

#planning-studio-root.ct-v2 .ct-route-body {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  position: relative;
}

/* ---------- Stop list ---------- */

#planning-studio-root.ct-v2 .ct-stop-list {
  height: 100%;
  overflow: auto;
  padding: 0.55rem 0.55rem 1rem;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

#planning-studio-root.ct-v2 .ct-route-body,
#planning-studio-root.ct-v2 .ct-route-workbench,
#planning-studio-root.ct-v2 .ct-route-timeline {
  max-width: 100%;
  min-width: 0;
  overflow-x: hidden;
}

#planning-studio-root.ct-v2 .ct-stop-rail {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
  padding-left: 0.15rem;
}

#planning-studio-root.ct-v2 .ct-stop-rail::before {
  content: '';
  position: absolute;
  left: 22px;
  top: 12px;
  bottom: 12px;
  width: 2px;
  background: color-mix(in srgb, var(--ct-route-line, var(--ct-accent)) 35%, #e2e8f0);
  border-radius: 999px;
  pointer-events: none;
  z-index: 0;
}

#planning-studio-root.ct-v2 .ct-stop-leg {
  display: flex;
  justify-content: flex-start;
  padding: 0 0 0 2.65rem;
  min-width: 0;
}

#planning-studio-root.ct-v2 .ct-stop-leg__label {
  font-size: 0.64rem;
  font-weight: 600;
  color: var(--ct-muted);
  background: transparent;
}

#planning-studio-root.ct-v2 .ct-stop {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  align-items: start;
  gap: 0.55rem;
  min-width: 0;
  max-width: 100%;
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
  padding: 0.55rem 1.55rem 0.55rem 0.45rem;
  border: 1px solid var(--ct-line);
  border-radius: var(--ct-radius);
  background: var(--ct-panel);
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

#planning-studio-root.ct-v2 .ct-stop:hover {
  border-color: var(--ct-line-2);
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.05);
}

#planning-studio-root.ct-v2 .ct-stop:focus-visible {
  outline: 2px solid var(--ct-accent);
  outline-offset: 2px;
}

#planning-studio-root.ct-v2 .ct-stop--active {
  border-color: color-mix(in srgb, var(--ct-accent) 45%, white);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--ct-accent) 18%, transparent);
}

#planning-studio-root.ct-v2 .ct-stop--depot {
  background: var(--ct-panel-2);
}

#planning-studio-root.ct-v2 .ct-stop--dragging {
  opacity: 0.55;
}

#planning-studio-root.ct-v2 .ct-stop--drop {
  border-color: var(--ct-accent);
  background: #eff6ff;
}

#planning-studio-root.ct-v2 .ct-stop--filter-muted {
  opacity: 0.28;
}

#planning-studio-root.ct-v2 .ct-stop--filter-hit {
  border-color: color-mix(in srgb, var(--ct-accent) 40%, var(--ct-line));
}

#planning-studio-root.ct-v2 .ct-stop--exec-done { border-left: 3px solid var(--ct-ok); }
#planning-studio-root.ct-v2 .ct-stop--exec-live { border-left: 3px solid var(--ct-info); }
#planning-studio-root.ct-v2 .ct-stop--exec-fail { border-left: 3px solid var(--ct-danger); }
#planning-studio-root.ct-v2 .ct-stop--exec-late { border-left: 3px solid var(--ct-warn); }
#planning-studio-root.ct-v2 .ct-stop--exec-pending { border-left: 3px solid var(--ct-line-2); }

#planning-studio-root.ct-v2 .ct-stop__num {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  flex: 0 0 auto;
  margin-top: 0.05rem;
  z-index: 1;
}

#planning-studio-root.ct-v2 .ct-stop__num--depot {
  font-size: 0.7rem;
}

#planning-studio-root.ct-v2 .ct-stop__num--done { background: var(--ct-ok) !important; }
#planning-studio-root.ct-v2 .ct-stop__num--live { background: var(--ct-info) !important; }
#planning-studio-root.ct-v2 .ct-stop__num--fail { background: var(--ct-danger) !important; }
#planning-studio-root.ct-v2 .ct-stop__num--pending { background: #94a3b8 !important; }

#planning-studio-root.ct-v2 .ct-stop__body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
  overflow: hidden;
}

#planning-studio-root.ct-v2 .ct-stop__type {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--ct-muted);
  white-space: nowrap;
  overflow: hidden;
}

#planning-studio-root.ct-v2 .ct-stop__type > span {
  flex: 0 0 auto;
}

#planning-studio-root.ct-v2 .ct-stop__type i {
  color: var(--ct-accent);
  width: 0.9rem;
  text-align: center;
}

#planning-studio-root.ct-v2 .ct-stop__track {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  color: #475569;
}

#planning-studio-root.ct-v2 .ct-stop__flags {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  align-self: start;
  margin-top: 0.15rem;
  flex: 0 0 auto;
}

#planning-studio-root.ct-v2 .ct-stop__flag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 999px;
  font-size: 0.62rem;
  background: #fff7ed;
  color: #c2410c;
}

#planning-studio-root.ct-v2 .ct-stop__flag--signature {
  background: #eff6ff;
  color: #1d4ed8;
}

#planning-studio-root.ct-v2 .ct-stop__flag--photo {
  background: #f0fdf4;
  color: #15803d;
}

#planning-studio-root.ct-v2 .ct-stop__flag--driver-note {
  background: #fef3c7;
  color: #b45309;
}

#planning-studio-root.ct-v2 .ct-stop__label {
  min-width: 0;
  max-width: 100%;
  color: var(--ct-ink);
  font-size: 0.86rem;
  font-weight: 550;
  line-height: 1.3;
  max-height: calc(1.3em * 2);
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  word-break: normal;
  overflow-wrap: break-word;
  white-space: normal;
  hyphens: none;
}

#planning-studio-root.ct-v2 .ct-stop__eta {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  align-self: start;
  margin-top: 0.1rem;
  padding: 0.22rem 0.45rem;
  border-radius: 999px;
  background: #eff6ff;
  color: var(--ct-accent);
  font-size: 0.72rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex: 0 0 auto;
}

#planning-studio-root.ct-v2 .ct-stop__eta--shadow {
  background: #f1f5f9;
  color: var(--ct-muted);
  font-style: italic;
}

#planning-studio-root.ct-v2 .ct-stop__grip {
  position: absolute;
  right: 0.35rem;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0;
  color: #94a3b8;
  font-size: 0.78rem;
  padding: 0.25rem;
  cursor: grab;
  transition: opacity 0.15s ease;
}

#planning-studio-root.ct-v2 .ct-stop:hover .ct-stop__grip,
#planning-studio-root.ct-v2 .ct-stop:focus-within .ct-stop__grip,
#planning-studio-root.ct-v2 .ct-stop--active .ct-stop__grip {
  opacity: 0.85;
}

#planning-studio-root.ct-v2 .ct-stop-list--compact .ct-stop {
  padding-top: 0.4rem;
  padding-bottom: 0.4rem;
}

#planning-studio-root.ct-v2 .ct-stop-list--compact .ct-stop__label {
  -webkit-line-clamp: 1;
  line-clamp: 1;
}

/* ---------- Inspector drawer ---------- */

#planning-studio-root.ct-v2 .ct-inspector__head {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--ct-line);
  flex: 0 0 auto;
}

#planning-studio-root.ct-v2 .ct-inspector__back {
  appearance: none;
  border: 1px solid var(--ct-line);
  background: var(--ct-panel);
  border-radius: 8px;
  padding: 0.35rem 0.55rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ct-ink);
  cursor: pointer;
}

#planning-studio-root.ct-v2 .ct-inspector__body,
#planning-studio-root.ct-v2 .ps-inspector-body {
  flex: 1 1 auto;
  overflow: auto;
  padding: 0.7rem;
  min-width: 0;
}

#planning-studio-root.ct-v2 .ct-inspector-scrim.ps-inspector-scrim {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.28);
  z-index: 10065;
  border: none;
  cursor: pointer;
}

#planning-studio-root.ct-v2 .ct-inspector-scrim[hidden] {
  display: none !important;
}

/* ---------- ~514px / narrow right column ---------- */

@media (max-width: 560px) {
  #planning-studio-root.ct-v2 .ct-route-header {
    grid-template-columns: 1fr;
    grid-template-areas:
      "driver"
      "tools"
      "search";
  }

  #planning-studio-root.ct-v2 .ct-route-header__tools {
    justify-self: start;
  }

  #planning-studio-root.ct-v2 .ct-stop {
    grid-template-columns: 28px minmax(0, 1fr);
    grid-template-rows: auto auto;
  }

  #planning-studio-root.ct-v2 .ct-stop__eta {
    grid-column: 2;
    justify-self: start;
  }

  #planning-studio-root.ct-v2 .ct-inspector.ps-inspector-col {
    inset: auto 0 0 0 !important;
    width: 100% !important;
    max-width: none !important;
    max-height: min(72vh, 560px);
    border-radius: 16px 16px 0 0;
    border-left: none;
    transform: translateY(110%);
  }

  #planning-studio-root.ct-v2 .ct-inspector--open,
  #planning-studio-root.ct-v2.ct-inspector-open .ct-inspector {
    transform: translateY(0);
  }
}

/* Prefer readable cards when the routes pane itself is ~514px wide */
@container (max-width: 540px) {
  #planning-studio-root.ct-v2 .ct-route-header {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  #planning-studio-root.ct-v2 .ct-inspector,
  #planning-studio-root.ct-v2 .ct-roster-card,
  #planning-studio-root.ct-v2 .ct-stop {
    transition: none !important;
  }
}

/* ============================================================
   Control Tower v2 — stacked roster strip + icon-only tabs
   ============================================================ */

@media (max-width: 900px) {
  #planning-studio-root.ct-v2 .ct-roster__list {
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    gap: 0.4rem;
    padding: 0.3rem 0.45rem 0.55rem;
  }

  #planning-studio-root.ct-v2 .ct-roster-card {
    flex: 0 0 auto;
    width: clamp(150px, 42vw, 210px);
    min-height: 48px;
    scroll-snap-align: start;
  }
}

@media (max-width: 560px) {
  #planning-studio-root.ct-v2 .ps-tabs .ps-tab > span:not(.ps-tab-badge) {
    display: none;
  }

  #planning-studio-root.ct-v2 .ps-tabs .ps-tab {
    justify-content: center;
    padding-left: 0.35rem;
    padding-right: 0.35rem;
    min-width: 44px;
  }

  #planning-studio-root.ct-v2 .ps-tabs .ps-tab i {
    font-size: 0.85rem;
    opacity: 1;
  }
}

/* Job title (rename) in command bar */
#planning-studio-root.ct-v2 .ps-command-title {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  max-width: min(280px, 32vw);
  min-width: 0;
  margin-left: 0.35rem;
  margin-right: 0.25rem;
}
#planning-studio-root.ct-v2 .ps-command-title__text {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ps-text, #1a1a1a);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
#planning-studio-root.ct-v2 .ps-command-title__text[data-empty="1"] {
  font-weight: 500;
  color: var(--ps-muted, #8a8a8a);
  font-style: italic;
}
#planning-studio-root.ct-v2 .ps-command-title__edit {
  flex: 0 0 auto;
  border: none;
  background: transparent;
  color: var(--ps-muted, #8a8a8a);
  cursor: pointer;
  padding: 0.2rem 0.35rem;
  border-radius: 4px;
  line-height: 1;
}
#planning-studio-root.ct-v2 .ps-command-title__edit:hover {
  color: var(--ps-text, #1a1a1a);
  background: rgba(0, 0, 0, 0.06);
}
#planning-studio-root.ct-v2 .ps-command-title__input {
  flex: 1 1 auto;
  min-width: 8rem;
  max-width: 100%;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.2rem 0.4rem;
  border: 1px solid var(--ps-border, #cfcfcf);
  border-radius: 4px;
  background: #fff;
  color: var(--ps-text, #1a1a1a);
}

/* ---- Modalità modifica ---- */
#planning-studio-root.ct-v2 #ps-action-edit-mode.is-active,
body.ps-edit-mode #ps-action-edit-mode {
  background: #0f766e;
  color: #fff;
  border-color: #0f766e;
}
.ps-edit-tray {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 900;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--ps-border, #d4d4d4);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ps-edit-tray__summary,
.ps-edit-tray__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.ps-edit-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: #ecfdf5;
  color: #0f766e;
  font-size: 0.75rem;
  font-weight: 600;
}
.ps-edit-route-tag {
  margin-left: 6px;
  font-size: 0.68rem;
  padding: 1px 6px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #64748b;
}
.ps-edit-route-tag.is-touched {
  background: #ffedd5;
  color: #c2410c;
}
.ps-edit-map-toolbar {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 850;
  display: flex;
  gap: 4px;
  background: rgba(255,255,255,0.95);
  border: 1px solid #d4d4d4;
  border-radius: 8px;
  padding: 4px;
}
.ps-edit-map-toolbar button {
  border: 0;
  background: transparent;
  min-width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: #334155;
}
.ps-edit-map-toolbar button.is-icon { padding: 0; width: 32px; justify-content: center; }
.ps-edit-map-toolbar__sep { width: 1px; align-self: stretch; margin: 4px 2px; background: #e2e8f0; }
.ps-edit-modechip {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 850;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid #d4d4d4;
  font-size: 12.5px;
  font-weight: 600;
  color: #0f766e;
}
.ps-edit-modechip .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #0f766e;
  box-shadow: 0 0 0 3px #d9f0ec;
}
.ps-edit-toggle__kbd {
  margin-left: 6px;
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid currentColor;
  font-size: 10px;
  opacity: 0.75;
}
.ps-edit-seg { display: inline-flex; gap: 3px; padding: 3px; border: 1px solid #d4d4d4; border-radius: 12px; background: #fff; }
.ps-edit-seg button {
  border: 0;
  background: transparent;
  border-radius: 9px;
  padding: 4px 10px;
  text-align: left;
  cursor: pointer;
}
.ps-edit-seg button b { display: flex; align-items: center; gap: 6px; font-size: 12.5px; }
.ps-edit-seg button small { display: block; font-size: 11px; color: #64748b; }
.ps-edit-seg button[aria-checked="true"] { background: #0f766e; }
.ps-edit-seg button[aria-checked="true"] b,
.ps-edit-seg button[aria-checked="true"] small { color: #fff; }
.ps-edit-tag { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: #f1f5f9; }
.ps-edit-tag.is-add { background: #d9f0ec; color: #0f766e; }
.ps-edit-tag.is-mod { background: #fef3c7; color: #b45309; }
.ps-edit-tag.is-rem { background: #fee2e2; color: #b91c1c; }
.ps-edit-tray__lab, .ps-edit-keep { font-size: 12.5px; color: #475569; }
.ps-edit-tray__spacer { flex: 1; }
.ps-edit-iconbtn {
  width: 34px; height: 34px; border-radius: 8px; border: 1px solid #d4d4d4; background: #fff; cursor: pointer;
}
.ps-edit-tray__hint { display: flex; gap: 8px; align-items: center; font-size: 12.5px; color: #475569; }
.ps-edit-map-toolbar button.is-active,
.ps-edit-map-toolbar button:hover {
  background: #ecfdf5;
  color: #0f766e;
}
.ps-edit-ctx-menu,
.ps-edit-add-sheet {
  position: absolute;
  z-index: 960;
  background: #fff;
  border: 1px solid #d4d4d4;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.12);
}
.ps-edit-ctx-menu {
  display: flex;
  flex-direction: column;
  min-width: 200px;
  padding: 4px;
}
.ps-edit-ctx-menu button {
  border: 0;
  background: transparent;
  text-align: left;
  padding: 8px 10px;
  cursor: pointer;
  border-radius: 6px;
}
.ps-edit-ctx-menu button:hover { background: #f8fafc; }
.ps-edit-add-sheet {
  right: 12px;
  top: 56px;
  width: min(360px, calc(100% - 24px));
  padding: 12px;
}
.ps-edit-add-sheet__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.ps-edit-estimate {
  font-size: 0.8rem;
  color: #475569;
  margin: 8px 0;
  max-height: 120px;
  overflow: auto;
}
.ps-edit-recalc-dialog {
  position: fixed;
  inset: 0;
  z-index: 12000;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
}
.ps-edit-recalc-dialog__panel {
  width: min(640px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow: auto;
  background: #fff;
  border-radius: 12px;
  padding: 16px;
}
.ps-edit-recalc-dialog__panel header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.ps-edit-recalc-tiles {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
.ps-edit-tile {
  text-align: left;
  border: 1px solid #d4d4d4;
  border-radius: 10px;
  padding: 12px;
  background: #fff;
  cursor: pointer;
}
.ps-edit-tile:hover { border-color: #0f766e; }
.ps-edit-tile b { display: block; margin-bottom: 4px; }
.ps-edit-tile span { color: #64748b; font-size: 0.85rem; }
.ps-edit-preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin: 10px 0;
}
.ps-edit-preview-table th,
.ps-edit-preview-table td {
  border-bottom: 1px solid #e2e8f0;
  padding: 6px 4px;
  text-align: left;
}
.ps-edit-recalc-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}
.ps-edit-error { color: #b91c1c; }
.ps-edit-warn { color: #c2410c; font-size: 0.85rem; }
.ps-edit-recalc-running {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 0;
}
.ps-edit-recalc-running .spinner {
  width: 18px;
  height: 18px;
  border: 2px solid #cbd5e1;
  border-top-color: #0f766e;
  border-radius: 50%;
  animation: ps-edit-spin 0.8s linear infinite;
}
@keyframes ps-edit-spin { to { transform: rotate(360deg); } }
