:root {
  color-scheme: light;
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #142033;
  --muted: #68768a;
  --line: #d9e2ef;
  --blue: #1d6fd1;
  --blue-dark: #174d9b;
  --green: #188a5b;
  --amber: #a86600;
  --shadow: 0 10px 30px rgba(20, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 8px 13px;
  cursor: pointer;
}

button.primary {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 9px 10px;
}

textarea {
  resize: vertical;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px clamp(14px, 4vw, 34px);
  border-bottom: 1px solid var(--line);
  background: rgba(245, 247, 251, 0.94);
  backdrop-filter: blur(10px);
}

.app-header h1 {
  margin: 0;
  font-size: 24px;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--blue-dark);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.viewer-link {
  color: var(--blue-dark);
  text-decoration: none;
  font-weight: 600;
}

.field-shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 18px clamp(12px, 3vw, 24px) 40px;
  display: grid;
  gap: 16px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 16px;
}

.section-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.section-title h2 {
  margin: 0;
  font-size: 18px;
}

.section-title p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  background: #eef4ff;
  color: var(--blue-dark);
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.badge.good {
  background: #e9f8f0;
  color: var(--green);
}

.badge.warn {
  background: #fff4df;
  color: var(--amber);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

label,
.field-label {
  display: grid;
  gap: 6px;
  color: #26364b;
  font-size: 13px;
  font-weight: 650;
}

.wide-label {
  margin-top: 12px;
}

.button-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.button-row.wrap {
  flex-wrap: wrap;
  margin-top: 12px;
}

.current-route-card,
.gps-card,
.status-line,
.route-summary {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
  color: #31435b;
  padding: 10px 12px;
  margin-top: 12px;
  font-size: 13px;
}

.offline-readiness-card,
.observation-tree,
.track-panel,
.quality-panel,
.conflict-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf7;
  color: #31435b;
  padding: 10px 12px;
  margin-top: 12px;
  font-size: 13px;
}

.offline-readiness-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.track-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.track-stats {
  border: 1px solid rgba(217, 226, 239, 0.9);
  border-radius: 8px;
  background: #f8fbff;
  color: #31435b;
  padding: 9px 10px;
  margin-top: 10px;
  font-size: 13px;
}

.track-map {
  display: block;
  width: 100%;
  height: 170px;
  border: 1px solid rgba(217, 226, 239, 0.9);
  border-radius: 8px;
  background: #fbfdff;
  margin-top: 10px;
}

.p3-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.p3-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  padding: 12px;
}

.p3-card h3 {
  margin: 0 0 12px;
  font-size: 15px;
}

.compact-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.p3-list {
  display: grid;
  gap: 6px;
  min-height: 52px;
  border: 1px solid rgba(217, 226, 239, 0.9);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  padding: 9px 10px;
  margin-top: 10px;
  font-size: 12px;
}

.p3-row {
  display: grid;
  gap: 4px;
  border-bottom: 1px solid #e9eef6;
  padding: 7px 0;
}

.p3-row:last-child {
  border-bottom: 0;
}

.p3-row strong {
  color: var(--text);
  font-size: 13px;
}

.offline-readiness-list,
.quality-list,
.conflict-list {
  display: grid;
  gap: 7px;
}

.observation-tree {
  display: grid;
  gap: 7px;
}

.tree-row,
.tree-empty {
  display: grid;
  gap: 4px;
  border-top: 1px solid rgba(217, 226, 239, 0.9);
  padding-top: 7px;
}

.tree-row:first-child,
.tree-empty:first-child {
  border-top: 0;
  padding-top: 0;
}

.tree-row span,
.tree-empty {
  color: var(--muted);
  font-size: 12px;
}

.readiness-row,
.quality-row,
.conflict-row {
  display: grid;
  gap: 4px;
  border-top: 1px solid rgba(217, 226, 239, 0.9);
  padding-top: 7px;
}

.readiness-row:first-child,
.quality-row:first-child,
.conflict-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.readiness-row strong,
.quality-row strong,
.conflict-row strong {
  color: var(--text);
}

