:root {
  color-scheme: light;
  --ink: #17211f;
  --muted: #63706c;
  --line: rgba(23, 33, 31, 0.14);
  --paper: #fffdf7;
  --card: rgba(255, 255, 255, 0.82);
  --green: #1f7a62;
  --blue: #256fa5;
  --coral: #d95f43;
  --sand: #f1d28a;
  --shadow: 0 18px 50px rgba(28, 46, 43, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 16% 12%, rgba(37, 111, 165, 0.2), transparent 26rem),
    radial-gradient(circle at 88% 4%, rgba(31, 122, 98, 0.2), transparent 25rem),
    linear-gradient(135deg, #fbf5e6 0%, #e9f2ee 50%, #eef0e4 100%);
}

button,
input {
  font: inherit;
}

a {
  color: inherit;
}

.shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 22px 0 42px;
}

.hero {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 28px;
  min-height: 340px;
  padding: 26px;
  display: grid;
  align-items: end;
  box-shadow: var(--shadow);
  background:
    radial-gradient(circle at 78% 30%, rgba(241, 210, 138, 0.22), transparent 22rem),
    radial-gradient(circle at 20% 80%, rgba(37, 111, 165, 0.35), transparent 24rem),
    linear-gradient(140deg, #0f2f33 0%, #11453d 52%, #0e2b3a 100%);
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 253, 247, 0.16) 1px, transparent 1.6px);
  background-size: 22px 22px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.7), transparent 78%);
  -webkit-mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.7), transparent 78%);
}

.hero > * {
  position: relative;
}

.topbar {
  position: absolute;
  top: 20px;
  left: 24px;
  right: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  color: #fffdf7;
  z-index: 2;
}

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

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(12px);
}

.summary-link,
.ghost-link {
  border: 1px solid rgba(255, 255, 255, 0.45);
  color: #fffdf7;
  text-decoration: none;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(12px);
  white-space: nowrap;
}

.hero-copy {
  width: min(760px, 100%);
  color: #fffdf7;
  padding-top: 86px;
}

.eyebrow {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  margin: 0 0 12px;
  color: rgba(255, 253, 247, 0.84);
  font-size: 0.92rem;
}

h1 {
  margin: 0;
  font-size: clamp(2.1rem, 6vw, 5.2rem);
  line-height: 0.96;
  letter-spacing: 0;
}

.hero-title {
  max-width: 10.8em;
}

.hero-title span {
  display: block;
}

.hero-copy p {
  margin: 16px 0 0;
  color: rgba(255, 253, 247, 0.86);
  font-size: clamp(1rem, 2.4vw, 1.22rem);
  line-height: 1.7;
}

.name-panel {
  margin-top: 16px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  width: min(560px, 100%);
}

.name-panel input,
.password-panel input,
.search-panel input {
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.58);
  background: rgba(255, 255, 255, 0.88);
  border-radius: 999px;
  padding: 14px 18px;
  outline: none;
}

.primary-btn,
.submit-btn {
  border: 0;
  border-radius: 999px;
  padding: 14px 20px;
  color: #fffdf7;
  background: linear-gradient(135deg, var(--green), var(--blue));
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 12px 26px rgba(31, 122, 98, 0.24);
}

.primary-btn:disabled,
.submit-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

.secondary-btn {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 13px 18px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
  font-weight: 800;
  cursor: pointer;
}

.status-line {
  min-height: 22px;
  margin: 12px 0 0;
  color: rgba(255, 253, 247, 0.82);
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin: 30px 2px 14px;
}

.section-head h2 {
  margin: 0;
  font-size: clamp(1.6rem, 3.6vw, 2.6rem);
}

.section-head p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

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

.print-stamp {
  display: none;
}

.progress-pill {
  flex: 0 0 auto;
  padding: 11px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
  color: var(--muted);
}

.progress-pill strong {
  color: var(--green);
}

/* ---- 标注区：地图主体 + 搜索 + 已标注 ---- */

.map-panel,
.chips-panel,
.panel {
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 22px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.62);
  box-shadow: 0 12px 28px rgba(28, 46, 43, 0.08);
}

.chips-panel {
  margin-top: 16px;
}

.map-panel h3,
.chips-panel h3,
.panel h2,
.panel h3 {
  margin: 0 0 12px;
}

.map-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.search-wrap {
  position: relative;
  width: min(460px, 100%);
}

.search-wrap input {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  border-radius: 999px;
  padding: 12px 18px;
  outline: none;
}

.search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 20;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.search-option {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  border: 0;
  background: transparent;
  padding: 11px 16px;
  cursor: pointer;
  text-align: left;
  font-size: 0.95rem;
}

.search-option:hover,
.search-option.is-active {
  background: rgba(31, 122, 98, 0.1);
}

