/* =======================================
   Redistribution Color System
======================================= */

:root {
  --redist-primary: #006637;
  --redist-red: #931e23;
  --redist-primary-soft: #e8f3ee;
  --redist-primary-line: #b9d9c8;

  --redist-bg: #eeeeec;
  --redist-white: #ffffff;
  --redist-card: #ffffff;

  --redist-text: #111827;
  --redist-muted: #5f6b63;
  --redist-light-text: #8a948d;

  --redist-border: #d8ded9;
  --redist-panel: #f3f6f4;

  --redist-shadow: 0 12px 28px rgba(0, 0, 0, 0.1);
  --redist-shadow-soft: 0 8px 12px rgba(0, 0, 0, 0.15);

  --redist-radius-xl: 28px;
  --redist-radius-lg: 22px;
  --redist-radius-md: 16px;
}

/* =======================================
   Page
======================================= */

#content-redistribution {
  background: var(--redist-bg);
  color: var(--redist-text);
}

.redistribution-shell {
  width: min(1280px, calc(100% - 34px));
  margin: 0 auto;
  padding: 0 0 20px;
}

/* =======================================
   Top Search Bar
======================================= */

.redist-topbar {
  height: 58px;
  padding: 0 24px;

  display: flex;
  align-items: center;
  gap: 28px;

  background: var(--redist-primary);
  border-radius: 20px 20px 0 0;
  color: #fff;
}

.redist-search-field {
  display: flex;
  align-items: center;
  gap: 12px;
}

.redist-search-field label {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.redist-search-field input,
.redist-search-field select {
  width: 260px;
  height: 30px;

  border: none;
  border-radius: 8px;
  padding: 0 12px;

  font-size: 13px;
  background: #fff;
}

.redist-date {
  margin-left: auto;
  font-size: 11px;
  opacity: 0.9;
  white-space: nowrap;
}

/* =======================================
   Region Meta
======================================= */

.redist-region-meta {
  height: 40px;
  padding: 0 24px;

  display: flex;
  align-items: center;
  gap: 8px;

  background: #fff;
  border-bottom: 1px solid var(--redist-border);

  font-size: 16px;
  color: var(--redist-muted);
}

.redist-region-meta span:last-child {
  color: var(--redist-primary);
  font-weight: 700;
}

/* =======================================
   KPI Row
======================================= */

.redist-kpi-row {
  padding: 22px 24px 12px;

  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 28px;

  background: #fff;
}

.redist-kpi-label {
  margin-bottom: 5px;
  margin-left: 8px;
  font-size: 13px;
  font-weight: 400;
  color: var(--redist-text);
  letter-spacing: -0.3px;
}

.redist-kpi-value {
  display: flex;
  align-items: center;
  gap: 12px;
  letter-spacing: -0.3px;
}

.redist-kpi-value strong {
  font-size: 32px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.redist-pill {
  min-width: 115px;
  height: 35px;
  padding: 0 14px;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  border-radius: 999px;
  background: var(--redist-primary);
  color: #fff;

  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.redist-kpi-note {
  margin-top: 2px;
  padding-left: 130px;

  font-size: 12px;
  line-height: 1.3;
  color: var(--redist-light-text);
  letter-spacing: -0.04em;
}

/* =======================================
   Diagnosis Title
======================================= */

.redist-diagnosis-title {
  padding: 4px 24px 16px;
  background: #fff;
}

.redist-title-label {
  margin-bottom: 5px;
  margin-left: 8px;
  font-size: 15px;
  font-weight: 400;
  color: var(--redist-text);
  letter-spacing: -0.3px;
}


.redist-diagnosis-title h2 {
  margin: 4px 0 0;
  margin-left: 8px;
  margin-bottom: 5px;

  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.06em;
}

.redist-diagnosis-title h2 span {
  color: var(--redist-primary);
}

/* =======================================
   Card
======================================= */

.redist-card {
  background: var(--redist-card);
  border-radius: var(--redist-radius-xl);
  box-shadow: var(--redist-shadow-soft);
  border: 1px solid #e4e6e8;
}

.redist-card h3 {
  margin: 0 0 18px;

  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.05em;
}

/* =======================================
   Matrix + Keymap
======================================= */

.redist-main-grid {
  padding: 0 18px 18px;

  display: grid;
  grid-template-columns: 2.4fr 0.95fr;
  gap: 18px;

  background: #fff;
  border-radius: 0 0 28px 28px;
}

.redist-matrix-plot {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
}

.redist-matrix-card,
.redist-keymap-card {
  height: 340px;
  overflow: hidden;
}

#redist-matrix,
#redist-keymap {
  width: 100%;
  height: 100%;
}

#redist-matrix {
  position: relative;

  border-radius: var(--redist-radius-xl);
  background: #fff;
}

.redist-matrix-title {
  position: absolute;
  left: 28px;
  bottom: 24px;

  font-size: 34px;
  line-height: 1.05;
  font-weight: 900;
  letter-spacing: -0.06em;
}

#redist-keymap {
  border-radius: var(--redist-radius-xl);
  background: #f4f5f3;
}

