* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 14px; color: #202124; overflow: hidden;
}
#map { position: absolute; inset: 0; background: #e8eaed; }

/* ---------- top bar ---------- */
#topbar {
  position: absolute; top: 10px; left: 10px; right: 10px; z-index: 1000;
  display: flex; align-items: flex-start; gap: 10px; pointer-events: none;
}
#topbar > * { pointer-events: auto; }

#searchwrap { position: relative; flex: 0 0 360px; }
#searchbox {
  display: flex; align-items: center; gap: 10px; height: 44px;
  background: #fff; border-radius: 8px; padding: 0 14px;
  box-shadow: 0 1px 4px rgba(0,0,0,.28);
}
#search { flex: 1; border: 0; outline: 0; font-size: 14.5px; background: transparent; min-width: 0; }
#clearsearch {
  border: 0; background: none; font-size: 20px; color: #5f6368;
  cursor: pointer; padding: 0 2px; display: none;
}
#suggestions {
  position: absolute; top: 48px; left: 0; right: 0; background: #fff;
  border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,.25); overflow: hidden;
}
.sug { display: flex; align-items: center; gap: 10px; padding: 9px 14px; cursor: pointer; }
.sug:hover, .sug.active { background: #f1f3f4; }
.sug .sub { color: #70757a; font-size: 12px; margin-left: auto; }
.sug svg { flex: none; }

/* one row, horizontally scrollable (desktop + mobile) */
#pills {
  display: flex; gap: 8px; align-items: center; flex: 1; min-width: 0;
  overflow-x: auto; padding-bottom: 6px;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
#pills::-webkit-scrollbar { display: none; }
.pill {
  display: inline-flex; align-items: center; gap: 7px; height: 34px; flex: none;
  background: #fff; border: 0; border-radius: 17px; padding: 0 14px;
  font-size: 13.5px; color: #3c4043; cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,.25); white-space: nowrap;
}
.pill:hover { background: #f8f9fa; }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; }
.pill.on { color: #fff; }
.pill.back { font-weight: 500; }
.pill.back .x { font-size: 16px; line-height: 1; margin-left: 2px; }
.pill-sep { width: 1px; height: 22px; background: rgba(0,0,0,.18); margin: 0 2px; flex: none; }
.pill.small { height: 30px; font-size: 12.5px; padding: 0 12px; }
.datepill { gap: 6px; padding: 0 10px 0 12px; }
.datepill select {
  border: 0; background: transparent; font-size: 12.5px; color: #3c4043;
  outline: 0; cursor: pointer; -webkit-appearance: none; appearance: none; padding-right: 2px;
}

/* ---------- left panel ---------- */
#panel {
  position: absolute; top: 64px; left: 10px; bottom: 10px; width: 400px; z-index: 999;
  background: #fff; border-radius: 8px; box-shadow: 0 1px 4px rgba(0,0,0,.28);
  overflow-y: auto; overscroll-behavior: contain;
}
#panel::-webkit-scrollbar { width: 8px; }
#panel::-webkit-scrollbar-thumb { background: #dadce0; border-radius: 4px; }

.panel-head { padding: 16px 18px 10px; border-bottom: 1px solid #e8eaed; position: sticky; top: 0; background: #fff; z-index: 2; }
.panel-head h1 { font-size: 18px; font-weight: 500; padding-right: 24px; }
.panel-head .meta { color: #70757a; font-size: 12.5px; margin-top: 2px; }
.panel-head .bigrow { display: flex; gap: 24px; margin-top: 10px; }
.panel-head .big .v { font-size: 20px; font-weight: 500; }
.panel-head .big .k { font-size: 11.5px; color: #70757a; }
.closebtn {
  position: absolute; top: 12px; right: 12px; border: 0; background: none;
  font-size: 20px; color: #5f6368; cursor: pointer; padding: 4px;
}
.backbtn {
  border: 0; background: none; color: #1a73e8; cursor: pointer;
  font-size: 13px; padding: 0; margin-bottom: 6px; display: inline-flex; align-items: center; gap: 4px;
}

.tabs { display: flex; gap: 2px; margin-top: 12px; border-bottom: 0; }
.tab {
  border: 0; background: none; padding: 8px 14px; font-size: 13px; color: #5f6368;
  cursor: pointer; border-bottom: 2.5px solid transparent;
}
.tab.on { color: #1a73e8; border-bottom-color: #1a73e8; font-weight: 500; }

.facts { padding: 6px 0; border-bottom: 1px solid #f1f3f4; }
.fact { display: flex; justify-content: space-between; gap: 12px; padding: 7px 18px; font-size: 13px; }
.fact .k { color: #70757a; }
.fact .v { font-weight: 500; text-align: right; }
.fact.link { cursor: pointer; }
.fact.link:hover { background: #f8f9fa; }
.fact.link .v { color: #1a73e8; }

.rows { padding: 6px 0; }
.row { display: flex; align-items: center; gap: 12px; padding: 9px 18px; cursor: pointer; }
.row:hover { background: #f8f9fa; }
.row.sel { background: #e8f0fe; }
.row .rank { width: 22px; color: #70757a; font-size: 12px; text-align: right; flex: none; }
.row .info { flex: 1; min-width: 0; }
.row .name { font-size: 13.5px; }
.row .type { font-size: 11.5px; color: #70757a; }
.row .val { font-size: 13.5px; font-weight: 500; text-align: right; flex: none; }
.row .val .sub { display: block; font-weight: 400; font-size: 11px; color: #70757a; }
.row .bar { height: 3px; border-radius: 2px; margin-top: 4px; background: #1a73e8; }

.sec {
  padding: 14px 18px 6px; font-size: 11.5px; font-weight: 500; color: #70757a;
  text-transform: uppercase; letter-spacing: .4px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.sortsel {
  border: 1px solid #dadce0; border-radius: 6px; background: #fff; color: #3c4043;
  font-size: 12px; padding: 3px 6px; outline: 0; cursor: pointer; text-transform: none; letter-spacing: 0;
}
.seeall {
  border: 0; background: none; color: #1a73e8; font-size: 12px; cursor: pointer;
  text-transform: none; letter-spacing: 0; padding: 0;
}

.catrow { display: flex; align-items: center; gap: 10px; padding: 7px 18px; cursor: pointer; }
.catrow:hover { background: #f8f9fa; }
.catrow .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.catrow .nm { flex: 1; font-size: 13px; }
.catrow .amt { font-size: 13px; font-weight: 500; }
.catrow .pct { font-size: 11.5px; color: #70757a; width: 34px; text-align: right; }
.catbar { height: 4px; background: #f1f3f4; border-radius: 2px; margin: 0 18px 2px 37px; overflow: hidden; }
.catbar > div { height: 100%; border-radius: 2px; }

.suprow { display: flex; align-items: center; gap: 10px; padding: 8px 18px; cursor: pointer; }
.suprow:hover { background: #f8f9fa; }
.suprow.selfrow { background: #f0f6ff; }
.suprow .rank { width: 18px; color: #70757a; font-size: 12px; text-align: right; flex: none; }
.suprow .logo {
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 600; color: #fff;
}
.suprow .nm { flex: 1; font-size: 13px; min-width: 0; }
.suprow .nm .cat { display: block; font-size: 11px; color: #70757a; }
.suprow .amt { font-size: 13px; font-weight: 500; flex: none; }
.minibar { display: block; height: 3px; background: #f1f3f4; border-radius: 2px; margin-top: 4px; overflow: hidden; }
.minibar > span { display: block; height: 100%; border-radius: 2px; }
.badge {
  display: inline-block; font-size: 10px; font-weight: 600; color: #188038;
  background: #e6f4ea; border-radius: 4px; padding: 1px 5px; margin-left: 4px; vertical-align: 1px;
}

.chiprow { display: flex; gap: 6px; flex-wrap: wrap; padding: 2px 18px 8px; }
.chip {
  border: 1px solid #dadce0; background: #fff; border-radius: 14px; height: 26px;
  padding: 0 11px; font-size: 12px; color: #3c4043; cursor: pointer; white-space: nowrap;
}
.chip.on { background: #3c4043; border-color: transparent; color: #fff; }

.comparebox { margin-top: 10px; }
.comparebox input {
  width: 100%; border: 1px solid #dadce0; border-radius: 8px; height: 32px;
  padding: 0 10px; font-size: 12.5px; outline: 0; color: #202124;
}
.comparebox input:focus { border-color: #1a73e8; }

/* compare tornado */
.cmp-names { display: flex; align-items: baseline; gap: 8px; margin-top: 8px; }
.cmp-names button { border: 0; background: none; font-size: 15px; font-weight: 600; cursor: pointer; padding: 0; }
.cmp-names span { color: #70757a; font-size: 12px; }
.cmp-row {
  display: grid; grid-template-columns: 1fr 108px 1fr; align-items: center; gap: 8px;
  padding: 5px 18px; font-size: 12.5px;
}
.cmp-row .cl { text-align: center; color: #5f6368; font-size: 11.5px; line-height: 1.25; }
.cmp-row .cv { display: flex; align-items: center; gap: 6px; font-weight: 500; }
.cmp-row .cv.a { justify-content: flex-end; }
.cmp-row .cv.b { justify-content: flex-start; }
.cbar { flex: 1; max-width: 90px; height: 6px; background: #f1f3f4; border-radius: 3px; overflow: hidden; }
.cv.a .cbar { transform: scaleX(-1); }
.cbar > span { display: block; height: 100%; border-radius: 3px; }
.cmp-stat { padding: 3px 0; }
.cmp-stat .cv { font-size: 14px; }

.trendwrap { padding: 8px 18px 18px; }
.trendwrap svg { width: 100%; height: 78px; }
.empty { padding: 20px 18px; color: #70757a; font-size: 13px; }

/* ---------- legend ---------- */
#legend {
  position: absolute; right: 10px; bottom: 24px; z-index: 998;
  background: #fff; border-radius: 8px; padding: 10px 12px; width: 190px;
  box-shadow: 0 1px 4px rgba(0,0,0,.28);
}
#legend-title { font-size: 11px; color: #3c4043; font-weight: 500; margin-bottom: 6px; }
#legend-bar { height: 8px; border-radius: 4px; }
#legend-labels { display: flex; justify-content: space-between; font-size: 10.5px; color: #70757a; margin-top: 3px; }

#datanote {
  position: absolute; left: 10px; bottom: 6px; z-index: 998;
  font-size: 10.5px; color: #5f6368; background: rgba(255,255,255,.85);
  padding: 2px 8px; border-radius: 4px;
}

.leaflet-container { font: inherit; }
.leaflet-tooltip.spendtip {
  background: #202124; color: #fff; border: 0; border-radius: 6px;
  box-shadow: 0 2px 6px rgba(0,0,0,.3); padding: 6px 10px; font-size: 12px;
}
.leaflet-tooltip.spendtip::before { display: none; }
.spendtip .tv { font-weight: 600; }
.spendtip .tp { color: #bdc1c6; font-size: 10.5px; }

/* ---------- mobile: stacked bar, scrollable pills, bottom sheet ---------- */
@media (max-width: 760px) {
  #topbar { flex-direction: column; gap: 8px; align-items: stretch; }
  #searchwrap { flex: none; width: 100%; }
  #pills { width: 100%; }
  #panel {
    top: auto; left: 0; right: 0; bottom: 0; width: auto; height: 52%;
    border-radius: 14px 14px 0 0;
  }
  #legend { bottom: auto; top: 104px; right: 10px; width: 150px; }
  #datanote { display: none; }
  .cmp-row { grid-template-columns: 1fr 92px 1fr; padding: 5px 12px; }
}
