/* 通用基础样式与组件 */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--c-bg);
  color: var(--c-ink);
  font-family: var(--f-sans);
  font-size: var(--fs-md);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.35; text-wrap: balance; font-weight: 600; }
p { margin: 0; }
a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--c-accent); outline-offset: 2px; }
.mono { font-family: var(--f-mono); font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--c-muted); }
.ink2 { color: var(--c-ink-2); }
.small { font-size: var(--fs-sm); }
.xs { font-size: var(--fs-xs); }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.danger-text { color: var(--c-danger); }
.eyebrow { font-size: var(--fs-xs); letter-spacing: 0.08em; color: var(--c-muted); font-weight: 500; }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: var(--r-md);
  border: 1px solid var(--c-line-strong); background: var(--c-surface);
  cursor: pointer; font-size: var(--fs-md); white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { border-color: var(--c-primary); color: var(--c-primary); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--c-primary); border-color: var(--c-primary); color: var(--c-primary-ink); }
.btn-primary:hover { background: var(--c-primary-hover); color: var(--c-primary-ink); }
.btn-accent { background: var(--c-accent); border-color: var(--c-accent); color: #fff; }
.btn-accent:hover { filter: brightness(1.05); color: #fff; border-color: var(--c-accent); }
.btn-danger { color: var(--c-danger); border-color: var(--c-danger); background: transparent; }
.btn-danger:hover { background: var(--c-danger); color: #fff; border-color: var(--c-danger); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { height: 28px; padding: 0 10px; font-size: var(--fs-sm); }
.btn-lg { height: 44px; padding: 0 20px; font-size: var(--fs-lg); border-radius: var(--r-lg); }
.btn-block { width: 100%; }
.link-btn { border: 0; background: none; padding: 0; color: var(--c-primary); cursor: pointer; font-size: inherit; }
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--c-danger); }
.link-btn:disabled { color: var(--c-muted); cursor: not-allowed; text-decoration: none; }

/* 表单 */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field-label { font-size: var(--fs-sm); color: var(--c-ink-2); font-weight: 500; }
.req::before { content: "*"; color: var(--c-danger); margin-right: 3px; }
.input, .select, .textarea {
  width: 100%; height: 36px; padding: 0 10px; border-radius: var(--r-md);
  border: 1px solid var(--c-line-strong); background: var(--c-surface);
  transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; min-height: 84px; padding: 8px 10px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 3px var(--c-primary-soft); }
.input.is-error, .select.is-error, .textarea.is-error { border-color: var(--c-danger); }
.input.is-changed, .textarea.is-changed { background: var(--c-accent-soft); border-color: var(--c-accent); }
.field-error { font-size: var(--fs-xs); color: var(--c-danger); }
.field-hint { font-size: var(--fs-xs); color: var(--c-muted); }
.field-ok { font-size: var(--fs-xs); color: var(--c-ok); }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.check input { accent-color: var(--c-primary); width: 16px; height: 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; height: 30px; padding: 0 12px;
  border-radius: 999px; border: 1px solid var(--c-line-strong); background: var(--c-surface);
  cursor: pointer; font-size: var(--fs-sm); user-select: none;
}
.chip.on { border-color: var(--c-primary); background: var(--c-primary-soft); color: var(--c-primary); font-weight: 500; }
.seg { display: inline-flex; border: 1px solid var(--c-line-strong); border-radius: var(--r-md); overflow: hidden; }
.seg button { border: 0; background: var(--c-surface); padding: 0 14px; height: 32px; cursor: pointer; border-right: 1px solid var(--c-line); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--c-primary); color: var(--c-primary-ink); }

