:root {
  --bg: #f7f3ec;
  --panel: #fffdfa;
  --panel-strong: #ffffff;
  --ink: #202124;
  --muted: #73706b;
  --line: #e5ded3;
  --brand: #2269a8;
  --brand-strong: #164d80;
  --gold: #b4832c;
  --green: #2f8c68;
  --red: #c94b4b;
  --shadow: 0 14px 40px rgba(46, 35, 20, 0.13);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.84), rgba(247,243,236,0.96)),
    var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 520px;
  margin: 0 auto;
  background: var(--bg);
  overflow: hidden;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 8px;
  padding: max(10px, env(safe-area-inset-top)) 14px 10px;
  background: rgba(247, 243, 236, 0.94);
  border-bottom: 1px solid rgba(229, 222, 211, 0.86);
  backdrop-filter: blur(18px);
}

.topbar-title {
  min-width: 0;
  text-align: center;
}

.topbar h1 {
  margin: 0;
  font-size: 18px;
  line-height: 24px;
  font-weight: 800;
  letter-spacing: 0;
}

.topbar p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-button {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255,255,255,0.72);
  border: 1px solid rgba(229, 222, 211, 0.8);
  color: var(--brand);
  font-size: 28px;
  line-height: 1;
}

.icon-button[hidden] {
  display: grid;
  visibility: hidden;
  pointer-events: none;
}

.content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 14px 86px;
  -webkit-overflow-scrolling: touch;
}

.content::-webkit-scrollbar,
.option-list::-webkit-scrollbar {
  width: 0;
}

.hero {
  padding: 18px 2px 12px;
}

.hero h2 {
  margin: 0;
  font-size: 28px;
  line-height: 36px;
  font-weight: 850;
}

.hero p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 22px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 48px;
  padding: 0 14px;
  margin: 12px 0;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--muted);
  box-shadow: 0 4px 18px rgba(53, 42, 26, 0.05);
}

.search-box input {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-size: 15px;
}

.search-box span:first-child {
  color: var(--brand);
  font-size: 19px;
}

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 0 10px;
}

.section-title h3 {
  margin: 0;
  font-size: 16px;
  line-height: 22px;
}

.section-title p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

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

.tool-card,
.entry-card,
.listing-card,
.estate-card,
.metric-card,
.chart-card,
.report-card,
.detail-panel {
  border: 1px solid rgba(229, 222, 211, 0.86);
  border-radius: 8px;
  background: var(--panel-strong);
  box-shadow: 0 8px 22px rgba(53, 42, 26, 0.07);
}

.tool-card {
  min-height: 132px;
  padding: 14px;
  text-align: left;
}

.tool-card:active,
.entry-card:active,
.listing-card:active,
.estate-card:active,
.report-card:active,
.filter-chip:active {
  transform: translateY(1px);
}

.tool-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--brand);
  font-size: 20px;
  margin-bottom: 12px;
}

.tool-card:nth-child(2) .tool-icon,
.tool-card:nth-child(5) .tool-icon {
  background: var(--gold);
}

.tool-card:nth-child(3) .tool-icon {
  background: var(--green);
}

.tool-card h4,
.entry-main h3,
.listing-card h3,
.estate-card h3,
.report-card h3 {
  margin: 0;
  font-size: 16px;
  line-height: 22px;
  font-weight: 750;
}

.tool-card p,
.entry-main p,
.listing-card p,
.estate-card p,
.report-card p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 20px;
}

.quick-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.metric-card {
  padding: 12px;
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 16px;
}

.metric-card strong {
  display: block;
  margin-top: 6px;
  color: var(--brand-strong);
  font-size: 22px;
  line-height: 28px;
}

.entry-list {
  display: grid;
  gap: 10px;
}

.entry-card {
  display: grid;
  grid-template-columns: 44px 1fr 22px;
  align-items: center;
  gap: 12px;
  min-height: 86px;
  padding: 14px;
}

.entry-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #edf4fb;
  color: var(--brand);
  font-size: 20px;
}

.entry-arrow {
  color: var(--muted);
  font-size: 20px;
}

.filter-row {
  position: sticky;
  top: 65px;
  z-index: 15;
  display: flex;
  gap: 8px;
  padding: 4px 0 10px;
  margin: -2px 0 8px;
  overflow-x: auto;
  background: linear-gradient(180deg, var(--bg) 74%, rgba(247,243,236,0));
}

.filter-row::-webkit-scrollbar {
  height: 0;
}

.filter-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 168px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel-strong);
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.filter-chip.active {
  border-color: rgba(34, 105, 168, 0.35);
  background: #eaf3fb;
  color: var(--brand-strong);
  font-weight: 700;
}

