/* Heights relative to the screen: svh where supported. On an iPhone plain vh
   is the height with Safari's toolbars hidden, so an 88vh box is taller than
   what is visible while they show - centred overlays then lost their header
   off the top edge. */
var vvh=n=>(window.CSS&&CSS.supports&&CSS.supports('height','1svh'))?n+'svh':n+'vh';
/* Empty search result -> the same "notify me" capture the homepage uses
   on its no-match path, so a visitor who finds nothing still leaves a
   contact. Copy and field set mirror #dreamspec-nomatch. */
function NoResultsNotify({onReset}){
  var [sent,setSent]=React.useState(false);
  var [f,setF]=React.useState({first:'',last:'',email:'',phone:'',method:'E-Mail'});
  function set(k,v){setF(function(s){var n=Object.assign({},s);n[k]=v;return n;});}
  var valid=f.first.trim()&&f.last.trim()&&/.+@.+\..+/.test(f.email);
  var lbl={display:'block',fontSize:12,fontWeight:700,color:'var(--fg-primary)',marginBottom:6};
  var inp={width:'100%',boxSizing:'border-box',padding:'11px 12px',fontSize:14,
           border:'1px solid var(--border-default,#e2ddd2)',borderRadius:10,
           fontFamily:'var(--font-body)',outline:'none',background:'#fff'};
  var pill={display:'flex',alignItems:'center',justifyContent:'center',gap:6,
            border:'1px solid var(--border-default,#e2ddd2)',borderRadius:10,
            padding:'9px 6px',fontSize:12,fontWeight:500,cursor:'pointer'};
  if(sent) return <div className="mkt-noresults" style={{padding:'44px 20px',textAlign:'center',maxWidth:560,margin:'0 auto'}}>
      <div style={{fontFamily:'var(--font-display)',fontWeight:800,fontSize:22,marginBottom:10}}>Danke — wir melden uns.</div>
      <div style={{color:'var(--fg-muted)',fontSize:15,lineHeight:1.6}}>
        Sobald ein passendes Fahrzeug eintrifft, benachrichtigen wir Sie.</div>
    </div>;
  return <div className="mkt-noresults" style={{padding:'40px 20px',maxWidth:560,margin:'0 auto',textAlign:'center'}}>
    <div style={{fontFamily:'var(--font-display)',fontWeight:800,fontSize:22,marginBottom:8}}>Aktuell keine Treffer</div>
    <div style={{color:'var(--fg-muted)',fontSize:15,lineHeight:1.6,marginBottom:22}}>
      Hinterlassen Sie Ihre Kontaktdaten und wir benachrichtigen Sie, sobald ein
      passendes Fahrzeug verfügbar ist.</div>
    <div className="mkt-noresults-grid" style={{display:'grid',gridTemplateColumns:'1fr 1fr',gap:14,textAlign:'left'}}>
      <div><label style={lbl}>Vorname *</label>
        <input style={inp} type="text" placeholder="z.B. Max" value={f.first} onChange={e=>set('first',e.target.value)}/></div>
      <div><label style={lbl}>Nachname *</label>
        <input style={inp} type="text" placeholder="z.B. Müller" value={f.last} onChange={e=>set('last',e.target.value)}/></div>
      <div><label style={lbl}>E-Mail *</label>
        <input style={inp} type="email" placeholder="sie@beispiel.de" value={f.email} onChange={e=>set('email',e.target.value)}/></div>
      <div><label style={lbl}>Telefonnummer (optional)</label>
        <input style={inp} type="tel" placeholder="+49 …" value={f.phone} onChange={e=>set('phone',e.target.value)}/></div>
      {/* One channel only: these notifications go out through Mailchimp. */}
      <div style={{gridColumn:'1 / -1'}}>
        <p className="modal-notify-note">Sie werden als Erste oder Erster per E-Mail benachrichtigt, sobald ein passendes Fahrzeug eintrifft.</p>
      </div>
    </div>
    <div style={{display:'flex',gap:10,justifyContent:'center',marginTop:20,flexWrap:'wrap'}}>
      <button type="button" onClick={onReset} style={{padding:'12px 18px',fontSize:14,fontWeight:700,
        borderRadius:12,border:'1px solid var(--border-default,#e2ddd2)',background:'#fff',
        color:'var(--fg-primary)',cursor:'pointer',fontFamily:'var(--font-body)'}}>Filter zurücksetzen</button>
      <button type="button" disabled={!valid} onClick={function(){if(valid)setSent(true);}}
        style={{padding:'12px 20px',fontSize:14,fontWeight:700,borderRadius:12,border:'none',
        background:valid?'var(--brand-600,#c8102e)':'#d8d4cd',color:'#fff',
        cursor:valid?'pointer':'not-allowed',fontFamily:'var(--font-body)'}}>Benachrichtigen</button>
    </div>
  </div>;
}

/* Auto-cycling hero images. Same behaviour as the static pages: runs only
   while on screen, and holds still under prefers-reduced-motion. State is
   kept as one object so idx/prev always advance together. */
function ImageCycle({images,duration}){
  var secs=duration||2.5;
  var [st,setSt]=React.useState({idx:0,prev:-1});
  var ref=React.useRef(null);
  React.useEffect(function(){
    if(!images||images.length<2)return;
    if(window.matchMedia&&window.matchMedia('(prefers-reduced-motion:reduce)').matches)return;
    var el=ref.current; if(!el)return;
    var timer=null;
    var io=new IntersectionObserver(function(entries){
      if(entries[0].isIntersecting){
        if(!timer)timer=setInterval(function(){
          setSt(function(s){return {idx:(s.idx+1)%images.length,prev:s.idx};});
        },secs*1000);
      }else{ clearInterval(timer); timer=null; }
    },{threshold:0});
    io.observe(el);
    return function(){ clearInterval(timer); io.disconnect(); };
  },[images,secs]);
  return <div ref={ref} className="image-cycle-collection__list" style={{position:'absolute',inset:0,overflow:'hidden',zIndex:0}}>
    {images.map(function(src,n){
      var state=n===st.idx?'active':(n===st.prev?'previous':'not-active');
      return <div key={src} className="image-cycle-collection__img" data-image-cycle-item={state}>
        <img src={src} alt="" loading={n===0?'eager':'lazy'}/>
      </div>;
    })}
  </div>;
}
window.VOITEL_HERO_CYCLE=['assets/photos/hero-cycle-1.jpg','assets/photos/hero-cycle-2.jpg','assets/photos/hero-cycle-3.jpg'];