/* 状态标签 */
.tag {
  display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px;
  border-radius: 999px; font-size: var(--fs-xs); font-weight: 500; white-space: nowrap;
  background: var(--c-neutral-soft); color: var(--c-ink-2);
}
.tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.tag.plain::before { display: none; }
.tag.ok { background: var(--c-ok-soft); color: var(--c-ok); }
.tag.warn { background: var(--c-warn-soft); color: var(--c-warn); }
.tag.danger { background: var(--c-danger-soft); color: var(--c-danger); }
.tag.info { background: var(--c-info-soft); color: var(--c-info); }
.tag.accent { background: var(--c-accent-soft); color: var(--c-accent); }
.label-tag {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: var(--r-sm);
  font-size: var(--fs-xs); background: var(--c-surface-2); color: var(--c-ink-2); border: 1px solid var(--c-line);
}
.label-tag.charity { background: var(--c-accent-soft); color: var(--c-accent); border-color: transparent; font-weight: 500; }

/* 卡片、提示条 */
.card { background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r-lg); }
.card-pad { padding: 20px; }
.notice {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: var(--r-md);
  background: var(--c-info-soft); color: var(--c-info); font-size: var(--fs-sm);
}
.notice.warn { background: var(--c-warn-soft); color: var(--c-warn); }
.notice.danger { background: var(--c-danger-soft); color: var(--c-danger); }
.notice.ok { background: var(--c-ok-soft); color: var(--c-ok); }
.notice b { font-weight: 600; }

/* 表格 */
.table-wrap { overflow-x: auto; border: 1px solid var(--c-line); border-radius: var(--r-lg); background: var(--c-surface); }
table.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--c-line); vertical-align: middle; }
.table th { background: var(--c-surface-2); color: var(--c-ink-2); font-weight: 500; white-space: nowrap; position: sticky; top: 0; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--c-surface-2); }
.table td.nowrap, .table th.nowrap { white-space: nowrap; }
.table .ops { display: flex; gap: 12px; white-space: nowrap; }
.table tr.row-error td { background: var(--c-danger-soft); }

/* 键值对 */
.kv { margin: 0; display: grid; grid-template-columns: 140px 1fr; gap: 10px 16px; font-size: var(--fs-sm); }
.kv dt { color: var(--c-muted); }
.kv dd { margin: 0; min-width: 0; word-break: break-all; }

/* 空状态 */
.empty { padding: 40px 16px; text-align: center; color: var(--c-muted); font-size: var(--fs-sm); }

