/* Theme: follows the system (prefers-color-scheme) unless the visitor picked one with the toggle -> data-theme on
   <html>, set by an inline <head> script before first paint (no flash). color-scheme makes native controls
   (checkboxes, selects, scrollbars) follow the theme too. */
:root {
  --bg:#f6f7f9; --panel:#fff; --ink:#1c2230; --muted:#6b7280; --line:#e5e7eb;
  --ac:#2e9e5b; --dc:#2f6fd0; --hpc:#7b3fe4; --live:#22c55e; --stale:#9aa3af;
  --accent:#0ea5a4; --warn:#e0532f;
  --accent-ink:#0f766e;   /* accent for TEXT: #0ea5a4 is only 3.0:1 on white, this is 5.5:1 (D43) */
  --map-icon-filter:none;
  color-scheme: light;
}
:root[data-theme="dark"] { --bg:#10141c; --panel:#171c26; --ink:#e7ebf2; --muted:#9aa3af; --line:#262d3a; --accent-ink:#0ea5a4; --map-icon-filter:invert(1); color-scheme: dark; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg:#10141c; --panel:#171c26; --ink:#e7ebf2; --muted:#9aa3af; --line:#262d3a; --accent-ink:#0ea5a4; --map-icon-filter:invert(1); color-scheme: dark; }
}
* { box-sizing:border-box; }
html,body { height:100%; margin:0; }
body { font:14px/1.45 system-ui,-apple-system,Segoe UI,Roboto,sans-serif; color:var(--ink); background:var(--bg);
  display:flex; flex-direction:column; }

/* header */
#top { display:flex; align-items:center; justify-content:space-between; gap:16px; flex-wrap:wrap;
  padding:10px 16px; background:var(--panel); border-bottom:1px solid var(--line); }
.brand { display:flex; align-items:center; gap:12px; }
.logo { font-size:26px; }
#top h1 { font-size:18px; margin:0; font-weight:700; }
#top .tag { font-size:11px; background:var(--accent); color:#fff; padding:1px 6px; border-radius:6px; vertical-align:middle; }
#top .sub { margin:1px 0 0; color:var(--muted); font-size:12px; }
.stats { display:flex; gap:18px; flex-wrap:wrap; }
.stat { text-align:center; }
.stat b { display:block; font-size:18px; font-weight:700; }
.stat span { font-size:11px; color:var(--muted); text-transform:uppercase; letter-spacing:.03em; }
.stat.warn b { color:var(--warn); }
.top-right { display:flex; flex-direction:column; align-items:flex-end; gap:6px; }
.langsw { font-size:12px; color:var(--muted); display:flex; align-items:center; gap:5px; line-height:1; }
.langsw a { color:var(--accent-ink); text-decoration:none; }
.langsw a:hover { text-decoration:underline; }
.langsw .on { font-weight:700; color:var(--ink); }
.langsw .sep { color:var(--line); }
.themesw { background:none; border:1px solid var(--line); color:var(--muted); border-radius:6px; padding:3px; margin-left:8px;
  cursor:pointer; line-height:0; }
.themesw:hover, .themesw:focus-visible { color:var(--accent-ink); border-color:var(--accent); outline:none; }
.themesw svg { width:14px; height:14px; display:block; }

/* layout */
main { flex:1; display:flex; min-height:0; }
#map { flex:1; min-width:0; }
#side { width:370px; background:var(--panel); border-left:1px solid var(--line); display:flex; flex-direction:column;
  overflow:hidden; }

/* search */
.search { display:flex; gap:6px; padding:10px; border-bottom:1px solid var(--line); }
.search input { flex:1; padding:8px 10px; border:1px solid var(--line); border-radius:8px; background:var(--bg); color:var(--ink); }
.search button { border:1px solid var(--line); background:var(--bg); border-radius:8px; padding:0 10px; cursor:pointer; }

/* filters */
.filters { padding:10px; border-bottom:1px solid var(--line); }
.frow { display:flex; align-items:center; gap:10px; margin:6px 0; flex-wrap:wrap; }
.flabel { font-size:12px; color:var(--muted); width:42px; }
.chips { display:flex; gap:6px; }
.chip { border:1px solid var(--line); background:var(--bg); color:var(--muted); border-radius:20px; padding:4px 11px;
  cursor:pointer; font-size:12px; font-weight:600; }