/* =======================================
   Supply / Access Analysis
======================================= */

.redist-analysis-grid {
  margin-top: 18px;

  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.redist-analysis-grid .redist-card {
  min-height: 520px;
  padding: 34px;
}

#redist-supply,
#redist-access {
  min-height: 410px;
}

.redist-gauge-svg,
.redist-inline-gauge-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.redist-inline-gauge-svg * {
  transition: fill 0.2s ease, stroke 0.2s ease;
}

/* =======================================
   Report
======================================= */

.redist-report-card {
  margin-top: 18px;
  padding: 34px;
  min-height: 360px;
}

.redist-report-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.redist-report-head h3 {
  margin: 0;
}

.redist-report-head span {
  font-size: 12px;
  font-weight: 800;
  color: var(--redist-primary);
}

#redist-report {
  min-height: 270px;
}

/* =======================================
   Temporary Placeholder
======================================= */

#redist-supply:empty::before,
#redist-access:empty::before,
#redist-report:empty::before {
  content: "";
  display: block;
  height: 100%;
}

#redist-keymap:empty {
  background:
    linear-gradient(135deg, rgba(0, 102, 55, 0.08), rgba(255, 255, 255, 0.4)),
    #f4f5f3;
}

#redist-matrix:empty {
  background: #fff;
}

/* =======================================
   Redistribution Matrix Detail
======================================= */

.redist-matrix-card {
  position: relative;
}

.redist-axis-title {
  position: absolute;
  z-index: 4;
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.05em;
  color: #222;
  white-space: nowrap;
}

.redist-axis-title-x {
  font-size: 18px;
  left: calc(14% - 30px) !important;
  top: calc(40% - 10px);
}

.redist-axis-title-y {
  font-size: 18px;
  left: calc(50% + 5px);
  top: 12px;
}

.redist-matrix-axis-x,
.redist-matrix-axis-y {
  position: absolute;
  background: #9ca3af;
  z-index: 2;
}

.redist-matrix-axis-x {
  left: 18% !important;
  right: 8% !important;
  top: 40% !important;
  height: 1px;
}

.redist-matrix-axis-y {
  top: 12% !important;
  bottom: 12% !important;
  left: 50% !important;
  width: 1px;
}

.redist-matrix-axis-x::after {
  content: "";

  position: absolute;
  right: -1px;
  top: 50%;

  transform: translateY(-50%);

  border-left: 10px solid #555;
  border-top: 3px solid transparent;
  border-bottom: 3px solid transparent;
}

.redist-matrix-axis-y::before {
  content: "";

  position: absolute;
  top: -1px;
  left: 50%;

  transform: translateX(-50%);

  border-bottom: 10px solid #555;
  border-left: 3px solid transparent;
  border-right: 3px solid transparent;
}

.redist-axis-label {
  position: absolute;
  font-size: 17px;
  font-weight: 400;
  color: var(--redist-primary);
  z-index: 9;
}

.redist-axis-label.x-left {
  left: calc(21% - 25px);
  top: calc(40% + 2px);
}

.redist-axis-label.x-mid {
  left: calc(50% - 35px);
  top: calc(40% + 2px);
}

.redist-axis-label.x-right {
  right: calc(8% + 8px);
  top: calc(40% + 2px);
}

.redist-axis-label.y-top {
  left: calc(50% + 5px);
  top: calc(8% + 2px);
}

.redist-axis-label.y-mid {
  left: calc(50% + 5px);
  top: calc(40% + 2px);
}

