:root {
  --bg: #f6f8fb;
  --panel: #ffffff;
  --ink: #1f2a3d;
  --muted: #6b7a90;
  --accent: #1ea9ff;
  --accent-2: #ff7a59;
  --border: #e0e6ed;
  --shadow: 0 10px 30px rgba(31, 42, 61, 0.08);
  --radius: 14px;
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
}

.topbar {
  height: 64px;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  background: #0f9bf2;
  color: #fff;
}

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

.brand .dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.25);
}

.brand-title {
  font-weight: 700;
  font-size: 16px;
}

.brand-sub {
  font-size: 12px;
  opacity: 0.85;
}

.search {
  flex: 1;
  display: flex;
}

.search input {
  width: 100%;
  padding: 10px 14px;
  border: none;
  border-radius: 999px;
  outline: none;
  font-size: 14px;
  color: #0c3a5a;
}

.actions button {
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #fff;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: not-allowed;
}

.layout {
  display: grid;
  grid-template-columns: 1.3fr 0.7fr;
  gap: 16px;
  padding: 16px;
  height: calc(100vh - 64px);
}

.map-panel {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

#map {
  width: 100%;
  height: 100%;
  position: relative;
  z-index: 1;
}

.map-hint {
  position: absolute;
  left: 16px;
  bottom: 16px;
  background: rgba(255, 255, 255, 0.92);
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 13px;
  color: var(--muted);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
  pointer-events: none;
  z-index: 2;
}

.leaflet-basemap-source-control {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(31, 42, 61, 0.16);
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(31, 42, 61, 0.12);
  color: var(--ink);
  font-family: var(--font);
}

.leaflet-basemap-source-control .basemap-source-title {
  padding: 0 6px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.leaflet-basemap-source-control .basemap-source-option {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  cursor: pointer;
}

.leaflet-basemap-source-control .basemap-source-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.leaflet-basemap-source-control .basemap-source-option span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1;
  color: var(--muted);
  white-space: nowrap;
}

.leaflet-basemap-source-control .basemap-source-option:hover span {
  border-color: rgba(30, 169, 255, 0.3);
  color: var(--ink);
}

.leaflet-basemap-source-control .basemap-source-option input:focus-visible + span {
  outline: 2px solid rgba(30, 169, 255, 0.45);
  outline-offset: 2px;
}

.leaflet-basemap-source-control .basemap-source-option input:checked + span {
  background: rgba(30, 169, 255, 0.12);
  border-color: rgba(30, 169, 255, 0.45);
  color: #0c7fc0;
  font-weight: 600;
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding-right: 4px;
}

.tool-pane {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hidden {
  display: none !important;
}

.card {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  border: 1px solid var(--border);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.card-header.with-action {
  align-items: flex-start;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 12px;
  color: var(--muted);
}

h3 {
  margin: 4px 0 0;
  font-size: 18px;
}

.badge {
  background: rgba(30, 169, 255, 0.12);
  color: var(--accent);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid rgba(30, 169, 255, 0.3);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
  font-size: 14px;
}

.field input {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
}

.field-row {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.field-row.triple {
  align-items: flex-end;
}

.field-row.single {
  justify-content: flex-start;
  align-items: center;
}

.select-row {
  justify-content: flex-start;
  gap: 12px;
}

.select-btn {
  min-width: 84px;
}

.select-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(30, 169, 255, 0.08);
}

.ghost-btn {
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-size: 14px;
  box-shadow: 0 4px 10px rgba(31, 42, 61, 0.06);
  transition: all 0.15s ease;
}

.ghost-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 6px 14px rgba(15, 155, 242, 0.18);
}

.ghost-btn.active {
  border-color: var(--accent);
  background: rgba(30, 169, 255, 0.12);
  color: var(--accent);
}

.pane-toggle {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(30, 169, 255, 0.08);
}

.pane-toggle:hover {
  border-color: var(--accent-2);
  color: var(--accent-2);
  background: rgba(255, 122, 89, 0.12);
}

.field-row .field {
  flex: 1;
  margin-bottom: 0;
}

.elevation-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  font-size: 14px;
  color: var(--muted);
}

