:root {
  color-scheme: dark;
  --bg: #0b1220;
  --panel: #101a2c;
  --panel-2: #142239;
  --line: #263853;
  --text: #edf4ff;
  --muted: #9db0c9;
  --accent: #55b5ff;
  --accent-2: #89d0ff;
  --city: #4da3ff;
  --panuj: #b47cff;
  --suggestion: #ff6fb0;
  --external: #a4b2c4;
  --ongoing: #21c98b;
  --preparing: #ffae45;
  --budgeted: #55b5ff;
  --completed: #a4b2c4;
  --cancelled: #ff6b72;
  --shadow: 0 24px 70px rgba(0, 0, 0, .28);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { overflow: hidden; }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 3px solid rgba(85, 181, 255, .55);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  z-index: 2000;
  left: 1rem;
  top: -4rem;
  padding: .7rem 1rem;
  border-radius: .6rem;
  background: #fff;
  color: #101827;
  transition: top .2s ease;
}
.skip-link:focus { top: 1rem; }

.app-shell {
  display: grid;
  grid-template-columns: minmax(350px, 420px) minmax(0, 1fr);
  grid-template-rows: 82px minmax(0, 1fr);
  height: 100vh;
}

.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 0 1.4rem;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(110deg, #101a2c 0%, #13243d 58%, #10294a 100%);
  box-shadow: 0 8px 24px rgba(2, 8, 18, .18);
  z-index: 600;
}

.brand { display: flex; align-items: center; min-width: 0; gap: .9rem; }
.brand-mark {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border-radius: 12px 12px 12px 3px;
  background:
    radial-gradient(circle at 50% 42%, #d9f0ff 0 16%, transparent 17%),
    linear-gradient(145deg, #55b5ff, #1666b1);
  box-shadow: 0 8px 24px rgba(32, 145, 230, .28);
  transform: rotate(-2deg);
}
.brand h1 { margin: 0; font-size: clamp(1.05rem, 2vw, 1.35rem); letter-spacing: -.02em; }
.brand p { margin: .2rem 0 0; color: var(--muted); font-size: .8rem; }

.summary { display: flex; align-items: stretch; gap: .45rem; }
.summary-item {
  min-width: 116px;
  padding: .55rem .75rem;
  border: 1px solid rgba(119, 167, 216, .22);
  border-radius: .65rem;
  background: rgba(8, 18, 33, .4);
}
.summary-item strong { display: block; font-size: 1rem; line-height: 1.05; }
.summary-item span { display: block; margin-top: .2rem; color: var(--muted); font-size: .68rem; line-height: 1.15; }

.sidebar {
  grid-column: 1;
  grid-row: 2;
  overflow-y: auto;
  scrollbar-color: #38516f transparent;
  background: var(--panel);
  border-right: 1px solid var(--line);
  z-index: 500;
}

.filters, .results { padding: 1.1rem 1.15rem; }
.filters { border-bottom: 1px solid var(--line); }
.section-heading, .results-toolbar { display: flex; align-items: flex-end; justify-content: space-between; gap: .8rem; }
.eyebrow { color: var(--accent-2); font-size: .66rem; font-weight: 750; letter-spacing: .14em; text-transform: uppercase; }
h2 { margin: .18rem 0 0; font-size: 1.02rem; letter-spacing: -.01em; }

.ghost-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: .78rem;
}
.ghost-button:hover { color: var(--text); }

.search-control {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin-top: .9rem;
  padding: 0 .75rem;
  border: 1px solid var(--line);
  border-radius: .7rem;
  background: #0c1627;
}
.search-control:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(85, 181, 255, .1); }
.search-control svg { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 1.8; }
.search-control input { width: 100%; min-width: 0; padding: .74rem 0; border: 0; outline: 0; background: transparent; color: var(--text); font-size: .82rem; }
.search-control input::placeholder { color: #6f839f; }

.filter-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; margin-top: .75rem; }
.filter-grid label { color: var(--muted); font-size: .7rem; font-weight: 650; }
select {
  width: 100%;
  margin-top: .35rem;
  padding: .62rem .65rem;
  border: 1px solid var(--line);
  border-radius: .62rem;
  background: #0c1627;
  color: var(--text);
  font-size: .78rem;
}

