:root {
    --bg0: #070B16;
    --bg1: #0B1220;
    --panel: rgba(255, 255, 255, .05);
    --border: rgba(255, 255, 255, .10);
    --text: #EAF1FF;
    --muted: #9FB1D1;
    --accent: #6EA8FE;
    --shadow: 0 14px 34px rgba(0, 0, 0, .35);
    --radius: 16px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial;
    color: var(--text);
    background:
        radial-gradient(900px 500px at 18% 0%, rgba(110, 168, 254, .22) 0%, rgba(110, 168, 254, 0) 60%),
        radial-gradient(900px 500px at 70% 10%, rgba(73, 211, 255, .14) 0%, rgba(73, 211, 255, 0) 55%),
        linear-gradient(180deg, var(--bg0) 0%, var(--bg1) 65%);
    height: 100vh;
    overflow: hidden;
}

.topbar {
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    background: rgba(6, 10, 22, .55);
    backdrop-filter: blur(10px);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(110, 168, 254, .95), rgba(73, 211, 255, .75));
    box-shadow: 0 10px 24px rgba(110, 168, 254, .18);
    border: 1px solid rgba(255, 255, 255, .18);
}

.title {
    font-size: 14px;
    letter-spacing: .2px;
}

.subtitle {
    font-size: 11px;
    color: var(--muted);
    margin-top: 2px;
}

.meta {
    display: flex;
    gap: 10px;
    align-items: center;
}

.pill {
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 11px;
    color: var(--muted);
    border: 1px solid rgba(255, 255, 255, .10);
    background: rgba(255, 255, 255, .04);
    white-space: nowrap;
}

.pill.subtle {
    background: rgba(255, 255, 255, .03);
    border-color: rgba(255, 255, 255, .08);
}

.layout {
    height: calc(100vh - 64px);
    display: grid;
    grid-template-columns: 420px 1fr;
    gap: 14px;
    padding: 14px;
    min-height: 0;
}

@media (max-width: 1100px) {
    body {
        overflow: auto;
        height: auto;
    }

    .layout {
        grid-template-columns: 1fr;
        height: auto;
    }
}

.panel {
    background: linear-gradient(180deg, rgba(255, 255, 255, .06), rgba(255, 255, 255, .03));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    min-height: 0;
}

.panelHeader {
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, .06);
    background: rgba(0, 0, 0, .14);
}

.panelTitle {
    font-size: 12px;
    color: var(--muted);
    letter-spacing: .3px;
    text-transform: uppercase;
}

.panelActions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.controls {
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

label {
    display: block;
    font-size: 11px;
    color: var(--muted);
    margin-bottom: 6px;
}

input,
select,
button {
    width: 100%;
    padding: 10px 10px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, .12);
    background: rgba(7, 11, 22, .55);
    color: var(--text);
    outline: none;
}

input::placeholder {
    color: rgba(233, 241, 255, .40);
}

.grid2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.btn {
    cursor: pointer;
    background: linear-gradient(180deg, rgba(110, 168, 254, .22), rgba(110, 168, 254, .10));
    border: 1px solid rgba(110, 168, 254, .35);
    transition: filter .12s ease, transform .05s ease;
}

.btn:hover {
    filter: brightness(1.07);
}

.btn:active {
    transform: translateY(1px);
}

.btn.secondary {
    background: rgba(255, 255, 255, .04);
    border: 1px solid rgba(255, 255, 255, .12);
}

.kpis {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.kpi {
    padding: 12px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, .08);
    background: rgba(0, 0, 0, .16);
}

.kpiValue {
    font-size: 18px;
    font-weight: 800;
}

.kpiLabel {
    font-size: 11px;
    color: var(--muted);
    margin-top: 3px;
}

.status {
    padding: 10px 12px;
    border-radius: 14px;
    border: 1px dashed rgba(255, 255, 255, .18);
    color: var(--muted);
    background: rgba(0, 0, 0, .14);
    font-size: 12px;
    line-height: 1.35;
}

.hint {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.35;
}

.mapPanel {
    display: flex;
    flex-direction: column;
}

