:root {
  --ui-bg: rgba(8, 15, 18, .92);
  --ui-bg-2: rgba(14, 24, 27, .94);
  --ui-line: rgba(196, 219, 214, .16);
  --ui-hot: #73b66f;
  --ui-blue: #5aa2d6;
  --ui-warn: #e3ad47;
}

body, body * {
  -webkit-user-select: none;
  user-select: none;
}

#topbar, #bottombar, #toolPanel, #hamburgerMenu, #classicLeftPanel,
.events-panel, .tmpe-popup, .pill, .toast {
  -webkit-user-select: none;
  user-select: none;
}

button, .hud-pill {
  transition: transform .12s ease, border-color .18s ease, background .18s ease, box-shadow .18s ease, filter .18s ease;
}

button:hover {
  transform: translateY(-1px);
  border-color: rgba(143, 211, 136, .52) !important;
  filter: brightness(1.08);
}

button:active {
  transform: translateY(1px) scale(.985);
}

button.active,
button.speed-active,
.transit-line-card.active,
.tmpe-mode-row button.active,
.tmpe-lane-card button.active {
  background: linear-gradient(180deg, rgba(88, 138, 76, .88), rgba(39, 84, 49, .92)) !important;
  border-color: rgba(152, 220, 126, .72) !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.16), 0 0 0 1px rgba(97, 179, 87, .14), 0 8px 22px rgba(55, 118, 54, .18);
}

body.city-mode #topbar.topbar {
  left: 0;
  right: 0;
  top: 0;
  transform: none;
  width: 100%;
  max-width: none;
  min-width: 0;
  border-radius: 0;
  border-left: 0;
  border-right: 0;
  padding-left: 10px;
  background: linear-gradient(180deg, rgba(8, 16, 20, .97), rgba(9, 18, 21, .92));
  box-shadow: 0 1px 0 rgba(255,255,255,.06), 0 14px 34px rgba(0,0,0,.24);
}

.hud-events-badge {
  cursor: pointer;
  color: #eef6f2;
}

.hud-events-badge span {
  color: #f5c869;
}

.classic-left-panel {
  background: linear-gradient(180deg, rgba(8, 16, 21, .90), rgba(8, 14, 18, .82));
  border-right-color: rgba(180, 211, 206, .14);
  box-shadow: 12px 0 34px rgba(0, 0, 0, .20);
}

.classic-tabs button {
  min-height: 44px;
  border-radius: 12px;
  margin: 2px 0;
}

.classic-cards article {
  border-radius: 8px;
  background: rgba(255,255,255,.055);
  border: 1px solid rgba(255,255,255,.08);
}

.tool-panel {
  max-height: min(74vh, 720px);
  overflow: auto;
  scrollbar-width: thin;
  background: linear-gradient(180deg, rgba(8,16,18,.94), rgba(7,13,15,.91));
  box-shadow: 0 24px 70px rgba(0,0,0,.34);
}

.tool-panel[data-active-tool="transit"] {
  width: min(720px, calc(100vw - 298px));
}

.tool-panel[data-active-tool="upgrade"] {
  width: min(430px, calc(100vw - 24px));
}

.tool-section[data-tool-section="transit"] .classic-tool-group:has([data-transit-side]) {
  display: none !important;
}

.transit-manager {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.transit-mode-row,
.transit-actions-main,
.tmpe-mode-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.tmpe-mode-row {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 8px 0;
}

.transit-manager button,
.tmpe-popup button,
.fleet-card-actions button,
.fleet-row-actions button {
  border: 1px solid var(--ui-line);
  border-radius: 8px;
  background: rgba(255,255,255,.055);
  color: #edf6f2;
  padding: 9px 10px;
  font-weight: 900;
}

.transit-filter {
  width: 100%;
  box-sizing: border-box;
  border-radius: 8px;
  border: 1px solid var(--ui-line);
  background: rgba(255,255,255,.055);
  color: #edf6f2;
  padding: 9px 10px;
  font-weight: 800;
}

.transit-line-list,
.fleet-vehicle-list {
  display: grid;
  gap: 7px;
  max-height: 172px;
  overflow: auto;
}

.transit-line-card,
.fleet-vehicle-row,
.fleet-catalog-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 9px;
  align-items: center;
  min-width: 0;
  border: 1px solid var(--ui-line);
  border-radius: 8px;
  background: rgba(255,255,255,.045);
  color: #edf6f2;
  padding: 9px;
  text-align: left;
}

