  :root {
    --bg: #f6f5f1; --surface: #ffffff; --ink: #1d1f22; --muted: #646a73; --line: #e3e1da;
    --accent: #1f5f8b; --accent-soft: #e5eef5; --good: #2e7d4f; --warn: #b26a00; --bad: #b3261e;
    --bar: #1f5f8b; --bar-2: #8fb3cf; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 14px rgba(0,0,0,.04);
  }
  @media (prefers-color-scheme: dark) {
    :root {
      --bg: #141618; --surface: #1c1f22; --ink: #e8e6e1; --muted: #9aa0a8; --line: #2c3035;
      --accent: #7db4dd; --accent-soft: #1f2d38; --good: #6cc391; --warn: #e3a43c; --bad: #ef7b72;
      --bar: #7db4dd; --bar-2: #3c5a72; --shadow: none;
    }
  }
  * { box-sizing: border-box; }
  body { margin: 0; background: var(--bg); color: var(--ink);
         font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
  .wrap { max-width: 1120px; margin: 0 auto; padding: 24px 16px 48px; }
  header h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.01em; }
  header p { margin: 0 0 18px; color: var(--muted); }

  form.search { display: grid; grid-template-columns: 2fr 1fr auto auto; gap: 10px;
                background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
                padding: 12px; box-shadow: var(--shadow); }
  form.search label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 4px; }
  input, select { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line);
                  border-radius: 8px; padding: 9px 10px; min-width: 0; }
  input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
  button { font: inherit; font-weight: 600; border: 0; border-radius: 8px; padding: 10px 18px; cursor: pointer;
           background: var(--accent); color: #fff; align-self: end; }
  @media (prefers-color-scheme: dark) { button { color: #0e1a24; } }
  button:disabled { opacity: .55; cursor: progress; }
  button.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); }
  .examples { margin: 10px 2px 0; font-size: 13px; color: var(--muted); }
  .examples a { color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }

  .status { margin: 18px 0; padding: 12px 14px; border-radius: 10px; background: var(--accent-soft); }
  .status.error { background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad); }
  .spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid currentColor;
             border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite;
             vertical-align: -2px; margin-right: 8px; }
  @keyframes spin { to { transform: rotate(360deg); } }

  .grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; margin-top: 18px; }
  .card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px;
          box-shadow: var(--shadow); min-width: 0; }
  .card h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
             margin: 0 0 12px; font-weight: 600; }
  .span-12 { grid-column: span 12; } .span-7 { grid-column: span 7; } .span-5 { grid-column: span 5; }
  .span-6 { grid-column: span 6; }
  @media (max-width: 860px) {
    form.search { grid-template-columns: 1fr 1fr; }
    form.search label.addr { grid-column: span 2; }
    .span-7, .span-5, .span-6 { grid-column: span 12; }
  }

  .hero { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
  .hero .title { flex: 1 1 320px; }
  .hero .title h3 { margin: 0; font-size: 20px; }
  .hero .title .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
  .facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px 16px; margin-top: 14px; }
  .fact .k { font-size: 12px; color: var(--muted); } .fact .v { font-weight: 600; }
  .epc { display: flex; align-items: center; gap: 8px; }
  .badge { width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; font-weight: 800;
           font-size: 22px; color: #fff; }
  .epc .arrow { color: var(--muted); }
  .badge.sm { width: 30px; height: 30px; font-size: 15px; border-radius: 7px; }
  .A { background: #008054; } .B { background: #19b459; } .C { background: #8dce46; } .D { background: #ffd500; color: #222; }
  .E { background: #fcaa65; color: #222; } .F { background: #ef8023; } .G { background: #e9153b; }

  #map { height: 420px; border-radius: 10px; border: 1px solid var(--line); }
  .legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 8px; }
  .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }

  .stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-bottom: 14px; }
  .stat { background: var(--bg); border-radius: 10px; padding: 10px 12px; }
  .stat .k { font-size: 12px; color: var(--muted); } .stat .v { font-size: 18px; font-weight: 700; }
  .muted { color: var(--muted); } .small { font-size: 12px; }
  .estimate { border: 1px solid var(--accent); background: var(--accent-soft); border-radius: 10px;
              padding: 12px 14px; margin-bottom: 14px; display: flex; gap: 18px; flex-wrap: wrap; align-items: baseline; }
  .estimate .big { font-size: 24px; font-weight: 800; }
  .estimate .rng { font-weight: 600; }

  .bars { display: flex; flex-direction: column; gap: 6px; }
  .bar-row { display: grid; grid-template-columns: 150px 1fr 56px; gap: 8px; align-items: center; font-size: 13px; }
  .bar-row .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .bar-track { height: 10px; background: var(--bg); border-radius: 5px; overflow: hidden; }
  .bar-fill { height: 100%; background: var(--bar); border-radius: 5px; }
  .bar-row .n { text-align: right; font-variant-numeric: tabular-nums; }

  .tbl-wrap { overflow-x: auto; max-height: 420px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; }
  table { border-collapse: collapse; width: 100%; font-size: 13px; }
  th, td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
  th { position: sticky; top: 0; background: var(--surface); font-weight: 600; color: var(--muted); cursor: pointer; user-select: none; }
  th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
  th .ind { opacity: .6; margin-left: 3px; }
  tr:hover td { background: var(--accent-soft); }
  .filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
  .chip { font-size: 12px; padding: 4px 10px; border-radius: 99px; border: 1px solid var(--line); background: transparent;
          color: var(--ink); font-weight: 500; }
  .chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }

  ul.list { list-style: none; margin: 0; padding: 0; }
  ul.list li { padding: 8px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 10px; }
  ul.list li:last-child { border-bottom: 0; }
  .narrative { white-space: pre-wrap; }
  .of { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px;
        white-space: nowrap; color: #fff; background: #8a8f98; }
  .of.g1 { background: #00703c; } .of.g2 { background: #2e8b57; } .of.g3 { background: #1d70b8; }
  .of.g4 { background: #c27c0e; } .of.g5 { background: #b3261e; }
  .areas { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
  .areas .of { font-weight: 600; font-size: 10.5px; }
  .timeline { display: flex; flex-wrap: wrap; align-items: center; gap: 3px; margin-top: 5px; font-size: 11px; }
  .timeline .step { display: inline-flex; flex-direction: column; align-items: center; }
  .timeline .yr { color: var(--muted); font-size: 10px; }
  .timeline .arrow { color: var(--muted); }
  .timeline .of { font-size: 10.5px; font-weight: 600; max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
  footer { margin-top: 28px; font-size: 12px; color: var(--muted); }
  footer a { color: inherit; }
  .hidden { display: none !important; }

  /* tabs */
  .tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 0 0 18px; }
  .tab { background: transparent; color: var(--muted); border: 0; border-bottom: 2px solid transparent;
         border-radius: 0; padding: 8px 14px; font-weight: 600; margin-bottom: -1px; }
  .tab.on { color: var(--ink); border-bottom-color: var(--accent); }
  .tab:hover { color: var(--ink); }

  /* street scores */
  .span-8 { grid-column: span 8; } .span-4 { grid-column: span 4; }
  @media (max-width: 860px) { .span-8, .span-4 { grid-column: span 12; } }
  .st-controls { display: flex; gap: 10px 16px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; font-size: 13px; }
  .st-controls label { display: flex; gap: 6px; align-items: center; color: var(--muted); }
  .st-controls input[type=search] { min-width: 200px; }
  #street-map { height: 600px; border-radius: 10px; border: 1px solid var(--line); }
  #street-map .leaflet-tile-pane { filter: grayscale(1) opacity(.55); }
  .swatch { display: inline-block; width: 22px; height: 5px; border-radius: 3px; margin-right: 5px; vertical-align: 2px; }
  .swatch.dash { background: repeating-linear-gradient(90deg, #8a8f96 0 5px, transparent 5px 8px) !important; }
  .score-big { font-size: 34px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
  .score-sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
  ol.rank { margin: 0; padding: 0; list-style: none; counter-reset: r; }
  ol.rank li { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line);
               font-size: 14px; cursor: pointer; }
  ol.rank li:hover { color: var(--accent); }
  ol.rank .num { font-weight: 700; font-variant-numeric: tabular-nums; }
  .street-link { display: inline-block; margin-top: 10px; font-weight: 600; color: var(--accent); text-decoration: none; }
  .street-link:hover { text-decoration: underline; }
  dl.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 12px 0 0; font-size: 13px; }
  dl.kv dt { color: var(--muted); } dl.kv dd { margin: 0; }

  .credits { margin: 28px auto 0; max-width: 980px; padding: 0 16px 24px; font-size: 12px; line-height: 1.5; color: var(--muted); } .credits a { color: inherit; }
.tile-logo img { display: block; }
