:root {
  --blue-950: #1d3557;
  --blue-800: #02569d;
  --blue-650: #02569d;
  --blue-100: #e9f5fb;
  --yellow: #ffb400;
  --yellow-dark: #cc9000;
  --ink: #153044;
  --muted: #617384;
  --surface: #fff;
  --line: #dbe5eb;
  --shadow: rgba(3, 24, 39, .25);
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  color: var(--ink);
  background: #f3f7f9;
  font: 16px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input { font: inherit; }

.app-shell { max-width: 1680px; margin: 0 auto; padding: 24px 32px; }

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  padding: 22px 4px 26px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--blue-650);
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .1em;
}

h1 { margin: 0; color: var(--blue-950); font-size: clamp(2rem, 3.3vw, 3.25rem); line-height: 1.12; letter-spacing: -.035em; }
h1 span { color: var(--blue-800); }
.intro { max-width: 720px; margin: 12px 0 0; color: var(--muted); font-size: clamp(1rem, 1.7vw, 1.2rem); }

.brand {
  flex: 0 0 auto;
  color: var(--blue-800);
  font-size: 1.25rem;
  font-weight: 900;
  letter-spacing: .12em;
  text-decoration: none;
}
.brand img { display: block; width: 220px; max-width: 100%; height: auto; }

.tool {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  height: clamp(700px, 80vh, 920px);
  min-height: 0;
  overflow: hidden;
  border: 1px solid rgba(9, 70, 108, .14);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: 0 24px 65px rgba(7, 43, 66, .12);
}

.controls { z-index: 2; padding: 22px; overflow: auto; border-right: 1px solid var(--line); }
label { display: block; margin-bottom: 7px; color: var(--blue-950); font-size: .82rem; font-weight: 800; }