.mapWrap {
    position: relative;
    flex: 1;
    min-height: 560px;
    overflow: hidden;
}

svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* IMPORTANT: Don’t make these too transparent, or you’ll think it’s “blank” */
.country {
    stroke: rgba(10, 16, 32, .85);
    stroke-width: .6px;
    opacity: 1;
}

.country.noData {
    fill: rgba(255, 255, 255, .06);
    opacity: 0.55;
}

.country.filtered {
    opacity: 0.20;
}

.country:hover {
    stroke: var(--accent);
    stroke-width: 1.4px;
}

.legend {
    position: absolute;
    left: 14px;
    bottom: 14px;
    width: 260px;
    background: rgba(6, 10, 22, .72);
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 14px;
    padding: 10px 10px;
    backdrop-filter: blur(10px);
    box-shadow: 0 14px 30px rgba(0, 0, 0, .35);
}

.legendTitle {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 8px;
}

.legendBar {
    height: 10px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, .14);
    background: linear-gradient(90deg, #7a1f1f, #c2572a, #d8c84b, #63c26a, #2a9d8f, #2f6fed);
}

.legendMinMax {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    font-size: 11px;
    color: var(--muted);
}

.tooltip {
    position: absolute;
    pointer-events: none;
    padding: 10px 10px;
    border-radius: 14px;
    background: rgba(6, 10, 22, .92);
    border: 1px solid rgba(255, 255, 255, .14);
    box-shadow: 0 14px 26px rgba(0, 0, 0, .40);
    font-size: 12px;
    line-height: 1.35;
    opacity: 0;
    transform: translate(-50%, -110%);
    white-space: nowrap;
}

:root{
  --bg0:#070B16; --bg1:#0B1220;
  --text:#EAF1FF; --muted:#9FB1D1;
  --border:rgba(255,255,255,.10);
  --accent:#6EA8FE;
  --shadow: 0 14px 34px rgba(0,0,0,.35);
  --radius:16px;
}
*{ box-sizing:border-box; }

body{
  margin:0; height:100vh; overflow:hidden;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial;
  color:var(--text);
  background:
    radial-gradient(900px 500px at 18% 0%, rgba(110,168,254,.22) 0%, rgba(110,168,254,0) 60%),
    linear-gradient(180deg, var(--bg0) 0%, var(--bg1) 65%);
}

.topbar{
  height:64px;
  display:flex; align-items:center; justify-content:space-between;
  padding:14px 18px;
  border-bottom:1px solid rgba(255,255,255,.08);
  background: rgba(6,10,22,.55);
  backdrop-filter: blur(10px);
}
.brand{ display:flex; gap:12px; align-items:center; }
.logo{
  width:34px; height:34px; border-radius:10px;
  background: linear-gradient(135deg, rgba(110,168,254,.95), rgba(73,211,255,.75));
  border:1px solid rgba(255,255,255,.18);
  box-shadow: 0 10px 24px rgba(110,168,254,.18);
}
.title{ font-size:14px; letter-spacing:.2px; }
.subtitle{ font-size:11px; color:var(--muted); margin-top:2px; }

.meta{ display:flex; gap:10px; align-items:center; }
.pill{
  padding:6px 10px; border-radius:999px;
  font-size:11px; color:var(--muted);
  border:1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.04);
}
.pill.subtle{ background: rgba(255,255,255,.03); border-color: rgba(255,255,255,.08); }

.layout{
  height: calc(100vh - 64px);
  display:grid; grid-template-columns: 420px 1fr;
  gap:14px; padding:14px; min-height:0;
}
.panel{
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.03));
  border:1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow:hidden; min-height:0;
}
.panelHeader{
  padding:12px 14px;
  display:flex; align-items:center; justify-content:space-between;
  border-bottom:1px solid rgba(255,255,255,.06);
  background: rgba(0,0,0,.14);
}
.panelTitle{
  font-size:12px; color:var(--muted);
  letter-spacing:.3px; text-transform: uppercase;
}
.controls{ padding:14px; display:flex; flex-direction:column; gap:12px; }
.grid2{ display:grid; grid-template-columns: 1fr 1fr; gap:10px; }

