:root {
  --bg-primary: #111217;
  --bg-secondary: #141619;
  --bg-card: #181b1f;
  --bg-card-hover: #1e2127;
  --border: rgba(255,255,255,0.07);
  --border-light: rgba(255,255,255,0.12);
  --text-primary: #d8dae3;
  --text-secondary: #8e8fa2;
  --text-muted: #555770;
  --accent-blue: #5794f2;
  --accent-green: #73bf69;
  --accent-orange: #ff9830;
  --accent-red: #f2495c;
  --accent-purple: #b877d9;
  --radius: 4px;
}

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

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  font-size: 13px;
  overflow-x: hidden;
}

/* ════════════════════════════════════
   MOBILE FIRST (default = phone)
   ════════════════════════════════════ */

/* ─── Bottom tab bar ─── */
.sidebar {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  display: flex; flex-direction: row;
  z-index: 200; height: 52px;
  padding: 0; padding-bottom: env(safe-area-inset-bottom, 0);
}

.logo { display: none; }
.sidebar-spacer { display: none; }
.sidebar-footer { display: none; }

.nav-item {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; padding: 6px 2px;
  color: var(--text-muted); text-decoration: none;
  font-size: 9px; font-weight: 500;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s;
}
.nav-item svg { width: 20px; height: 20px; }
.nav-item.active { color: var(--accent-orange); }

/* ─── Content ─── */
.content {
  padding: 12px;
  padding-bottom: calc(64px + env(safe-area-inset-bottom, 0));
}

.view { display: none; }
.view.active { display: block; }

.view-header {
  display: flex; flex-direction: column; gap: 8px;
  margin-bottom: 10px;
}
.view-header h1 { font-size: 18px; font-weight: 600; }
.header-actions { width: 100%; }

/* ─── Search ─── */
.search-box { position: relative; width: 100%; }
.search-box input {
  width: 100%; padding: 10px 12px 10px 34px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-primary);
  font-family: inherit; font-size: 13px;
  -webkit-appearance: none;
}
.search-box input:focus { outline: none; border-color: var(--accent-orange); }
.search-box input::placeholder { color: var(--text-muted); }
.search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); pointer-events: none;
}

/* ─── Stats ─── */
.stats-grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 6px; margin-bottom: 10px;
}
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px;
}
.stat-label { font-size: 9px; color: var(--text-secondary); margin-bottom: 2px; text-transform: uppercase; letter-spacing: 0.3px; }
.stat-value { font-size: 20px; font-weight: 600; }
.stat-card.accent-blue .stat-value { color: var(--accent-blue); }
.stat-card.accent-green .stat-value { color: var(--accent-green); }
.stat-card.accent-orange .stat-value { color: var(--accent-orange); }

/* ─── Filters ─── */
.filter-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 6px; margin-bottom: 8px;
}
.filter-chips {
  display: flex; gap: 4px;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.filter-chips::-webkit-scrollbar { display: none; }
.chip {
  padding: 6px 12px; border-radius: 3px; font-size: 11px; font-weight: 500;
  cursor: pointer; border: 1px solid var(--border); background: transparent;
  color: var(--text-muted); font-family: inherit;
  white-space: nowrap; flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.chip.active { border-color: var(--accent-orange); background: rgba(255,152,48,0.1); color: var(--accent-orange); }
.filtered-count { font-size: 10px; color: var(--text-muted); white-space: nowrap; }

/* ─── Map ─── */
#map {
  width: 100%;
  height: calc(100dvh - 280px);
  min-height: 250px;
  border-radius: var(--radius); border: 1px solid var(--border);
  margin-bottom: 10px;
}

/* Leaflet dark tiles */
.leaflet-tile-pane { filter: none; }
.leaflet-control-zoom a {
  background: var(--bg-card) !important; color: var(--text-primary) !important;
  border-color: var(--border) !important;
  width: 36px !important; height: 36px !important; line-height: 36px !important; font-size: 18px !important;
}
.leaflet-control-attribution { background: rgba(17,18,23,0.85) !important; color: var(--text-muted) !important; font-size: 8px !important; }
.leaflet-control-attribution a { color: var(--text-secondary) !important; }
.leaflet-popup-content-wrapper {
  background: var(--bg-card) !important; color: var(--text-primary) !important;
  border-radius: var(--radius) !important; border: 1px solid var(--border) !important;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5) !important;
}
.leaflet-popup-tip { background: var(--bg-card) !important; }
.leaflet-popup-content { font-family: 'Inter', sans-serif !important; font-size: 12px !important; margin: 10px 12px !important; }