/* 覆盖层：弹窗、抽屉、提示 */
.overlay-host { position: absolute; inset: 0; pointer-events: none; z-index: 900; }
.overlay-host > * { pointer-events: auto; }
.mask { position: absolute; inset: 0; background: var(--c-overlay); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 910; }
.modal {
  background: var(--c-surface); border-radius: var(--r-lg); box-shadow: var(--shadow-2);
  width: min(520px, 100%); max-height: calc(100% - 32px); display: flex; flex-direction: column;
}
.modal.wide { width: min(820px, 100%); }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--c-line); display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.modal-head h3 { font-size: var(--fs-lg); }
.modal-body { padding: 18px 20px; overflow: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { padding: 12px 20px; border-top: 1px solid var(--c-line); display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.close-x { border: 0; background: none; font-size: 20px; line-height: 1; cursor: pointer; color: var(--c-muted); padding: 4px; }
.drawer-mask { justify-content: flex-end; align-items: stretch; padding: 0; }
.drawer { background: var(--c-surface); width: min(640px, 100%); height: 100%; display: flex; flex-direction: column; box-shadow: var(--shadow-2); }
.sheet-mask { align-items: flex-end; padding: 0; }
.sheet { background: var(--c-surface); width: 100%; border-radius: var(--r-lg) var(--r-lg) 0 0; max-height: 85%; display: flex; flex-direction: column; padding-bottom: env(safe-area-inset-bottom, 0px); }
.toasts { position: absolute; top: 16px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 950; width: max-content; max-width: calc(100% - 32px); pointer-events: none; }
.toast { background: var(--c-ink); color: var(--c-bg); padding: 10px 16px; border-radius: var(--r-md); box-shadow: var(--shadow-2); font-size: var(--fs-sm); }
.toast.error { background: var(--c-danger); color: #fff; }
.toast.ok { background: var(--c-ok); color: var(--c-primary-ink); }
.viewer { position: absolute; inset: 0; background: rgba(0,0,0,.85); z-index: 960; display: flex; align-items: center; justify-content: center; padding: 24px; cursor: zoom-out; }
.viewer img { max-height: 100%; border-radius: var(--r-md); background: #fff; }

/* 图片上传 */
.uploads { display: flex; flex-wrap: wrap; gap: 10px; }
.thumb { position: relative; width: 88px; height: 88px; border-radius: var(--r-md); overflow: hidden; border: 1px solid var(--c-line); background: var(--c-surface-2); cursor: zoom-in; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .rm { position: absolute; top: 2px; right: 2px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; line-height: 22px; padding: 0; }
.thumb-add { width: 88px; height: 88px; border-radius: var(--r-md); border: 1px dashed var(--c-line-strong); display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--c-muted); cursor: pointer; font-size: var(--fs-xs); gap: 2px; background: var(--c-surface); }
.thumb-add:hover { border-color: var(--c-primary); color: var(--c-primary); }
.thumb-add span.plus { font-size: 24px; line-height: 1; }

/* 富文本 */
.rte { border: 1px solid var(--c-line-strong); border-radius: var(--r-md); background: var(--c-surface); }
.rte-bar { display: flex; gap: 2px; padding: 4px; border-bottom: 1px solid var(--c-line); flex-wrap: wrap; }
.rte-bar button { border: 0; background: none; min-width: 30px; height: 28px; border-radius: var(--r-sm); cursor: pointer; color: var(--c-ink-2); }
.rte-bar button:hover { background: var(--c-surface-2); }
.rte-area { min-height: 140px; padding: 10px 12px; outline: none; }
.rte-area:empty::before { content: attr(data-placeholder); color: var(--c-muted); }
.rich { line-height: 1.8; word-break: break-word; }
.rich p { margin: 0 0 .6em; }
.rich img { max-width: 100%; border-radius: var(--r-md); margin: 6px 0; }
.rich ul, .rich ol { padding-left: 1.4em; margin: 0 0 .6em; }

/* 地图 */
.map-box { position: relative; background: var(--c-map-bg); overflow: hidden; }
.map-box .leaflet-container { background: var(--c-map-bg); font-family: var(--f-sans); width: 100%; height: 100%; }
.pin {
  width: 30px; height: 30px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  background: var(--c-primary); border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.3);
  display: flex; align-items: center; justify-content: center;
}
.pin i { transform: rotate(45deg); color: #fff; font-style: normal; font-size: 13px; font-weight: 700; }
.pin.charity { background: var(--c-accent); }
.pin.active { width: 38px; height: 38px; }
.pin-cluster {
  width: 42px; height: 42px; border-radius: 50%; background: var(--c-primary); color: #fff; font-weight: 700;
  display: flex; align-items: center; justify-content: center; border: 3px solid rgba(255,255,255,.85);
  box-shadow: 0 0 0 5px rgba(46,122,87,.25); font-size: 14px;
}
.map-attr { position: absolute; right: 6px; bottom: 4px; font-size: 10px; color: var(--c-muted); z-index: 500; background: color-mix(in srgb, var(--c-surface) 70%, transparent); padding: 0 4px; border-radius: 3px; }

/* 迷你图表 */
.chart { width: 100%; display: block; overflow: visible; }
.chart text { fill: var(--c-muted); font-size: 11px; font-family: var(--f-sans); }
.chart .grid { stroke: var(--c-line); stroke-width: 1; }
.chart .bar { fill: var(--c-primary); }
.chart .bar.hl { fill: var(--c-accent); }
.chart .line { stroke: var(--c-primary); stroke-width: 2; fill: none; }
.chart .area { fill: var(--c-primary); opacity: .12; }
.chart-tip { position: absolute; pointer-events: none; background: var(--c-ink); color: var(--c-bg); font-size: 12px; padding: 4px 8px; border-radius: 4px; white-space: nowrap; transform: translate(-50%, -110%); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
.map-box { isolation: isolate; }
.region-row { flex-wrap: nowrap; }
.region-row .select { flex: 1 1 0; min-width: 0; }
.org-form.compact .region-row, .region-stack .region-row { flex-wrap: wrap; }
.org-form.compact .region-row .select, .region-stack .region-row .select { flex: 1 1 45%; }