const isTouchDevice=typeof window!=='undefined'&&(window.matchMedia('(hover:none)').matches||window.matchMedia('(max-width:1024px)').matches);
function ListingRow({v,onOpen,compareSelected,onToggleCompare,compareDisabled,isFavorite,onToggleFavorite,primaryLabel,onPrimary,secondaryLabel,onSecondary,showCompareCheckbox=true}){
const photos=v.photos&&v.photos.length?v.photos:null;
const [frame,setFrame]=React.useState(0);
const [hovered,setHovered]=React.useState(false);
function prevFrame(e){e.stopPropagation();setFrame(f=>(f-1+photos.length)%photos.length);}
function nextFrame(e){e.stopPropagation();setFrame(f=>(f+1)%photos.length);}
const dot=' · ';
/* Finger-swipe through the card's photos. Horizontal intent only, so a
   vertical drag still scrolls the page; a completed swipe then swallows the
   click the browser fires afterwards, which would otherwise open the
   vehicle mid-gesture. */
const touchRef=React.useRef(null), swipedRef=React.useRef(false);
function onTouchStart(e){var t=e.touches[0];touchRef.current={x:t.clientX,y:t.clientY};swipedRef.current=false;}
function onTouchEnd(e){
  if(!touchRef.current||!photos||photos.length<2)return;
  var t=e.changedTouches[0],dx=t.clientX-touchRef.current.x,dy=t.clientY-touchRef.current.y;
  touchRef.current=null;
  if(Math.abs(dx)<40||Math.abs(dx)<Math.abs(dy))return;
  swipedRef.current=true;
  setFrame(function(f){return (f+(dx<0?1:-1)+photos.length)%photos.length;});
}
function swallowClickAfterSwipe(e){if(swipedRef.current){e.stopPropagation();e.preventDefault();swipedRef.current=false;}}
const specs=[[v.color,'Farbe'],[v.fuel,'Kraftstoff'],[v.km.toLocaleString('de-DE')+' km','Kilometerstand'],[v.firstReg||'—','Erstzulassung'],[v.prevOwners!=null?v.prevOwners:'—','Vorbesitzer'],['Ohne Unfälle','Historie'],[v.power+' PS','Leistung'],[v.transmission,'Getriebe']];
return <div onClick={()=>onOpen(v)} className="v-listing-row" style={{cursor:'pointer',background:'#fff',borderRadius:'var(--radius-m)',padding:24,minWidth:0,width:'100%'}}>
{window.voitelIsFresh&&window.voitelIsFresh(v)&&<div className="mkt-fresh-badge mkt-fresh-badge-row">Frisch eingetroffen</div>}
<div className="v-listing-row-inner" style={{display:'flex',gap:28,minWidth:0}}>
<div className="v-listing-row-img" style={{position:'relative',width:340,flexShrink:0}}>
<div onMouseEnter={()=>setHovered(true)} onMouseLeave={()=>setHovered(false)} onTouchStart={onTouchStart} onTouchEnd={onTouchEnd} onClickCapture={swallowClickAfterSwipe} style={{position:'relative',height:290,borderRadius:'var(--radius-m)',overflow:'hidden',background:photos?`url(${photos[frame]}) center/cover`:v.img.light,touchAction:'pan-y'}}>
{v.offer&&<span style={{position:'absolute',top:10,left:10,background:'var(--brand-600)',color:'#fff',fontSize:11,fontWeight:700,padding:'4px 9px',borderRadius:100}}>Sonderangebot</span>}
{/* Mirror of the Sonderangebot pill on the opposite corner of the same
    photo - same 10px inset and pill radius, so the two read as a pair.
    It used to sit on the card root, floating over the card's border with
    nothing to anchor to. */}
{v._groupCount>1&&<span className="mkt-count-badge mkt-count-badge-onimg">{v._groupCount} verfügbar</span>}
<div onClick={e=>{e.stopPropagation();onToggleFavorite(v);}} className="v-listing-fav-overlay" style={{position:'absolute',top:v._groupCount>1?52:10,right:10,width:30,height:30,borderRadius:'50%',background:isFavorite?'var(--brand-600)':'rgba(255,255,255,.9)',display:'flex',alignItems:'center',justifyContent:'center',cursor:'pointer'}}><img src="https://unpkg.com/lucide-static@0.469.0/icons/heart.svg" width={15} style={isFavorite?{filter:'invert(1)'}:{}}/></div>
{photos&&photos.length>1&&(hovered||isTouchDevice)&&<React.Fragment>
<button onClick={prevFrame} aria-label="Vorheriges Bild" style={{position:'absolute',left:10,top:'50%',transform:'translateY(-50%)',width:34,height:34,borderRadius:'50%',border:'none',background:'rgba(255,255,255,.92)',cursor:'pointer',display:'flex',alignItems:'center',justifyContent:'center',zIndex:2}}><img src="https://unpkg.com/lucide-static@0.469.0/icons/chevron-left.svg" width={17}/></button>
<button onClick={nextFrame} aria-label="Nächstes Bild" style={{position:'absolute',right:10,top:'50%',transform:'translateY(-50%)',width:34,height:34,borderRadius:'50%',border:'none',background:'rgba(255,255,255,.92)',cursor:'pointer',display:'flex',alignItems:'center',justifyContent:'center',zIndex:2}}><img src="https://unpkg.com/lucide-static@0.469.0/icons/chevron-right.svg" width={17}/></button>
</React.Fragment>}
</div>
{photos&&photos.length>1&&<div className="v-listing-thumbs" style={{display:'flex',gap:6,marginTop:6}}>
{photos.slice(0,3).map((p,i)=><div key={i} onClick={e=>{e.stopPropagation();setFrame(i);}} style={{flex:1,height:70,borderRadius:6,overflow:'hidden',background:`url(${p}) center/cover`,cursor:'pointer',outline:frame===i?'2px solid var(--brand-600)':'none'}}/>)}
</div>}
</div>
<div style={{flex:1,minWidth:0,display:'flex',flexDirection:'column'}}>
<div style={{fontSize:12,color:'var(--fg-muted)',fontWeight:700,letterSpacing:'.03em',textTransform:'uppercase'}}>{v.brand}</div>
<div className="v-listing-model" style={{fontFamily:'var(--font-display)',fontWeight:800,fontSize:24,marginBottom:4}}>{v.model}</div>
<div style={{fontSize:14,color:'var(--fg-secondary)',fontWeight:600,marginBottom:12}}>{v.condition}</div>
<div style={{height:1,background:'var(--border-subtle)',margin:'0 0 12px'}}/>
<div className="v-listing-specs" style={{display:'grid',gridTemplateColumns:'repeat(auto-fit,minmax(90px,1fr))',gap:'16px 16px',minWidth:0}}>
{specs.map(([value,label],i)=><div key={i} style={{minWidth:0}}><div style={{fontSize:11,color:'var(--fg-muted)',textTransform:'uppercase',letterSpacing:'.03em',marginBottom:3}}>{label}</div><div style={{fontSize:13.5,fontWeight:700,color:'var(--fg-primary)',lineHeight:1.35,overflow:'hidden',textOverflow:'ellipsis',whiteSpace:'nowrap'}}>{value}</div></div>)}
</div>
<div style={{height:1,background:'var(--border-subtle)',margin:'12px 0'}}/>
<div style={{display:'flex',alignItems:'baseline',gap:8}}>
{/* Was window.fmtPrice(Math.round(v.price*1.12/100)*100) - a struck-through
    "former price" invented by adding 12%. Only a real UVP from the import
    is shown now, and nothing at all when there is none. */}
{(function(){var uvp=window.voitelMsrp&&window.voitelMsrp(v);return uvp?<span className="v-listing-oldprice" style={{fontSize:15,color:'var(--fg-muted)',textDecoration:'line-through'}}>{window.fmtPrice(uvp)}</span>:null;})()}
</div>
<div style={{display:'flex',alignItems:'baseline',gap:8}}>
<span className="v-listing-price" style={{fontFamily:'var(--font-display)',fontWeight:800,fontSize:28,color:'var(--fg-brand)'}}>{window.fmtPrice(v.price)}</span>
<span style={{fontSize:12,color:'var(--fg-muted)'}}>MwSt. ausweisbar</span>
</div>
<div className="v-listing-actions-desktop" style={{display:'flex',gap:10,margin:'16px 0'}}>
<button onClick={e=>{e.stopPropagation();onPrimary?onPrimary(v):onOpen(v);}} style={{border:'none',background:'var(--brand-600)',color:'#fff',borderRadius:'var(--radius-m)',padding:'11px 22px',fontSize:13.5,fontWeight:700,cursor:'pointer',fontFamily:'var(--font-body)'}}>{primaryLabel||'Details ansehen'}</button>
{showCompareCheckbox?<label onClick={e=>e.stopPropagation()} style={{display:'flex',alignItems:'center',gap:7,border:'1px solid var(--border-subtle)',borderRadius:'var(--radius-m)',padding:'11px 18px',fontSize:13.5,fontWeight:700,cursor:compareDisabled&&!compareSelected?'not-allowed':'pointer',color:'var(--fg-primary)'}}>
<input type="checkbox" checked={compareSelected} disabled={compareDisabled&&!compareSelected} onChange={()=>onToggleCompare(v)} style={{width:14,height:14}}/>Vergleichen
</label>:secondaryLabel&&<button onClick={e=>{e.stopPropagation();onSecondary&&onSecondary(v);}} style={{border:'1px solid var(--border-subtle)',background:'#fff',color:'var(--fg-primary)',borderRadius:'var(--radius-m)',padding:'11px 18px',fontSize:13.5,fontWeight:700,cursor:'pointer',fontFamily:'var(--font-body)'}}>{secondaryLabel}</button>}
</div>
<div className="v-listing-actions-mobile" style={{display:'none',gap:12,margin:'16px 0',alignItems:'center'}}>
<button onClick={e=>{e.stopPropagation();onToggleFavorite(v);}} aria-label="Merken" style={{width:48,height:48,flexShrink:0,borderRadius:'50%',border:'1px solid var(--border-subtle)',background:isFavorite?'var(--brand-600)':'#fff',display:'flex',alignItems:'center',justifyContent:'center',cursor:'pointer'}}><img src="https://unpkg.com/lucide-static@0.469.0/icons/heart.svg" width={20} style={isFavorite?{filter:'invert(1)'}:{}}/></button>
{showCompareCheckbox&&<button onClick={e=>{e.stopPropagation();if(!(compareDisabled&&!compareSelected))onToggleCompare(v);}} aria-label="Vergleichen" style={{width:48,height:48,flexShrink:0,borderRadius:'50%',border:'1px solid var(--border-subtle)',background:compareSelected?'var(--brand-600)':'#fff',display:'flex',alignItems:'center',justifyContent:'center',cursor:compareDisabled&&!compareSelected?'not-allowed':'pointer'}}><img src="https://unpkg.com/lucide-static@0.469.0/icons/git-compare.svg" width={20} style={compareSelected?{filter:'invert(1)'}:{}}/></button>}
<button onClick={e=>{e.stopPropagation();onPrimary?onPrimary(v):onOpen(v);}} style={{flex:1,border:'none',background:'var(--brand-600)',color:'#fff',borderRadius:999,padding:'14px 22px',fontSize:14.5,fontWeight:700,cursor:'pointer',fontFamily:'var(--font-body)'}}>{primaryLabel||'Details ansehen'}</button>
</div>
{v.energyLabel&&<div style={{fontSize:12,color:'var(--fg-muted)',marginTop:2,lineHeight:1.6}}>Kraftstoffverbrauch (kombiniert): {v.energyLabel.consumption} l/100 km · CO₂-Emissionen (kombiniert): {v.energyLabel.co2} g/km</div>}
</div>
</div>
</div>;
}