.readiness-row span,
.quality-row span,
.conflict-row span {
  color: var(--muted);
  font-size: 12px;
}

.readiness-ok strong {
  color: var(--green);
}

.readiness-warn strong,
.quality-warn strong,
.conflict-panel-title {
  color: var(--amber);
}

.quality-pass strong {
  color: var(--green);
}

.quality-panel-title {
  color: var(--blue-dark);
  font-weight: 800;
  margin-bottom: 8px;
}

.readiness-fail strong {
  color: #b42318;
}

.conflict-panel-title {
  font-weight: 800;
  margin-bottom: 8px;
}

.conflict-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 4px;
}

.sync-settings {
  margin-top: 12px;
}

.sync-settings summary {
  color: var(--blue-dark);
  cursor: pointer;
  font-weight: 700;
}

.login-grid {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
  align-items: end;
  margin: 10px 0;
}

.login-status {
  color: var(--muted);
  font-size: 12px;
  margin-top: 8px;
}

.segmented {
  display: inline-grid;
  grid-auto-flow: column;
  border: 1px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
  margin-bottom: 14px;
}

.segmented button {
  border: 0;
  border-radius: 0;
  background: #fff;
}

.segmented button.active {
  background: var(--blue);
  color: #fff;
}

.purpose-box {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.purpose-box label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 500;
}

.purpose-box input[type="checkbox"] {
  width: auto;
}

.purpose-box input[type="text"],
.purpose-box input:not([type]) {
  width: min(240px, 100%);
}

.photo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 14px;
}

.file-input {
  display: none;
}

.photo-preview,
.sample-photo-list,
.existing-photo-list {
  min-height: 98px;
  border: 1px dashed #bed0e5;
  border-radius: 8px;
  background: #f8fbff;
  color: var(--muted);
  padding: 10px;
  margin-top: 8px;
  overflow: hidden;
}

.photo-preview img,
.sample-photo-row img,
.existing-photo-row img {
  max-width: 100%;
  max-height: 220px;
  display: block;
  border-radius: 6px;
}

.sample-photo-row,
.existing-photo-row,
.record-row {
  display: grid;
  gap: 5px;
  border-bottom: 1px solid #e9eef6;
  padding: 9px 0;
}

.existing-photo-row {
  grid-template-columns: 78px 1fr;
  cursor: pointer;
}

.existing-photo-row img {
  width: 70px;
  height: 54px;
  object-fit: cover;
}

.hidden {
  display: none !important;
}

.sticky-actions {
  position: sticky;
  bottom: 0;
  justify-content: flex-end;
  padding-top: 12px;
  margin-top: 14px;
  background: linear-gradient(to top, #fff 72%, rgba(255, 255, 255, 0));
}

.record-list {
  display: grid;
  gap: 4px;
}

.record-row strong {
  font-size: 14px;
}

.record-row span {
  color: var(--muted);
  font-size: 12px;
}

.photo-dialog {
  width: min(900px, 94vw);
  border: 0;
  border-radius: 12px;
  padding: 0;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.25);
}

.photo-dialog::backdrop {
  background: rgba(8, 20, 37, 0.55);
}

.photo-dialog form {
  padding: 14px;
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.marker-stage {
  position: relative;
  min-height: 240px;
  max-height: 70vh;
  overflow: auto;
  border-radius: 10px;
  background: #0f1722;
}

.marker-stage img {
  display: block;
  max-width: 100%;
  margin: 0 auto;
}

.photo-marker {
  position: absolute;
  width: 18px;
  height: 18px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: #e23131;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 2px #e23131;
  pointer-events: none;
}

.marker-summary {
  color: var(--muted);
  font-size: 13px;
  margin: 10px 0;
}

@media (max-width: 760px) {
  .app-header {
    align-items: flex-start;
  }

  .form-grid,
  .photo-grid,
  .login-grid,
  .p3-grid,
  .compact-grid {
    grid-template-columns: 1fr;
  }

  .section-title {
    display: grid;
  }

  .segmented {
    width: 100%;
  }

  .segmented button {
    width: 100%;
  }
}
