:root {
  --bg: #f4f6f8; --surface: #ffffff; --surface-2: #f1f4f7; --fg: #0f172a; --muted: #64748b; --line: #e3e8ee;
  --accent: #0e9f6e; --accent-ink: #ffffff; --accent-soft: #e3f6ee;
  --free: #16a34a; --busy: #e11d48; --broken: #94a3b8; --unknown: #94a3b8; --extra: #64748b;
  --shadow: 0 8px 28px rgba(15, 23, 42, .14), 0 1px 3px rgba(15, 23, 42, .08);
  --radius: 18px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117; --surface: #161b22; --surface-2: #1f2630; --fg: #e6edf3; --muted: #8b98a8; --line: #2a323d;
    --accent: #34d399; --accent-ink: #052e1c; --accent-soft: #10392b;
    --free: #22c55e; --busy: #fb7185; --broken: #64748b; --unknown: #64748b; --extra: #8b98a8;
    --shadow: 0 8px 28px rgba(0, 0, 0, .5), 0 1px 3px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body { font: 15px/1.45 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--fg);
  -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
button { font: inherit; color: inherit; }
svg { width: 20px; height: 20px; fill: currentColor; flex: none; }
h1 { font-size: 18px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 21px; margin: 0; letter-spacing: -.02em; line-height: 1.25; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 0 10px; font-weight: 600; }
.muted { color: var(--muted); } .small { font-size: 13px; }

#map { position: fixed; inset: 0; background: var(--surface-2); }
.leaflet-container { font: inherit; }
.leaflet-control-attribution { font-size: 10px; background: color-mix(in srgb, var(--surface) 80%, transparent) !important; color: var(--muted); }
.leaflet-control-attribution a { color: var(--muted); }
.leaflet-control-zoom { display: none; }

/* Yläpalkki */
.top { position: fixed; top: 0; left: 0; right: 0; z-index: 1002; padding: calc(env(safe-area-inset-top) + 12px) 12px 0; pointer-events: none; }
.top > * { pointer-events: auto; }
.search { display: flex; align-items: center; gap: 10px; background: var(--surface); border-radius: 999px; padding: 0 8px 0 16px; height: 50px;
  box-shadow: var(--shadow); max-width: 560px; }
.search svg { color: var(--muted); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--fg); font: inherit; font-size: 16px; height: 100%; }
.search input::-webkit-search-cancel-button { display: none; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 10px 2px 12px; scrollbar-width: none; max-width: 560px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 7px 13px; font-size: 13.5px; font-weight: 500; cursor: pointer; box-shadow: 0 1px 3px rgba(15, 23, 42, .08); transition: background .15s, color .15s; }
.chip[aria-pressed="true"] { background: var(--fg); color: var(--surface); border-color: var(--fg); }
.icon-btn { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; border: 0; background: transparent; cursor: pointer; color: var(--muted); }
.icon-btn:hover { background: var(--surface-2); }

.progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 1100; overflow: hidden; }
.progress span { position: absolute; inset: 0; width: 40%; background: var(--accent); animation: slide 1.1s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(260%); } }

.fab { position: fixed; z-index: 1000; right: 14px; bottom: 50vh; width: 50px; height: 50px; border-radius: 50%; border: 0; background: var(--surface); color: var(--accent);
  box-shadow: var(--shadow); display: grid; place-items: center; cursor: pointer; }
.fab svg { width: 24px; height: 24px; }

/* Merkit */
.pin { display: inline-flex; align-items: center; justify-content: center; gap: 2px; min-width: 30px; height: 30px; padding: 0 7px; border-radius: 999px;
  color: #fff; font-weight: 700; font-size: 13px; border: 2.5px solid #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, .3); transform: translate(-50%, -50%);
  white-space: nowrap; position: absolute; left: 0; top: 0; }
