:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1f2933;
  --muted: #667085;
  --line: #d9dee8;
  --accent: #0f766e;
  --accent-weak: #d8f3ef;
  --hot: #9f1239;
  --warning: #9a4d00;
  --shadow: 0 10px 30px rgba(18, 38, 63, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  min-height: 36px;
  padding: 0 14px;
}

button:hover,
.tab.active,
.button-link:hover {
  border-color: var(--accent);
  color: var(--accent);
}

button.primary,
.sidebar-action.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

button.primary:hover,
.sidebar-action.primary:hover {
  background: #0b5f59;
  border-color: #0b5f59;
  color: #fff;
}

.button-link {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  display: inline-flex;
  min-height: 36px;
  padding: 0 14px;
  text-decoration: none;
}

.app-shell {
  min-height: 100vh;
  padding: 20px;
}

.topbar {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin: 0 auto 16px;
  max-width: 1500px;
}

.topbar h1 {
  font-size: 26px;
  line-height: 1.2;
  margin: 0 0 4px;
}

.topbar p,
.muted {
  color: var(--muted);
  margin: 0;
}

.actions,
.tabs {
  display: flex;
  gap: 8px;
}

.actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

#showAllPropertiesBtn,
#openPropertyImportBtn {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 700;
  min-width: 128px;
}

#showAllPropertiesBtn:hover,
#openPropertyImportBtn:hover {
  background: #0b5f59;
  border-color: #0b5f59;
  color: #fff;
}

.tabs {
  flex-wrap: wrap;
  margin: 0 auto 16px;
  max-width: 1500px;
}

.tab.active {
  background: var(--accent-weak);
}

.stats {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0 auto 16px;
  max-width: 1500px;
}

.stats article,
.audit-panel,
.sidebar,
.detail,
.property-tools,
.property-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.stats article {
  padding: 14px 16px;
}

.stats span {
  color: var(--muted);
  display: block;
  margin-bottom: 4px;
}

.stats strong {
  font-size: 24px;
}

.audit-panel {
  align-items: center;
  display: grid;
  gap: 16px;
  grid-template-columns: 260px minmax(0, 1fr);
  margin: 0 auto 16px;
  max-width: 1500px;
  padding: 14px 16px;
}

.collection-guide {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
  grid-column: 1 / -1;
  padding-top: 12px;
}

.collection-guide strong,
.collection-guide b {
  font-weight: 700;
}

.collection-guide div {
  align-items: baseline;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.collection-guide span {
  color: var(--muted);
}

.collection-warning {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  color: #9a3412;
  font-size: 13px;
  font-weight: 700;
  margin: 0;
  padding: 8px 10px;
}

.collection-guide ul {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(5, minmax(160px, 1fr));
  list-style: none;
  margin: 0;
  padding: 0;
}

.collection-guide li {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  min-height: 72px;
  padding: 8px 10px;
}

.work-plan {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
  grid-column: 1 / -1;
  padding-top: 12px;
}

.work-plan-head {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.work-plan-head h2 {
  font-size: 16px;
  margin: 0 0 4px;
}

.work-plan-head p {
  color: var(--muted);
  margin: 0;
}

.work-plan-head strong {
  background: var(--accent-weak);
  border: 1px solid #99d8ce;
  border-radius: 8px;
  color: var(--accent);
  padding: 8px 12px;
  white-space: nowrap;
}

.work-plan-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
}

.work-plan-grid article {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  min-height: 96px;
  padding: 10px;
}

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

.work-plan-grid strong {
  font-size: 18px;
}

.work-plan-grid p {
  color: var(--muted);
  margin: 0;
}

.audit-panel h2,
.property-tools h2 {
  font-size: 16px;
  margin: 0 0 4px;
}

.audit-list {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(8, minmax(110px, 1fr));
}

.audit-item {
  border: 1px solid #f2c078;
  border-radius: 8px;
  background: #fff8eb;
  min-height: 58px;
  padding: 8px 10px;
}

.audit-item.ok {
  background: #ecfdf3;
  border-color: #86d9a8;
}

.audit-item span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-bottom: 4px;
}

