:root {
  --ink: #17202a;
  --muted: #65727f;
  --line: #dbe3e7;
  --paper: #f7f9f8;
  --panel: #ffffff;
  --green: #0b6b57;
  --red: #a92832;
  --gold: #c99022;
  --teal: #147a86;
  --blue: #315f9c;
  --shadow: 0 18px 45px rgba(23, 32, 42, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 360px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 24px;
  background: #ffffff;
  border-right: 1px solid var(--line);
}

.brand-row {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 14px;
  align-items: center;
}

.brand-row img {
  width: 64px;
  height: 64px;
  object-fit: contain;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 1.55rem;
  line-height: 1.15;
}

.brief {
  margin: 24px 0;
  padding: 18px;
  color: #27333f;
  background: #eef6f3;
  border: 1px solid #d3e7df;
  border-radius: 8px;
}

.brief p,
.notes p {
  line-height: 1.55;
}

.control-group {
  display: grid;
  gap: 8px;
  margin: 20px 0;
}

label {
  font-size: 0.82rem;
  font-weight: 800;
  color: #33424f;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

.segmented button,
select,
input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.segmented button {
  cursor: pointer;
  font-weight: 750;
}

.segmented button.active {
  color: #fff;
  background: var(--green);
  border-color: var(--green);
}

select,
input {
  padding: 0 12px;
}

.context {
  margin-top: 28px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.context h2 {
  font-size: 1rem;
}

.context ul {
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.55;
}

.workspace {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
}

.topbar h2 {
  margin: 0;
  font-size: clamp(1.4rem, 2.4vw, 2.3rem);
}

.source-pill {
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: #fff;
  white-space: nowrap;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.kpi-grid article,
.panel,
.map-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 22px rgba(23, 32, 42, 0.06);
}

.kpi-grid article {
  padding: 18px;
}

.kpi-grid span {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.kpi-grid strong {
  display: block;
  font-size: clamp(1.45rem, 2vw, 2rem);
}

.kpi-grid small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.35;
}

.map-band {
  position: relative;
  min-height: 560px;
  margin-bottom: 18px;
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

#map {
  position: relative;
  height: 640px;
  min-height: 560px;
  background: #dde6e4;
}

.map-svg {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, #e8f0ef 0%, #dce7e5 100%);
}

.map-svg path {
  cursor: pointer;
  vector-effect: non-scaling-stroke;
  transition: fill-opacity 0.16s ease, stroke-width 0.16s ease;
}

.map-svg path:hover,
.map-svg path.active {
  stroke: #17202a;
  stroke-width: 1.8;
  fill-opacity: 0.96;
}

.map-panel {
  position: absolute;
  right: 18px;
  bottom: 18px;
  width: min(360px, calc(100% - 36px));
  padding: 18px;
  z-index: 500;
}

.map-panel h3 {
  margin-bottom: 6px;
  font-size: 1.2rem;
}

.map-panel p {
  color: var(--muted);
  line-height: 1.45;
}

.map-panel dl {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 14px 0 0;
}

.map-panel dt {
  color: var(--muted);
  font-size: 0.75rem;
}

.map-panel dd {
  margin: 3px 0 0;
  font-weight: 850;
}

.analysis-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.panel {
  padding: 18px;
  min-width: 0;
}

.panel.wide {
  grid-column: 1 / -1;
}

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

.panel-head h3 {
  margin: 0;
}

.panel-head select {
  width: auto;
  min-width: 150px;
}

.panel-head span {
  color: var(--muted);
  font-size: 0.86rem;
}

.ranking-list {
  display: grid;
  gap: 10px;
}

.rank-item {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.rank-num {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  color: #fff;
  background: var(--red);
  border-radius: 50%;
  font-weight: 850;
  font-size: 0.8rem;
}

.rank-name {
  font-weight: 850;
}

.rank-meta {
  color: var(--muted);
  font-size: 0.8rem;
}

.rank-value {
  font-weight: 850;
  color: var(--green);
  white-space: nowrap;
}

.insight-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.insight {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.insight span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.insight strong {
  display: block;
  margin: 8px 0;
  font-size: 1.2rem;
}

.insight p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.notes {
  display: grid;
  gap: 10px;
}

.source-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.source-links a {
  padding: 9px 11px;
  color: #fff;
  background: var(--blue);
  border-radius: 8px;
  text-decoration: none;
  font-weight: 750;
}

.legend {
  position: absolute;
  left: 18px;
  bottom: 18px;
  z-index: 450;
  padding: 10px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 5px 20px rgba(23, 32, 42, 0.16);
  line-height: 1.4;
}

.legend i {
  display: inline-block;
  width: 16px;
  height: 12px;
  margin-right: 8px;
  vertical-align: middle;
}

.zoom-tools {
  position: absolute;
  left: 18px;
  top: 18px;
  z-index: 450;
  display: grid;
  gap: 6px;
}

.zoom-tools button {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 5px 16px rgba(23, 32, 42, 0.12);
  cursor: pointer;
  font-weight: 900;
}

.map-empty {
  display: grid;
  place-items: center;
  height: 100%;
  padding: 24px;
  text-align: center;
  color: var(--muted);
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .segmented {
    grid-template-columns: repeat(3, 1fr);
  }

  .kpi-grid,
  .insight-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .workspace,
  .sidebar {
    padding: 16px;
  }

  .topbar,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .source-pill {
    white-space: normal;
  }

  .kpi-grid,
  .analysis-grid,
  .insight-grid {
    grid-template-columns: 1fr;
  }

  .segmented {
    grid-template-columns: 1fr;
  }

  #map {
    height: 560px;
  }

  .map-panel {
    position: relative;
    right: auto;
    bottom: auto;
    width: auto;
    margin: -150px 12px 12px;
  }

  .rank-item {
    grid-template-columns: 34px 1fr;
  }

  .rank-value {
    grid-column: 2;
  }
}