.search-option span {
  color: var(--muted);
  font-size: 0.85rem;
}

.map-box {
  width: 100%;
  height: min(68vh, 640px);
  min-height: 420px;
  border-radius: 16px;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(37, 111, 165, 0.08), rgba(31, 122, 98, 0.06));
}

.map-tip {
  margin: 10px 2px 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.6;
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 12px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.legend-item i {
  width: 18px;
  height: 18px;
  border-radius: 6px;
  border: 1px solid rgba(23, 33, 31, 0.18);
}

.selected-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.selected-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 8px 8px 8px 14px;
  background: linear-gradient(135deg, var(--green), var(--blue));
  color: #fffdf7;
  cursor: pointer;
  font-size: 0.92rem;
  line-height: 1.2;
}

.selected-chip em {
  font-style: normal;
  font-size: 0.8rem;
  opacity: 0.85;
}

.selected-chip .chip-x {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.24);
  color: #fffdf7;
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  padding: 0;
}

/* ---- 编辑器弹窗 ---- */

.editor-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 32, 29, 0.48);
  backdrop-filter: blur(6px);
}

.editor-card {
  width: min(440px, 100%);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 22px;
  padding: 20px;
  background: #fffdf7;
  box-shadow: var(--shadow);
}

.editor-card h3 {
  margin: 0 0 14px;
  font-size: 1.3rem;
}

.editor-field {
  margin-bottom: 12px;
}

.editor-field label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.editor-field input,
.editor-field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.9);
  padding: 11px 14px;
  outline: none;
  font: inherit;
  resize: vertical;
}

.visit-rows {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.visit-row {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) 30px;
  gap: 8px;
  align-items: center;
}

.visit-row input,
.visit-row select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.9);
  padding: 10px 12px;
  outline: none;
  font: inherit;
}

.visit-del {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.8);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
  padding: 0;
}

.visit-del:hover {
  color: var(--coral);
  border-color: var(--coral);
}

.editor-add {
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: transparent;
  color: var(--green);
  font-weight: 800;
  cursor: pointer;
  padding: 9px 14px;
  margin-bottom: 10px;
}

.editor-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 6px;
}

.editor-spacer {
  flex: 1;
}

.editor-unmark {
  border: 0;
  background: transparent;
  color: var(--coral);
  font-weight: 800;
  cursor: pointer;
  padding: 10px 4px;
}

.picker-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.picker-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 16px;
  background: rgba(255, 255, 255, 0.85);
  cursor: pointer;
  font-size: 0.95rem;
}

.picker-chip.is-selected {
  color: #fffdf7;
  background: linear-gradient(135deg, var(--green), var(--blue));
  border-color: transparent;
}

.list-empty {
  color: var(--muted);
  padding: 8px 2px;
}

.action-bar {
  position: sticky;
  bottom: 10px;
  z-index: 5;
  margin-top: 20px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 20px;
  background: rgba(255, 253, 247, 0.86);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}

.submit-note {
  color: var(--muted);
  line-height: 1.5;
}

/* ---- 汇总页 ---- */

.summary-page .hero {
  min-height: 260px;
}

.password-panel {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 18px;
  width: min(520px, 100%);
}

.member-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 16px;
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.55);
}

.member-filter .filter-label {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
  margin-right: 4px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 20px;
}

.kpi-card {
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 20px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.66);
  box-shadow: 0 10px 26px rgba(28, 46, 43, 0.08);
}

.kpi-card span {
  color: var(--muted);
  font-size: 0.92rem;
}

.kpi-card strong {
  display: block;
  margin-top: 6px;
  font-size: clamp(1.7rem, 3.4vw, 2.5rem);
  line-height: 1;
}

.kpi-card small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.5;
}

.kpi-card:nth-child(1) { border-top: 5px solid var(--green); }
.kpi-card:nth-child(2) { border-top: 5px solid var(--blue); }
.kpi-card:nth-child(3) { border-top: 5px solid var(--coral); }
.kpi-card:nth-child(4) { border-top: 5px solid var(--sand); }

.chart-panel {
  margin-top: 16px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 22px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.62);
  box-shadow: 0 12px 28px rgba(28, 46, 43, 0.08);
}

.chart-panel h3 {
  margin: 0 0 4px;
}

.chart-panel .chart-sub {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.6;
}

.chart-box {
  width: 100%;
  height: 380px;
}

.chart-box.tall {
  height: min(64vh, 560px);
  min-height: 380px;
}

.timeline-list {
  max-height: 380px;
  overflow-y: auto;
  padding-right: 6px;
}

.timeline-year {
  margin: 0 0 6px;
  font-size: 1.05rem;
  font-weight: 900;
  color: var(--green);
}

.timeline-year:not(:first-child) {
  margin-top: 16px;
}