.redist-axis-label.y-bottom {
  left: calc(50% + 5px);
  bottom: 25px;
}

.redist-dot {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #a7a9ac;
  transform: translate(-50%, -50%);
  z-index: 5;
}

.redist-dot.active {
  width: 12px;
  height: 12px;
  background: var(--redist-red);
  z-index: 20;
}

.redist-dot-label {
  display: none;
  position: absolute;
  transform: translate(2px, -50%);
  top: 0;

  font-size: 12px;
  font-weight: 400;
  color: #8a8f94;

  white-space: nowrap;
  z-index: 6;
  pointer-events: none;

  transition:
    background-color 0.15s ease,
    color 0.15s ease,
    transform 0.15s ease,
    font-size 0.15s ease;
}

.redist-dot-label.is-visible {
  display: block;
}

.redist-dot-label.is-right {
  transform: translate(8px, -50%);
  text-align: left;
}

.redist-dot-label.is-left {
  transform: translate(calc(-100% - 10px), -50%);
  text-align: right;
}

.redist-dot.active+.redist-dot-label {
  color: #111827;
  font-size: 18px;
  font-weight: 800;
  z-index: 20;
}

.redist-dot:hover+.redist-dot-label {
  display: block;
  z-index: 30;

  color: #fff;
  background: rgba(90, 90, 90, .92);

  font-size: 13px;
  font-weight: 600;

  padding: 2px 6px;
  border-radius: 5px;
}



/* =======================================
   Keymap Leaflet
======================================= */

#redist-keymap .leaflet-container {
  width: 100%;
  height: 100%;
}

.distribution-sido-label div {
  font-size: 10px;
  font-weight: 700;
  color: #777;
  text-align: center;
  white-space: nowrap;
}

.distribution-selected-label div {
  min-width: 52px;
  height: 28px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 999px;
  background: #747474;
  color: #fff;

  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.distribution-marker-icon {
  width: 34px !important;
  height: auto !important;
  aspect-ratio: auto !important;
  object-fit: contain !important;
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.25));
}

/* =======================================
   Analysis Card Common
======================================= */

.redist-analysis-card {
  position: relative;
}

.redist-analysis-main {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  gap: 26px;
  align-items: center;
  margin-top: 10px;
}

.redist-gauge-wrap {
  position: relative;
  width: 150px;
  height: 150px;
}

.redist-gauge-img {
  width: 100%;
  height: 100%;
  display: block;
}

.redist-gauge-center {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.redist-gauge-value {
  font-size: 35px;
  font-weight: 900;
  letter-spacing: -0.06em;
  color: #222;
}

.redist-metric-list {
  display: grid;
  gap: 12px;
}

.redist-metric-row {
  display: grid;
  grid-template-columns: 150px 1fr;
  align-items: center;
  gap: 25px;
}

.redist-metric-row span {
  text-align: left;
}

.redist-metric-row strong {
  text-align: left;
  font-size: 18px;
  font-weight: 900;
}

/* =======================================
   Comment Bubble
======================================= */

.redist-comment-box,
.redist-report-comment {
  position: relative;
  margin-top: 28px;
  padding: 22px 24px;
  border: 3px solid var(--redist-primary);
  border-radius: 18px;
  background: #fff;
}

.redist-comment-box p,
.redist-report-comment p {
  margin: 0;
  font-size: 18px;
  line-height: 1.45;
  letter-spacing: -0.04em;
  color: #111;
  word-break: keep-all;
}

.redist-comment-box strong,
.redist-report-comment strong {
  color: var(--redist-primary);
  font-size: 18px;
  font-weight: 800;
}

.redist-comment-icon {
  position: absolute;
  left: 18px;
  top: -32px;
  width: 48px;
  height: 48px;
}

.redist-sub-compare {
  margin-top: 20px;
  margin-bottom: 0;
  padding: 0;
}

.redist-sub-title {
  margin: 0;
  font-size: 15px;
  font-weight: 400;
  color: var(--redist-muted);
}

.redist-sub-compare p {
  margin: 5px;
  margin-left: 15px;
  font-size: 18px;
  line-height: 1.6;
  color: #606a64;
  letter-spacing: -0.3px;
  word-break: keep-all;
}

/* =======================================
   Access Gauge / Bars
======================================= */

.redist-access-gauge {
  width: 150px;
  height: 150px;
}

.redist-access-progress-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  pointer-events: none;
}