.audit-item strong {
  color: var(--text);
  font-size: 18px;
}

.workspace,
.properties-view {
  display: grid;
  gap: 16px;
  margin: 0 auto;
  max-width: 1500px;
}

.workspace {
  grid-template-columns: 380px minmax(0, 1fr);
}

.properties-view {
  grid-template-columns: 360px minmax(0, 1fr);
}

.sidebar,
.property-tools {
  max-height: calc(100vh - 220px);
  overflow: auto;
  padding: 14px;
}

.property-tools section + section {
  border-top: 1px solid var(--line);
  margin-top: 16px;
  padding-top: 16px;
}

.detail,
.property-panel {
  min-height: calc(100vh - 220px);
  padding: 18px;
}

.field {
  display: block;
  margin-bottom: 10px;
}

.field span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-bottom: 5px;
}

.field input,
.field select,
.field textarea,
textarea {
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 36px;
  padding: 8px 10px;
  width: 100%;
}

textarea {
  resize: vertical;
}

.check-row {
  align-items: center;
  color: var(--muted);
  display: flex;
  gap: 8px;
  margin: 8px 0;
}

.check-row input {
  width: auto;
}

.sidebar-hint {
  font-size: 12px;
  margin: -2px 0 10px;
}

.sidebar-action {
  margin: 4px 0 12px;
  width: 100%;
}

.property-gap-panel {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  margin-top: 10px;
  padding: 10px;
}

.property-detail-queue-panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  margin-top: 10px;
  padding: 10px;
}

