:root {
  --ink: #17202a;
  --muted: #657386;
  --line: #dfe5ec;
  --surface: #ffffff;
  --soft: #f5f7fa;
  --accent: #b4233a;
  --teal: #0f766e;
  --amber: #f4c95d;
  --orange: #ef8a47;
  --red: #d64550;
  --shadow: 0 18px 40px rgba(23, 32, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body.map-dashboard {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background: #f3f6f8;
  color: var(--ink);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

.dashboard-nav.navbar-custom {
  background: rgba(18, 24, 33, 0.96);
  border: 0;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08);
}

.dashboard-nav .navbar-brand,
.dashboard-nav .navbar-nav > li > a {
  color: #f7f9fb;
  letter-spacing: 0;
}

.dashboard-nav .navbar-nav > li > a:hover,
.dashboard-nav .navbar-brand:hover {
  color: #ffffff;
}

.dashboard-shell {
  width: min(1840px, calc(100% - 32px));
  margin: 0 auto;
  padding: 88px 0 40px;
}

.dashboard-head {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(420px, 820px);
  gap: 20px;
  align-items: end;
  margin-bottom: 18px;
}

.dashboard-title h1 {
  margin: 6px 0 6px;
  font-size: clamp(30px, 4vw, 54px);
  line-height: 1;
  font-weight: 800;
  color: var(--ink);
}

.dashboard-title p {
  max-width: 860px;
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  white-space: normal !important;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.section-kicker {
  display: block;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.filter-bar {
  display: grid;
  grid-template-columns: minmax(180px, 2fr) minmax(110px, 0.75fr) minmax(130px, 0.9fr) auto;
  gap: 10px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.filter-bar label {
  display: grid;
  gap: 5px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.filter-select,
.search-box input {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  font-size: 14px;
  outline: none;
}

.filter-select {
  padding: 0 36px 0 12px;
}

.filter-select:focus,
.search-box input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.primary-action,
.icon-action,
.detail-link,
.table-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 6px;
  text-decoration: none;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.primary-action {
  align-self: end;
  min-height: 42px;
  padding: 0 16px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 800;
}

.primary-action:hover,
.detail-link:hover,
.table-link:hover,
.icon-action:hover {
  transform: translateY(-1px);
}

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

.data-note {
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 1px solid #f0c9d1;
  border-radius: 8px;
  background: #fff8fa;
  color: #4f1724;
  font-size: 13px;
  line-height: 1.45;
}

.data-note strong {
  color: #b4233a;
}

.data-note a {
  color: #8f1730;
  font-weight: 800;
}

.metric-card {
  min-height: 112px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 10px 24px rgba(23, 32, 42, 0.05);
}

.metric-card span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.metric-card strong {
  display: block;
  color: var(--ink);
  font-size: clamp(22px, 2.3vw, 34px);
  line-height: 1.05;
  font-weight: 800;
}

.metric-card small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
}

.insight-panel,
.map-panel,
.data-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.insight-panel {
  display: grid;
  align-content: start;
}

.panel-block {
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.panel-block:last-child {
  border-bottom: 0;
}

.selected-province h2 {
  margin: 8px 0 4px;
  font-size: 30px;
  line-height: 1.05;
  font-weight: 800;
}

.selected-value {
  color: var(--accent);
  font-size: 42px;
  line-height: 1;
  font-weight: 800;
}

.selected-province dl {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 16px 0;
}

.selected-province dl div {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--soft);
}

.selected-province dt {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.selected-province dd {
  margin: 3px 0 0;
  font-size: 20px;
  font-weight: 800;
}

.detail-link {
  width: 100%;
  min-height: 42px;
  background: var(--ink);
  color: #ffffff;
  font-weight: 800;
}

.legend-stack {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.legend-stack div {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  gap: 8px;
  align-items: center;
  color: var(--muted);
}

.legend-stack strong {
  color: var(--ink);
}

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

.legend-dot.low {
  background: #4fb286;
}

.legend-dot.mid-low {
  background: var(--amber);
}

.legend-dot.mid-high {
  background: var(--orange);
}

.legend-dot.high {
  background: var(--red);
}

.top-list {
  display: grid;
  gap: 8px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.top-list li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}

.top-list li:hover,
.top-list li.is-active,
.province-table tr.is-active {
  background: #eef8f6;
  border-color: rgba(15, 118, 110, 0.35);
}

.map-panel {
  min-width: 0;
  overflow: hidden;
}

.map-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 58px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.map-chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  margin-right: 6px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.icon-action {
  width: 38px;
  height: 38px;
  background: #eef1f4;
  color: var(--ink);
}

.map-container {
  width: 100%;
  height: min(68vh, 760px);
  min-height: 520px;
}

.map-error {
  display: grid;
  min-height: 420px;
  place-items: center;
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

.data-section {
  margin-top: 14px;
  overflow: hidden;
}

.data-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.data-heading h2 {
  margin: 4px 0 0;
  font-size: 24px;
  font-weight: 800;
}

.search-box {
  position: relative;
  width: min(340px, 100%);
  margin: 0;
}

.search-box i {
  position: absolute;
  top: 50%;
  left: 13px;
  color: var(--muted);
  transform: translateY(-50%);
}

.search-box input {
  padding: 0 12px 0 38px;
}

.table-wrap {
  max-height: 520px;
  overflow: auto;
}

.province-table {
  width: 100%;
  border-collapse: collapse;
}

.province-table th,
.province-table td {
  padding: 13px 18px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.province-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fafbfc;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.province-table tbody tr {
  cursor: pointer;
}

.province-table tbody tr:hover {
  background: #fafcfd;
}

.province-table td:nth-child(1),
.province-table td:nth-child(3),
.province-table td:nth-child(4) {
  font-weight: 800;
}

.positive {
  color: #168457;
}

.negative {
  color: var(--accent);
}

.table-link {
  width: 34px;
  height: 34px;
  background: #eef1f4;
  color: var(--ink);
}

@media (max-width: 1180px) {
  .dashboard-head,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 760px) {
  .dashboard-shell {
    width: min(100% - 20px, 1840px);
    padding-top: 76px;
  }

  .dashboard-title h1 {
    font-size: 34px;
  }

  .dashboard-title p {
    font-size: 13px;
  }

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

  .primary-action {
    width: 100%;
  }

  .map-container {
    min-height: 430px;
    height: 62vh;
  }

  .data-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .province-table th,
  .province-table td {
    padding: 11px 12px;
  }
}