.timeline-item {
  display: flex;
  gap: 8px;
  align-items: baseline;
  padding: 5px 0;
  border-bottom: 1px dashed rgba(23, 33, 31, 0.1);
  line-height: 1.5;
}

.timeline-item:last-child {
  border-bottom: 0;
}

.timeline-item strong {
  flex: 0 0 auto;
}

.timeline-item em {
  font-style: normal;
  color: var(--muted);
}

.chart-duo {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}

.matrix-wrap {
  overflow-x: auto;
}

.matrix {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 8px;
  min-width: 640px;
}

.matrix th,
.matrix td {
  padding: 10px 12px;
  text-align: left;
  background: rgba(255, 255, 255, 0.7);
}

.matrix th:first-child,
.matrix td:first-child {
  border-radius: 12px 0 0 12px;
  position: sticky;
  left: 0;
}

.matrix th:last-child,
.matrix td:last-child {
  border-radius: 0 12px 12px 0;
}

.matrix .tick {
  color: var(--green);
  font-weight: 900;
}

.empty-state {
  color: var(--muted);
  line-height: 1.7;
}

.hidden {
  display: none !important;
}

@media (max-width: 900px) {
  .chart-duo,
  .kpi-grid {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 641px) and (max-width: 1024px) {
  .shell {
    width: min(100% - 32px, 1180px);
  }

  .hero {
    min-height: 380px;
  }

  .hero-copy {
    width: min(680px, 100%);
  }
}

@media (max-width: 640px) {
  .shell {
    width: min(100% - 18px, 1180px);
    padding-top: 9px;
  }

  .hero {
    min-height: 430px;
    border-radius: 22px;
    padding: 18px;
  }

  .hero-copy {
    padding-top: 104px;
  }

  h1 {
    font-size: clamp(2.35rem, 11vw, 3.75rem);
    line-height: 1.02;
  }

  .hero-title {
    max-width: 7.2em;
  }

  .topbar {
    top: 14px;
    left: 16px;
    right: 16px;
  }

  .summary-link,
  .ghost-link {
    padding: 9px 11px;
    font-size: 0.86rem;
  }

  .name-panel,
  .password-panel,
  .action-bar,
  .section-head {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .section-head {
    display: block;
  }

  .summary-actions {
    margin-top: 14px;
  }

  .progress-pill {
    display: inline-flex;
    margin-top: 10px;
  }

  .map-box {
    height: 52vh;
    min-height: 320px;
  }

  .chart-box {
    height: 320px;
  }
}

@page {
  size: A4 landscape;
  margin: 10mm;
}

@media print {
  :root {
    --ink: #17211f;
    --muted: #51605a;
    --line: rgba(23, 33, 31, 0.18);
  }

  * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  body {
    min-height: 0;
    background: #fff;
  }

  .shell {
    width: 100%;
    padding: 0;
  }

  .summary-page .hero {
    min-height: 0;
    padding: 12mm;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    break-after: avoid;
  }

  .topbar,
  .password-panel,
  #summaryStatus,
  .summary-actions,
  .member-filter,
  .action-bar {
    display: none !important;
  }

  .hero-copy {
    width: 100%;
    padding: 0;
  }

  .hero-copy h1 {
    font-size: 34pt;
    line-height: 1;
  }

  .hero-copy .eyebrow {
    margin-bottom: 8px;
    font-size: 10pt;
  }

  .section-head {
    margin: 8mm 0 4mm;
  }

  .section-head h2 {
    font-size: 22pt;
  }

  .section-head p {
    margin-top: 3px;
    font-size: 10pt;
  }

  .print-stamp {
    display: block;
  }

  .kpi-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 5mm;
  }

  .kpi-card,
  .chart-panel {
    border: 1px solid var(--line);
    border-radius: 0;
    padding: 5mm;
    box-shadow: none;
    background: #fff;
    break-inside: avoid;
  }

  .chart-duo {
    grid-template-columns: 1fr 1fr;
    gap: 5mm;
  }

  .chart-box,
  .chart-box.tall {
    height: 86mm;
    min-height: 0;
  }

  .timeline-list {
    max-height: none;
    overflow: visible;
  }

  .matrix-wrap {
    overflow: visible;
  }

  .matrix {
    min-width: 0;
    border-spacing: 0 3px;
    font-size: 8.5pt;
  }

  .matrix th,
  .matrix td {
    padding: 5px 6px;
    background: #fff;
    border-bottom: 1px solid rgba(23, 33, 31, 0.1);
  }

  .matrix th:first-child,
  .matrix td:first-child {
    position: static;
    min-width: 110px;
    border-radius: 0;
  }

  .matrix th:last-child,
  .matrix td:last-child {
    border-radius: 0;
  }

  .matrix tr {
    break-inside: avoid;
  }
}
