:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #758096;
  --line: #e5e9f1;
  --soft: #f6f8fc;
  --blue: #2356e8;
  --blue-dark: #173fb7;
  --navy: #111b35;
  --white: #fff;
  --success: #178864;
  --warning: #d96c27;
  --shadow: 0 24px 70px rgba(31, 46, 85, 0.1);
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 5% 5%, rgba(35, 86, 232, 0.08), transparent 27%),
    linear-gradient(135deg, #f7f9fd 0%, #eef2f8 100%);
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.app-shell {
  width: min(1460px, calc(100% - 56px));
  margin: 0 auto;
  padding: 34px 0 46px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 24px;
  padding: 0 6px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--blue);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.2em;
}

h1 {
  margin: 0;
  font-size: clamp(25px, 3vw, 38px);
  line-height: 1.1;
  letter-spacing: -0.04em;
}

.subtitle {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 14px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 410px;
  min-height: 760px;
  overflow: hidden;
  border: 1px solid rgba(220, 225, 236, 0.88);
  border-radius: 24px;
  background: var(--white);
  box-shadow: var(--shadow);
}

.map-card {
  display: flex;
  min-width: 0;
  flex-direction: column;
  padding: 22px 25px 18px;
  background:
    linear-gradient(rgba(35, 86, 232, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(35, 86, 232, 0.025) 1px, transparent 1px),
    #fbfcfe;
  background-size: 28px 28px;
}

.map-toolbar,
.map-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 38px;
}

.map-toolbar > div {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #49546a;
  font-size: 13px;
  font-weight: 700;
}

.mode-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 0 5px rgba(35, 86, 232, 0.1);
}

.text-button,
.mini-button {
  padding: 7px 10px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.text-button:hover,
.mini-button:hover {
  color: var(--blue);
}

.map-stage {
  position: relative;
  display: grid;
  min-height: 615px;
  flex: 1;
  place-items: center;
}

#chinaMap {
  display: block;
  width: 100%;
  height: 100%;
  max-height: 650px;
  overflow: visible;
}

.province-shape {
  vector-effect: non-scaling-stroke;
  cursor: pointer;
  transition:
    fill 180ms ease,
    opacity 180ms ease,
    filter 180ms ease;
  stroke: #fff;
  stroke-width: 1.15;
  stroke-linejoin: round;
}

.province-shape:hover {
  filter: brightness(0.96);
}

.province-shape.is-selected {
  filter: drop-shadow(0 0 4px rgba(20, 48, 117, 0.38));
  stroke: #112b72;
  stroke-width: 2.2;
}

.province-label {
  pointer-events: none;
  fill: #46516a;
  font-size: 10px;
  font-weight: 650;
  text-anchor: middle;
  paint-order: stroke;
  stroke: rgba(255, 255, 255, 0.8);
  stroke-width: 2px;
  stroke-linejoin: round;
}

.map-tooltip {
  position: absolute;
  z-index: 4;
  min-width: 104px;
  padding: 9px 12px;
  transform: translate(12px, -50%);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  opacity: 0;
  color: #fff;
  background: rgba(17, 27, 53, 0.94);
  box-shadow: 0 10px 26px rgba(16, 28, 56, 0.2);
  font-size: 12px;
  line-height: 1.5;
  pointer-events: none;
  transition: opacity 120ms ease;
}

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

.map-tooltip.is-visible {
  opacity: 1;
}

.empty-hint {
  position: absolute;
  bottom: 18px;
  left: 50%;
  padding: 8px 13px;
  transform: translateX(-50%);
  border: 1px solid #e1e6f0;
  border-radius: 999px;
  color: #7b879c;
  background: rgba(255, 255, 255, 0.86);
  font-size: 12px;
  white-space: nowrap;
  backdrop-filter: blur(8px);
}

.map-footer {
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.selection-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
}

.selection-summary span {
  color: var(--muted);
}

.selection-summary strong {
  font-size: 13px;
}

.legend {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
}