.transit-line-card i {
  width: 10px;
  height: 36px;
  border-radius: 4px;
  box-shadow: 0 0 14px currentColor;
}

.transit-line-card b,
.fleet-vehicle-row b,
.fleet-catalog-card b {
  display: block;
  font-size: 12px;
}

.transit-line-card span,
.fleet-vehicle-row span,
.fleet-catalog-card span,
.fleet-catalog-card p {
  display: block;
  margin: 2px 0 0;
  color: #aebfba;
  font-size: 10px;
}

.transit-selected-row {
  display: grid;
  grid-template-columns: 82px 1fr;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border-radius: 8px;
  background: rgba(255,255,255,.04);
}

.transit-selected-row label {
  display: grid;
  gap: 4px;
  color: #b8cbc5;
  font-size: 10px;
  font-weight: 900;
}

.transit-selected-row input {
  width: 100%;
  height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
}

.fleet-catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
  max-height: 260px;
  overflow: auto;
}

.fleet-catalog-card {
  grid-template-columns: 1fr;
  align-items: start;
}

.fleet-catalog-card em,
.fleet-vehicle-row em {
  color: #f0d28a;
  font-size: 11px;
  font-style: normal;
  font-weight: 900;
}

.fleet-vehicle-row {
  grid-template-columns: 1fr auto auto;
}

.danger,
.fleet-row-actions .danger {
  background: rgba(150, 54, 48, .36) !important;
  border-color: rgba(222, 96, 86, .44) !important;
}

.events-panel {
  position: fixed;
  top: 58px;
  right: 16px;
  width: min(340px, calc(100vw - 32px));
  z-index: 710;
  border: 1px solid var(--ui-line);
  border-radius: 10px;
  background: var(--ui-bg);
  box-shadow: 0 20px 55px rgba(0,0,0,.38);
  padding: 10px;
}

.events-panel.hidden,
.tmpe-popup.hidden {
  display: none;
}

.events-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #edf6f2;
  margin-bottom: 8px;
}

.event-row {
  width: 100%;
  display: grid;
  grid-template-columns: 14px 1fr;
  gap: 9px;
  align-items: center;
  border: 1px solid var(--ui-line);
  border-radius: 8px;
  background: rgba(255,255,255,.045);
  color: #edf6f2;
  padding: 9px;
  margin-top: 6px;
  text-align: left;
}

.event-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ui-warn);
}

