:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #16181d;
  --muted: #646b77;
  --line: #e2e5ea;
  --accent: #2481cc;
  --accent-text: #ffffff;
  --accent-soft: #e8f2fb;
  --ok: #1f8a4c;
  --warn: #a8660a;
  --radius: 10px;
  /* letter avatars */
  --c0: #e8704f; --c1: #d9a13b; --c2: #4bab63; --c3: #3aa1c9; --c4: #6d7ce0; --c5: #c261b6;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a20;
    --text: #e8eaee;
    --muted: #9aa1ad;
    --line: #272c35;
    --accent: #4ea4e6;
    --accent-text: #0f1115;
    --accent-soft: #16273a;
    --ok: #4cc27f;
    --warn: #e0a24a;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }

.top { background: var(--surface); border-bottom: 1px solid var(--line); }
.top-in { display: flex; align-items: center; justify-content: space-between; height: 52px; }
.logo { font-weight: 700; font-size: 17px; color: var(--text); }

main { padding-top: 12px; padding-bottom: 40px; }

h1 { font-size: 26px; line-height: 1.2; margin: 6px 0 8px; }
h2 { font-size: 18px; margin: 28px 0 10px; }
h2 a { color: var(--text); }
.lead { color: var(--muted); margin: 0 0 16px; }
.muted { color: var(--muted); margin: 0 0 12px; }

.crumbs { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; }
.crumbs a { color: var(--muted); }

.btn {
  display: inline-block;
  background: var(--accent);
  color: var(--accent-text);
  padding: 10px 18px;
  border-radius: var(--radius);
  font-weight: 600;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; filter: brightness(1.05); }
.btn-small { padding: 6px 12px; font-size: 14px; }
.btn-wide { display: block; text-align: center; margin: 16px 0; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.chip {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 14px;
  color: var(--text);
}
.chip b { color: var(--muted); font-weight: 500; margin-left: 4px; }

.search input {
  width: 100%;
  padding: 11px 14px;
  font-size: 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}
.search input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.search-small { max-width: 360px; margin-bottom: 8px; }
#search-results { margin-top: 10px; }
.empty { color: var(--muted); }

/* ---------- avatars */
.ava {
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--accent-soft);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 17px;
}
span.ava { background: var(--c3); }
.ava-c0 { background: var(--c0) !important; } .ava-c1 { background: var(--c1) !important; }
.ava-c2 { background: var(--c2) !important; } .ava-c3 { background: var(--c3) !important; }
.ava-c4 { background: var(--c4) !important; } .ava-c5 { background: var(--c5) !important; }
.ava-sm { width: 34px; height: 34px; font-size: 14px; }
.ava-big { width: 72px; height: 72px; font-size: 28px; }

/* ---------- full lists (city / category pages) */
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
@media (min-width: 900px) { .list { grid-template-columns: 1fr 1fr; } }
.item a {
  display: flex;
  gap: 12px;
  height: 100%;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
}
.item a:hover { text-decoration: none; border-color: var(--accent); }
.item.is-inactive { opacity: 0.6; }
.item-body { min-width: 0; display: grid; gap: 1px; align-content: start; }
.item-name { font-weight: 600; overflow-wrap: anywhere; }
.item-meta { font-size: 13px; color: var(--muted); margin: 0; }
.item-desc {
  font-size: 13px; color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

.badge-ok { color: var(--ok); font-weight: 600; }
.badge-warn { color: var(--warn); }
.more { display: inline-block; margin-top: 8px; font-weight: 600; font-size: 14px; }
.back { margin-top: 20px; }

/* ---------- compact rows + panels (home) */
.panels { display: grid; gap: 12px; grid-template-columns: 1fr; margin-top: 16px; }
@media (min-width: 640px) { .panels { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .panels { grid-template-columns: repeat(4, 1fr); } }
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 12px 10px;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.panel-title { font-size: 15px; margin: 0 0 8px; display: flex; justify-content: space-between; gap: 8px; }
.panel-title a { color: var(--text); }
.panel-count { color: var(--muted); font-weight: 500; font-size: 13px; }
.panel-more { font-size: 13px; font-weight: 600; margin-top: auto; padding-top: 6px; }
.block-title { font-size: 18px; margin: 28px 0 0; }

.rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.rows-grid { display: grid; gap: 4px 12px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .rows-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .rows-grid { grid-template-columns: repeat(4, 1fr); } }
.row a { display: flex; gap: 10px; align-items: center; padding: 6px 4px; border-radius: 8px; color: var(--text); min-width: 0; }
.row a:hover { background: var(--accent-soft); text-decoration: none; }
.row-body { min-width: 0; display: grid; }
.row-name, .row-meta { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-name { font-weight: 600; font-size: 14px; }
.row-meta { font-size: 12px; color: var(--muted); }

/* ---------- home */
.hero { padding: 8px 0 0; }
.search-hero input { padding: 13px 16px; font-size: 16px; border-width: 2px; }
.stats { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-wrap: wrap; gap: 6px 18px; color: var(--muted); font-size: 14px; }
.stats b { color: var(--text); font-size: 16px; }

.map-block { margin-top: 16px; }
.map { height: 360px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); z-index: 0; }
@media (max-width: 640px) { .map { height: 260px; } }
.map-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; font-size: 13px; color: var(--muted); margin: 6px 0 0; }
.map-hint { margin-left: auto; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: -8px; vertical-align: -1px; }
.dot-live { background: var(--accent); }
.dot-soon { background: var(--muted); opacity: .6; }
.leaflet-container { font: inherit; }
@media (prefers-color-scheme: dark) {
  /* OSM tiles are light: invert them to match the dark theme */
  .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.85) contrast(.9); }
  .leaflet-tooltip { background: var(--surface); color: var(--text); border-color: var(--line); }
  .leaflet-control-attribution { background: rgba(23, 26, 32, .8) !important; color: var(--muted); }
  .leaflet-control-attribution a { color: var(--accent); }
}