.legend-gradient {
  width: 130px;
  height: 8px;
  border-radius: 99px;
  background: linear-gradient(90deg, #e9f0ff, #8eb5ff, #2356e8, #102d84);
}

.control-panel {
  overflow: hidden;
  border-left: 1px solid var(--line);
  background: var(--white);
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 13px 14px 0;
  border-bottom: 1px solid var(--line);
  background: #fbfcfe;
}

.tab {
  position: relative;
  padding: 15px 8px 16px;
  border: 0;
  color: #8a93a5;
  background: transparent;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.tab::after {
  position: absolute;
  right: 28%;
  bottom: -1px;
  left: 28%;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--blue);
  content: "";
  opacity: 0;
  transform: scaleX(0.5);
  transition: 180ms ease;
}

.tab.is-active {
  color: var(--ink);
}

.tab.is-active::after {
  opacity: 1;
  transform: scaleX(1);
}

.panel-content {
  padding: 23px 24px 25px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-heading > div {
  display: flex;
  align-items: center;
  gap: 9px;
}

.section-heading h2 {
  margin: 0;
  font-size: 16px;
}

.step {
  display: grid;
  width: 27px;
  height: 27px;
  place-items: center;
  border-radius: 8px;
  color: var(--blue);
  background: #edf2ff;
  font-size: 10px;
  font-weight: 800;
}

.mini-button {
  font-size: 12px;
}

.helper {
  margin: 10px 0 14px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.search-box {
  position: relative;
  display: block;
  margin-bottom: 13px;
}

.search-box input {
  width: 100%;
  height: 40px;
  padding: 0 14px 0 39px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: 0;
  color: var(--ink);
  background: var(--soft);
  transition: 160ms ease;
}

.search-box input:focus {
  border-color: #9cb3f6;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(35, 86, 232, 0.08);
}

.search-icon {
  position: absolute;
  z-index: 1;
  top: 13px;
  left: 15px;
  width: 13px;
  height: 13px;
  border: 1.8px solid #8a96aa;
  border-radius: 50%;
}

.search-icon::after {
  position: absolute;
  right: -5px;
  bottom: -3px;
  width: 6px;
  height: 1.8px;
  transform: rotate(45deg);
  border-radius: 2px;
  background: #8a96aa;
  content: "";
}

.province-grid {
  display: grid;
  max-height: 213px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
  overflow: auto;
  padding: 1px 4px 3px 1px;
  scrollbar-color: #ccd3e0 transparent;
  scrollbar-width: thin;
}

.province-option {
  min-width: 0;
  padding: 8px 5px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #586378;
  background: #fff;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  transition: 140ms ease;
}

.province-option:hover {
  border-color: #b4c3ed;
  color: var(--blue);
}

.province-option.is-selected {
  border-color: var(--blue);
  color: var(--blue);
  background: #edf2ff;
  font-weight: 700;
}

.divider {
  height: 1px;
  margin: 22px 0;
  background: var(--line);
}

.selected-count {
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
}

.color-controls {
  display: grid;
  grid-template-columns: 1fr 128px;
  gap: 13px;
  margin-top: 15px;
}

.swatches {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.swatch {
  position: relative;
  min-height: 37px;
  border: 3px solid #fff;
  border-radius: 9px;
  outline: 1px solid transparent;
  cursor: pointer;
  transition: 130ms ease;
}

.swatch:hover,
.swatch.is-active {
  outline-color: #aeb8c9;
  transform: translateY(-1px);
}

.swatch.is-active::after {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 7px;
  height: 4px;
  transform: translate(-50%, -65%) rotate(-45deg);
  border-bottom: 2px solid #fff;
  border-left: 2px solid #fff;
  content: "";
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.3));
}

.custom-color {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
}

.custom-color input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.color-preview {
  width: 31px;
  height: 31px;
  flex: 0 0 auto;
  border: 3px solid #fff;
  border-radius: 8px;
  outline: 1px solid #d7ddea;
  background: var(--blue);
}

.custom-color strong,
.custom-color small {
  display: block;
}

.custom-color strong {
  font-size: 11px;
}

.custom-color small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
}

.primary-button {
  width: 100%;
  min-height: 45px;
  margin-top: 19px;
  border: 0;
  border-radius: 11px;
  color: #fff;
  background: var(--blue);
  box-shadow: 0 8px 18px rgba(35, 86, 232, 0.2);
  font-size: 13px;
  font-weight: 750;
  cursor: pointer;
  transition: 160ms ease;
}

.primary-button:hover:not(:disabled) {
  background: var(--blue-dark);
  transform: translateY(-1px);
}

.primary-button:disabled {
  color: #a6aebc;
  background: #e6e9ef;
  box-shadow: none;
  cursor: not-allowed;
}

.data-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 17px;
}