.property-gap-head,
.property-gap-item div,
.property-gap-actions {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.property-gap-head span,
.property-gap-item span,
.property-gap-item p {
  color: var(--muted);
  font-size: 12px;
}

.property-gap-list {
  display: grid;
  gap: 6px;
}

.property-next-queue {
  background: #eef6ff;
  border: 1px solid #bfd7ff;
  border-radius: 8px;
  display: grid;
  gap: 6px;
  padding: 8px;
}

.property-next-queue article {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  display: grid;
  gap: 3px;
  padding: 6px;
}

.property-next-queue span,
.property-next-queue p {
  color: var(--muted);
  font-size: 12px;
  margin: 0;
}

.property-gap-item {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 6px;
  padding: 8px;
}

.property-gap-item.ok {
  border-color: #9ecfba;
}

.property-gap-item p {
  margin: 0;
}

.property-gap-actions {
  justify-content: flex-start;
}

.property-gap-actions button {
  min-height: 30px;
  padding: 0 10px;
}

.button-link.mini {
  min-height: 30px;
  padding: 6px 10px;
}

.property-batch-preview {
  display: grid;
  gap: 8px;
  margin: 10px 0;
}

.sidebar-import {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
}

.sidebar-import h3 {
  font-size: 14px;
  margin: 0;
}

.sidebar-import textarea {
  min-height: 118px;
}

.client-batch-preview {
  display: grid;
  gap: 8px;
}

.property-batch-head,
.property-batch-title {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.property-batch-head span,
.property-batch-title span,
.property-batch-item p {
  color: var(--muted);
  font-size: 12px;
}

.property-batch-list {
  display: grid;
  gap: 6px;
  max-height: 360px;
  overflow: auto;
}

.property-batch-item {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 6px;
  padding: 8px;
}

.property-batch-item.ready {
  border-color: #9ecfba;
}

.property-batch-item.duplicate {
  background: #fff7ed;
  border-color: #fed7aa;
}

.property-batch-item.invalid {
  background: #fef2f2;
  border-color: #fecaca;
}

.property-batch-item p {
  margin: 0;
}

.key-candidate-preview {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  margin: 4px 0 12px;
  padding: 10px;
}

.key-candidate-head {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.key-candidate-head span,
.key-candidate-preview p {
  color: var(--muted);
  font-size: 12px;
}

.key-candidate-preview p {
  margin: 0;
}

.key-candidate-list {
  display: grid;
  gap: 6px;
}

.key-candidate-item {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 8px;
}

.key-candidate-item div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.key-candidate-actions {
  align-items: end;
  justify-items: end;
}

.key-candidate-item span,
.key-candidate-item em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.key-candidate-item button {
  min-height: 30px;
  padding: 0 10px;
}

.client-list,
.property-list,
.matches {
  display: grid;
  gap: 8px;
}

.client-list {
  max-height: calc(100vh - 420px);
  overflow: auto;
  padding-right: 4px;
}

.client-item,
.property-card,
.match-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.client-item {
  cursor: pointer;
  text-align: left;
  width: 100%;
}

.client-item.active {
  background: var(--accent-weak);
  border-color: var(--accent);
}

.property-card.editing {
  background: #f0fdfa;
  border-color: var(--accent);
}

.client-title,
.match-head,
.detail-head {
  align-items: flex-start;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.client-title-actions {
  align-items: center;
  display: flex;
  flex-shrink: 0;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.quick-key-btn {
  font-size: 12px;
  min-height: 26px;
  padding: 0 8px;
}

.quick-key-btn.active {
  background: #ffe4e6;
  border-color: #fda4af;
  color: var(--hot);
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.client-title strong,
.match-head h4,
.property-card h3 {
  font-size: 16px;
  margin: 0 0 6px;
}

.pill,
.tag {
  background: #eef2f6;
  border-radius: 999px;
  color: #475467;
  display: inline-flex;
  font-size: 12px;
  line-height: 1;
  padding: 5px 8px;
  white-space: nowrap;
}

.pill.hot,
.tag.hot {
  background: #ffe4e6;
  color: var(--hot);
}

.mini-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.client-item p,
.property-card p {
  color: var(--muted);
  margin: 6px 0 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.client-item .client-missing {
  color: var(--warning);
}

.client-match-preview {
  display: grid;
  gap: 4px;
  margin-top: 8px;
}

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

.client-match-preview em {
  color: var(--text);
  display: grid;
  gap: 2px;
  font-style: normal;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.client-match-preview strong,
.client-match-preview small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.client-match-preview strong {
  font-weight: 600;
}

.client-match-preview small {
  color: var(--muted);
  font-size: 12px;
}

.property-detail {
  border-top: 1px solid var(--line);
  margin-top: 10px;
  padding-top: 10px;
}

.property-detail summary {
  color: var(--accent);
  cursor: pointer;
  font-weight: 600;
}

.property-detail dl {
  display: grid;
  gap: 8px;
  margin: 10px 0 0;
}

.property-detail dl div {
  display: grid;
  gap: 6px;
  grid-template-columns: 92px minmax(0, 1fr);
}

.property-detail dt {
  color: var(--muted);
}

.property-detail dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.property-detail a {
  color: var(--accent);
}

.property-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 8px;
}

.property-actions button {
  min-height: 30px;
}

.editing-badge {
  align-items: center;
  background: var(--accent-weak);
  border: 1px solid #99d8ce;
  border-radius: 999px;
  color: var(--accent);
  display: inline-flex;
  font-size: 12px;
  min-height: 30px;
  padding: 0 10px;
}

.client-completeness h3 {
  font-size: 16px;
  margin: 0;
}

.client-demand-summary h3 {
  font-size: 16px;
  margin: 0 0 10px;
}

.client-demand-summary dl {
  display: grid;
  gap: 8px;
  margin: 0;
}

.client-demand-summary dl div {
  display: grid;
  gap: 6px;
  grid-template-columns: 90px minmax(0, 1fr);
}

.client-demand-summary dt {
  color: var(--muted);
}

.client-demand-summary dd {
  margin: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.client-detail-signal-preview {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  margin-top: 10px;
  padding: 10px;
}

.client-detail-signal-preview p {
  color: var(--muted);
  margin: 0;
}

.client-detail-signal-preview dl {
  display: grid;
  gap: 8px;
  margin: 0;
}

.client-detail-signal-preview dl div {
  display: grid;
  gap: 6px;
  grid-template-columns: 90px minmax(0, 1fr);
}

.client-detail-signal-preview dt {
  color: var(--muted);
}

.client-detail-signal-preview dd {
  margin: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.client-source-detail {
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 16px;
  padding: 14px;
}

.client-source-detail summary {
  color: var(--accent);
  cursor: pointer;
  font-weight: 600;
}

.client-source-detail article {
  border-top: 1px solid var(--line);
  margin-top: 12px;
  padding-top: 12px;
}

.client-source-detail h4 {
  font-size: 14px;
  margin: 0 0 8px;
}

.client-source-detail pre {
  color: var(--muted);
  font: inherit;
  margin: 0;
  max-height: 260px;
  overflow: auto;
  white-space: pre-wrap;
}

.empty-state {
  align-items: center;
  color: var(--muted);
  display: grid;
  min-height: 360px;
  place-content: center;
  text-align: center;
}

.empty-state h2 {
  color: var(--text);
  margin: 0 0 8px;
}

.detail-head {
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
  padding-bottom: 14px;
}

.detail-head h2 {
  font-size: 22px;
  margin: 0 0 8px;
}

.meta-row {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.requirement {
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 16px;
  padding: 14px;
}

.form-grid {
  display: grid;
  gap: 10px;
}

.ocr-tools {
  border: 1px dashed var(--line);
  border-radius: 8px;
  margin: 10px 0;
  padding: 10px;
}

.ocr-tools .field {
  margin-bottom: 8px;
}

.ocr-tools button {
  margin-bottom: 8px;
  width: 100%;
}

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

.form-grid.compact {
  margin: 4px 0 12px;
}

.field.full {
  grid-column: 1 / -1;
}

.price {
  color: var(--accent);
  font-size: 20px;
  font-weight: 700;
  white-space: nowrap;
}

.score {
  color: var(--muted);
}

.reasons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.reason {
  background: var(--accent-weak);
  border-radius: 999px;
  color: #075e56;
  padding: 5px 8px;
}

.match-evidence {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  margin-top: 10px;
  padding: 10px;
}

.match-evidence > strong {
  font-size: 13px;
}

.match-evidence div {
  display: grid;
  gap: 2px;
}

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

.match-evidence p {
  margin: 0;
}

.match-client-evidence,
.match-property-evidence {
  background: #f6f8fb;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 6px;
  margin-top: 10px;
  padding: 10px;
}

.match-property-evidence {
  background: #f7fbf7;
}

.match-client-evidence > strong,
.match-property-evidence > strong {
  font-size: 13px;
}

.match-client-evidence p,
.match-property-evidence p {
  margin: 0;
  overflow-wrap: anywhere;
}

.match-client-evidence span,
.match-property-evidence span {
  color: var(--muted);
  display: inline-block;
  font-size: 12px;
  margin-right: 8px;
}

.match-cautions {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  color: #9a3412;
  display: grid;
  gap: 6px;
  margin-top: 10px;
  padding: 10px;
}

.match-cautions > strong {
  font-size: 13px;
}

.match-cautions p {
  margin: 0;
}

.warning {
  color: var(--warning);
}

.duplicate-warning {
  align-items: flex-start;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.duplicate-warning p {
  flex: 1 1 320px;
  margin: 0;
}

.duplicate-warning button {
  flex-shrink: 0;
}

@media (max-width: 980px) {
  .app-shell {
    padding: 12px;
  }

  .topbar,
  .workspace,
  .properties-view {
    display: block;
  }

  .actions {
    margin-top: 12px;
  }

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

  .audit-panel {
    display: block;
  }

  .audit-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 12px;
  }

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

  .sidebar,
  .property-tools {
    margin-bottom: 12px;
    max-height: none;
  }

  .client-list {
    max-height: 320px;
  }

  .form-grid.two {
    grid-template-columns: 1fr;
  }
}