label{ display:block; font-size:11px; color:var(--muted); margin-bottom:6px; }
input, select, button{
  width:100%;
  padding:10px 10px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,.12);
  background: rgba(7,11,22,.55);
  color: var(--text);
  outline:none;
}
input::placeholder{ color: rgba(233,241,255,.40); }

.btn{
  cursor:pointer;
  background: linear-gradient(180deg, rgba(110,168,254,.22), rgba(110,168,254,.10));
  border:1px solid rgba(110,168,254,.35);
}
.btn.secondary{
  background: rgba(255,255,255,.04);
  border:1px solid rgba(255,255,255,.12);
}

.kpis{ display:grid; grid-template-columns: 1fr 1fr; gap:10px; }
.kpi{
  padding:12px; border-radius:14px;
  border:1px solid rgba(255,255,255,.08);
  background: rgba(0,0,0,.16);
}
.kpiValue{ font-size:18px; font-weight:800; }
.kpiLabel{ font-size:11px; color:var(--muted); margin-top:3px; }

.status{
  padding:10px 12px;
  border-radius:14px;
  border:1px dashed rgba(255,255,255,.18);
  color:var(--muted);
  background: rgba(0,0,0,.14);
  font-size:12px;
}

.mapPanel{ display:flex; flex-direction:column; }
.mapWrap{ position:relative; flex:1; min-height:560px; overflow:hidden; }
svg{ width:100%; height:100%; display:block; }

.country{
  stroke: rgba(10,16,32,.85);
  stroke-width: .6px;
}
.country.noData{
  fill: rgba(255,255,255,.06);
  opacity: 0.55;
}
.country.filtered{ opacity: 0.20; }
.country:hover{
  stroke: var(--accent);
  stroke-width: 1.4px;
}