.elevation-value {
  padding: 6px 10px;
  border-radius: 10px;
  background: #f0f4fa;
  color: var(--ink);
  font-weight: 600;
}

.elevation-field {
  flex: 0.9;
}

.elevation-field .elevation-value {
  min-height: 40px;
  display: flex;
  align-items: center;
}

.field-label {
  font-size: 14px;
  color: var(--muted);
  min-width: 120px;
}

.readonly-input {
  background: #f0f4fa;
  border: 1px solid var(--border);
  color: var(--ink);
  font-weight: 600;
}

.title-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 8px 0 6px;
}

.dam-marker .dam-pin {
  background: linear-gradient(120deg, #ff7a59, #ff9a7a);
  color: #fff;
  padding: 6px 10px;
  border-radius: 12px;
  border: 2px solid #fff;
  box-shadow: 0 8px 18px rgba(255, 122, 89, 0.35);
  font-weight: 700;
  font-size: 13px;
  transform: translateY(-6px);
}

.station-marker .station-pin {
  background: linear-gradient(120deg, #0f9bf2, #2fd1ff);
  color: #fff;
  padding: 6px 10px;
  border-radius: 12px;
  border: 2px solid #fff;
  box-shadow: 0 8px 18px rgba(15, 155, 242, 0.35);
  font-weight: 700;
  font-size: 13px;
  transform: translateY(-6px);
}

.actions-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.primary {
  background: linear-gradient(120deg, #0f9bf2, #29d1ff);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 10px 16px;
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(15, 155, 242, 0.35);
}

.primary:disabled {
  cursor: not-allowed;
  opacity: 0.6;
  box-shadow: none;
}

.inline-hint {
  font-size: 12px;
  color: var(--muted);
}

.dam-row {
  gap: 12px;
}

.dam-row .inline-hint {
  margin-left: 4px;
}

.hydro-actions {
  justify-content: flex-start;
}

.layer-toggle-group {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
  flex: 1;
  flex-wrap: wrap;
}

.layer-row {
  margin: 4px 0 0;
  padding-left: 2px;
}

.layer-toggle-group label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.status-card .muted,
.muted {
  color: var(--muted);
  font-size: 13px;
}

.status-pill {
  padding: 6px 12px;
  border-radius: 999px;
  background: #fff1dc;
  color: #9b5200;
  border: 1px solid #ffd9a6;
  font-size: 12px;
}

.status-pill.ready {
  background: #e6f8ef;
  color: #0f8d4b;
  border-color: #b5e8cb;
}

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

.stat {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f9fbff;
}

.stat .label {
  display: block;
  font-size: 12px;
  color: var(--muted);
}

.stat .value {
  display: inline-block;
  font-size: 18px;
  font-weight: 700;
  margin-right: 6px;
}

.stat .unit {
  font-size: 12px;
  color: var(--muted);
}

.level0a-summary {
  min-height: 48px;
}

.flow-comparison {
  margin-top: 12px;
}

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

.level0a-item {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f9fbff;
  min-width: 0;
}

.level0a-item .label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.level0a-item .value {
  display: block;
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.flow-comparison-title {
  margin: 0 0 10px;
  font-size: 14px;
  color: var(--ink);
}

.flow-source-group {
  margin-top: 10px;
}

.flow-source-group-title {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

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

.flow-source {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfcff;
  min-width: 0;
}

.flow-source.skipped {
  background: #f7f9fc;
  border-style: dashed;
}

.flow-source.error {
  background: #fff8f6;
  border-color: rgba(255, 122, 89, 0.45);
}

.flow-source h5 {
  margin: 0 0 8px;
  font-size: 15px;
  color: var(--ink);
  line-height: 1.25;
}

.flow-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 8px;
  padding: 7px 0;
  border-top: 1px solid rgba(16, 24, 40, 0.06);
}

.flow-field .label,
.flow-differences .label {
  color: var(--muted);
  font-size: 12px;
}

.flow-field .value {
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  justify-self: end;
  line-height: 1.35;
  text-align: right;
  overflow-wrap: normal;
  word-break: normal;
}

.flow-measure {
  display: inline-flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 3px;
  white-space: nowrap;
}

.flow-unit {
  color: var(--muted);
  font-size: 0.9em;
  font-weight: 700;
}

.flow-status {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(22, 163, 74, 0.1);
  color: #137333;
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
}

.flow-status.skipped,
.flow-status.error {
  background: #f7f9fc;
  color: var(--muted);
}

.flow-warning-field {
  align-items: start;
}

.flow-warning-list {
  margin: 0;
  padding-left: 16px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  overflow-wrap: break-word;
}

.flow-warning-list li + li {
  margin-top: 3px;
}

.flow-differences {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.flow-difference {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #f5f7fa;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  overflow-wrap: break-word;
  word-break: normal;
}

.reference-correction {
  margin-top: 12px;
  padding: 10px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: #f5f7fa;
}

.reference-correction span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.reference-correction strong {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
}

.summary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.summary-table th {
  text-align: left;
  color: var(--muted);
  font-size: 12px;
  padding: 8px 6px;
  border-bottom: 1px solid var(--border);
}

.summary-table td {
  padding: 10px 6px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  word-break: break-word;
}

.summary-table tr:last-child td {
  border-bottom: none;
}

.summary-table .value {
  font-size: 15px;
  font-weight: 700;
}

.summary-table .unit {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.summary-table .desc {
  color: var(--muted);
}

.image-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.image-grid img {
  width: 100%;
  height: auto;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
  cursor: zoom-in;
}

.image-grid > div {
  width: 100%;
}

.monthly-runoff-panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.monthly-runoff-panel h4 {
  margin: 0 0 10px;
  font-size: 14px;
}

.monthly-runoff-chart {
  width: 100%;
  height: auto;
  margin-bottom: 10px;
}

.monthly-runoff-chart line {
  stroke: var(--border);
  stroke-width: 1;
}

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

.monthly-runoff-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.monthly-runoff-table th,
.monthly-runoff-table td {
  border-bottom: 1px solid var(--border);
  padding: 6px 8px;
  text-align: right;
}

.monthly-runoff-table th:first-child,
.monthly-runoff-table td:first-child {
  text-align: left;
}

.image-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 2000;
}

.image-modal.hidden {
  display: none;
}

.image-modal-content {
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-modal-content img {
  max-width: 90vw;
  max-height: 90vh;
  width: auto;
  height: auto;
  object-fit: contain;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
}

.image-grid .caption {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr;
    height: auto;
  }
  .map-panel {
    min-height: 360px;
  }
  .side-panel {
    max-height: unset;
  }
  .level0a-grid {
    grid-template-columns: 1fr;
  }
  .flow-field {
    grid-template-columns: 1fr;
    gap: 2px;
  }
  .flow-field .value {
    justify-self: start;
    text-align: left;
  }
}

@media (max-width: 720px) {
  .flow-source-grid {
    grid-template-columns: 1fr;
  }
}

/* ─── NC 文件图层面板 ─── */
.nc-layer-panel {
  margin: 8px 0 4px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
}

.nc-upload-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.nc-upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  background: linear-gradient(135deg, #e8f4ff, #f0f8ff);
  border-color: var(--accent);
  color: var(--accent);
  transition: all 0.2s ease;
}

.nc-upload-btn:hover {
  background: linear-gradient(135deg, #d0ebff, #e0f2ff);
  box-shadow: 0 4px 12px rgba(30, 169, 255, 0.2);
  transform: translateY(-1px);
}

.nc-filename {
  font-size: 12px;
  color: var(--muted);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nc-controls {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nc-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nc-label {
  font-size: 12px;
  color: var(--muted);
  min-width: 48px;
  flex-shrink: 0;
}

.nc-select {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  background: #fff;
  color: var(--ink);
  outline: none;
  max-width: 240px;
}

.nc-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(30, 169, 255, 0.1);
}

.nc-slider {
  flex: 1;
  height: 4px;
  cursor: pointer;
  accent-color: var(--accent);
}

#nc-opacity-value {
  font-size: 12px;
  color: var(--muted);
  width: 36px;
  text-align: right;
}

.nc-toggle-row {
  justify-content: space-between;
}

.nc-toggle-row label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}

.nc-stats {
  font-size: 11px;
  color: var(--muted);
  font-family: monospace;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
