:root {
  --primary-color: #0b5ed7;
  --primary-hover: #0a58ca;
  --bg-glass: rgba(255, 255, 255, 0.94);
  --glass-border: rgba(226, 232, 240, 0.8);
  --shadow-main: 0 8px 24px -4px rgba(15, 23, 42, 0.12), 0 4px 6px -4px rgba(15, 23, 42, 0.04);
  --shadow-sheet: 0 -8px 25px rgba(0, 0, 0, 0.15);
}

html, body, #app, #map {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

#app {
  position: relative;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #1e293b;
}

/* Header & Top Panel */
.top-panel {
  position: absolute;
  z-index: 1000;
  top: max(10px, env(safe-area-inset-top));
  left: 10px;
  right: 10px;
  padding: 10px;
  border-radius: 16px;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-main);
}

.brand {
  color: var(--primary-color);
  font-size: 13.5px;
  font-weight: 800;
  letter-spacing: 0.3px;
  display: flex;
  gap: 5px;
  align-items: center;
  margin-bottom: 8px;
}

.brand b {
  color: #0f172a;
}

.brand small {
  font-size: 8px;
  letter-spacing: 1px;
  color: #64748b;
  font-weight: 700;
}

.brand-mark {
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #0b5ed7 0%, #0284c7 100%);
  color: white;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  box-shadow: 0 2px 5px rgba(11, 94, 215, 0.3);
}

.search-mode {
  flex: 0 0 102px;
  max-width: 102px;
  font-size: 11.5px;
  font-weight: 600;
  border: 0;
  border-right: 1px solid #e2e8f0;
  background-color: transparent;
  color: #334155;
}

.filters {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  align-items: center;
}

.filters select {
  max-width: 140px;
  border-radius: 8px;
  font-size: 12px;
  border-color: #cbd5e1;
  padding: 3px 8px;
}

.filters .btn-group .btn {
  font-weight: 600;
  font-size: 11px;
  padding: 3px 10px;
}

/* Autocomplete Suggestions */
.suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 1010;
  max-height: 240px;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  box-shadow: var(--shadow-main);
}

.suggestion {
  width: 100%;
  padding: 9px 12px;
  text-align: left;
  border: 0;
  border-bottom: 1px solid #f1f5f9;
  background: transparent;
  font-size: 12.5px;
}

.suggestion:hover, .suggestion:active {
  background: #f0f6ff;
}

.suggestion b {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #0f172a;
}

.suggestion small {
  display: block;
  color: #64748b;
}

/* Floating Actions & Loading */
.loading, .empty {
  position: absolute;
  z-index: 1001;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-glass);
  backdrop-filter: blur(8px);
  padding: 10px 18px;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-main);
  white-space: nowrap;
  font-weight: 500;
  font-size: 13.5px;
}

.action {
  position: absolute;
  right: 12px;
  z-index: 1000;
  width: 42px;
  height: 42px;
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  background: var(--bg-glass);
  backdrop-filter: blur(8px);
  color: var(--primary-color);
  font-size: 19px;
  bottom: calc(160px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow-main);
  display: grid;
  place-items: center;
  transition: transform 0.15s, background 0.15s;
}

.action:active {
  transform: scale(0.92);
  background: #ffffff;
}

.refresh {
  bottom: calc(112px + env(safe-area-inset-bottom));
}

/* Legend Box */
.legend {
  position: absolute;
  z-index: 1000;
  left: 10px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--bg-glass);
  backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-main);
  font-size: 11px;
  color: #334155;
}

.legend b {
  display: block;
  margin-bottom: 3px;
  color: #0f172a;
  font-size: 11.5px;
}

.legend span {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}

.legend i {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.black { background: #1e293b; }
.green { background: #16a34a; }
.yellow { background: #eab308; }
.orange { background: #f97316; }
.red { background: #dc3545; }

/* Custom Markers */
.asset-marker {
  background: transparent;
  border: 0;
}

.asset-marker span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 2px solid white;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  color: white;
  font-size: 9.5px;
  font-weight: 700;
}

.marker-odp span {
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
}

.marker-odp b {
  transform: rotate(45deg);
}

.marker-odc span {
  border-radius: 7px;
  transform: rotate(45deg);
}

.marker-odc b {
  transform: rotate(-45deg);
}

.asset-selected span {
  box-shadow: 0 0 0 3px white, 0 0 0 5px var(--primary-color), 0 3px 10px rgba(0, 0, 0, 0.3);
}

/* Bottom Sheet Details - Compact for Small Phone Displays */
.sheet {
  position: absolute;
  z-index: 1040;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 48vh; /* Ultra-compact so 60%+ map remains visible! */
  overflow-y: auto;
  background: #ffffff;
  padding: 8px 14px calc(14px + env(safe-area-inset-bottom));
  border-radius: 20px 20px 0 0;
  box-shadow: var(--shadow-sheet);
  transform: translateY(110%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.sheet.open {
  transform: translateY(0);
}

.handle {
  width: 38px;
  height: 4px;
  margin: 0 auto 8px;
  background: #cbd5e1;
  border-radius: 10px;
}

.title {
  font-size: 16px;
  font-weight: 800;
  color: #0f172a;
  margin-right: 26px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Compact 4-column stats layout (Fix Item #4) */
.stats-compact {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin: 8px 0;
}

.stat-item {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  padding: 6px 4px;
  border-radius: 8px;
  text-align: center;
}

.stat-item span {
  display: block;
  font-size: 10px;
  color: #64748b;
  font-weight: 500;
}

.stat-item strong {
  display: block;
  font-size: 13px;
  font-weight: 800;
  color: #0f172a;
  margin-top: 1px;
}

.sub-stats {
  display: flex;
  gap: 10px;
  font-size: 11px;
  color: #475569;
  background: #f1f5f9;
  padding: 5px 8px;
  border-radius: 6px;
  margin-top: 4px;
}

.sub-stats div {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result {
  display: block;
  width: 100%;
  padding: 8px 12px;
  margin: 4px 0;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: white;
  text-align: left;
}

.result strong {
  display: block;
  color: #0f172a;
  font-size: 13px;
}

.result span {
  display: block;
  font-size: 11px;
  color: #64748b;
}

.route-summary {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: #eff6ff;
  border: 1px solid #dbeafe;
  color: #1e40af;
  font-size: 12px;
}

/* Modals Mobile Fix */
.modal-dialog {
  margin: 10px;
}

.modal-content {
  border-radius: 18px;
  border: none;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
}

.modal-header {
  border-bottom: 1px solid #f1f5f9;
  padding: 14px 16px;
}

.modal-body {
  padding: 16px;
}

.modal-footer {
  border-top: 1px solid #f1f5f9;
  padding: 12px 16px;
}

/* Desktop Styles */
@media (min-width: 768px) {
  .top-panel {
    right: auto;
    width: 410px;
  }
  .sheet {
    left: 16px;
    right: auto;
    bottom: 16px;
    width: 370px;
    max-height: 55vh;
    border-radius: 18px;
    padding-bottom: 16px;
    transform: translateY(calc(100% + 30px));
  }
  .modal-dialog {
    margin: 1.75rem auto;
  }
}
