:root {
  --ink: #14212b;
  --muted: #60717c;
  --line: #d8e1e4;
  --soft-line: #e8eef0;
  --paper: #ffffff;
  --canvas: #f4f7f7;
  --teal: #087f7b;
  --teal-dark: #08635f;
  --teal-soft: #e5f4f1;
  --coral: #cf543c;
  --coral-soft: #faece8;
  --amber: #b87814;
  --amber-soft: #fff4dc;
  --blue: #2671a8;
  --blue-soft: #eaf3fa;
  --shadow: 0 14px 34px rgba(27, 53, 63, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
  background: var(--canvas);
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--canvas);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
.leaflet-container:focus-visible {
  outline: 3px solid rgba(38, 113, 168, 0.34);
  outline-offset: 2px;
}

.app-header {
  min-height: 76px;
  padding: 14px clamp(18px, 3vw, 42px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  color: #ffffff;
  background: #123a44;
  border-bottom: 4px solid #e1a72e;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 30px;
  height: 42px;
  display: block;
  border: 3px solid #81d2c6;
  border-top-color: #f0ba48;
  border-radius: 50% 50% 46% 46%;
  transform: rotate(12deg);
}

.brand-block p,
.brand-block h1 {
  margin: 0;
}

.app-header .module-nav {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
}

.app-header .module-nav a {
  min-height: 34px;
  padding: 7px 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  color: #cfe7e4;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.app-header .module-nav a.active {
  color: #123a44;
  background: #f0ba48;
}

.language-switch {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
}

.language-switch button {
  min-height: 32px;
  padding: 6px 9px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #cfe7e4;
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.language-switch button.active {
  background: #f0ba48;
  color: #123a44;
}

.brand-block p {
  margin-bottom: 3px;
  color: #a9d8d2;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.trial-tag {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 1px 6px;
  border: 1px solid rgba(240, 186, 72, 0.55);
  border-radius: 4px;
  background: rgba(240, 186, 72, 0.16);
  color: #ffd87b;
  font-size: 10px;
  font-weight: 900;
}

.brand-block h1 {
  font-size: clamp(20px, 2.2vw, 29px);
  line-height: 1.15;
}

.data-status {
  min-height: 38px;
  padding: 8px 13px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(255, 255, 255, 0.23);
  border-radius: 6px;
  color: #d8efec;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.data-status > span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #efbc50;
}

.data-status > div {
  display: grid;
  gap: 2px;
}

.data-status strong {
  color: #e5f5f2;
  font-size: 12px;
}

.data-status a {
  color: #a9d8d2;
  font-size: 10px;
  font-weight: 600;
  text-decoration: none;
}

.data-status a:hover {
  text-decoration: underline;
}

.data-status[data-tone="ready"] > span {
  background: #68c593;
}

.data-status[data-tone="error"] > span {
  background: #ef7761;
}

.app-shell {
  width: min(1800px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(380px, 0.82fr) minmax(620px, 1.5fr);
  align-items: start;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.control-column,
.result-column {
  min-width: 0;
  padding: clamp(20px, 2.5vw, 34px);
}

.control-column {
  border-right: 1px solid var(--line);
  background: #fbfdfd;
}

.result-column {
  display: grid;
  gap: 24px;
}

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

.section-heading.compact {
  align-items: flex-end;
  margin-bottom: 14px;
}

.section-heading h2,
.decision-copy h2 {
  margin: 3px 0 0;
  font-size: 21px;
  line-height: 1.25;
}

.step-label {
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 800;
}

.coverage-tag,
.source-label,
#chartRange {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.coverage-tag {
  padding: 6px 9px;
  border: 1px solid #b9d7d3;
  border-radius: 5px;
  color: var(--teal-dark);
  background: var(--teal-soft);
}

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

.control-grid label {
  min-width: 0;
  display: grid;
  gap: 7px;
  color: #3b4b55;
  font-size: 13px;
  font-weight: 700;
}

.wide-control {
  grid-column: 1 / -1;
}

.control-grid input,
.control-grid select {
  width: 100%;
  min-height: 44px;
  padding: 9px 11px;
  border: 1px solid #becbd0;
  border-radius: 5px;
  color: var(--ink);
  background: #ffffff;
}

.control-grid input:hover,
.control-grid select:hover {
  border-color: #7f9ca3;
}

.query-button {
  width: 100%;
  min-height: 46px;
  margin: 17px 0 22px;
  border: 0;
  border-radius: 5px;
  color: #ffffff;
  background: var(--teal);
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 7px 16px rgba(8, 127, 123, 0.2);
}

.query-button:hover {
  background: var(--teal-dark);
}

.query-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.map-toolbar {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.map-mode {
  display: inline-flex;
  flex: 0 0 auto;
  padding: 3px;
  border: 1px solid #becbd0;
  border-radius: 5px;
  background: #ffffff;
}

.map-mode button {
  min-height: 30px;
  padding: 5px 9px;
  border: 0;
  border-radius: 3px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.map-mode button.active {
  color: #ffffff;
  background: var(--teal);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 9px;
}

.legend[hidden] {
  display: none;
}

.legend > span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.legend-swatch {
  width: 10px;
  height: 10px;
  display: inline-block;
  border: 1px solid rgba(20, 33, 43, 0.18);
}

.legend-swatch.safe { background: #4aa779; }
.legend-swatch.watch { background: #e7ad3e; }
.legend-swatch.danger { background: #d65b46; }
.legend-swatch.no-data { background: #cad3d6; }
.legend-swatch.temp-cool { background: #2f78aa; }
.legend-swatch.temp-mild { background: #2c9c99; }
.legend-swatch.temp-warm { background: #58a96e; }
.legend-swatch.temp-hot { background: #e4a436; }
.legend-swatch.temp-extreme { background: #cf543c; }

.map {
  width: 100%;
  height: clamp(440px, 60vh, 700px);
  border: 1px solid #9fb0b6;
  border-radius: 6px;
  background: #dbe6e6;
  overflow: hidden;
}

.map-caption {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.leaflet-container {
  font-family: inherit;
}

.leaflet-control-layers,
.leaflet-bar {
  border: 1px solid rgba(20, 33, 43, 0.28) !important;
  box-shadow: 0 5px 16px rgba(20, 33, 43, 0.12) !important;
}

.leaflet-tooltip {
  border: 0;
  border-radius: 4px;
  color: #ffffff;
  background: rgba(20, 33, 43, 0.92);
  box-shadow: none;
}

.leaflet-tooltip::before {
  border-top-color: rgba(20, 33, 43, 0.92) !important;
}

.risk-summary {
  padding: 22px 24px;
  border-left: 6px solid #95a7ad;
  background: #f1f5f6;
}

.risk-summary[data-level="safe"] {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.risk-summary[data-level="watch"] {
  border-color: var(--amber);
  background: var(--amber-soft);
}

.risk-summary[data-level="danger"] {
  border-color: var(--coral);
  background: var(--coral-soft);
}

.risk-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  font-size: 13px;
}

.risk-state {
  padding: 5px 9px;
  border-radius: 4px;
  color: #ffffff;
  background: #71828b;
  font-weight: 800;
}

.risk-summary[data-level="safe"] .risk-state { background: var(--teal); }
.risk-summary[data-level="watch"] .risk-state { background: var(--amber); }
.risk-summary[data-level="danger"] .risk-state { background: var(--coral); }

.risk-summary h2 {
  margin: 13px 0 7px;
  font-size: clamp(22px, 2.4vw, 31px);
  line-height: 1.28;
}

.risk-summary p {
  margin: 0;
  color: #4f626d;
  font-size: 15px;
  line-height: 1.75;
}

.trial-notice {
  padding: 13px 15px;
  border-left: 4px solid var(--amber);
  background: var(--amber-soft);
}

.trial-notice strong {
  display: block;
  color: #85580e;
  font-size: 14px;
}

.trial-notice p {
  margin: 5px 0 0;
  color: #6d5a35;
  font-size: 13px;
  line-height: 1.6;
}

.trial-notice a {
  display: inline-block;
  margin-top: 7px;
  color: var(--teal-dark);
  font-size: 13px;
  font-weight: 800;
}

.location-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
}

.location-strip > div {
  min-width: 0;
  padding: 13px 15px;
  border-right: 1px solid var(--soft-line);
}

.location-strip > div:last-child {
  border-right: 0;
}

.location-strip span,
.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.location-strip strong {
  display: block;
  margin-top: 5px;
  font-size: 15px;
  overflow-wrap: anywhere;
}

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

.metric-card {
  min-height: 132px;
  padding: 15px;
  border: 1px solid var(--line);
  border-top: 4px solid #b9c9ce;
  border-radius: 6px;
  background: #ffffff;
}

.metric-card.primary-metric {
  border-top-color: var(--blue);
  background: var(--blue-soft);
}

.metric-card.threshold-metric {
  border-top-color: var(--teal);
}

.metric-card.cold-metric {
  border-top-color: #7b77a8;
}

.metric-card strong {
  display: block;
  margin: 10px 0 8px;
  font-size: clamp(23px, 2.2vw, 31px);
  line-height: 1;
  white-space: nowrap;
}

html[lang="en"] .metric-card strong {
  font-size: 24px;
  line-height: 1.15;
  white-space: normal;
  overflow-wrap: anywhere;
}

.metric-card small {
  display: block;
  color: #70818b;
  font-size: 11px;
  line-height: 1.35;
}

.chart-frame {
  position: relative;
  height: 330px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  overflow: hidden;
}

.trend-chart {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.chart-tooltip {
  position: absolute;
  z-index: 3;
  min-width: 126px;
  padding: 8px 10px;
  pointer-events: none;
  border-radius: 4px;
  color: #ffffff;
  background: rgba(20, 33, 43, 0.94);
  font-size: 12px;
  line-height: 1.45;
  box-shadow: 0 7px 18px rgba(20, 33, 43, 0.18);
}

.decision-section {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(300px, 0.9fr);
  gap: 28px;
  padding: 21px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.decision-copy p {
  margin: 12px 0 0;
  color: #43555f;
  font-size: 15px;
  line-height: 1.8;
}

.cell-details dl {
  margin: 0;
}

.cell-details dl > div {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr);
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--soft-line);
}

.cell-details dl > div:last-child {
  border-bottom: 0;
}

.cell-details dt {
  color: var(--muted);
  font-size: 12px;
}

.cell-details dd {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
}

.quality-warning {
  padding: 14px 16px;
  border: 1px solid #e7bd69;
  border-radius: 5px;
  background: var(--amber-soft);
}

.quality-warning strong {
  color: #85580e;
}

.quality-warning p {
  margin: 5px 0 0;
  color: #6d5a35;
  font-size: 13px;
  line-height: 1.6;
}

footer {
  width: min(1800px, 100%);
  margin: 0 auto;
  padding: 18px clamp(20px, 3vw, 42px) 26px;
  color: #64757f;
  background: #eef3f3;
  border-top: 1px solid var(--line);
  font-size: 12px;
  line-height: 1.7;
}

footer p {
  margin: 4px 0;
}

footer a {
  color: var(--teal-dark);
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: minmax(340px, 0.86fr) minmax(520px, 1.2fr);
  }

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

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

  .location-strip > div:nth-child(2) {
    border-right: 0;
  }

  .location-strip > div:nth-child(-n + 2) {
    border-bottom: 1px solid var(--soft-line);
  }

  .decision-section {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .app-header {
    align-items: flex-start;
  }

  .data-status {
    white-space: normal;
  }

  .app-shell {
    display: block;
  }

  .control-column {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .map {
    height: 520px;
  }
}

@media (max-width: 560px) {
  .app-header {
    min-height: 0;
    padding: 13px 15px;
    flex-direction: column;
    gap: 10px;
  }

  .brand-mark {
    width: 24px;
    height: 34px;
  }

  .data-status {
    min-height: 30px;
    padding: 5px 8px;
  }

  .app-header .module-nav {
    width: 100%;
  }

  .language-switch {
    width: 100%;
  }

  .app-header .module-nav a {
    flex: 1;
  }

  .language-switch button {
    flex: 1;
  }

  .control-column,
  .result-column {
    padding: 18px 14px;
  }

  .control-grid,
  .metric-grid,
  .location-strip {
    grid-template-columns: 1fr;
  }

  .wide-control {
    grid-column: auto;
  }

  .map-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .legend {
    justify-content: flex-start;
  }

  .map {
    height: 430px;
  }

  .location-strip > div,
  .location-strip > div:nth-child(2) {
    border-right: 0;
    border-bottom: 1px solid var(--soft-line);
  }

  .location-strip > div:last-child {
    border-bottom: 0;
  }

  .metric-card {
    min-height: 108px;
  }

  .chart-frame {
    height: 280px;
  }

  .risk-topline,
  .section-heading.compact {
    align-items: flex-start;
    flex-direction: column;
    gap: 7px;
  }

  .cell-details dl > div {
    grid-template-columns: 78px minmax(0, 1fr);
  }
}
