@font-face {
  font-family: "Noto Sans";
  src: url("./fonts/noto-sans-v27-latin-regular.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Patria";
  src: url("./fonts/Patria_Regular.otf") format("opentype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

:root {
  --paper: #f4f1e9;
  --card: #fffef9;
  --ink: #18241f;
  --muted: #69736d;
  --line: #d9d5ca;
  --wine: #701a38;
  --wine-dark: #4b1025;
  --gold: #bd8b1d;
  --green: #235b4e;
  --black: #222323;
}

* { box-sizing: border-box; }
html, body { width: 100%; min-height: 100%; margin: 0; }
body { overflow: hidden; color: var(--ink); background: var(--paper); font-family: "Noto Sans", sans-serif; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid rgba(189,139,29,.38);
  outline-offset: 2px;
}

.app-shell { display: flex; flex-direction: column; height: 100vh; height: 100dvh; min-height: 0; background: var(--paper); }
.topbar {
  position: relative;
  z-index: 1200;
  height: 110px;
  flex-shrink: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 28px;
  padding: 0 38px;
  color: #fff;
  background: #691731;
  border-bottom: 3px solid var(--gold);
  overflow: visible;
  isolation: isolate;
}
.topbar::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: url("./textura-guinda-header-v2.svg?rev=09c94f394dad5e86a62c7ac92e611868e555ce80") left 42% / 430px auto repeat;
  opacity: .34;
  mix-blend-mode: multiply;
  -webkit-mask-image: linear-gradient(90deg,#000 0%,rgba(0,0,0,.88) 27%,rgba(0,0,0,.35) 52%,transparent 76%);
  mask-image: linear-gradient(90deg,#000 0%,rgba(0,0,0,.88) 27%,rgba(0,0,0,.35) 52%,transparent 76%);
  -webkit-mask-size: 100% 100%;
  mask-size: 100% 100%;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  pointer-events: none;
}
.topbar > * {
  position: relative;
  z-index: 1;
}
.brand-logo { justify-self: start; min-width: 0; }
.brand-logo img { display: block; width: auto; height: 75px; max-width: 260px; object-fit: contain; }
.brand-copy { justify-self: center; min-width: max-content; text-align: center; }
.brand-copy p { margin: 0 0 5px; color: #ead7a2; font-size: .72rem; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; }
.brand-copy h1 { margin: 0; font-family: "Patria", "Noto Sans", sans-serif; font-size: 1.82rem; font-weight: 400; letter-spacing: -.02em; text-transform: uppercase; }

.layer-menu-wrap { position: relative; justify-self: end; }
.layer-menu-toggle {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: 28px auto 12px;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  padding: 7px 11px;
  color: #fff;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.46);
  border-radius: 7px;
  cursor: pointer;
  text-align: left;
  backdrop-filter: none;
}
.layer-menu-toggle:hover { opacity: .86; }
.layer-menu-toggle strong, .layer-menu-toggle small { display: block; }
.layer-menu-toggle strong { font-size: .77rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.layer-menu-toggle small { margin-top: 3px; color: #ead7a2; font-size: .65rem; }
.layer-menu-toggle b { color: #ead7a2; font-size: 1rem; transition: transform .2s ease; }
.layers-icon { position: relative; width: 28px; height: 23px; display: block; }
.layers-icon i { position: absolute; left: 4px; width: 19px; height: 12px; border: 1.6px solid #ead7a2; border-radius: 2px; transform: rotate(30deg) skewX(-30deg); }
.layers-icon i:nth-child(1) { top: 0; z-index: 3; }
.layers-icon i:nth-child(2) { top: 5px; z-index: 2; }
.layers-icon i:nth-child(3) { top: 10px; z-index: 1; }
body.layers-open .layer-menu-toggle b { transform: rotate(180deg); }
.layer-menu {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  width: min(390px, calc(100vw - 24px));
  overflow: hidden;
  color: var(--ink);
  background: rgba(255,254,249,.98);
  border: 1px solid rgba(76,48,55,.18);
  border-radius: 12px;
  box-shadow: 0 22px 60px rgba(34,18,24,.32);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-8px);
  transition: opacity .18s, transform .18s, visibility .18s;
}
body.layers-open .layer-menu { opacity: 1; visibility: visible; pointer-events: auto; transform: translateY(0); }
.layer-menu header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 17px 16px 14px 18px;
  color: #fff;
  background: linear-gradient(100deg,var(--wine-dark),var(--wine));
}
.layer-menu header small, .layer-menu header strong { display: block; }
.layer-menu header small { margin-bottom: 4px; color: #dec88c; font-size: .62rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.layer-menu header strong { font-family: "Noto Sans", sans-serif; font-size: 1.05rem; font-weight: 500; }
.layer-menu header button { width: 36px; height: 36px; color: #fff; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.25); border-radius: 50%; cursor: pointer; font-size: 1.5rem; }
.layer-options { padding: 8px 12px 5px; }
.layer-option {
  display: grid;
  grid-template-columns: 22px 16px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 12px 7px;
  border-bottom: 1px solid #ebe7de;
  cursor: pointer;
}
.layer-option:last-child { border-bottom: 0; }
.layer-option input { width: 18px; height: 18px; accent-color: var(--wine); }
.layer-swatch { width: 13px; height: 13px; border: 2px solid #fff; border-radius: 50%; box-shadow: 0 0 0 1px currentColor; background: currentColor; }
.layer-option strong, .layer-option small { display: block; }
.layer-option strong { font-size: .86rem; }
.layer-option small { margin-top: 3px; color: var(--muted); font-size: .68rem; }
.layer-option > b { color: #756e64; font-size: .75rem; font-weight: 700; }
.base-map-options { margin: 2px 17px 11px; padding: 10px 12px 12px; display: flex; gap: 16px; border: 1px solid #ddd8cd; border-radius: 7px; }
.base-map-options legend { padding: 0 5px; color: #776f65; font-size: .62rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.base-map-options label { display: flex; align-items: center; gap: 6px; font-size: .72rem; font-weight: 700; }
.base-map-options input { accent-color: var(--wine); }
.layer-hint { margin: 0; padding: 11px 18px 15px; color: #6f776f; background: #f1eee6; font-size: .69rem; line-height: 1.45; }

.workspace { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: 410px minmax(0,1fr); }
.side-panel { overflow-y: auto; background: var(--paper); border-right: 1px solid #c8c4bb; scrollbar-color: #b7b2a7 transparent; scrollbar-width: thin; }
.intro-block { padding: 25px 25px 19px; border-bottom: 1px solid var(--line); }
.eyebrow { margin: 0 0 9px; color: var(--wine); font-size: .66rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.intro-block h2 { margin: 0; font-family: "Noto Sans", sans-serif; font-size: 1.6rem; font-weight: 500; line-height: 1.08; }
.intro-block > p:last-child { margin: 11px 0 0; color: var(--muted); font-size: .82rem; line-height: 1.5; }
.filters { padding: 18px 25px; background: rgba(255,255,255,.32); border-bottom: 1px solid var(--line); }
.filters label { display: block; }
.filters label > span { display: block; margin-bottom: 6px; color: #53615a; font-size: .65rem; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.filters input, .filters select {
  width: 100%;
  height: 42px;
  padding: 0 11px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid #cbc8c0;
  border-radius: 6px;
  outline: none;
  font-size: .78rem;
}
.filters input:focus, .filters select:focus { border-color: var(--wine); box-shadow: 0 0 0 3px rgba(112,26,56,.09); }
.search-field { margin-bottom: 13px; }
.select-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.unit-field { margin-top: 10px; }
.filter-actions { display: grid; grid-template-columns: 1fr auto; gap: 9px; margin-top: 14px; }
.filter-actions button { min-height: 40px; padding: 0 13px; border-radius: 6px; cursor: pointer; font-size: .75rem; font-weight: 800; }
.fit-button { color: #fff; background: var(--green); border: 1px solid var(--green); }
.reset-button { color: var(--wine); background: transparent; border: 1px solid #c8c3b9; }
.selected-slot:empty { display: none; }
.selected-card {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  margin: 15px 15px 0;
  padding: 19px;
  color: #fff;
  background: linear-gradient(145deg,#701a38,#4b1025);
  border-radius: 11px;
  box-shadow: 0 12px 30px rgba(62,21,34,.18);
}
.selected-card::before, .map-popup-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}
.selected-card::before { background: url("./textura-guinda-header-v2.svg?rev=16098991849840ad98b45c8c9733130dd6fe3101") center/280px auto repeat; opacity: .24; }
.selected-card > * { position: relative; z-index: 1; }
.selected-heading { display: flex; align-items: flex-start; gap: 12px; }
.selected-heading p { margin: 0 0 4px; color: #dec88c; font-size: .61rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.selected-heading h3 { margin: 0; font-family: "Noto Sans", sans-serif; font-size: 1.28rem; font-weight: 500; line-height: 1.12; }
.selected-heading button { margin-left: auto; color: rgba(255,255,255,.76); background: transparent; border: 0; cursor: pointer; font-size: 1.45rem; }
.record-key { display: inline-block; margin: 12px 0 10px; padding: 4px 7px; color: #fff4d4; background: rgba(255,255,255,.11); border: 1px solid rgba(255,255,255,.16); border-radius: 4px; font-family: "Noto Sans", sans-serif; font-size: .64rem; }
.selected-location { margin: 0 0 6px; font-size: .78rem; font-weight: 700; line-height: 1.4; }
.selected-address { margin: 0; color: rgba(255,255,255,.72); font-size: .7rem; line-height: 1.5; }
.coordinate-line { display: flex; flex-wrap: wrap; gap: 7px; margin: 12px 0; }
.coordinate-line span { padding: 5px 7px; color: #e6d9bd; background: rgba(0,0,0,.16); border-radius: 3px; font-family: "Noto Sans", sans-serif; font-size: .63rem; }
.share-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.share-grid a, .share-grid button { min-height: 38px; display: flex; align-items: center; justify-content: center; padding: 0 8px; border-radius: 5px; cursor: pointer; text-decoration: none; font-size: .7rem; font-weight: 800; text-align: center; }
.primary-action { color: #3d2b0d; background: #e0bd68; border: 1px solid #e0bd68; }
.share-grid button { color: #fff; background: transparent; border: 1px solid rgba(255,255,255,.35); }
.results-block { padding: 18px 15px 28px; }
.results-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 0 6px 9px; border-bottom: 1px solid var(--line); }
.results-heading p { margin: 0; color: var(--wine); font-size: .74rem; font-weight: 700; }
.results-heading p strong { font-family: "Noto Sans", sans-serif; font-size: 1.38rem; font-weight: 500; }
.results-heading span { max-width: 150px; color: #7d857f; font-size: .63rem; text-align: right; }
.result-list { padding-top: 5px; }
.result-item { width: 100%; display: grid; grid-template-columns: 18px 1fr auto; gap: 11px; align-items: center; padding: 12px 9px; color: inherit; background: transparent; border: 0; border-bottom: 1px solid #dfdcd4; cursor: pointer; text-align: left; }
.result-item:hover, .result-item.is-selected { background: rgba(255,255,255,.65); }
.result-item.is-selected { box-shadow: inset 3px 0 var(--wine); }
.result-pin { width: 11px; height: 11px; border: 2px solid #fff; border-radius: 50%; box-shadow: 0 0 0 1px currentColor; background: currentColor; }
.result-copy { min-width: 0; display: flex; flex-direction: column; }
.result-copy strong { overflow: hidden; font-family: "Noto Sans", sans-serif; font-size: .9rem; font-weight: 600; line-height: 1.2; text-overflow: ellipsis; white-space: nowrap; }
.result-copy small { margin: 3px 0; color: var(--wine); font-family: "Noto Sans", sans-serif; font-size: .59rem; }
.result-copy > span { overflow: hidden; color: #737c76; font-size: .66rem; text-overflow: ellipsis; white-space: nowrap; }
.result-project { align-self: start; padding: 4px 6px; color: #fff; border-radius: 3px; font-size: .53rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.result-note, .empty-state { margin: 12px 5px; padding: 13px; color: #626d66; background: #ebe7dc; border-radius: 6px; font-size: .72rem; line-height: 1.45; text-align: center; }
.empty-state strong { display: block; margin-bottom: 5px; font-family: "Noto Sans", sans-serif; font-size: 1rem; }

.map-panel { position: relative; min-width: 0; overflow: hidden; background: #d9ddd3; }
.map-canvas { width: 100%; height: 100%; z-index: 1; }
.map-note { position: absolute; top: 15px; left: 50%; z-index: 500; transform: translateX(-50%); display: flex; align-items: center; gap: 8px; padding: 9px 13px; color: #3c4942; background: rgba(255,254,249,.94); border: 1px solid rgba(105,105,94,.23); border-radius: 6px; box-shadow: 0 7px 22px rgba(38,48,42,.13); font-size: .7rem; font-weight: 700; white-space: nowrap; backdrop-filter: blur(8px); transition: opacity .2s,transform .2s; }
.map-note > span:first-child { width: 8px; height: 8px; background: var(--wine); border: 2px solid #fff; border-radius: 50%; box-shadow: 0 0 0 1px var(--wine); }
.map-note.is-hidden { opacity: 0; visibility: hidden; pointer-events: none; transform: translate(-50%,-8px); }
.leaflet-container { font-family: "Noto Sans", sans-serif; }
.leaflet-bar { border: 0 !important; box-shadow: 0 5px 18px rgba(33,42,37,.18) !important; }
.leaflet-bar a { color: var(--wine) !important; background: var(--card) !important; }
.center-popup .leaflet-popup-content-wrapper { padding: 0; overflow: hidden; border-radius: 9px; box-shadow: 0 14px 45px rgba(34,31,26,.24); }
.center-popup .leaflet-popup-content { margin: 0; width: auto !important; }
.center-popup .leaflet-popup-close-button { top: 8px !important; right: 8px !important; color: #fff !important; font-size: 20px !important; z-index: 3; }
.center-popup .leaflet-popup-tip { background: var(--card); }
.map-popup-card { position: relative; isolation: isolate; min-width: 286px; max-width: 320px; overflow: hidden; color: var(--ink); background: rgba(255,254,249,.97); }
.map-popup-card::before { background: url("./textura-mexicana-fichas.png") center/330px auto; opacity: .04; }
.map-popup-card > * { position: relative; z-index: 1; }
.map-popup-head { padding: 15px 42px 14px 18px; color: #fff; background: linear-gradient(110deg,var(--wine-dark),var(--wine)); }
.map-popup-head p { margin: 0 0 4px; color: #dfc990; font-size: .6rem; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }
.map-popup-head h3 { margin: 0; font-family: "Noto Sans", sans-serif; font-size: 1.18rem; font-weight: 500; line-height: 1.12; }
.map-popup-key { display: inline-block; margin: 12px 18px 4px; color: var(--wine); font-family: "Noto Sans", sans-serif; font-size: .63rem; font-weight: 700; }
.map-popup-card dl { margin: 0; padding: 4px 18px 9px; }
.map-popup-card dl div { display: grid; grid-template-columns: 74px 1fr; gap: 8px; padding: 6px 0; border-bottom: 1px solid #e6e2d9; }
.map-popup-card dt { color: #818881; font-size: .57rem; font-weight: 800; text-transform: uppercase; }
.map-popup-card dd { margin: 0; color: #344139; font-size: .66rem; line-height: 1.4; }
.map-popup-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 7px 18px 17px; }
.map-popup-actions a, .map-popup-actions button { min-height: 37px; display: flex; align-items: center; justify-content: center; border-radius: 5px; cursor: pointer; font-size: .68rem; font-weight: 800; text-decoration: none; }
.map-popup-actions .popup-primary { color: #fff; background: var(--wine); border: 1px solid var(--wine); }
.map-popup-actions button { color: var(--wine); background: rgba(255,255,255,.7); border: 1px solid #c9c4b9; }
.cluster-marker { display: grid; place-items: center; color: #fff; border: 2px solid #fff; border-radius: 50%; box-shadow: 0 3px 12px rgba(25,33,29,.3); font-size: .62rem; font-weight: 800; }
.mobile-search-toggle, .mobile-panel-header, .mobile-search-backdrop, .layer-backdrop { display: none; }
.share-toast { position: fixed; z-index: 3000; left: 50%; bottom: 22px; transform: translateX(-50%); padding: 11px 16px; color: #fff; background: var(--green); border-radius: 6px; box-shadow: 0 10px 30px #0003; font-size: .74rem; font-weight: 800; opacity: 0; pointer-events: none; transition: opacity .2s; }
.share-toast.show { opacity: 1; }

@media (max-width: 1100px) {
  .topbar { grid-template-columns: auto 1fr auto; gap: 18px; padding: 0 22px; }
  .brand-logo img { height: 64px; max-width: 190px; }
  .brand-copy h1 { font-size: 1.45rem; }
  .layer-menu-toggle { min-width: 0; }
}

@media (max-width: 900px) {
  body { overflow: hidden; }
  .topbar { height: 82px; grid-template-columns: auto 1fr auto; gap: 11px; padding: 0 12px; }
  .topbar::before {
    background-size: 330px auto;
    opacity: .28;
    -webkit-mask-image: linear-gradient(90deg,#000 0%,rgba(0,0,0,.65) 43%,transparent 88%);
    mask-image: linear-gradient(90deg,#000 0%,rgba(0,0,0,.65) 43%,transparent 88%);
  }
  .brand-logo img { height: 53px; max-width: 132px; }
  .brand-copy { justify-self: start; min-width: 0; text-align: left; }
  .brand-copy p { margin-bottom: 2px; font-size: .48rem; letter-spacing: .12em; }
  .brand-copy h1 { font-size: 1rem; line-height: 1.04; }
  .layer-menu-toggle { min-width: 48px; min-height: 48px; grid-template-columns: 1fr; place-items: center; gap: 0; padding: 6px; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.32); border-radius: 8px; }
  .layer-menu-toggle > span:nth-child(2), .layer-menu-toggle b { display: none; }
  .layer-menu { position: fixed; top: 88px; right: 8px; left: 8px; width: auto; max-height: calc(100dvh - 100px); overflow-y: auto; }
  .layer-backdrop, .mobile-search-backdrop { position: fixed; inset: 0; z-index: 1090; display: block; background: rgba(26,19,21,.52); opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .2s,visibility .2s; backdrop-filter: blur(2px); }
  body.layers-open .layer-backdrop, body.search-menu-open .mobile-search-backdrop { opacity: 1; visibility: visible; pointer-events: auto; }
  body.search-menu-open, body.layers-open { overflow: hidden; }
  .workspace { flex: 1 1 auto; height: auto; min-height: 0; display: block; }
  .map-panel { width: 100%; height: 100%; min-height: 0; }
  .side-panel { position: fixed; top: 82px; right: 7px; bottom: max(7px,env(safe-area-inset-bottom)); left: 7px; z-index: 1100; width: auto; max-height: calc(100dvh - 89px); overflow-y: auto; border: 1px solid rgba(112,32,57,.18); border-radius: 15px; box-shadow: 0 20px 60px rgba(32,17,22,.34); opacity: 0; visibility: hidden; pointer-events: none; transform: translateY(calc(100% + 20px)); transition: transform .28s,opacity .22s,visibility .28s; }
  body.search-menu-open .side-panel { opacity: 1; visibility: visible; pointer-events: auto; transform: translateY(0); }
  .mobile-panel-header { position: sticky; top: 0; z-index: 4; min-height: 62px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 9px 11px 9px 17px; color: #fff; background: linear-gradient(100deg,var(--wine-dark),var(--wine)); border-bottom: 2px solid var(--gold); }
  .mobile-panel-header small, .mobile-panel-header strong { display: block; }
  .mobile-panel-header small { margin-bottom: 3px; color: #dec88c; font-size: .55rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
  .mobile-panel-header strong { font-family: "Noto Sans", sans-serif; font-size: 1.12rem; font-weight: 500; }
  .mobile-panel-header button { width: 42px; height: 42px; color: #fff; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.25); border-radius: 50%; cursor: pointer; font-size: 1.55rem; }
  .mobile-search-toggle { position: absolute; top: 13px; left: 13px; z-index: 900; min-height: 44px; display: inline-flex; align-items: center; gap: 9px; padding: 0 14px; color: #fff; background: var(--wine); border: 1px solid rgba(255,255,255,.42); border-radius: 8px; box-shadow: 0 8px 24px rgba(48,20,29,.25); cursor: pointer; font-size: .74rem; font-weight: 800; }
  .search-icon { position: relative; width: 15px; height: 15px; border: 2px solid #ead7a2; border-radius: 50%; }
  .search-icon::after { content: ""; position: absolute; right: -5px; bottom: -3px; width: 7px; height: 2px; background: #ead7a2; transform: rotate(45deg); }
  .map-note { top: 66px; max-width: calc(100% - 26px); overflow: hidden; font-size: .64rem; text-overflow: ellipsis; }
  .select-grid { grid-template-columns: 1fr 1fr; }
  .center-popup .leaflet-popup-content-wrapper { max-height: calc(100dvh - 106px); }
  .map-popup-card { min-width: min(278px,calc(100vw - 46px)); }
}

@media (max-width: 560px) {
  .brand-logo img { height: 48px; max-width: 105px; }
  .brand-copy h1 { max-width: 150px; font-size: .88rem; }
  .layer-menu-toggle { min-width: 44px; min-height: 44px; }
  .layers-icon { transform: scale(.86); }
  .select-grid { grid-template-columns: 1fr; }
  .intro-block { padding: 20px 20px 17px; }
  .filters { padding: 17px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
