* { margin:0; padding:0; box-sizing:border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background:#0f1923; color:#e0e0e0; overflow:hidden; height:100vh; }

#header {
  background: linear-gradient(135deg, #141e2b 0%, #1a2a3a 100%);
  padding: 14px 24px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid #2a3a4a;
  z-index: 100; position: relative;
}
#header h1 { font-size: 20px; font-weight: 700; color: #fff; }
#header-stats { display: flex; gap: 20px; }
.stat { font-size: 13px; color: #8899aa; }
.stat-num { font-size: 18px; font-weight: 700; color: #4A90D9; margin-right: 4px; }

#toolbar {
  display: flex; align-items: center; padding: 10px 24px;
  background: #141e2b; border-bottom: 1px solid #1e3040; gap: 16px; z-index: 99; position: relative;
}

#search-box { position: relative; flex: 0 0 320px; }

#filter-box { display:flex; align-items:center; gap:8px; }
#hot-filter {
  padding: 7px 12px; border: 1px solid #2a3a4a; border-radius: 6px;
  background: #1a2a3a; color: #ccc; font-size: 13px; outline: none; cursor: pointer;
  min-width: 180px;
}
#hot-filter:focus { border-color: #4A90D9; }
#hot-filter option { background: #1a2a3a; color: #ccc; }
.filter-count {
  font-size: 12px; color: #4A90D9; background: #4A90D922;
  padding: 2px 10px; border-radius: 10px; white-space: nowrap;
}
.filter-count.hidden { display:none; }
#search-input {
  width: 100%; padding: 8px 14px; border: 1px solid #2a3a4a; border-radius: 8px;
  background: #1a2a3a; color: #eee; font-size: 14px; outline: none;
}
#search-input:focus { border-color: #4A90D9; }
#search-results {
  position: absolute; top: 100%; left: 0; right: 0; background: #1a2a3a;
  border: 1px solid #2a3a4a; border-radius: 0 0 8px 8px; max-height: 360px; overflow-y: auto;
  display: none; z-index: 200;
}
#search-results.show { display: block; }
.sr-item {
  padding: 10px 14px; cursor: pointer; border-bottom: 1px solid #253545;
  display: flex; align-items: center; gap: 10px; font-size: 13px;
}
.sr-item:hover { background: #253545; }
.sr-tag {
  font-size: 11px; padding: 2px 8px; border-radius: 4px; font-weight: 600; flex-shrink: 0;
}
.sr-tag.ent { background:#4A90D9; color:#fff; }
.sr-tag.chain { background:#E8A838; color:#fff; }
.sr-tag.inv { background:#E85A5A; color:#fff; }
.sr-tag.infra { background:#7BC47F; color:#fff; }
.sr-tag.opp { background:#E67E22; color:#fff; }

#toolbar-btns { display: flex; gap: 8px; margin-left: auto; }
.tb-btn {
  padding: 7px 16px; border: 1px solid #2a3a4a; border-radius: 6px;
  background: #1a2a3a; color: #ccc; font-size: 13px; cursor: pointer;
}
.tb-btn:hover { background: #253545; color: #fff; border-color: #4A90D9; }

#main { display: flex; height: calc(100vh - 105px); position: relative; }

#graph-container { flex: 1; position: relative; overflow: hidden; }
#graph-svg { width: 100%; height: 100%; }

#detail-panel {
  width: 420px; background: #141e2b; border-left: 1px solid #2a3a4a;
  overflow-y: auto; padding: 20px; position: relative; transition: right 0.3s;
}
#detail-panel.hidden { display: none; }

#panel-close, #modal-close {
  position: absolute; top: 12px; right: 12px; background: none; border: none;
  color: #667; font-size: 20px; cursor: pointer; z-index: 10;
}
#panel-close:hover, #modal-close:hover { color: #fff; }

.dp-header { margin-bottom: 16px; }
.dp-type {
  font-size: 11px; text-transform: uppercase; letter-spacing: 1px;
  padding: 3px 10px; border-radius: 4px; display: inline-block; margin-bottom: 8px; font-weight: 600;
}
.dp-type.enterprise { background: #4A90D922; color: #4A90D9; border: 1px solid #4A90D955; }
.dp-type.chain { background: #E8A83822; color: #E8A838; border: 1px solid #E8A83855; }
.dp-type.investment { background: #E85A5A22; color: #E85A5A; border: 1px solid #E85A5A55; }
.dp-type.infrastructure { background: #7BC47F22; color: #7BC47F; border: 1px solid #7BC47F55; }
.dp-type.opportunity { background: #E67E2222; color: #E67E22; border: 1px solid #E67E2255; }
.dp-type.gap-supply { background: #E74C3C22; color: #E74C3C; border: 1px solid #E74C3C55; }
.dp-type.gap-tech { background: #8E44AD22; color: #8E44AD; border: 1px solid #8E44AD55; }
.dp-type.gap-upstream { background: #3498DB22; color: #3498DB; border: 1px solid #3498DB55; }
.dp-type.gap-downstream { background: #1ABC9C22; color: #1ABC9C; border: 1px solid #1ABC9C55; }

.gap-tag { display:inline-block; padding:2px 8px; border-radius:4px; font-size:11px; font-weight:600; margin-left:6px; }
.gap-tag.supply { background:#E74C3C22; color:#E74C3C; border:1px solid #E74C3C55; }
.gap-tag.tech { background:#8E44AD22; color:#8E44AD; border:1px solid #8E44AD55; }
.gap-tag.upstream { background:#3498DB22; color:#3498DB; border:1px solid #3498DB55; }
.gap-tag.downstream { background:#1ABC9C22; color:#1ABC9C; border:1px solid #1ABC9C55; }
.dp-type.city { background: #9B59B622; color: #9B59B6; border: 1px solid #9B59B655; }

.dp-title { font-size: 20px; font-weight: 700; color: #fff; }
.dp-sub { font-size: 13px; color: #8899aa; margin-top: 4px; }

.dp-section { margin-top: 16px; }
.dp-section h3 {
  font-size: 14px; font-weight: 600; color: #aabbcc; margin-bottom: 8px;
  border-bottom: 1px solid #1e3040; padding-bottom: 6px;
}
.dp-field { display: flex; padding: 4px 0; font-size: 13px; }
.dp-field .label { color: #667; width: 100px; flex-shrink: 0; }
.dp-field .value { color: #ddd; }
.dp-list { font-size: 13px; }
.dp-list li { padding: 6px 0; border-bottom: 1px solid #1a2a3a; list-style: none; }
.dp-list li .name { color: #4A90D9; font-weight: 500; }
.dp-list li .meta { color: #667; font-size: 12px; margin-left: 8px; }

#tooltip {
  position: absolute; pointer-events: none; background: rgba(20,30,43,0.95);
  border: 1px solid #2a3a4a; border-radius: 8px; padding: 8px 14px;
  font-size: 13px; color: #eee; display: none; z-index: 300; max-width: 300px;
}

#legend {
  position: absolute; bottom: 20px; left: 20px; background: rgba(20,30,43,0.9);
  border: 1px solid #2a3a4a; border-radius: 8px; padding: 12px 16px; z-index: 50;
}
.lg-item { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #aab; margin: 3px 0; }
.lg-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

/* Modal */
#modal-overlay { position: fixed; inset:0; background:rgba(0,0,0,0.6); z-index:1000; }
#modal-overlay.hidden, #modal.hidden { display:none; }
#modal {
  position: fixed; top:50%; left:50%; transform:translate(-50%,-50%);
  width:80vw; max-width:900px; max-height:85vh; overflow-y:auto;
  background:#141e2b; border:1px solid #2a3a4a; border-radius:12px;
  padding:28px; z-index:1001;
}
#modal-content { color:#e0e0e0; }
#modal-close { top:16px; right:16px; font-size:24px; }

/* Analysis page */
.analysis-grid { display:grid; grid-template-columns:1fr 1fr; gap:20px; margin-top:16px; }
.analysis-card {
  background:#1a2a3a; border:1px solid #2a3a4a; border-radius:10px; padding:16px;
}
.analysis-card h3 { font-size:15px; font-weight:600; color:#aabbcc; margin-bottom:10px; }
.analysis-card .ai { font-size:13px; padding:4px 0; }
.analysis-card .ai .big { color:#4A90D9; font-size:28px; font-weight:700; }
.analysis-card .ai .unit { color:#667; font-size:13px; }
.gap-item { padding:8px 0; border-bottom:1px solid #253545; font-size:13px; }
.gap-item:last-child { border:0; }
.gap-item .chain-name { color:#E8A838; font-weight:600; }
.gap-item .gap-desc { color:#E85A5A; }
.gap-item .sol { color:#7BC47F; }

.city-card { font-size:13px; padding:6px 0; }
.city-card .city-name { color:#9B59B6; font-weight:600; }
.city-tag { display:inline-block; padding:1px 8px; border-radius:4px; font-size:11px; margin:0 4px; }
.city-tag.compete { background:#E85A5A22; color:#E85A5A; border:1px solid #E85A5A55; }
.city-tag.cooperate { background:#3498DB22; color:#3498DB; border:1px solid #3498DB55; }
.city-tag.complement { background:#2ECC7122; color:#2ECC71; border:1px solid #2ECC7155; }

@media (max-width: 768px) {
  #header { flex-direction: column; gap: 8px; text-align: center; }
  #header-stats { flex-wrap: wrap; justify-content: center; }
  #toolbar { flex-wrap: wrap; }
  #search-box { flex: 1; min-width: 200px; }
  #detail-panel { width: 100%; position: fixed; bottom: 0; left: 0; height: 50vh; z-index: 500; }
  #modal { width: 95vw; padding: 16px; }
  .analysis-grid { grid-template-columns: 1fr; }
}
