:root {
  --surface: #fcfcfb;
  --page: #f4f3ef;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --hairline: #e1e0d9;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --accent-ink: #1c5cab;
  --accent-wash: rgba(42, 120, 214, 0.09);
  --warn: #8a5a00;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 6px 20px rgba(0, 0, 0, 0.07);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.4 var(--font); color: var(--ink); background: var(--page); overflow: hidden; }
#map { position: absolute; inset: 0; }
button { font: inherit; }

.card {
  position: absolute; z-index: 10;
  background: rgba(252, 252, 251, 0.96);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
}

/* ---------- controls ---------- */
.controls { top: 16px; left: 16px; width: 380px; max-width: calc(100% - 32px); padding: 12px 14px 12px; }
.brand { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 6px; font-size: 13px; font-weight: 700; letter-spacing: -0.01em; color: var(--ink); text-decoration: none; }
.brand:hover { color: var(--accent-ink); }
.brand svg { width: 15px; height: 15px; flex: none; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; font-size: 12px; color: var(--muted); min-height: 18px; }
.crumbs button { border: 0; background: none; padding: 1px 4px; margin: 0 -2px; border-radius: 4px; color: var(--accent-ink); cursor: pointer; font-size: 12px; }
.crumbs button:hover { background: var(--accent-wash); }
.crumbs .sep { color: #c9c7bf; padding: 0 2px; }
.place { margin: 2px 0 10px; font-size: 20px; line-height: 1.2; font-weight: 650; letter-spacing: -0.01em; }
.place small { font-size: 12px; font-weight: 450; color: var(--muted); margin-left: 6px; letter-spacing: 0; }

.group { padding-top: 10px; border-top: 1px solid var(--hairline); margin-top: 2px; }
.group + .group { margin-top: 10px; }
.group-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; margin-bottom: 7px; display: flex; justify-content: space-between; }
.period-label { text-transform: none; letter-spacing: 0; color: var(--ink); font-weight: 600; font-size: 12px; }

.return-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.plus { color: var(--muted); font-weight: 600; }
.rent-row { margin-top: 6px; }
.rent-label { font-size: 13px; color: var(--ink-2); margin-right: 2px; }
.seg-wide { display: flex; width: 100%; box-sizing: border-box; }
.seg-wide button { flex: 1; }
.rent-row[hidden] { display: none; }
.method { margin-top: 8px; font-size: 12px; color: var(--ink-2); }
.method summary { cursor: pointer; color: var(--accent-ink); font-weight: 600; list-style: none; width: fit-content; }
.method summary::-webkit-details-marker { display: none; }
.method summary::before { content: '\25B8\00A0'; }
.method[open] summary::before { content: '\25BE\00A0'; }
.method dl { margin: 4px 0 0; max-height: 42vh; overflow: auto; }
.method dt { font-weight: 650; color: var(--ink); margin-top: 6px; }
.method dd { margin: 1px 0 0; line-height: 1.4; }
.method p { margin: 6px 0 0; color: var(--muted); }
.chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 10px 5px 8px; border-radius: 8px;
  border: 1px solid var(--border); background: #fff; color: var(--ink-2); cursor: pointer; font-size: 13px;
}
.chip .box { width: 15px; height: 15px; border-radius: 4px; border: 1.5px solid #b9b7ae; display: inline-grid; place-items: center; }
.chip[aria-pressed="true"] { color: var(--ink); font-weight: 600; border-color: rgba(42, 120, 214, .45); background: var(--accent-wash); }
.chip[aria-pressed="true"] .box { background: var(--accent); border-color: var(--accent); }
.chip[aria-pressed="true"] .box::after { content: ''; width: 8px; height: 4px; border: 2px solid #fff; border-top: 0; border-right: 0; transform: translateY(-1px) rotate(-45deg); }
.chip:disabled { cursor: not-allowed; opacity: .55; }

.seg { display: inline-flex; padding: 3px; gap: 2px; background: #eceae4; border-radius: 9px; }
.seg button { border: 0; background: none; font-size: 13px; color: var(--ink-2); padding: 4px 9px; border-radius: 7px; cursor: pointer; white-space: nowrap; }
.seg button:hover:not(:disabled) { color: var(--ink); }
.seg button[aria-checked="true"] { background: #fff; color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.seg button:disabled { opacity: .45; cursor: not-allowed; }
.formula { margin: 8px 0 0; font-size: 12px; color: var(--ink-2); }
.formula b { color: var(--ink); }

/* dual-thumb year range */
.range { position: relative; height: 22px; }
.range-track { position: absolute; left: 8px; right: 8px; top: 9px; height: 4px; border-radius: 2px; background: #e4e2db; }
.range-fill { position: absolute; top: 0; bottom: 0; background: var(--accent); border-radius: 2px; }
.range input { position: absolute; inset: 0; width: 100%; margin: 0; background: none; pointer-events: none; -webkit-appearance: none; appearance: none; height: 22px; }
.range input::-webkit-slider-thumb { -webkit-appearance: none; pointer-events: auto; width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 2px solid var(--accent); box-shadow: 0 1px 3px rgba(0,0,0,.2); cursor: grab; }
.range input::-moz-range-thumb { pointer-events: auto; width: 13px; height: 13px; border-radius: 50%; background: #fff; border: 2px solid var(--accent); cursor: grab; }
.range input::-webkit-slider-runnable-track { background: none; }
.range input:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--accent); outline-offset: 2px; }
.range-ticks { display: flex; justify-content: space-between; padding: 0 3px; font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; margin-top: 1px; }
.presets { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.presets button { border: 1px solid var(--border); background: #fff; border-radius: 999px; padding: 2px 10px; font-size: 12px; color: var(--ink-2); cursor: pointer; }
.presets button:hover { color: var(--ink); border-color: rgba(11,11,11,.25); }
.presets button[aria-pressed="true"] { background: var(--accent-wash); border-color: rgba(42,120,214,.45); color: var(--accent-ink); font-weight: 600; }

.tool { display: flex; gap: 7px; align-items: center; font-size: 12px; color: var(--ink-2); margin-top: 10px; cursor: pointer; }

/* ---------- legend ---------- */
.legend { left: 16px; bottom: 16px; width: 280px; padding: 10px 12px 9px; }
.legend-title { font-size: 12px; font-weight: 600; margin-bottom: 6px; }
.legend-bar { height: 10px; border-radius: 3px; position: relative; }
.legend-zero { position: absolute; top: -2px; bottom: -2px; width: 1.5px; background: var(--ink); opacity: .55; }
.legend-ticks { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 4px; font-variant-numeric: tabular-nums; }
.legend-keys { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 7px; padding-top: 7px; border-top: 1px solid var(--hairline); font-size: 11px; color: var(--ink-2); }
.legend-keys span { display: inline-flex; gap: 5px; align-items: center; }
.legend-scale { margin-top: 7px; font-size: 11px; color: var(--muted); display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.legend-scale button { border: 1px solid var(--border); background: #fff; border-radius: 999px; padding: 1px 8px; font-size: 11px; color: var(--ink-2); cursor: pointer; }
.legend-scale button[aria-pressed="true"] { background: var(--accent-wash); border-color: rgba(42,120,214,.45); color: var(--accent-ink); font-weight: 600; }
.key { width: 14px; height: 10px; border-radius: 2px; display: inline-block; box-shadow: inset 0 0 0 1px rgba(0,0,0,.1); }
.key-hatch { background: repeating-linear-gradient(135deg, #969489 0 1.5px, #f0efec 1.5px 5px); }
.key-light { background: #6da7ec; opacity: .5; }

/* ---------- panel ---------- */
.panel { top: 16px; right: 16px; width: 300px; max-height: calc(100% - 32px); overflow: auto; padding: 14px 14px 12px; }
.kicker { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; }
.panel h2 { margin: 2px 0 10px; font-size: 18px; line-height: 1.25; font-weight: 650; }
.panel h3 { font-size: 12px; font-weight: 600; color: var(--ink-2); margin: 12px 0 6px; padding-top: 12px; border-top: 1px solid var(--hairline); }
.headline { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.big { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.big-label { font-size: 12px; color: var(--ink-2); }
.sum { margin: -4px 0 10px; font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.parts { margin: 0 0 8px; display: grid; gap: 8px; }
.part { display: grid; grid-template-columns: 1fr auto; gap: 1px 8px; font-size: 13px; }
.part dt { color: var(--ink-2); }
.part dd { margin: 0; font-weight: 650; font-variant-numeric: tabular-nums; }
.basis { grid-column: 1 / -1; font-size: 11px; color: var(--muted); }
.basis-inherited, .basis-mixed { color: var(--warn); }
.basis-model { color: #6250d6; }
.basis-none { color: #a82b2b; }
.warn { font-size: 12px; color: var(--warn); background: #fdf5e4; border-radius: 6px; padding: 6px 8px; margin: 6px 0; }
.note { font-size: 11px; color: var(--ink-2); background: #f1f0fb; border-radius: 6px; padding: 6px 8px; margin: 6px 0; }
.levels { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; }
.levels div { background: #f4f3ef; border-radius: 8px; padding: 6px 8px; display: grid; }
.levels span { font-size: 11px; color: var(--muted); }
.levels b { font-size: 13px; font-variant-numeric: tabular-nums; }
.levels small { font-size: 10px; color: var(--muted); }
.chart { margin: 10px 0 0; }
.chart figcaption { font-size: 11px; color: var(--ink-2); margin-bottom: 3px; }
.chart .axis { stroke: #c3c2b7; stroke-width: 1; }
.chart-axis { display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); }
.chart-empty { font-size: 11px; color: var(--muted); margin-top: 8px; }
.sources { margin-top: 10px; font-size: 12px; }
.sources summary { cursor: pointer; color: var(--accent-ink); }
.sources ul { padding-left: 0; list-style: none; margin: 6px 0 0; display: grid; gap: 5px; }
.sources a { color: var(--ink-2); }
.kind { font-size: 9.5px; text-transform: uppercase; letter-spacing: .05em; padding: 1px 5px; border-radius: 4px; font-weight: 700; }
.kind-official { background: #e3f1e3; color: #006300; }
.kind-industry { background: #fdf0dc; color: #8a5a00; }
.kind-research { background: #e6eefb; color: #1f4f9c; }
.intro { color: var(--ink-2); font-size: 13px; }
.rank { list-style: none; margin: 0; padding: 0; }
.rank button { display: grid; grid-template-columns: 10px 1fr auto; align-items: center; gap: 8px; width: calc(100% + 12px); margin: 0 -6px; border: 0; background: none; padding: 5px 6px; border-radius: 6px; font-size: 13px; text-align: left; cursor: pointer; }
.rank button:hover { background: var(--accent-wash); }
.rank .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank .cov { font-size: 10px; color: var(--warn); background: #fdf5e4; border-radius: 4px; padding: 0 4px; margin-left: 4px; }
.rank .v { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; font-size: 12px; }
.rank .split { display: block; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.more { font-size: 12px; color: var(--muted); margin: 6px 0 0; }
.caveat { font-size: 11px; color: var(--muted); margin: 10px 0 0; padding-top: 8px; border-top: 1px solid var(--hairline); }

/* ---------- tooltip ---------- */
.tooltip { position: fixed; z-index: 30; pointer-events: none; display: none; background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); padding: 9px 11px; font-size: 12px; min-width: 190px; max-width: 280px; }
.tt-title { font-size: 13px; font-weight: 650; }
.tt-sub { color: var(--muted); font-size: 11px; margin-bottom: 5px; }
.tt-total { display: flex; align-items: center; gap: 6px; font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tt-total small { font-size: 11px; font-weight: 450; color: var(--ink-2); }
.tt-parts { color: var(--ink-2); margin-top: 3px; display: grid; gap: 1px; }
.tt-parts b { color: var(--ink); }
.tt-flag { margin-top: 5px; font-size: 11px; color: var(--warn); }
.tt-hint { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--hairline); color: var(--accent-ink); font-size: 11px; }

.loading { position: absolute; left: 50%; top: 16px; transform: translateX(-50%); z-index: 20; background: var(--ink); color: #fff; font-size: 12px; padding: 5px 12px; border-radius: 999px; opacity: 0; transition: opacity .2s; pointer-events: none; }
.loading.on { opacity: .85; }
.error { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; color: var(--ink-2); z-index: 40; background: var(--page); }

@media (max-width: 820px) {
  .panel { display: none; }
  .controls { width: auto; right: 16px; }
  .legend { width: 220px; }
}
@media (max-width: 480px) {
  .controls { top: 8px; left: 8px; right: 8px; padding: 10px; }
  .seg button { padding: 4px 6px; font-size: 12px; }
  .legend { left: 8px; bottom: 8px; width: 190px; }
  .legend-keys { display: none; }
}

/* ---------- embedded in a page (iframe) on a small screen: keep the map visible ---------- */
@media (max-width: 700px) {
  .embedded .controls .group + .group, .embedded .formula, .embedded .method, .embedded .tool,
  .embedded .legend-keys, .embedded .legend-scale { display: none; }
  .embedded .controls { padding: 8px 10px; }
  .embedded .place { font-size: 16px; margin-bottom: 6px; }
}
