:root {
  --bg: #f3f5f7;
  --panel: #ffffff;
  --panel-soft: #f8fafb;
  --ink: #18211e;
  --muted: #65716c;
  --line: #d8e0df;
  --green: #087954;
  --green-dark: #075b40;
  --red: #b33a2f;
  --blue: #1d6f9f;
  --amber: #b7791f;
  --shadow: 0 14px 34px rgba(20, 31, 28, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: "Noto Sans TC", "Microsoft JhengHei", "Segoe UI", sans-serif;
  line-height: 1.5;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  padding: 18px clamp(16px, 4vw, 46px);
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.brand-block h1 {
  margin: 0;
  font-size: clamp(24px, 3vw, 34px);
  letter-spacing: 0;
}

.eyebrow,
.section-kicker {
  margin: 0 0 3px;
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.agent-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 13px;
  color: #fff;
  background: #18211e;
  border-radius: 8px;
  white-space: nowrap;
}

.agent-strip a {
  color: #ffe08a;
  font-weight: 900;
  text-decoration: none;
}

.market-layout {
  width: min(1480px, 100%);
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  margin: 0 auto;
  padding: 18px clamp(12px, 3vw, 34px) 34px;
}

.control-band,
.status-band,
.project-directory,
.community-section,
.chart-section,
.table-section {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.control-band {
  position: sticky;
  top: 88px;
  grid-row: 1 / span 6;
  padding: 16px;
}

.status-band,
.project-directory,
.community-section,
.metrics-grid,
.chart-section,
.table-section {
  grid-column: 2;
}

.search-line {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

label span,
.search-box span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

input[type="search"],
select,
textarea {
  width: 100%;
  border: 1px solid #c9d3d0;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

input[type="search"] {
  min-height: 52px;
  padding: 0 13px;
  font-size: 17px;
  font-weight: 800;
}

input[type="search"]:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(8, 121, 84, 0.14);
}

select {
  height: 42px;
  padding: 0 34px 0 10px;
}

button {
  min-height: 46px;
  padding: 0 15px;
  border: 1px solid var(--green-dark);
  border-radius: 8px;
  color: #fff;
  background: var(--green);
  cursor: pointer;
  font-weight: 900;
}

button:hover {
  background: var(--green-dark);
}

button.secondary {
  border-color: #5b6770;
  background: #49545c;
}

button.secondary:hover {
  background: #2f383f;
}

.filters {
  display: grid;
  grid-template-columns: 1fr;
  gap: 11px;
  margin-top: 14px;
}

.check-control {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.check-control input {
  width: 18px;
  height: 18px;
  accent-color: var(--green);
}

.check-control span {
  margin: 0;
  color: var(--ink);
}

.status-band {
  padding: 15px 17px;
}

.proposal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.proposal-actions label {
  grid-column: 1 / -1;
}

.proposal-actions button {
  min-width: 0;
}

button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.data-status {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.result-status {
  margin: 5px 0 0;
  font-size: clamp(18px, 2vw, 23px);
  font-weight: 950;
}

.hidden {
  display: none;
}

.community-section,
.project-directory,
.chart-section,
.table-section {
  overflow: hidden;
}

.project-directory {
  background: #ffffff;
}

.project-chips {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 8px;
  padding: 14px;
  background: var(--panel-soft);
}

.project-chip {
  min-height: 68px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.project-chip:hover {
  border-left-color: var(--green);
  background: #fff;
  color: var(--ink);
  box-shadow: 0 8px 18px rgba(20, 31, 28, 0.08);
}

.project-chip strong {
  display: block;
  font-size: 15px;
  font-weight: 950;
}

.project-chip span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--line);
}

.section-head h2 {
  margin: 0;
  font-size: 20px;
}

.section-head span {
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  padding: 1px;
  background: var(--line);
}

.profile-item {
  min-height: 74px;
  padding: 12px 15px;
  background: #fff;
}

.profile-item small,
.compare-card small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.profile-item strong {
  display: block;
  margin-top: 4px;
  font-size: 15px;
}

.comparison-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  padding: 14px;
  background: var(--panel-soft);
  border-top: 1px solid var(--line);
}

.compare-card {
  min-height: 104px;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.compare-card strong {
  display: block;
  margin-top: 7px;
  font-size: clamp(21px, 2vw, 28px);
  letter-spacing: 0;
}

.compare-card em {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.compare-card:nth-child(2) strong {
  color: var(--red);
}

.compare-card:nth-child(3) strong {
  color: var(--green);
}

.compare-card:nth-child(4) strong {
  color: var(--blue);
}

.compact-head {
  background: #fff;
}

.listing-cards {
  display: grid;
  gap: 10px;
  padding: 14px;
  background: #eef3f4;
}

.listing-card {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) minmax(150px, 190px);
  gap: 14px;
  align-items: center;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-left: 5px solid var(--green);
  border-radius: 8px;
}

.empty-card {
  padding: 22px;
  color: var(--muted);
  background: #fff;
  border: 1px dashed #b9c5c2;
  border-radius: 8px;
  font-weight: 800;
}

.listing-rank {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  color: #fff;
  background: var(--ink);
  border-radius: 50%;
  font-weight: 950;
}

.listing-title {
  margin: 0;
  font-size: 17px;
  font-weight: 950;
}

.listing-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  color: #34413d;
  background: #edf2f1;
  border: 1px solid #d7e0de;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.pill.warn {
  color: #8b2b22;
  background: #fff0ed;
  border-color: #f0c7bf;
}

.listing-price {
  text-align: right;
}

.listing-price strong {
  display: block;
  color: var(--red);
  font-size: 25px;
  font-weight: 950;
}

.listing-price span,
.listing-price em {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.listing-price a {
  display: inline-block;
  margin-top: 7px;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.metric {
  min-height: 108px;
  padding: 13px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 8px 18px rgba(20, 31, 28, 0.06);
}

.metric small {
  display: block;
  color: var(--muted);
  font-weight: 900;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
  letter-spacing: 0;
}

.metric em {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
}

.metric:nth-child(2) strong {
  color: var(--red);
}

.metric:nth-child(3) strong {
  color: var(--green);
}

.metric:nth-child(4) strong {
  color: var(--blue);
}

.metric:nth-child(5) strong {
  color: var(--amber);
}

.monthly-chart {
  min-height: 238px;
  display: grid;
  grid-template-columns: repeat(12, minmax(42px, 1fr));
  align-items: end;
  gap: 8px;
  padding: 16px;
  overflow-x: auto;
}

.bar {
  min-width: 42px;
}

.bar-track {
  height: 176px;
  display: flex;
  align-items: end;
  background: #e8eef0;
  border: 1px solid #d5e0df;
}

.bar-fill {
  width: 100%;
  min-height: 3px;
  background: linear-gradient(180deg, var(--blue), var(--green));
}

.bar-label,
.bar-value {
  display: block;
  text-align: center;
  font-size: 12px;
}

.bar-value {
  min-height: 20px;
  margin-bottom: 6px;
  color: var(--ink);
  font-weight: 900;
}

.bar-label {
  margin-top: 6px;
  color: var(--muted);
}

.table-wrap {
  overflow: auto;
  max-height: 56vh;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eef3f4;
  color: #3e4945;
  font-size: 13px;
}

td.numeric,
th.numeric {
  text-align: right;
}

.location-main {
  display: block;
  max-width: 460px;
  font-weight: 900;
}

.location-sub {
  display: block;
  max-width: 460px;
  color: var(--muted);
  font-size: 12px;
}

a {
  color: var(--green-dark);
  font-weight: 900;
}

.cut-price {
  display: block;
  color: var(--muted);
  font-size: 12px;
  text-decoration: line-through;
}

.tag {
  display: inline-block;
  margin: 2px 4px 2px 0;
  padding: 2px 6px;
  border: 1px solid #d7c39c;
  border-radius: 999px;
  color: #72510f;
  background: #fff8e8;
  font-size: 12px;
  font-weight: 800;
}

.tag.warn {
  border-color: #e1afa6;
  color: #8b2b22;
  background: #fff0ed;
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 16px clamp(16px, 4vw, 46px);
  color: var(--muted);
  background: #fff;
  border-top: 1px solid var(--line);
  font-size: 13px;
}

@media (max-width: 1180px) {
  .market-layout {
    grid-template-columns: 1fr;
  }

  .control-band,
  .status-band,
  .project-directory,
  .community-section,
  .metrics-grid,
  .chart-section,
  .table-section {
    grid-column: 1;
  }

  .control-band {
    position: static;
    grid-row: auto;
  }

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

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

  .proposal-actions label {
    grid-column: auto;
  }

  .search-box {
    grid-column: 1 / -1;
  }
}

@media (max-width: 900px) {
  .metrics-grid,
  .profile-grid,
  .comparison-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .listing-card {
    grid-template-columns: 46px minmax(0, 1fr);
  }

  .listing-price {
    grid-column: 2;
    text-align: left;
  }
}

@media (max-width: 700px) {
  .topbar,
  footer,
  .status-band,
  .search-line,
  .filters,
  .metrics-grid,
  .profile-grid,
  .comparison-grid {
    grid-template-columns: 1fr;
    display: grid;
  }

  .proposal-actions {
    grid-template-columns: 1fr;
  }

  .proposal-actions label {
    grid-column: 1;
  }

  .agent-strip {
    align-items: start;
    flex-direction: column;
    gap: 4px;
    white-space: normal;
  }

  .section-head {
    align-items: start;
    flex-direction: column;
  }

  .section-head span {
    text-align: left;
  }

  .monthly-chart {
    grid-template-columns: repeat(12, 54px);
  }
}
