
:root {
  --background: #eef3f7;
  --surface: #ffffff;
  --surface-soft: #f7fafc;
  --text: #162432;
  --muted: #647383;
  --border: #d9e2e9;
  --brand: #0b5cab;
  --brand-dark: #073f78;
  --brand-soft: #e8f3ff;
  --info: #1684d6;
  --shadow: 0 16px 40px rgba(16, 39, 61, 0.12);
  --shadow-soft: 0 7px 24px rgba(16, 39, 61, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--background);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  overflow: hidden;
  background: var(--background);
}
button, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
h1, h2, h3, p { margin-top: 0; }

.site-header {
  display: grid;
  grid-template-columns: minmax(190px, .72fr) minmax(320px, 1.4fr) minmax(200px, .72fr);
  align-items: center;
  gap: 16px;
  min-height: 62px;
  padding: 4px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand-lockup {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 9px;
  min-width: 0;
}
.brand-logo {
  width: auto;
  height: 54px;
  object-fit: contain;
  display: block;
  flex: 0 0 auto;
}
.brand-copy { display: grid; gap: 0; min-width: 0; }
.brand-name { font-weight: 850; font-size: .88rem; letter-spacing: -.015em; line-height: 1.15; }
.brand-subtitle { color: var(--brand-dark); font-size: .6rem; font-weight: 850; letter-spacing: .075em; line-height: 1.25; white-space: nowrap; }

.header-copy { min-width: 0; }
h1 { margin-bottom: 3px; font-size: clamp(1.35rem, 1.85vw, 1.95rem); letter-spacing: -.035em; line-height: 1.08; }
h2 { margin-bottom: 0; font-size: 1.05rem; }
h3 { margin-bottom: 10px; font-size: .9rem; }
.header-description { margin: 0; color: var(--muted); font-size: .82rem; line-height: 1.3; }

.header-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.update-label { min-height: 15px; color: var(--muted); font-size: .7rem; text-align: right; }
.button {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 11px;
  padding: 0 15px;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 780;
  text-decoration: none;
  white-space: nowrap;
  transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
}
.button-primary { color: #fff; background: var(--brand); border-color: var(--brand); }
.button-secondary { color: var(--brand); background: var(--brand-soft); border-color: #c6e1fb; }
.button:hover { filter: brightness(.985); box-shadow: var(--shadow-soft); transform: translateY(-1px); }
.button:disabled { opacity: .65; cursor: wait; transform: none; box-shadow: none; }
.button:focus-visible, select:focus-visible, .text-button:focus-visible { outline: 3px solid rgba(11, 92, 171, .22); outline-offset: 2px; }
.header-navigation { display: flex; align-items: center; justify-content: flex-end; gap: 7px; }

.location-strip {
  min-height: 30px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 18px;
  color: var(--brand-dark);
  background: #eaf5ff;
  border-bottom: 1px solid #cfe6f8;
}
.location-strip p { margin: 0; font-size: .74rem; line-height: 1.2; }
.location-strip strong { font-weight: 850; }
.location-icon { color: var(--info); font-size: .66rem; }

.map-layout {
  min-height: 0;
  display: grid;
  grid-template-columns: 305px minmax(0, 1fr);
  background: var(--surface);
  overflow: hidden;
}

.filter-panel {
  position: relative;
  z-index: 500;
  overflow-y: auto;
  padding: 18px;
  background: var(--surface);
  border-right: 1px solid var(--border);
}
.panel-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.text-button { background: transparent; border: 0; color: var(--brand); cursor: pointer; font-weight: 750; padding: 4px; }

.filters { display: grid; gap: 14px; margin-top: 18px; }
.filters label { display: grid; gap: 7px; }
.filters label > span { color: #425263; font-size: .8rem; font-weight: 780; }
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 38px 0 12px;
  color: var(--text);
  background-color: #fff;
  cursor: pointer;
}

.summary-card {
  margin-top: 18px;
  padding: 14px;
  border-radius: 14px;
  background: linear-gradient(135deg, #0c3154, #0b5cab);
  color: #fff;
  box-shadow: var(--shadow-soft);
}
.summary-card > div { display: flex; align-items: baseline; gap: 8px; }
.summary-card strong { font-size: 1.75rem; line-height: 1; }
.summary-card span { color: #dcecfb; font-size: .84rem; }
.summary-total { display: block; margin-top: 8px; color: #bcd7ed !important; font-size: .73rem !important; }
.active-summary { min-height: 18px; margin-top: 10px; color: var(--muted); font-size: .78rem; line-height: 1.4; }

.legend-section { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.legend { display: grid; grid-template-columns: 1fr; gap: 8px; }
.legend-item { display: flex; align-items: center; gap: 9px; color: #4c5b69; font-size: .78rem; }
.legend-dot { width: 11px; height: 11px; border-radius: 999px; flex: 0 0 auto; }
.panel-note { margin: 16px 0 0; color: var(--muted); font-size: .75rem; line-height: 1.45; }

.map-shell { position: relative; min-width: 0; min-height: 0; background: #dce9f4; }
#map { width: 100%; height: 100%; }
.leaflet-interactive:focus-visible {
  outline: none;
  stroke: var(--brand-dark);
  stroke-width: 4;
  filter: drop-shadow(0 0 3px rgba(255,255,255,.95));
}

.empty-state {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 14px 18px;
  border-radius: 14px;
  background: rgba(255,255,255,.97);
  box-shadow: var(--shadow-soft);
  color: var(--muted);
  font-weight: 700;
  text-align: center;
}

.site-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 18px;
  padding: 8px 22px 8px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.footer-copy { color: #536271; font-size: .74rem; line-height: 1.34; }
.footer-copy p { margin: 0 0 3px; }
.demo-disclaimer { color: var(--brand-dark); font-weight: 700; }
.footer-contact {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 5px 10px;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  white-space: nowrap;
}
.footer-contact-text {
  color: #405263;
  font-size: .76rem;
}
.footer-contact-text strong { color: var(--brand-dark); font-weight: 800; }
.footer-social-links { display: flex; align-items: center; gap: 7px; }
.footer-social-icon {
  width: 31px;
  height: 31px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  text-decoration: none;
  font-size: 1.08rem;
  transition: transform .16s ease, background .16s ease, color .16s ease;
}
.footer-social-whatsapp { color: #148a43; background: rgba(37, 211, 102, .11); }
.footer-social-instagram { color: #b22372; background: rgba(193, 53, 132, .09); }
.footer-social-icon:hover { transform: translateY(-1px); }
.footer-social-icon:focus-visible { outline: 3px solid rgba(11, 92, 171, .22); outline-offset: 2px; }
.footer-company {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  color: var(--muted);
  font-size: .74rem;
}
.footer-company-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  text-align: right;
}
.footer-company-label {
  color: var(--muted);
  font-size: .72rem;
  font-weight: 600;
}
.footer-company-logo {
  width: 190px;
  max-height: 72px;
  object-fit: contain;
  display: block;
}

.footer-company-link {
  color: var(--brand-dark);
  font-size: .77rem;
  font-weight: 700;
  text-decoration: none;
}
.footer-company-link:hover { text-decoration: underline; }
.footer-company-link:focus-visible {
  outline: 3px solid rgba(11, 92, 171, .22);
  outline-offset: 2px;
  border-radius: 4px;
}

.leaflet-popup-content-wrapper {
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.leaflet-popup-content {
  margin: 0;
  width: 310px !important;
  max-height: min(520px, 62vh);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.popup-card { overflow: hidden; }
.popup-photo-frame {
  position: relative;
  display: block;
  width: 100%;
  height: 168px;
  overflow: hidden;
  background: #e8f0f6;
}
.popup-photo-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 750;
  text-align: center;
  background: linear-gradient(110deg, #e8f0f6 8%, #f5f8fa 18%, #e8f0f6 33%);
  background-size: 220% 100%;
  animation: popup-photo-loading 1.15s linear infinite;
}
.popup-photo {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity .18s ease;
}
.popup-photo-frame.is-loaded .popup-photo { opacity: 1; }
.popup-photo-frame.is-loaded .popup-photo-placeholder { display: none; }
.popup-photo-frame.is-failed .popup-photo { display: none; }
.popup-photo-frame.is-failed .popup-photo-placeholder {
  background: #f2f5f7;
  animation: none;
}
@keyframes popup-photo-loading {
  to { background-position-x: -220%; }
}
.popup-body { padding: 14px; }
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 850;
  letter-spacing: .05em;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.status-reportado { background: #ffe8e8; color: #b42318; }
.status-en-revision { background: #fff3dc; color: #b26a00; }
.status-programado { background: #e4f1ff; color: #0b5cab; }
.status-fin-conforme, .status-finalizado { background: #e4f8eb; color: #12703f; }
.status-cancelado { background: #edf0f3; color: #556372; }
.popup-description { margin: 0 0 12px; font-size: .92rem; line-height: 1.45; color: var(--text); }
.popup-meta { margin: 0; display: grid; gap: 8px; }
.popup-row { display: grid; grid-template-columns: 72px 1fr; gap: 10px; align-items: start; }
.popup-meta dt { margin: 0; color: var(--muted); font-size: .74rem; font-weight: 800; }
.popup-meta dd { margin: 0; color: var(--text); font-size: .8rem; line-height: 1.35; }

@media (max-width: 1180px) {
  .site-header { grid-template-columns: minmax(175px, .7fr) minmax(290px, 1.25fr) auto; gap: 13px; padding-left: 14px; padding-right: 14px; }
  .brand-logo { width: auto; height: 52px; }
  .brand-name { font-size: .9rem; }
  .brand-subtitle { font-size: .62rem; }
}

@media (max-width: 920px) {
  body { grid-template-rows: auto auto 1fr auto; }
  .site-header {
    grid-template-columns: minmax(165px, auto) minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    min-height: 58px;
    padding: 5px 12px;
  }
  .brand-logo { width: auto; height: 46px; }
  .brand-name { font-size: .84rem; }
  .brand-subtitle { font-size: .58rem; }
  h1 { font-size: 1.3rem; }
  .header-description { display: none; }
  .header-actions { align-items: flex-end; }
  .location-strip, .site-footer { padding-left: 12px; padding-right: 12px; }
  .map-layout { grid-template-columns: 270px minmax(0, 1fr); }
}

@media (max-width: 760px) {
  .map-layout { grid-template-columns: 255px minmax(0, 1fr); }
  .filter-panel { padding: 14px; }
  .leaflet-popup-content { width: 260px !important; max-height: 58vh; }
  .popup-photo-frame { height: 146px; }
  .popup-row { grid-template-columns: 66px 1fr; }
}

@media (max-width: 980px) {
  .site-footer { grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; padding: 7px 12px; }
  .footer-company-copy { gap: 1px; }
  .footer-company-label { font-size: .66rem; }
  .footer-company-logo { width: 124px; max-height: 50px; }
  .footer-company-link { font-size: .68rem; }
  .footer-copy { font-size: .67rem; line-height: 1.26; }
  .footer-contact { gap: 7px; padding: 4px 8px; }
  .footer-contact-text { font-size: .69rem; }
  .footer-social-icon { width: 29px; height: 29px; font-size: 1rem; }
}

@media (max-width: 760px) {
  .site-footer { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "copy company" "contact contact"; gap: 5px 10px; }
  .footer-copy { grid-area: copy; }
  .footer-company { grid-area: company; }
  .footer-contact { grid-area: contact; border: 0; border-top: 1px solid var(--border); padding: 5px 0 0; justify-content: flex-end; }
}

@media (max-width: 680px) {
  html, body { height: auto; min-height: 100%; }
  body { display: block; overflow: auto; }
  .site-header {
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas: "brand copy" "actions actions";
    gap: 8px;
    padding: 5px 8px;
  }
  .brand-lockup { grid-area: brand; }
  .header-copy { grid-area: copy; }
  .header-actions { grid-area: actions; width: 100%; }
  .header-navigation { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  .header-navigation .button { width: 100%; min-height: 44px; }
  .brand-copy { display: none; }
  .brand-logo { width: auto; height: 44px; }
  h1 { font-size: 1.08rem; white-space: normal; }
  .update-label { display: none; }
  .button { min-height: 34px; padding: 0 10px; font-size: .75rem; }
  .map-layout { display: grid; grid-template-columns: 1fr; grid-template-rows: auto minmax(420px, 62vh); overflow: visible; }
  .filter-panel { overflow: visible; border-right: 0; border-bottom: 1px solid var(--border); }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .legend { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .map-shell { height: 62vh; min-height: 420px; }
  #map { min-height: 420px; }
}


@media (max-width: 520px) {
  .filters, .legend { grid-template-columns: 1fr; }
  .site-footer { grid-template-columns: 1fr; grid-template-areas: "copy" "contact" "company"; }
  .footer-copy, .footer-contact, .footer-company { width: 100%; }
  .footer-contact { justify-content: center; }
  .footer-contact-text { white-space: normal; text-align: center; }
  .footer-company { justify-content: center; }
  .footer-company-copy { align-items: center; text-align: center; }
  .footer-company-logo { width: 108px; }
}
