:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fbff;
  --surface-strong: #edf4ff;
  --line: #dbe5f2;
  --line-strong: #c5d3e6;
  --text: #172033;
  --muted: #65748b;
  --muted-strong: #43536a;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eaf1ff;
  --accent: #5867a6;
  --accent-soft: #edf0fb;
  --green: #198754;
  --green-soft: #e6f5ee;
  --orange: #c96b13;
  --orange-soft: #fff1df;
  --red: #c8383f;
  --red-soft: #fdecee;
  --shadow: 0 20px 48px rgba(28, 48, 84, .10);
  --shadow-soft: 0 8px 20px rgba(28, 48, 84, .07);
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body { margin: 0; min-height: 100%; background: radial-gradient(circle at top right, #e6efff 0, transparent 31rem), var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }
a { color: inherit; text-decoration: none; }
code { display: inline-block; max-width: 100%; padding: 3px 7px; border-radius: 6px; background: #eef3fb; color: var(--muted-strong); word-break: break-all; }

.layout { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; z-index: 20; height: 100vh; padding: 22px 16px; border-right: 1px solid rgba(219, 229, 242, .9); background: rgba(255, 255, 255, .92); display: flex; flex-direction: column; gap: 24px; backdrop-filter: blur(18px); }
.brand { display: grid; grid-template-columns: 42px minmax(0, 1fr); gap: 12px; align-items: center; padding: 8px 6px; }
.brand-mark { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; background: linear-gradient(135deg, #3b82f6, #1d4ed8); color: #fff; font-weight: 900; letter-spacing: 0; box-shadow: 0 12px 24px rgba(37, 99, 235, .25); }
.brand-text { min-width: 0; display: grid; gap: 2px; }
.brand-name { font-size: 16px; font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-subtitle { color: var(--muted); font-size: 12px; font-weight: 800; }
.nav { display: grid; gap: 6px; }
.nav::before { content: "工作台"; padding: 0 10px 4px; color: #8794a8; font-size: 12px; font-weight: 900; }
.nav a { position: relative; display: flex; align-items: center; min-height: 44px; padding: 10px 12px 10px 16px; border-radius: 12px; color: #4a5870; font-weight: 800; transition: background .15s ease, color .15s ease, box-shadow .15s ease; }
.nav a::before { content: ""; width: 6px; height: 6px; border-radius: 99px; margin-right: 10px; background: #b8c6d9; }
.nav a.active, .nav a:hover { background: var(--primary-soft); color: var(--primary-dark); }
.nav a.active { box-shadow: inset 0 0 0 1px rgba(31, 111, 235, .12); }
.nav a.active::before { background: var(--primary); }

.main { min-width: 0; max-width: 1680px; width: 100%; margin: 0 auto; padding: 30px 38px 48px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-bottom: 24px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.page-heading { display: flex; align-items: center; gap: 12px; }
.page-kicker { margin: 0 0 4px; color: var(--primary); font-size: 12px; font-weight: 900; letter-spacing: .08em; }
h1 { margin: 0; font-size: 30px; line-height: 1.2; letter-spacing: -.025em; }
h2 { margin: 0 0 16px; font-size: 18px; line-height: 1.25; }
h3 { margin: 0; font-size: 16px; line-height: 1.25; }
.user { display: flex; gap: 12px; align-items: center; color: var(--muted); }
.user span { min-height: 38px; display: inline-flex; align-items: center; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255, 255, 255, .72); font-weight: 800; color: var(--muted-strong); }

button, .button { min-height: 40px; border: 0; border-radius: 10px; background: var(--primary) linear-gradient(135deg, #3b82f6, transparent); color: #fff; padding: 9px 15px; cursor: pointer; font: inherit; font-weight: 900; line-height: 1.2; display: inline-flex; justify-content: center; align-items: center; gap: 7px; white-space: nowrap; transition: transform .12s ease, box-shadow .12s ease, background-color .12s ease, border-color .12s ease; }
button:hover, .button:hover { background-color: var(--primary-dark); box-shadow: 0 10px 20px rgba(31, 111, 235, .14); }
button:active, .button:active { transform: translateY(1px); }
button.secondary, .button.secondary { background: #fff; color: var(--muted-strong); border: 1px solid var(--line-strong); }
button.secondary:hover, .button.secondary:hover { background: var(--surface-strong); box-shadow: none; }
button.danger, .button.danger { background: var(--red); color: #fff; }
button.danger:hover, .button.danger:hover { background: #a82f35; box-shadow: 0 10px 20px rgba(200, 56, 63, .14); }
button:disabled { opacity: .62; cursor: not-allowed; transform: none; box-shadow: none; }

.panel, table { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-soft); }
.panel { padding: 22px; margin-bottom: 18px; }
.panel p { margin: 8px 0; color: var(--muted-strong); }
.panel > p:last-child { margin-bottom: 0; }
.panel.form-grid { align-items: end; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.dashboard-stats { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.stat { position: relative; min-height: 126px; padding: 18px; border: 1px solid var(--line); border-top: 4px solid var(--primary); border-radius: 14px; background: linear-gradient(145deg, #fff, #f8fbff); box-shadow: var(--shadow-soft); overflow: hidden; }
.stat label { display: block; margin-bottom: 14px; color: var(--muted); font-size: 13px; font-weight: 900; }
.stat strong { position: relative; z-index: 1; font-size: 34px; line-height: 1; color: var(--primary); }

table { width: 100%; border-collapse: separate; border-spacing: 0; overflow: hidden; }
th, td { padding: 13px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { position: sticky; top: 0; z-index: 1; background: var(--surface-strong); color: var(--muted-strong); font-size: 12px; font-weight: 900; }
td { word-break: break-word; }
tbody tr { background: #fff; }
tbody tr:nth-child(even) { background: #fbfcfa; }
tbody tr:hover { background: #f3f7ff; }
tr:last-child td { border-bottom: 0; }
.table-compact th, .table-compact td { padding: 10px 12px; vertical-align: top; }
.table-status { margin: 14px 0 0; }

.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; align-items: end; }
.form-grid > * { min-width: 0; }
input, select, textarea { width: 100%; min-height: 42px; border: 1px solid var(--line-strong); border-radius: 10px; padding: 9px 11px; background: #fff; color: var(--text); font: inherit; outline: none; transition: border-color .12s ease, box-shadow .12s ease, background .12s ease; }
textarea { min-height: 92px; resize: vertical; line-height: 1.55; }
select[multiple] { min-height: 122px; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(31, 111, 235, .12); }
label { color: var(--muted); font-size: 13px; display: grid; gap: 7px; font-weight: 900; }

.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 900; background: var(--accent-soft); color: #3c4d91; line-height: 1.35; }
.badge.green { background: var(--green-soft); color: #12663f; }
.badge.orange { background: var(--orange-soft); color: #9b4f0c; }
.badge.gray { background: #eef1ed; color: #5b665e; }
.mini-tags, .auth-summary { display: flex; flex-wrap: wrap; gap: 6px; max-width: 440px; }
.mini-tag, .auth-tag { display: inline-flex; align-items: center; max-width: 100%; padding: 4px 8px; border-radius: 7px; background: #edf4ff; color: #244f8f; font-size: 12px; font-weight: 800; line-height: 1.35; word-break: break-word; }
.mini-tag.green { background: var(--green-soft); color: #12663f; }
.mini-tag.orange { background: var(--orange-soft); color: #9b4f0c; }
.log-detail { max-width: 380px; color: var(--muted); line-height: 1.7; word-break: break-word; }
.log-content { max-width: 320px; line-height: 1.7; word-break: break-word; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.section-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 18px 0 10px; }

.toast { position: fixed; top: 22px; right: 28px; z-index: 30; max-width: 360px; padding: 13px 18px; border-radius: 12px; background: var(--primary); color: #fff; box-shadow: 0 18px 36px rgba(21, 87, 189, .2); font-weight: 900; }
.toast.error-toast { background: var(--red); }
.error { color: var(--red); margin: 8px 0; min-height: 20px; }
.muted { color: var(--muted); }

.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at top right, #cddfff, transparent 36rem), linear-gradient(135deg, #f8fbff 0%, #eef4ff 100%); }
.login-card { width: min(410px, 100%); padding: 32px; border: 1px solid var(--line); border-radius: 18px; background: rgba(255, 255, 255, .94); box-shadow: var(--shadow); }
.login-card h1 { margin-bottom: 8px; }
.login-card label { margin-top: 14px; }

.photo-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.photo-item { display: grid; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-soft); }
.photo-item strong { font-size: 13px; }
.photo-item img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: #eef3fb; }
.photo-link { display: block; border-radius: 8px; }
.photo-link:hover img { border-color: var(--primary); box-shadow: 0 12px 24px rgba(31, 111, 235, .14); }
.gps-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.gps-card { display: grid; gap: 8px; align-content: start; padding: 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-soft); }
.gps-card strong { font-size: 15px; }
.gps-card p { margin: 0; color: var(--muted-strong); line-height: 1.65; word-break: break-all; }
.gps-card .button { justify-self: start; margin-top: 4px; }

.village-editor { display: grid; grid-template-columns: 1fr 1fr 130px 120px 110px 110px 180px; border: 1px solid var(--line); border-radius: 8px; overflow: auto; margin-bottom: 18px; background: #fff; box-shadow: var(--shadow-soft); }
.village-editor-head { padding: 12px 14px; background: var(--surface-strong); color: var(--muted-strong); font-size: 12px; font-weight: 900; border-bottom: 1px solid var(--line); white-space: nowrap; }
.village-editor-row { display: contents; }
.village-editor-row input, .village-editor-row .actions, .village-editor-row .village-stat { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; min-height: 50px; }
.village-editor-row input:focus { position: relative; z-index: 2; box-shadow: inset 0 0 0 2px rgba(31, 111, 235, .18); }
.village-editor-row .village-stat { display: flex; gap: 5px; align-items: center; padding: 8px 12px; background: #fff; color: var(--text); }
.village-editor-row .village-stat small { color: var(--muted); font-weight: 900; }
.village-editor-row .actions { padding: 7px 10px; align-items: center; background: #fff; }

.auth-page { max-width: 1240px; display: grid; gap: 18px; }
.auth-hero { display: flex; justify-content: space-between; align-items: center; gap: 18px; padding: 24px 28px; border: 1px solid var(--line); border-radius: 8px; background: linear-gradient(135deg, #ffffff 0%, #f3f7ff 100%); box-shadow: var(--shadow-soft); }
.eyebrow { margin: 0 0 6px; color: var(--primary); font-size: 13px; font-weight: 900; }
.auth-hero h2 { margin: 0 0 10px; font-size: 26px; }
.worker-meta { display: flex; gap: 10px; flex-wrap: wrap; color: var(--muted); font-weight: 900; }
.worker-meta span { padding: 5px 10px; border-radius: 999px; background: #edf4ff; }
.auth-count-card { min-width: 240px; padding: 16px 18px; border: 1px solid #bfd2f5; border-radius: 8px; background: var(--primary-soft); color: var(--primary-dark); display: grid; gap: 4px; }
.auth-count-card span { font-size: 20px; font-weight: 900; }
.auth-count-card small { color: var(--muted-strong); font-weight: 800; }
.auth-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 18px; align-items: start; }
.auth-side { position: sticky; top: 24px; display: grid; gap: 18px; }
.auth-side label, .auth-person-grid label { color: var(--text); font-size: 14px; }
.auth-help { padding: 14px; border-radius: 8px; background: var(--surface-soft); border: 1px solid var(--line); color: var(--muted); }
.auth-help strong { color: var(--text); display: block; margin-bottom: 8px; }
.auth-help p { margin: 0; line-height: 1.7; }
.auth-main, .auth-person-panel, .auth-project, .township-list { display: grid; gap: 16px; }
.auth-person-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.auth-password-field { grid-column: span 2; }
.auth-project-title { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); padding-bottom: 14px; }
.auth-project-title h3 { font-size: 22px; }
.township-card { border: 1px solid var(--line); border-radius: 8px; background: #fff; overflow: hidden; }
.township-title { display: flex; justify-content: space-between; align-items: center; padding: 13px 16px; background: var(--surface-strong); color: var(--text); font-size: 15px; font-weight: 900; }
.township-title small { color: var(--muted); font-size: 12px; font-weight: 900; }
.village-check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; padding: 14px; }
.village-check { position: relative; display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; background: #fff; color: var(--text); font-size: 14px; font-weight: 900; cursor: pointer; min-height: 52px; transition: border-color .15s ease, background .15s ease, box-shadow .15s ease; }
.village-check input { position: absolute; opacity: 0; pointer-events: none; }
.village-check .checkmark { width: 18px; height: 18px; border-radius: 5px; border: 2px solid #98a8bd; background: #fff; display: inline-grid; place-items: center; }
.village-check .checkmark::after { content: ""; width: 8px; height: 4px; border-left: 2px solid #fff; border-bottom: 2px solid #fff; transform: rotate(-45deg); opacity: 0; margin-top: -1px; }
.village-check .village-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.village-check small { color: var(--muted); font-weight: 900; }
.village-check:hover { border-color: #9bbcf4; box-shadow: 0 8px 18px rgba(31, 111, 235, .08); }
.village-check.selected { border-color: var(--primary); background: var(--primary-soft); }
.village-check.selected .checkmark { border-color: var(--primary); background: var(--primary); }
.village-check.selected .checkmark::after { opacity: 1; }
.auth-empty { min-height: 260px; display: grid; place-content: center; text-align: center; }
.form-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.vertical-actions { display: grid; }
.vertical-actions .button, .vertical-actions button { width: 100%; text-align: center; }

.project-detail-page { display: grid; gap: 18px; }
.project-detail-toolbar { display: grid; grid-template-columns: minmax(260px, 420px) auto minmax(0, 1fr); gap: 14px; align-items: end; }
.project-map-stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.compact-stat { min-height: 98px; padding: 16px; }
.compact-stat label { margin-bottom: 10px; }
.compact-stat strong { font-size: 28px; }
.project-detail-layout { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(340px, .65fr); gap: 18px; align-items: start; }
.project-map-panel { position: relative; min-height: 640px; display: grid; grid-template-rows: auto minmax(520px, 1fr); gap: 14px; }
.project-map-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.project-map-head h2 { margin-bottom: 0; font-size: 24px; }
.project-map { width: 100%; min-height: 520px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #e8eef6; }
.map-empty { position: absolute; left: 22px; top: 104px; z-index: 2; width: max-content; max-width: calc(100% - 150px); padding: 10px 14px; border: 1px solid rgba(197, 211, 230, .9); border-radius: 8px; background: rgba(255, 255, 255, .9); color: var(--muted-strong); text-align: left; font-weight: 900; box-shadow: 0 10px 24px rgba(28, 48, 84, .12); backdrop-filter: blur(8px); }
.project-map .mapboxgl-ctrl-logo, .project-map .mapboxgl-ctrl-attrib,
.mapboxgl-ctrl-logo, .mapboxgl-ctrl-attrib { display: none !important; }
.project-map .mapboxgl-ctrl-bottom-left .mapboxgl-ctrl { margin: 0 0 16px 16px; }
.project-map .mapboxgl-ctrl-scale { position: relative; min-height: 26px; padding: 5px 12px 7px; border: 1px solid rgba(197, 211, 230, .82); border-bottom: 0; border-radius: 999px; background: rgba(255, 255, 255, .88); color: var(--text); box-shadow: 0 8px 18px rgba(28, 48, 84, .14); font-size: 12px; font-weight: 900; line-height: 1; backdrop-filter: blur(10px); }
.project-map .mapboxgl-ctrl-scale::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: 4px; height: 3px; border-radius: 999px; background: linear-gradient(90deg, var(--primary), var(--primary-dark)); }
.map-legend { display: inline-flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; padding: 6px; border: 1px solid var(--line); border-radius: 14px; background: rgba(248, 251, 255, .94); color: var(--muted-strong); font-size: 12px; font-weight: 900; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .72); }
.map-legend-toggle { display: inline-flex; align-items: center; gap: 7px; width: auto; min-height: 36px; padding: 8px 13px; border: 1px solid transparent; border-radius: 10px; background: transparent; color: var(--muted-strong); box-shadow: none; font-size: 12px; font-weight: 900; cursor: pointer; }
.map-legend-toggle:hover { background: #fff; box-shadow: none; }
.map-legend-toggle.active { border-color: rgba(31, 111, 235, .18); background: var(--primary); color: #fff; box-shadow: 0 8px 18px rgba(31, 111, 235, .2); }
.map-legend-toggle:not(.active) { opacity: .72; }
.map-dot { width: 10px; height: 10px; border-radius: 999px; display: inline-block; }
.map-dot.pending { background: var(--red); }
.map-dot.debugged { background: var(--green); }
.map-dot.operation { background: var(--primary); }
.map-legend-toggle.active .map-dot.operation { background: #fff; }
.project-map-pin { width: 34px; height: 34px; min-height: 34px; padding: 0; border: 3px solid #fff; border-radius: 50% 50% 50% 6px; transform: rotate(-45deg); box-shadow: 0 10px 20px rgba(24, 34, 54, .2); cursor: pointer; }
.project-map-pin::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: #fff; display: block; margin: 9px auto 0; }
.project-map-pin.pending { background: var(--red); }
.project-map-pin.debugged { background: var(--green); }
.project-map-pin.operation { background: var(--primary); border-radius: 50%; transform: none; }
.project-map-pin:hover { box-shadow: 0 12px 24px rgba(31, 111, 235, .28); }
.map-popup { min-width: 220px; display: grid; gap: 4px; color: var(--text); }
.map-popup strong { font-size: 15px; }
.map-popup p { margin: 0; color: var(--muted-strong); line-height: 1.55; }
.mapboxgl-popup-content { border-radius: 12px; padding: 16px 42px 16px 16px; box-shadow: 0 18px 36px rgba(15, 23, 42, .18); }
.mapboxgl-popup-close-button { width: 34px; height: 34px; border-radius: 0 12px 0 10px; background: var(--primary); color: #fff; font-size: 22px; line-height: 34px; }
.mapboxgl-popup-close-button:hover { background: var(--primary-dark); }
.operation-popup { min-width: 260px; gap: 7px; }
.map-popup-device { display: inline-flex; align-items: center; gap: 6px; width: max-content; max-width: 100%; padding: 6px 10px; border-radius: 9px; background: var(--primary-soft); color: var(--primary-dark); font-size: 16px; font-weight: 900; word-break: break-word; }
.map-popup-device span { color: var(--muted); }
.map-popup-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.map-popup-link { display: inline-flex; align-items: center; min-height: 28px; padding: 5px 9px; border-radius: 999px; background: var(--surface-strong); color: var(--primary-dark); font-size: 12px; font-weight: 900; }
.project-detail-side { display: grid; gap: 18px; }
.township-progress, .project-record-list { display: grid; gap: 10px; max-height: 560px; overflow: auto; padding-right: 4px; }
.project-progress-group { display: grid; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-soft); }
.project-progress-title { display: flex; justify-content: space-between; gap: 10px; color: var(--text); font-size: 15px; font-weight: 900; }
.project-progress-title span { color: var(--muted-strong); font-size: 12px; }
.township-progress-card { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.township-progress-title { display: flex; justify-content: space-between; gap: 10px; padding: 12px 14px; background: var(--surface-strong); color: var(--text); font-weight: 900; }
.township-progress-title span { color: var(--muted-strong); font-size: 12px; }
.village-progress-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--line); align-items: center; }
.village-progress-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 800; }
.village-progress-row strong { color: var(--primary-dark); }
.village-progress-row small { color: var(--muted); font-weight: 800; }
.project-record-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.project-record-item div { min-width: 0; display: grid; gap: 2px; }
.project-record-item strong, .project-record-item span:not(.badge) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-record-item span:not(.badge) { color: var(--muted); font-size: 12px; font-weight: 800; }

@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid > [style*="grid-column"] { grid-column: 1 / -1 !important; }
  table { display: block; overflow-x: auto; }
  .project-detail-layout { grid-template-columns: 1fr; }
  .project-detail-side { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; top: 0; left: 0; width: min(294px, 84vw); height: 100dvh; padding: 20px 16px; border-right: 1px solid var(--line); border-bottom: 0; box-shadow: 18px 0 44px rgba(28, 48, 84, .16); transform: translateX(-105%); transition: transform .22s ease; overflow-y: auto; }
  .sidebar.is-open { transform: translateX(0); }
  .nav-backdrop { position: fixed; inset: 0; z-index: 15; background: rgba(15, 23, 42, .4); backdrop-filter: blur(2px); }
  .nav-open { overflow: hidden; }
  .mobile-nav-toggle { width: 40px; min-width: 40px; height: 40px; min-height: 40px; padding: 9px; display: inline-grid; align-content: center; gap: 4px; }
  .mobile-nav-toggle span { display: block; width: 18px; height: 2px; margin: 0 auto; border-radius: 99px; background: currentColor; }
  .main { padding: 20px 18px 36px; }
  .topbar { align-items: flex-start; margin-bottom: 20px; padding-bottom: 16px; }
  .user { justify-content: flex-end; }
  .auth-hero, .auth-layout { grid-template-columns: 1fr; display: grid; }
  .auth-side { position: static; }
  .auth-person-grid { grid-template-columns: 1fr; }
  .auth-password-field { grid-column: auto; }
  .gps-grid, .photo-grid { grid-template-columns: 1fr; }
  .project-detail-toolbar, .project-map-stats, .project-detail-side { grid-template-columns: 1fr; }
  .project-map-panel { min-height: 520px; grid-template-rows: auto minmax(420px, 1fr); }
  .project-map { min-height: 420px; }
  .map-empty { left: 14px; top: 112px; max-width: calc(100% - 116px); }
}

@media (max-width: 640px) {
  body { font-size: 13px; background: var(--bg); }
  .main { padding: 14px 12px 30px; }
  .topbar { align-items: center; gap: 10px; margin-bottom: 16px; padding-bottom: 14px; }
  .page-kicker { display: none; }
  h1 { font-size: 23px; }
  .user { width: auto; }
  .user span { display: none; }
  .user form { width: auto; }
  .user button { min-height: 38px; width: auto; padding: 8px 11px; font-size: 12px; }
  .stats, .form-grid, .nav { grid-template-columns: 1fr; }
  .stats { gap: 10px; }
  .stat { min-height: 104px; padding: 15px; }
  .stat label { margin-bottom: 10px; }
  .stat strong { font-size: 30px; }
  .panel { padding: 16px; margin-bottom: 14px; border-radius: 12px; }
  .form-grid > [style*="grid-column"] { grid-column: 1 / -1 !important; }
  .form-grid > button, .form-grid > .button { width: 100%; }
  .actions { gap: 6px; }
  .actions button, .actions .button { width: auto; min-height: 36px; padding: 7px 10px; font-size: 12px; }
  .section-title-row { align-items: flex-start; flex-direction: column; }
  table { display: block; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; box-shadow: none; border-radius: 12px; }
  th, td { padding: 11px 12px; white-space: nowrap; }
  td:nth-child(3), td:nth-child(5), td:nth-child(7) { white-space: normal; min-width: 150px; }
  .project-map-panel { padding: 12px; min-height: 400px; grid-template-rows: auto minmax(340px, 1fr) auto; }
  .project-map { min-height: 340px; }
  .project-map-head { align-items: flex-start; flex-direction: column; }
  .project-map-head h2 { font-size: 19px; }
  .map-legend { justify-content: flex-start; }
  .map-empty { position: static; width: 100%; max-width: none; margin: 0; transform: none; text-align: center; }
  .login { padding: 16px; place-items: start center; }
  .login-card { margin-top: max(40px, 10vh); padding: 24px 20px; border-radius: 16px; }
}

@media (min-width: 901px) {
  .mobile-nav-toggle, .nav-backdrop { display: none; }
}

.project-map-device-label { position: absolute; bottom: 38px; left: 50%; transform: translateX(-50%); white-space: nowrap; padding: 3px 7px; border-radius: 5px; background: white; color: #17202a; font-size: 12px; font-weight: 700; box-shadow: 0 1px 5px #0003; }
