:root {
  --bg: #f3f7fd;
  --surface: #ffffff;
  --surface-soft: #f8fbff;
  --line: #d8e3f2;
  --text: #14233b;
  --muted: #6f7e95;
  --blue: #1f6fe5;
  --blue-soft: #eaf2ff;
  --green: #1fa774;
  --green-soft: #ebfaf4;
  --amber: #d89714;
  --amber-soft: #fff6dd;
  --purple: #6a47d4;
  --purple-soft: #f1ebff;
  --shadow: 0 20px 60px rgba(17, 39, 74, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", sans-serif;
}

body {
  min-height: 100vh;
}

button,
input,
select {
  font: inherit;
}

.dashboard-shell {
  min-height: 100vh;
}

.workspace {
  max-width: 1540px;
  margin: 0 auto;
  padding: 20px 24px 28px;
}

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

.title-block h1 {
  margin: 0;
  font-size: clamp(1.9rem, 3vw, 2.55rem);
  letter-spacing: -0.04em;
  font-weight: 800;
}

.title-block p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 1.08rem;
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.meta-pill {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow);
  min-width: 132px;
  padding: 12px 14px;
}

.meta-label {
  display: block;
  color: var(--muted);
  font-size: 0.73rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.meta-pill strong {
  display: block;
  margin-top: 6px;
  font-size: 1rem;
}

.kpi-grid,
.content-grid,
.bottom-grid {
  display: grid;
  gap: 18px;
}

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

.kpi-card,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.kpi-card {
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 18px;
}

.kpi-icon {
  width: 78px;
  height: 78px;
  border-radius: 18px;
  display: grid;
  place-items: center;
}

.kpi-icon svg {
  width: 38px;
  fill: currentColor;
}

.kpi-icon.blue {
  background: var(--blue-soft);
  color: var(--blue);
}

.kpi-icon.green {
  background: var(--green-soft);
  color: var(--green);
}

.kpi-icon.amber {
  background: var(--amber-soft);
  color: var(--amber);
}

.kpi-icon.purple {
  background: var(--purple-soft);
  color: var(--purple);
}

.kpi-copy span {
  display: block;
  color: var(--muted);
  font-size: 1rem;
}

.kpi-copy strong {
  display: block;
  margin-top: 10px;
  font-size: clamp(2rem, 3vw, 2.7rem);
  font-weight: 800;
  letter-spacing: -0.04em;
}

.panel {
  padding: 16px;
}

.filter-bar {
  margin-bottom: 14px;
  position: relative;
}

.filter-row {
  display: grid;
  grid-template-columns: 220px 170px 170px minmax(220px, 1fr) 160px;
  gap: 12px;
  align-items: center;
}

.filter-group {
  position: relative;
}

.select-button,
.select-wrap select,
.search-wrap input,
.ghost-button {
  width: 100%;
  height: 46px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--text);
}

.select-button,
.ghost-button {
  padding: 0 14px;
  text-align: left;
  font-weight: 600;
  cursor: pointer;
}

.select-button::after {
  content: "▾";
  float: right;
  color: var(--muted);
}

.select-wrap select,
.search-wrap input {
  padding: 0 14px;
  outline: 0;
}

.search-wrap input::placeholder {
  color: #98a4b7;
}

.ghost-button {
  text-align: center;
  background: #f8fbff;
  color: var(--blue);
}

.dropdown-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 20;
  width: min(420px, 80vw);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(17, 39, 74, 0.16);
  padding: 14px;
}

.dropdown-panel[hidden] {
  display: none;
}

.dropdown-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.text-button {
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--blue);
  font-weight: 700;
  cursor: pointer;
}

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

.province-check {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f9fbff;
  padding: 10px 12px;
  font-size: 0.94rem;
}

.province-check input {
  accent-color: var(--blue);
}

.filter-summary {
  margin-top: 12px;
  min-height: 18px;
  color: var(--muted);
  font-size: 0.94rem;
}

.selection-chip {
  display: inline-flex;
  align-items: center;
  margin: 0 8px 8px 0;
  padding: 8px 12px;
  border-radius: 999px;
  background: #edf4ff;
  color: var(--blue);
  font-size: 0.82rem;
  font-weight: 700;
}

.content-grid {
  grid-template-columns: minmax(420px, 1.04fr) minmax(500px, 1.16fr) minmax(340px, 0.9fr);
  align-items: stretch;
}

.bottom-grid {
  grid-template-columns: 1fr 1fr 1fr;
  margin-top: 18px;
}

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

.section-head h2 {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.table-wrap {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid #e9eff7;
  text-align: left;
  vertical-align: top;
}

th {
  font-size: 0.79rem;
  color: var(--muted);
  font-weight: 700;
}

td {
  font-size: 0.93rem;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr.is-selected {
  background: #f4f8ff;
}

.municipality-button {
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--blue);
  font-weight: 700;
  cursor: pointer;
}

.municipality-button:hover {
  text-decoration: underline;
}

.chance-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 0.78rem;
  font-weight: 700;
}

.chance-badge.high {
  background: #def6ea;
  color: #19865f;
}

.chance-badge.medium {
  background: #fff1cf;
  color: #c18300;
}

.chance-badge.low {
  background: #e7eef9;
  color: #46698e;
}