.search-row { display: flex; gap: 8px; }
input {
  width: 100%;
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid #bacbd5;
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

input:focus { border-color: var(--blue-650); box-shadow: 0 0 0 3px rgba(6, 116, 173, .13); }
:focus-visible { outline: 3px solid var(--blue-650); outline-offset: 3px; }
button:disabled { opacity: .55; cursor: default; }
button, .cta { border: 0; border-radius: 10px; font-weight: 800; cursor: pointer; }
button { padding: 10px 14px; background: var(--blue-800); color: #fff; }
button:hover { background: var(--blue-950); }

.search-results { margin-top: 8px; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; }
.search-results button { display: block; width: 100%; padding: 9px 11px; border-radius: 0; border-bottom: 1px solid var(--line); background: #fff; color: var(--ink); text-align: left; font-size: .84rem; }
.search-results button:last-child { border-bottom: 0; }
.search-results button:hover { background: var(--blue-100); }

.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 22px; }
.time-slider { margin-top: 22px; }
.slider-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.slider-heading output { color: var(--blue-800); font-size: .85rem; font-weight: 800; font-variant-numeric: tabular-nums; }
input[type="range"] { padding: 0; border: 0; accent-color: var(--yellow-dark); box-shadow: none; }
input[type="range"] { appearance: none; height: 22px; background: transparent; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 10px; background: #dbe5eb; }
input[type="range"]::-webkit-slider-thumb { appearance: none; width: 18px; height: 18px; margin-top: -6px; border-radius: 50%; background: var(--yellow); border: 2px solid white; box-shadow: 0 1px 5px #1d355744; }
input[type="range"]::-moz-range-track { height: 6px; border-radius: 10px; background: #dbe5eb; }
input[type="range"]::-moz-range-thumb { width: 15px; height: 15px; border-radius: 50%; background: var(--yellow); border: 2px solid white; }
.scale { display: flex; justify-content: space-between; color: var(--muted); font-size: .68rem; }

.sun-card {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-top: 22px;
  padding: 14px;
  border: 1px solid #f0d88d;
  border-radius: 12px;
  background: #fff9e7;
}
.sun-icon { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 50%; background: var(--yellow); font-size: 1.45rem; }
.sun-icon { flex-shrink: 0; }
.sun-card strong, .sun-card span { display: block; }
.sun-card strong { color: #5d4700; font-size: .9rem; }
.sun-card div span { color: #806a1a; font-size: .78rem; }

.legend { display: flex; flex-wrap: wrap; gap: 15px; margin-top: 20px; color: var(--muted); font-size: .78rem; }
.legend span { display: flex; align-items: center; gap: 6px; }
.swatch { width: 14px; height: 14px; border-radius: 4px; }
.swatch.shadow { background: rgba(7, 31, 46, .52); }
.swatch.building { background: #91afbf; }
.swatch.cadastre { background: #02569d; }
.appearance { min-width: 0; margin: 14px 0 0; padding: 10px; border: 1px solid var(--line); border-radius: 10px; }
.appearance legend { color: var(--blue-950); font-size: .8rem; font-weight: 700; padding: 0 5px; }
.color-row { display: flex; align-items: center; gap: 7px; margin-bottom: 12px; }
.color-row label { flex: 1; margin: 0; font-size: .75rem; }
.color-row input[type="color"] { width: 36px; height: 34px; padding: 2px; border: 1px solid var(--line); border-radius: 5px; flex-shrink: 0; cursor: pointer; }
.color-row .hex-color { width: 82px; padding: 7px 5px; font-size: .75rem; font-family: monospace; }
.hex-color:invalid { outline: 2px solid #b42318; }
.data-retry { margin-top: 8px; padding: 7px 10px; font-size: .75rem; }
.catastro-map-status { position: absolute; top: 78px; left: 18px; width: 310px; max-width: calc(100% - 80px); padding: 10px 13px; border-radius: 10px; background: #ffffffed; border-left: 4px solid var(--yellow); box-shadow: 0 3px 15px #1d355722; pointer-events: none; font-size: .75rem; }
.catastro-map-status strong, .catastro-map-status span { display: block; }
.catastro-map-status strong { color: var(--blue-800); }
.catastro-map-status span { color: var(--muted); margin-top: 3px; }
.catastro-map-status[data-state="ready"] { border-color: var(--blue-800); }
.map-wrap .loading { top: auto; bottom: 92px; }

.notice { margin: 22px 0 0; padding: 13px 14px; border-left: 4px solid var(--yellow-dark); border-radius: 4px 10px 10px 4px; background: #fff8dc; color: #675718; font-size: .78rem; }
.cta { display: block; margin-top: 16px; padding: 13px 16px; background: var(--yellow); color: #312800; text-align: center; text-decoration: none; }
.cta:hover { background: #ffd968; }

.map-wrap { position: relative; min-height: 0; background: #d7e3e9; }
#map { position: absolute; inset: 0; }
.loading { position: absolute; z-index: 3; border-radius: 10px; top: 72px; left: 18px; padding: 9px 14px; background: var(--blue-950); color: #fff; font-size: .8rem; }
.map-tip { padding: 8px 12px; color: var(--ink); font-size: .72rem; }
.maplibregl-ctrl-group { border-radius: 10px; overflow: hidden; }

footer { padding: 18px 4px 2px; color: var(--muted); font-size: .78rem; }
footer p { margin: 0; }
footer a { color: var(--blue-650); }
.panel-title { display: flex; gap: 10px; align-items: center; margin-bottom: 20px; }
.panel-title h2 { font-size: .92rem; margin: 0; }
.section-number { background: var(--blue-100); color: var(--blue-800); border-radius: 7px; padding: 5px 7px; font-size: .7rem; font-weight: 800; }
.layer-title { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line); margin-bottom: 14px; }
.quick-actions { display: flex; gap: 8px; margin-top: 12px; }
.quick-actions button { flex: 1; font-size: .78rem; }
.quick-actions .secondary { flex: 0 0 auto; background: var(--blue-100); color: var(--blue-800); }
.presets { display: flex; gap: 6px; margin-top: 10px; }
.presets button { flex: 1; background: #f1f5f9; color: var(--muted); font-size: .73rem; padding: 7px; }
.presets button:hover, .presets button[aria-pressed="true"] { background: var(--yellow); color: var(--blue-950); }
.timezone-note { color: var(--muted); font-size: .69rem; margin: 8px 0 0; }
.toggle { display: flex; align-items: center; justify-content: space-between; }
#basemap { width: 100%; padding: 11px; border: 1px solid var(--line); border-radius: 9px; background: white; color: var(--blue-950); font: inherit; font-size: .8rem; }
#basemap-status { margin-bottom: 12px; }
.aerial-note { margin-bottom: 14px; padding: 9px; background: #fff8dc; border-radius: 7px; }
.toggle input { width: 18px; height: 18px; accent-color: var(--blue-800); }
.coverage { font-size: .73rem; color: var(--muted); margin-bottom: 0; }
.notice summary { cursor: pointer; font-weight: 700; }
.notice p { margin-bottom: 0; }
.map-toolbar { position: absolute; left: 18px; top: 18px; display: flex; gap: 4px; padding: 5px; border-radius: 12px; background: white; box-shadow: 0 4px 20px #1d35571a; }
.map-toolbar button { background: white; color: var(--blue-950); font-size: .78rem; padding: 9px 12px; }
.map-toolbar button:hover { background: var(--blue-100); }
.map-toolbar button[aria-pressed="true"] { background: var(--blue-800); color: white; }
.map-bottom { position: absolute; left: 16px; right: 16px; bottom: 40px; display: flex; flex-wrap: wrap; width: fit-content; max-width: calc(100% - 32px); background: #fffffff0; border: 1px solid white; border-radius: 10px; pointer-events: none; }
.map-readout { padding: 8px 12px; font-size: .72rem; font-variant-numeric: tabular-nums; }
.live-dot { display: inline-block; width: 7px; height: 7px; background: var(--yellow); border-radius: 50%; margin-right: 6px; }
kbd { border: 1px solid var(--line); border-radius: 4px; padding: 1px 4px; font: inherit; font-weight: 700; }
.map-error { position: absolute; z-index: 4; left: 20px; right: 20px; top: 90px; max-width: 420px; padding: 20px; background: white; border-left: 4px solid var(--yellow); border-radius: 12px; box-shadow: 0 8px 24px var(--shadow); }
[hidden] { display: none !important; }

@media (max-width: 820px) {
  .app-shell { padding: 0; }
  .hero { align-items: flex-start; padding: 22px 18px; flex-direction: column-reverse; gap: 22px; }
  .brand img { width: 170px; }
  .tool { display: flex; height: auto; min-height: 0; flex-direction: column; border-width: 1px 0; border-radius: 0; }
  .controls { border-right: 0; border-bottom: 1px solid var(--line); padding: 19px 18px; }
  .map-wrap { min-height: 62vh; }
  footer { padding: 16px 18px; }
}

@media (max-width: 420px) {
  .field-grid { gap: 8px; }
  .map-tip { display: none; }
  .map-toolbar { left: 10px; top: 10px; gap: 0; }
  .map-toolbar button { padding: 9px; }
}