.event-accident { background: #e35b4f; }
.event-flood { background: #5aa8dd; }
.event-protest { background: #f0ead0; }
.event-roadwork { background: #eda43c; }
.event-pothole { background: #4c4035; }

.event-row small,
.event-empty,
.tmpe-help {
  display: block;
  color: #aabbb5;
  font-size: 10px;
}

.tmpe-popup {
  position: fixed;
  left: 286px;
  top: 174px;
  width: min(430px, calc(100vw - 302px));
  z-index: 705;
  border: 1px solid var(--ui-line);
  border-radius: 10px;
  background: var(--ui-bg-2);
  box-shadow: 0 20px 55px rgba(0,0,0,.40);
  padding: 12px;
  color: #edf6f2;
}

.tmpe-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.tmpe-head button {
  width: 28px;
  height: 28px;
  padding: 0;
}

.tmpe-title {
  color: #b9cbc5;
  font-size: 11px;
  font-weight: 900;
  margin-bottom: 8px;
}

.tmpe-slider {
  display: grid;
  gap: 6px;
  font-size: 11px;
  font-weight: 900;
  color: #dcebe6;
}

.tmpe-slider span {
  color: #f0d28a;
}

.tmpe-lanes {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.tmpe-lane-card {
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border-radius: 8px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.07);
}

.tmpe-lane-card div {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

@media (max-width: 980px) {
  body.city-mode #topbar.topbar {
    gap: 5px;
    overflow-x: auto;
    padding-right: 8px;
  }

  .classic-left-panel {
    transform: translateX(-100%);
  }

  .tool-panel {
    left: 10px !important;
    width: min(620px, calc(100vw - 20px)) !important;
  }

  .tmpe-popup {
    left: 10px;
    top: 150px;
    width: calc(100vw - 20px);
    box-sizing: border-box;
  }

  .tmpe-mode-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .tool-cluster button .tool-label {
    display: none;
  }

  .fleet-catalog-grid {
    grid-template-columns: 1fr;
  }

  .transit-selected-row,
  .tmpe-lane-card {
    grid-template-columns: 1fr;
  }
}

/* v0.9.15: core antigo + responsividade sem depender de zoom do navegador. */
body.city-mode #topbar.topbar {
  min-height: 42px;
  height: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  padding: 6px 8px;
  box-sizing: border-box;
}

body.city-mode #topbar .brand {
  min-width: 124px;
  max-width: 150px;
}

body.city-mode #topbar .hud-pill {
  min-width: 0;
  height: 28px;
  padding: 0 7px;
  gap: 4px;
  white-space: nowrap;
}

body.city-mode #topbar .hud-pill b {
  font-size: 8px;
  letter-spacing: .02em;
}

body.city-mode #topbar .hud-pill span {
  font-size: 10.5px;
}

body.city-mode .classic-left-panel {
  position: fixed;
  display: grid;
  grid-template-columns: 50px 0;
  left: 8px;
  top: 54px;
  bottom: 84px;
  width: 54px;
  transform: none !important;
  z-index: 690;
  overflow: hidden;
  border-radius: 14px;
  border: 1px solid rgba(196,219,214,.13);
  transition: width .18s ease, grid-template-columns .18s ease, background .18s ease;
}

body.city-mode .classic-left-panel:hover,
body.city-mode .classic-left-panel:focus-within {
  width: min(230px, calc(100vw - 22px));
  grid-template-columns: 50px 1fr;
}

.classic-tabs {
  padding: 8px 5px;
}

.classic-tabs button {
  width: 40px;
  height: 42px;
  min-height: 42px;
  overflow: hidden;
  text-indent: -999px;
  position: relative;
}

.classic-tabs button::before {
  content: attr(data-tool);
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-indent: 0;
  text-transform: uppercase;
  font-size: 8px;
}

.classic-panel-body {
  min-width: 154px;
  padding: 10px 10px 10px 2px;
}

body.city-mode .tool-panel {
  left: 72px;
  top: 64px;
  width: min(374px, calc(100vw - 92px));
  max-height: calc(100vh - 150px);
  box-sizing: border-box;
}

body.city-mode .tool-panel[data-active-tool="transit"] {
  width: min(374px, calc(100vw - 92px));
}

.tool-section[data-tool-section="transit"] .transit-manager > h4 {
  display: none;
}

.transit-fleet-panel {
  position: fixed;
  left: min(458px, calc(100vw - 384px));
  top: 64px;
  width: min(360px, calc(100vw - 92px));
  max-height: calc(100vh - 150px);
  overflow: auto;
  z-index: 704;
  border: 1px solid var(--ui-line);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(8,16,18,.95), rgba(7,13,15,.93));
  box-shadow: 0 24px 70px rgba(0,0,0,.34);
  color: #edf6f2;
  padding: 10px;
  box-sizing: border-box;
}

.transit-fleet-panel.hidden {
  display: none;
}

.transit-fleet-body {
  display: grid;
  gap: 10px;
}

.transit-fleet-body h4 {
  margin: 2px 0 -2px;
  font-size: 11px;
  text-transform: uppercase;
  color: #dbeae4;
}