/* ─── Tables (horizontal scroll on mobile) ─── */
.chart-container {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px; margin-bottom: 8px;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.chart-container h2 {
  font-size: 12px; font-weight: 500; color: var(--text-secondary);
  margin-bottom: 6px; padding-bottom: 6px; border-bottom: 1px solid var(--border);
}

.data-table { width: 100%; border-collapse: collapse; font-size: 11px; min-width: 520px; }
.data-table th {
  text-align: left; padding: 6px 6px; font-weight: 500;
  color: var(--text-muted); border-bottom: 1px solid var(--border); font-size: 9px;
  white-space: nowrap; text-transform: uppercase; letter-spacing: 0.3px;
}
.data-table td { padding: 8px 6px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table tbody tr { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.data-table tbody tr:active { background: rgba(255,255,255,0.03); }

.badge {
  display: inline-block; padding: 2px 6px; border-radius: 3px;
  font-size: 9px; font-weight: 600; text-transform: uppercase;
}
.badge-warehouse { background: rgba(87,148,242,0.15); color: var(--accent-blue); }
.badge-transit { background: rgba(255,152,48,0.15); color: var(--accent-orange); }
.badge-delivered { background: rgba(115,191,105,0.15); color: var(--accent-green); }

/* ─── Warehouse grid ─── */
.wh-grid { display: grid; grid-template-columns: 1fr; gap: 8px; }
.wh-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px;
  -webkit-tap-highlight-color: transparent; cursor: pointer;
}
.wh-card:active { background: var(--bg-card-hover); }
.wh-card h3 { font-size: 15px; font-weight: 600; margin-bottom: 2px; }
.wh-country { font-size: 10px; color: var(--text-muted); margin-bottom: 8px; }

.wh-stats-row {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 4px; margin-top: 10px;
}
.wh-mini-stat { text-align: center; }
.wh-mini-val { font-size: 16px; font-weight: 600; }
.wh-mini-label { font-size: 8px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.3px; }

/* ─── Pulse animation ─── */
@keyframes pulse {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(2.5); opacity: 0; }
}
.pulse-ring { animation: pulse 2s ease-out infinite; }

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 4px; height: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.06); border-radius: 2px; }

/* ════════════════════════════════════
   DESKTOP (sidebar on left)
   ════════════════════════════════════ */
@media (min-width: 769px) {
  body { display: flex; flex-direction: row; }

  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; right: auto;
    width: 220px; height: auto;
    flex-direction: column; align-items: stretch;
    border-top: none; border-right: 1px solid var(--border);
    padding: 0; padding-bottom: 0;
  }

  .logo {
    display: flex; align-items: center; gap: 10px;
    padding: 16px 18px; font-size: 15px; font-weight: 600;
    color: var(--accent-orange); border-bottom: 1px solid var(--border);
  }
  .logo svg { flex-shrink: 0; }

  .nav-item {
    flex: none; flex-direction: row; justify-content: flex-start;
    gap: 10px; padding: 9px 18px; font-size: 13px;
    border-left: 3px solid transparent;
  }
  .nav-item svg { width: 18px; height: 18px; }
  .nav-item:hover { background: rgba(255,255,255,0.03); color: var(--text-primary); }
  .nav-item.active { background: rgba(255,152,48,0.08); border-left-color: var(--accent-orange); }

  .sidebar-spacer { display: block; flex: 1; }
  .sidebar-footer {
    display: block; padding: 12px 18px; font-size: 11px;
    color: var(--text-muted); border-top: 1px solid var(--border);
  }

  .content {
    margin-left: 220px; padding: 24px;
    padding-bottom: 24px; max-width: 1600px;
  }

  .view-header { flex-direction: row; align-items: center; justify-content: space-between; }
  .header-actions { width: auto; }
  .search-box { width: 280px; }

  .stats-grid { grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .stat-card { padding: 14px; }
  .stat-label { font-size: 10px; }
  .stat-value { font-size: 24px; }

  #map { height: 500px; }

  .wh-grid { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
  .wh-card { padding: 20px; }
  .wh-card:hover { background: var(--bg-card-hover); }
  .wh-mini-val { font-size: 18px; }
  .wh-mini-label { font-size: 9px; }
}