.filter-chip span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-stack {
  display: grid;
  gap: 10px;
}

.listing-card,
.estate-card,
.report-card {
  padding: 14px;
}

.listing-top,
.estate-top,
.report-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.price {
  flex: 0 0 auto;
  color: var(--red);
  font-size: 19px;
  line-height: 24px;
  font-weight: 850;
  text-align: right;
}

.meta-row,
.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  max-width: 100%;
  padding: 3px 8px;
  border-radius: 6px;
  background: #f3eee6;
  color: #6f6049;
  font-size: 12px;
  line-height: 18px;
}

.pill.blue {
  color: var(--brand-strong);
  background: #eaf3fb;
}

.pill.green {
  color: var(--green);
  background: #e9f5ef;
}

.pill.gold {
  color: #8b641e;
  background: #f8edda;
}

.empty-state {
  padding: 44px 20px;
  text-align: center;
  color: var(--muted);
}

.chart-card {
  padding: 14px;
  margin-bottom: 10px;
}

.bar-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: 64px 1fr 46px;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.bar-track {
  height: 9px;
  border-radius: 999px;
  background: #eee7dc;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--brand);
}

.trend-line {
  height: 142px;
  display: flex;
  align-items: end;
  gap: 6px;
  padding: 12px 0 0;
}

.trend-line span {
  flex: 1;
  min-width: 0;
  border-radius: 5px 5px 0 0;
  background: linear-gradient(180deg, var(--brand), #79a7d0);
}

.tabbar {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 30;
  transform: translateX(-50%);
  width: min(520px, 100vw);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 6px 8px max(6px, env(safe-area-inset-bottom));
  background: rgba(255,255,255,0.95);
  border-top: 1px solid rgba(229, 222, 211, 0.9);
  backdrop-filter: blur(18px);
}

.tab-item {
  min-width: 0;
  height: 54px;
  display: grid;
  place-items: center;
  gap: 2px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 11px;
}

.tab-icon {
  font-size: 20px;
  line-height: 20px;
}

.tab-item.active {
  color: var(--brand);
  background: #eaf3fb;
  font-weight: 700;
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(23, 19, 15, 0.32);
}

.bottom-sheet,
.detail-sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 50;
  width: min(520px, 100vw);
  max-height: 84vh;
  transform: translate(-50%, 110%);
  border-radius: 18px 18px 0 0;
  background: var(--panel-strong);
  box-shadow: var(--shadow);
  transition: transform 180ms ease;
  overflow: hidden;
}

.bottom-sheet.open,
.detail-sheet.open {
  transform: translate(-50%, 0);
}

.sheet-handle {
  width: 42px;
  height: 4px;
  margin: 10px auto;
  border-radius: 999px;
  background: #d7cdbc;
}

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

.sheet-head h2 {
  margin: 0;
  font-size: 18px;
  line-height: 24px;
}

.sheet-head p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.text-button {
  min-height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  color: var(--brand);
  background: #eaf3fb;
  font-size: 13px;
  font-weight: 700;
}

.option-list {
  max-height: 62vh;
  overflow-y: auto;
  padding: 10px 16px 18px;
}

.option-button {
  width: 100%;
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #f0ebe3;
  text-align: left;
  font-size: 15px;
}

.option-button.active {
  color: var(--brand);
  font-weight: 750;
}

.detail-sheet {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#detailContent {
  padding: 0 16px 22px;
}

.detail-title {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.detail-title h2 {
  margin: 0;
  font-size: 21px;
  line-height: 28px;
}

.detail-title p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 20px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0;
}

.detail-cell {
  padding: 10px;
  border-radius: 8px;
  background: #f7f1e8;
}

.detail-cell span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.detail-cell strong {
  display: block;
  margin-top: 4px;
  font-size: 15px;
  line-height: 21px;
}

.timeline {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.timeline-item {
  padding-left: 14px;
  border-left: 2px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  line-height: 20px;
}

.timeline-item strong {
  display: block;
  color: var(--ink);
  font-size: 14px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 92px;
  z-index: 80;
  max-width: min(320px, calc(100vw - 40px));
  transform: translate(-50%, 18px);
  opacity: 0;
  pointer-events: none;
  padding: 10px 14px;
  border-radius: 20px;
  color: #fff;
  background: rgba(22, 22, 22, 0.84);
  font-size: 13px;
  line-height: 18px;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (min-width: 521px) {
  body {
    padding: 18px 0;
  }

  .app-shell {
    min-height: calc(100vh - 36px);
    border: 1px solid var(--line);
    border-radius: 22px;
    box-shadow: var(--shadow);
  }

  .tabbar {
    bottom: 18px;
    border-radius: 0 0 22px 22px;
  }
}