.outline-button {
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: #536079;
  background: #fff;
  font-size: 11px;
  font-weight: 650;
  cursor: pointer;
}

.outline-button:hover {
  border-color: #b5c3eb;
  color: var(--blue);
  background: #f7f9ff;
}

.ratio-list-header,
.ratio-row {
  display: grid;
  grid-template-columns: 1fr 105px;
  align-items: center;
}

.ratio-list-header {
  padding: 0 7px 8px;
  color: #8b95a8;
  font-size: 10px;
}

.ratio-list-header span:last-child {
  text-align: right;
}

.ratio-list {
  max-height: 412px;
  overflow: auto;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  scrollbar-color: #ccd3e0 transparent;
  scrollbar-width: thin;
}

.ratio-row {
  min-height: 43px;
  padding: 5px 7px;
  border-bottom: 1px solid #f0f2f6;
}

.ratio-row:last-child {
  border-bottom: 0;
}

.ratio-row label {
  color: #4f5b71;
  font-size: 12px;
}

.ratio-input-wrap {
  position: relative;
}

.ratio-input {
  width: 100%;
  height: 31px;
  padding: 0 26px 0 9px;
  border: 1px solid #dde2eb;
  border-radius: 7px;
  outline: 0;
  color: var(--ink);
  background: var(--soft);
  text-align: right;
}

.ratio-input:focus {
  border-color: #94acf1;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(35, 86, 232, 0.07);
}

.ratio-input-wrap::after {
  position: absolute;
  top: 8px;
  right: 9px;
  color: #a2aabc;
  font-size: 10px;
  content: "%";
}

.total-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 15px;
  padding: 12px 14px;
  border: 1px solid #f0d6c7;
  border-radius: 11px;
  background: #fff9f5;
}

.total-card > div span,
.total-card > div small {
  display: block;
}

.total-card > div span {
  font-size: 12px;
  font-weight: 700;
}

.total-card > div small {
  margin-top: 4px;
  color: var(--warning);
  font-size: 10px;
}

.total-card strong {
  color: var(--warning);
  font-size: 22px;
}

.total-card.is-valid {
  border-color: #bee3d6;
  background: #f1fbf7;
}

.total-card.is-valid strong,
.total-card.is-valid small {
  color: var(--success);
}

[hidden] {
  display: none !important;
}

@media (max-width: 1050px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr) 370px;
  }

  .map-card {
    padding-right: 15px;
    padding-left: 15px;
  }

  .province-label {
    font-size: 8px;
  }
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100% - 24px, 720px);
    padding-top: 22px;
  }

  .topbar {
    display: block;
  }

  .subtitle {
    margin-top: 10px;
  }

  .workspace {
    display: block;
    overflow: visible;
  }

  .map-stage {
    min-height: 480px;
  }

  .control-panel {
    border-top: 1px solid var(--line);
    border-left: 0;
  }
}

@media (max-width: 480px) {
  .app-shell {
    width: 100%;
    padding: 18px 10px 30px;
  }

  .workspace {
    border-radius: 17px;
  }

  .map-card {
    padding: 15px 10px;
  }

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

  .province-label {
    display: none;
  }

  .panel-content {
    padding-right: 16px;
    padding-left: 16px;
  }
}
