.topbar{background:linear-gradient(160deg,var(--navy) 0%,var(--navy-2) 70%,var(--navy-3) 100%);padding:calc(env(safe-area-inset-top) + 14px) 16px 14px;flex-shrink:0;position:relative;overflow:hidden;}
.topbar::after{content:'';position:absolute;top:-40px;right:-40px;width:160px;height:160px;background:radial-gradient(circle,rgba(232,182,90,.18),transparent 70%);}
.brand-row{display:flex;align-items:center;justify-content:space-between;gap:10px;position:relative;z-index:1;}
.brand .eyebrow{font-size:10.5px;letter-spacing:2.5px;color:var(--gold);text-transform:uppercase;font-weight:600;}
.brand h1{margin:0;font-size:20px;font-weight:700;color:#fff;font-family:Georgia,serif;}
.icon-btn{width:36px;height:36px;border-radius:10px;border:1px solid rgba(255,255,255,.18);background:rgba(255,255,255,.06);display:flex;align-items:center;justify-content:center;color:#fff;flex-shrink:0;}
.icon-btn:active{background:rgba(255,255,255,.16);}
.search-wrap{margin-top:14px;position:relative;z-index:1;}
.search-box{display:flex;align-items:center;gap:8px;background:rgba(255,255,255,.96);border-radius:12px;padding:10px 12px;box-shadow:0 4px 14px rgba(0,0,0,.18);}
.search-box svg{flex-shrink:0;color:var(--ink-soft);}
/* 16px, no 15.5px: por debajo de ese umbral iOS Safari hace zoom automatico
   al enfocar el campo, y el usuario tiene que separar la pagina con los dedos. */
.search-box input{border:none;outline:none;flex:1;font-size:16px;background:transparent;color:var(--ink);min-width:0;}
.search-box input::placeholder{color:#A3A8AE;}
.clear-x{display:none;color:#A3A8AE;padding:2px;}
/* Indicador sutil de búsqueda en curso */
@keyframes _search-pulse{0%,100%{box-shadow:0 4px 14px rgba(0,0,0,.18)}50%{box-shadow:0 4px 18px rgba(59,130,246,.35)}}
.search-box.searching{animation:_search-pulse 1s ease-in-out infinite;}

.chip-row{display:flex;gap:6px;margin-top:10px;overflow-x:auto;padding-bottom:2px;position:relative;z-index:1;-webkit-overflow-scrolling:touch;}
.chip{flex-shrink:0;padding:6px 13px;border-radius:999px;font-size:12.5px;font-weight:600;background:rgba(255,255,255,.1);color:rgba(255,255,255,.85);border:1px solid rgba(255,255,255,.16);white-space:nowrap;cursor:pointer;user-select:none;-webkit-user-select:none;}
.chip.active{background:var(--gold);color:var(--navy);border-color:var(--gold);}
.stats-line{margin-top:0;margin-bottom:12px;font-size:11.5px;color:rgba(255,255,255,.55);position:relative;z-index:1;display:flex;justify-content:space-between;}

.topbar {
  /* padding seguro para PWA en Windows/macOS */
  padding-top: env(titlebar-area-y, env(safe-area-inset-top, 0px));
  padding-left: env(titlebar-area-x, 0px);
  padding-right: calc(env(titlebar-area-width, 0px) + 10px);
  -webkit-app-region: drag; /* Permite arrastrar la ventana desde la topbar */
}

/* Location Selector Styles */
.location-selector {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  z-index: 2;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
.loc-group {
  display: grid;
  grid-template-columns: 60px 1fr;
  align-items: center;
  gap: 8px;
}
.loc-label {
  color: rgba(255, 255, 255, 0.85);
  font-size: 12.5px;
  font-weight: 600;
  text-align: right;
}
.loc-picker {
  display: flex;
  gap: 6px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  scrollbar-width: none; /* Firefox */
  margin: 0 auto;
}
.loc-picker::-webkit-scrollbar {
  display: none;
}
.loc-item {
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  user-select: none;
  -webkit-user-select: none;
  transition: all 0.2s ease;
  scroll-snap-align: center;
}
.loc-item:active {
  background: rgba(255, 255, 255, 0.16);
}
.loc-item.active {
  background: var(--gold);
  color: var(--navy);
  border-color: var(--gold);
}

/* Horizontal Pickers */
#pickerEst {
  flex-direction: row;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  width: 100%;
  max-width: 254px;
  padding: 0 calc(50% - 23px);
}
#pickerEst .loc-item {
  width: 46px;
  height: 44px;
  font-size: 16px;
  transition: width 0.3s ease, background 0.2s, color 0.2s, border-color 0.2s;
}
#pickerEst .loc-item.active {
  width: 150px;
}

#pickerCol {
  flex-direction: row;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  width: 100%;
  max-width: 150px;
  padding: 0 calc(50% - 23px);
}
#pickerCol .loc-item {
  width: 46px;
  height: 36px;
  font-size: 14px;
}

/* Vertical Picker (Fila) */
#pickerFila {
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  height: 108px; /* Exactamente 3 elementos de 36px */
  width: 46px; 
  padding: 36px 0; /* (108 / 2) - (36 / 2) = 36px */
  align-items: center;
}
#pickerFila .loc-item {
  width: 46px;
  height: 36px;
  font-size: 14px;
  border-color: rgba(232, 182, 90, 0.4); /* Subtle gold border to connect visually */
}
#pickerFila .loc-item.active {
  border-color: var(--gold);
  background: rgba(232, 182, 90, 0.15);
}


/* ─── Search History Dropdown ─────────────────────────────────────────────── */
/* El dropdown se adjunta al <body> con position:fixed vía JS              */

.sh-dropdown {
  display: none;
  /* position:fixed y coordenadas las pone JS con getBoundingClientRect() */
  background: #ffffff;
  border: 1px solid rgba(0,0,0,.10);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,.22), 0 2px 8px rgba(0,0,0,.12);
  overflow: hidden;
  z-index: 9999;
  transform-origin: top center;
  animation: shSlideIn .16s ease;
}
.sh-dropdown.open { display: block; }

@keyframes shSlideIn {
  from { opacity: 0; transform: scaleY(.94) translateY(-4px); }
  to   { opacity: 1; transform: scaleY(1) translateY(0); }
}

.sh-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 14px;
  border: none;
  background: transparent;
  cursor: pointer;
  text-align: left;
  border-bottom: 1px solid rgba(0,0,0,.06);
  transition: background .12s;
}
.sh-item:last-of-type { border-bottom: none; }
.sh-item:hover, .sh-item:focus {
  background: #FFF8EC;
  outline: none;
}

.sh-clock { color: #B8A060; flex-shrink: 0; }

.sh-text {
  flex: 1;
  font-size: 14px;
  color: #1a2238;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sh-del {
  border: none;
  background: transparent;
  color: #ccc;
  cursor: pointer;
  padding: 4px 2px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  border-radius: 6px;
  transition: color .12s, background .12s;
}
.sh-del:hover { color: #d94040; background: rgba(220,80,80,.10); }

.sh-footer {
  padding: 7px 14px;
  border-top: 1px solid rgba(0,0,0,.07);
  display: flex;
  justify-content: flex-end;
}
.sh-clear-all {
  border: none;
  background: transparent;
  font-size: 12px;
  color: #999;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  transition: color .12s, background .12s;
}
.sh-clear-all:hover { color: #c0392b; background: rgba(220,80,80,.08); }