.chip.on { background:var(--accent); border-color:var(--accent); color:#fff; }
.tog { font-size:13px; display:flex; align-items:center; gap:5px; cursor:pointer; }
#f-op { width:100%; padding:7px 8px; border:1px solid var(--line); border-radius:8px; background:var(--bg); color:var(--ink); }
.muted { color:var(--muted); }
#count { margin:8px 0 0; font-size:12px; }

/* panel */
#panel { flex:1; overflow-y:auto; padding:12px; }
#panel h2 { font-size:15px; margin:2px 0 8px; }
#panel h3 { font-size:13px; margin:14px 0 6px; }
.diff { margin:0 0 6px; padding-left:18px; }
.diff li { margin:4px 0; }
.diff b { color:var(--accent-ink); }

/* operator league */
table.lt { width:100%; border-collapse:collapse; font-size:12px; }
table.lt th,table.lt td { text-align:left; padding:4px 6px; border-bottom:1px solid var(--line); }
table.lt td.num,table.lt th.num { text-align:right; font-variant-numeric:tabular-nums; }
.bad { color:var(--warn); font-weight:600; }
.good { color:var(--ac); font-weight:600; }

/* detail */
#detail .back { background:none; border:none; color:var(--accent-ink); cursor:pointer; padding:0; font-size:13px; }
.site-h { font-size:16px; font-weight:700; margin:6px 0 0; }
.op { font-size:13px; margin:3px 0 2px; }
.op a { color:var(--accent-ink); text-decoration:none; }
.op a:hover { text-decoration:underline; }
.evse { border:1px solid var(--line); border-radius:10px; padding:9px 10px; margin:9px 0; }
.evse-h { display:flex; justify-content:space-between; align-items:center; gap:8px; }
.pw { font-weight:700; }
.badge { font-size:11px; font-weight:700; padding:2px 8px; border-radius:20px; }
.b-free { background:rgba(34,197,94,.15); color:var(--ac); }
.b-busy { background:rgba(224,83,47,.15); color:var(--warn); }
.b-unk  { background:rgba(154,163,175,.2); color:var(--muted); }
.b-live { background:var(--live); color:#04210f; }
.b-stale{ background:rgba(154,163,175,.25); color:var(--muted); }
.kv { font-size:12px; color:var(--muted); margin-top:3px; }
.spark { margin-top:6px; }
.spark svg { display:block; }
.histbtn { background:none;border:1px dashed var(--line);border-radius:7px;color:var(--muted);cursor:pointer;font-size:11px;padding:3px 7px;margin-top:6px;}

/* markers */
.mk { width:15px; height:15px; border-radius:50%; border:2px solid #fff; box-shadow:0 0 0 1px rgba(0,0,0,.25);
  display:block; }
.mk-ac  { background:var(--ac); }  .mk-dc { background:var(--dc); }  .mk-hpc{ background:var(--hpc); }
.mk-un  { background:var(--stale); }
.mk-live{ border-color:var(--live); }
.mk-stale{ opacity:.55; border-style:dotted; }

/* legend */
.legend { display:flex; gap:12px; flex-wrap:wrap; padding:8px 12px; border-top:1px solid var(--line); font-size:11px; color:var(--muted); }
.legend i.lg { display:inline-block; width:11px; height:11px; border-radius:50%; margin-right:3px; vertical-align:-1px; }
.lg.ac{background:var(--ac)} .lg.dc{background:var(--dc)} .lg.hpc{background:var(--hpc)}
.lg.ring{background:transparent;border:2px solid var(--live)} .lg.stale{background:var(--stale);opacity:.55;border:2px dotted #fff}
.src { font-size:10px; color:var(--muted); padding:0 12px 10px; margin:6px 0 0; }

/* maplibre tweaks */
#map { background:var(--bg); }
/* Map popups take the theme's colours: MapLibre's default is a WHITE box, which made the inherited light text of the
   dark theme unreadable (owner report 2026-10-13). */
.maplibregl-popup.tip .maplibregl-popup-content { font:12px/1.3 system-ui,sans-serif; padding:5px 8px; border-radius:6px;
  background:var(--panel); color:var(--ink); border:1px solid var(--line); box-shadow:0 2px 8px rgba(0,0,0,.28); }
.maplibregl-popup.tip .maplibregl-popup-close-button { color:var(--muted); }
.maplibregl-popup.tip .maplibregl-popup-tip { display:none; }
/* MapLibre's own controls follow the theme too (white boxes looked out of place on the dark basemap, D44) */
.maplibregl-ctrl-group { background:var(--panel); }
.maplibregl-ctrl-group button+button { border-top-color:var(--line); }
.maplibregl-ctrl-group .maplibregl-ctrl-icon, .maplibregl-ctrl-attrib-button { filter:var(--map-icon-filter); }
.maplibregl-ctrl-attrib.maplibregl-compact { background:var(--panel); color:var(--ink); }
.maplibregl-ctrl-attrib a { color:var(--muted); }
input[type=range]{ flex:1; accent-color:var(--accent); }
.flabel{ white-space:nowrap; }

/* data.evse.world (no map) */
body.data{ display:block; overflow:auto; }
.dpage{ display:block; max-width:1100px; margin:0 auto; padding:16px; }   /* override base main{display:flex} */
.dpage section{ margin:18px 0; }
.dpage h2{ font-size:16px; margin:18px 0 8px; }
.dpage a{ color:var(--accent-ink); text-decoration:none; }
.dpage a:hover{ text-decoration:underline; }
.cols{ display:flex; gap:18px; flex-wrap:wrap; }
.cols section{ flex:1; min-width:280px; margin:0; }
.tiles{ display:grid; grid-template-columns:repeat(auto-fill,minmax(220px,1fr)); gap:12px; }
.tile{ background:var(--panel); border:1px solid var(--line); border-radius:10px; padding:12px; }
.tile h3{ margin:0 0 6px; font-size:13px; }
.tile b{ font-variant-numeric:tabular-nums; }
.dpage th[data-k]{ cursor:pointer; user-select:none; }
.csw{ font-size:12px; margin:4px 0 0; color:var(--muted); }   /* data hub country switch (D47) */
.csw a{ color:var(--accent-ink); text-decoration:none; } .csw a:hover{ text-decoration:underline; }
.csw .on{ font-weight:700; color:var(--ink); } .csw .sep{ color:var(--line); margin:0 6px; }
table.lt tr.sel td{ background:var(--panel); }
#top .sub a{ color:var(--accent-ink); text-decoration:none; }

/* low-zoom variant switcher */
.varsw{ padding:8px 10px; border-bottom:1px solid var(--line); font-size:12px; line-height:1.7; }
.varsw a{ color:var(--accent-ink); text-decoration:none; margin-right:4px; }
.varsw a:hover{ text-decoration:underline; }
.varsw .on{ font-weight:700; background:var(--accent); color:#fff; padding:1px 7px; border-radius:5px; margin-right:4px; }
.varsw .muted{ display:block; margin-top:2px; }

/* per-operator page (operator.html / operator.js) */
.op-id{ margin-bottom:4px; }
.op-id .back{ display:inline-block; color:var(--accent-ink); text-decoration:none; font-size:13px; margin-bottom:6px; }
.op-id .back:hover{ text-decoration:underline; }
.op-id .site-h{ margin:2px 0; }
.op-id .badge{ vertical-align:middle; margin-left:6px; font-weight:700; }
.dpage .stats{ gap:22px; margin:8px 0; }
.dpage .stats.big{ gap:30px; }
.dpage .stats.big .stat b{ font-size:26px; }
.rel-explain{ margin:8px 0 0; max-width:72ch; }
/* (i) info tooltip in section headers (replaces run-on muted subtitles) */
.i{ display:inline-flex; align-items:center; justify-content:center; width:15px; height:15px; margin-left:6px;
  border-radius:50%; border:1px solid var(--muted); color:var(--muted); font:italic 600 10px/1 Georgia,serif;
  cursor:help; vertical-align:2px; position:relative; }
.i:hover, .i:focus{ color:var(--accent-ink); border-color:var(--accent); outline:none; }
.i:hover::after, .i:focus::after{ content:attr(data-tip); position:absolute; left:0; top:150%; transform:translateX(-45%);
  background:var(--ink); color:var(--bg); padding:6px 9px; border-radius:6px; font:400 12px/1.35 system-ui,sans-serif;
  white-space:normal; width:max-content; max-width:260px; z-index:20; box-shadow:0 2px 10px rgba(0,0,0,.25); pointer-events:none; }

@media (max-width:760px){
  main{flex-direction:column;} #map{height:55vh;flex:none;} #side{width:auto;border-left:none;border-top:1px solid var(--line);}
  .stats{gap:12px;}
  .dpage .stats,.dpage .stats.big{ gap:16px; }
}