#redist-access-progress {
  fill: none;
  stroke: var(--redist-primary);
  stroke-width: 25;
  stroke-linecap: butt;
}

.redist-access-value {
  font-size: 40px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.08em;
  color: #242225;
}

.redist-access-bars {
  display: grid;
  gap: 20px;
}

.redist-access-bar-row {
  display: grid;
  grid-template-columns: 1fr 150px 58px;
  gap: 10px;
  align-items: center;
}

.redist-access-bar-label {
  grid-column: 1 / -1;
  font-size: 15px;
  color: #111;
}

.redist-access-bar-wrap {
  grid-column: 1 / 3;
  height: 30px;
  border-radius: 999px;
  background: #e9ecea;
  overflow: hidden;
}

.redist-access-bar-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--redist-primary);
}

.redist-access-bar-row strong {
  font-size: 18px;
  font-weight: 900;
  text-align: left;
}

.redist-access-extra-row {
  display: flex;
  justify-content: space-between;
  align-items: left;
  padding-top: 4px;
  margin-right: 8px;
  font-size: 15px;
}

.redist-access-extra-row strong {
  font-size: 18px;
  font-weight: 900;
}

#redist-national-rate,
#redist-vulnerable-rate,
#redist-extra-distance {
  color: #111827;
  display: block;
}

#redist-national-bar,
#redist-vulnerable-bar {
  background: var(--redist-primary);
}

/* =======================================
   Report
======================================= */

.redist-report-badge {
  display: flex;
  align-items: center;
  gap: 10px;
}

.redist-report-badge img {
  width: 48px;
  height: 48px;
}

.redist-report-title {
  margin-top: 24px;
  font-size: 32px;
  font-weight: 900;
  letter-spacing: -0.06em;
}

.redist-report-title span {
  color: var(--redist-primary);
}

.redist-priority-wrap {
  margin-top: 28px;
}

.redist-priority-title {
  font-size: 20px;
  font-weight: 500;
  color: #222;
  letter-spacing: -0.3px;
}

.redist-priority-list {
  display: flex;
  gap: 60px;
  flex-wrap: wrap;
  letter-spacing: -0.3px;
}

.redist-priority-item {
  display: flex;
  align-items: center;
  gap: 14px;
}

.redist-priority-item img {
  width: 120px;
  height: 80px;
  object-fit: contain;
}

.redist-priority-item span {
  display: block;
  margin-bottom: 4px;
  font-size: 16px;
  color: #111;
}

.redist-priority-item strong {
  display: block;
  font-size: 20px;
  font-weight: 900;
}

.redist-sgg-search-wrap {
  position: relative;
}

.redist-recent-sgg-list {
  display: none;
  position: absolute;
  left: 72px;
  top: calc(100% + 8px);
  width: 260px;
  padding: 5px;
  background: #fff;
  border: 1px solid #d8e2dc;
  border-radius: 12px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.16);
  z-index: 3000;
}

.redist-recent-sgg-list.is-visible {
  display: block;
}

.redist-recent-title {
  padding: 2px 4px 4px;
  font-size: 12px;
  font-weight: 700;
  color: #006637;
}

.redist-recent-item {
  width: 100%;
  padding: 9px 10px;
  border: 0;
  background: transparent;
  border-radius: 8px;
  text-align: left;
  cursor: pointer;
}

.redist-recent-item:hover {
  background: #eef7f1;
}

.redist-recent-item span {
  display: block;
  font-size: 12px;
  color: #667;
}

.redist-recent-item strong {
  display: block;
  margin-top: 2px;
  font-size: 14px;
  color: #111;
}

/* =======================================
   Mobile Addition
======================================= */

@media (max-width: 1024px) {
  .redist-analysis-main {
    grid-template-columns: 150px minmax(0, 1fr);
  }

  .redist-access-bar-row {
    grid-template-columns: 1fr 120px 54px;
  }

  .redist-matrix-axis-x {
    left: 180px;
  }

  .redist-axis-label.x-left {
    left: 160px;
  }
}

/* =======================================
   Mobile
======================================= */

