:root {
  --ink: #14213d;
  --muted: #64748b;
  --line: #dbe4ee;
  --panel: #ffffff;
  --bg: #eef3f7;
  --blue: #22577a;
  --teal: #2d9c8b;
  --orange: #c76f2c;
  --green: #3d7c48;
  --red: #b54747;
  --soft-blue: #e6f0f6;
  --soft-green: #e4f3ec;
  --soft-orange: #f8eadf;
  font-family: "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 30px;
  background: #132f4c;
  color: #fff;
  border-bottom: 4px solid #2d9c8b;
}

.eyebrow {
  margin: 0 0 4px;
  color: #9ed8d0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.2;
}

h2 {
  font-size: 17px;
  line-height: 1.25;
}

.meta {
  display: flex;
  align-items: center;
  gap: 16px;
  color: #c9d8e4;
  font-size: 13px;
  white-space: nowrap;
}

.meta a {
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.55);
}

.shell {
  max-width: 1560px;
  margin: 0 auto;
  padding: 18px 22px 32px;
}

.filters {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) 210px minmax(240px, 0.6fr);
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}

.field {
  display: grid;
  gap: 6px;
}

label {
  color: #425466;
  font-size: 12px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  height: 38px;
  padding: 0 11px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
}

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

.kpi,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(20, 33, 61, 0.06);
}

.kpi {
  min-height: 112px;
  padding: 15px 16px;
  display: grid;
  align-content: space-between;
}

.kpi span,
.kpi small {
  color: var(--muted);
  font-size: 12px;
}

.kpi strong {
  display: block;
  margin: 8px 0 5px;
  font-size: 25px;
  line-height: 1.08;
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
  gap: 14px;
}

.map-grid {
  display: grid;
  grid-template-columns: 1fr;
  margin-bottom: 14px;
}

.wide-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.65fr);
  gap: 14px;
  margin-top: 14px;
}

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

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

.map-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 280px;
}

.map-wrap {
  position: relative;
  overflow: hidden;
  border: 1px solid #dce7f1;
  border-radius: 7px;
  background: #f8fbfe;
}

.sa2-map {
  display: block;
  width: 100%;
  height: 560px;
  cursor: crosshair;
}

.map-sa2 {
  stroke: rgba(255, 255, 255, 0.82);
  stroke-width: 0.8;
  vector-effect: non-scaling-stroke;
  cursor: pointer;
  transition: fill 120ms ease, stroke 120ms ease, opacity 120ms ease;
}

.map-sa2:hover,
.map-sa2.is-hovered {
  stroke: #0f172a;
  stroke-width: 2;
  opacity: 1;
}

.map-sa2.is-selected {
  stroke: #111827;
  stroke-width: 2.6;
  filter: drop-shadow(0 2px 3px rgba(15, 23, 42, 0.35));
}

.map-tooltip {
  position: absolute;
  z-index: 4;
  min-width: 210px;
  max-width: 280px;
  padding: 10px 11px;
  border-radius: 7px;
  color: #fff;
  background: rgba(15, 23, 42, 0.94);
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.22);
  pointer-events: none;
  font-size: 12px;
  line-height: 1.35;
}

.map-tooltip strong {
  display: block;
  margin-bottom: 5px;
  font-size: 13px;
}

.map-legend {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.legend-swatch {
  width: 42px;
  height: 11px;
  border-radius: 2px;
  border: 1px solid rgba(15, 23, 42, 0.12);
}

.panel-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--soft-blue);
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.chart,
.scatter {
  display: block;
  width: 100%;
  height: 320px;
  border: 1px solid #edf2f7;
  border-radius: 6px;
  background: #fbfdff;
}

.scatter {
  height: 360px;
}

.table-wrap {
  overflow: auto;
  max-height: 360px;
  border: 1px solid #edf2f7;
  border-radius: 6px;
}

.metric-table {
  max-height: 360px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

th,
td {
  padding: 8px 9px;
  border-bottom: 1px solid #edf2f7;
  text-align: right;
  white-space: nowrap;
}

th:first-child,
td:first-child,
td:last-child,
th:last-child {
  text-align: left;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: #fff;
  background: var(--blue);
  font-weight: 700;
}

tbody tr {
  cursor: pointer;
}

tbody tr:nth-child(even) {
  background: #f9fbfd;
}

tbody tr:hover {
  background: #eaf6f3;
}

.checks-list {
  display: grid;
  gap: 8px;
  max-height: 360px;
  overflow: auto;
}

.check {
  padding: 10px;
  border: 1px solid #edf2f7;
  border-radius: 6px;
  background: #fbfdff;
}

.check strong {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
}

.check span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.axis {
  stroke: #b8c7d6;
  stroke-width: 1;
}

.grid-line {
  stroke: #e7eef6;
  stroke-width: 1;
}

.label {
  fill: #52677a;
  font-size: 11px;
}

.series-vif {
  fill: none;
  stroke: var(--blue);
  stroke-width: 3;
}

.series-atlas {
  fill: none;
  stroke: var(--orange);
  stroke-width: 3;
}

.series-income {
  fill: none;
  stroke: var(--green);
  stroke-width: 3;
}

.dot-vif {
  fill: var(--blue);
}

.dot-atlas {
  fill: var(--orange);
}

.dot-income,
.dot-selected {
  fill: var(--green);
}

.dot-muted {
  fill: #9aaec1;
  opacity: 0.42;
}

.dot-selected {
  stroke: #0f172a;
  stroke-width: 2;
  opacity: 1;
}

.legend {
  fill: #1f2937;
  font-size: 12px;
  font-weight: 700;
}

@media (max-width: 980px) {
  .topbar,
  .meta {
    align-items: flex-start;
    flex-direction: column;
  }

  .filters,
  .kpi-grid,
  .map-grid,
  .main-grid,
  .wide-grid {
    grid-template-columns: 1fr;
  }

  .sa2-map {
    height: 420px;
  }

  .chart,
  .scatter {
    height: 280px;
  }
}
