:root {
  color-scheme: light;
  --bg: #f3f5f3;
  --surface: #ffffff;
  --surface-muted: #f8faf8;
  --ink: #202824;
  --muted: #68736d;
  --line: #dce2de;
  --line-strong: #c9d1cc;
  --green: #0f6147;
  --green-soft: #e8f2ed;
  --amber: #a96208;
  --amber-soft: #fff3dd;
  --rust: #a94432;
  --rust-soft: #faebe7;
  --focus: #2b78a0;
  --shadow: 0 1px 3px rgba(25, 43, 34, 0.08);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
  letter-spacing: 0;
}

button,
select {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(43, 120, 160, 0.24);
  outline-offset: 2px;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 66px;
  color: #fff;
  background: #124f3d;
  border-bottom: 1px solid #0b3b2d;
}

.header-inner {
  width: min(1440px, calc(100% - 40px));
  height: 100%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.52);
  border-radius: 5px;
  font-size: 18px;
  font-weight: 700;
}

.brand strong,
.brand small {
  display: block;
  letter-spacing: 0;
}

.brand strong {
  font-size: 18px;
  line-height: 1.2;
}

.brand small {
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.68);
  font-size: 11px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 18px;
}

.source-links {
  display: flex;
  align-items: center;
  gap: 16px;
}

.source-link {
  color: rgba(255, 255, 255, 0.75);
  text-decoration: none;
}

.source-link:hover {
  color: #fff;
}

.refresh-button {
  height: 36px;
  padding: 0 13px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #153126;
  background: #fff;
  border: 0;
  border-radius: 5px;
  font-weight: 650;
}

.refresh-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.refresh-button.is-loading .refresh-icon {
  animation: spin 0.9s linear infinite;
}

main {
  width: min(1440px, calc(100% - 40px));
  margin: 0 auto;
}

.overview {
  min-height: 104px;
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 32px;
  border-bottom: 1px solid var(--line-strong);
}

.overview-main {
  display: flex;
  align-items: center;
  gap: 22px;
}

.city-control {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
}

.city-control select {
  width: 104px;
  height: 36px;
  padding: 0 8px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 5px;
}

.status-summary {
  min-height: 44px;
  padding: 0 15px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  box-shadow: var(--shadow);
  font-weight: 650;
}

.status-summary strong {
  color: var(--green);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

.sync-state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  white-space: nowrap;
}

.sync-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  background: var(--amber);
  border-radius: 50%;
}

.sync-dot.ready {
  background: var(--green);
}

.sync-dot.error {
  background: var(--rust);
}

.metrics {
  display: flex;
  align-items: stretch;
}

.metric {
  min-width: 132px;
  padding: 24px 22px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-left: 1px solid var(--line);
}

.metric span {
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  margin-top: 2px;
  font-size: 21px;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
}

.filters {
  padding: 22px 0 24px;
  border-bottom: 1px solid var(--line-strong);
}

.section-heading,
.results-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.section-heading > div,
.results-toolbar > div {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

h1,
h2 {
  margin: 0;
  font-size: 17px;
  line-height: 1.35;
}

.filter-count,
.results-toolbar > div > span {
  color: var(--muted);
  font-size: 12px;
}

.text-button {
  padding: 4px 0;
  color: var(--green);
  background: transparent;
  border: 0;
  font-weight: 600;
}

.filter-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: minmax(220px, 1.35fr) minmax(150px, 0.8fr) minmax(140px, 0.75fr) repeat(3, minmax(188px, 1fr));
  gap: 12px;
}

.field {
  min-width: 0;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: 0;
}

.field > span,
.field legend {
  padding: 0;
  color: #52605a;
  font-size: 12px;
  font-weight: 600;
}

.field input,
.field select,
.sort-control select {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 5px;
}

.field input:hover,
.field select:hover,
.sort-control select:hover {
  border-color: #9ba8a1;
}

.range-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 16px minmax(0, 1fr);
  align-items: center;
}

.range-field legend {
  grid-column: 1 / -1;
  margin-bottom: 6px;
}

.range-field > span {
  text-align: center;
  color: #89928d;
  font-weight: 400;
}

.results {
  padding: 22px 0 30px;
}