.tn-minimap.sim-minimap {
  position: fixed;
  right: 14px;
  bottom: 84px;
  width: 222px;
  z-index: 690;
  padding: 10px;
  border: 1px solid rgba(196,219,214,.16);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(8,16,18,.92), rgba(7,13,15,.88));
  box-shadow: 0 20px 55px rgba(0,0,0,.34);
  box-sizing: border-box;
}

.tn-minimap.sim-minimap.collapsed canvas,
.tn-minimap.sim-minimap.collapsed .tn-minimap-head,
.tn-minimap.sim-minimap.collapsed .tn-minimap-actions button:not(#miniMapHide) {
  display: none;
}

.tn-minimap-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 7px;
  color: #edf6f2;
}

.tn-minimap-head span {
  font-size: 9px;
  color: #9fb4ad;
  text-transform: uppercase;
}

#miniMapCanvas {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  height: auto;
  border-radius: 10px;
  background: #203728;
  border: 1px solid rgba(255,255,255,.08);
  cursor: crosshair;
}

.tn-minimap-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 8px;
}

.tn-minimap-actions button {
  padding: 7px 5px;
  border-radius: 8px;
  border: 1px solid var(--ui-line);
  background: rgba(255,255,255,.055);
  color: #edf6f2;
  font-size: 9px;
  font-weight: 900;
}

@media (max-width: 1180px) {
  .transit-fleet-panel {
    left: 72px;
    top: 64px;
    width: min(374px, calc(100vw - 92px));
  }

  body.city-mode #topbar .hud-pill {
    height: 24px;
    padding: 0 5px;
  }
}

@media (max-width: 980px) {
  body.city-mode .classic-left-panel {
    top: 52px;
    bottom: 78px;
    width: 50px;
  }

  body.city-mode .tool-panel,
  body.city-mode .tool-panel[data-active-tool="transit"],
  .transit-fleet-panel {
    left: 62px !important;
    width: calc(100vw - 74px) !important;
  }

  .tn-minimap.sim-minimap {
    width: 168px;
    right: 8px;
    bottom: 76px;
  }
}

@media (max-width: 720px) {
  body.city-mode #topbar .hud-pill {
    height: 22px;
  }

  body.city-mode .classic-left-panel {
    display: none;
  }

  body.city-mode .tool-panel,
  body.city-mode .tool-panel[data-active-tool="transit"],
  .transit-fleet-panel {
    left: 8px !important;
    width: calc(100vw - 16px) !important;
    max-height: calc(100vh - 136px);
  }

  .tn-minimap.sim-minimap {
    width: 136px;
  }
}

/* v0.9.15 final override: vence regras antigas do styles-urban.css que escondiam a sidebar. */
body.city-mode #classicLeftPanel.classic-left-panel {
  display: grid !important;
  grid-template-columns: 50px 0 !important;
  left: 8px !important;
  top: 54px !important;
  bottom: 84px !important;
  width: 54px !important;
  max-height: none !important;
  overflow: hidden !important;
}

body.city-mode #classicLeftPanel.classic-left-panel:hover,
body.city-mode #classicLeftPanel.classic-left-panel:focus-within {
  width: min(230px, calc(100vw - 22px)) !important;
  grid-template-columns: 50px 1fr !important;
}

@media (max-width: 720px) {
  body.city-mode #classicLeftPanel.classic-left-panel {
    display: grid !important;
    grid-template-columns: 44px 0 !important;
    left: 6px !important;
    top: 50px !important;
    bottom: 74px !important;
    width: 46px !important;
  }

  body.city-mode #classicLeftPanel.classic-left-panel:hover,
  body.city-mode #classicLeftPanel.classic-left-panel:focus-within {
    width: min(208px, calc(100vw - 12px)) !important;
    grid-template-columns: 44px 1fr !important;
  }

  body.city-mode .tool-panel,
  body.city-mode .tool-panel[data-active-tool="transit"],
  .transit-fleet-panel {
    left: 58px !important;
    width: calc(100vw - 66px) !important;
  }
}