.pin svg { width: 12px; height: 12px; }
.pin.free { background: var(--free); } .pin.busy { background: var(--busy); } .pin.broken, .pin.unknown { background: #7c8a9c; }
.pin.extra { background: var(--extra); min-width: 14px; width: 14px; height: 14px; padding: 0; border-width: 2px; opacity: .9; }
.pin.selected { outline: 3px solid var(--accent); outline-offset: 2px; z-index: 1000; }
.marker-cluster { background: transparent; }
.cluster { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; color: var(--fg);
  background: var(--surface); box-shadow: var(--shadow); border: 3px solid var(--accent); }

/* Alapaneeli / sivupaneeli */
.sheet { position: fixed; z-index: 1001; left: 0; right: 0; bottom: 0; height: calc(100dvh - 124px - env(safe-area-inset-top)); background: var(--surface);
  border-radius: 22px 22px 0 0; box-shadow: 0 -6px 30px rgba(15, 23, 42, .16); display: flex; flex-direction: column;
  transition: height .28s cubic-bezier(.2, .8, .2, 1); padding-bottom: env(safe-area-inset-bottom); overflow: hidden; }
.sheet.dragging { transition: none; }
.sheet-grip { padding: 10px 0 6px; display: grid; place-items: center; cursor: grab; touch-action: none; flex: none; }
.sheet-grip span { width: 40px; height: 5px; border-radius: 99px; background: var(--line); }
.sheet-head { padding: 0 18px 8px; touch-action: none; }
.sheet-sub { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 2px; }
.sheet-sub p { margin: 0; }
.legend { display: flex; gap: 10px; white-space: nowrap; font-size: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 4px; }
#list-view, #detail-view { display: flex; flex-direction: column; min-height: 0; flex: 1; }
[hidden] { display: none !important; }
.list { overflow-y: auto; flex: 1; padding: 0 10px 20px; overscroll-behavior: contain; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex: none; }
.dot.free { background: var(--free); } .dot.busy { background: var(--busy); } .dot.broken, .dot.unknown { background: var(--unknown); } .dot.extra { background: var(--extra); }

.card + .card { border-top: 1px solid var(--line); }
.card { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; width: 100%; text-align: left; padding: 14px 12px; border: 0; border-radius: 0;
  background: transparent; cursor: pointer; }
.card:hover, .card:focus-visible { background: var(--surface-2); outline: none; border-radius: 12px; }
.card .name { font-weight: 600; font-size: 15.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .sub { grid-column: 1; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .meta { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.card .right { grid-row: 1 / 3; grid-column: 2; text-align: right; }
.card .price { font-weight: 700; font-size: 15px; white-space: nowrap; }
.card .price.none { font-weight: 500; color: var(--muted); font-size: 13px; }
.card .dist { color: var(--muted); font-size: 12.5px; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: var(--surface-2); }
.badge.free { background: color-mix(in srgb, var(--free) 15%, transparent); color: var(--free); }
.badge.busy { background: color-mix(in srgb, var(--busy) 14%, transparent); color: var(--busy); }
.badge.broken { color: var(--muted); }
.empty { text-align: center; padding: 30px 20px; color: var(--muted); }

/* Yksityiskohdat */
.detail-top { display: flex; align-items: center; gap: 4px; padding: 0 10px 4px; }
.detail { overflow-y: auto; flex: 1; padding: 4px 18px 28px; overscroll-behavior: contain; }
.d-head { display: flex; gap: 14px; align-items: flex-start; }
.d-head img { width: 44px; height: 44px; border-radius: 12px; object-fit: contain; background: #fff; border: 1px solid var(--line); flex: none; }
.d-addr { color: var(--muted); margin: 4px 0 0; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 0; }
.stat { background: var(--surface-2); border-radius: 14px; padding: 10px 12px; }
.stat b { display: block; font-size: 16px; letter-spacing: -.01em; white-space: nowrap; }
.stat span { font-size: 12px; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn { flex: 1; display: inline-flex; justify-content: center; align-items: center; gap: 8px; padding: 12px 16px; border-radius: 14px; font-weight: 600;
  text-decoration: none; background: var(--accent); color: var(--accent-ink); min-width: 140px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn.secondary { background: var(--surface-2); color: var(--fg); }
.btn svg { width: 18px; height: 18px; }
.evses { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.evse { border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; }
.evse-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.conn { display: flex; justify-content: space-between; gap: 12px; margin-top: 10px; align-items: flex-start; }
.conn-type { font-weight: 600; }
.conn-price { text-align: right; }
.conn-price b { display: block; font-size: 15px; }
.conn-price .small { display: block; }
.note { background: var(--surface-2); border-radius: 14px; padding: 12px 14px; font-size: 13.5px; }
.note + .note { margin-top: 8px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.source { margin-top: 18px; font-size: 12px; color: var(--muted); }

/* Työpöytä: sivupaneeli vasemmalla */
@media (min-width: 900px) {
  .top { left: 0; right: auto; width: 420px; padding: 16px 16px 0; }
  .sheet { top: 0; bottom: 0; left: 0; right: auto; width: 420px; height: auto !important; border-radius: 0; 
    padding-top: 128px; box-shadow: 4px 0 24px rgba(15, 23, 42, .1); }
  .sheet-grip { display: none; }
  .fab { bottom: 24px !important; right: 24px; }
  .leaflet-control-zoom { display: block; }
  #map { left: 420px; }
}

.tiles-dark { filter: invert(1) hue-rotate(180deg) brightness(.95) contrast(.85) saturate(.6); }
.tiles-light { filter: saturate(.75) brightness(1.03); }
