:root {
  --bg-primary: #0a0a0f;
  --bg-panel: rgba(12, 12, 20, 0.85);
  --border: rgba(255, 255, 255, 0.06);
  --text-primary: rgba(255, 255, 255, 0.9);
  --text-secondary: rgba(255, 255, 255, 0.5);
  --accent-tanker: #f59e0b;
  --accent-green: #22c55e;
  --accent-red: #ef4444;
  --accent-teal: #14b8a6;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Menlo', monospace;
  --radius: 12px;
}

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  height: 100dvh;
  width: 100vw;
}

#map {
  position: absolute;
  inset: 0;
  z-index: 0;
}

/* Panels */
.panel {
  position: absolute;
  background: var(--bg-panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  z-index: 10;
  padding: 16px;
}

/* Oil Panel */
#oil-panel {
  top: 16px;
  left: 16px;
  min-width: 220px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.panel-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.5px;
  color: var(--text-secondary);
}

.panel-meta {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
}

.panel-sub {
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.5px;
  color: rgba(255, 255, 255, 0.3);
}

/* Price flash on refresh */
@keyframes price-flash {
  0% { color: var(--text-primary); }
  20% { color: var(--accent-green); text-shadow: 0 0 8px rgba(34, 197, 94, 0.4); }
  100% { color: var(--text-primary); text-shadow: none; }
}

.oil-price.flash {
  animation: price-flash 0.8s ease-out;
}

/* Panel border pulse */
@keyframes panel-pulse {
  0% { border-color: var(--border); }
  30% { border-color: rgba(34, 197, 94, 0.25); }
  100% { border-color: var(--border); }
}

#oil-panel.refreshed {
  animation: panel-pulse 0.8s ease-out;
}

.oil-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.oil-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.oil-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  width: 40px;
}

.oil-price {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
}

.oil-change {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 4px;
}

.oil-change.up {
  color: var(--accent-green);
  background: rgba(34, 197, 94, 0.1);
}

.oil-change.down {
  color: var(--accent-red);
  background: rgba(239, 68, 68, 0.1);
}

/* Ship Detail */
.ship-detail {
  top: 16px;
  right: 16px;
  min-width: 260px;
}

.ship-detail.hidden {
  display: none;
}

.ship-detail.pinned {
  border-color: rgba(255, 255, 255, 0.15);
}

.ship-detail .detail-value {
  user-select: text;
  cursor: text;
}

.detail-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.detail-close:hover {
  color: var(--text-primary);
}

.detail-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding-right: 24px;
}

.detail-name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.detail-type-badge {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.detail-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--text-secondary);
}

.detail-value {
  font-size: 14px;
  color: var(--text-primary);
}

.mono {
  font-family: var(--font-mono);
}

/* Stats Bar */
.stats-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  background: var(--bg-panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 10px 20px;
  gap: 28px;
}

.stat {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}

.has-tooltip {
  cursor: help;
}

.tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(12, 12, 20, 0.95);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  pointer-events: none;
}

.has-tooltip:hover .tooltip {
  display: block;
}

.stat-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--text-secondary);
}

.stat-value {
  font-size: 14px;
  font-weight: 500;
}

.tanker-color {
  color: var(--accent-tanker);
}

/* Author */
.author-link {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  text-decoration: none;
}

.author-link:hover {
  color: var(--text-primary);
}

/* Connection */
.connection-stat {
  margin-left: auto;
}

.connection-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.connection-dot.connected {
  background: var(--accent-green);
  box-shadow: 0 0 6px var(--accent-green);
}

.connection-dot.connecting {
  background: var(--accent-tanker);
  box-shadow: 0 0 6px var(--accent-tanker);
}

.connection-dot.disconnected {
  background: var(--accent-red);
  box-shadow: 0 0 6px var(--accent-red);
}

