/* Visor Catastral — estilo iOS
   Tokens, chrome del mapa, panel flotante / hoja inferior, listas agrupadas. */

:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Inter", "Segoe UI", Roboto, system-ui, sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;

  --blue: #007aff;
  --green: #34c759;
  --red: #ff3b30;
  --orange: #ff9500;
  --teal: #30b0c7;
  --indigo: #5856d6;

  --label: #000;
  --label-2: #3c3c43;          /* 60% */
  --label-3: rgba(60,60,67,.55);
  --label-4: rgba(60,60,67,.32);
  --separator: rgba(60,60,67,.18);
  --fill-1: rgba(120,120,128,.20);
  --fill-2: rgba(120,120,128,.16);
  --fill-3: rgba(120,120,128,.12);

  --bg: #f2f2f7;
  --bg-elevated: #fff;
  --glass: rgba(249,249,251,.78);
  --glass-strong: rgba(255,255,255,.92);
  --glass-border: rgba(255,255,255,.55);
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 12px 32px -8px rgba(20,24,40,.22);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.06), 0 4px 12px -2px rgba(20,24,40,.14);
  --thumb-bg: #fff;

  --r-xl: 26px;
  --r-lg: 18px;
  --r-md: 12px;
  --r-sm: 9px;
  --gap: 12px;
  --panel-w: 372px;
  --ease-spring: cubic-bezier(.32,1.35,.5,1);
  --ease-out: cubic-bezier(.2,.8,.2,1);

  --z-map: 0; --z-hud: 10; --z-panel: 20; --z-menu: 30; --z-toast: 50; --z-modal: 60;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --blue: #0a84ff; --green: #30d158; --red: #ff453a; --orange: #ff9f0a; --teal: #40c8e0; --indigo: #5e5ce6;
    --label: #fff;
    --label-2: #ebebf5;
    --label-3: rgba(235,235,245,.6);
    --label-4: rgba(235,235,245,.3);
    --separator: rgba(84,84,88,.6);
    --fill-1: rgba(120,120,128,.36);
    --fill-2: rgba(120,120,128,.32);
    --fill-3: rgba(120,120,128,.24);
    --bg: #000;
    --bg-elevated: #1c1c1e;
    --glass: rgba(28,28,30,.74);
    --glass-strong: rgba(36,36,38,.92);
    --glass-border: rgba(255,255,255,.12);
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 16px 40px -8px rgba(0,0,0,.7);
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4), 0 4px 14px -2px rgba(0,0,0,.5);
    --thumb-bg: #636366;
  }
}
:root[data-theme="dark"] {
  --blue: #0a84ff; --green: #30d158; --red: #ff453a; --orange: #ff9f0a; --teal: #40c8e0; --indigo: #5e5ce6;
  --label: #fff; --label-2: #ebebf5; --label-3: rgba(235,235,245,.6); --label-4: rgba(235,235,245,.3);
  --separator: rgba(84,84,88,.6); --fill-1: rgba(120,120,128,.36); --fill-2: rgba(120,120,128,.32); --fill-3: rgba(120,120,128,.24);
  --bg: #000; --bg-elevated: #1c1c1e; --glass: rgba(28,28,30,.74); --glass-strong: rgba(36,36,38,.92); --glass-border: rgba(255,255,255,.12);
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 16px 40px -8px rgba(0,0,0,.7); --shadow-sm: 0 1px 2px rgba(0,0,0,.4), 0 4px 14px -2px rgba(0,0,0,.5);
  --thumb-bg: #636366;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  font-size: 15px; line-height: 1.45;
  color: var(--label);
  background: var(--bg);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, p { margin: 0; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:disabled { cursor: default; opacity: .5; }
input, output { font: inherit; color: inherit; }
svg { width: 22px; height: 22px; flex: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; border-radius: 6px; }

.skip { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--blue); color: #fff; padding: 8px 12px; border-radius: 8px; }
.skip:focus { left: 8px; }

/* Cristal */
.glass {
  background: var(--glass);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  backdrop-filter: saturate(180%) blur(22px);
  box-shadow: var(--shadow-sm), inset 0 0 0 .5px var(--glass-border);
}

/* Mapa */
#map { position: absolute; inset: 0; z-index: var(--z-map); background: var(--bg); }
.map-fallback { position: absolute; inset: 0; display: grid; place-items: start center; padding-top: 120px; z-index: 1; pointer-events: none; }
.map-fallback p { color: var(--label-3); font-size: 13px; background: var(--glass); padding: 6px 12px; border-radius: 999px; }
.maplibregl-ctrl-scale { font-family: var(--font); font-size: 11px; color: var(--label-2); background: var(--glass); border: 1px solid var(--separator); border-top: 0; border-radius: 0 0 6px 6px; padding: 0 6px; }
.maplibregl-ctrl-bottom-left { bottom: 48px; left: max(12px, env(safe-area-inset-left)); }
.maplibregl-ctrl-attrib { font-family: var(--font); font-size: 10px; background: var(--glass) !important; color: var(--label-3); border-radius: 8px; }
.maplibregl-ctrl-attrib a { color: var(--label-2); }
.maplibregl-ctrl-bottom-right { bottom: 48px; right: max(12px, env(safe-area-inset-right)); }
.maplibregl-canvas:focus { outline: none; }
.map-measuring .maplibregl-canvas-container { cursor: crosshair !important; }
.maplibregl-popup-content { font-family: var(--font); background: var(--glass-strong); color: var(--label); border-radius: 12px; box-shadow: var(--shadow-sm); padding: 8px 12px; font-size: 13px; }
.maplibregl-popup-anchor-bottom .maplibregl-popup-tip { border-top-color: var(--glass-strong); }
.maplibregl-popup-anchor-top .maplibregl-popup-tip { border-bottom-color: var(--glass-strong); }

/* Barra superior */
.topbar {
  position: absolute; z-index: var(--z-hud);
  top: max(12px, env(safe-area-inset-top)); left: 12px; right: 12px;
  display: grid; grid-template-columns: auto auto 1fr; gap: var(--gap); align-items: center;
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 8px 14px 8px 10px; border-radius: 999px; }
.brand-mark { width: 28px; height: 28px; border-radius: 9px; background: linear-gradient(145deg, var(--blue), var(--indigo)); position: relative; flex: none; }
.brand-mark::after { content: ""; position: absolute; inset: 7px; border: 2px solid #fff; border-radius: 3px; transform: rotate(8deg); opacity: .9; }
.brand h1 { font-size: 15px; font-weight: 600; letter-spacing: -.01em; line-height: 1.15; }
.brand p { font-size: 12px; color: var(--label-3); line-height: 1.2; }

/* Control segmentado (iOS) */
.seg { position: relative; display: inline-flex; padding: 2px; border-radius: 999px; background: var(--fill-2); isolation: isolate; }
.seg.glass { background: var(--glass); }
.seg > button {
  position: relative; z-index: 1; padding: 8px 16px; border-radius: 999px; font-size: 14px; font-weight: 500;
  color: var(--label-2); white-space: nowrap; min-height: 40px; transition: color .2s;
}
.seg > button[aria-checked="true"], .seg > button[aria-selected="true"] { color: var(--label); font-weight: 600; }
.seg-thumb {
  position: absolute; top: 2px; bottom: 2px; left: 0; width: 0; border-radius: 999px; background: var(--thumb-bg);
  box-shadow: 0 1px 3px rgba(0,0,0,.14), 0 3px 8px rgba(0,0,0,.10);
  transition: transform .32s var(--ease-spring), width .32s var(--ease-spring); z-index: 0;
}
.seg.small { width: 100%; padding: 2px; border-radius: 10px; background: var(--fill-2); }
.seg.small > button { flex: 1; padding: 6px 10px; min-height: 32px; font-size: 13px; border-radius: 8px; }
.seg.small .seg-thumb { border-radius: 8px; }
.seg.tiny > button { padding: 4px 10px; min-height: 28px; font-size: 12px; }

/* Búsqueda */
.search { display: flex; align-items: center; gap: 8px; padding: 0 10px 0 12px; border-radius: 999px; min-height: 44px; }
.search .ico { color: var(--label-3); width: 18px; height: 18px; }
.search input { flex: 1; min-width: 0; background: none; border: 0; outline: none; font-size: 15px; height: 44px; }
.search input::placeholder { color: var(--label-3); }
.search input::-webkit-search-cancel-button { display: none; }
.search .clear { width: 24px; height: 24px; border-radius: 50%; background: var(--label-4); color: var(--bg); display: grid; place-items: center; }
.search .clear svg { width: 14px; height: 14px; }
.search:focus-within { box-shadow: var(--shadow-sm), 0 0 0 3px color-mix(in srgb, var(--blue) 35%, transparent); }

.results {
  position: absolute; z-index: var(--z-menu); top: 68px; left: 12px; right: 12px;
  max-height: min(56vh, 460px); overflow: auto; border-radius: var(--r-lg); padding: 6px;
  animation: pop .22s var(--ease-out);
}
.results .res { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center; padding: 9px 10px; border-radius: 10px; width: 100%; text-align: left; }
.results .res[aria-selected="true"], .results .res:hover { background: var(--fill-3); }
.res-ico { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; font-size: 11px; font-weight: 700; color: #fff; letter-spacing: .02em; }
.res-ico.terreno { background: var(--orange); } .res-ico.barrio, .res-ico.vereda { background: var(--teal); } .res-ico.manzana { background: var(--indigo); } .res-ico.construccion { background: #64748b; }
.res-ico.ph_conjunto { background: #9d174d; } .res-ico.ubp { background: #7c3aed; } .res-ico.funza_norma { background: #334155; }
.res-main { min-width: 0; }
.res-title { font-weight: 600; font-size: 14px; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.res-sub { font-size: 12px; color: var(--label-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.res-tag { font-size: 11px; color: var(--label-3); }
.results .res-more, .results .res-empty { padding: 12px; font-size: 13px; color: var(--label-3); text-align: center; }
.results mark { background: none; color: var(--blue); font-weight: 700; }

/* Controles del mapa */
.mapctl { position: absolute; z-index: var(--z-hud); right: 12px; top: 72px; display: flex; flex-direction: column; gap: 10px; }
.ctl-group { display: flex; flex-direction: column; border-radius: 14px; overflow: hidden; }
.ctl-group button { width: 44px; height: 44px; display: grid; place-items: center; color: var(--label); transition: background .15s; }
.ctl-group button + button { border-top: .5px solid var(--separator); }
.ctl-group button:hover { background: var(--fill-3); }
.ctl-group button:active { background: var(--fill-1); }
.ctl-group button[aria-pressed="true"], .ctl-group button[aria-expanded="true"] { background: var(--blue); color: #fff; }
.ctl-group button:focus-visible { outline-offset: -3px; }
.panel-toggle { display: none; }

.menu { position: absolute; z-index: var(--z-menu); right: 64px; top: 190px; min-width: 230px; border-radius: 14px; padding: 6px; animation: pop .2s var(--ease-out); transform-origin: top right; }
.menu button { display: flex; align-items: center; gap: 8px; width: 100%; padding: 9px 12px 9px 32px; border-radius: 9px; text-align: left; font-size: 14px; position: relative; }
.menu button:hover { background: var(--fill-3); }
.menu button[aria-checked="true"]::before { content: ""; position: absolute; left: 12px; top: 50%; width: 6px; height: 11px; border: solid var(--blue); border-width: 0 2px 2px 0; transform: translateY(-60%) rotate(45deg); }

.measure { position: absolute; z-index: var(--z-hud); left: 50%; transform: translateX(-50%); top: 72px; display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 16px; border-radius: 999px; font-size: 14px; font-variant-numeric: tabular-nums; animation: pop .2s var(--ease-out); white-space: nowrap; }
.measure button { background: var(--blue); color: #fff; border-radius: 999px; padding: 6px 14px; font-weight: 600; font-size: 13px; }

.statusbar { position: absolute; z-index: var(--z-hud); left: 50%; transform: translateX(-50%); bottom: max(12px, env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 12px; padding: 6px 14px; border-radius: 999px; font-size: 12px; color: var(--label-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.statusbar .sep { width: 1px; height: 12px; background: var(--separator); }

/* Onboarding: elegir departamento/municipio antes de cargar datos */
.onboard {
  position: fixed; inset: 0; z-index: var(--z-modal);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(0,0,0,.45); backdrop-filter: blur(6px); animation: pop .25s var(--ease-out);
}
.onboard-card {
  width: 100%; max-width: 380px; background: var(--glass-strong); border-radius: var(--r-xl);
  box-shadow: var(--shadow), inset 0 0 0 .5px var(--glass-border); padding: 24px 22px; text-align: center;
}
.onboard-card .brand-mark { margin: 0 auto 14px; width: 40px; height: 40px; border-radius: 12px; }
.onboard-card h2 { font-size: 19px; font-weight: 700; margin-bottom: 4px; }
.onboard-step { font-size: 13px; color: var(--label-2); margin-bottom: 14px; }
.onboard-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.onboard-list button { padding: 12px 16px; border-radius: 12px; background: var(--fill-2); font-size: 15px; font-weight: 500; text-align: left; transition: background .15s; }
.onboard-list button:hover, .onboard-list button:focus-visible { background: var(--fill-3); }
.onboard-list button:disabled { opacity: .4; cursor: default; }
.onboard-list button small { display: block; font-size: 12px; color: var(--label-3); font-weight: 400; margin-top: 1px; }
#onboard-back { display: block; margin: 2px auto 0; }
.onboard-card { position: relative; }
.onboard-close { position: absolute; top: 12px; right: 12px; }
/* Fuentes y licencias */
.lic-card { max-width: 440px; max-height: calc(100dvh - 40px); overflow-y: auto; text-align: left; }
.lic-card h2 { padding-right: 40px; margin-bottom: 12px; }
.lic-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; font-size: 13px; line-height: 1.45; color: var(--label-2); }
.lic-list li { padding: 10px 12px; border-radius: 12px; background: var(--fill-2); }
.lic-list strong { color: var(--label); font-weight: 600; }
.lic-list a { color: var(--blue); font-weight: 600; white-space: nowrap; }
.lic-list small { display: block; margin-top: 4px; font-size: 12px; color: var(--label-3); }
#btn-licencias { flex: none; min-height: 32px; padding: 4px 0; font-size: 12px; }
/* Municipio activo + "Cambiar municipio" (reemplaza el selector segmentado) */
.mpio-pill { display: flex; align-items: center; gap: 12px; padding: 6px 8px 6px 16px; border-radius: 999px; min-width: 0; }
.mpio-actual { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mpio-actual small { font-weight: 400; color: var(--label-3); }
.mpio-pill .btn.link { flex: none; min-height: 30px; padding: 4px 10px; border-radius: 999px; background: var(--fill-3); }

/* Panel */
.panel {
  position: absolute; z-index: var(--z-panel);
  left: 12px; top: 72px; bottom: 56px; width: var(--panel-w);
  border-radius: var(--r-xl); display: flex; flex-direction: column; overflow: hidden;
  box-shadow: var(--shadow), inset 0 0 0 .5px var(--glass-border);
  transition: transform .4s var(--ease-spring), opacity .25s;
}
.panel.collapsed { transform: translateX(calc(-100% - 24px)); opacity: 0; pointer-events: none; }
.grabber { display: none; }
.panel-head { padding: 12px 12px 8px; }
.panel-body { flex: 1; overflow: auto; padding: 4px 12px 20px; overscroll-behavior: contain; scrollbar-width: thin; }
.panel-body::-webkit-scrollbar { width: 6px; } .panel-body::-webkit-scrollbar-thumb { background: var(--fill-1); border-radius: 3px; }

.group-title { font-size: 13px; font-weight: 400; color: var(--label-3); padding: 18px 12px 6px; }
.group-title:first-child { padding-top: 6px; }
.list { background: color-mix(in srgb, var(--bg-elevated) 70%, transparent); border-radius: var(--r-md); overflow: hidden; margin: 0; padding: 0; list-style: none; }
.row { display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 8px 12px; position: relative; }
.row + .row::before, .list > li + li::before { content: ""; position: absolute; left: 12px; right: 0; top: 0; height: .5px; background: var(--separator); }
.row.col { flex-direction: column; align-items: stretch; gap: 6px; }
.row-label { flex: 1; font-size: 15px; }
.row-sub { font-size: 12px; color: var(--label-3); font-variant-numeric: tabular-nums; }
.range-pair { display: flex; gap: 8px; align-items: center; }
.range-pair input { flex: 1; min-width: 0; width: 60px; background: var(--fill-3); border: 0; border-radius: 8px; padding: 7px 10px; font-size: 14px; font-variant-numeric: tabular-nums; }

/* Capas: filas */
.layer { display: grid; grid-template-columns: 14px 1fr auto; grid-template-areas: "sw name toggle" "sw meta toggle" "bar bar bar"; column-gap: 10px; padding: 8px 12px; min-height: 52px; position: relative; align-items: center; }
.layer .sw { grid-area: sw; width: 14px; height: 14px; border-radius: 4px; border: 2px solid var(--sw-line, #888); background: var(--sw-fill, transparent); }
.layer .sw.line { height: 3px; border: 0; background: var(--sw-line); border-radius: 2px; }
.layer .name { grid-area: name; font-size: 15px; }
.layer .meta { grid-area: meta; font-size: 12px; color: var(--label-3); font-variant-numeric: tabular-nums; }
.layer .meta.err { color: var(--red); }
.layer .ctl { grid-area: toggle; display: flex; align-items: center; gap: 8px; }
.layer .bar { grid-area: bar; height: 3px; border-radius: 2px; background: var(--fill-2); overflow: hidden; margin-top: 6px; }
.layer .bar > i { display: block; height: 100%; width: 0; background: var(--blue); transition: width .25s; }
.layer .bar.indet > i { width: 40%; animation: indet 1.1s infinite linear; }
.layer.off .name { color: var(--label-3); }
.layer.zoomed .meta::after { content: " · acerca el mapa"; color: var(--orange); }
.layer.deferred .meta::after { content: " · se carga al acercar"; color: var(--label-3); }
.opacity { width: 64px; accent-color: var(--blue); height: 24px; }
@media (max-width: 420px) { .opacity { width: 48px; } }

/* Switch iOS */
.switch { position: relative; display: inline-block; width: 51px; height: 31px; flex: none; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--fill-1); transition: background .25s; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 3px 8px rgba(0,0,0,.15), 0 1px 1px rgba(0,0,0,.16); transition: transform .3s var(--ease-spring); }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 3px solid var(--blue); outline-offset: 2px; }

/* Stepper */
.stepper { display: inline-flex; align-items: center; background: var(--fill-3); border-radius: 9px; overflow: hidden; }
.stepper button { width: 36px; height: 32px; display: grid; place-items: center; }
.stepper button:hover { background: var(--fill-2); }
.stepper output { min-width: 56px; text-align: center; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Estadísticas */
.stats { border-radius: var(--r-lg); padding: 14px; background: linear-gradient(160deg, color-mix(in srgb, var(--blue) 14%, var(--bg-elevated)), color-mix(in srgb, var(--indigo) 10%, var(--bg-elevated))); box-shadow: inset 0 0 0 .5px var(--separator); }
.stats-empty { color: var(--label-3); font-size: 14px; text-align: center; padding: 8px 0; }
.stats h3 { font-size: 20px; font-weight: 700; letter-spacing: -.02em; }
.stats .sub { font-size: 12px; color: var(--label-3); margin-bottom: 10px; }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
.stat b { display: block; font-size: 18px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat span { font-size: 12px; color: var(--label-3); }
.stats .vals { margin-top: 10px; padding-top: 10px; border-top: .5px solid var(--separator); font-size: 12px; color: var(--label-2); display: grid; gap: 2px; font-variant-numeric: tabular-nums; }
.skeleton { background: linear-gradient(90deg, var(--fill-3), var(--fill-1), var(--fill-3)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 6px; color: transparent !important; }

/* Leyenda */
.legend { padding: 6px 12px; display: grid; gap: 8px; }
.legend-row { display: grid; grid-template-columns: 110px 1fr; grid-template-areas: "label bar" "label range"; column-gap: 10px; align-items: center; font-size: 12px; }
.legend-label { grid-area: label; color: var(--label-2); }
.legend-bar { grid-area: bar; height: 10px; border-radius: 5px; }
.legend-bar.u { background: linear-gradient(90deg, #a5f3fc, #22d3ee, #3b82f6, #4338ca); }
.legend-bar.r { background: linear-gradient(90deg, #ecfccb, #a3e635, #16a34a, #14532d); }
.legend-range { grid-area: range; color: var(--label-3); font-variant-numeric: tabular-nums; display: flex; justify-content: space-between; }
.legend-note { font-size: 11px; color: var(--label-3); }

.foot { font-size: 11px; color: var(--label-3); padding: 14px 12px 0; }

/* Ficha */
.ficha .empty { display: grid; place-items: center; gap: 10px; padding: 48px 20px; text-align: center; color: var(--label-3); font-size: 14px; }
.ficha .empty svg { width: 36px; height: 36px; color: var(--label-4); }
.ficha-head { display: flex; align-items: flex-start; gap: 10px; padding: 6px 4px 12px; }
.ficha-head .kind { font-size: 12px; color: var(--label-3); }
.ficha-head h3 { font-size: 20px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
.ficha-head .spacer { flex: 1; }
.iconbtn { width: 34px; height: 34px; border-radius: 50%; background: var(--fill-3); display: grid; place-items: center; color: var(--blue); flex: none; }
.iconbtn:hover { background: var(--fill-2); }
.iconbtn svg { width: 18px; height: 18px; }

/* El elemento memorable: el código predial como tiquete de 30 dígitos */
.ticket { border-radius: var(--r-lg); padding: 12px; background: var(--bg-elevated); box-shadow: inset 0 0 0 .5px var(--separator); }
.ticket .code { font-family: var(--mono); font-size: 13px; letter-spacing: .04em; word-break: break-all; color: var(--label-2); margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.ticket .code b { flex: 1; font-weight: 500; color: var(--label); }
.ticket .parts { display: flex; flex-wrap: wrap; gap: 6px; }
.part { display: grid; gap: 2px; padding: 5px 8px; border-radius: 9px; background: color-mix(in srgb, var(--pc, var(--blue)) 12%, transparent); border-left: 3px solid var(--pc, var(--blue)); min-width: 44px; }
.part b { font-family: var(--mono); font-size: 14px; font-weight: 600; letter-spacing: .06em; color: var(--label); line-height: 1.1; }
.part span { font-size: 10px; color: var(--label-3); white-space: nowrap; }
.part.zero { opacity: .55; }
.ticket .reading { margin-top: 10px; font-size: 12px; color: var(--label-2); line-height: 1.4; }

.kv { display: flex; justify-content: space-between; gap: 12px; padding: 9px 12px; min-height: 42px; align-items: center; position: relative; }
.kv + .kv::before { content: ""; position: absolute; left: 12px; right: 0; top: 0; height: .5px; background: var(--separator); }
.kv .k { color: var(--label-2); font-size: 14px; }
.kv .v { font-size: 14px; font-weight: 500; text-align: right; font-variant-numeric: tabular-nums; word-break: break-word; }
.kv .v.mono { font-family: var(--mono); font-size: 13px; }
.kv .v.big { font-size: 17px; font-weight: 700; }
.kv .v.muted { color: var(--label-3); font-weight: 400; }
.list.avaluo .kv .v { white-space: nowrap; word-break: normal; }
.est { border-radius: var(--r-md); padding: 12px; margin-top: 10px; background: color-mix(in srgb, var(--green) 12%, var(--bg-elevated)); }
.est b { display: block; font-size: 22px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.est small { display: block; font-size: 11px; color: var(--label-3); margin-top: 4px; }
.est .warn { font-size: 12px; color: var(--label-2); margin-top: 6px; display: flex; gap: 6px; align-items: flex-start; }
.est .warn svg { width: 14px; height: 14px; margin-top: 2px; color: var(--orange); }
.ficha-aviso { margin: 10px 12px 0; padding: 10px 12px; border-radius: 10px; font-size: 12.5px; line-height: 1.4; color: var(--label); background: color-mix(in srgb, var(--orange) 14%, transparent); display: flex; gap: 8px; align-items: flex-start; }
.ficha-aviso svg { width: 16px; height: 16px; flex: none; margin-top: 1px; color: var(--orange); }
.ficha .chip-list { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 12px 12px; }
.chip { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: var(--fill-3); }
.chip.warn { background: color-mix(in srgb, var(--red) 15%, transparent); color: var(--red); font-weight: 600; }
.constr-row { display: grid; grid-template-columns: 30px 1fr auto; gap: 10px; align-items: center; padding: 8px 12px; min-height: 44px; position: relative; width: 100%; text-align: left; }
.constr-row + .constr-row::before { content: ""; position: absolute; left: 12px; right: 0; top: 0; height: .5px; background: var(--separator); }
.constr-row:hover { background: var(--fill-3); }
.constr-row .n { width: 30px; height: 30px; border-radius: 8px; background: #64748b; color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.constr-row .t { font-size: 14px; }
.constr-row .s { font-size: 12px; color: var(--label-3); font-variant-numeric: tabular-nums; }
.constr-row .a { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }

.actions { display: flex; gap: 8px; padding: 14px 0 0; flex-wrap: wrap; }
.btn { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 8px 14px; border-radius: var(--r-md); background: var(--fill-3); font-weight: 600; font-size: 14px; white-space: nowrap; transition: background .15s, transform .15s; }
.btn:hover { background: var(--fill-2); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--blue); color: #fff; }
.btn.primary:hover { background: color-mix(in srgb, var(--blue) 88%, #000); }
.btn svg { width: 18px; height: 18px; }

/* Toasts */
.toasts { position: absolute; z-index: var(--z-toast); left: 50%; transform: translateX(-50%); bottom: 56px; display: flex; flex-direction: column-reverse; gap: 8px; align-items: center; pointer-events: none; width: min(92vw, 420px); }
@media (max-width: 768px) { .toasts { bottom: auto; top: 172px; flex-direction: column; } }
.toast { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: 999px; font-size: 14px; font-weight: 500; background: var(--glass-strong); color: var(--label); box-shadow: var(--shadow); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); animation: toast-in .35s var(--ease-spring); pointer-events: auto; max-width: 100%; }
.toast svg { width: 18px; height: 18px; }
.toast.err svg { color: var(--red); } .toast.ok svg { color: var(--green); } .toast.info svg { color: var(--blue); }
.toast.out { animation: toast-out .25s var(--ease-out) forwards; }

@keyframes pop { from { opacity: 0; transform: translateY(-6px) scale(.98); } to { opacity: 1; transform: none; } }
.results, .measure { animation-name: pop-x; }
@keyframes pop-x { from { opacity: 0; transform: translateX(-50%) translateY(-6px) scale(.98); } to { opacity: 1; transform: translateX(-50%); } }
.results { animation-name: pop; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-16px) scale(.9); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-10px) scale(.95); } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes indet { from { transform: translateX(-100%); } to { transform: translateX(260%); } }

/* Móvil: hoja inferior */
@media (max-width: 768px) {
  .topbar { grid-template-columns: 1fr; gap: 8px; }
  .brand { display: none; }
  .seg.glass { justify-self: stretch; }
  .seg.glass > button { flex: 1; padding: 8px 6px; font-size: 13px; }
  .results { top: 112px; }
  .mapctl { top: 118px; }
  .menu { top: 240px; }
  .measure { top: 118px; left: 12px; right: 76px; transform: none; width: auto; }
  @keyframes pop-x { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
  .statusbar { display: none; }
  .maplibregl-ctrl-bottom-left, .maplibregl-ctrl-bottom-right { bottom: 100px; }

  .panel {
    left: 0; right: 0; width: auto; top: auto; bottom: 0;
    height: 92dvh; border-radius: var(--r-xl) var(--r-xl) 0 0;
    padding-bottom: env(safe-area-inset-bottom);
    transform: translateY(var(--sheet-y, 50%));
    transition: transform .45s var(--ease-spring);
    will-change: transform;
  }
  .panel.dragging { transition: none; }
  .panel.collapsed { transform: translateY(100%); opacity: 1; pointer-events: none; }
  .panel[data-detent="peek"] { --sheet-y: calc(100% - 128px); }
  .panel[data-detent="half"] { --sheet-y: 48%; }
  .panel[data-detent="full"] { --sheet-y: var(--topbar-h, 150px); }
  .grabber { display: grid; place-items: center; height: 22px; cursor: grab; touch-action: none; }
  .grabber span { width: 36px; height: 5px; border-radius: 3px; background: var(--label-4); }
  .panel-head { padding-top: 0; touch-action: none; }
  .panel-toggle { display: flex; }
  .panel-body { padding-bottom: 60px; }
}

@media (max-width: 380px) { .seg.glass > button { padding: 8px 4px; font-size: 12px; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Construcciones expandibles dentro de la ficha del predio */
.constr-item { position: relative; }
.constr-item + .constr-item::before { content: ""; position: absolute; left: 12px; right: 0; top: 0; height: .5px; background: var(--separator); z-index: 1; }
.constr-item .constr-row::before { display: none; }
.constr-row .a { display: inline-flex; align-items: center; gap: 6px; }
.constr-row .chev { width: 14px; height: 14px; color: var(--label-3); transition: transform .25s cubic-bezier(.2,.8,.2,1); }
.constr-item.open .chev { transform: rotate(90deg); }
.constr-detail { display: none; padding: 0 12px 10px 52px; }
.constr-item.open .constr-detail { display: block; animation: constr-in .22s ease-out; }
.constr-detail .kv { padding: 6px 0; min-height: 0; font-size: 13px; }
.constr-item.focus { background: color-mix(in srgb, var(--blue) 10%, transparent); }
.constr-item.focus .constr-row .n { background: var(--blue); }
.btn.link { background: none; color: var(--blue); padding: 6px 0; min-height: 32px; font-size: 13px; gap: 6px; }
.btn.link svg { width: 14px; height: 14px; }
@keyframes constr-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* Bogotá: grupo de capas, modo temático y leyenda */
.group-sub { font-size: 11px; color: var(--label-4); margin-left: 6px; font-weight: 400; }
.theme { margin-top: 8px; }
.theme .row { flex-wrap: wrap; }
.theme .seg.tiny { margin-left: auto; }
.theme-legend { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; padding: 4px 12px 10px; font-size: 12px; color: var(--label-2); }
.theme-legend .lg { display: flex; align-items: center; gap: 6px; min-width: 0; }
.theme-legend .lg i { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.theme-legend .lg span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.theme-legend .lg small { color: var(--label-3); font-variant-numeric: tabular-nums; }
.theme-legend.seq { grid-template-columns: repeat(7, 1fr); text-align: center; }
.theme-legend.seq .lg { flex-direction: column; gap: 2px; }
.theme-legend.seq .lg i { width: 100%; height: 10px; }
.amz-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
/* Leyenda inline bajo una capa categórica del panel (Fase 2: tratamiento, área de actividad, estrato manzana) */
.lg-legend { padding: 0 12px 10px; border-bottom: .5px solid var(--separator); }
.lg-legend .lg-wrap { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; color: var(--label-2); }
.lg-legend .lg { display: flex; align-items: center; gap: 5px; min-width: 0; max-width: 100%; }
.lg-legend .lg i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.lg-legend .lg span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px; }
.stats .destinos { margin-top: 10px; padding-top: 10px; border-top: .5px solid var(--separator); display: grid; gap: 4px; }
.stats .destino { display: grid; grid-template-columns: 1fr auto; gap: 8px; font-size: 12px; align-items: center; }
.stats .destino span { display: flex; align-items: center; gap: 6px; min-width: 0; color: var(--label-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stats .destino i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.stats .destino b { font-variant-numeric: tabular-nums; font-weight: 600; }
.stats .destino .barra { grid-column: 1 / -1; height: 4px; border-radius: 2px; background: var(--fill-3); overflow: hidden; }
.stats .destino .barra i { display: block; height: 100%; border-radius: 2px; }
.stats .note { font-size: 11px; color: var(--label-3); margin-top: 8px; }
.res-ico.bog_lote { background: #0ea5e9; } .res-ico.bog_predio { background: #8b5cf6; } .res-ico.bog_sector { background: #6d28d9; } .res-ico.bog_localidad { background: #0e9aa7; }

/* Bogotá: ficha del lote — predios paginados */
.predio-item .constr-row .n { font-size: 10px; background: var(--indigo); }
.predio-item .constr-row .t { font-weight: 500; }
.predio-item .constr-row .s .mono { font-family: var(--mono); font-size: 11px; }
.predio-item .constr-detail { padding-left: 12px; }
.predio-item .constr-detail .kv { padding: 6px 0; min-height: 0; }
.predio-item .chip-v { display: inline-flex; align-items: center; gap: 6px; }
.predio-item .chip-v .iconbtn { width: 26px; height: 26px; }
.predio-item .chip-v .iconbtn svg { width: 14px; height: 14px; }
.ticket.nupre { margin: 6px 0 8px; padding: 10px; }
.ticket.nupre .code { font-size: 12px; }
.ticket.nupre .part { min-width: 38px; padding: 4px 6px; }
.ticket.nupre .part b { font-size: 12px; }
.ticket.nupre .part span { font-size: 9px; }
.filterbox { display: flex; align-items: center; gap: 8px; padding: 0 10px; margin: 0 0 8px; min-height: 38px; border-radius: 10px; background: var(--fill-3); }
.filterbox svg { width: 16px; height: 16px; color: var(--label-3); }
.filterbox input { flex: 1; min-width: 0; background: none; border: 0; outline: none; font-size: 14px; height: 38px; }
.filterbox input::-webkit-search-cancel-button { -webkit-appearance: none; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 4px 0; font-size: 12px; color: var(--label-3); font-variant-numeric: tabular-nums; }
.pager-btns { display: flex; gap: 6px; }
.pager .btn { flex: none; min-height: 32px; width: 40px; padding: 0; }
.pager .btn svg { width: 16px; height: 16px; }
.placas .row { min-height: 38px; padding: 6px 12px; }
.placas .row-label { font-size: 14px; font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) { .constr-item.open .constr-detail { animation: none; } .constr-row .chev { transition: none; } }

/* Cuenta e inicio de sesión (js/auth.js). Demo sin cuenta: Soacha; los demás territorios llevan candado. */
.cuenta-btn { width: 30px; height: 30px; position: relative; }
.cuenta-btn svg { width: 16px; height: 16px; }
.cuenta-btn .cuenta-ini { display: none; font-size: 13px; font-weight: 700; text-transform: uppercase; }
.cuenta-btn.sesion { background: var(--blue); color: #fff; }
.cuenta-btn.sesion svg { display: none; }
.cuenta-btn.sesion .cuenta-ini { display: block; }
.onboard-list button .mpio-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.onboard-list button .badge { flex: none; display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 999px; background: var(--fill-3); color: var(--label-2); }
.onboard-list button .badge.gratis { background: color-mix(in srgb, var(--green) 18%, transparent); color: color-mix(in srgb, var(--green) 70%, var(--label)); }
.onboard-list button .badge svg { width: 12px; height: 12px; }
.onboard-list button.locked { color: var(--label-2); }
.auth-card { max-height: calc(100dvh - 40px); overflow-y: auto; }
.auth-tabs { display: flex; gap: 4px; padding: 3px; margin: 0 0 14px; border-radius: 10px; background: var(--fill-3); }
.auth-tabs button { flex: 1; padding: 7px 8px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--label-2); }
.auth-tabs button[aria-selected="true"] { background: var(--thumb-bg); color: var(--label); box-shadow: var(--shadow-sm); }
.auth-form { display: flex; flex-direction: column; gap: 10px; text-align: left; }
.auth-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--label-2); }
.auth-field input { font: inherit; font-size: 16px; font-weight: 400; color: var(--label); padding: 10px 12px; min-height: 44px; border-radius: var(--r-md); border: 0; background: var(--fill-3); outline: none; }
.auth-field input:focus-visible { box-shadow: 0 0 0 2px var(--blue); }
.auth-msg { font-size: 13px; line-height: 1.4; color: var(--red); }
.auth-captcha { min-height: 65px; display: flex; justify-content: center; }
.auth-captcha[hidden] { display: none; }
.auth-msg.ok { color: var(--label-2); }
.auth-form .btn { flex: none; width: 100%; }
.auth-form .btn[disabled] { opacity: .6; }
.auth-links { display: flex; flex-direction: column; align-items: center; gap: 0; margin-top: 6px; }
.auth-nota { margin-top: 8px; font-size: 12px; color: var(--label-3); }

/* Bienvenida por municipio (js/bienvenida.js): panel NO modal sobre el mapa, solo la primera vez por territorio.
   Escritorio: tarjeta a la derecha, bajo la barra superior y al lado de los controles del mapa (no tapa el selector de
   municipio ni el botón de cuenta). Móvil: hoja inferior compacta con 16px de margen, encima del panel. */
.bienvenida {
  position: absolute; z-index: 25; top: 72px; right: 68px; width: min(360px, calc(100vw - 372px - 100px));
  max-height: calc(100dvh - 140px); display: flex; flex-direction: column; overflow: hidden;
  border-radius: var(--r-xl); padding: 16px 16px 12px; background: var(--bg-elevated);
  box-shadow: var(--shadow), inset 0 0 0 .5px var(--glass-border); animation: pop .25s var(--ease-out);
}
.bienvenida:focus { outline: none; }
.bienvenida:focus-visible { outline: none; } /* foco programático al abrir (lector de pantalla); los controles internos sí muestran el anillo */
.bienvenida > * { flex: none; }
.bienv-close { position: absolute; top: 10px; right: 10px; }
.bienv-sub { font-size: 12px; color: var(--label-3); padding-right: 40px; }
.bienvenida h2 { font-size: 20px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; padding-right: 40px; }
.bienv-desc { font-size: 13.5px; color: var(--label-2); margin: 4px 0 10px; line-height: 1.4; }
.bienv-capas-t { font-size: 12px; font-weight: 600; color: var(--label-3); text-transform: uppercase; letter-spacing: .04em; margin: 0 0 4px; }
.bienvenida > .bienv-capas { flex: 1 1 auto; min-height: 96px; overflow-y: auto; overscroll-behavior: contain; }
.bienv-capas { list-style: none; margin: 0; padding: 0; border-radius: var(--r-md); background: var(--fill-3); }
.bienv-capa { display: grid; grid-template-columns: 14px 1fr auto; align-items: center; column-gap: 10px; min-height: 44px; padding: 3px 8px 3px 12px; position: relative; }
.bienv-capa + .bienv-capa::before { content: ""; position: absolute; left: 12px; right: 0; top: 0; height: .5px; background: var(--separator); }
.bienv-capa .sw { width: 14px; height: 14px; border-radius: 4px; border: 2px solid var(--sw-line, #888); background: var(--sw-fill, transparent); }
.bienv-capa .sw.line { height: 3px; border: 0; background: var(--sw-line); border-radius: 2px; }
.bienv-capa .name { font-size: 14px; line-height: 1.25; }
.bienv-capa .name small { display: block; font-size: 11px; color: var(--label-3); }
.bienv-capa.off .name { color: var(--label-2); }
.bienv-aviso { display: flex; gap: 8px; align-items: flex-start; margin-top: 10px; padding: 8px 10px; border-radius: 10px; font-size: 12px; line-height: 1.4; color: var(--label-2); background: color-mix(in srgb, var(--orange) 12%, transparent); }
.bienv-aviso svg { width: 15px; height: 15px; flex: none; margin-top: 1px; color: var(--orange); }
.bienv-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
.bienv-actions .btn { flex: none; }
.bienv-actions .btn.primary { min-height: 40px; padding: 6px 18px; }
@media (max-width: 1000px) and (min-width: 769px) { .bienvenida { width: 300px; } }
@media (max-width: 768px) {
  .bienvenida {
    top: auto; right: 16px; left: 16px; width: auto; bottom: calc(16px + env(safe-area-inset-bottom));
    max-height: min(58dvh, 480px); padding: 14px 14px 10px; border-radius: var(--r-lg);
  }
  .bienvenida h2 { font-size: 18px; }
  .bienv-desc { margin-bottom: 8px; }
  .bienv-capa { min-height: 40px; }
}