function AdvSearchPanel({open,onClose,filters,setFilter,resetFilters,resultCount}){
if(!open) return null;
const M = window.VOITEL_MARKET||[];
const uniq = (f)=>[...new Set(M.map(f).filter(Boolean))].sort();
const brands = uniq(v=>v.brand);
const bodyCats = window.VOITEL_BODY_ORDER;
const usages = uniq(v=>v.condition);
const fuels = ['Benzin','Diesel','Hybrid','Elektro'];
const drives = uniq(v=>window.voitelDrive?window.voitelDrive(v):v.driveMechanism);
const colOut = uniq(v=>v.basePaintColor);
const colIn  = uniq(v=>v.seatCoverBaseColor);
const eur = n=>new Intl.NumberFormat('de-DE').format(n)+' €';
const toggle=(key,val)=>{const cur=filters[key]||[];setFilter(key,cur.indexOf(val)===-1?cur.concat(val):cur.filter(x=>x!==val));};
const Group=({title,children})=><div className="adv-group"><div className="adv-group-title">{title}</div>{children}</div>;
const Check=({label,checked,onChange,count})=>
  <label className="adv-check"><input type="checkbox" checked={!!checked} onChange={onChange}/>
  <span>{label}</span>{count!=null&&<em>{count}</em>}</label>;
const Range=({label,fromKey,toKey,steps,disabled,note})=>
  <Group title={label}>
    <div className="adv-range">
      <select disabled={disabled} value={filters[fromKey]} onChange={e=>setFilter(fromKey,e.target.value)}>
        <option value="">von</option>{steps.map(s=><option key={s} value={s}>{eur(s)}</option>)}</select>
      <span>–</span>
      <select disabled={disabled} value={filters[toKey]} onChange={e=>setFilter(toKey,e.target.value)}>
        <option value="">bis</option>{steps.map(s=><option key={s} value={s}>{eur(s)}</option>)}</select>
    </div>
    {note&&<div className="adv-note">{note}</div>}
  </Group>;
const EQUIP = window.VOITEL_EQUIP_TAXONOMY;
return <div className="adv-overlay" onClick={e=>{if(e.target.classList.contains('adv-overlay'))onClose();}}>
<div className="adv-panel" data-lenis-prevent>
  <header><strong>Erweiterte Suche</strong>
    <button className="adv-x" onClick={onClose} aria-label="Schließen">✕</button></header>
  <div className="adv-body">
    <Group title="Hersteller">{brands.map(b=><Check key={b} label={b} checked={filters.brands.indexOf(b)!==-1}
      onChange={()=>toggle('brands',b)} count={M.filter(v=>v.brand===b).length}/>)}</Group>
    <Group title="Modellzusatz">
      <input className="adv-text" type="search" placeholder="z.B. Titanium X" value={filters.modelExt}
        onChange={e=>setFilter('modelExt',e.target.value)}/></Group>
    <Group title="Fahrzeugkarosserien">{bodyCats.map(c=>{
      const n=M.filter(v=>window.voitelBodyCategory(v.type)===c).length;
      return <Check key={c} label={c} checked={filters.bodyCats.indexOf(c)!==-1} onChange={()=>toggle('bodyCats',c)} count={n}/>;})}
    </Group>
    <Group title="Fahrzeugart">{['Tageszulassung','Vorführwagen','Gebrauchtfahrzeug'].map(u=>
      <Check key={u} label={u} checked={filters.usage.indexOf(u)!==-1} onChange={()=>toggle('usage',u)}
        count={M.filter(v=>v.condition===u).length}/>)}</Group>
    <Group title="Kraftstoff">{fuels.map(f=>
      <Check key={f} label={f} checked={filters.fuels.indexOf(f)!==-1} onChange={()=>toggle('fuels',f)}
        count={M.filter(v=>window.voitelFuelGroup(v.fuel)===f).length}/>)}</Group>
    <Range label="Preis" fromKey="priceFrom" toKey="priceTo" steps={window.VOITEL_PRICE_STEPS}/>
    <Group title="MwSt.">
      <Check label="MwSt. ausweisbar" checked={filters.vat} onChange={()=>setFilter('vat',!filters.vat)}
        count={M.filter(v=>v.vatDeductible).length}/></Group>
    <Range label="Finanzierung (monatliche Rate)" fromKey="finFrom" toKey="finTo"
      steps={window.VOITEL_RATE_STEPS} disabled={!window.VOITEL_RATE_DATA_AVAILABLE}
      note="Keine Ratendaten im Bestand – dieser Filter schränkt die Ergebnisse derzeit nicht ein."/>
    <Range label="Leasing (monatliche Rate)" fromKey="leaseFrom" toKey="leaseTo"
      steps={window.VOITEL_RATE_STEPS} disabled={!window.VOITEL_RATE_DATA_AVAILABLE}
      note="Keine Ratendaten im Bestand – dieser Filter schränkt die Ergebnisse derzeit nicht ein."/>
    <Group title="Fahrzeug">
      <label className="adv-sub">Antrieb</label>
      <select className="adv-select" value={filters.drive} onChange={e=>setFilter('drive',e.target.value)}>
        <option>Alle</option>{drives.map(d=><option key={d}>{d}</option>)}</select>
      <label className="adv-sub">Außenfarbe</label>
      <select className="adv-select" value={filters.colorOut} onChange={e=>setFilter('colorOut',e.target.value)}>
        <option>Alle</option>{colOut.map(d=><option key={d}>{d}</option>)}</select>
      <label className="adv-sub">Innenfarbe</label>
      <select className="adv-select" value={filters.colorIn} onChange={e=>setFilter('colorIn',e.target.value)}>
        <option>Alle</option>{colIn.map(d=><option key={d}>{d}</option>)}</select>
    </Group>
    {Object.keys(EQUIP).map(cat=>
      <Group key={cat} title={'Ausstattung · '+cat}>
        <div className="adv-equip">{EQUIP[cat].map(item=>
          <Check key={item} label={item} checked={filters.equip.indexOf(item)!==-1} onChange={()=>toggle('equip',item)}
            count={M.filter(v=>window.voitelHasEquip(v,item)).length}/>)}</div>
      </Group>)}
  </div>
  <footer>
    <button className="adv-reset" onClick={resetFilters}>Zurücksetzen</button>
    <button className="adv-apply" onClick={onClose}>{resultCount} Fahrzeuge anzeigen</button>
  </footer>
</div></div>;
}

