:root {
  color-scheme: light;
  --ink: #18271f;
  --muted: #606d64;
  --line: #e2e7df;
  --background: #f6f7f3;
  --white: #fff;
  --green: #245a43;
  --dark-green: #194b35;
  --pending: #665c45;
  --assigned: #255f94;
  --partial: #965808;
  --done: #246748;
  --shadow: 0 2px 8px #21352808;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--background); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .53; }
button, input, select, textarea { outline-offset: 3px; }
:focus-visible { outline: 2px solid #357657; }
[hidden] { display: none !important; }
body[data-view="team"] .manager-only { display: none !important; }
.masthead { background: #fff; border-bottom: 1px solid var(--line); }
.masthead-inner, .container { width: min(100% - 64px, 1400px); margin: 0 auto; }
.masthead-inner { display: flex; align-items: center; justify-content: space-between; min-height: 72px; }
.brand { display: flex; gap: 11px; align-items: center; }
.brand-icon { width: 38px; height: 38px; display: grid; place-items: center; color: #fff; background: var(--green); border-radius: 11px; }
.brand-icon svg { width: 22px; height: 22px; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 17px; font-weight: 720; line-height: 1.15; }
.brand small { margin-top: 4px; color: var(--muted); font-size: 11px; }
.view-nav { display: inline-flex; gap: 3px; align-items: center; padding: 3px; background: #f0f4ee; border-radius: 8px; }
.view-nav a { padding: 6px 11px; border-radius: 6px; color: var(--muted); font-size: 12px; font-weight: 670; text-decoration: none; white-space: nowrap; }
.view-nav a[aria-current="page"] { background: white; color: var(--green); box-shadow: var(--shadow); }
.preview-badge, .map-type, .count-badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 99px; white-space: nowrap; font-size: 12px; font-weight: 650; }
.preview-badge { background: #ecf3ed; color: #2c5d43; border: 1px solid #e0ebe0; }
.preview-badge span, .map-type > span:first-child { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.container { padding: 30px 0 16px; }
.auth-gate { width: min(420px, calc(100% - 30px)); margin: 55px auto; padding: 26px; background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.auth-gate h1 { font-size: 25px; }
.auth-gate p { margin-top: 8px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.auth-gate form { display: grid; gap: 8px; margin-top: 20px; }
.auth-gate label { color: var(--muted); font-size: 13px; }
.auth-gate input { min-height: 42px; width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; }
.auth-gate #authError { margin: 0; color: #983d35; }
.auth-gate .button { margin-top: 4px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 23px; }
.eyebrow { color: var(--green); font-size: 12px; font-weight: 750; letter-spacing: .11em; margin-bottom: 7px; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(25px, 3.2vw, 38px); line-height: 1.18; font-weight: 740; letter-spacing: -.025em; }
.page-heading p { color: var(--muted); font-size: 14px; margin-top: 9px; line-height: 1.6; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-height: 39px; padding: 8px 13px; border: 1px solid transparent; border-radius: 8px; font-size: 13px; font-weight: 680; line-height: 1.25; white-space: nowrap; }
.button.primary { color: white; background: var(--green); }
.button.primary:not(:disabled):hover { background: var(--dark-green); }
.button.secondary { color: var(--ink); background: #fff; border-color: #dce4db; }
.button.secondary:not(:disabled):hover { background: #f3f7f1; }
.draw-button { padding-inline: 14px; min-height: 42px; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
[data-view="team"] .metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.metric { position: relative; display: flex; align-items: center; gap: 12px; padding: 13px 16px; min-height: 67px; border: 1px solid var(--line); border-radius: 12px; background: white; box-shadow: var(--shadow); }
.metric::before { content: ""; width: 9px; height: 9px; background: var(--accent); border-radius: 50%; flex: 0 0 auto; }
.metric-pending { --accent: #8e805c; }
.metric-assigned { --accent: #3d7ab5; }
.metric-partial { --accent: #cc8b31; }
.metric-done { --accent: #3e8a64; }
.metric-count { font-size: 25px; line-height: 1; font-weight: 750; font-variant-numeric: tabular-nums; }
.metric-label { color: var(--muted); font-size: 13px; font-weight: 640; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 345px); gap: 15px; align-items: start; }
.map-card, .side-card { background: white; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
.card-header { min-height: 66px; padding: 15px 17px 13px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card-header h2 { font-size: 17px; font-weight: 730; }
.card-header p { margin-top: 5px; color: var(--muted); font-size: 12px; }
.map-type { color: #5d655b; border: 1px solid var(--line); background: #f8f9f5; }
.map-frame { position: relative; isolation: isolate; display: grid; place-items: center; overflow: hidden; background: #f2f0e9; border-block: 1px solid #e6e8df; }
.real-map { grid-area: 1 / 1; width: 100%; height: clamp(365px, 53vw, 640px); border: 0; }
#amapPreview { position: relative; z-index: 1; }
#amapCanvas { position: relative; isolation: isolate; }
.map-tools, .amap-notice { display: flex; align-items: center; gap: 9px; padding: 9px 14px; }
.map-tools { padding-top: 0; }
.place-search { display: flex; gap: 6px; flex: 1; min-width: 0; }
.place-search input { width: 100%; min-width: 0; }
.place-search input, .manual-drawing textarea, #amapForm input { padding: 8px 9px; color: var(--ink); background: #fafbf9; border: 1px solid #d9e2d8; border-radius: 7px; font-size: 13px; }
.amap-notice { justify-content: space-between; color: var(--muted); font-size: 12px; line-height: 1.5; background: #f8faf6; border-bottom: 1px solid var(--line); }
.amap-notice a { white-space: nowrap; }
.amap-notice a, .manual-drawing a, #amapForm a { color: var(--green); text-underline-offset: 2px; }
.manual-drawing p { margin: 7px 0; color: var(--muted); line-height: 1.5; font-size: 12px; }
.manual-drawing textarea { width: 100%; min-height: 69px; resize: vertical; }
#map { width: 100%; height: auto; aspect-ratio: 10 / 7; max-height: 640px; display: block; touch-action: manipulation; user-select: none; }
#map.drawing { cursor: crosshair; }
.area-shape { cursor: pointer; stroke-width: 2.3; vector-effect: non-scaling-stroke; }
.area-shape.status-pending { fill: #f5e3ac84; stroke: #88754a; }
.area-shape.status-assigned { fill: #83b6e978; stroke: #3672a8; }
.area-shape.status-partial { fill: #efb65b79; stroke: #9f6110; }
.area-shape.status-done { fill: #7ebd9283; stroke: #357955; }
.area-shape.selected, .area-shape:hover, .area-shape:focus-visible { stroke-width: 3.4; }
.area-shape.selected { filter: drop-shadow(0 1px 2px #28493435); }
.drawing .area-shape { pointer-events: none; }
.map-label { pointer-events: none; user-select: none; fill: #203127; font-size: 16px; font-weight: 720; paint-order: stroke; stroke: #fffffff0; stroke-width: 4; stroke-linejoin: round; }
.map-controls { position: absolute; z-index: 2; display: grid; overflow: hidden; top: 12px; right: 12px; border: 1px solid #dce2d7; background: #fff; border-radius: 9px; box-shadow: 0 2px 10px #28352816; }
.map-controls button { display: grid; place-items: center; height: 36px; width: 36px; color: var(--ink); border: 0; background: transparent; font-size: 22px; }
.map-controls button + button { border-top: 1px solid var(--line); }
.map-controls button:hover { background: #edf3eb; }
.map-controls button:focus-visible { outline-offset: -3px; }
.map-caption { position: absolute; left: 10px; bottom: 10px; padding: 4px 7px; color: #526056; background: #fffffff1; border: 1px solid #e4e7df; border-radius: 5px; font-size: 10px; pointer-events: none; }
.map-footer { min-height: 44px; display: flex; flex-wrap: wrap; gap: 8px 17px; align-items: center; padding: 9px 15px; }
.map-footer span { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }
.status-dot { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: var(--status-dot); }
.status-pending { --status-dot: #9b8856; --status-text: var(--pending); --status-bg: #f4eedf; }
.status-assigned { --status-dot: #447daf; --status-text: var(--assigned); --status-bg: #e9f2fb; }
.status-partial { --status-dot: #be7a26; --status-text: var(--partial); --status-bg: #fff1da; }
.status-done { --status-dot: #469468; --status-text: var(--done); --status-bg: #e8f3e9; }
.sidebar { display: grid; gap: 12px; }
.count-badge { color: var(--green); background: #edf4ec; }
.count-badge:empty { display: none; }
.search { display: flex; gap: 7px; align-items: center; margin: 0 13px 9px; padding: 0 9px; color: var(--muted); border: 1px solid var(--line); border-radius: 8px; background: #f9faf7; }
.search:focus-within { border-color: #759984; }
.search input { min-width: 0; width: 100%; min-height: 35px; border: 0; background: transparent; color: var(--ink); font-size: 13px; outline: 0; }
.filters { display: flex; flex-wrap: wrap; gap: 3px; padding: 0 12px 9px; }
.filters button { border: 0; padding: 5px 7px; color: #556157; border-radius: 6px; background: transparent; font-size: 12px; }
.filters button:hover, .filters button.active, .filters button[aria-pressed="true"] { color: var(--green); background: #eaf2e9; }
.area-list { display: grid; gap: 2px; padding: 0 8px 8px; max-height: 272px; overflow: auto; }
.area-row { min-height: 54px; display: flex; align-items: center; gap: 9px; width: 100%; text-align: left; padding: 8px 9px; border: 1px solid transparent; border-radius: 8px; background: white; color: var(--ink); }
.area-row:hover { background: #f6f8f4; }
.area-row.selected { border-color: #d4e4d7; background: #eff6ee; }
.area-row:focus-visible { outline-offset: -2px; }
.row-copy { flex: 1; min-width: 0; display: grid; gap: 4px; }
.row-title { overflow-wrap: anywhere; font-size: 13px; font-weight: 700; }
.row-subtitle { color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.status-pill { padding: 4px 7px; background: var(--status-bg); color: var(--status-text); border-radius: 99px; font-size: 11px; font-weight: 680; white-space: nowrap; }
.detail-card .card-header { min-height: auto; padding-bottom: 10px; }
#detail { padding: 0 15px 15px; }
.detail-heading { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.detail-name { font-size: 15px; font-weight: 720; overflow-wrap: anywhere; }
.detail-meta, .detail-note, .empty, .empty-state, .draw-copy p { color: var(--muted); line-height: 1.55; font-size: 12px; overflow-wrap: anywhere; }
.detail-note { margin: 6px 0 0; white-space: pre-wrap; }
.empty, .empty-state { padding: 10px 5px; }
.detail-form { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin-top: 10px; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.detail-form label { font-size: 12px; color: var(--muted); }
.detail-form select, .detail-form textarea, .draw-fields input { border: 1px solid #d9e2d8; color: var(--ink); background: #fafbf9; border-radius: 7px; padding: 8px 9px; font-size: 13px; min-height: 38px; }
.detail-form select { flex: 1; }
.detail-form textarea { width: 100%; min-height: 61px; resize: vertical; }
.publish-form { display: grid; align-items: start; }
.publish-form label { display: grid; gap: 4px; font-weight: 650; }
.publish-form input { width: 100%; min-height: 38px; border: 1px solid #d9e2d8; border-radius: 7px; padding: 8px 9px; color: var(--ink); background: #fafbf9; font-size: 13px; }
.publish-form .button { justify-self: start; }
.task-facts { display: grid; gap: 6px; margin: 9px 0; }
.task-facts div { display: grid; gap: 2px; }
.task-facts dt { color: var(--muted); font-size: 11px; font-weight: 700; }
.task-facts dd { margin: 0; color: var(--ink); line-height: 1.5; font-size: 13px; overflow-wrap: anywhere; white-space: pre-wrap; }
.boundary-preview { margin-top: 11px; padding: 9px; border: 1px solid var(--line); border-radius: 8px; background: #f8faf6; }
.boundary-preview-header { display: flex; justify-content: space-between; gap: 7px; flex-wrap: wrap; align-items: center; margin-bottom: 5px; font-size: 12px; }
.boundary-preview p { margin: 4px 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.boundary-preview svg { display: block; width: 100%; max-height: 126px; }
.boundary-preview a { color: var(--green); font-size: 12px; text-underline-offset: 2px; }
.draw-bar { padding: 12px 15px 13px; border-bottom: 1px solid var(--line); background: #f1f7ef; }
.draw-copy strong { font-size: 13px; }
.draw-copy p { margin-top: 4px; }
.draw-fields { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.draw-fields input { flex: 1 1 145px; width: 145px; }
.page-footer { display: flex; gap: 7px; align-items: flex-start; color: var(--muted); font-size: 12px; line-height: 1.5; padding: 13px 0 4px; }
.page-footer svg { flex: 0 0 auto; }
#toast { position: fixed; z-index: 3; right: 22px; bottom: 22px; max-width: min(92vw, 410px); padding: 12px 15px; border-radius: 9px; background: #214b37; box-shadow: 0 4px 16px #1c372e26; color: white; font-size: 13px; line-height: 1.5; }
#toast:empty, #toast[hidden] { display: none; }
#toast.error, #toast[data-kind="error"] { background: #983d35; }
#amapDialog { width: min(435px, calc(100% - 28px)); padding: 20px; border: 1px solid var(--line); border-radius: 13px; color: var(--ink); box-shadow: 0 8px 28px #21352830; }
#amapDialog::backdrop { background: #233d3460; }
#amapForm { display: grid; gap: 10px; }
#amapForm p, #amapForm a, #amapForm label { font-size: 13px; line-height: 1.5; }
#amapForm label { display: grid; gap: 4px; }
#amapForm p { color: var(--muted); }
#amapForm .form-error { color: #983d35; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 7px; margin-top: 4px; }
@media (max-width: 930px) {
  .masthead-inner, .container { width: calc(100% - 36px); }
  .workspace { grid-template-columns: minmax(0, 1fr) 290px; }
}
@media (max-width: 720px) {
  .masthead-inner, .container { width: calc(100% - 26px); }
  .masthead-inner { min-height: 58px; }
  .container { padding-top: 19px; }
  .page-heading { margin-bottom: 16px; align-items: center; }
  .page-heading p { font-size: 12px; }
  .workspace { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .metrics { gap: 5px; margin-bottom: 12px; }
  .metric { gap: 5px; padding: 8px 6px; min-height: 49px; border-radius: 8px; flex-wrap: wrap; }
  .metric::before { width: 6px; height: 6px; }
  .metric-count { font-size: 20px; }
  .metric-label { font-size: 11px; }
  .sidebar { gap: 10px; }
  .detail-card { order: -1; }
  #map { min-height: 240px; max-height: 440px; }
  .real-map { height: min(420px, 60vh); min-height: 300px; }
  .map-tools { gap: 5px; padding-inline: 9px; }
  .map-tools button { padding-inline: 7px; }
}
@media (max-width: 500px) {
  .masthead-inner { gap: 6px; }
  .view-nav a { padding-inline: 7px; }
  .masthead .preview-badge { padding-inline: 6px; font-size: 11px; }
}
@media (max-width: 400px) {
  .draw-button { padding-inline: 8px; font-size: 12px; }
  .draw-button svg { width: 14px; }
  .metric { column-gap: 3px; }
  .metric-label { font-size: 10px; }
}