.layer-controls { display: flex; flex-wrap: wrap; gap: .5rem .85rem; margin: .85rem 0 0; padding: 0; border: 0; }
.layer-controls legend { float: left; width: 100%; margin-bottom: .38rem; color: var(--muted); font-size: .7rem; font-weight: 650; }
.layer-controls label { display: inline-flex; align-items: center; gap: .38rem; font-size: .73rem; color: #c7d5e8; cursor: pointer; }
.layer-controls input { accent-color: var(--accent); }
.layer-dot { width: 8px; height: 8px; border-radius: 50%; }
.layer-dot.city { background: var(--city); }
.layer-dot.panuj { background: var(--panuj); }
.layer-dot.suggestion { background: var(--suggestion); }
.layer-dot.external { background: var(--external); }

.map-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin-top: .9rem; }
.suggestion-button {
  grid-column: 1 / -1;
  padding: .72rem .8rem;
  border: 1px solid #ff9ac8;
  border-radius: .66rem;
  background: linear-gradient(135deg, #d84386, #a92665);
  color: #fff;
  font-size: .8rem;
  font-weight: 800;
}
.primary-button, .secondary-button {
  padding: .65rem .7rem;
  border-radius: .62rem;
  font-size: .76rem;
  font-weight: 750;
}
.primary-button { border: 1px solid #69c0ff; background: linear-gradient(135deg, #2a91df, #166eb8); color: #fff; }
.secondary-button { border: 1px solid var(--line); background: #142239; color: #dce9f8; }
a.secondary-button { display:flex; align-items:center; justify-content:center; text-align:center; text-decoration:none; }
.primary-button:hover, .secondary-button:hover, .suggestion-button:hover { filter: brightness(1.1); }
.admin-link { display: inline-flex; margin-top: .7rem; color: #8fa5c0; font-size: .68rem; text-decoration: none; }
.admin-link:hover { color: #d9e8fa; text-decoration: underline; }

.results { padding-bottom: 2rem; }
.results-toolbar { align-items: center; }
.view-toggle { display: flex; padding: 3px; border: 1px solid var(--line); border-radius: .58rem; background: #0c1627; }
.view-toggle button { padding: .38rem .5rem; border: 0; border-radius: .42rem; background: transparent; color: var(--muted); font-size: .66rem; }
.view-toggle button.active { background: #1d3150; color: #fff; }

.project-list { display: grid; gap: .62rem; margin-top: .85rem; }
.project-card {
  width: 100%;
  padding: .78rem;
  border: 1px solid #20344f;
  border-radius: .72rem;
  background: linear-gradient(145deg, rgba(22, 37, 61, .9), rgba(14, 26, 45, .95));
  color: var(--text);
  text-align: left;
  box-shadow: 0 8px 24px rgba(1, 7, 16, .12);
  transition: border-color .18s ease, transform .18s ease, background .18s ease;
}
.project-card:hover { transform: translateY(-1px); border-color: #3d628c; background: #162945; }
.project-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: .7rem; }
.project-card h3 { margin: .25rem 0 0; font-size: .84rem; line-height: 1.28; letter-spacing: -.005em; }
.project-id { color: #7891ad; font-size: .62rem; letter-spacing: .08em; }
.status-pill { flex: 0 0 auto; padding: .28rem .42rem; border-radius: 999px; font-size: .59rem; font-weight: 800; color: #08131d; }
.status-pill.ongoing { background: var(--ongoing); }
.status-pill.preparing { background: var(--preparing); }
.status-pill.budgeted { background: var(--budgeted); }
.status-pill.completed { background: var(--completed); }
.status-pill.cancelled { background: var(--cancelled); }
.status-pill.participatory { background: var(--panuj); color: #fff; }
.status-pill.suggestion { background: var(--suggestion); color: #2a0718; }
.status-pill.related, .status-pill.other { background: #7d8da3; }
.project-meta { display: flex; flex-wrap: wrap; gap: .35rem .7rem; margin-top: .65rem; color: var(--muted); font-size: .68rem; }
.project-meta span { display: inline-flex; align-items: center; gap: .28rem; }
.project-meta .amount { color: #d9eafe; font-weight: 700; }
.project-scope { margin: .55rem 0 0; color: #aebed3; font-size: .7rem; line-height: 1.38; }
.empty-state { padding: 1.1rem; border: 1px dashed var(--line); border-radius: .7rem; color: var(--muted); font-size: .78rem; text-align: center; }

.map-panel { position: relative; grid-column: 2; grid-row: 2; min-width: 0; min-height: 0; background: #d8e1e8; }
#map { position: absolute; inset: 0; background: #dce5eb; }
.map-note, .legend {
  position: absolute;
  z-index: 500;
  border: 1px solid rgba(22, 45, 69, .18);
  background: rgba(248, 251, 254, .94);
  color: #13243a;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}
.map-note { top: 1rem; right: 1rem; width: min(260px, calc(100% - 2rem)); padding: .72rem .82rem; border-radius: .7rem; }
.map-note strong { display: block; font-size: .78rem; }
.map-note span { display: block; margin-top: .22rem; color: #5d6f83; font-size: .67rem; line-height: 1.3; }
.legend { left: 1rem; bottom: 1rem; display: flex; flex-wrap: wrap; gap: .45rem .7rem; max-width: calc(100% - 2rem); padding: .58rem .7rem; border-radius: .62rem; }
.legend span { display: inline-flex; align-items: center; gap: .3rem; font-size: .63rem; font-weight: 650; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; }
.status-dot.ongoing { background: var(--ongoing); }
.status-dot.preparing { background: var(--preparing); }
.status-dot.budgeted { background: var(--budgeted); }
.status-dot.completed { background: var(--completed); }
.status-dot.participatory { background: var(--panuj); }
.status-dot.suggestion { background: var(--suggestion); }
.mobile-results { display: none; }

.pick-location-banner {
  position: absolute;
  z-index: 900;
  top: 1rem;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 1rem;
  width: min(440px, calc(100% - 2rem));
  padding: .72rem .8rem;
  border: 1px solid rgba(255, 255, 255, .32);
  border-radius: .75rem;
  background: #13243a;
  color: #fff;
  box-shadow: var(--shadow);
  transform: translateX(-50%);
}
.pick-location-banner[hidden] { display: none; }
.pick-location-banner div { min-width: 0; flex: 1; }
.pick-location-banner strong, .pick-location-banner span { display: block; }
.pick-location-banner strong { font-size: .8rem; }
.pick-location-banner span { margin-top: .12rem; color: #b8cbe0; font-size: .68rem; }
.pick-location-banner button { padding: .45rem .6rem; border: 1px solid #617894; border-radius: .5rem; background: transparent; color: #fff; font-size: .7rem; }
#map.is-picking, #map.is-picking .leaflet-interactive { cursor: crosshair; }

.map-marker { width: 20px; height: 20px; border: 3px solid #fff; border-radius: 50% 50% 50% 12%; box-shadow: 0 4px 12px rgba(3, 16, 28, .34); transform: rotate(-45deg); }
.map-marker::after { content: ""; position: absolute; inset: 5px; border-radius: 50%; background: rgba(255,255,255,.85); }
.map-marker.ongoing { background: var(--ongoing); }
.map-marker.preparing { background: var(--preparing); }
.map-marker.budgeted { background: var(--budgeted); }
.map-marker.completed { background: var(--completed); }
.map-marker.cancelled { background: var(--cancelled); }
.map-marker.participatory { background: var(--panuj); }
.map-marker.suggestion { background: var(--suggestion); }
.map-marker.related, .map-marker.other { background: #7d8da3; }
.map-marker.approximate { border-style: dashed; }

.leaflet-control-zoom a { color: #18314b; }
.leaflet-container { font-family: inherit; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: #101a2c; color: var(--text); }
.leaflet-popup-content-wrapper { border: 1px solid #2b4361; border-radius: .72rem; box-shadow: var(--shadow); }
.leaflet-popup-content { width: min(290px, 70vw) !important; margin: .85rem; }
.leaflet-popup-close-button { color: #b8c8db !important; }
.popup-eyebrow { color: var(--accent-2); font-size: .61rem; font-weight: 800; letter-spacing: .08em; }
.popup-title { margin: .25rem 0 .5rem; font-size: .9rem; line-height: 1.25; }
.popup-grid { display: grid; grid-template-columns: 82px 1fr; gap: .3rem .55rem; margin: 0; font-size: .67rem; line-height: 1.3; }
.popup-grid dt { color: var(--muted); }
.popup-grid dd { margin: 0; }
.popup-scope { margin: .58rem 0 0; color: #b9c8dc; font-size: .68rem; line-height: 1.4; }
.popup-photo { display: block; width: 100%; max-height: 170px; margin: .6rem 0 0; border-radius: .55rem; object-fit: cover; }
.popup-actions { display: flex; align-items: center; gap: .45rem; margin-top: .7rem; }
.popup-actions button, .popup-actions a { display: inline-flex; padding: .43rem .58rem; border-radius: .48rem; text-decoration: none; font-size: .65rem; font-weight: 750; }
.popup-actions button { border: 0; background: var(--accent); color: #092038; }
.popup-actions a { border: 1px solid #3c5878; color: #dcecff; }

dialog {
  width: min(660px, calc(100vw - 2rem));
  max-height: min(82vh, 760px);
  padding: 0;
  border: 1px solid #304766;
  border-radius: 1rem;
  background: #111d30;
  color: var(--text);
  box-shadow: 0 28px 100px rgba(0, 0, 0, .55);
}
dialog::backdrop { background: rgba(3, 8, 16, .74); backdrop-filter: blur(3px); }
.dialog-close { position: sticky; float: right; top: .7rem; right: .7rem; z-index: 1; width: 34px; height: 34px; margin: .7rem .7rem 0 0; border: 1px solid #3a526e; border-radius: 50%; background: #17283f; color: #d9e8fa; font-size: 1.25rem; }
#dialog-content { padding: 1.4rem 1.45rem 1.55rem; overflow: auto; }
.detail-kicker { color: var(--accent-2); font-size: .66rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.detail-title { margin: .35rem 2.6rem .75rem 0; font-size: 1.35rem; line-height: 1.2; }
.detail-subtitle { margin: 0 0 1rem; color: var(--muted); font-size: .8rem; line-height: 1.5; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
.detail-item { padding: .72rem; border: 1px solid #263a56; border-radius: .66rem; background: #0d1727; }
.detail-item span { display: block; color: var(--muted); font-size: .65rem; }
.detail-item strong { display: block; margin-top: .24rem; font-size: .78rem; line-height: 1.35; }
.detail-section { margin-top: 1rem; }
.detail-section h3 { margin: 0 0 .4rem; font-size: .78rem; color: #cfe5fb; }
.detail-section p { margin: 0; color: #afc0d5; font-size: .76rem; line-height: 1.55; }
.detail-source { display: inline-flex; margin-top: 1rem; color: #8bd1ff; font-size: .76rem; font-weight: 750; }
.detail-photo { display: block; width: 100%; max-height: 380px; margin: 1rem 0 0; border-radius: .75rem; object-fit: cover; }

#suggestion-dialog { width: min(720px, calc(100vw - 2rem)); max-height: min(90vh, 880px); overflow-y: auto; }
.suggestion-form { display: grid; gap: .9rem; padding: 1.4rem 1.45rem 1.55rem; }
.form-intro { margin: -.35rem 2.5rem .15rem 0; color: var(--muted); font-size: .82rem; line-height: 1.5; }
.form-field, .photo-field { display: grid; gap: .38rem; color: #dfeafa; font-size: .82rem; font-weight: 700; }
.optional { color: var(--muted); font-size: .72rem; font-weight: 500; }
.form-field input, .form-field select, .form-field textarea, .photo-field input {
  width: 100%;
  margin: 0;
  padding: .72rem .75rem;
  border: 1px solid #304766;
  border-radius: .62rem;
  outline: 0;
  background: #0c1627;
  color: var(--text);
  font-size: 1rem;
}
.form-field textarea { min-height: 118px; resize: vertical; line-height: 1.45; }
.form-field input:focus, .form-field select:focus, .form-field textarea:focus, .photo-field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(85, 181, 255, .11); }
.form-two-columns { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.location-picker { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .78rem; border: 1px solid #304766; border-radius: .68rem; background: #0d1727; }
.location-picker div { min-width: 0; }
.location-picker span, .location-picker strong { display: block; }
.location-picker span { color: var(--muted); font-size: .7rem; }
.location-picker strong { margin-top: .22rem; font-size: .8rem; }
.location-picker button { flex: 0 0 auto; }
.photo-field small { color: var(--muted); font-size: .68rem; font-weight: 500; }
.photo-field input { padding: .58rem; font-size: .82rem; }
.photo-field input::file-selector-button { margin-right: .7rem; padding: .48rem .65rem; border: 0; border-radius: .48rem; background: #28415f; color: #fff; cursor: pointer; }
.photo-preview { width: 100%; max-height: 260px; border: 1px solid #304766; border-radius: .72rem; object-fit: cover; }
.consent-field { display: flex; align-items: flex-start; gap: .65rem; color: #bdcce0; font-size: .76rem; line-height: 1.45; cursor: pointer; }
.consent-field input { flex: 0 0 auto; margin-top: .18rem; accent-color: var(--accent); }
.submit-suggestion { padding: .8rem 1rem; border: 1px solid #ff9ac8; border-radius: .68rem; background: linear-gradient(135deg, #d84386, #a92665); color: #fff; font-weight: 800; }
.submit-suggestion:disabled { cursor: wait; opacity: .65; }
.form-status { min-height: 1.25rem; color: #bcd0e7; font-size: .76rem; line-height: 1.4; }
.form-status.error { color: #ff9ca1; }
.form-status.success { color: #73e2b8; }
.honeypot { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

noscript { position: fixed; z-index: 3000; inset: 1rem; padding: 1rem; background: #fff; color: #111; }

@media (max-width: 980px) {
  body { overflow: auto; }
  .app-shell { display: flex; flex-direction: column; height: auto; min-height: 100vh; }
  .topbar { position: sticky; top: 0; min-height: 72px; padding: .7rem 1rem; }
  .summary-item:nth-child(3) { display: none; }
  .summary-item { min-width: 92px; }
  .map-panel { order: 2; height: 54vh; min-height: 390px; }
  .sidebar { order: 3; overflow: visible; border-right: 0; }
  .filters, .results { padding: 1rem; }
  .mobile-results { display: block; position: absolute; z-index: 500; left: 50%; bottom: 1rem; transform: translateX(-50%); padding: .62rem .9rem; border: 0; border-radius: 999px; background: #10213a; color: #fff; box-shadow: var(--shadow); font-weight: 750; }
  .legend { bottom: 4.4rem; }
  .pick-location-banner { top: .65rem; }
}

@media (max-width: 640px) {
  .brand-mark { width: 32px; height: 32px; }
  .brand h1 { font-size: .98rem; }
  .brand p { font-size: .68rem; }
  .summary { display: none; }
  .filter-grid { grid-template-columns: 1fr; }
  .map-panel { height: 50vh; min-height: 350px; }
  .map-note { top: .65rem; right: .65rem; }
  .legend { left: .65rem; max-width: calc(100% - 1.3rem); }
  .detail-grid { grid-template-columns: 1fr; }
  .form-two-columns { grid-template-columns: 1fr; }
  .location-picker { align-items: stretch; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