function PortalCard({v,onOpen,compareSelected,onToggleCompare,compareDisabled,isFavorite,onToggleFavorite}){
const oldPrice=Math.round(v.price*1.12/100)*100;
const photos=v.photos&&v.photos.length?v.photos.slice(0,5):null;
const totalFrames=photos?photos.length+1:2;
const [frame,setFrame]=React.useState(0);
const [hovered,setHovered]=React.useState(false);
const [open,setOpen]=React.useState(false);
const [showContact,setShowContact]=React.useState(false);
const msg=encodeURIComponent(`Hallo, ich interessiere mich für den ${v.brand} ${v.model} mit dem Preisschild von ${window.fmtPrice(v.price)}. ${location.href}`);
function prevFrame(e){e.stopPropagation();setFrame(f=>(f-1+totalFrames)%totalFrames);}
function nextFrame(e){e.stopPropagation();setFrame(f=>(f+1)%totalFrames);}
return <div className="v-card" onClick={()=>onOpen(v)} style={{cursor:'pointer',background:'#fff',borderRadius:'var(--radius-m)',overflow:'hidden'}}>
{v._groupCount>1&&<div className="mkt-count-badge">{v._groupCount} verfügbar</div>}
{window.voitelIsFresh&&window.voitelIsFresh(v)&&<div className="mkt-fresh-badge">Frisch eingetroffen</div>}
<div onMouseEnter={()=>setHovered(true)} onMouseLeave={()=>{setHovered(false);setFrame(0);}} style={{position:'relative',height:190,overflow:'hidden',background:photos?(frame<photos.length?`url(${photos[frame]}) center/cover`:'#1a1a1a'):(frame===0?v.img.light:v.img.dark),transition:'background .25s ease'}}>
{photos&&frame===photos.length&&<div onClick={e=>{e.stopPropagation();onOpen(v);}} style={{position:'absolute',inset:0,display:'flex',alignItems:'center',justifyContent:'center'}}>
<span style={{background:'#fff',color:'var(--fg-primary)',fontSize:13,fontWeight:700,padding:'10px 20px',borderRadius:999}}>Fahrzeug ansehen</span>
</div>}
{photos&&(hovered||isTouchDevice)&&<React.Fragment>
<button onClick={prevFrame} aria-label="Vorheriges Bild" style={{position:'absolute',left:8,top:'50%',transform:'translateY(-50%)',width:28,height:28,borderRadius:'50%',border:'none',background:'rgba(255,255,255,.9)',cursor:'pointer',display:'flex',alignItems:'center',justifyContent:'center',zIndex:2}}><img src="https://unpkg.com/lucide-static@0.469.0/icons/chevron-left.svg" width={14}/></button>
<button onClick={nextFrame} aria-label="Nächstes Bild" style={{position:'absolute',right:8,top:'50%',transform:'translateY(-50%)',width:28,height:28,borderRadius:'50%',border:'none',background:'rgba(255,255,255,.9)',cursor:'pointer',display:'flex',alignItems:'center',justifyContent:'center',zIndex:2}}><img src="https://unpkg.com/lucide-static@0.469.0/icons/chevron-right.svg" width={14}/></button>
<div style={{position:'absolute',bottom:8,left:0,right:0,display:'flex',justifyContent:'center',gap:4}}>
{Array.from({length:totalFrames}).map((_,i)=><div key={i} style={{width:5,height:5,borderRadius:'50%',background:i===frame?'#fff':'rgba(255,255,255,.5)'}}/>)}
</div>
</React.Fragment>}
<div style={{position:'absolute',top:8,right:8,display:'flex',flexDirection:'column',gap:6,alignItems:'flex-end'}} onClick={e=>e.stopPropagation()}>
<div onClick={()=>onToggleFavorite(v)} style={{width:26,height:26,borderRadius:'50%',background:isFavorite?'var(--brand-600)':'rgba(255,255,255,.9)',display:'flex',alignItems:'center',justifyContent:'center',cursor:'pointer'}}><img src="https://unpkg.com/lucide-static@0.469.0/icons/heart.svg" width={13} style={isFavorite?{filter:'invert(1)'}:{}}/></div>
<label style={{display:'flex',alignItems:'center',justifyContent:'center',width:26,height:26,borderRadius:'50%',background:compareSelected?'var(--brand-600)':'rgba(255,255,255,.9)',cursor:compareDisabled&&!compareSelected?'not-allowed':'pointer'}} title="Vergleichen">
<input type="checkbox" checked={compareSelected} disabled={compareDisabled&&!compareSelected} onChange={()=>onToggleCompare(v)} style={{width:12,height:12}}/>
</label>
</div>
<div onClick={e=>e.stopPropagation()} style={{position:'absolute',inset:0,background:'#fff',transform:open?'translateY(0)':'translateY(100%)',transition:'transform .32s cubic-bezier(.2,.8,.2,1)',zIndex:5,display:'flex',flexDirection:'column',justifyContent:'center',padding:16}}>
<div style={{display:'grid',gridTemplateColumns:'1fr 1fr',gap:'6px 12px',fontSize:12}}>
<span style={{color:'var(--fg-muted)'}}>Marke</span><span style={{fontWeight:700}}>{v.brand}</span>
<span style={{color:'var(--fg-muted)'}}>Modell</span><span style={{fontWeight:700}}>{v.model}</span>
<span style={{color:'var(--fg-muted)'}}>Preis</span><span style={{fontWeight:700}}>{window.fmtPrice(v.price)}</span>
<span style={{color:'var(--fg-muted)'}}>Kilometerstand</span><span style={{fontWeight:700}}>{v.km.toLocaleString('de-DE')} km</span>
<span style={{color:'var(--fg-muted)'}}>Leasing</span><span style={{fontWeight:700}}>{v.leasing?'Ja':'Nein'}</span>
<span style={{color:'var(--fg-muted)'}}>Rückkauf</span><span style={{fontWeight:700}}>{v.buyback?'Ja':'Nein'}</span>
</div>
<div style={{display:'flex',gap:8,marginTop:12}}>
<button onClick={()=>onOpen(v)} style={{flex:1,border:'1px solid var(--border-default)',background:'#fff',color:'var(--fg-primary)',borderRadius:'var(--radius-m)',padding:'7px',fontSize:11,fontWeight:700,cursor:'pointer',fontFamily:'var(--font-body)'}}>Fahrzeug ansehen</button>
<button onClick={e=>{e.stopPropagation();setShowContact(true);}} style={{flex:1,border:'none',background:'var(--brand-600)',color:'#fff',borderRadius:'var(--radius-m)',padding:'7px',fontSize:11,fontWeight:700,cursor:'pointer',fontFamily:'var(--font-body)'}}>Kontakt</button>
</div>
</div>
{showContact&&<div onClick={e=>{e.stopPropagation();setShowContact(false);}} style={{position:'fixed',inset:0,background:'rgba(11,27,46,.5)',zIndex:300,display:'flex',alignItems:'center',justifyContent:'center'}}>
<div onClick={e=>e.stopPropagation()} style={{background:'#fff',borderRadius:'var(--radius-l)',boxShadow:'var(--shadow-overlay)',padding:24,width:'min(360px,90vw)',fontFamily:'var(--font-body)',display:'flex',flexDirection:'column',gap:12}}>
<div style={{display:'flex',justifyContent:'space-between',alignItems:'center'}}>
<span style={{fontWeight:800,fontSize:16}}>Kontakt aufnehmen</span>
<button onClick={()=>setShowContact(false)} style={{border:'none',background:'none',fontSize:20,cursor:'pointer',color:'var(--fg-muted)'}}>×</button>
</div>
<p style={{margin:0,fontSize:13,color:'var(--fg-muted)'}}>{v.brand} {v.model}</p>
<a href="tel:+493741557777" style={{textDecoration:'none'}}><div style={{border:'1px solid var(--border-default)',borderRadius:'var(--radius-m)',padding:'12px 14px',display:'flex',alignItems:'center',gap:10,fontSize:14,fontWeight:600,color:'var(--fg-primary)'}}><img src="https://unpkg.com/lucide-static@0.469.0/icons/phone.svg" width={16}/>Jetzt anrufen</div></a>
<a href={`https://wa.me/491757120472?text=${msg}`} target="_blank" rel="noreferrer" style={{textDecoration:'none'}}><div style={{border:'1px solid var(--border-default)',borderRadius:'var(--radius-m)',padding:'12px 14px',display:'flex',alignItems:'center',gap:10,fontSize:14,fontWeight:600,color:'var(--fg-primary)'}}><img src="https://unpkg.com/lucide-static@0.469.0/icons/message-circle.svg" width={16}/>Per WhatsApp</div></a>
<a href={`mailto:anfrage@auto-voitel.de?subject=${encodeURIComponent(v.brand+' '+v.model)}&body=${msg}`} style={{textDecoration:'none'}}><div style={{border:'1px solid var(--border-default)',borderRadius:'var(--radius-m)',padding:'12px 14px',display:'flex',alignItems:'center',gap:10,fontSize:14,fontWeight:600,color:'var(--fg-primary)'}}><img src="https://unpkg.com/lucide-static@0.469.0/icons/mail.svg" width={16}/>Per E-Mail</div></a>
</div>
</div>}
</div>
<div style={{padding:'12px 14px'}}>
<div style={{fontWeight:700,fontSize:14,fontFamily:'var(--font-body)'}}>{v.brand} {v.model}</div>
<div style={{fontSize:12,color:'var(--fg-muted)',margin:'3px 0'}}>{v.km.toLocaleString('de-DE')} km · {v.fuel} · {v.power} PS</div>
<div style={{display:'flex',justifyContent:'space-between',alignItems:'center',gap:8,marginTop:4}}>
<div style={{display:'flex',alignItems:'baseline',gap:8}}>
<span style={{fontFamily:'var(--font-display)',fontWeight:800,fontSize:16,color:'var(--fg-brand)'}}>{window.fmtPrice(v.price)}</span>
<span style={{fontSize:12,color:'var(--fg-muted)',textDecoration:'line-through'}}>{window.fmtPrice(oldPrice)}</span>
</div>
<button onClick={e=>{e.stopPropagation();setOpen(o=>!o);}} style={{flex:'none',border:'1px solid '+(open?'var(--brand-600)':'var(--border-default)'),background:open?'var(--brand-600)':'#fff',color:open?'#fff':'var(--fg-secondary)',fontSize:11,fontWeight:700,padding:'6px 12px',borderRadius:999,cursor:'pointer',fontFamily:'var(--font-body)',whiteSpace:'nowrap'}}>{open?'Details schließen':'Details anzeigen'}</button>
</div>
</div></div>;
}
function HeroCard({hero,onOpenVehicle,favorites,compareList,toggleCompare,onToggleFavorite}){
const photos=hero.photos&&hero.photos.length?hero.photos.slice(0,5):null;
const [frame,setFrame]=React.useState(0);
const [hovered,setHovered]=React.useState(false);
function prevFrame(e){e.stopPropagation();setFrame(f=>(f-1+photos.length)%photos.length);}
function nextFrame(e){e.stopPropagation();setFrame(f=>(f+1)%photos.length);}
return <div onClick={()=>onOpenVehicle(hero)} className="v-card mkt-hero-card" style={{cursor:'pointer',borderRadius:'var(--radius-m)',overflow:'hidden',height:'100%',display:'flex',flexDirection:'column'}}>
{hero._groupCount>1&&<div className="mkt-count-badge mkt-count-badge-hero">{hero._groupCount} verfügbar</div>}
{window.voitelIsFresh&&window.voitelIsFresh(hero)&&<div className="mkt-fresh-badge">Frisch eingetroffen</div>}
<div className="mkt-hero-image" onMouseEnter={()=>setHovered(true)} onMouseLeave={()=>{setHovered(false);setFrame(0);}} style={{position:'relative',background:photos?`url(${photos[frame]}) center/cover`:hero.img.light,minHeight:280,flex:1,display:'flex',flexDirection:'column',justifyContent:'flex-end'}}>
<div className="mkt-hero-scrim" style={{background:'linear-gradient(0deg,rgba(20,20,20,.75),transparent 60%)',position:'absolute',inset:0}}/>
{photos&&photos.length>1&&(hovered||isTouchDevice)&&<React.Fragment>
<button onClick={prevFrame} aria-label="Vorheriges Bild" style={{position:'absolute',left:10,top:'50%',transform:'translateY(-50%)',width:32,height:32,borderRadius:'50%',border:'none',background:'rgba(255,255,255,.9)',cursor:'pointer',display:'flex',alignItems:'center',justifyContent:'center',zIndex:2}}><img src="https://unpkg.com/lucide-static@0.469.0/icons/chevron-left.svg" width={16}/></button>
<button onClick={nextFrame} aria-label="Nächstes Bild" style={{position:'absolute',right:10,top:'50%',transform:'translateY(-50%)',width:32,height:32,borderRadius:'50%',border:'none',background:'rgba(255,255,255,.9)',cursor:'pointer',display:'flex',alignItems:'center',justifyContent:'center',zIndex:2}}><img src="https://unpkg.com/lucide-static@0.469.0/icons/chevron-right.svg" width={16}/></button>
<div style={{position:'absolute',bottom:10,left:0,right:0,display:'flex',justifyContent:'center',gap:5,zIndex:2}}>
{photos.map((_,i)=><div key={i} style={{width:6,height:6,borderRadius:'50%',background:i===frame?'#fff':'rgba(255,255,255,.5)'}}/>)}
</div>
</React.Fragment>}
<div style={{position:'absolute',top:10,right:10,display:'flex',gap:8}} onClick={e=>e.stopPropagation()}>
<div onClick={()=>onToggleFavorite(hero)} style={{width:30,height:30,borderRadius:'50%',background:favorites.find(x=>x.id===hero.id)?'var(--brand-600)':'rgba(255,255,255,.9)',display:'flex',alignItems:'center',justifyContent:'center',cursor:'pointer'}}><img src="https://unpkg.com/lucide-static@0.469.0/icons/heart.svg" width={15} style={favorites.find(x=>x.id===hero.id)?{filter:'invert(1)'}:{}}/></div>
<label style={{display:'flex',alignItems:'center',justifyContent:'center',width:30,height:30,borderRadius:'50%',background:compareList.find(x=>x.id===hero.id)?'var(--brand-600)':'rgba(255,255,255,.9)',cursor:compareList.length>=3&&!compareList.find(x=>x.id===hero.id)?'not-allowed':'pointer'}} title="Vergleichen">
<input type="checkbox" checked={!!compareList.find(x=>x.id===hero.id)} disabled={compareList.length>=2&&!compareList.find(x=>x.id===hero.id)} onChange={()=>toggleCompare(hero)} style={{width:13,height:13}}/>
</label>
</div>
<div className="mkt-hero-overlay-info" style={{position:'relative',padding:18,color:'#fff'}}><div style={{fontFamily:'var(--font-display)',fontWeight:800,fontSize:22}}>{hero.brand} {hero.model}</div><div style={{display:'flex',alignItems:'baseline',gap:10,marginTop:4}}><span style={{fontFamily:'var(--font-display)',fontWeight:800,fontSize:20}}>{window.fmtPrice(hero.price)}</span><span style={{fontSize:14,opacity:.7,textDecoration:'line-through'}}>{window.fmtPrice(Math.round(hero.price*1.12/100)*100)}</span></div></div>
</div>
<div className="mkt-hero-panel-info" style={{display:'none',padding:'12px 14px',background:'#fff',color:'var(--fg-primary)'}}>
<div style={{fontWeight:700,fontSize:16,fontFamily:'var(--font-display)'}}>{hero.brand} {hero.model}</div>
{hero.km!=null&&<div style={{fontSize:12,color:'var(--fg-muted)',margin:'3px 0'}}>{hero.km.toLocaleString('de-DE')} km · {hero.fuel} · {hero.power} PS</div>}
<div style={{display:'flex',justifyContent:'space-between',alignItems:'center',gap:8,marginTop:4}}>
<div style={{display:'flex',alignItems:'baseline',gap:8}}>
<span style={{fontFamily:'var(--font-display)',fontWeight:800,fontSize:16,color:'var(--fg-brand)'}}>{window.fmtPrice(hero.price)}</span>
<span style={{fontSize:12,color:'var(--fg-muted)',textDecoration:'line-through'}}>{window.fmtPrice(Math.round(hero.price*1.12/100)*100)}</span>
</div>
<button onClick={e=>{e.stopPropagation();onOpenVehicle(hero);}} style={{flex:'none',border:'1px solid var(--border-default)',background:'#fff',color:'var(--fg-secondary)',fontSize:11,fontWeight:700,padding:'6px 12px',borderRadius:999,cursor:'pointer',fontFamily:'var(--font-body)',whiteSpace:'nowrap'}}>Details anzeigen</button>
</div>
</div>
</div>;
}
function MarketScreenPortal({onOpenVehicle,onOpenSavedSearch,onOpenTradeIn,compareList,setCompareList,onOpenCompare,favorites,onToggleFavorite,onLimitReached}){
const {Select,Button,Badge,Input}=window.AutohausVoitelDesignSystem_21e950;
const [searchOpen,setSearchOpen]=React.useState(false);
const [recentSearches,setRecentSearches]=React.useState(()=>{try{return JSON.parse(localStorage.getItem('voitel_recent_searches')||'[]');}catch(e){return [];}});
const searchWrapRef=React.useRef(null);
const suggestions=['Elektrofahrzeug mit hoher Reichweite','Puma Gen-E unter 30.000 km','Kombi mit Anhängerkupplung'];
function commitSearch(q){
if(!q)return;
setFilter('modelText',q);
setRecentSearches(prev=>{const next=[q,...prev.filter(x=>x!==q)].slice(0,5);try{localStorage.setItem('voitel_recent_searches',JSON.stringify(next));}catch(e){}return next;});
setSearchOpen(false);
setBrowseAll(true);
}
React.useEffect(()=>{
function onDocClick(e){if(searchWrapRef.current&&!searchWrapRef.current.contains(e.target))setSearchOpen(false);}
document.addEventListener('mousedown',onDocClick);
return ()=>document.removeEventListener('mousedown',onDocClick);
},[]);
function toggleCompare(v){setCompareList(cl=>{if(cl.find(x=>x.id===v.id))return cl.filter(x=>x.id!==v.id);if(cl.length>=2){onLimitReached&&onLimitReached();return cl;}return [...cl,v];});}
const count=window.VOITEL_MARKET.length;
/* 'Frisch eingetroffen' is driven by firstSeenDate, not hardcoded ids.
   Newest first; the hero is the newest arrival. */
const freshList=window.voitelCollapse(window.VOITEL_MARKET
  .filter(v=>window.voitelIsFresh&&window.voitelIsFresh(v))
  .sort((a,b)=>new Date(b.firstSeenDate)-new Date(a.firstSeenDate)));
const hero=freshList[0]||window.VOITEL_MARKET.find(v=>v.offer)||window.VOITEL_MARKET[0];
const dayDeals=freshList.slice(1,5);

const emptyFilters={brand:'Alle Marken',modelText:'',yearFrom:'',type:'Alle Typen',transmission:'Alle',fuel:'Alle',priceMin:'',priceMax:'',kmMax:'',dispMin:'',powerMin:'',seats:'Alle',electric:false,offer:false,/* advanced search */ brands:[],modelExt:'',bodyCats:[],usage:[],fuels:[],priceFrom:'',priceTo:'',vat:false,finFrom:'',finTo:'',leaseFrom:'',leaseTo:'',drive:'Alle',colorOut:'Alle',colorIn:'Alle',equip:[]};
/* The results view is a real step in the journey, so it gets its own history
   entry. Without one, Back from an open vehicle popped straight past the
   results to the portal landing, because browseAll lived only in React state
   and nothing in the URL described it. Every existing setBrowseAll call site
   keeps working - the wrapper just syncs the URL alongside the state. */
var VIEW_DEFAULT=false;   /* this page opens on the portal landing */
const [browseAll,setBrowseAllState]=React.useState(function(){
  try{var p=new URLSearchParams(location.search);return p.has('view')?p.get('view')==='results':VIEW_DEFAULT;}catch(e){return VIEW_DEFAULT;}
});
function setBrowseAll(on){
  setBrowseAllState(on);
  try{
    var u=new URL(location.href);
    u.searchParams.set('view',on?'results':'landing');
    u.searchParams.delete('vehicle');
    var next=u.pathname+u.search;
    if(next!==location.pathname+location.search)
      history.pushState(Object.assign({},history.state||{},{view:on?'results':null}),'',next);
  }catch(e){}
}
React.useEffect(function(){
  function syncFromUrl(){
    try{
      var p=new URLSearchParams(location.search);
      setBrowseAllState(p.has('view')?p.get('view')==='results':VIEW_DEFAULT);
      /* restore the search as well, or Back lands on the results with
         everyone else's filters */
      var s=voitelReadSearch();
      setFiltersState(s.filters);
      setSort(s.sort);
      setFreshOnly(p.get('fresh')==='1'||window.VOITEL_FRESH_ONLY===true);
    }catch(e){}
  }
  window.addEventListener('popstate',syncFromUrl);
  return function(){window.removeEventListener('popstate',syncFromUrl);};
},[]);
const [freshOnly,setFreshOnly]=React.useState(function(){try{return window.VOITEL_FRESH_ONLY===true||new URLSearchParams(location.search).get('fresh')==='1';}catch(e){return window.VOITEL_FRESH_ONLY===true;}});
const [advOpen,setAdvOpen]=React.useState(false);
/* The search lives in the URL, so Back returns to the results the visitor was
   actually reading - and so a search can be shared or bookmarked. One named
   parameter per filter (?brand=Ford&model=Kuga) rather than an encoded blob.
   Only values that differ from the defaults are written, so a plain listing
   URL stays clean. */
var VOITEL_SEARCH_PARAMS={
  brand:'brand', modelText:'model', yearFrom:'year', type:'type',
  transmission:'transmission', fuel:'fuel', priceMin:'priceMin', priceMax:'priceMax',
  kmMax:'kmMax', dispMin:'dispMin', powerMin:'powerMin', seats:'seats',
  electric:'electric', offer:'offer',
  /* Erweiterte Suche */
  brands:'brands', modelExt:'modelExt', bodyCats:'bodyCats', usage:'usage', fuels:'fuels',
  priceFrom:'priceFrom', priceTo:'priceTo', vat:'vat',
  finFrom:'finFrom', finTo:'finTo', leaseFrom:'leaseFrom', leaseTo:'leaseTo',
  drive:'drive', colorOut:'colorOut', colorIn:'colorIn', equip:'equip'
};
function voitelReadSearch(){
  var out={filters:Object.assign({},emptyFilters),sort:'Neu hinzugefügt'};
  try{
    var q=new URLSearchParams(location.search);
    /* links shared before the readable parameters landed */
    var legacy=q.get('f');
    if(legacy)out.filters=Object.assign({},emptyFilters,JSON.parse(legacy));
    Object.keys(VOITEL_SEARCH_PARAMS).forEach(function(k){
      var p=VOITEL_SEARCH_PARAMS[k];
      if(!q.has(p))return;
      var raw=q.get(p), def=emptyFilters[k];
      if(Array.isArray(def)) out.filters[k]=raw?raw.split(',').filter(Boolean):[];
      else if(typeof def==='boolean') out.filters[k]=(raw==='1'||raw==='true');
      else out.filters[k]=raw;
    });
    if(q.get('sort'))out.sort=q.get('sort');
  }catch(e){}
  return out;
}
var voitelInitialSearch=voitelReadSearch();
const [sort,setSort]=React.useState(voitelInitialSearch.sort);
const [filters,setFiltersState]=React.useState(voitelInitialSearch.filters);
function setFilter(k,v){setFiltersState(s=>({...s,[k]:v}));}
function resetFilters(){setFiltersState(emptyFilters);}
/* replaceState, not push: narrowing a search refines the current view rather
   than adding a step, so Back still leaves the results in one go - but the
   entry the vehicle pushes on top carries the search with it. */
React.useEffect(function(){
  try{
    var u=new URL(location.href);
    Object.keys(VOITEL_SEARCH_PARAMS).forEach(function(k){
      var p=VOITEL_SEARCH_PARAMS[k], v=filters[k], def=emptyFilters[k];
      if(JSON.stringify(v)===JSON.stringify(def)){u.searchParams.delete(p);return;}
      if(Array.isArray(v))u.searchParams.set(p,v.join(','));
      else if(typeof v==='boolean')u.searchParams.set(p,'1');
      else u.searchParams.set(p,String(v));
    });
    u.searchParams.delete('f');   /* superseded by the named parameters */
    if(sort&&sort!=='Neu hinzugefügt')u.searchParams.set('sort',sort); else u.searchParams.delete('sort');
    if(freshOnly)u.searchParams.set('fresh','1'); else u.searchParams.delete('fresh');
    var next=u.pathname+decodeURIComponent(u.search).replace(/ /g,'%20');
    if(next!==location.pathname+decodeURIComponent(location.search).replace(/ /g,'%20'))
      history.replaceState(history.state,'',next);
  }catch(e){}
},[filters,sort,freshOnly]);
let list=window.VOITEL_MARKET.filter(v=>{
if(freshOnly&&!(window.voitelIsFresh&&window.voitelIsFresh(v)))return false;
/* --- Erweiterte Suche --- */
if(filters.brands.length&&filters.brands.indexOf(v.brand)===-1)return false;
if(filters.modelExt&&!String(v.modelExtension||v.model||'').toLowerCase().includes(filters.modelExt.toLowerCase()))return false;
if(filters.bodyCats.length&&filters.bodyCats.indexOf(window.voitelBodyCategory(v.type))===-1)return false;
if(filters.usage.length&&filters.usage.indexOf(v.condition)===-1)return false;
if(filters.fuels.length&&!filters.fuels.some(f=>window.voitelFuelGroup(v.fuel)===f))return false;
if(filters.priceFrom&&v.price<Number(filters.priceFrom))return false;
if(filters.priceTo&&v.price>Number(filters.priceTo))return false;
if(filters.vat&&!v.vatDeductible)return false;
if(filters.drive!=='Alle'&&v.driveMechanism!==filters.drive)return false;
if(filters.colorOut!=='Alle'&&v.basePaintColor!==filters.colorOut)return false;
if(filters.colorIn!=='Alle'&&v.seatCoverBaseColor!==filters.colorIn)return false;
if(filters.equip.length&&!filters.equip.every(e=>window.voitelHasEquip(v,e)))return false;
/* Finanzierung / Leasing: no monthly-rate field exists in the API data, so these
   are intentionally NOT applied - see the notice rendered in the panel. */
if(filters.brand!=='Alle Marken'&&v.brand!==filters.brand)return false;
if(filters.modelText&&!(v.model+' '+v.brand).toLowerCase().includes(filters.modelText.toLowerCase()))return false;
/* v.type holds the raw AUTOMANAGER body name ("Geländewagen", "Coupé"),
   while the dropdown lists categories, so an exact match found almost
   nothing. Same grouping the Erweiterte Suche panel already uses. */
if(filters.type!=='Alle Typen'&&window.voitelBodyCategory(v.type)!==filters.type)return false;
if(filters.transmission!=='Alle'&&v.transmission!==filters.transmission)return false;
if(filters.fuel!=='Alle'&&window.voitelFuelGroup(v.fuel)!==filters.fuel)return false;
/* v.fuel holds raw values ("Super", "Plug-In-Hybrid (Benzin/Elektro)"), so an
   exact match against the dropdown's groups only ever hit a handful. */
if(filters.yearFrom){var _y=String(v.firstReg||'').match(/(\d{4})/); if(!_y||Number(_y[1])<Number(filters.yearFrom))return false;}
if(filters.priceMin&&v.price<Number(filters.priceMin))return false;
if(filters.priceMax&&v.price>Number(filters.priceMax))return false;
if(filters.kmMax&&v.km>Number(filters.kmMax))return false;
if(filters.dispMin&&v.displacement<Number(filters.dispMin))return false;
if(filters.powerMin&&v.power<Number(filters.powerMin))return false;
if(filters.seats!=='Alle'&&!(filters.seats==='7+'?v.seats>=7:v.seats===Number(filters.seats)))return false;
if(filters.electric&&!v.electric)return false;
if(filters.offer&&!v.offer)return false;
return true;
});
if(sort==='Preis aufsteigend')list=[...list].sort((a,b)=>a.price-b.price);
else if(sort==='Preis absteigend')list=[...list].sort((a,b)=>b.price-a.price);
else if(sort==='Verfügbare Angebote')list=list.filter(v=>v.offer);
else list=[...list].sort((a,b)=>new Date(b.added)-new Date(a.added));
/* The cards stay collapsed - one per group - but every count reported to
   the visitor is of real inventory units, so a group of 6 identical vans
   counts 6. Taken before the collapse, after all filtering. */
const unitCount=list.length;
/* collapse duplicate listings to one card per group (listing view only) */
list=window.voitelCollapse?window.voitelCollapse(list):list;
const FilterPanel=window.FilterPanelExport;
const [mobileFiltersOpen,setMobileFiltersOpen]=React.useState(false);
if(browseAll)return <div style={{fontFamily:'var(--font-body)'}}>
<AdvSearchPanel open={advOpen} onClose={()=>setAdvOpen(false)} filters={filters} setFilter={setFilter} resetFilters={resetFilters} resultCount={unitCount}/>
<div className="mkt-browse-page-content" style={{maxWidth:'var(--container-max)',margin:'0 auto',padding:'24px'}}>
<div style={{display:'flex',alignItems:'center',gap:16,marginBottom:20}}>
<button className="mkt-filter-toggle-btn" onClick={()=>setMobileFiltersOpen(true)} aria-label="Suche &amp; Filter" style={{display:'none',alignItems:'center',justifyContent:'center',gap:10,border:'none',background:'var(--brand-600)',borderRadius:999,width:88,height:56,padding:0,cursor:'pointer',flexShrink:0}}><img src="https://unpkg.com/lucide-static@0.469.0/icons/search.svg" width={20} style={{filter:'invert(1)'}}/><img src="https://unpkg.com/lucide-static@0.469.0/icons/car.svg" width={22} style={{filter:'invert(1)'}}/></button>
<button onClick={()=>setBrowseAll(false)} style={{border:'none',background:'none',color:'var(--fg-brand)',fontWeight:600,fontSize:14,cursor:'pointer',padding:0}}>← Zurück zur Suche</button>
</div>
<div className="mkt-modelzusatz-row" style={{marginBottom:16}}>
<Input placeholder="Modellzusatz (z.B. ST-Line, Titanium)" value={filters.modelText} onChange={e=>setFilter('modelText',e.target.value)}/>
</div>
<div className="mkt-browse-grid" style={{display:'grid',gridTemplateColumns:'260px minmax(0,1fr)',gap:28}}>
<div className="mkt-filter-sidebar" style={{position:'sticky',top:24,alignSelf:'start',background:'#fff',border:'1px solid var(--border-subtle)',borderRadius:'var(--radius-m)',padding:20}}>
<FilterPanel filters={filters} setFilter={setFilter} resultCount={unitCount} onReset={resetFilters}/>
</div>
{mobileFiltersOpen&&<div className="mkt-filter-modal-backdrop" onClick={()=>setMobileFiltersOpen(false)} style={{position:'fixed',inset:0,background:'rgba(20,20,20,.5)',zIndex:200,display:'flex',alignItems:'flex-end',overflow:'hidden'}}>
<div data-lenis-prevent onClick={e=>e.stopPropagation()} style={{background:'#fff',borderRadius:'20px 20px 0 0',padding:20,width:'100%',maxHeight:vvh(80),overflowY:'auto',WebkitOverflowScrolling:'touch',overscrollBehavior:'contain',touchAction:'pan-y'}}>
<div style={{display:'flex',justifyContent:'flex-end',marginBottom:8}}><button onClick={()=>setMobileFiltersOpen(false)} style={{border:'none',background:'none',fontSize:22,cursor:'pointer',lineHeight:1,padding:8}}>×</button></div>
<button className="adv-open-results adv-open-inmodal" onClick={()=>{setMobileFiltersOpen(false);setAdvOpen(true);}} style={{width:'100%',justifyContent:'center',marginBottom:14}}><img src="https://unpkg.com/lucide-static@0.469.0/icons/sliders-horizontal.svg" width={15}/>Erweiterte Suche</button> <div style={{marginBottom:16}}><Input placeholder="Modellzusatz (z.B. ST-Line, Titanium)" value={filters.modelText} onChange={e=>setFilter('modelText',e.target.value)}/></div>
<FilterPanel filters={filters} setFilter={setFilter} resultCount={unitCount} onReset={resetFilters}/>
<button onClick={()=>setMobileFiltersOpen(false)} style={{width:'100%',marginTop:16,background:'var(--fg-brand)',color:'#fff',border:'none',borderRadius:'var(--radius-m)',padding:'14px',fontSize:15,fontWeight:700,cursor:'pointer'}}>{unitCount} Fahrzeuge anzeigen</button>
</div>
</div>}
<div>
{/* The toolbar stays in view while the results scroll. top tracks the
    measured nav height, like the detail page's tab strip, and the negative
    margins let the white background span the column's padding so rows do
    not show through as they pass under it. */}
<div className="mkt-results-bar" style={{display:'flex',justifyContent:'space-between',alignItems:'center',marginBottom:16,flexWrap:'wrap',gap:10,position:'sticky',top:'var(--gnav-h,67px)',zIndex:40,background:'#fff',paddingTop:12,paddingBottom:12,marginLeft:-8,marginRight:-8,paddingLeft:8,paddingRight:8}}>
<div style={{fontSize:14,color:'var(--fg-muted)'}}>{unitCount} Fahrzeuge gefunden</div>

<Select label="" options={['Neu hinzugefügt','Preis aufsteigend','Preis absteigend','Verfügbare Angebote']} value={sort} onChange={e=>setSort(e.target.value)}/>
</div>
<div style={{display:'flex',flexDirection:'column',gap:14}}>
{[...list].sort((a,b)=>(b.photos&&b.photos.length?1:0)-(a.photos&&a.photos.length?1:0)).map(v=><ListingRow key={v.id} v={v} onOpen={onOpenVehicle} compareSelected={!!compareList.find(x=>x.id===v.id)} compareDisabled={compareList.length>=2} onToggleCompare={toggleCompare} isFavorite={!!favorites.find(x=>x.id===v.id)} onToggleFavorite={onToggleFavorite}/>)}
</div>
{list.length===0&&<NoResultsNotify onReset={resetFilters}/>}
</div>
</div>
</div>
{compareList.length>0&&<div className="mkt-compare-bar" style={{position:'fixed',bottom:0,left:0,right:0,background:'var(--navy-950)',color:'#fff',padding:'14px 24px',display:'flex',justifyContent:'center',gap:16,alignItems:'center',zIndex:50}}>
<span style={{fontSize:14}}>{compareList.length===1?'Fahrzeug 1 ausgewählt — wählen Sie noch ein Fahrzeug zum Vergleich':compareList.length+' Fahrzeuge zum Vergleich ausgewählt'}</span>
<div style={{display:'flex',gap:8}}>{compareList.map(v=><Badge key={v.id} tone="neutral">{v.model}</Badge>)}</div>
<Button variant="primary" size="s" onClick={onOpenCompare} disabled={compareList.length<2}>Vergleichen</Button>
<button onClick={()=>setCompareList([])} style={{border:'none',background:'none',color:'var(--fg-on-dark-muted)',cursor:'pointer',fontSize:13}}>Leeren</button>
</div>}
</div>;
return <div style={{fontFamily:'var(--font-body)'}}>
<AdvSearchPanel open={advOpen} onClose={()=>setAdvOpen(false)} filters={filters} setFilter={setFilter} resetFilters={resetFilters} resultCount={unitCount}/>
<div style={{position:'relative'}}>
<div className="mkt-hero-banner-img" style={{height:550,position:'relative',overflow:'hidden',margin:'0 32px',borderRadius:20}}>
<ImageCycle images={window.VOITEL_HERO_CYCLE} duration={5}/>

</div>
<div className="mkt-hero-search-card" style={{maxWidth:'min(920px,92vw)',margin:'-190px auto 0',background:'#fff',borderRadius:'var(--radius-l)',boxShadow:'var(--shadow-raised)',padding:28,position:'relative',display:'flex',flexDirection:'column',alignItems:'center',justifyContent:'center',textAlign:'center',zIndex:1}}>
<img className="mkt-hero-logo" src="assets/logos/voitel-favicon.svg" style={{height:64,marginTop:6}}/>
<div className="mkt-h1" style={{fontFamily:'var(--font-display)',fontWeight:800,fontSize:32,textAlign:'center',marginTop:16,marginBottom:18}}>Ihre Plattform für Neu- und Gebrauchtwagen</div>
<div ref={searchWrapRef} style={{position:'relative',width:'100%',marginBottom:14}}>
<img src="https://unpkg.com/lucide-static@0.469.0/icons/search.svg" width={18} style={{position:'absolute',left:16,top:'50%',transform:'translateY(-50%)',opacity:.5,zIndex:1}}/>
<input placeholder="z.B. Ford Puma ST-Line" value={filters.modelText} onFocus={()=>setSearchOpen(true)} onChange={e=>{setFilter('modelText',e.target.value);setSearchOpen(true);}} onKeyDown={e=>{if(e.key==='Enter')commitSearch(filters.modelText);}} style={{width:'100%',padding:'16px 16px 16px 46px',fontSize:16,borderRadius:'var(--radius-pill)',border:'1px solid var(--border-default)',outline:'none',fontFamily:'inherit',background:'#fff',color:'var(--fg-primary)',position:'relative'}}/>
{searchOpen&&<div style={{position:'absolute',top:'calc(100% + 8px)',left:0,right:0,background:'#fff',border:'1px solid var(--border-subtle)',borderRadius:'var(--radius-l)',boxShadow:'var(--shadow-raised)',zIndex:20,maxHeight:420,overflowY:'auto',padding:'10px 0'}}>
{filters.modelText.trim()===''?<React.Fragment>
{recentSearches.length>0&&<div style={{padding:'6px 18px'}}>
<div style={{display:'flex',justifyContent:'space-between',alignItems:'center',marginBottom:4}}>
<span style={{fontSize:12,fontWeight:700,color:'var(--fg-muted)',textTransform:'uppercase',letterSpacing:'.03em'}}>Zuletzt</span>
<button onClick={()=>{setRecentSearches([]);try{localStorage.removeItem('voitel_recent_searches');}catch(e){}}} style={{border:'none',background:'none',color:'var(--fg-brand)',fontSize:12,fontWeight:600,cursor:'pointer'}}>Alle löschen</button>
</div>
{recentSearches.map((q,i)=><div key={i} onClick={()=>commitSearch(q)} style={{display:'flex',alignItems:'center',gap:10,padding:'10px 0',cursor:'pointer',fontSize:14}}><img src="https://unpkg.com/lucide-static@0.469.0/icons/history.svg" width={15} style={{opacity:.5}}/>{q}</div>)}
</div>}
<div style={{padding:'6px 18px'}}>
<div style={{fontSize:12,fontWeight:700,color:'var(--fg-muted)',textTransform:'uppercase',letterSpacing:'.03em',marginBottom:4}}>Vorschläge</div>
{suggestions.map((s,i)=><div key={i} onClick={()=>commitSearch(s)} style={{display:'flex',alignItems:'center',gap:10,padding:'10px 0',cursor:'pointer',fontSize:14}}><img src="https://unpkg.com/lucide-static@0.469.0/icons/sparkles.svg" width={15} style={{color:'var(--fg-brand)',opacity:.7}}/>{s}</div>)}
</div>
</React.Fragment>:(()=>{
const q=filters.modelText.trim().toLowerCase();
const matches=window.VOITEL_MARKET.filter(v=>(v.brand+' '+v.model).toLowerCase().includes(q)).slice(0,5);
if(matches.length===0)return <div style={{padding:'24px 18px',textAlign:'center',color:'var(--fg-muted)',fontSize:14}}>😕 Kein Treffer für "{filters.modelText}"</div>;
return matches.map(v=><div key={v.id} onClick={()=>{setSearchOpen(false);onOpenVehicle(v);}} style={{display:'flex',alignItems:'center',gap:12,padding:'10px 18px',cursor:'pointer'}}>
<div style={{width:56,height:42,borderRadius:8,flex:'none',background:v.photos&&v.photos[0]?`url(${v.photos[0]}) center/cover`:v.img.light}}/>
<div style={{flex:1,minWidth:0}}>
<div style={{fontSize:14,fontWeight:700,whiteSpace:'nowrap',overflow:'hidden',textOverflow:'ellipsis'}}>{v.brand} {v.model}</div>
<div style={{fontSize:12,color:'var(--fg-muted)'}}>{v.km.toLocaleString('de-DE')} km · {v.fuel}</div>
</div>
<div style={{fontSize:14,fontWeight:800,color:'var(--fg-brand)',flex:'none'}}>{window.fmtPrice(v.price)}</div>
</div>);
})()}
</div>}
</div>
<div className="mkt-filter-grid" style={{display:'grid',gridTemplateColumns:'repeat(4,1fr)',gap:10,marginBottom:10,width:'100%'}}>
<Select label="" options={['Marke',...window.VOITEL_BRANDS]} value={filters.brand==='Alle Marken'?'Marke':filters.brand} onChange={e=>setFilter('brand',e.target.value==='Marke'?'Alle Marken':e.target.value)}/>
<Select label="" options={['Modell',...window.voitelModelOptions()]} value={filters.modelText||'Modell'} onChange={e=>setFilter('modelText',e.target.value==='Modell'?'':e.target.value)}/>
<Select label="" options={['Preis bis',...window.voitelPriceOptions()]} value={filters.priceMax?window.voitelPriceLabel(filters.priceMax):'Preis bis'} onChange={e=>setFilter('priceMax',e.target.value.replace(/\D/g,''))}/>
<Select label="" options={['Baujahr ab',...window.voitelYearOptions()]} value={filters.yearFrom||'Baujahr ab'} onChange={e=>setFilter('yearFrom',e.target.value==='Baujahr ab'?'':e.target.value)}/>
</div>
<div className="mkt-filter-grid" style={{display:'grid',gridTemplateColumns:'repeat(4,1fr)',gap:10,width:'100%'}}>
<Select label="" options={['Kraftstoff',...window.voitelFuelOptions()]} value={filters.fuel==='Alle'?'Kraftstoff':filters.fuel} onChange={e=>setFilter('fuel',e.target.value==='Kraftstoff'?'Alle':e.target.value)}/>
<Select label="" options={['Fahrzeugtyp',...window.voitelTypeOptions()]} value={filters.type==='Alle Typen'?'Fahrzeugtyp':filters.type} onChange={e=>setFilter('type',e.target.value==='Fahrzeugtyp'?'Alle Typen':e.target.value)}/>
<Button variant="outline" onClick={()=>setAdvOpen(true)} icon={<img src="https://unpkg.com/lucide-static@0.469.0/icons/sliders-horizontal.svg" width={16}/>}>Erweiterte Suche</Button>
<Button variant="primary" onClick={()=>setBrowseAll(true)} style={{whiteSpace:'nowrap',fontSize:13,padding:'10px 12px',width:'100%'}} icon={<img className="mkt-search-icon" src="assets/logos/search-icon.svg" width={18}/>}>{unitCount} Fahrzeuge</Button>
{/* Clearing a search one field at a time was not possible - several of
    them have no empty option. Shown only when there is something to
    clear, so it is never a control that does nothing. */}
{(function(){
  var dirty=freshOnly||Object.keys(emptyFilters).some(function(k){
    return JSON.stringify(filters[k])!==JSON.stringify(emptyFilters[k]);});
  if(!dirty)return null;
  return <button type="button" className="mkt-reset-all" onClick={function(){
    resetFilters(); setFreshOnly(false); setSort('Neu hinzugefügt');
  }}>Alle Filter zurücksetzen</button>;
})()}
</div>
</div>
<div style={{height:40}}></div>
</div>
<div style={{maxWidth:'var(--container-max)',margin:'0 auto',padding:'0 24px'}}>
<div className="mkt-quicklinks-row" data-lenis-prevent style={{display:'flex',gap:16,marginTop:8}}>
<button onClick={onOpenSavedSearch} style={{flex:1,background:'var(--brand-50,#fdeceb)',border:'none',borderRadius:'var(--radius-l)',padding:'24px',textAlign:'left',cursor:'pointer',fontFamily:'var(--font-body)',minHeight:150,position:'relative',overflow:'hidden'}}><img src="https://unpkg.com/lucide-static@0.469.0/icons/bell.svg" width={28} style={{position:'absolute',top:20,right:20,opacity:.35}}/><div className="mkt-h3" style={{fontWeight:800,fontSize:19,fontFamily:'var(--font-display)',maxWidth:'75%'}}>Suche speichern</div><div style={{fontWeight:400,fontSize:13,color:'var(--fg-secondary)',marginTop:8,maxWidth:'80%'}}>Wir benachrichtigen Sie, sobald ein passendes Fahrzeug erscheint.</div></button>
<button onClick={onOpenTradeIn} style={{flex:1,background:'var(--navy-50,#eaeef3)',border:'none',borderRadius:'var(--radius-l)',padding:'24px',textAlign:'left',cursor:'pointer',fontFamily:'var(--font-body)',minHeight:150,position:'relative',overflow:'hidden'}}><img src="https://unpkg.com/lucide-static@0.469.0/icons/car.svg" width={28} style={{position:'absolute',top:20,right:20,opacity:.35}}/><div className="mkt-h3" style={{fontWeight:800,fontSize:19,fontFamily:'var(--font-display)',maxWidth:'75%'}}>Fahrzeug in Zahlung geben</div><div style={{fontWeight:400,fontSize:13,color:'var(--fg-secondary)',marginTop:8,maxWidth:'80%'}}>Eine unverbindliche Einschätzung Ihres aktuellen Fahrzeugs.</div></button>
<button onClick={()=>window.voitelOpenAppointment&&window.voitelOpenAppointment()} style={{flex:1,background:'var(--surface-sunken,#f0efec)',border:'none',borderRadius:'var(--radius-l)',padding:'24px',textAlign:'left',cursor:'pointer',fontFamily:'var(--font-body)',minHeight:150,position:'relative',overflow:'hidden'}}><img src="https://unpkg.com/lucide-static@0.469.0/icons/wrench.svg" width={28} style={{position:'absolute',top:20,right:20,opacity:.35}}/><div className="mkt-h3" style={{fontWeight:800,fontSize:19,fontFamily:'var(--font-display)',maxWidth:'75%'}}>Werkstatt-Termin buchen</div><div style={{fontWeight:400,fontSize:13,color:'var(--fg-secondary)',marginTop:8,maxWidth:'80%'}}>Herstellerkonformer Service für alle Marken.</div></button>
</div>
</div>
<div style={{maxWidth:'var(--container-max)',margin:'0 auto',padding:'40px 24px 100px'}}>
<div style={{display:'flex',justifyContent:'space-between',alignItems:'baseline',marginBottom:16}}>
<div className="mkt-h2" style={{fontFamily:'var(--font-display)',fontWeight:800,fontSize:22}}>Frisch eingetroffen</div>
<a href="frisch-eingetroffen.html" className="mkt-seeall-top" style={{fontSize:13,fontWeight:600}}>Alle Fahrzeuge ansehen</a>
</div>
<div className="mkt-herodeals-grid" style={{display:'grid',gridTemplateColumns:'1.4fr 1fr 1fr',gap:16}}>
<HeroCard hero={hero} onOpenVehicle={onOpenVehicle} favorites={favorites} compareList={compareList} toggleCompare={toggleCompare} onToggleFavorite={onToggleFavorite}/>
<div className="mkt-daydeals-inner" style={{display:'grid',gridTemplateColumns:'1fr 1fr',gap:16,gridColumn:'span 2'}}>
{dayDeals.map(v=><PortalCard key={v.id} v={v} onOpen={onOpenVehicle} compareSelected={!!compareList.find(x=>x.id===v.id)} compareDisabled={compareList.length>=2} onToggleCompare={toggleCompare} isFavorite={!!favorites.find(x=>x.id===v.id)} onToggleFavorite={onToggleFavorite}/>)}
</div>
</div>
<a href="frisch-eingetroffen.html" className="mkt-seeall-btn" style={{display:'none',textAlign:'center',width:'100%',marginTop:16,fontSize:13,fontWeight:600,color:'var(--fg-brand)',textDecoration:'underline'}}>Alle Fahrzeuge ansehen</a>
<div style={{marginTop:56,marginBottom:20}}>
<div className="mkt-h2" style={{fontFamily:'var(--font-display)',fontWeight:800,fontSize:22,marginBottom:16}}>Fahrzeugtypen</div>
<div className="mkt-types-grid" data-lenis-prevent style={{display:'grid',gridTemplateColumns:'repeat(4,1fr)',gap:16,overflowX:'auto'}}>
{window.voitelBodyCounts().slice(0,4).map(function(c){
 var photo=window.voitelCategoryPhoto(c.category);
 return <div key={c.category} className="v-card" onClick={()=>{setFilter('bodyCats',[c.category]);setBrowseAll(true);}} style={{borderRadius:'var(--radius-m)',overflow:'hidden',cursor:'pointer'}}>
 <div style={{height:150,background:'var(--surface-sunken)',backgroundImage:photo?`url(${photo})`:'none',backgroundSize:'cover',backgroundPosition:'center'}}></div>
 <div style={{padding:'14px 16px'}}>
 <div style={{fontWeight:700,fontSize:15}}>{c.category}</div>
 <div style={{fontSize:12.5,color:'var(--fg-muted)',marginTop:2}}>{c.count} {c.count===1?'Fahrzeug':'Fahrzeuge'}</div>
 </div></div>;})}
</div>
</div>
<div style={{marginTop:56}}>
<div className="mkt-h2" style={{fontFamily:'var(--font-display)',fontWeight:800,fontSize:22,marginBottom:16}}>Beliebte Kategorien</div>
<div className="mkt-popcat-grid" data-lenis-prevent style={{display:'grid',gridTemplateColumns:'repeat(3,1fr)',gap:16}}>
{[['Familienautos',['5 Sitze','Van & Kombi','bis €65.000'],window.voitelCategoryPhoto('Van/Kleinbus')],['Sportlich',['ab 200 PS','Coupé & Sport','Top-Ausstattung'],window.voitelCategoryPhoto('Sportwagen/Coupé')],['Frisch eingetroffen',['neu im Bestand','geprüft','sofort verfügbar'],(window.VOITEL_MARKET.filter(window.voitelIsFresh)[0]||{photos:[]}).photos[0]]].map(([title,tags,img])=>
<div key={title} className="v-card" style={{borderRadius:'var(--radius-m)',overflow:'hidden',cursor:'pointer'}}>
<div style={{height:200,backgroundImage:`url(${img})`,backgroundSize:'cover',backgroundPosition:'center 65%'}}/>
<div style={{background:'#fff',padding:16}}>
<div style={{fontFamily:'var(--font-display)',fontWeight:700,fontSize:17,marginBottom:10}}>{title}</div>
<div style={{display:'flex',gap:6,flexWrap:'wrap'}}>{tags.map(t=><span key={t} style={{fontSize:11,fontWeight:600,color:'var(--fg-secondary)',background:'var(--surface-sunken)',padding:'4px 9px',borderRadius:'var(--radius-pill)'}}>{t}</span>)}</div>
</div></div>)}
</div></div>
</div>
<div style={{background:'var(--navy-950)',color:'#fff',padding:'48px 24px'}}>
<div style={{maxWidth:'var(--container-max)',margin:'0 auto'}}>
<div style={{fontFamily:'var(--font-display)',fontWeight:800,fontSize:24,marginBottom:28}}>Beliebte Marken &amp; mehr auf unserem Fahrzeugmarkt</div>
<div className="mkt-makes-grid" style={{display:'grid',gridTemplateColumns:'repeat(4,1fr)',gap:32,fontSize:14}}>
{[['Ford Gebrauchtwagen',['Ford Puma','Ford Kuga','Ford Focus','Ford Fiesta','Ford Ranger','Ford Mustang Mach-E']],
['Mitsubishi Gebrauchtwagen',['Mitsubishi ASX','Mitsubishi Eclipse Cross','Mitsubishi Space Star','Mitsubishi Outlander','Mitsubishi Colt','Mitsubishi L200']],
['Fahrzeugtypen',['SUV gebraucht','Kombi gebraucht','Kompakt gebraucht','Pickup gebraucht','Elektro gebraucht','Hybrid gebraucht']],
['Infos & Services',['Finanzierung','Leasing','Fahrzeug in Zahlung geben','Werkstatt-Termin','Gespeicherte Suche','Kontakt']]].map(([title,items])=>
<div key={title}>
<div style={{fontWeight:700,fontSize:15,marginBottom:14}}>{title}</div>
<div style={{display:'flex',flexDirection:'column',gap:10}}>
{items.map(it=><a key={it} href="#" onClick={e=>e.preventDefault()} style={{display:'flex',alignItems:'center',gap:6,color:'var(--fg-on-dark-muted)',fontSize:13}}><img src="https://unpkg.com/lucide-static@0.469.0/icons/chevron-right.svg" width={12} style={{filter:'invert(1)',opacity:.6}}/>{it}</a>)}
</div></div>)}
</div></div></div>
{compareList.length>0&&<div className="mkt-compare-bar" style={{position:'fixed',bottom:0,left:0,right:0,background:'var(--navy-950)',color:'#fff',padding:'14px 24px',display:'flex',justifyContent:'center',gap:16,alignItems:'center',zIndex:50}}>
<span style={{fontSize:14}}>{compareList.length===1?'Fahrzeug 1 ausgewählt — wählen Sie noch ein Fahrzeug zum Vergleich':compareList.length+' Fahrzeuge zum Vergleich ausgewählt'}</span>
<div style={{display:'flex',gap:8}}>{compareList.map(v=><Badge key={v.id} tone="neutral">{v.model}</Badge>)}</div>
<Button variant="primary" size="s" onClick={onOpenCompare} disabled={compareList.length<2}>Vergleichen</Button>
<button onClick={()=>setCompareList([])} style={{border:'none',background:'none',color:'var(--fg-on-dark-muted)',cursor:'pointer',fontSize:13}}>Leeren</button>
</div>}
</div>;
}
window.MarketScreenPortalExport=MarketScreenPortal;
window.ListingRow=ListingRow;