.my-city { margin-top: 16px; padding: 14px 16px; border-radius: var(--radius);
  background: var(--accent-soft); border: 1px solid var(--line); }
.my-city h2 { margin: 2px 0; font-size: 20px; }
.my-city .rows { margin: 10px 0 4px; }
.my-city-label { font-size: 12px; font-weight: 600; color: var(--accent); text-transform: uppercase; letter-spacing: .04em; }
.my-city-meta { color: var(--muted); margin: 0; font-size: 14px; }
.my-city-actions { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin-top: 8px; }
.my-city-other { font-size: 13px; color: var(--muted); }
.my-city .chips { margin: 10px 0 0; }

.cities { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.cities a {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
  padding: 9px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
}
.cities a:hover { text-decoration: none; border-color: var(--accent); }
.city-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.city-count { font-size: 13px; color: var(--muted); }
.region { font-size: 13px; color: var(--muted); font-weight: 600; margin: 16px 0 0; text-transform: uppercase; letter-spacing: .03em; }

.upcoming { margin-top: 8px; }
.progress-list { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 6px 24px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.progress-list li { display: grid; grid-template-columns: minmax(0, 1fr) 2fr auto; gap: 10px; align-items: center; font-size: 14px; }
.progress-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress-bar { height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress-bar span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.progress-count { font-size: 13px; color: var(--muted); white-space: nowrap; }

.cta {
  margin-top: 32px;
  padding: 16px 18px;
  background: var(--accent-soft);
  border-radius: var(--radius);
  display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; justify-content: space-between;
}
.cta h2 { margin: 0 0 4px; font-size: 17px; }
.cta p { margin: 0; color: var(--muted); max-width: 640px; }

/* ---------- card */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-top: 10px;
  max-width: 760px;
}
.card-head { display: flex; gap: 16px; align-items: center; }
.card-head h1 { margin: 0 0 4px; font-size: 22px; overflow-wrap: anywhere; }
.card-desc { white-space: pre-line; overflow-wrap: anywhere; margin: 14px 0 0; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.card-actions { display: flex; flex-wrap: wrap; gap: 16px; font-size: 13px; margin: 18px 0 0; }
.card-actions a { color: var(--muted); }

.card-stats { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.card-stats h2 { font-size: 16px; margin: 0 0 10px; }
.kpis { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); margin: 0; }
.kpis div { background: var(--bg); border-radius: 8px; padding: 8px 10px; }
.kpis dt { font-size: 12px; color: var(--muted); }
.kpis dd { margin: 2px 0 0; font-weight: 700; font-size: 17px; }
.up { color: var(--ok); }
.down { color: #d0453a; }
.spark { display: block; width: 100%; height: 48px; margin-top: 12px; color: var(--accent); }
.small { font-size: 12px; margin-top: 8px; }

.section { margin-top: 4px; }
.steps, .rules { padding-left: 20px; }
.steps li, .rules li { margin-bottom: 6px; }

.foot { border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; padding: 14px 0 28px; }
.foot p { margin: 4px 0; }

@media (max-width: 480px) {
  h1 { font-size: 22px; }
  .card { padding: 14px; }
}
