/* Bản đồ truy vết (trace-map.js): lớp phủ toàn màn hình, bản đồ trái + cột lộ trình phải. */
#tmView { position: fixed; inset: 0; z-index: 900; display: flex; flex-direction: column; background: var(--bg); }
#tmView[hidden], #tmView [hidden] { display: none !important; }
body.tm-open { overflow: hidden; }
.tm-top { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel); }
.tm-tt { display: flex; flex-direction: column; min-width: 0; }
.tm-tt b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tm-tt span { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#tmEdit.on { border-color: var(--warn); color: var(--warn); }
.tm-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 380px; }
.tm-map { position: relative; min-height: 0; }
#tmMap { position: absolute; inset: 0; background: #0b1016; }
/* nền OSM tối dịu cho hợp giao diện; ghim / đường vẽ không bị lọc */
#tmMap .leaflet-tile-pane { filter: brightness(.78) contrast(1.08) saturate(.85); }
#tmMap .leaflet-control-attribution { background: rgba(16,22,30,.8); color: var(--muted); }
#tmMap .leaflet-control-attribution a { color: #93c5fd; }
#tmMap .leaflet-popup-content-wrapper, #tmMap .leaflet-popup-tip { background: var(--panel2); color: var(--text); border: 1px solid var(--line2); }
#tmMap .leaflet-tooltip { background: var(--panel2); color: var(--text); border: 1px solid var(--line2); box-shadow: none; }
#tmMap .leaflet-tooltip-top::before { border-top-color: var(--line2); }
.tm-legend { position: absolute; left: 12px; bottom: 26px; z-index: 500; display: flex; flex-wrap: wrap; gap: 6px 12px; max-width: calc(100% - 24px);
  padding: 6px 10px; border-radius: 8px; background: rgba(16,22,30,.88); border: 1px solid var(--line2); font-size: 12px; }
.tm-legend span { display: inline-flex; align-items: center; gap: 6px; }
.tm-legend i { width: 10px; height: 10px; border-radius: 50%; }
.tm-msg { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); z-index: 500; padding: 6px 12px; border-radius: 8px;
  background: rgba(16,22,30,.92); border: 1px solid var(--line2); font-size: 13px; max-width: 80%; text-align: center; }
.tm-msg[hidden] { display: none; }

.tm-cam { display: block; width: 12px; height: 12px; border-radius: 50%; background: var(--c); border: 2px solid #0b1016; opacity: .55; }
.tm-cam.on { opacity: 1; width: 14px; height: 14px; box-shadow: 0 0 0 3px rgba(255,255,255,.18); }
.tm-stop { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px;
  background: var(--c); color: #0b1016; font: 700 12px/1 Inter, sans-serif; border: 2px solid #0b1016; box-shadow: 0 1px 4px rgba(0,0,0,.5); white-space: nowrap; }
.tm-stop.first { background: #22c55e; }
.tm-stop.last { background: #ef4444; color: #fff; }
.tm-arrow { display: block; width: 0; height: 0; margin: 2px; border-left: 12px solid #facc15; border-top: 6px solid transparent; border-bottom: 6px solid transparent;
  filter: drop-shadow(0 0 2px #000); }
.tm-dot { display: block; width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 3px solid #3d8bfd; box-shadow: 0 0 0 6px rgba(61,139,253,.35); }
.tm-inc { display: block; width: 20px; height: 20px; border-radius: 50%; background: #ef4444; border: 3px solid #fff; box-shadow: 0 0 0 7px rgba(239,68,68,.3); }
.tm-hn { display: inline-block; min-width: 48px; padding: 0 6px; border-radius: 9px; text-align: center; font: 700 12px/18px Inter, sans-serif; color: #fff; background: rgba(11,16,22,.85); }

.tm-pop { font-size: 12.5px; display: flex; flex-direction: column; gap: 4px; }
.tm-pop .muted { color: var(--muted); font-size: 12px; }
.tm-pop-row { display: flex; gap: 8px; align-items: center; }
.tm-pop-row img { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; background: var(--panel3); flex: none; }

.tm-side { min-height: 0; overflow-y: auto; border-left: 1px solid var(--line); background: var(--panel); padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.tm-pad { padding: 10px; }
.tm-err { color: #fca5a5; }
.tm-card { border: 1px solid var(--line2); border-radius: 9px; padding: 10px 12px; background: var(--panel2); font-size: 12.5px; line-height: 1.5; }
.tm-warn { border-color: rgba(245,158,11,.5); background: rgba(245,158,11,.08); }
.tm-note { border-color: rgba(167,139,250,.5); background: rgba(167,139,250,.08); }
.tm-edit { border-color: rgba(250,204,21,.45); background: rgba(250,204,21,.07); display: flex; flex-direction: column; gap: 6px; }
.tm-miss, .tm-chips, .tm-acts { display: flex; flex-wrap: wrap; gap: 6px; }
.tm-sum { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; text-align: center; }
.tm-sum b { display: block; font-size: 16px; }
.tm-sum span { color: var(--muted); font-size: 11px; }
.tm-ctl { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.tm-ctl label { display: inline-flex; align-items: center; gap: 6px; }
.tm-ctl .sel { height: 30px; }
.tm-ctl .muted { flex-basis: 100%; font-size: 12px; }
.tm-bars { display: flex; align-items: flex-end; gap: 2px; height: 44px; }
.tm-bars i { flex: 1; background: var(--accent); border-radius: 2px 2px 0 0; opacity: .85; }
.tm-bx { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--dim); }
.tm-list { display: flex; flex-direction: column; gap: 4px; }
.tm-item { display: flex; gap: 10px; align-items: center; padding: 7px 8px; border-radius: 8px; border: 1px solid transparent; cursor: pointer; }
.tm-item:hover { background: var(--panel2); border-color: var(--line2); }
.tm-item.cur { border-color: var(--accent); background: var(--accent-soft); }
.tm-item.off { opacity: .5; }
.tm-item.ref { border-color: rgba(34,197,94,.5); }
.tm-n { flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--panel3); font-size: 11.5px; font-weight: 700; }
.tm-chk { flex: none; width: 18px; height: 18px; accent-color: var(--accent); }
.tm-im { flex: none; width: 48px; height: 48px; border-radius: 7px; overflow: hidden; background: var(--panel3); }
.tm-im:empty { display: none; }
.tm-im img { width: 100%; height: 100%; object-fit: cover; }
.tm-veh .tm-im { width: 72px; height: 48px; }
.tm-tx { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 1px; font-size: 12.5px; }
.tm-tx b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tm-tx span, .tm-tx small { color: var(--muted); }
.tm-tx small { font-size: 11.5px; }

/* nút mở bản đồ trong các trang */
.tm-open-btn svg { margin-right: 4px; }

@media (max-width: 900px) {
  .tm-body { grid-template-columns: 1fr; grid-template-rows: minmax(260px, 55vh) 1fr; }
  .tm-side { border-left: 0; border-top: 1px solid var(--line); }
  .tm-top { padding: 8px 12px; flex-wrap: wrap; }
}
.mem .btn.sm { height: 22px; padding: 0 7px; font-size: 10.5px; margin-top: 2px; }