.panel-footer {
  padding-top: 12px;
  color: var(--blue);
  font-weight: 600;
  font-size: 0.92rem;
}

.region-stage {
  min-height: 420px;
  border-radius: 16px;
  background: linear-gradient(180deg, #eef5ff 0%, #e3edf9 100%);
  border: 1px solid #d4e2f7;
  padding: 14px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nl-map {
  width: 100%;
  height: 100%;
  display: block;
  background: transparent;
}

#map-zoom-group {
  transform: translate(4px, -3px);
}

.province-shape {
  fill: #e6ecf4;
  stroke: #ffffff;
  stroke-width: 2.6;
  transition: fill 180ms ease, stroke 180ms ease, transform 180ms ease;
  cursor: pointer;
}

.province-shape:hover {
  stroke: rgba(31, 111, 229, 0.45);
}

.province-shape.is-selected {
  stroke: rgba(31, 111, 229, 0.9);
  stroke-width: 3.2;
}

.province-label {
  display: none;
}

.province-click-target {
  fill: transparent;
  cursor: pointer;
  pointer-events: all;
}

.profile-score-block {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 18px;
  align-items: center;
  margin-bottom: 18px;
}

.score-ring {
  --score-angle: 270deg;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background:
    conic-gradient(var(--green) var(--score-angle), #e8edf5 0);
  display: grid;
  place-items: center;
}

.score-ring-inner {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: #fff;
  display: grid;
  place-items: center;
  text-align: center;
}

.score-ring-inner strong {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
}

.score-ring-inner span {
  color: var(--muted);
  font-size: 0.92rem;
}

.score-breakdown {
  display: grid;
  gap: 10px;
}

.breakdown-row {
  display: grid;
  grid-template-columns: 1.2fr 1fr 42px;
  gap: 12px;
  align-items: center;
  font-size: 0.9rem;
}

.breakdown-label {
  color: var(--text);
}

.breakdown-bar {
  height: 8px;
  border-radius: 999px;
  background: #ebf0f7;
  overflow: hidden;
}

.breakdown-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #32b183, #1fa774);
}

.profile-section {
  margin-top: 16px;
}

.profile-section h3 {
  margin: 0 0 12px;
  font-size: 0.98rem;
}

.signal-bullets {
  margin: 0;
  padding-left: 18px;
  color: var(--text);
}

.signal-bullets li {
  margin-bottom: 10px;
  line-height: 1.45;
}

.action-card {
  border-radius: 14px;
  border: 1px solid #ffe4a3;
  background: linear-gradient(180deg, #fff9e7, #fff3cb);
  padding: 14px 16px;
  font-weight: 600;
  color: #6a4d00;
}

.chart-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: #fbfdff;
}

#trend-chart {
  width: 100%;
  height: 220px;
  display: block;
}

.chart-grid {
  stroke: #d8e3f2;
  fill: none;
}

.chart-line {
  fill: none;
  stroke: var(--blue);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-area {
  fill: rgba(31, 111, 229, 0.12);
}

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

.chart-text {
  fill: var(--muted);
  font-size: 12px;
}

.mix-layout {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 12px;
  align-items: center;
}

.donut-card {
  display: grid;
  place-items: center;
}

.donut-ring {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  position: relative;
}

.donut-hole {
  position: absolute;
  inset: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--line);
}

.mix-legend {
  display: grid;
  gap: 10px;
}

.legend-row {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  gap: 10px;
  align-items: center;
  font-size: 0.92rem;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.legend-value {
  color: var(--muted);
  font-weight: 600;
}

.pipeline-steps {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.pipeline-step {
  min-height: 80px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #f8fbff;
  display: grid;
  place-items: center;
  padding: 12px;
  text-align: center;
  font-weight: 700;
}

.pipeline-step.is-active {
  color: var(--blue);
}

.pipeline-step.is-live {
  color: var(--green);
  background: #eefaf5;
  border-color: rgba(31, 167, 116, 0.24);
}

.pipeline-arrow {
  height: 2px;
  background: linear-gradient(90deg, #9ebaea, #bfd3f3);
  border-radius: 999px;
}

.pipeline-note {
  margin-top: 16px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.55;
}

.status-ok {
  color: var(--green);
}

.status-error {
  color: #d04646;
}

.inline-link {
  color: var(--blue);
  text-decoration: none;
}

.inline-link:hover {
  text-decoration: underline;
}

.empty-state {
  border: 1px dashed var(--line);
  background: #fbfdff;
  border-radius: 14px;
  padding: 16px;
  color: var(--muted);
}

.muted {
  color: var(--muted);
}

@media (max-width: 1280px) {
  .content-grid {
    grid-template-columns: 1fr 1fr;
  }

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

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

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

@media (max-width: 1180px) {
  .workspace {
    padding: 20px;
  }

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

  .filter-row {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 860px) {
  .topbar {
    flex-direction: column;
  }

  .topbar-meta {
    width: 100%;
    flex-wrap: wrap;
  }

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

  .filter-row {
    grid-template-columns: 1fr;
  }

  .mix-layout,
  .profile-score-block {
    grid-template-columns: 1fr;
  }

  .region-stage {
    min-height: 360px;
  }

  .nl-map {
    height: 100%;
  }
}

@media (max-width: 640px) {
  .workspace {
    padding: 14px;
  }

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

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