.sort-control {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.sort-control select {
  width: 160px;
  height: 34px;
  padding-right: 8px;
}

.result-table {
  margin-top: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.result-head,
.result-row {
  display: grid;
  grid-template-columns: minmax(310px, 2fr) 138px 112px 104px 160px 116px 76px;
  align-items: center;
  column-gap: 14px;
}

.result-head {
  min-height: 42px;
  padding: 0 16px;
  color: #66716c;
  background: var(--surface-muted);
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  font-weight: 650;
}

.result-row {
  position: relative;
  min-height: 92px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  transition: background-color 120ms ease;
}

.result-row:last-child {
  border-bottom: 0;
}

.result-row:hover {
  background: #fbfcfb;
}

.project-cell {
  min-width: 0;
}

.project-title {
  display: -webkit-box;
  overflow: hidden;
  color: var(--ink);
  font-size: 15px;
  font-weight: 650;
  line-height: 1.45;
  text-decoration: none;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.project-title:hover {
  color: var(--green);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.subject-relation {
  margin-top: 6px;
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 7px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.subject-relation > span:first-child {
  color: var(--green);
  font-weight: 700;
}

.subject-relation strong {
  overflow: hidden;
  max-width: 100%;
  color: #44504a;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-meta {
  margin-top: 7px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 1px 7px;
  color: var(--amber);
  background: var(--amber-soft);
  border: 1px solid #efd3a3;
  border-radius: 4px;
  font-weight: 650;
}

.status-badge.ongoing {
  color: var(--rust);
  background: var(--rust-soft);
  border-color: #edc6bc;
}

.data-cell {
  min-width: 0;
  color: #27312c;
  font-variant-numeric: tabular-nums;
}

.data-cell strong,
.data-cell small {
  display: block;
}

.data-cell strong {
  overflow: hidden;
  font-size: 14px;
  font-weight: 650;
  text-overflow: ellipsis;
}

.data-cell small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.unknown {
  color: #929b96;
  font-weight: 400 !important;
}

.row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.official-link,
.image-link {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: var(--green);
  background: var(--green-soft);
  border: 1px solid #c9ded4;
  border-radius: 5px;
  font-size: 18px;
  font-weight: 700;
  text-decoration: none;
}

.image-link {
  padding: 0;
}

.image-link svg {
  width: 18px;
  height: 18px;
}

.official-link:hover,
.image-link:hover {
  color: #fff;
  background: var(--green);
  border-color: var(--green);
}

.image-viewer {
  width: min(1080px, calc(100% - 32px));
  height: min(820px, calc(100% - 32px));
  max-width: none;
  max-height: none;
  padding: 0;
  color: #fff;
  background: #151a17;
  border: 1px solid #3b433f;
  border-radius: 6px;
  box-shadow: 0 18px 55px rgba(0, 0, 0, 0.4);
}

.image-viewer::backdrop {
  background: rgba(17, 22, 19, 0.78);
}

.image-viewer-shell {
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.image-viewer-header {
  min-width: 0;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: #202723;
  border-bottom: 1px solid #3b433f;
}

.image-viewer-header > div {
  min-width: 0;
}

.image-viewer-header h2,
.image-viewer-header span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-viewer-header h2 {
  margin: 0;
  font-size: 16px;
  letter-spacing: 0;
}

.image-viewer-header span {
  display: block;
  margin-top: 2px;
  color: #b9c2bd;
  font-size: 12px;
}

.viewer-icon-button,
.viewer-nav-button {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  padding: 0;
  color: #fff;
  background: transparent;
  border: 1px solid #515b55;
  border-radius: 5px;
}

.viewer-icon-button:hover,
.viewer-nav-button:hover:not(:disabled) {
  background: #303934;
  border-color: #75817a;
}

.viewer-icon-button svg,
.viewer-nav-button svg {
  width: 20px;
  height: 20px;
}

.viewer-nav-button:disabled {
  opacity: 0.3;
  cursor: default;
}

.image-viewer-stage {
  min-height: 0;
  padding: 12px;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 38px;
  align-items: center;
  gap: 12px;
}

.image-viewer-canvas {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #0d100e;
}

.image-viewer-canvas img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.viewer-message {
  position: absolute;
  color: #c7cfca;
  font-size: 13px;
}

.viewer-message[hidden],
.image-viewer-canvas img[hidden] {
  display: none;
}

.viewer-error {
  color: #f1c7bd;
}

.image-viewer-footer {
  min-height: 44px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #b9c2bd;
  background: #202723;
  border-top: 1px solid #3b433f;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.message-state {
  min-height: 260px;
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
}

.message-state[hidden] {
  display: none;
}

.message-state strong {
  color: var(--ink);
  font-size: 15px;
}

.message-state button {
  margin-top: 10px;
  height: 34px;
  padding: 0 14px;
  color: #fff;
  background: var(--green);
  border: 0;
  border-radius: 5px;
}

.error-state {
  border-color: #ddb7ae;
}

.spinner {
  width: 28px;
  height: 28px;
  margin-bottom: 8px;
  border: 3px solid #dce7e1;
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

.pagination {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.pagination[hidden] {
  display: none;
}

.pagination span {
  min-width: 86px;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.icon-button {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  font-size: 22px;
  line-height: 1;
}

.icon-button:disabled {
  color: #b2b9b5;
  background: #eef1ef;
  cursor: not-allowed;
}

footer {
  width: min(1440px, calc(100% - 40px));
  min-height: 70px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding-top: 18px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font-size: 12px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 1220px) {
  .filter-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .field-keyword {
    grid-column: span 1;
  }

  .result-head,
  .result-row {
    grid-template-columns: minmax(270px, 2fr) 130px 100px 96px 140px 104px 76px;
    column-gap: 10px;
  }
}

@media (max-width: 900px) {
  .app-header {
    height: 60px;
  }

  .header-inner,
  main,
  footer {
    width: min(100% - 24px, 720px);
  }

  .source-link {
    display: none;
  }

  .overview {
    padding: 18px 0;
    flex-direction: column;
    gap: 16px;
  }

  .overview-main {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .city-control {
    position: absolute;
    top: 18px;
    right: 0;
  }

  .overview {
    position: relative;
  }

  .sync-state {
    padding-right: 132px;
  }

  .status-summary {
    width: 100%;
    justify-content: space-between;
  }

  .metrics {
    border-top: 1px solid var(--line);
  }

  .metric {
    min-width: 0;
    flex: 1;
    padding: 14px 12px 0;
  }

  .metric:first-child {
    padding-left: 0;
    border-left: 0;
  }

  .metric strong {
    font-size: 18px;
  }

  .filter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .field-keyword {
    grid-column: span 1;
  }

  .result-head {
    display: none;
  }

  .result-table {
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    overflow: visible;
  }

  .result-body {
    display: grid;
    gap: 10px;
  }

  .result-row {
    min-height: 0;
    padding: 15px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 12px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 6px;
    box-shadow: var(--shadow);
  }

  .project-cell {
    grid-column: 1 / -1;
    padding-right: 42px;
  }

  .result-row.has-images .project-cell {
    padding-right: 82px;
  }

  .data-cell::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 3px;
    color: var(--muted);
    font-size: 11px;
  }

  .row-actions {
    position: absolute;
    top: 14px;
    right: 14px;
  }
}

@media (max-width: 580px) {
  .image-viewer {
    width: calc(100% - 16px);
    height: calc(100% - 16px);
  }

  .image-viewer-stage {
    padding: 8px 4px;
    grid-template-columns: 36px minmax(0, 1fr) 36px;
    gap: 4px;
  }

  .viewer-nav-button {
    width: 36px;
    height: 36px;
  }

  .brand small,
  .refresh-button > span:last-child {
    display: none;
  }

  .refresh-button {
    width: 36px;
    padding: 0;
    justify-content: center;
    font-size: 19px;
  }

  .metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .city-control {
    position: static;
  }

  .city-control select {
    flex: 1;
  }

  .sync-state {
    padding-right: 0;
  }

  .metric {
    padding-right: 7px;
    padding-left: 7px;
  }

  .metric strong {
    overflow: hidden;
    font-size: 16px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .section-heading,
  .results-toolbar {
    align-items: flex-start;
  }

  .filter-grid {
    grid-template-columns: 1fr;
  }

  .results-toolbar {
    gap: 12px;
  }

  .sort-control {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
  }

  .sort-control select {
    width: 140px;
  }

  footer {
    flex-direction: column;
    justify-content: flex-start;
    gap: 4px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