@media (max-width: 1024px) {
  .redistribution-shell {
    width: calc(100% - 32px);
  }

  .redist-topbar {
    height: auto;
    padding: 16px;
    flex-wrap: wrap;
    gap: 12px;
  }

  .redist-search-field input,
  .redist-search-field select {
    width: 220px;
  }

  .redist-date {
    margin-left: 0;
    width: 100%;
  }

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

  .redist-main-grid,
  .redist-analysis-grid {
    grid-template-columns: 1fr;
  }

  .redist-matrix-card,
  .redist-keymap-card {
    height: 320px;
  }
}

@media (max-width: 768px) {
  .redistribution-shell {
    width: calc(100% - 20px);
    padding: 18px 0 56px;
  }

  .redist-topbar {
    border-radius: 18px 18px 0 0;
  }

  .redist-search-field {
    width: 100%;
    justify-content: space-between;
  }

  .redist-search-field input,
  .redist-search-field select {
    width: calc(100% - 90px);
  }

  .redist-region-meta {
    height: auto;
    padding: 12px 16px;
    flex-wrap: wrap;
  }

  .redist-kpi-row {
    padding: 18px 16px 10px;
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .redist-kpi-value strong {
    font-size: 28px;
  }

  .redist-kpi-note {
    padding-left: 0;
  }

  .redist-diagnosis-title {
    padding: 4px 16px 16px;
  }

  .redist-diagnosis-title h2 {
    font-size: 28px;
  }

  .redist-main-grid {
    padding: 0 10px 14px;
  }

  .redist-analysis-grid .redist-card,
  .redist-report-card {
    padding: 24px;
  }

  .redist-card h3 {
    font-size: 20px;
  }

  .redist-matrix-card {
    height: 320px !important;
    padding: 0 !important;
    overflow: hidden;
  }

  #redist-matrix {
    position: relative !important;
    height: 100%;
    width: 100%;
  }



  .redist-matrix-title {
    position: relative !important;
    left: 30px !important;
    top: 20px !important;
    bottom: auto;

    font-size: 25px;
    line-height: 1.05;
    text-align: left;
    z-index: 30;
  }

  .redist-matrix-title::after {
    content: "";
    display: block;
    width: 82px;
    height: 2px;
    margin-top: 10px;
    background: var(--redist-primary);
  }

  .redist-matrix-plot {
    position: absolute !important;

    left: 20px !important;
    right: 20px !important;
    top: 115px !important;
    bottom: 15px !important;

    width: auto !important;
    height: auto !important;
  }

  /* 제목 하단에서 y축 시작 */
  .redist-matrix-axis-y {
    left: 50% !important;
    top: 0 !important;
    bottom: 0 !important;
    width: 1px;
  }

  /* x축은 공급수준 텍스트와 분리해서 최대한 길게 */
  .redist-matrix-axis-x {
    left: 0 !important;
    right: 10px !important;
    top: calc(50%) !important;
    height: 1px;
  }

  .redist-axis-title-x {
    left: 0 !important;
    top: calc(45% - 10px) !important;
    font-size: 15px;
    font-weight: 700;
  }

  .redist-axis-title-y {
    left: calc(35% + 10px) !important;
    top: -20px !important;
    font-size: 15px;
    font-weight: 700;
  }

  .redist-axis-label.x-left {
    left: 0px !important;
    top: calc(50% + 5px) !important;
    font-size: 16px;
  }

  .redist-axis-label.x-mid {
    left: calc(50% - 30px) !important;
    top: calc(50% + 5px) !important;
    font-size: 16px;
  }

  .redist-axis-label.x-right {
    right: 15px !important;
    top: calc(50% + 5px) !important;
    font-size: 16px;
  }

  .redist-axis-label.y-top {
    left: calc(50% + 5px) !important;
    top: 0 !important;
    font-size: 16px;
  }

  .redist-axis-label.y-mid {
    left: calc(50% + 5px) !important;
    top: calc(50% + 5px) !important;
    font-size: 16px;
  }

  .redist-axis-label.y-bottom {
    left: calc(50% + 5px) !important;
    bottom: 0 !important;
    font-size: 16px;
  }

  .redist-dot {
    width: 7px;
    height: 7px;
  }

  .redist-dot.active {
    width: 12px;
    height: 12px;
  }

  .redist-dot-label {
    font-size: 9.5px;
  }

  .redist-dot.active+.redist-dot-label {
    font-size: 17px;
  }


}