:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #17191c;
  --muted: #6b7280;
  --line: #e5e7eb;
  --buy: #2563eb;
  --rent: #059669;
  --accent: #111827;
  --soft: #f0f4f8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.wrap {
  max-width: 1220px;
  margin: 0 auto;
  padding: 20px 18px 48px;
}

.top {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 22px;
  font-size: 14px;
}

.top a {
  color: var(--muted);
  text-decoration: none;
}

.top a:hover { color: var(--text); }

.top strong { letter-spacing: -0.02em; }

.hero {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 18px;
}

h1 {
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.05;
  margin: 0 0 8px;
  letter-spacing: -0.03em;
}

.sub {
  color: var(--muted);
  max-width: 780px;
  line-height: 1.5;
  margin: 0;
}

.badge {
  font-size: 12px;
  background: #e8eefc;
  color: #244b9b;
  padding: 7px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.grid {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 18px;
}

.panel,
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
}

.panel { padding: 18px; }

.results { display: grid; gap: 18px; }

.mode {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--soft);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 14px;
}

.mode button {
  border: 0;
  background: transparent;
  border-radius: 9px;
  padding: 10px;
  font-weight: 700;
  cursor: pointer;
}

.mode button.active {
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.lookback {
  font-size: 13px;
  color: var(--muted);
}

.periods {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin: 10px 0 18px;
}

.periods button {
  padding: 8px 4px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 9px;
  cursor: pointer;
  font-size: 13px;
}

.periods button.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.section {
  padding-top: 14px;
  margin-top: 14px;
  border-top: 1px solid var(--line);
}

.section:first-of-type {
  border-top: 0;
  padding-top: 0;
  margin-top: 0;
}

.section h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 10px;
}

.row {
  display: grid;
  grid-template-columns: 1fr 120px;
  gap: 12px;
  align-items: center;
  margin: 9px 0;
}

.row label {
  font-size: 14px;
  line-height: 1.25;
}

input,
select {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 9px;
  padding: 9px 10px;
  font: inherit;
  background: #fff;
  color: var(--text);
}

input:focus,
select:focus {
  outline: 2px solid #9db4ef;
  outline-offset: 1px;
}

.hint {
  font-size: 11px;
  color: var(--muted);
  margin: 3px 0 0;
}

.summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.stat { padding: 18px; }

.stat .k {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 8px;
}

.stat .v {
  font-size: clamp(24px, 3vw, 36px);
  font-weight: 800;
  letter-spacing: -0.03em;
}

.stat .s {
  font-size: 13px;
  color: var(--muted);
  margin-top: 5px;
}

.winner { border: 2px solid #d1d5db; }

.chartcard { padding: 16px 16px 10px; }

.charthead {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 8px;
}

.charthead h2 {
  font-size: 18px;
  margin: 0;
}

.legend {
  display: flex;
  gap: 14px;
  font-size: 12px;
  color: var(--muted);
  flex-wrap: wrap;
}

.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 999px;
  margin-right: 5px;
}

.dot.buy { background: var(--buy); }
.dot.rent { background: var(--rent); }

svg {
  width: 100%;
  height: auto;
  display: block;
}

.tablecard {
  padding: 16px;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 640px;
}

th,
td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  text-align: right;
}

th:first-child,
td:first-child { text-align: left; }

th {
  color: var(--muted);
  font-weight: 600;
}

.note {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  padding: 0 2px;
  margin: 0;
}

.smallbtn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 9px;
  padding: 8px 10px;
  cursor: pointer;
}

.futureOnly { display: none; }

body.future .futureOnly { display: grid; }
body.future .historicalOnly { display: none; }

@media (max-width: 900px) {
  .grid { grid-template-columns: 1fr; }
  .summary { grid-template-columns: 1fr; }
  .panel { order: 1; }
  .results { order: 2; }
}