.legend{
  position:absolute; left:14px; bottom:14px; width:260px;
  background: rgba(6,10,22,.72);
  border:1px solid rgba(255,255,255,.12);
  border-radius:14px;
  padding:10px 10px;
  backdrop-filter: blur(10px);
  box-shadow: 0 14px 30px rgba(0,0,0,.35);
}
.legendTitle{ font-size:12px; color:var(--muted); margin-bottom:8px; }
.legendBar{
  height:10px; border-radius:999px;
  border:1px solid rgba(255,255,255,.14);
  background: linear-gradient(90deg, #7a1f1f, #c2572a, #d8c84b, #63c26a, #2a9d8f, #2f6fed);
}
.legendMinMax{ display:flex; justify-content:space-between; margin-top:6px; font-size:11px; color:var(--muted); }

.tooltip{
  position:absolute; pointer-events:none;
  padding:10px 10px;
  border-radius:14px;
  background: rgba(6,10,22,.92);
  border:1px solid rgba(255,255,255,.14);
  box-shadow: 0 14px 26px rgba(0,0,0,.40);
  font-size:12px; line-height:1.35;
  opacity:0;
  transform: translate(-50%, -110%);
  white-space:nowrap;
}

/* --- TI-style hover card --- */
.hoverCard{
  position:absolute;
  right:18px;
  top:18px;
  width: 320px;
  background: rgba(255,255,255,.96);
  color:#111;
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(0,0,0,.18);
  border: 1px solid rgba(0,0,0,.08);
  padding: 16px;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity .12s ease, transform .12s ease;
  pointer-events:none;
}
.hoverCard.show{
  opacity: 1;
  transform: translateY(0);
}
.hcTitle{
  font-weight: 900;
  font-size: 26px;
  letter-spacing: .5px;
  text-transform: uppercase;
}
.hcMeta{
  display:flex;
  gap:18px;
  margin-top:10px;
  margin-bottom:14px;
}
.hcMetric{ flex:1; }
.hcLabel{
  font-size:12px;
  color:#555;
  font-weight:700;
  text-transform: uppercase;
  letter-spacing: .3px;
}
.hcValue{
  margin-top:6px;
  font-size:22px;
  font-weight:900;
}
.hcSmall{
  font-size:14px;
  font-weight:700;
  color:#555;
  margin-left:4px;
}

/* Segmented bar */
.hcBarWrap{
  position:relative;
  height: 32px;
}
.hcBar{
  position:absolute;
  left:0; right:0;
  top: 10px;
  height: 12px;
  border-radius: 2px;
  overflow:hidden;
  display:flex;
  border: 1px solid rgba(0,0,0,.12);
}
.hcSeg{
  height: 100%;
  flex: 1;
}
.hcMarker{
  position:absolute;
  top: 4px;
  width: 2px;
  height: 24px;
  background:#111;
  left: 0;
  transform: translateX(-1px);
}
.hcAvg{
  position:absolute;
  top: 8px;
  width: 2px;
  height: 16px;
  background: rgba(0,0,0,.30);
  left: 0;
  transform: translateX(-1px);
}
.hcAvgLabel{
  position:absolute;
  top: 26px;
  right:0;
  font-size:10px;
  color:#666;
  font-weight:800;
  letter-spacing:.3px;
  text-transform: uppercase;
}

.hcBadge{
  display:inline-block;
  margin-top:8px;
  padding:4px 10px;
  border-radius:999px;
  font-size:11px;
  font-weight:900;
  letter-spacing:.3px;
  text-transform: uppercase;
  border:1px solid rgba(0,0,0,.10);
  background: rgba(0,0,0,.04);
  color:#111;
}

/* Tier colors (subtle, exec-friendly) */
.hcBadge[data-tier="elite"]     { background:#e8fff0; border-color:#9be2b2; }
.hcBadge[data-tier="top10"]     { background:#f0fff7; border-color:#b7efcf; }
.hcBadge[data-tier="top25"]     { background:#f6fff2; border-color:#cdebb2; }
.hcBadge[data-tier="midHigh"]   { background:#fffdf0; border-color:#efe1a6; }
.hcBadge[data-tier="midLow"]    { background:#fff6ee; border-color:#f1c8a6; }
.hcBadge[data-tier="bottom25"]  { background:#fff0f0; border-color:#f0b1b1; }
.hcBadge[data-tier="bottom10"]  { background:#ffe8e8; border-color:#ee9a9a; }
.hcBadge[data-tier="bottom5"]   { background:#ffdede; border-color:#e67878; }
.hcBadge[data-tier="unranked"]  { background:#f2f2f2; border-color:#d0d0d0; color:#333; }

.legend.hidden {
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}

/* =========================
   Responsive (Tablet/Mobile)
   ========================= */

/* Tablet: stack panels, keep card smaller */
@media (max-width: 1100px) {
  body { overflow: auto; height: auto; }
  .layout {
    grid-template-columns: 1fr;
    height: auto;
  }
  .mapWrap { min-height: 520px; }
}

/* Mobile: map first, filters below (optional), hover card becomes bottom sheet */
@media (max-width: 720px) {
  .topbar {
    height: auto;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .meta {
    width: 100%;
    flex-wrap: wrap;
    gap: 8px;
  }
  .layout {
    padding: 10px;
    gap: 10px;
  }

  /* Make panels breathe on small screens */
  .panelHeader { padding: 10px 12px; }
  .controls { padding: 12px; }
  .grid2 { grid-template-columns: 1fr; } /* stack inputs */

  /* Map */
  .mapWrap { min-height: 520px; }


  /* Hover card -> bottom sheet */
  .hoverCard {
    right: 10px;
    left: 10px;
    top: auto;
    bottom: 10px;
    width: auto;
    border-radius: 14px;
    padding: 14px;
    transform: translateY(10px);
    max-height: 42vh;
    overflow-y: auto;
  }
  .hoverCard.show { transform: translateY(0); }

  .hcTitle { font-size: 20px; }
  .hcMeta { gap: 12px; }
  .hcValue { font-size: 18px; }

  /* Legend smaller */
  .legend {
    left: 10px;
    bottom: 86px; /* leave room for bottom sheet */
    width: 220px;
    padding: 8px 8px;
  }
}

/* Very small devices */
@media (max-width: 420px) {
  .legend { width: 200px; }
  .hcTitle { font-size: 18px; }
}
