:root {
  color-scheme: light;
  --bg: #f3f6f4;
  --panel: #ffffff;
  --line: #d8e2dc;
  --text: #17211d;
  --muted: #61706a;
  --green: #1f5f4a;
  --green-soft: #e3f0ea;
  --red: #9c2f2f;
  --amber: #916b1e;
}

* {
  box-sizing: border-box;
}

/* 始终保留滚动条位置：内容短于视口时不再收走滚动条，
   否则跨页跳转（工作台 ⇄ 数据详情）时整页会横向抖一下。 */
html {
  overflow-y: scroll;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

.sidebar {
  min-height: 100vh;
  padding: 22px;
  background: #ffffff;
  border-right: 1px solid var(--line);
  position: sticky;
  top: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--green);
  display: inline-block;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--muted);
  margin-top: 3px;
}

nav {
  display: grid;
  gap: 8px;
}

.nav-item,
.docs-link,
button,
input,
select,
textarea {
  font: inherit;
}

.nav-item,
.docs-link {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 12px;
  color: var(--text);
  background: transparent;
  text-align: left;
  text-decoration: none;
  display: flex;
  align-items: center;
  cursor: pointer;
}

.nav-item.active,
.nav-item:hover,
.docs-link:hover {
  background: var(--green-soft);
  color: var(--green);
}

.docs-link {
  margin-top: 18px;
}

main {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 22px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
}

h2 {
  font-size: 18px;
}

.topbar p,
.panel-head span,
.empty-state,
.map-empty {
  color: var(--muted);
}

.badge {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--amber);
  white-space: nowrap;
}

.badge.ok {
  color: var(--green);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.metric,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric {
  padding: 18px;
}

.metric span {
  display: block;
  color: var(--muted);
  margin-bottom: 8px;
}

.metric strong {
  font-size: 28px;
}

.panel {
  padding: 18px;
  margin-bottom: 16px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

/* 开发自检数据开关：默认关，避免自检记录占满首屏 */
.filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}

.filter-toggle input {
  width: auto;
  min-height: 0;
  height: 15px;
  margin: 0;
  padding: 0;
  accent-color: var(--green);
}

.map-shell {
  height: 440px;
  border: 1px solid var(--line);
  border-radius: 8px;
  position: relative;
  overflow: hidden;
  background: #f8fbf9;
}

.point-layer {
  position: absolute;
  inset: 0;
}

.point {
  position: absolute;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  background: var(--green);
  border: 2px solid #ffffff;
  box-shadow: 0 2px 8px rgb(0 0 0 / 18%);
}

.map-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 20px;
}

/* 墨卡托投影地图 */
.map-svg {
  display: block;
  width: 100%;
  height: 100%;
}

.map-bg {
  fill: #f8fbf9;
}

.grid-line {
  stroke: #dfe8e3;
  stroke-width: 1;
  stroke-dasharray: 4 4;
}

.axis-label {
  fill: #7b8a84;
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.map-dot {
  cursor: pointer;
  transition: r 120ms ease, opacity 120ms ease;
}

.map-dot:hover {
  r: 10;
  opacity: 0.85;
}

.map-meta {
  position: absolute;
  left: 12px;
  bottom: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  font-size: 12px;
  color: var(--muted);
  background: rgb(255 255 255 / 88%);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 10px;
  max-width: calc(100% - 24px);
}

.map-meta b {
  color: var(--green);
  font-weight: 600;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.chart-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px 10px;
  background: #fcfdfd;
}

.chart-card h3 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.bar-svg {
  display: block;
  width: 100%;
  height: auto;
}

.bar-track {
  fill: #eaf1ed;
}

.bar-label {
  fill: var(--text);
  font-size: 12px;
}

.bar-value {
  fill: var(--muted);
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-item i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  border: 1px solid rgb(255 255 255 / 90%);
  box-shadow: 0 0 0 1px rgb(0 0 0 / 8%);
}

.list {
  display: grid;
  gap: 10px;
}

.item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: start;
}

.item-title {
  font-weight: 700;
  margin-bottom: 5px;
}

/* 记录卡片：左边照片、右边文字，第一眼就能看到「谁拍了什么」 */
.record {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  display: grid;
  grid-template-columns: 208px 1fr;
  gap: 16px;
  padding: 12px;
  align-items: stretch;
}

.record-photos {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-auto-rows: 96px;
  gap: 4px;
  align-content: start;
}

.record-photos.is-empty {
  grid-template-columns: 1fr;
  grid-auto-rows: 156px;
  background: #f4f7f5;
  border: 1px dashed var(--line);
  border-radius: 8px;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
}

.record-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 6px;
  background: #eef3f0;
  cursor: zoom-in;
  display: block;
  transition: opacity 120ms ease;
}

.record-thumb:hover {
  opacity: 0.86;
}

.photo-more {
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 13px;
  font-weight: 600;
}

.record-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.record-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.record-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.4;
  word-break: break-word;
}

.record-status {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px;
  white-space: nowrap;
  flex: none;
}

.record-notes {
  margin: 0;
  font-size: 14px;
  line-height: 1.65;
  color: #2b3a33;
  white-space: pre-wrap;
  word-break: break-word;
}

.record-notes.is-empty {
  color: var(--muted);
  font-style: italic;
}

.record-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: 12px;
  color: var(--muted);
}

.record-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.record-tag {
  background: #f1f5f3;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 8px;
  font-size: 12px;
  color: #4a5a53;
}

.lightbox {
  position: fixed;
  inset: 0;
  background: rgb(12 18 15 / 82%);
  display: grid;
  place-items: center;
  padding: 28px;
  z-index: 60;
  cursor: zoom-out;
}

.lightbox[hidden] {
  display: none;
}

.lightbox img {
  max-width: 92vw;
  max-height: 88vh;
  border-radius: 8px;
  box-shadow: 0 18px 48px rgb(0 0 0 / 45%);
  background: #ffffff;
}

.meta {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.actions {
  display: flex;
  gap: 8px;
}

button {
  border: 0;
  border-radius: 8px;
  min-height: 38px;
  padding: 0 14px;
  cursor: pointer;
}

.primary {
  background: var(--green);
  color: #ffffff;
}

.ghost {
  background: var(--green-soft);
  color: var(--green);
}

.danger {
  background: #f5dddd;
  color: var(--red);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: #304139;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 42px;
  padding: 9px 11px;
  background: #ffffff;
  color: var(--text);
}

textarea {
  resize: vertical;
}

.wide {
  grid-column: 1 / -1;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 20px;
  background: #fbfcfb;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  background: #17211d;
  color: #ffffff;
  border-radius: 8px;
  padding: 12px 14px;
  min-width: 220px;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 860px) {
  body {
    display: block;
  }

  .sidebar {
    min-height: auto;
    position: static;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  nav {
    grid-template-columns: repeat(2, 1fr);
  }

  main {
    padding: 18px;
  }

  .topbar,
  .panel-head {
    display: grid;
  }

  .stats-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .record {
    grid-template-columns: 1fr;
  }

  .record-photos {
    grid-auto-rows: 92px;
  }
}

/* 审核令牌：待审核数据需要管理员身份，令牌只存在本机浏览器 */
.admin-token {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 12px 18px 0;
}

.admin-token label {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

.admin-token input {
  flex: 1 1 220px;
  min-width: 0;
}

.admin-token button {
  white-space: nowrap;
}

.admin-token-state {
  font-size: 12px;
  color: var(--muted);
}


/* Role visibility must override the navigation flex layout. */
#navReview[hidden] { display: none !important; }