/* Vessel Panel */
.vessel-panel {
  bottom: 52px;
  left: 16px;
  padding: 0;
  width: 260px;
  max-height: calc(100dvh - 120px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.vessel-panel.collapsed {
  max-height: 42px;
}

.vessel-panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.vessel-panel-header:hover {
  background: rgba(255, 255, 255, 0.03);
}

.vessel-panel-count {
  font-size: 12px;
  color: var(--text-secondary);
}

.vessel-panel-chevron {
  margin-left: auto;
  font-size: 10px;
  color: var(--text-secondary);
  transition: transform 0.3s ease;
}

.vessel-panel.collapsed .vessel-panel-chevron {
  transform: rotate(180deg);
}

.vessel-panel-body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.vessel-panel.collapsed .vessel-panel-body {
  display: none;
}

.filter-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 8px 6px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}

.filter-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
  user-select: none;
}

.filter-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.filter-item input[type="checkbox"] {
  display: none;
}

.filter-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dot-color);
  box-shadow: 0 0 6px var(--dot-color);
  flex-shrink: 0;
  transition: opacity 0.2s, box-shadow 0.2s;
}

.filter-item.disabled .filter-dot {
  opacity: 0.2;
  box-shadow: none;
}

.filter-name {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-primary);
  flex: 1;
  transition: opacity 0.2s;
}

.filter-item.disabled .filter-name {
  opacity: 0.35;
}

.filter-count {
  font-size: 10px;
  color: var(--text-secondary);
  min-width: 16px;
  text-align: right;
  transition: opacity 0.2s;
}

.filter-item.disabled .filter-count {
  opacity: 0.25;
}

/* Vessel search */
.vessel-search-wrap {
  padding: 8px 10px;
  flex-shrink: 0;
}

.vessel-search {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-family: var(--font);
  font-size: 11px;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s;
}

.vessel-search::placeholder {
  color: rgba(255, 255, 255, 0.25);
}

.vessel-search:focus {
  border-color: rgba(255, 255, 255, 0.15);
}

/* Vessel list */
.vessel-list {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  max-height: 320px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.vessel-list::-webkit-scrollbar {
  width: 4px;
}

.vessel-list::-webkit-scrollbar-track {
  background: transparent;
}

.vessel-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

.vessel-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  cursor: pointer;
  transition: background 0.12s;
  border-bottom: 1px solid rgba(255, 255, 255, 0.02);
}

.vessel-row:hover {
  background: rgba(255, 255, 255, 0.05);
}

.vessel-row-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.vessel-row-name {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-primary);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vessel-row-speed {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.vessel-list-empty {
  padding: 16px 14px;
  font-size: 11px;
  color: var(--text-secondary);
  text-align: center;
}

/* MapLibre overrides */
.maplibregl-ctrl-bottom-left {
  bottom: 200px;
}

.maplibregl-ctrl-bottom-right {
  bottom: 48px;
}

.maplibregl-ctrl-attrib {
  background: rgba(0, 0, 0, 0.5) !important;
  color: rgba(255, 255, 255, 0.4) !important;
  font-size: 10px !important;
}

.maplibregl-ctrl-attrib a {
  color: rgba(255, 255, 255, 0.5) !important;
}


/* Mobile */
@media (max-width: 640px) {
  #oil-panel {
    top: 12px;
    left: 12px;
    right: 12px;
    min-width: unset;
    padding: 12px;
  }

  .oil-grid {
    flex-direction: row;
    gap: 16px;
  }

  .panel-header {
    margin-bottom: 8px;
  }

  .ship-detail {
    top: auto;
    bottom: 52px;
    right: 0;
    left: 0;
    min-width: unset;
    border-radius: var(--radius) var(--radius) 0 0;
    border-bottom: none;
  }

  .vessel-panel {
    bottom: 44px;
    left: 0;
    width: 240px;
    border-radius: 0 var(--radius) 0 0;
    border-left: none;
    border-bottom: none;
    max-height: calc(100dvh - 100px);
  }

  .vessel-list {
    max-height: 200px;
  }

  .stats-bar {
    padding: 8px 12px;
    gap: 16px;
  }

  .stat-label {
    font-size: 9px;
  }

  .stat-value {
    font-size: 12px;
  }
}

@media (pointer: coarse) {
  .detail-close {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

/* Ship cursor on hover */
.maplibregl-canvas-container.maplibregl-interactive {
  cursor: grab;
}
